Merge lp:~hipl-core/hipl/mobility-fixes into lp:hipl

Proposed by René Hummen
Status: Merged
Merged at revision: 5173
Proposed branch: lp:~hipl-core/hipl/mobility-fixes
Merge into: lp:hipl
Diff against target: 1095 lines (+338/-360)
21 files modified
firewall/conntrack.c (+1/-0)
hipd/esp_prot_hipd_msg.c (+1/-0)
hipd/esp_prot_light_update.c (+1/-0)
hipd/hadb.h (+0/-2)
hipd/hadb_legacy.h (+0/-12)
hipd/hipd.c (+0/-1)
hipd/hipd.h (+0/-2)
hipd/init.c (+1/-0)
hipd/input.c (+1/-0)
lib/core/builder.c (+6/-177)
lib/core/builder.h (+6/-10)
lib/core/debug.c (+1/-51)
lib/core/debug.h (+0/-6)
lib/core/protodefs.h (+0/-52)
lib/core/state.h (+0/-35)
modules/update/Makefile.am (+1/-0)
modules/update/hipd/update.c (+94/-12)
modules/update/hipd/update.h (+60/-0)
modules/update/hipd/update_builder.c (+111/-0)
modules/update/hipd/update_builder.h (+49/-0)
modules/update/hipd/update_legacy.c (+5/-0)
To merge this branch: bzr merge lp:~hipl-core/hipl/mobility-fixes
Reviewer Review Type Date Requested Status
Diego Biurrun Needs Fixing
Review via email: mp+41490@code.launchpad.net

Description of the change

This branch aims at further encapsulating mobility functionality in the update module. To this end, dead code was removed or has been moved where possible.

To post a comment you must log in.
Revision history for this message
Diego Biurrun (diego-biurrun) wrote :
Download full text (6.0 KiB)

On Mon, Nov 22, 2010 at 05:21:54PM +0000, René Hummen wrote:
> René Hummen has proposed merging lp:~hipl-core/hipl/mobility-fixes into lp:hipl.
>
> Requested reviews:
> HIPL core team (hipl-core)

Looks mostly good, I noticed some issues below.

 review needs-fixing

> --- modules/update/Makefile.am 2010-03-30 08:44:33 +0000
> +++ modules/update/Makefile.am 2010-11-22 17:21:23 +0000
> @@ -1,6 +1,7 @@
>
> modules_update_hipd_libhipupdate_la_SOURCES = modules/update/hipd/update.c \
> - modules/update/hipd/update_legacy.c
> + modules/update/hipd/update_legacy.c \
> + modules/update/hipd/update_builder.c

alphabetical order please

> --- modules/update/hipd/update.c 2010-11-12 16:42:54 +0000
> +++ modules/update/hipd/update.c 2010-11-22 17:21:23 +0000
> @@ -616,6 +622,88 @@
>
> /**
> + * Retreive a @c LOCATOR ADDRESS ITEM@c from a list.

The second @c looks misplaced, I don't think you wanted to markup "from".
I suggest you run 'make doxygen' and see if this really produces what
you intended to express.

> +static union hip_locator_info_addr *hip_get_locator_item(void *item_list, int idx)

needlessly long line

> +{
> + int i = 0;
> + struct hip_locator_info_addr_item *temp;
> + char *result;
> + result = (char *) item_list;

pointless void* cast

> + for (i = 0; i <= idx - 1; i++) {
> + temp = (struct hip_locator_info_addr_item *) result;
> + if (temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI ||
> + temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_IPV6) {
> + result += sizeof(struct hip_locator_info_addr_item);
> + } else {
> + result += sizeof(struct hip_locator_info_addr_item2);
> + }

The temp assignment looks useless, does the following (untested) work?

for (i = 0; i <= idx - 1; i++) {
    if (result->locator_type == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI ||
        result->locator_type == HIP_LOCATOR_LOCATOR_TYPE_IPV6) {
        result += sizeof(struct hip_locator_info_addr_item);
    } else {
        result += sizeof(struct hip_locator_info_addr_item2);
    }
}

> +/**
> + * Retrieve the amount the locators inside a LOCATOR parameter.

Doh?

> + * Type 1 and 2 parameters are supported.
> + *
> + * @param locator a LOCATOR parameter
> + * @return the amount of locators

s/amount/number/

> +int hip_get_locator_addr_item_count(const struct hip_locator *locator)
> +{
> + const char *address_pointer = (const char *) (locator + 1);
> + int amount = 0;
> + uint8_t type;
> +
> + while (address_pointer <
> + ((const char *) locator) + hip_get_param_contents_len(locator)) {
> + type = ((const struct hip_locator_info_addr_item *)
> + address_pointer)->locator_type;

address_pointer is never really used as char*, so it should possibly be
one of the types it is cast to. Also I wonder why you use const for a
variable that is assigned to later in the function.

> + if (type == HIP_LOCATOR_LOCATOR_TYPE_UDP) {
> + address_pointer += sizeof(struct hip_locator_inf...

Read more...

review: Needs Fixing
lp:~hipl-core/hipl/mobility-fixes updated
5183. By René Hummen

fixed alignment, spelling and incorporated feedback from mailinglist

Revision history for this message
René Hummen (rene-hummen) wrote :

I addressed the comments in rev 5182. If there are no further comments, I will commit the changes to trunk.

Revision history for this message
Diego Biurrun (diego-biurrun) wrote :

On Tue, Nov 23, 2010 at 02:44:28PM +0000, René Hummen wrote:
> I addressed the comments in rev 5182. If there are no further comments, I will commit the changes to trunk.

You left 10 minutes for "further comments".

If you wish to commit right away, commit right away, but if you wish to
hear further comments, leave a sensible timeframe for comments to
arrive...

Diego

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'firewall/conntrack.c'
--- firewall/conntrack.c 2010-10-27 11:27:48 +0000
+++ firewall/conntrack.c 2010-11-23 14:43:16 +0000
@@ -59,6 +59,7 @@
59#include "lib/core/prefix.h"59#include "lib/core/prefix.h"
60#include "lib/core/protodefs.h"60#include "lib/core/protodefs.h"
61#include "lib/tool/pk.h"61#include "lib/tool/pk.h"
62#include "modules/update/hipd/update.h"
62#include "common_types.h"63#include "common_types.h"
63#include "dlist.h"64#include "dlist.h"
64#include "esp_prot_conntrack.h"65#include "esp_prot_conntrack.h"
6566
=== modified file 'hipd/esp_prot_hipd_msg.c'
--- hipd/esp_prot_hipd_msg.c 2010-10-15 15:29:14 +0000
+++ hipd/esp_prot_hipd_msg.c 2010-11-23 14:43:16 +0000
@@ -45,6 +45,7 @@
45#include "lib/core/ife.h"45#include "lib/core/ife.h"
46#include "lib/core/protodefs.h"46#include "lib/core/protodefs.h"
47#include "lib/tool/xfrmapi.h"47#include "lib/tool/xfrmapi.h"
48#include "modules/update/hipd/update_builder.h"
48#include "cookie.h"49#include "cookie.h"
49#include "esp_prot_anchordb.h"50#include "esp_prot_anchordb.h"
50#include "esp_prot_light_update.h"51#include "esp_prot_light_update.h"
5152
=== modified file 'hipd/esp_prot_light_update.c'
--- hipd/esp_prot_light_update.c 2010-10-15 15:29:14 +0000
+++ hipd/esp_prot_light_update.c 2010-11-23 14:43:16 +0000
@@ -43,6 +43,7 @@
43#include "lib/core/ife.h"43#include "lib/core/ife.h"
44#include "lib/core/protodefs.h"44#include "lib/core/protodefs.h"
45#include "lib/tool/xfrmapi.h"45#include "lib/tool/xfrmapi.h"
46#include "modules/update/hipd/update_builder.h"
46#include "esp_prot_anchordb.h"47#include "esp_prot_anchordb.h"
47#include "esp_prot_hipd_msg.h"48#include "esp_prot_hipd_msg.h"
48#include "hipd.h"49#include "hipd.h"
4950
=== modified file 'hipd/hadb.h'
--- hipd/hadb.h 2010-10-15 15:29:14 +0000
+++ hipd/hadb.h 2010-11-23 14:43:16 +0000
@@ -42,8 +42,6 @@
42/* For switch userspace / kernel IPsec */42/* For switch userspace / kernel IPsec */
43extern int hip_use_userspace_ipsec;43extern int hip_use_userspace_ipsec;
4444
45extern hip_xmit_func_set_t nat_xmit_func_set;
46
47extern HIP_HASHTABLE *hadb_hit;45extern HIP_HASHTABLE *hadb_hit;
4846
49void hip_hadb_hold_entry(void *entry);47void hip_hadb_hold_entry(void *entry);
5048
=== modified file 'hipd/hadb_legacy.h'
--- hipd/hadb_legacy.h 2010-10-15 15:29:14 +0000
+++ hipd/hadb_legacy.h 2010-11-23 14:43:16 +0000
@@ -37,18 +37,6 @@
37 const struct in6_addr *addr,37 const struct in6_addr *addr,
38 uint32_t *lifetime,38 uint32_t *lifetime,
39 struct timeval *modified_time);39 struct timeval *modified_time);
40void hip_update_handle_ack_old(hip_ha_t *entry,
41 struct hip_ack *ack,
42 int have_esp_info);
43//add by santtu
44int hip_hadb_add_udp_addr_old(hip_ha_t *entry,
45 struct in6_addr *addr,
46 int is_bex_address,
47 uint32_t lifetime,
48 int is_preferred_addr,
49 uint16_t port,
50 uint32_t priority,
51 uint8_t kind);
5240
53void hip_hadb_delete_peer_addrlist_one_old(hip_ha_t *ha, struct in6_addr *addr);41void hip_hadb_delete_peer_addrlist_one_old(hip_ha_t *ha, struct in6_addr *addr);
5442
5543
=== modified file 'hipd/hipd.c'
--- hipd/hipd.c 2010-10-15 15:29:14 +0000
+++ hipd/hipd.c 2010-11-23 14:43:16 +0000
@@ -159,7 +159,6 @@
159159
160int hip_shotgun_status = HIP_MSG_SHOTGUN_OFF;160int hip_shotgun_status = HIP_MSG_SHOTGUN_OFF;
161161
162int hip_trigger_update_on_heart_beat_failure = 1;
163int hip_wait_addr_changes_to_stabilize = 1;162int hip_wait_addr_changes_to_stabilize = 1;
164163
165/**164/**
166165
=== modified file 'hipd/hipd.h'
--- hipd/hipd.h 2010-10-15 15:29:14 +0000
+++ hipd/hipd.h 2010-11-23 14:43:16 +0000
@@ -112,8 +112,6 @@
112extern int esp_prot_num_transforms;112extern int esp_prot_num_transforms;
113extern long esp_prot_num_parallel_hchains;113extern long esp_prot_num_parallel_hchains;
114114
115extern int hip_trigger_update_on_heart_beat_failure;
116
117extern int hip_locator_status;115extern int hip_locator_status;
118extern int hip_transform_order;116extern int hip_transform_order;
119117
120118
=== modified file 'hipd/init.c'
--- hipd/init.c 2010-10-15 15:29:14 +0000
+++ hipd/init.c 2010-11-23 14:43:16 +0000
@@ -708,6 +708,7 @@
708 lmod_register_packet_type(HIP_CLOSE_ACK, "HIP_CLOSE_ACK");708 lmod_register_packet_type(HIP_CLOSE_ACK, "HIP_CLOSE_ACK");
709 lmod_register_packet_type(HIP_PSIG, "HIP_PSIG");709 lmod_register_packet_type(HIP_PSIG, "HIP_PSIG");
710 lmod_register_packet_type(HIP_TRIG, "HIP_TRIG");710 lmod_register_packet_type(HIP_TRIG, "HIP_TRIG");
711 lmod_register_packet_type(HIP_UPDATE, "HIP_UPDATE");
711 lmod_register_packet_type(HIP_LUPDATE, "HIP_LUPDATE");712 lmod_register_packet_type(HIP_LUPDATE, "HIP_LUPDATE");
712 lmod_register_packet_type(HIP_DATA, "HIP_DATA");713 lmod_register_packet_type(HIP_DATA, "HIP_DATA");
713 lmod_register_packet_type(HIP_PAYLOAD, "HIP_PAYLOAD");714 lmod_register_packet_type(HIP_PAYLOAD, "HIP_PAYLOAD");
714715
=== modified file 'hipd/input.c'
--- hipd/input.c 2010-10-22 10:41:25 +0000
+++ hipd/input.c 2010-11-23 14:43:16 +0000
@@ -69,6 +69,7 @@
69#include "lib/core/state.h"69#include "lib/core/state.h"
70#include "lib/core/transform.h"70#include "lib/core/transform.h"
71#include "lib/tool/xfrmapi.h"71#include "lib/tool/xfrmapi.h"
72#include "modules/update/hipd/update.h"
72#include "config.h"73#include "config.h"
73#include "cookie.h"74#include "cookie.h"
74#include "dh.h"75#include "dh.h"
7576
=== modified file 'lib/core/builder.c'
--- lib/core/builder.c 2010-11-15 12:40:48 +0000
+++ lib/core/builder.c 2010-11-23 14:43:16 +0000
@@ -393,7 +393,7 @@
393 * @param tlv_generic pointer to the parameter393 * @param tlv_generic pointer to the parameter
394 * @param type type of the parameter (in host byte order)394 * @param type type of the parameter (in host byte order)
395 */395 */
396static void hip_set_param_type(struct hip_tlv_common *tlv_generic, hip_tlv_type_t type)396void hip_set_param_type(struct hip_tlv_common *tlv_generic, hip_tlv_type_t type)
397{397{
398 tlv_generic->type = htons(type);398 tlv_generic->type = htons(type);
399}399}
@@ -468,17 +468,6 @@
468}468}
469469
470/**470/**
471 * Retrieve a pointer to the first locator in a LOCATOR parameter
472 *
473 * @param locator a pointer a LOCATOR parameter
474 * @return a pointer to the first locator in the LOCATOR parameter
475 */
476struct hip_locator_info_addr_item *hip_get_locator_first_addr_item(struct hip_locator *locator)
477{
478 return (struct hip_locator_info_addr_item *) (locator + 1);
479}
480
481/**
482 * Translate a service life time from seconds to a 8-bit integer value. The471 * Translate a service life time from seconds to a 8-bit integer value. The
483 * lifetime value in seconds is translated to a 8-bit integer value using472 * lifetime value in seconds is translated to a 8-bit integer value using
484 * following formula: <code>lifetime = (8 * (log(seconds) / log(2)))473 * following formula: <code>lifetime = (8 * (log(seconds) / log(2)))
@@ -1069,9 +1058,9 @@
1069 * @param contents_size size of the contents after the TLV header1058 * @param contents_size size of the contents after the TLV header
1070 * (in host byte order)1059 * (in host byte order)
1071 */1060 */
1072static void hip_calc_generic_param_len(struct hip_tlv_common *tlv_common,1061void hip_calc_generic_param_len(struct hip_tlv_common *tlv_common,
1073 hip_tlv_len_t tlv_size,1062 hip_tlv_len_t tlv_size,
1074 hip_tlv_len_t contents_size)1063 hip_tlv_len_t contents_size)
1075{1064{
1076 hip_set_param_contents_len(tlv_common,1065 hip_set_param_contents_len(tlv_common,
1077 tlv_size + contents_size -1066 tlv_size + contents_size -
@@ -1089,8 +1078,8 @@
1089 * @param contents_size size of the contents after type and length fields1078 * @param contents_size size of the contents after type and length fields
1090 * (in host byte order)1079 * (in host byte order)
1091 */1080 */
1092static void hip_calc_param_len(struct hip_tlv_common *tlv_common,1081void hip_calc_param_len(struct hip_tlv_common *tlv_common,
1093 hip_tlv_len_t contents_size)1082 hip_tlv_len_t contents_size)
1094{1083{
1095 hip_calc_generic_param_len(tlv_common,1084 hip_calc_generic_param_len(tlv_common,
1096 sizeof(struct hip_tlv_common),1085 sizeof(struct hip_tlv_common),
@@ -2829,84 +2818,6 @@
2829}2818}
28302819
2831/**2820/**
2832 * build a HIP locator parameter
2833 *
2834 * @param msg the message where the REA will be appended
2835 * @param addrs list of addresses
2836 * @param addr_count number of addresses
2837 * @return 0 on success, otherwise < 0.
2838 */
2839int hip_build_param_locator(struct hip_common *msg,
2840 struct hip_locator_info_addr_item *addrs,
2841 int addr_count)
2842{
2843 int err = 0;
2844 struct hip_locator *locator_info = NULL;
2845 int addrs_len = addr_count * (sizeof(struct hip_locator_info_addr_item));
2846
2847 HIP_IFE(!(locator_info = malloc(sizeof(struct hip_locator) + addrs_len)), -1);
2848
2849 hip_set_param_type((struct hip_tlv_common *) locator_info, HIP_PARAM_LOCATOR);
2850
2851 hip_calc_generic_param_len((struct hip_tlv_common *) locator_info,
2852 sizeof(struct hip_locator),
2853 addrs_len);
2854
2855 memcpy(locator_info + 1, addrs, addrs_len);
2856 HIP_IFE(hip_build_param(msg, locator_info), -1);
2857
2858out_err:
2859 if (locator_info) {
2860 free(locator_info);
2861 }
2862 return err;
2863}
2864
2865
2866
2867/**
2868 * build and append a HIP SEQ parameter to a message
2869 *
2870 * @param msg the message where the parameter will be appended
2871 * @param update_id Update ID
2872 * @return 0 on success, otherwise < 0.
2873 */
2874int hip_build_param_seq(struct hip_common *msg, uint32_t update_id)
2875{
2876 int err = 0;
2877 struct hip_seq seq;
2878
2879 hip_set_param_type((struct hip_tlv_common *) &seq, HIP_PARAM_SEQ);
2880 hip_calc_generic_param_len((struct hip_tlv_common *) &seq,
2881 sizeof(struct hip_seq),
2882 0);
2883 seq.update_id = htonl(update_id);
2884 err = hip_build_param(msg, &seq);
2885 return err;
2886}
2887
2888/**
2889 * build and append a HIP ACK parameter to a message
2890 *
2891 * @param msg the message where the parameter will be appended
2892 * @param peer_update_id peer Update ID
2893 * @return 0 on success, otherwise < 0.
2894 */
2895int hip_build_param_ack(struct hip_common *msg, uint32_t peer_update_id)
2896{
2897 int err = 0;
2898 struct hip_ack ack;
2899
2900 hip_set_param_type((struct hip_tlv_common *) &ack, HIP_PARAM_ACK);
2901 hip_calc_generic_param_len((struct hip_tlv_common *) &ack,
2902 sizeof(struct hip_ack),
2903 0);
2904 ack.peer_update_id = htonl(peer_update_id);
2905 err = hip_build_param(msg, &ack);
2906 return err;
2907}
2908
2909/**
2910 * build and append a ESP PROT transform parameter2821 * build and append a ESP PROT transform parameter
2911 *2822 *
2912 * @param msg the message where the parameter will be appended2823 * @param msg the message where the parameter will be appended
@@ -3954,88 +3865,6 @@
3954}3865}
39553866
3956/**3867/**
3957 * Retrieve the amount the locators inside a LOCATOR parameter.
3958 * Type 1 and 2 parameters are supported.
3959 *
3960 * @param locator a LOCATOR parameter
3961 * @return the amount of locators
3962 */
3963int hip_get_locator_addr_item_count(const struct hip_locator *locator)
3964{
3965 const char *address_pointer = (const char *) (locator + 1);
3966 int amount = 0;
3967 uint8_t type;
3968
3969 while (address_pointer <
3970 ((const char *) locator) + hip_get_param_contents_len(locator)) {
3971 type = ((const struct hip_locator_info_addr_item *)
3972 address_pointer)->locator_type;
3973
3974 if (type == HIP_LOCATOR_LOCATOR_TYPE_UDP) {
3975 address_pointer += sizeof(struct hip_locator_info_addr_item2);
3976 amount += 1;
3977 } else if (type == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI) {
3978 address_pointer += sizeof(struct hip_locator_info_addr_item);
3979 amount += 1;
3980 } else if (type == HIP_LOCATOR_LOCATOR_TYPE_IPV6) {
3981 address_pointer += sizeof(struct hip_locator_info_addr_item);
3982 amount += 1;
3983 } else {
3984 address_pointer += sizeof(struct hip_locator_info_addr_item);
3985 }
3986 }
3987 return amount;
3988}
3989
3990/**
3991 * Retreive a @c LOCATOR ADDRESS ITEM@c from a list.
3992 *
3993 * @param item_list a pointer to the first item in the list
3994 * @param idx the index of the item in the list
3995 * @return the locator addres item
3996 */
3997union hip_locator_info_addr *hip_get_locator_item(void *item_list, int idx)
3998{
3999 int i = 0;
4000 struct hip_locator_info_addr_item *temp;
4001 char *result;
4002 result = (char *) item_list;
4003
4004
4005 for (i = 0; i <= idx - 1; i++) {
4006 temp = (struct hip_locator_info_addr_item *) result;
4007 if (temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI ||
4008 temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_IPV6) {
4009 result += sizeof(struct hip_locator_info_addr_item);
4010 } else {
4011 result += sizeof(struct hip_locator_info_addr_item2);
4012 }
4013 }
4014 return (union hip_locator_info_addr *) result;
4015}
4016
4017/**
4018 * retrieve a IP address from a locator item structure
4019 *
4020 * @param item a pointer to the item
4021 * @return a pointer to the IP address
4022 */
4023struct in6_addr *hip_get_locator_item_address(void *item)
4024{
4025 struct hip_locator_info_addr_item *temp;
4026
4027
4028 temp = (struct hip_locator_info_addr_item *) item;
4029 if (temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI) {
4030 return &temp->address;
4031 } else if (temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_IPV6) {
4032 return &temp->address;
4033 } else {
4034 return &((struct hip_locator_info_addr_item2 *) temp)->address;
4035 }
4036}
4037
4038/**
4039 * Build a @c RELAY_TO parameter to the HIP packet @c msg.3868 * Build a @c RELAY_TO parameter to the HIP packet @c msg.
4040 *3869 *
4041 * @param msg a pointer to a HIP packet common header3870 * @param msg a pointer to a HIP packet common header
40423871
=== modified file 'lib/core/builder.h'
--- lib/core/builder.h 2010-10-15 15:29:14 +0000
+++ lib/core/builder.h 2010-11-23 14:43:16 +0000
@@ -68,7 +68,6 @@
68 const struct in6_addr *,68 const struct in6_addr *,
69 const struct in6_addr *);69 const struct in6_addr *);
70int hip_host_id_hits(hip_ha_t *entry, struct hip_common *msg);70int hip_host_id_hits(hip_ha_t *entry, struct hip_common *msg);
71int hip_build_param_ack(struct hip_common *, uint32_t);
72int hip_build_param_contents(struct hip_common *,71int hip_build_param_contents(struct hip_common *,
73 const void *,72 const void *,
74 hip_tlv_type_t,73 hip_tlv_type_t,
@@ -115,9 +114,6 @@
115 uint32_t,114 uint32_t,
116 uint16_t,115 uint16_t,
117 struct hip_crypto_key *);116 struct hip_crypto_key *);
118int hip_build_param_locator(struct hip_common *,
119 struct hip_locator_info_addr_item *,
120 int);
121int hip_build_param_cert(struct hip_common *,117int hip_build_param_cert(struct hip_common *,
122 uint8_t,118 uint8_t,
123 uint8_t,119 uint8_t,
@@ -139,7 +135,6 @@
139135
140int hip_build_param_r1_counter(struct hip_common *, uint64_t);136int hip_build_param_r1_counter(struct hip_common *, uint64_t);
141137
142int hip_build_param_seq(struct hip_common *, uint32_t);
143int hip_build_param_signature2_contents(struct hip_common *,138int hip_build_param_signature2_contents(struct hip_common *,
144 const void *,139 const void *,
145 hip_tlv_len_t,140 hip_tlv_len_t,
@@ -190,13 +185,9 @@
190struct hip_dh_public_value185struct hip_dh_public_value
191 *hip_dh_select_key(struct hip_diffie_hellman *);186 *hip_dh_select_key(struct hip_diffie_hellman *);
192uint8_t hip_get_host_id_algo(const struct hip_host_id *);187uint8_t hip_get_host_id_algo(const struct hip_host_id *);
193int hip_get_locator_addr_item_count(const struct hip_locator *);
194union hip_locator_info_addr *hip_get_locator_item(void *item_list, int index);
195int hip_get_lifetime_value(time_t seconds, uint8_t *lifetime);188int hip_get_lifetime_value(time_t seconds, uint8_t *lifetime);
196int hip_get_lifetime_seconds(uint8_t lifetime, time_t *seconds);189int hip_get_lifetime_seconds(uint8_t lifetime, time_t *seconds);
197int hip_check_network_msg_len(const struct hip_common *msg);190int hip_check_network_msg_len(const struct hip_common *msg);
198struct hip_locator_info_addr_item
199 *hip_get_locator_first_addr_item(struct hip_locator *);
200hip_hdr_err_t hip_get_msg_err(const struct hip_common *);191hip_hdr_err_t hip_get_msg_err(const struct hip_common *);
201uint16_t hip_get_msg_total_len(const struct hip_common *);192uint16_t hip_get_msg_total_len(const struct hip_common *);
202hip_hdr_type_t hip_get_msg_type(const struct hip_common *);193hip_hdr_type_t hip_get_msg_type(const struct hip_common *);
@@ -216,6 +207,12 @@
216hip_tlv_len_t hip_get_param_total_len(const void *);207hip_tlv_len_t hip_get_param_total_len(const void *);
217hip_transform_suite_t hip_get_param_transform_suite_id(const void *);208hip_transform_suite_t hip_get_param_transform_suite_id(const void *);
218hip_tlv_type_t hip_get_param_type(const void *);209hip_tlv_type_t hip_get_param_type(const void *);
210void hip_set_param_type(struct hip_tlv_common *tlv_generic, hip_tlv_type_t type);
211void hip_calc_generic_param_len(struct hip_tlv_common *tlv_common,
212 hip_tlv_len_t tlv_size,
213 hip_tlv_len_t contents_size);
214void hip_calc_param_len(struct hip_tlv_common *tlv_common,
215 hip_tlv_len_t contents_size);
219uint16_t hip_get_msg_checksum(struct hip_common *msg);216uint16_t hip_get_msg_checksum(struct hip_common *msg);
220const char *hip_message_type_name(const uint8_t);217const char *hip_message_type_name(const uint8_t);
221struct hip_common *hip_msg_alloc(void);218struct hip_common *hip_msg_alloc(void);
@@ -284,7 +281,6 @@
284int hip_build_param_nat_port(hip_common_t *msg,281int hip_build_param_nat_port(hip_common_t *msg,
285 const in_port_t port,282 const in_port_t port,
286 hip_tlv_type_t hipparam);283 hip_tlv_type_t hipparam);
287struct in6_addr *hip_get_locator_item_address(void *item);
288int hip_build_digest(const int type, const void *in, int in_len, void *out);284int hip_build_digest(const int type, const void *in, int in_len, void *out);
289285
290int hip_build_param_hmac(struct hip_common *msg,286int hip_build_param_hmac(struct hip_common *msg,
291287
=== modified file 'lib/core/debug.c'
--- lib/core/debug.c 2010-10-18 17:44:31 +0000
+++ lib/core/debug.c 2010-11-23 14:43:16 +0000
@@ -83,6 +83,7 @@
83#include "lib/core/list.h"83#include "lib/core/list.h"
84#include "lib/core/prefix.h"84#include "lib/core/prefix.h"
85#include "lib/tool/lutil.h"85#include "lib/tool/lutil.h"
86#include "modules/update/hipd/update.h"
86#include "builder.h"87#include "builder.h"
87#include "ife.h"88#include "ife.h"
88#include "state.h"89#include "state.h"
@@ -813,54 +814,3 @@
813 HIP_DEBUG_HIT("Peer address", &addr->address);814 HIP_DEBUG_HIT("Peer address", &addr->address);
814 }815 }
815}816}
816
817/**
818 * Print a locator.
819 * @param file
820 * @param debug_level
821 * @param line
822 * @param function
823 * @param str string to be printed before the HIT
824 * @param locator the locator to be printed
825 */
826void hip_print_locator(UNUSED int debug_level, UNUSED const char *file,
827 UNUSED int line, UNUSED const char *function,
828 DBG const char *str, struct hip_locator *locator)
829{
830/* XXTRASHXX Totally useless does anything but what it is supposed to do -SAMU */
831
832 int n_addrs = 0, i = 0;
833 struct hip_locator_info_addr_item *first_address_item = NULL,
834 *locator_address_item = NULL;
835 struct hip_locator_info_addr_item2 *locator_address_item2 = NULL;
836 /* locator = hip_get_param((struct hip_common *)in_msg,
837 * HIP_PARAM_LOCATOR);*/
838 if (locator) {
839 HIP_DEBUG("%s: \n", str);
840
841 n_addrs = hip_get_locator_addr_item_count(locator);
842 HIP_DEBUG("there are %d locator items \n", n_addrs);
843 first_address_item = hip_get_locator_first_addr_item(locator);
844
845 for (i = 0; i < n_addrs; i++) {
846 locator_address_item = (struct hip_locator_info_addr_item *)
847 hip_get_locator_item(first_address_item, i);
848 HIP_DEBUG("locator items index %d, type is %d \n", i,
849 locator_address_item->locator_type );
850 if (locator_address_item->locator_type == HIP_LOCATOR_LOCATOR_TYPE_IPV6) {
851 HIP_INFO_HIT("locator",
852 (struct in6_addr *) &locator_address_item->address);
853 }
854 if (locator_address_item->locator_type == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI) {
855 HIP_INFO_HIT("LOCATOR from ESP SPI(type 1)",
856 (struct in6_addr *) &locator_address_item->address);
857 }
858 if (locator_address_item->locator_type == HIP_LOCATOR_LOCATOR_TYPE_UDP) {
859 locator_address_item2 = (struct hip_locator_info_addr_item2 *) locator_address_item;
860 HIP_INFO_HIT("LOCATOR from UDP",
861 (struct in6_addr *) &locator_address_item2->address);
862 HIP_DEBUG("LOCATOR port for UDP: %d\n", ntohs(locator_address_item2->port));
863 }
864 }
865 }
866}
867817
=== modified file 'lib/core/debug.h'
--- lib/core/debug.h 2010-11-12 15:50:17 +0000
+++ lib/core/debug.h 2010-11-23 14:43:16 +0000
@@ -406,12 +406,6 @@
406void hip_print_locator_addresses(const struct hip_common *);406void hip_print_locator_addresses(const struct hip_common *);
407void hip_print_peer_addresses_to_be_added(hip_ha_t *);407void hip_print_peer_addresses_to_be_added(hip_ha_t *);
408void hip_print_peer_addresses(hip_ha_t *);408void hip_print_peer_addresses(hip_ha_t *);
409void hip_print_locator(int debug_level,
410 const char *file,
411 int line,
412 const char *function,
413 const char *str,
414 struct hip_locator *locator);
415409
416#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))410#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
417411
418412
=== modified file 'lib/core/protodefs.h'
--- lib/core/protodefs.h 2010-10-20 03:38:26 +0000
+++ lib/core/protodefs.h 2010-11-23 14:43:16 +0000
@@ -576,12 +576,6 @@
576typedef struct in6_addr hip_hit_t;576typedef struct in6_addr hip_hit_t;
577typedef struct in_addr hip_lsi_t;577typedef struct in_addr hip_lsi_t;
578typedef struct hip_hadb_state hip_ha_t;578typedef struct hip_hadb_state hip_ha_t;
579typedef struct hip_hadb_rcv_func_set hip_rcv_func_set_t;
580typedef struct hip_hadb_handle_func_set hip_handle_func_set_t;
581typedef struct hip_hadb_update_func_set hip_update_func_set_t;
582typedef struct hip_hadb_misc_func_set hip_misc_func_set_t;
583typedef struct hip_hadb_xmit_func_set hip_xmit_func_set_t;
584typedef struct hip_ipsec_func_set hip_ipsec_func_set_t;
585typedef struct hip_common hip_common_t;579typedef struct hip_common hip_common_t;
586580
587struct hip_crypto_key {581struct hip_crypto_key {
@@ -688,46 +682,6 @@
688 uint16_t caseid;682 uint16_t caseid;
689} __attribute__ ((packed));683} __attribute__ ((packed));
690684
691/**
692 * Fixed start of this struct must match to struct hip_peer_addr_list_item
693 * for the part of address item. It is used in hip_update_locator_match().
694 * @todo Maybe fix this in some better way?
695 */
696struct hip_locator_info_addr_item {
697 uint8_t traffic_type;
698 uint8_t locator_type;
699 uint8_t locator_length;
700 uint8_t reserved; /**< last bit is P (prefered) */
701 uint32_t lifetime;
702 struct in6_addr address;
703} __attribute__ ((packed));
704//add by santtu
705/**
706 * it is the type 2 locater for UDP or other transport protocol later.
707 */
708struct hip_locator_info_addr_item2 {
709 uint8_t traffic_type;
710 uint8_t locator_type;
711 uint8_t locator_length;
712 uint8_t reserved; /* last bit is P (prefered) */
713 uint32_t lifetime;
714 uint16_t port;
715 uint8_t transport_protocol;
716 uint8_t kind;
717 uint32_t priority;
718 uint32_t spi;
719 struct in6_addr address;
720} __attribute__ ((packed));
721
722
723/**
724 * it is a union of both type1 and type2 locator.
725 */
726union hip_locator_info_addr {
727 struct hip_locator_info_addr_item type1;
728 struct hip_locator_info_addr_item2 type2;
729} __attribute__ ((packed));
730//end add
731/** Structure describing an endpoint. This structure is used by the resolver in685/** Structure describing an endpoint. This structure is used by the resolver in
732 * the userspace, so it is not length-padded like HIP parameters. All of the686 * the userspace, so it is not length-padded like HIP parameters. All of the
733 * members are in network byte order.687 * members are in network byte order.
@@ -938,12 +892,6 @@
938 uint8_t data[0]; /**< A pointer to the notification data */892 uint8_t data[0]; /**< A pointer to the notification data */
939} __attribute__ ((packed));893} __attribute__ ((packed));
940894
941struct hip_locator {
942 hip_tlv_type_t type;
943 hip_tlv_len_t length;
944 /* fixed part ends */
945} __attribute__ ((packed));
946
947struct hip_hmac {895struct hip_hmac {
948 hip_tlv_type_t type;896 hip_tlv_type_t type;
949 hip_tlv_len_t length;897 hip_tlv_len_t length;
950898
=== modified file 'lib/core/state.h'
--- lib/core/state.h 2010-11-12 16:42:54 +0000
+++ lib/core/state.h 2010-11-23 14:43:16 +0000
@@ -80,26 +80,10 @@
80/* #define PEER_ADDR_STATE_UNVERIFIED 1 */80/* #define PEER_ADDR_STATE_UNVERIFIED 1 */
81#define PEER_ADDR_STATE_ACTIVE 281#define PEER_ADDR_STATE_ACTIVE 2
8282
83#define HIP_LOCATOR_TRAFFIC_TYPE_DUAL 0
84#define HIP_LOCATOR_TRAFFIC_TYPE_SIGNAL 1
85
86#define HIP_LOCATOR_LOCATOR_TYPE_IPV6 0
87#define HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI 1
88//NAT branch
89#define HIP_LOCATOR_LOCATOR_TYPE_UDP 2
90
91/* #define HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI_PRIORITY 126 */
92/* #define HIP_LOCATOR_LOCATOR_TYPE_REFLEXIVE_PRIORITY 120 */
93/** for the triple nat mode*/83/** for the triple nat mode*/
94#define HIP_NAT_MODE_NONE 084#define HIP_NAT_MODE_NONE 0
95#define HIP_NAT_MODE_PLAIN_UDP 185#define HIP_NAT_MODE_PLAIN_UDP 1
9686
97#define HIP_UPDATE_LOCATOR 0
98#define HIP_UPDATE_ECHO_REQUEST 1
99#define HIP_UPDATE_ECHO_RESPONSE 2
100#define HIP_UPDATE_ESP_ANCHOR 3
101#define HIP_UPDATE_ESP_ANCHOR_ACK 4
102
103#define HIP_SPI_DIRECTION_OUT 187#define HIP_SPI_DIRECTION_OUT 1
104#define HIP_SPI_DIRECTION_IN 288#define HIP_SPI_DIRECTION_IN 2
10589
@@ -142,8 +126,6 @@
142 uint32_t lifetime;126 uint32_t lifetime;
143 struct timeval modified_time; /* time when this address was127 struct timeval modified_time; /* time when this address was
144 * added or updated */128 * added or updated */
145 uint32_t seq_update_id; /* the Update ID in SEQ parameter
146 * this address is related to */
147 uint8_t echo_data[4]; /* data put into the ECHO_REQUEST parameter */129 uint8_t echo_data[4]; /* data put into the ECHO_REQUEST parameter */
148//NAT branch130//NAT branch
149 uint8_t transport_protocol; /*value 1 for UDP*/131 uint8_t transport_protocol; /*value 1 for UDP*/
@@ -162,34 +144,17 @@
162 /* ifindex if the netdev to which this is related to */144 /* ifindex if the netdev to which this is related to */
163 int ifindex;145 int ifindex;
164 unsigned long timestamp; /* when SA was created */146 unsigned long timestamp; /* when SA was created */
165 int updating; /* UPDATE is in progress */
166 uint32_t esp_info_spi_out; /* UPDATE, the stored outbound147 uint32_t esp_info_spi_out; /* UPDATE, the stored outbound
167 * SPI related to the inbound148 * SPI related to the inbound
168 * SPI we sent in reply (useless?)*/149 * SPI we sent in reply (useless?)*/
169 uint16_t keymat_index; /* advertised keymat index */150 uint16_t keymat_index; /* advertised keymat index */
170 int update_state_flags; /* 0x1=received ack for
171 * sent SEQ, 0x2=received
172 * peer's ESP_INFO,
173 * both=0x3=can move back
174 * to established */
175 /* the Update ID in SEQ parameter these SPI are related to */151 /* the Update ID in SEQ parameter these SPI are related to */
176 uint32_t seq_update_id;
177 /* the corresponding esp_info of peer */
178 struct hip_esp_info stored_received_esp_info;152 struct hip_esp_info stored_received_esp_info;
179 /* our addresses this SPI is related to, reuse struct to ease coding */
180 struct hip_locator_info_addr_item *addresses;
181 int addresses_n; /* number of addresses */
182};153};
183154
184struct hip_spi_out_item {155struct hip_spi_out_item {
185 uint32_t spi;156 uint32_t spi;
186 uint32_t new_spi; /* spi is changed to this when rekeying */157 uint32_t new_spi; /* spi is changed to this when rekeying */
187
188 /* USELESS, IF SEQ ID WILL BE RELATED TO ADDRESS ITEMS,
189 * NOT OUTBOUND SPIS */
190 /* the Update ID in SEQ parameter these SPI are related to */
191 uint32_t seq_update_id;
192
193 HIP_HASHTABLE * peer_addr_list; /* Peer's IPv6 addresses */158 HIP_HASHTABLE * peer_addr_list; /* Peer's IPv6 addresses */
194 struct in6_addr preferred_address;159 struct in6_addr preferred_address;
195};160};
196161
=== modified file 'modules/update/Makefile.am'
--- modules/update/Makefile.am 2010-03-30 08:44:33 +0000
+++ modules/update/Makefile.am 2010-11-23 14:43:16 +0000
@@ -1,6 +1,7 @@
1lib_LTLIBRARIES += modules/update/hipd/libhipupdate.la1lib_LTLIBRARIES += modules/update/hipd/libhipupdate.la
22
3modules_update_hipd_libhipupdate_la_SOURCES = modules/update/hipd/update.c \3modules_update_hipd_libhipupdate_la_SOURCES = modules/update/hipd/update.c \
4 modules/update/hipd/update_builder.c \
4 modules/update/hipd/update_legacy.c5 modules/update/hipd/update_legacy.c
56
6hipd_hipd_LDADD += modules/update/hipd/libhipupdate.la7hipd_hipd_LDADD += modules/update/hipd/libhipupdate.la
78
=== modified file 'modules/update/hipd/update.c'
--- modules/update/hipd/update.c 2010-11-22 18:30:04 +0000
+++ modules/update/hipd/update.c 2010-11-23 14:43:16 +0000
@@ -51,7 +51,6 @@
51#include "hipd/pisa.h"51#include "hipd/pisa.h"
52#include "hipd/pkt_handling.h"52#include "hipd/pkt_handling.h"
53#include "hipd/user.h"53#include "hipd/user.h"
54#include "lib/core/builder.h"
55#include "lib/core/common.h"54#include "lib/core/common.h"
56#include "lib/core/crypto.h"55#include "lib/core/crypto.h"
57#include "lib/core/debug.h"56#include "lib/core/debug.h"
@@ -64,6 +63,7 @@
64#include "lib/core/protodefs.h"63#include "lib/core/protodefs.h"
65#include "lib/core/solve.h"64#include "lib/core/solve.h"
66#include "lib/core/modularization.h"65#include "lib/core/modularization.h"
66#include "update_builder.h"
67#include "update_legacy.h"67#include "update_legacy.h"
68#include "update.h"68#include "update.h"
6969
@@ -72,11 +72,6 @@
72 @todo Remove this kludge. */72 @todo Remove this kludge. */
73 int update_state;73 int update_state;
7474
75 /** Update function set.
76 @note Do not modify this value directly. Use
77 hip_hadb_set_handle_function_set() instead. */
78 hip_update_func_set_t *hadb_update_func;
79
80 /** This "linked list" includes the locators we recieved in the initial75 /** This "linked list" includes the locators we recieved in the initial
81 * UPDATE packet. Locators are stored as "struct in6_addr *"s.76 * UPDATE packet. Locators are stored as "struct in6_addr *"s.
82 *77 *
@@ -98,6 +93,17 @@
98static const int update_id_window_size = 50;93static const int update_id_window_size = 50;
9994
100/**95/**
96 * Retrieve a pointer to the first locator in a LOCATOR parameter
97 *
98 * @param locator a pointer a LOCATOR parameter
99 * @return a pointer to the first locator in the LOCATOR parameter
100 */
101static struct hip_locator_info_addr_item *hip_get_locator_first_addr_item(struct hip_locator *locator)
102{
103 return (struct hip_locator_info_addr_item *) (locator + 1);
104}
105
106/**
101 * build locators in an UPDATE message107 * build locators in an UPDATE message
102 *108 *
103 * @param locator_msg the message where the LOCATOR should be appended109 * @param locator_msg the message where the LOCATOR should be appended
@@ -618,6 +624,88 @@
618}624}
619625
620/**626/**
627 * Retrieve a locator address item from a list.
628 *
629 * @param item_list a pointer to the first item in the list
630 * @param idx the index of the item in the list
631 * @return the locator addres item
632 */
633static union hip_locator_info_addr *hip_get_locator_item(void *item_list,
634 int idx)
635{
636 int i = 0;
637 struct hip_locator_info_addr_item *temp;
638 char *result;
639 result = item_list;
640
641
642 for (i = 0; i <= idx - 1; i++) {
643 temp = (struct hip_locator_info_addr_item *) result;
644 if (temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI ||
645 temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_IPV6) {
646 result += sizeof(struct hip_locator_info_addr_item);
647 } else {
648 result += sizeof(struct hip_locator_info_addr_item2);
649 }
650 }
651 return (union hip_locator_info_addr *) result;
652}
653
654/**
655 * retrieve a IP address from a locator item structure
656 *
657 * @param item a pointer to the item
658 * @return a pointer to the IP address
659 */
660static struct in6_addr *hip_get_locator_item_address(void *item)
661{
662 struct hip_locator_info_addr_item *temp;
663
664
665 temp = item;
666 if (temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI) {
667 return &temp->address;
668 } else if (temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_IPV6) {
669 return &temp->address;
670 } else {
671 return &((struct hip_locator_info_addr_item2 *) temp)->address;
672 }
673}
674
675/**
676 * Retrieve the number of locators inside a LOCATOR parameter.
677 * Type 1 and 2 parameters are supported.
678 *
679 * @param locator a LOCATOR parameter
680 * @return the number of locators
681 */
682int hip_get_locator_addr_item_count(const struct hip_locator *locator)
683{
684 const char *address_pointer = (const char *) (locator + 1);
685 int loc_count = 0;
686 uint8_t type;
687
688 while (address_pointer <
689 ((const char *) locator) + hip_get_param_contents_len(locator)) {
690 type = ((const struct hip_locator_info_addr_item *)
691 address_pointer)->locator_type;
692
693 if (type == HIP_LOCATOR_LOCATOR_TYPE_UDP) {
694 address_pointer += sizeof(struct hip_locator_info_addr_item2);
695 loc_count += 1;
696 } else if (type == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI
697 || type == HIP_LOCATOR_LOCATOR_TYPE_IPV6) {
698
699 address_pointer += sizeof(struct hip_locator_info_addr_item);
700 loc_count += 1;
701 } else {
702 address_pointer += sizeof(struct hip_locator_info_addr_item);
703 }
704 }
705 return loc_count;
706}
707
708/**
621 * process a LOCATOR paramter709 * process a LOCATOR paramter
622 *710 *
623 * @param ha the related host association711 * @param ha the related host association
@@ -640,7 +728,6 @@
640 HIP_IFEL(!locator, -1, "locator is NULL");728 HIP_IFEL(!locator, -1, "locator is NULL");
641729
642 locator_addr_count = hip_get_locator_addr_item_count(locator);730 locator_addr_count = hip_get_locator_addr_item_count(locator);
643 HIP_IFEL((locator_addr_count < 0), -1, "Negative address count\n");
644731
645 HIP_DEBUG("LOCATOR has %d address(es), loc param len=%d\n",732 HIP_DEBUG("LOCATOR has %d address(es), loc param len=%d\n",
646 locator_addr_count, hip_get_param_total_len(locator));733 locator_addr_count, hip_get_param_total_len(locator));
@@ -852,7 +939,6 @@
852 "Error on allocating memory for a update state instance.\n");939 "Error on allocating memory for a update state instance.\n");
853940
854 update_state->update_state = 0;941 update_state->update_state = 0;
855 update_state->hadb_update_func = NULL;
856 update_state->addresses_to_send_echo_request = hip_linked_list_init();942 update_state->addresses_to_send_echo_request = hip_linked_list_init();
857 update_state->update_id_out = 0;943 update_state->update_id_out = 0;
858 update_state->update_id_in = 0;944 update_state->update_id_in = 0;
@@ -996,8 +1082,6 @@
996 ack_peer_update_id = ntohl(ack->peer_update_id);1082 ack_peer_update_id = ntohl(ack->peer_update_id);
997 HIP_DEBUG("ACK parameter found with peer Update ID %u.\n",1083 HIP_DEBUG("ACK parameter found with peer Update ID %u.\n",
998 ack_peer_update_id);1084 ack_peer_update_id);
999 /*ha->hadb_update_func->hip_update_handle_ack(
1000 * ha, ack, has_esp_info);*/
1001 if (ack_peer_update_id != hip_update_get_out_id(localstate)) {1085 if (ack_peer_update_id != hip_update_get_out_id(localstate)) {
1002 // Simplified logic of RFC 5201 6.12.2, 1st step:1086 // Simplified logic of RFC 5201 6.12.2, 1st step:
1003 // We drop the packet if the Update ID in the ACK1087 // We drop the packet if the Update ID in the ACK
@@ -1139,8 +1223,6 @@
1139{1223{
1140 int err = 0;1224 int err = 0;
11411225
1142 lmod_register_packet_type(HIP_UPDATE, "HIP_UPDATE");
1143
1144 HIP_IFEL(lmod_register_state_init_function(&hip_update_init_state),1226 HIP_IFEL(lmod_register_state_init_function(&hip_update_init_state),
1145 -1,1227 -1,
1146 "Error on registering update state init function.\n");1228 "Error on registering update state init function.\n");
11471229
=== modified file 'modules/update/hipd/update.h'
--- modules/update/hipd/update.h 2010-11-19 16:10:03 +0000
+++ modules/update/hipd/update.h 2010-11-23 14:43:16 +0000
@@ -38,6 +38,66 @@
3838
39#include "lib/core/protodefs.h"39#include "lib/core/protodefs.h"
4040
41/* the different mobility message types */
42#define HIP_UPDATE_LOCATOR 0
43#define HIP_UPDATE_ECHO_REQUEST 1
44#define HIP_UPDATE_ECHO_RESPONSE 2
45#define HIP_UPDATE_ESP_ANCHOR 3
46#define HIP_UPDATE_ESP_ANCHOR_ACK 4
47
48/* locator parameter types */
49#define HIP_LOCATOR_LOCATOR_TYPE_IPV6 0
50#define HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI 1
51#define HIP_LOCATOR_LOCATOR_TYPE_UDP 2
52
53
54struct hip_locator {
55 hip_tlv_type_t type;
56 hip_tlv_len_t length;
57 /* fixed part ends */
58} __attribute__ ((packed));
59
60/**
61 * Fixed start of this struct must match to struct hip_peer_addr_list_item
62 * for the part of address item. It is used in hip_update_locator_match().
63 * @todo Maybe fix this in some better way?
64 */
65struct hip_locator_info_addr_item {
66 uint8_t traffic_type;
67 uint8_t locator_type;
68 uint8_t locator_length;
69 uint8_t reserved; /**< last bit is P (preferred) */
70 uint32_t lifetime;
71 struct in6_addr address;
72} __attribute__ ((packed));
73
74/**
75 * it is the type 2 locater for UDP or other transport protocol later.
76 */
77struct hip_locator_info_addr_item2 {
78 uint8_t traffic_type;
79 uint8_t locator_type;
80 uint8_t locator_length;
81 uint8_t reserved; /* last bit is P (preferred) */
82 uint32_t lifetime;
83 uint16_t port;
84 uint8_t transport_protocol;
85 uint8_t kind;
86 uint32_t priority;
87 uint32_t spi;
88 struct in6_addr address;
89} __attribute__ ((packed));
90
91/**
92 * it is a union of both type1 and type2 locator.
93 */
94union hip_locator_info_addr {
95 struct hip_locator_info_addr_item type1;
96 struct hip_locator_info_addr_item2 type2;
97} __attribute__ ((packed));
98
99int hip_get_locator_addr_item_count(const struct hip_locator *locator);
100
41int hip_create_locators(hip_common_t *locator_msg,101int hip_create_locators(hip_common_t *locator_msg,
42 struct hip_locator_info_addr_item **locators);102 struct hip_locator_info_addr_item **locators);
43103
44104
=== added file 'modules/update/hipd/update_builder.c'
--- modules/update/hipd/update_builder.c 1970-01-01 00:00:00 +0000
+++ modules/update/hipd/update_builder.c 2010-11-23 14:43:16 +0000
@@ -0,0 +1,111 @@
1/*
2 * Copyright (c) 2010 Aalto University and RWTH Aachen University.
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use,
8 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following
11 * conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26/**
27 * @file
28 *
29 * This file facilitates buiding of mobility and multi-homing-specific
30 * parameters.
31 *
32 * @author Rene Hummen
33 */
34
35#include <string.h>
36
37#include "lib/core/builder.h"
38#include "lib/core/ife.h"
39#include "update_builder.h"
40
41
42/**
43 * build and append a HIP SEQ parameter to a message
44 *
45 * @param msg the message where the parameter will be appended
46 * @param update_id Update ID
47 * @return 0 on success, otherwise < 0.
48 */
49int hip_build_param_seq(struct hip_common *msg, uint32_t update_id)
50{
51 int err = 0;
52 struct hip_seq seq;
53
54 hip_set_param_type((struct hip_tlv_common *) &seq, HIP_PARAM_SEQ);
55 hip_calc_param_len((struct hip_tlv_common *) &seq,
56 sizeof(struct hip_seq));
57 seq.update_id = htonl(update_id);
58 err = hip_build_param(msg, &seq);
59 return err;
60}
61
62/**
63 * build and append a HIP ACK parameter to a message
64 *
65 * @param msg the message where the parameter will be appended
66 * @param peer_update_id peer Update ID
67 * @return 0 on success, otherwise < 0.
68 */
69int hip_build_param_ack(struct hip_common *msg, uint32_t peer_update_id)
70{
71 int err = 0;
72 struct hip_ack ack;
73
74 hip_set_param_type((struct hip_tlv_common *) &ack, HIP_PARAM_ACK);
75 hip_calc_param_len((struct hip_tlv_common *) &ack, sizeof(struct hip_ack));
76 ack.peer_update_id = htonl(peer_update_id);
77 err = hip_build_param(msg, &ack);
78 return err;
79}
80
81/**
82 * build a HIP locator parameter
83 *
84 * @param msg the message where the REA will be appended
85 * @param addrs list of addresses
86 * @param addr_count number of addresses
87 * @return 0 on success, otherwise < 0.
88 */
89int hip_build_param_locator(struct hip_common *msg,
90 struct hip_locator_info_addr_item *addrs,
91 int addr_count)
92{
93 int err = 0;
94 struct hip_locator *locator_info = NULL;
95 int addrs_len = addr_count * sizeof(struct hip_locator_info_addr_item);
96
97 HIP_IFE(!(locator_info = malloc(sizeof(struct hip_locator) + addrs_len)), -1);
98
99 hip_set_param_type((struct hip_tlv_common *) locator_info, HIP_PARAM_LOCATOR);
100
101 hip_calc_generic_param_len((struct hip_tlv_common *) locator_info,
102 sizeof(struct hip_locator),
103 addrs_len);
104
105 memcpy(locator_info + 1, addrs, addrs_len);
106 HIP_IFE(hip_build_param(msg, locator_info), -1);
107
108out_err:
109 free(locator_info);
110 return err;
111}
0112
=== added file 'modules/update/hipd/update_builder.h'
--- modules/update/hipd/update_builder.h 1970-01-01 00:00:00 +0000
+++ modules/update/hipd/update_builder.h 2010-11-23 14:43:16 +0000
@@ -0,0 +1,49 @@
1/*
2 * Copyright (c) 2010 Aalto University and RWTH Aachen University.
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use,
8 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following
11 * conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26/**
27 * @file
28 *
29 * This file facilitates buiding of mobility and multi-homing-specific
30 * parameters.
31 *
32 * @author Rene Hummen
33 */
34
35#ifndef MODULES_UPDATE_HIPD_UPDATE_BUILDER_H
36#define MODULES_UPDATE_HIPD_UPDATE_BUILDER_H
37
38#include <stdint.h>
39
40#include "lib/core/protodefs.h"
41#include "update.h"
42
43int hip_build_param_seq(struct hip_common *msg, uint32_t update_id);
44int hip_build_param_ack(struct hip_common *msg, uint32_t peer_update_id);
45int hip_build_param_locator(struct hip_common *msg,
46 struct hip_locator_info_addr_item *addrs,
47 int addr_count);
48
49#endif /* MODULES_UPDATE_HIPD_UPDATE_BUILDER_H */
050
=== modified file 'modules/update/hipd/update_legacy.c'
--- modules/update/hipd/update_legacy.c 2010-11-22 18:30:04 +0000
+++ modules/update/hipd/update_legacy.c 2010-11-23 14:43:16 +0000
@@ -45,9 +45,14 @@
45#include "lib/core/list.h"45#include "lib/core/list.h"
46#include "lib/core/prefix.h"46#include "lib/core/prefix.h"
47#include "lib/core/protodefs.h"47#include "lib/core/protodefs.h"
48#include "update_builder.h"
48#include "update.h"49#include "update.h"
49#include "update_legacy.h"50#include "update_legacy.h"
5051
52
53#define HIP_LOCATOR_TRAFFIC_TYPE_DUAL 0
54#define HIP_LOCATOR_TRAFFIC_TYPE_SIGNAL 1
55
51/**56/**
52 * build a LOCATOR parameter for an UPDATE packet57 * build a LOCATOR parameter for an UPDATE packet
53 *58 *

Subscribers

People subscribed via source and target branches

to all changes: