Merge lp:~hipl-core/hipl/hipv2-modularization into lp:hipl

Proposed by Xin
Status: Rejected
Rejected by: Xin
Proposed branch: lp:~hipl-core/hipl/hipv2-modularization
Merge into: lp:hipl
Diff against target: 3278 lines (+1417/-846)
33 files modified
doc/HOWTO.xml.in (+43/-0)
hipd/hipd.conf (+1/-0)
libcore/builder.c (+164/-41)
libcore/builder.h (+12/-1)
libcore/conf.c (+56/-2)
libcore/icomm.h (+2/-0)
libcore/protodefs.h (+4/-15)
libcore/state.h (+2/-0)
libcore/transform.c (+36/-35)
libcore/transform.h (+3/-3)
libhipl/close.c (+5/-3)
libhipl/cookie.c (+33/-24)
libhipl/cookie.h (+7/-4)
libhipl/esp_prot_hipd_msg.c (+2/-1)
libhipl/esp_prot_light_update.c (+5/-3)
libhipl/hidb.c (+11/-7)
libhipl/hidb.h (+1/-1)
libhipl/hiprelay.c (+4/-2)
libhipl/init.c (+625/-389)
libhipl/init.h (+2/-0)
libhipl/input.c (+40/-11)
libhipl/nat.c (+1/-1)
libhipl/netdev.c (+3/-0)
libhipl/output.c (+20/-14)
libhipl/output.h (+2/-1)
libhipl/pkt_handling.c (+39/-23)
libhipl/pkt_handling.h (+3/-2)
libhipl/user.c (+13/-0)
modules/cert/hipd/cert.c (+42/-39)
modules/midauth/hipd/midauth.c (+31/-25)
modules/update/hipd/update.c (+199/-195)
test/libcore/cert.c (+1/-1)
test/libcore/gpl/pk.c (+5/-3)
To merge this branch: bzr merge lp:~hipl-core/hipl/hipv2-modularization
Reviewer Review Type Date Requested Status
Diego Biurrun Needs Fixing
Review via email: mp+108486@code.launchpad.net

Description of the change

HIPL dual-version support (Bug #913516)

This is not a branch with all version 2 features, but rather a foundation to
adopt those features in the future. What I have done in this branch includes:

1) Extend the modularization framework so we can register different functions
   for different HIP versions now.

2) Extend our builder to support version 2, such as handling HIPv2 version
   number and providing common handling functions for list-like parameters
   (since there are quite many of them in HIPv2).

3) Build a dual-version HIPL daemon to support both version 1 and version 2.
   In the newly added section of HOWTO you can find more details.

NOTE: The version 2 handling in this branch only handles HIPv2 version number,
and reuses all function handlers from version 1. In the future, when
implementing version 2 features, we just need to add and register new handlers.
Actually that's what I have done in another branch: hipv2-dh-ecdh. The
hipv2-dh-ecdh branch is dependent on this branch and it contains ECDH cryto
handling (via openssl library) and the new DH negotiation mechanism introduced
by version 2.

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

 review needs-fixing

On Sun, Jun 03, 2012 at 12:28:18PM +0000, Xin wrote:
> Xin has proposed merging lp:~eric-nevup/hipl/hipv2-modularization into lp:hipl.

Just a quick superficial review ...

> --- doc/HOWTO.xml.in 2012-05-12 07:08:30 +0000
> +++ doc/HOWTO.xml.in 2012-06-03 12:27:20 +0000
> @@ -2607,6 +2607,49 @@
>
> +<chapter id="ch_dual_version_support">
> + <title>HIP dual-version support</title>
> +
> + <section id="ch_dual_version_support_functionality">
> + <title>Provided functionality</title>
> + <para>HIPL dual-version support allows a host to run HIPv1 and HIPv2 as
> + a dual stack. Based on the version number of received I1 messages, the host
> + automatically determines the HIP version for this peer. The version is
> + decided separately for each host association, which means the host can
> + have HIPv1 association with one peer, while maintaining HIPv2 association

have a, maintaining a

> + (the I1 message) will be switched to the version given by he hipconf

by _t_he

> --- libcore/builder.c 2012-05-12 10:21:32 +0000
> +++ libcore/builder.c 2012-06-03 12:27:20 +0000
> @@ -1556,6 +1579,94 @@
>
> +int hip_build_param_list(struct hip_common *const msg, const hip_tlv param_type,
> + void *const list_content, const hip_tlv_len item_count,
> + const int item_size)
> +{
> + int remain_count = item_count;
> +
> + // host to network byte order transform
> + if (item_size == sizeof(uint16_t)) {
> + uint16_t *p = (uint16_t *) list_content;
> + while (remain_count-- > 0) {
> + *p = htons(*p);
> + p++;
> + }
> + } else if (item_size == sizeof(uint32_t)) {
> + uint32_t *p = (uint32_t *) list_content;
> + while (remain_count-- > 0) {
> + *p = htonl(*p);
> + p++;
> + }
> + }

Why not treat everything as 16 bytes and avoid the code duplication?

> +void hip_get_list_from_param(const struct hip_tlv_common *const param,
> + void *const buffer, int *const item_number,
> + const int item_size)
> +{
> + int plen = hip_get_param_contents_len(param);
> + int actual_count = plen / item_size;
> +
> + const void *p = (const char *) param + sizeof(struct hip_tlv_common);

The cast should be unnecessary.

> + /* network to host byte order transform */
> + if (item_size == sizeof(uint16_t)) {
> + uint16_t *bp = (uint16_t *) buffer;
> + while (actual_count-- > 0) {
> + *bp = ntohs(*bp);
> + bp++;
> + }
> + } else if (item_size == sizeof(uint32_t)) {
> + uint32_t *bp = (uint32_t *) buffer;
> + while (actual_count-- > 0) {
> + *bp = ntohl(*bp);
> + bp++;
> + }
> + }
> +}

see above

> @@ -2586,7 +2703,7 @@
> for (i = 0; i < pkt_tfms; i++, tfm++) {
> int j;
> for (j = 0; j < table_n; j++) {
> - if (ntohs(*tfm) == table[j]) {
> + if (*tfm == table[j]) {
> return table[j];

unrelated?

> --- libcore/builder.h 2012-05-12 06:54:33 +0000
> +++ libcore/builder....

Read more...

review: Needs Fixing
6254. By Xin

Improve code and doc based on review opinions.

Revision history for this message
Xin (eric-nevup) wrote :
Download full text (5.1 KiB)

Hi,

On 06/03/2012 08:07 PM, Diego Biurrun wrote:
> review needs-fixing
>
>
>> --- libcore/builder.c 2012-05-12 10:21:32 +0000
>> +++ libcore/builder.c 2012-06-03 12:27:20 +0000
>> @@ -1556,6 +1579,94 @@
>>
>> +int hip_build_param_list(struct hip_common *const msg, const hip_tlv param_type,
>> + void *const list_content, const hip_tlv_len item_count,
>> + const int item_size)
>> +{
>> + int remain_count = item_count;
>> +
>> + // host to network byte order transform
>> + if (item_size == sizeof(uint16_t)) {
>> + uint16_t *p = (uint16_t *) list_content;
>> + while (remain_count--> 0) {
>> + *p = htons(*p);
>> + p++;
>> + }
>> + } else if (item_size == sizeof(uint32_t)) {
>> + uint32_t *p = (uint32_t *) list_content;
>> + while (remain_count--> 0) {
>> + *p = htonl(*p);
>> + p++;
>> + }
>> + }
> Why not treat everything as 16 bytes and avoid the code duplication?

I need to do network to host byte order change here, the function calls
for handling 16 and 32 bits are different.
I don't think I can make it simpler if you mean change the code like this:

     if (item_size == sizeof(uint16_t) || sizeof(uint32_t)) {
         uint16_t *p = (uint16_t *) list_content;
         while (remain_count-- > 0) {
             if (item_size == sizeof(uint16_t)) {
                 *p = htons(*p);
             } else {
                 uint32_t *p32 = (uint32_t *) list_content;
                 *p32 = htons(*p32);
             }
             p += item_size / sizeof(uint16_t);
         }
     }

>
>> + /* network to host byte order transform */
>> + if (item_size == sizeof(uint16_t)) {
>> + uint16_t *bp = (uint16_t *) buffer;
>> + while (actual_count--> 0) {
>> + *bp = ntohs(*bp);
>> + bp++;
>> + }
>> + } else if (item_size == sizeof(uint32_t)) {
>> + uint32_t *bp = (uint32_t *) buffer;
>> + while (actual_count--> 0) {
>> + *bp = ntohl(*bp);
>> + bp++;
>> + }
>> + }
>> +}
> see above

the same

>
>> @@ -2586,7 +2703,7 @@
>> for (i = 0; i< pkt_tfms; i++, tfm++) {
>> int j;
>> for (j = 0; j< table_n; j++) {
>> - if (ntohs(*tfm) == table[j]) {
>> + if (*tfm == table[j]) {
>> return table[j];
> unrelated?

No, this is related to the previous changes. Since we have added new
functions to handle list-like parameters and those functions already
handle the byte order, we don't need to change the byte order by ourself.

>
>> @@ -801,19 +804,9 @@
>>
>> -struct hip_hip_transform {
>> - hip_tlv type;
>> - hip_tlv_len length;
>> - hip_transform_suite suite_id[HIP_TRANSFORM_HIP_MAX];
>> -} __attribute__((packed));
>> -
>> -struct hip_esp_transform {
>> - hip_tlv type;
>> - hip_tlv_len length;
>> - uint16_t reserved;
>> - hip_transform_suite suite_id[HIP_TRANSFORM_ESP_MAX];
>> -} __attribute__((packed));
>> -
>> +typedef struct hip_tlv_common hip_hip_transform;
>> +
>> +typedef struct hip...

Read more...

Revision history for this message
Christof Mroz (christof-mroz) wrote :

On 07.06.2012 15:00, Xin Gu wrote:
> Hi,
>
> On 06/03/2012 08:07 PM, Diego Biurrun wrote:
>> review needs-fixing
>>
>>
>>> --- libcore/builder.c 2012-05-12 10:21:32 +0000
>>> +++ libcore/builder.c 2012-06-03 12:27:20 +0000
>>> @@ -1556,6 +1579,94 @@
>>>
>>> +int hip_build_param_list(struct hip_common *const msg, const hip_tlv
>>> param_type,
>>> + void *const list_content, const hip_tlv_len
>>> item_count,
>>> + const int item_size)
>>> +{
>>> + int remain_count = item_count;
>>> +
>>> + // host to network byte order transform
>>> + if (item_size == sizeof(uint16_t)) {
>>> + uint16_t *p = (uint16_t *) list_content;
>>> + while (remain_count--> 0) {
>>> + *p = htons(*p);
>>> + p++;
>>> + }
>>> + } else if (item_size == sizeof(uint32_t)) {
>>> + uint32_t *p = (uint32_t *) list_content;
>>> + while (remain_count--> 0) {
>>> + *p = htonl(*p);
>>> + p++;
>>> + }
>>> + }
>> Why not treat everything as 16 bytes and avoid the code duplication?
>
> I need to do network to host byte order change here, the function calls
> for handling 16 and 32 bits are different.
> I don't think I can make it simpler if you mean change the code like this:
>
> if (item_size == sizeof(uint16_t) || sizeof(uint32_t)) {
> uint16_t *p = (uint16_t *) list_content;
> while (remain_count-- > 0) {
> if (item_size == sizeof(uint16_t)) {
> *p = htons(*p);
> } else {
> uint32_t *p32 = (uint32_t *) list_content;
> *p32 = htons(*p32);
> }
> p += item_size / sizeof(uint16_t);
> }
> }
>
>>> + /* network to host byte order transform */
>>> + if (item_size == sizeof(uint16_t)) {
>>> + uint16_t *bp = (uint16_t *) buffer;
>>> + while (actual_count--> 0) {
>>> + *bp = ntohs(*bp);
>>> + bp++;
>>> + }
>>> + } else if (item_size == sizeof(uint32_t)) {
>>> + uint32_t *bp = (uint32_t *) buffer;
>>> + while (actual_count--> 0) {
>>> + *bp = ntohl(*bp);
>>> + bp++;
>>> + }
>>> + }
>>> +}
>> see above
>
> the same
>

I liked the first version better, but since you need the exact same code
twice I'd put it in another function and shorten a bit, e.g.

void hton_buffer(void *bfr, unsigned count, size_t item_size) {
 if(item_size == sizeof(uint16_t)) {
  uint16_t *const p = bfr;

  for(unsigned i = 0; i < count; ++i)
   p[i] = htons(p[i])
 }
 else if(item_size == sizeof(uint32_t)) { ... }
 else { HIP_ASSERT("..."); }
}

6255. By Xin

Reorganize redundant code for list parameter operations.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'doc/HOWTO.xml.in'
2--- doc/HOWTO.xml.in 2012-05-12 07:08:30 +0000
3+++ doc/HOWTO.xml.in 2012-07-07 13:45:26 +0000
4@@ -2607,6 +2607,49 @@
5
6 </chapter> <!-- ch_cert_exchange -->
7
8+<chapter id="ch_dual_version_support">
9+ <title>HIP dual-version support</title>
10+
11+ <section id="ch_dual_version_support_functionality">
12+ <title>Provided functionality</title>
13+ <para>HIPL dual-version support allows a host to run HIPv1 and HIPv2 as
14+ a dual stack. Based on the version number of received I1 messages, the host
15+ automatically determines the HIP version for this peer. The version is
16+ decided separately for each host association, which means the host can
17+ have a HIPv1 association with one peer, while maintaining a HIPv2
18+ association with another peer.</para>
19+ <para>HIPL dual-version support also enables a host to choose the default
20+ HIP version for HIP association initiation. This behavior can be configured
21+ via both the hipd configuration file and the hipconf command line tool.
22+ </para>
23+ </section>
24+
25+ <section id="ch_dual_version_support_conf_file">
26+ <title>Configure the default HIP version for HA initiation via the
27+ configuration file</title>
28+ <para>The configuration parameter: <emphasis>hip-default-version</emphasis>
29+ in the hipd.conf file accepts two value: 1 and 2, which stands for HIPv1
30+ and HIPv2 respectively. If the hipd cannot find this parameter in the
31+ configuration file, HIPv1 will be used as a default value.
32+ </para>
33+ </section>
34+
35+ <section id="ch_dual_version_support_hipconf">
36+ <title>Configure the default HIP version for HA initiation via the
37+ hipconf command</title>
38+ <para>Modification of the configuration parameter: <emphasis>
39+ hip-default-version</emphasis> in the hipconf command line takes effect
40+ immediately and no restart of the daemon is required. Any HA before
41+ the modification keeps unchanged and all new HIP initiation messages
42+ (the I1 message) will be switched to the version given by the hipconf
43+ command. Below is an example of setting the parameter to HIPv1. To use
44+ HIPv2, change the value from 1 to 2. </para>
45+ <para><programlisting>
46+ hipconf daemon default-hip-version 1
47+ </programlisting></para>
48+</section>
49+</chapter> <!-- ch_dual_version_support -->
50+
51 <chapter id="ch_exp_extensions">
52 <title>Other Experimental HIP Extensions</title>
53
54
55=== modified file 'hipd/hipd.conf'
56--- hipd/hipd.conf 2011-12-12 14:26:13 +0000
57+++ hipd/hipd.conf 2012-07-07 13:45:26 +0000
58@@ -19,3 +19,4 @@
59 #nat port local 11111 # change local default UDP port
60 #nat port peer 22222 # change local peer UDP port
61 debug medium # debug verbosity: all, medium, low or none
62+default-hip-version 1 # default HIP version number for the I1 message. (1=HIPV1, 2=HIPV2)
63
64=== modified file 'libcore/builder.c'
65--- libcore/builder.c 2012-05-12 10:21:32 +0000
66+++ libcore/builder.c 2012-07-07 13:45:26 +0000
67@@ -88,6 +88,7 @@
68
69 #include <errno.h>
70 #include <math.h>
71+#include <stdbool.h>
72 #include <stdlib.h>
73 #include <string.h>
74 #include <unistd.h>
75@@ -109,6 +110,37 @@
76 static enum select_dh_key_t select_dh_key = STRONGER_KEY;
77
78 /**
79+ * Convert the byte order of a list of items in one buffer.
80+ *
81+ * @param content the buffer to hold all the items
82+ * @param count the number of items in the buffer
83+ * @param item_size the size of each item in bytes. The function only supports
84+ * items in 2 bytes or 4 bytes.
85+ * @param hton if true, perform host-to-network byte order transform,
86+ * other wise perform network-to-host transform.
87+ */
88+static void convert_byte_order(void *content, unsigned count,
89+ unsigned item_size, bool hton)
90+{
91+ uint32_t (*f32)(uint32_t) = hton ? htonl : ntohl;
92+ uint16_t (*f16)(uint16_t) = hton ? htons : ntohs;
93+
94+ HIP_ASSERT(item_size == sizeof(uint16_t) || item_size == sizeof(uint32_t));
95+
96+ if (item_size == sizeof(uint16_t)) {
97+ uint16_t *p = content;
98+ for (unsigned i = 0; i < count; i++) {
99+ p[i] = f16(p[i]);
100+ }
101+ } else {
102+ uint32_t *p = content;
103+ for (unsigned i = 0; i < count; i++) {
104+ p[i] = f32(p[i]);
105+ }
106+ }
107+}
108+
109+/**
110 * attach a HIP RR and a hostname into a hip_host_id_priv parameter
111 *
112 * @param host_id a hip_host_id_priv parameter
113@@ -286,6 +318,28 @@
114 }
115
116 /**
117+ * Get the HIP version number from a HIP message header
118+ *
119+ * @param msg pointer to the beginning of the message header
120+ * @return HIP version number
121+ */
122+uint8_t hip_get_msg_version(const struct hip_common *msg)
123+{
124+ return msg->ver_res >> 4;
125+}
126+
127+/**
128+ * Set HIP version number to a given HIP message header
129+ *
130+ * @param msg pointer to the beginning of the message header
131+ * @param version HIP message version
132+ */
133+void hip_set_msg_version(struct hip_common *msg, const uint8_t version)
134+{
135+ msg->ver_res = version << 4 | HIP_VER_RES;
136+}
137+
138+/**
139 * set the error value of the daemon message
140 *
141 * @param msg pointer to the beginning of the message header
142@@ -1239,6 +1293,7 @@
143 HIP_DEBUG("Msg length: %d\n", hip_get_msg_total_len(msg));
144 HIP_DEBUG("Msg err: %d\n", hip_get_msg_err(msg));
145 HIP_DEBUG("Msg controls: 0x%04x\n", msg->control);
146+ HIP_DEBUG("Msg version: %d\n", hip_get_msg_version(msg));
147
148 while ((current_param = hip_get_next_param(msg, current_param))) {
149 len = hip_get_param_contents_len(current_param);
150@@ -1556,6 +1611,68 @@
151 }
152
153 /**
154+ * Build a HIP parameter containing several items in a consecutive list.
155+ *
156+ * If the @c item_size is 2 bytes or 4 bytes, each item in the list will be
157+ * transformed from host byte order to network byte order.
158+ *
159+ * @param msg the pointer to a message where the parameter will be
160+ * appended.
161+ * @param param_type the type of the parameter, in host byte order.
162+ * @param list_content the pointer to a buffer containing all list items.
163+ * @param item_count the number of the items in the @c list_content.
164+ * @param item_size the size of each item in bytes.
165+ * @return zero on success, or negative value on error.
166+ */
167+int hip_build_param_list(struct hip_common *const msg, const hip_tlv param_type,
168+ void *const list_content, const hip_tlv_len item_count,
169+ const int item_size)
170+{
171+ // host to network byte order transform
172+ convert_byte_order(list_content, item_count, item_size, true);
173+
174+ return hip_build_param_contents(msg, list_content, param_type,
175+ item_count * item_size);
176+}
177+
178+/**
179+ * Fetch the content of a HIP list-like parameter to a specified buffer.
180+ *
181+ * If the buffer size is smaller than the size of all items in the list, the
182+ * result in the buffer will be truncated to first N items
183+ * (N <= @c item_number). If the @c item_size is 2 bytes or 4 bytes, result
184+ * items will be transformed from network byte order to host byte order.
185+ *
186+ * @param param pointer to the HIP list parameter.
187+ * @param buffer the buffer for holding items of the list parameter.
188+ * @param item_number a value-result argument. The caller must initialize it to
189+ * the number of items @c buffer can hold; On return, it
190+ * will contains the number of items in the given HIP list
191+ * parameter.
192+ * @param item_size the size of each item in bytes.
193+ */
194+void hip_get_list_from_param(const struct hip_tlv_common *const param,
195+ void *const buffer, int *const item_number,
196+ const int item_size)
197+{
198+ int plen = hip_get_param_contents_len(param);
199+ int actual_count = plen / item_size;
200+
201+ const void *p = param + 1;
202+
203+ if (actual_count > *item_number) {
204+ HIP_DEBUG("The buffer size is smaller than the size of list parameter.\n");
205+ actual_count = *item_number;
206+ } else {
207+ *item_number = actual_count;
208+ }
209+ memcpy(buffer, p, actual_count * item_size);
210+
211+ /* network to host byte order transform */
212+ convert_byte_order(buffer, actual_count, item_size, false);
213+}
214+
215+/**
216 * set whether to request for a response from hipd or not
217 *
218 * @param msg user message
219@@ -1648,6 +1765,7 @@
220 * @param control HIP control bits in host byte order
221 * @param hit_sender source HIT in network byte order
222 * @param hit_receiver destination HIT in network byte order
223+ * @param version HIP version number of the message
224 * @todo build HIP network header in the same fashion as in build_daemon_hdr().
225 * <ul>
226 * <li>Write missing headers in the header using accessor functions
227@@ -1664,7 +1782,8 @@
228 */
229 void hip_build_network_hdr(struct hip_common *msg, uint8_t type_hdr,
230 uint16_t control, const struct in6_addr *hit_sender,
231- const struct in6_addr *hit_receiver)
232+ const struct in6_addr *hit_receiver,
233+ uint8_t version)
234 {
235 /* build header first and then parameters */
236 HIP_ASSERT(hip_get_msg_total_len(msg) == 0);
237@@ -1673,7 +1792,7 @@
238 /* Do not touch the length; it is written by param builders */
239 msg->type_hdr = type_hdr; /* 1 byte, no htons() */
240 /* version includes the SHIM6 bit */
241- msg->ver_res = (HIP_VER_RES << 4) | 1; /* 1 byte, no htons() */
242+ msg->ver_res = (version << 4) | HIP_VER_RES; /* 1 byte, no htons() */
243
244 msg->control = htons(control);
245 msg->checksum = htons(0); /* this will be written by xmit */
246@@ -1835,7 +1954,8 @@
247 struct sockaddr *src, struct sockaddr *dst,
248 int len)
249 {
250- int err = 0, plen, checksum;
251+ int err = 0, plen, checksum;
252+ uint8_t version;
253
254 plen = hip_get_msg_total_len(hip_common);
255
256@@ -1849,7 +1969,8 @@
257
258 /* we should ignore reserved bits and SHIM6 bit when checking
259 * the HIP header of incoming pakcets */
260- if ((hip_common->ver_res & 0xF0) != HIP_VER_RES << 4) {
261+ version = hip_get_msg_version(hip_common);
262+ if (version == 0 || version >= HIP_MAX_VERSION) {
263 HIP_ERROR("Invalid version in received packet. Dropping\n");
264 return -EPROTOTYPE;
265 }
266@@ -2470,9 +2591,9 @@
267 const hip_transform_suite transform_suite[],
268 const uint16_t transform_count)
269 {
270- uint16_t i;
271- uint16_t transform_max;
272- struct hip_esp_transform transform_param;
273+ uint16_t i;
274+ uint16_t transform_max;
275+ hip_transform_suite suite[transform_count + 1];
276
277 transform_max = get_transform_max(HIP_PARAM_ESP_TRANSFORM);
278
279@@ -2483,19 +2604,15 @@
280 return -E2BIG;
281 }
282
283- transform_param.reserved = 0;
284-
285- /* Copy and convert transforms to network byte order. */
286+ /* Build the content of the list, the first item in the list is a reserved
287+ * zero field according to HIP_ESP_FRANSFORM format */
288+ suite[0] = HIP_ESP_RESERVED;
289 for (i = 0; i < transform_count; i++) {
290- transform_param.suite_id[i] = htons(transform_suite[i]);
291+ suite[i + 1] = transform_suite[i];
292 }
293
294- hip_set_param_type((struct hip_tlv_common *) &transform_param,
295- HIP_PARAM_ESP_TRANSFORM);
296- hip_calc_param_len((struct hip_tlv_common *) &transform_param,
297- 2 + transform_count * sizeof(hip_transform_suite));
298-
299- return hip_build_param(msg, &transform_param);
300+ return hip_build_param_list(msg, HIP_PARAM_ESP_TRANSFORM, suite,
301+ transform_count + 1, sizeof(hip_transform_suite));
302 }
303
304 /**
305@@ -2511,13 +2628,12 @@
306 const hip_transform_suite transform_suite[],
307 const uint16_t transform_count)
308 {
309- uint16_t i;
310- uint16_t transform_max;
311- struct hip_hip_transform transform_param;
312+ uint16_t i;
313+ uint16_t transform_max;
314+ hip_transform_suite transform_list[transform_count];
315
316 transform_max = get_transform_max(HIP_PARAM_HIP_TRANSFORM);
317
318-
319 /* Check that the maximum number of transforms is not overflowed */
320 if (transform_max > 0 && transform_count > transform_max) {
321 HIP_ERROR("Too many transforms (%d) for type %d.\n",
322@@ -2525,18 +2641,13 @@
323 return -E2BIG;
324 }
325
326-
327 /* Copy and convert transforms to network byte order. */
328 for (i = 0; i < transform_count; i++) {
329- transform_param.suite_id[i] = htons(transform_suite[i]);
330+ transform_list[i] = transform_suite[i];
331 }
332
333- hip_set_param_type((struct hip_tlv_common *) &transform_param,
334- HIP_PARAM_HIP_TRANSFORM);
335- hip_calc_param_len((struct hip_tlv_common *) &transform_param,
336- transform_count * sizeof(hip_transform_suite));
337-
338- return hip_build_param(msg, &transform_param);
339+ return hip_build_param_list(msg, HIP_PARAM_HIP_TRANSFORM, transform_list,
340+ transform_count, sizeof(hip_transform_suite));
341 }
342
343 /**
344@@ -2555,7 +2666,8 @@
345 * which MUST match one of the values offered to the Initiator in
346 * the R1 packet. Does this function check this?
347 * -Lauri 01.08.2008. */
348- hip_tlv type;
349+ hip_tlv type = hip_get_param_type(transform_tlv);
350+
351 uint16_t supported_hip_tf[] = { HIP_HIP_NULL_SHA1,
352 HIP_HIP_3DES_SHA1,
353 HIP_HIP_AES_SHA1 };
354@@ -2564,20 +2676,31 @@
355 HIP_ESP_AES_SHA1 };
356 const uint16_t *table = NULL;
357 const uint16_t *tfm;
358- int table_n = 0, pkt_tfms = 0, i;
359-
360- type = hip_get_param_type(transform_tlv);
361+ int table_n = 0, i;
362+
363+ // reserve one extra slot for ESP reserved field
364+ int pkt_tfms = get_transform_max(type) + 1;
365+ uint16_t suite[pkt_tfms];
366+
367+ hip_get_list_from_param(transform_tlv, suite, &pkt_tfms, sizeof(uint16_t));
368+
369 if (type == HIP_PARAM_HIP_TRANSFORM) {
370- table = supported_hip_tf;
371- table_n = sizeof(supported_hip_tf) / sizeof(uint16_t);
372- tfm = (const uint16_t *) ((const uint8_t *) transform_tlv + sizeof(struct hip_tlv_common));
373- pkt_tfms = hip_get_param_contents_len(transform_tlv) / sizeof(uint16_t);
374+ table = supported_hip_tf;
375+ table_n = sizeof(supported_hip_tf) / sizeof(uint16_t);
376+ tfm = suite;
377+ if (pkt_tfms > HIP_TRANSFORM_HIP_MAX) {
378+ pkt_tfms = HIP_TRANSFORM_HIP_MAX;
379+ }
380 } else if (type == HIP_PARAM_ESP_TRANSFORM) {
381 table = supported_esp_tf;
382 table_n = sizeof(supported_esp_tf) / sizeof(uint16_t);
383- tfm = (const uint16_t *) ((const uint8_t *) transform_tlv +
384- sizeof(struct hip_tlv_common) + sizeof(uint16_t));
385- pkt_tfms = (hip_get_param_contents_len(transform_tlv) - sizeof(uint16_t)) / sizeof(uint16_t);
386+ if (pkt_tfms <= 1) {
387+ /* the first item in the list is a reserved field for ESP_TRANSFORM */
388+ HIP_ERROR("No ESP_TRANSFORM suite available\n");
389+ return 0;
390+ }
391+ tfm = &suite[1];
392+ pkt_tfms--;
393 } else {
394 HIP_ERROR("Invalid type %u\n", type);
395 return 0;
396@@ -2586,7 +2709,7 @@
397 for (i = 0; i < pkt_tfms; i++, tfm++) {
398 int j;
399 for (j = 0; j < table_n; j++) {
400- if (ntohs(*tfm) == table[j]) {
401+ if (*tfm == table[j]) {
402 return table[j];
403 }
404 }
405
406=== modified file 'libcore/builder.h'
407--- libcore/builder.h 2012-05-12 06:54:33 +0000
408+++ libcore/builder.h 2012-07-07 13:45:26 +0000
409@@ -63,12 +63,18 @@
410 uint8_t,
411 uint16_t,
412 const struct in6_addr *,
413- const struct in6_addr *);
414+ const struct in6_addr *,
415+ uint8_t);
416 int hip_host_id_hits(struct hip_hadb_state *entry, struct hip_common *msg);
417 int hip_build_param_contents(struct hip_common *,
418 const void *,
419 hip_tlv,
420 hip_tlv);
421+int hip_build_param_list(struct hip_common *const msg,
422+ const hip_tlv param_type,
423+ void *const list_content,
424+ const hip_tlv_len list_size,
425+ const int item_size);
426 int hip_build_param_diffie_hellman_contents(struct hip_common *,
427 uint8_t,
428 void *,
429@@ -168,6 +174,7 @@
430 int hip_get_lifetime_seconds(uint8_t lifetime, time_t *seconds);
431 int hip_check_network_msg_len(const struct hip_common *msg);
432 hip_hdr_err hip_get_msg_err(const struct hip_common *);
433+uint8_t hip_get_msg_version(const struct hip_common *msg);
434 uint16_t hip_get_msg_total_len(const struct hip_common *);
435 hip_hdr hip_get_msg_type(const struct hip_common *);
436 const struct hip_tlv_common *hip_get_next_param(const struct hip_common *,
437@@ -179,6 +186,9 @@
438 const void *hip_get_param_contents(const struct hip_common *, hip_tlv);
439 const void *hip_get_param_contents_direct(const void *);
440 hip_tlv_len hip_get_param_contents_len(const void *);
441+void hip_get_list_from_param(const struct hip_tlv_common *const param,
442+ void *const buffer, int *const item_number,
443+ const int item_size);
444 int hip_get_param_host_id_di_type_len(const struct hip_host_id *,
445 const char **, int *);
446 const char *hip_get_param_host_id_hostname(const struct hip_host_id *);
447@@ -198,6 +208,7 @@
448 void hip_set_msg_err(struct hip_common *, hip_hdr_err);
449 void hip_set_msg_checksum(struct hip_common *msg, uint8_t checksum);
450 void hip_set_msg_total_len(struct hip_common *, uint16_t);
451+void hip_set_msg_version(struct hip_common *msg, const uint8_t version);
452 void hip_set_param_contents_len(struct hip_tlv_common *, hip_tlv_len);
453 void hip_set_param_lsi_value(struct hip_esp_info *, uint32_t);
454 void hip_zero_msg_checksum(struct hip_common *);
455
456=== modified file 'libcore/conf.c'
457--- libcore/conf.c 2012-03-20 12:25:10 +0000
458+++ libcore/conf.c 2012-07-07 13:45:26 +0000
459@@ -129,7 +129,9 @@
460 #define ACTION_MANUAL_UPDATE 40
461 #define ACTION_BROADCAST 41
462 #define ACTION_ACQUIRE 42
463-#define ACTION_MAX 43 /* exclusive */
464+/* This parameter defines which HIP version will be used by default */
465+#define ACTION_DEFAULT_HIP_VERSION 45
466+#define ACTION_MAX 46 /* exclusive */
467
468 /**
469 * TYPE_ constant list, as an index for each action_handler function.
470@@ -180,7 +182,8 @@
471 #define TYPE_MANUAL_UPDATE 43
472 #define TYPE_BROADCAST 44
473 #define TYPE_CERTIFICATE 45
474-#define TYPE_MAX 46 /* exclusive */
475+#define TYPE_DEFAULT_HIP_VERSION 46
476+#define TYPE_MAX 47 /* exclusive */
477
478 /* #define TYPE_RELAY 22 */
479
480@@ -235,6 +238,7 @@
481 "id-to-addr hit|lsi\n"
482 "broadcast on|off\n"
483 "acquire certificate <hit> [valid-till_timestamp]\n"
484+ "default-hip-version 1|2\n"
485 ;
486
487 /**
488@@ -655,6 +659,8 @@
489 ret = ACTION_BROADCAST;
490 } else if (!strcmp("acquire", argv[2])) {
491 ret = ACTION_ACQUIRE;
492+ } else if (!strcmp("default-hip-version", argv[2])) {
493+ ret = ACTION_DEFAULT_HIP_VERSION;
494 }
495
496 return ret;
497@@ -692,6 +698,7 @@
498 case ACTION_HIT_TO_IP:
499 case ACTION_HIT_TO_IP_SET:
500 case ACTION_BROADCAST:
501+ case ACTION_DEFAULT_HIP_VERSION:
502 count = 1;
503 break;
504 case ACTION_ADD:
505@@ -786,6 +793,8 @@
506 ret = TYPE_LSI_TO_HIT;
507 } else if (strcmp("broadcast", argv[2]) == 0) {
508 ret = TYPE_BROADCAST;
509+ } else if (strcmp("default-hip-version", text) == 0) {
510+ ret = TYPE_DEFAULT_HIP_VERSION;
511 } else {
512 HIP_DEBUG("ERROR: NO MATCHES FOUND \n");
513 }
514@@ -837,6 +846,7 @@
515 case ACTION_LSI_TO_HIT:
516 case ACTION_DEBUG:
517 case ACTION_SHOTGUN:
518+ case ACTION_DEFAULT_HIP_VERSION:
519 type_arg = 2;
520 break;
521 default:
522@@ -2435,6 +2445,49 @@
523 }
524
525 /**
526+ * Handles the hipconf commands where the type is @c default-hip-version.
527+ *
528+ * @param msg a pointer to the buffer where the message for hipd will
529+ * be written.
530+ * @param action unused.
531+ * @param opt an array of pointers to the command line arguments after
532+ * the action and type.
533+ * @param optc the number of elements in the array.
534+ * @param send_only unused.
535+ * @return zero on success, or negative error value on error.
536+ */
537+static int conf_handle_default_hip_version(struct hip_common *msg,
538+ UNUSED int action, const char *opt[],
539+ int optc, UNUSED int send_only)
540+{
541+ int status = 0;
542+
543+ if (optc != 0) {
544+ HIP_ERROR("Incorrect number of arguments. "
545+ "Usage:\nhipconf default-hip-version 1|2\n");
546+ return -EINVAL;
547+ }
548+
549+ if (!strcmp("1", opt[0])) {
550+ HIP_INFO("Default hip version: 1\n");
551+ status = HIP_MSG_DEFAULT_HIP_VERSION_1;
552+ } else if (!strcmp("2", opt[0])) {
553+ HIP_INFO("Default hip version: 2\n");
554+ status = HIP_MSG_DEFAULT_HIP_VERSION_2;
555+ } else {
556+ HIP_ERROR("Unknown argument\n");
557+ return -EINVAL;
558+ }
559+
560+ if (hip_build_user_hdr(msg, status, 0) < 0) {
561+ HIP_ERROR("Failed to build the user message header.\n");
562+ return -1;
563+ }
564+
565+ return 0;
566+}
567+
568+/**
569 * Utility function which compactly checks whether a string represents
570 * a positive natural number, since scanf() is too lenient.
571 *
572@@ -2678,6 +2731,7 @@
573 conf_handle_manual_update, /* 43: TYPE_MANUAL_UPDATE */
574 conf_handle_broadcast, /* 44: TYPE_BROADCAST */
575 conf_handle_certificate, /* 45: TYPE_CERTIFICATE */
576+ conf_handle_default_hip_version, /* 46: TYPE_DEFAULT_HIP_VERSION */
577 NULL /* TYPE_MAX, the end. */
578 };
579
580
581=== modified file 'libcore/icomm.h'
582--- libcore/icomm.h 2012-05-12 06:54:33 +0000
583+++ libcore/icomm.h 2012-07-07 13:45:26 +0000
584@@ -158,6 +158,8 @@
585 #define HIP_MSG_BROADCAST_ON 203
586 #define HIP_MSG_LSI_ON 204
587 #define HIP_MSG_LSI_OFF 205
588+#define HIP_MSG_DEFAULT_HIP_VERSION_1 206
589+#define HIP_MSG_DEFAULT_HIP_VERSION_2 207
590 /* @} */
591
592 /* inclusive */
593
594=== modified file 'libcore/protodefs.h'
595--- libcore/protodefs.h 2012-05-12 06:54:33 +0000
596+++ libcore/protodefs.h 2012-07-07 13:45:26 +0000
597@@ -78,6 +78,7 @@
598 /**
599 * @todo add description
600 */
601+#define HIP_MAX_VERSION 3
602 #define HIP_MAX_PACKET_TYPE 64
603
604 #define HIP_HIT_TYPE_HASH100 1
605@@ -372,7 +373,9 @@
606
607 #define HIP_MAX_KEY_LEN 32 /* max. draw: 256 bits! */
608
609-#define HIP_VER_RES 0x01 /* Version 1, reserved 0 */
610+#define HIP_V1 1
611+#define HIP_V2 2
612+#define HIP_VER_RES 0x01 /* reserved and shim6 bit */
613 #define HIP_USER_VER_RES 0xF0 /* Internal messages */
614
615
616@@ -801,20 +804,6 @@
617 struct hip_dh_public_value pub_val;
618 } __attribute__((packed));
619
620-struct hip_hip_transform {
621- hip_tlv type;
622- hip_tlv_len length;
623- hip_transform_suite suite_id[HIP_TRANSFORM_HIP_MAX];
624-} __attribute__((packed));
625-
626-struct hip_esp_transform {
627- hip_tlv type;
628- hip_tlv_len length;
629- uint16_t reserved;
630- hip_transform_suite suite_id[HIP_TRANSFORM_ESP_MAX];
631-} __attribute__((packed));
632-
633-
634 struct hip_encrypted_aes_sha1 {
635 hip_tlv type;
636 hip_tlv_len length;
637
638=== modified file 'libcore/state.h'
639--- libcore/state.h 2012-05-12 10:21:32 +0000
640+++ libcore/state.h 2012-07-07 13:45:26 +0000
641@@ -314,6 +314,8 @@
642 unsigned spi_outbound_old;
643 unsigned spi_outbound_new;
644
645+ /* The HIP version in use for this HA pair */
646+ uint8_t hip_version;
647 /* modular state */
648 struct modular_state *hip_modular_state;
649 } __attribute__((packed));
650
651=== modified file 'libcore/transform.c'
652--- libcore/transform.c 2011-08-15 14:11:56 +0000
653+++ libcore/transform.c 2012-07-07 13:45:26 +0000
654@@ -1,5 +1,5 @@
655 /*
656- * Copyright (c) 2010 Aalto University and RWTH Aachen University.
657+ * Copyright (c) 2010, 2012 Aalto University and RWTH Aachen University.
658 *
659 * Permission is hereby granted, free of charge, to any person
660 * obtaining a copy of this software and associated documentation
661@@ -38,32 +38,27 @@
662 * select a HIP transform
663 *
664 * @param ht HIP_TRANSFORM payload where the transform is selected from
665- * @return the first acceptable Transform-ID or negative if no
666- * acceptable transform was found. The return value is in host byte order.
667+ * @return the first acceptable Transform-ID or zero if no acceptable
668+ * transform was found. The return value is in host byte order.
669 */
670-hip_transform_suite hip_select_hip_transform(const struct hip_hip_transform *ht)
671+hip_transform_suite hip_select_hip_transform(const struct hip_tlv_common *ht)
672 {
673- hip_transform_suite tid = 0;
674- int i;
675- int length;
676+ int item_number = HIP_TRANSFORM_HIP_MAX;
677+ hip_transform_suite tid = 0;
678 const hip_transform_suite *suggestion;
679-
680- length = ntohs(ht->length);
681- suggestion = (const hip_transform_suite *) &ht->suite_id[0];
682-
683- if ((length >> 1) > 6) {
684- HIP_ERROR("Too many transforms (%d)\n", length >> 1);
685- goto out;
686- }
687-
688- for (i = 0; i < length; i++) {
689- switch (ntohs(*suggestion)) {
690+ hip_transform_suite suite[item_number];
691+
692+ hip_get_list_from_param(ht, suite, &item_number,
693+ sizeof(hip_transform_suite));
694+
695+ suggestion = suite;
696+ while (item_number-- > 0) {
697+ switch (*suggestion) {
698 case HIP_HIP_AES_SHA1:
699 case HIP_HIP_3DES_SHA1:
700 case HIP_HIP_NULL_SHA1:
701- tid = ntohs(*suggestion);
702+ tid = *suggestion;
703 goto out;
704- break;
705
706 default:
707 /* Specs don't say what to do when unknown are found.
708@@ -88,35 +83,41 @@
709
710 /**
711 * select an ESP transform to use
712- * @param ht ESP_TRANSFORM payload where the transform is selected from
713+ * @param param ESP_TRANSFORM payload where the transform is selected from
714 *
715- * @return the first acceptable Suite-ID or negative if no
716- * acceptable Suite-ID was found.
717+ * @return the first acceptable Suite-ID or zero if no acceptable
718+ * Suite-ID was found.
719 */
720-hip_transform_suite hip_select_esp_transform(const struct hip_esp_transform *ht)
721+hip_transform_suite hip_select_esp_transform(const struct hip_tlv_common *param)
722 {
723- hip_transform_suite tid = 0;
724- unsigned i, length;
725+ int item_number = HIP_TRANSFORM_ESP_MAX;
726+ hip_transform_suite tid = 0;
727+ hip_transform_suite suite[item_number];
728 const hip_transform_suite *suggestion;
729
730- length = hip_get_param_contents_len(ht);
731- suggestion = (const hip_transform_suite *) &ht->suite_id[0];
732-
733- for (i = 0; i < length; i++) {
734- switch (ntohs(*suggestion)) {
735+ hip_get_list_from_param(param, suite, &item_number,
736+ sizeof(hip_transform_suite));
737+
738+ /* the first item in the list is a reserved field and should be ignored */
739+ if (--item_number < 1) {
740+ HIP_ERROR("Non ESP suite id can be found\n");
741+ return 0;
742+ }
743+ suggestion = &suite[1];
744+
745+ while (item_number-- > 0) {
746+ switch (*suggestion) {
747 case HIP_ESP_AES_SHA1:
748 case HIP_ESP_NULL_NULL:
749 case HIP_ESP_3DES_SHA1:
750 case HIP_ESP_NULL_SHA1:
751- tid = ntohs(*suggestion);
752+ tid = *suggestion;
753 goto out;
754- break;
755 default:
756 /* Specs don't say what to do when unknowns are found.
757 * We ignore.
758 */
759- HIP_ERROR("Unknown ESP suite id suggestion (%u)\n",
760- ntohs(*suggestion));
761+ HIP_ERROR("Unknown ESP suite id suggestion (%u)\n", *suggestion);
762 break;
763 }
764 suggestion++;
765
766=== modified file 'libcore/transform.h'
767--- libcore/transform.h 2012-05-12 06:54:33 +0000
768+++ libcore/transform.h 2012-07-07 13:45:26 +0000
769@@ -1,5 +1,5 @@
770 /*
771- * Copyright (c) 2010 Aalto University and RWTH Aachen University.
772+ * Copyright (c) 2010, 2012 Aalto University and RWTH Aachen University.
773 *
774 * Permission is hereby granted, free of charge, to any person
775 * obtaining a copy of this software and associated documentation
776@@ -28,8 +28,8 @@
777
778 #include "protodefs.h"
779
780-hip_transform_suite hip_select_esp_transform(const struct hip_esp_transform *);
781-hip_transform_suite hip_select_hip_transform(const struct hip_hip_transform *);
782+hip_transform_suite hip_select_esp_transform(const struct hip_tlv_common *param);
783+hip_transform_suite hip_select_hip_transform(const struct hip_tlv_common *param);
784 int hip_transform_key_length(int tid);
785
786 #endif /* HIPL_LIBCORE_TRANSFORM_H */
787
788=== modified file 'libhipl/close.c'
789--- libhipl/close.c 2012-05-12 10:21:32 +0000
790+++ libhipl/close.c 2012-07-07 13:45:26 +0000
791@@ -1,5 +1,5 @@
792 /*
793- * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University.
794+ * Copyright (c) 2010-2012 Aalto University and RWTH Aachen University.
795 *
796 * Permission is hereby granted, free of charge, to any person
797 * obtaining a copy of this software and associated documentation
798@@ -115,7 +115,8 @@
799 HIP_CLOSE,
800 mask,
801 &entry->hit_our,
802- &entry->hit_peer);
803+ &entry->hit_peer,
804+ entry->hip_version);
805
806 /********ECHO (SIGNED) **********/
807
808@@ -300,7 +301,8 @@
809 HIP_CLOSE_ACK,
810 HIP_PACKET_CTRL_NON,
811 &ctx->hadb_entry->hit_our,
812- &ctx->hadb_entry->hit_peer);
813+ &ctx->hadb_entry->hit_peer,
814+ ctx->hadb_entry->hip_version);
815
816 HIP_IFEL(hip_build_param_echo(ctx->output_msg, request + 1,
817 echo_len, 1, 0), -1,
818
819=== modified file 'libhipl/cookie.c'
820--- libhipl/cookie.c 2012-05-12 10:21:32 +0000
821+++ libhipl/cookie.c 2012-07-07 13:45:26 +0000
822@@ -179,16 +179,17 @@
823 /**
824 * get a copy of R1entry structure
825 *
826- * @param ip_i Initiator's IPv6
827- * @param ip_r Responder's IPv6
828- * @param our_hit Our HIT
829+ * @param ip_i Initiator's IPv6
830+ * @param ip_r Responder's IPv6
831+ * @param our_hit Our HIT
832+ * @param hip_version HIP message version
833 *
834 * @note Comments for the if 0 code are inlined below.
835 *
836 * Returns NULL if error.
837 */
838 struct hip_common *hip_get_r1(struct in6_addr *ip_i, struct in6_addr *ip_r,
839- struct in6_addr *our_hit)
840+ struct in6_addr *our_hit, uint8_t hip_version)
841 {
842 struct hip_common *err = NULL, *r1 = NULL;
843 struct hip_r1entry *hip_r1table = NULL;
844@@ -199,7 +200,7 @@
845 HIP_IFEL(!(hid = hip_get_hostid_entry_by_lhi_and_algo(our_hit, HIP_ANY_ALGO, -1)),
846 NULL, "Unknown HIT\n");
847
848- hip_r1table = hid->r1;
849+ hip_r1table = hid->r1[hip_version];
850 idx = calc_cookie_idx(ip_i, ip_r);
851 HIP_DEBUG("Calculated index: %d\n", idx);
852
853@@ -220,18 +221,20 @@
854 /**
855 * precreate an R1 packet
856 *
857- * @param r1table a pointer to R1 table structure
858- * @param hit the local HIT
859- * @param sign a signing callback function
860- * @param privkey the private key to use for signing
861- * @param pubkey the host id (public key)
862- * @return zero on success and non-zero on error
863+ * @param r1table a pointer to R1 table structure
864+ * @param hit the local HIT
865+ * @param sign a signing callback function
866+ * @param privkey the private key to use for signing
867+ * @param pubkey the host id (public key)
868+ * @param hip_version HIP message version
869+ * @return zero on success and non-zero on error
870 */
871 int hip_precreate_r1(struct hip_r1entry *const r1table,
872 const struct in6_addr *const hit,
873 int (*sign)(void *const key, struct hip_common *const m),
874 void *const privkey,
875- const struct hip_host_id *const pubkey)
876+ const struct hip_host_id *const pubkey,
877+ const uint8_t hip_version)
878 {
879 int i = 0;
880 for (i = 0; i < HIP_R1TABLESIZE; i++) {
881@@ -241,7 +244,8 @@
882
883 hip_msg_init(&r1table[i].buf.msg);
884
885- if (hip_create_r1(&r1table[i].buf.msg, hit, sign, privkey, pubkey, cookie_k)) {
886+ if (hip_create_r1(&r1table[i].buf.msg, hit, sign, privkey, pubkey,
887+ cookie_k, hip_version)) {
888 HIP_ERROR("Unable to precreate R1s\n");
889 return 0;
890 }
891@@ -257,16 +261,18 @@
892 * as in the puzzle we sent. If not, then we check the previous ones (since the
893 * puzzle might just have been expired).
894 *
895- * @param ip_i a pointer to Initiator's IP address.
896- * @param ip_r a pointer to Responder's IP address.
897- * @param hdr a pointer to HIP packet common header
898- * @param solution a pointer to a solution structure
899- * @return Zero if the cookie was verified successfully, negative
900- * otherwise.
901+ * @param ip_i a pointer to Initiator's IP address.
902+ * @param ip_r a pointer to Responder's IP address.
903+ * @param hdr a pointer to HIP packet common header
904+ * @param solution a pointer to a solution structure
905+ * @param hip_version HIP message version
906+ * @return Zero if the cookie was verified successfully, negative
907+ * otherwise.
908 */
909 int hip_verify_cookie(struct in6_addr *ip_i, struct in6_addr *ip_r,
910 struct hip_common *hdr,
911- const struct hip_solution *solution)
912+ const struct hip_solution *solution,
913+ const uint8_t hip_version)
914 {
915 /* In a effort to conform the HIPL coding convention, the return value
916 * of this function was inverted. I.e. This function now returns
917@@ -283,7 +289,7 @@
918 HIP_ANY_ALGO,
919 -1)),
920 -1, "Requested source HIT not (any more) available.\n");
921- result = &hid->r1[calc_cookie_idx(ip_i, ip_r)];
922+ result = &hid->r1[hip_version][calc_cookie_idx(ip_i, ip_r)];
923
924 puzzle = hip_get_param(&result->buf.msg, HIP_PARAM_PUZZLE);
925 HIP_IFEL(!puzzle, -1, "Internal error: could not find the cookie\n");
926@@ -338,6 +344,7 @@
927 static int recreate_r1s_for_entry_move(struct local_host_id *entry,
928 UNUSED void *opaque)
929 {
930+ int i;
931 int (*signature_func)(void *const key, struct hip_common *const m);
932
933 switch (hip_get_host_id_algo(&entry->host_id)) {
934@@ -357,9 +364,11 @@
935 return -1;
936 }
937
938- if (!hip_precreate_r1(entry->r1, &entry->hit, signature_func,
939- entry->private_key, &entry->host_id)) {
940- return -1;
941+ for (i = 1; i < HIP_MAX_VERSION; i++) {
942+ if (!hip_precreate_r1(entry->r1[i], &entry->hit, signature_func,
943+ entry->private_key, &entry->host_id, i)) {
944+ return -1;
945+ }
946 }
947
948 return 0;
949
950=== modified file 'libhipl/cookie.h'
951--- libhipl/cookie.h 2012-05-12 10:21:32 +0000
952+++ libhipl/cookie.h 2012-07-07 13:45:26 +0000
953@@ -1,5 +1,5 @@
954 /*
955- * Copyright (c) 2010 Aalto University and RWTH Aachen University.
956+ * Copyright (c) 2010, 2012 Aalto University and RWTH Aachen University.
957 *
958 * Permission is hereby granted, free of charge, to any person
959 * obtaining a copy of this software and associated documentation
960@@ -43,16 +43,19 @@
961
962 struct hip_common *hip_get_r1(struct in6_addr *ip_i,
963 struct in6_addr *ip_r,
964- struct in6_addr *peer_hit);
965+ struct in6_addr *peer_hit,
966+ uint8_t hip_version);
967 int hip_recreate_all_precreated_r1_packets(void);
968 int hip_precreate_r1(struct hip_r1entry *const r1table,
969 const struct in6_addr *const hit,
970 int (*sign)(void *const key, struct hip_common *const m),
971 void *const privkey,
972- const struct hip_host_id *const pubkey);
973+ const struct hip_host_id *const pubkey,
974+ const uint8_t hip_version);
975 int hip_verify_cookie(struct in6_addr *ip_i, struct in6_addr *ip_r,
976 struct hip_common *hdr,
977- const struct hip_solution *cookie);
978+ const struct hip_solution *cookie,
979+ const uint8_t hip_version);
980 int hip_inc_cookie_difficulty(void);
981 int hip_dec_cookie_difficulty(void);
982 int hip_get_puzzle_difficulty_msg(struct hip_common *msg);
983
984=== modified file 'libhipl/esp_prot_hipd_msg.c'
985--- libhipl/esp_prot_hipd_msg.c 2012-05-12 10:21:32 +0000
986+++ libhipl/esp_prot_hipd_msg.c 2012-07-07 13:45:26 +0000
987@@ -92,7 +92,8 @@
988 HIP_UPDATE,
989 mask,
990 &recv_update->hit_receiver,
991- &recv_update->hit_sender);
992+ &recv_update->hit_sender,
993+ entry->hip_version);
994
995 /* Add ESP_INFO */
996 HIP_IFEL(hip_build_param_esp_info(resp_update,
997
998=== modified file 'libhipl/esp_prot_light_update.c'
999--- libhipl/esp_prot_light_update.c 2012-05-12 10:21:32 +0000
1000+++ libhipl/esp_prot_light_update.c 2012-07-07 13:45:26 +0000
1001@@ -1,5 +1,5 @@
1002 /*
1003- * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University.
1004+ * Copyright (c) 2010-2012 Aalto University and RWTH Aachen University.
1005 *
1006 * Permission is hereby granted, free of charge, to any person
1007 * obtaining a copy of this software and associated documentation
1008@@ -76,7 +76,8 @@
1009 HIP_LUPDATE,
1010 mask,
1011 &entry->hit_our,
1012- &entry->hit_peer);
1013+ &entry->hit_peer,
1014+ entry->hip_version);
1015
1016 /* Add ESP_INFO */
1017 HIP_IFEL(hip_build_param_esp_info(light_ack, entry->current_keymat_index,
1018@@ -134,7 +135,8 @@
1019 HIP_LUPDATE,
1020 mask,
1021 &entry->hit_our,
1022- &entry->hit_peer);
1023+ &entry->hit_peer,
1024+ entry->hip_version);
1025
1026 /********************* add SEQ *********************/
1027
1028
1029=== modified file 'libhipl/hidb.c'
1030--- libhipl/hidb.c 2012-05-12 10:21:32 +0000
1031+++ libhipl/hidb.c 2012-07-07 13:45:26 +0000
1032@@ -429,6 +429,7 @@
1033 hip_lsi_t *lsi,
1034 const struct hip_host_id_priv *host_id)
1035 {
1036+ int i;
1037 int err = 0;
1038 struct local_host_id *id_entry = NULL;
1039 struct local_host_id *old_entry;
1040@@ -492,13 +493,16 @@
1041 err = -1;
1042 goto out_err;
1043 }
1044-
1045- HIP_IFEL(!hip_precreate_r1(id_entry->r1,
1046- &hit,
1047- signature_func,
1048- id_entry->private_key, &id_entry->host_id),
1049- -ENOENT,
1050- "Unable to precreate R1s.\n");
1051+ for (i = 1; i < HIP_MAX_VERSION; i++) {
1052+ HIP_IFEL(!hip_precreate_r1(id_entry->r1[i],
1053+ &hit,
1054+ signature_func,
1055+ id_entry->private_key,
1056+ &id_entry->host_id,
1057+ i),
1058+ -ENOENT,
1059+ "Unable to precreate R1s.\n");
1060+ }
1061
1062 out_err:
1063 if (err && id_entry) {
1064
1065=== modified file 'libhipl/hidb.h'
1066--- libhipl/hidb.h 2012-05-12 10:21:32 +0000
1067+++ libhipl/hidb.h 2012-07-07 13:45:26 +0000
1068@@ -45,7 +45,7 @@
1069 hip_lsi_t lsi;
1070 struct hip_host_id host_id;
1071 void *private_key; /* RSA or DSA */
1072- struct hip_r1entry r1[HIP_R1TABLESIZE]; /* precreated R1s */
1073+ struct hip_r1entry r1[HIP_MAX_VERSION][HIP_R1TABLESIZE]; /* precreated R1s */
1074 };
1075
1076 struct local_host_id *hip_get_hostid_entry_by_lhi_and_algo(const struct in6_addr *const hit,
1077
1078=== modified file 'libhipl/hiprelay.c'
1079--- libhipl/hiprelay.c 2012-05-12 10:21:32 +0000
1080+++ libhipl/hiprelay.c 2012-07-07 13:45:26 +0000
1081@@ -851,7 +851,8 @@
1082
1083 hip_build_network_hdr(msg_to_be_relayed, type_hdr, 0,
1084 &ctx->input_msg->hit_sender,
1085- &ctx->input_msg->hit_receiver);
1086+ &ctx->input_msg->hit_receiver,
1087+ hip_get_msg_version(ctx->input_msg));
1088
1089 /* Notice that in most cases the incoming I1 has no paramaters at all,
1090 * and this "while" loop is skipped. Multiple rvses en route to responder
1091@@ -962,7 +963,8 @@
1092 "No memory to copy original I1\n");
1093
1094 hip_build_network_hdr(r_to_be_relayed, type_hdr, 0,
1095- &r->hit_sender, &r->hit_receiver);
1096+ &r->hit_sender, &r->hit_receiver,
1097+ hip_get_msg_version(r));
1098
1099 while ((current_param = hip_get_next_param(r, current_param)) != NULL) {
1100 HIP_DEBUG("Found parameter in R.\n");
1101
1102=== modified file 'libhipl/init.c'
1103--- libhipl/init.c 2012-05-12 10:21:32 +0000
1104+++ libhipl/init.c 2012-07-07 13:45:26 +0000
1105@@ -151,6 +151,11 @@
1106 /* Startup flags of the HIPD. Keep the around, for they will be used at exit */
1107 static uint64_t sflags;
1108
1109+/* The value of the default HIP version loaded from hipd.conf. Its accessor
1110+ * functions are hip_set_default_version() and hip_get_default_version().
1111+ */
1112+static uint8_t hip_default_hip_version = 1;
1113+
1114 /******************************************************************************/
1115 /**
1116 * Catch SIGCHLD.
1117@@ -553,403 +558,605 @@
1118 lmod_register_packet_type(HIP_LUPDATE, "HIP_LUPDATE");
1119 }
1120
1121+static void init_handle_functions_v1(void)
1122+{
1123+ HIP_DEBUG("Initialize handle functions.\n");
1124+
1125+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_check_i1, 20000);
1126+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_handle_i1, 30000);
1127+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_update_retransmissions, 35000);
1128+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_send_r1, 40000);
1129+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I1_SENT, &hip_check_i1, 20000);
1130+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I1_SENT, &hip_handle_i1, 30000);
1131+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I1_SENT, &hip_update_retransmissions, 35000);
1132+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I1_SENT, &hip_send_r1, 40000);
1133+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I2_SENT, &hip_check_i1, 20000);
1134+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I2_SENT, &hip_handle_i1, 30000);
1135+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I2_SENT, &hip_update_retransmissions, 35000);
1136+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I2_SENT, &hip_send_r1, 40000);
1137+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_R2_SENT, &hip_check_i1, 20000);
1138+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_R2_SENT, &hip_handle_i1, 30000);
1139+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_R2_SENT, &hip_update_retransmissions, 35000);
1140+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_R2_SENT, &hip_send_r1, 40000);
1141+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_ESTABLISHED, &hip_check_i1, 20000);
1142+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_ESTABLISHED, &hip_handle_i1, 30000);
1143+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 35000);
1144+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_ESTABLISHED, &hip_send_r1, 40000);
1145+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSING, &hip_check_i1, 20000);
1146+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSING, &hip_handle_i1, 30000);
1147+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSING, &hip_update_retransmissions, 35000);
1148+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSING, &hip_send_r1, 40000);
1149+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSED, &hip_check_i1, 20000);
1150+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSED, &hip_handle_i1, 30000);
1151+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSED, &hip_update_retransmissions, 35000);
1152+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSED, &hip_send_r1, 40000);
1153+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_NONE, &hip_check_i1, 20000);
1154+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_NONE, &hip_handle_i1, 30000);
1155+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_NONE, &hip_update_retransmissions, 35000);
1156+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_NONE, &hip_send_r1, 40000);
1157+
1158+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_check_i2, 20000);
1159+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_handle_i2, 30000);
1160+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_update_retransmissions, 30250);
1161+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_setup_ipsec_sa, 30500);
1162+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_create_r2, 40000);
1163+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_add_rvs_reg_from, 41000);
1164+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_hmac2_and_sign, 42000);
1165+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_add_rvs_relay_to, 43000);
1166+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_send_r2, 50000);
1167+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_check_i2, 20000);
1168+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_handle_i2, 30000);
1169+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_update_retransmissions, 30250);
1170+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_setup_ipsec_sa, 30500);
1171+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_create_r2, 40000);
1172+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_add_rvs_reg_from, 41000);
1173+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_hmac2_and_sign, 42000);
1174+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_add_rvs_relay_to, 43000);
1175+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_send_r2, 50000);
1176+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_check_i2, 20000);
1177+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_handle_i2_in_i2_sent, 21000);
1178+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_handle_i2, 30000);
1179+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30250);
1180+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_setup_ipsec_sa, 30500);
1181+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_create_r2, 40000);
1182+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_add_rvs_reg_from, 41000);
1183+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_hmac2_and_sign, 42000);
1184+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_add_rvs_relay_to, 43000);
1185+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_send_r2, 50000);
1186+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_check_i2, 20000);
1187+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_handle_i2, 30000);
1188+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_update_retransmissions, 30250);
1189+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_setup_ipsec_sa, 30500);
1190+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_create_r2, 40000);
1191+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_add_rvs_reg_from, 41000);
1192+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_hmac2_and_sign, 42000);
1193+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_add_rvs_relay_to, 43000);
1194+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_send_r2, 50000);
1195+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_check_i2, 20000);
1196+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_handle_i2, 30000);
1197+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 30250);
1198+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_setup_ipsec_sa, 30500);
1199+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_create_r2, 40000);
1200+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_add_rvs_reg_from, 41000);
1201+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_hmac2_and_sign, 42000);
1202+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_add_rvs_relay_to, 43000);
1203+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_send_r2, 50000);
1204+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_check_i2, 20000);
1205+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_handle_i2, 30000);
1206+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_update_retransmissions, 30250);
1207+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_setup_ipsec_sa, 30500);
1208+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_create_r2, 40000);
1209+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_add_rvs_reg_from, 41000);
1210+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_hmac2_and_sign, 42000);
1211+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_add_rvs_relay_to, 43000);
1212+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_send_r2, 50000);
1213+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_check_i2, 20000);
1214+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_handle_i2, 30000);
1215+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_update_retransmissions, 30250);
1216+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_setup_ipsec_sa, 30500);
1217+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_create_r2, 40000);
1218+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_add_rvs_reg_from, 41000);
1219+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_hmac2_and_sign, 42000);
1220+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_add_rvs_relay_to, 43000);
1221+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_send_r2, 50000);
1222+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_check_i2, 20000);
1223+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_handle_i2, 30000);
1224+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_update_retransmissions, 30250);
1225+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_setup_ipsec_sa, 30500);
1226+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_create_r2, 40000);
1227+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_add_rvs_reg_from, 41000);
1228+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_hmac2_and_sign, 42000);
1229+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_add_rvs_relay_to, 43000);
1230+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_send_r2, 50000);
1231+
1232+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_check_r1, 20000);
1233+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_handle_r1, 30000);
1234+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_update_retransmissions, 30500);
1235+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_build_esp_info, 31000);
1236+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_build_solution, 32000);
1237+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_handle_diffie_hellman, 33000);
1238+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &esp_prot_r1_handle_transforms, 34000);
1239+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_create_i2, 40000);
1240+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_add_signed_echo_response, 41000);
1241+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_mac_and_sign_handler, 42000);
1242+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_add_unsigned_echo_response, 43000);
1243+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_send_i2, 50000);
1244+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_check_r1, 20000);
1245+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_handle_r1, 30000);
1246+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30500);
1247+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_build_esp_info, 31000);
1248+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_build_solution, 32000);
1249+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_handle_diffie_hellman, 33000);
1250+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &esp_prot_r1_handle_transforms, 34000);
1251+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_create_i2, 40000);
1252+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_add_signed_echo_response, 41000);
1253+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_mac_and_sign_handler, 42000);
1254+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_add_unsigned_echo_response, 43000);
1255+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_send_i2, 50000);
1256+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_check_r1, 20000);
1257+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_handle_r1, 30000);
1258+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_update_retransmissions, 30500);
1259+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_build_esp_info, 31000);
1260+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_build_solution, 32000);
1261+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_handle_diffie_hellman, 33000);
1262+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &esp_prot_r1_handle_transforms, 34000);
1263+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_create_i2, 40000);
1264+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_add_signed_echo_response, 41000);
1265+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_mac_and_sign_handler, 42000);
1266+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_add_unsigned_echo_response, 43000);
1267+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_send_i2, 50000);
1268+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_check_r1, 20000);
1269+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_handle_r1, 30000);
1270+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_update_retransmissions, 30500);
1271+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_build_esp_info, 31000);
1272+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_build_solution, 32000);
1273+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_handle_diffie_hellman, 33000);
1274+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &esp_prot_r1_handle_transforms, 34000);
1275+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_create_i2, 40000);
1276+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_add_signed_echo_response, 41000);
1277+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_mac_and_sign_handler, 42000);
1278+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_add_unsigned_echo_response, 43000);
1279+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_send_i2, 50000);
1280+
1281+ hip_register_handle_function(HIP_V1, HIP_R2, HIP_STATE_I2_SENT, &hip_check_r2, 20000);
1282+ hip_register_handle_function(HIP_V1, HIP_R2, HIP_STATE_I2_SENT, &hip_handle_r2, 30000);
1283+ hip_register_handle_function(HIP_V1, HIP_R2, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30250);
1284+ hip_register_handle_function(HIP_V1, HIP_R2, HIP_STATE_I2_SENT, &hip_setup_ipsec_sa, 30500);
1285+
1286+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_I1_SENT, &hip_check_notify, 20000);
1287+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_I1_SENT, &hip_handle_notify, 30000);
1288+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_I2_SENT, &hip_check_notify, 20000);
1289+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_I2_SENT, &hip_handle_notify, 30000);
1290+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_R2_SENT, &hip_check_notify, 20000);
1291+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_R2_SENT, &hip_handle_notify, 30000);
1292+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_ESTABLISHED, &hip_check_notify, 20000);
1293+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_ESTABLISHED, &hip_handle_notify, 30000);
1294+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_CLOSING, &hip_check_notify, 20000);
1295+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_CLOSING, &hip_handle_notify, 30000);
1296+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_CLOSED, &hip_check_notify, 20000);
1297+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_CLOSED, &hip_handle_notify, 30000);
1298+
1299+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_check_packet, 20000);
1300+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 25000);
1301+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_create_response, 30000);
1302+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_send_response, 40000);
1303+
1304+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_check_packet, 20000);
1305+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_CLOSING, &hip_update_retransmissions, 25000);
1306+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_create_response, 30000);
1307+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_send_response, 40000);
1308+
1309+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_close_ack_check_packet, 20000);
1310+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_update_retransmissions, 25000);
1311+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_close_ack_handle_packet, 30000);
1312+
1313+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_close_ack_check_packet, 20000);
1314+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_update_retransmissions, 25000);
1315+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_close_ack_handle_packet, 30000);
1316+
1317+ hip_register_handle_function(HIP_V1, HIP_LUPDATE, HIP_STATE_ESTABLISHED, &esp_prot_handle_light_update, 20000);
1318+ hip_register_handle_function(HIP_V1, HIP_LUPDATE, HIP_STATE_R2_SENT, &esp_prot_handle_light_update, 20000);
1319+}
1320+
1321+static void init_handle_functions_v2(void)
1322+{
1323+ HIP_DEBUG("Initialize handle functions.\n");
1324+
1325+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_check_i1, 20000);
1326+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_handle_i1, 30000);
1327+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_update_retransmissions, 35000);
1328+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_send_r1, 40000);
1329+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_I1_SENT, &hip_check_i1, 20000);
1330+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_I1_SENT, &hip_handle_i1, 30000);
1331+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_I1_SENT, &hip_update_retransmissions, 35000);
1332+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_I1_SENT, &hip_send_r1, 40000);
1333+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_I2_SENT, &hip_check_i1, 20000);
1334+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_I2_SENT, &hip_handle_i1, 30000);
1335+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_I2_SENT, &hip_update_retransmissions, 35000);
1336+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_I2_SENT, &hip_send_r1, 40000);
1337+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_R2_SENT, &hip_check_i1, 20000);
1338+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_R2_SENT, &hip_handle_i1, 30000);
1339+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_R2_SENT, &hip_update_retransmissions, 35000);
1340+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_R2_SENT, &hip_send_r1, 40000);
1341+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_ESTABLISHED, &hip_check_i1, 20000);
1342+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_ESTABLISHED, &hip_handle_i1, 30000);
1343+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 35000);
1344+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_ESTABLISHED, &hip_send_r1, 40000);
1345+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_CLOSING, &hip_check_i1, 20000);
1346+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_CLOSING, &hip_handle_i1, 30000);
1347+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_CLOSING, &hip_update_retransmissions, 35000);
1348+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_CLOSING, &hip_send_r1, 40000);
1349+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_CLOSED, &hip_check_i1, 20000);
1350+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_CLOSED, &hip_handle_i1, 30000);
1351+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_CLOSED, &hip_update_retransmissions, 35000);
1352+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_CLOSED, &hip_send_r1, 40000);
1353+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_NONE, &hip_check_i1, 20000);
1354+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_NONE, &hip_handle_i1, 30000);
1355+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_NONE, &hip_update_retransmissions, 35000);
1356+ hip_register_handle_function(HIP_V2, HIP_I1, HIP_STATE_NONE, &hip_send_r1, 40000);
1357+
1358+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_check_i2, 20000);
1359+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_handle_i2, 30000);
1360+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_update_retransmissions, 30250);
1361+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_setup_ipsec_sa, 30500);
1362+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_create_r2, 40000);
1363+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_add_rvs_reg_from, 41000);
1364+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_hmac2_and_sign, 42000);
1365+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_add_rvs_relay_to, 43000);
1366+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_send_r2, 50000);
1367+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I1_SENT, &hip_check_i2, 20000);
1368+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I1_SENT, &hip_handle_i2, 30000);
1369+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I1_SENT, &hip_update_retransmissions, 30250);
1370+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I1_SENT, &hip_setup_ipsec_sa, 30500);
1371+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I1_SENT, &hip_create_r2, 40000);
1372+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I1_SENT, &hip_add_rvs_reg_from, 41000);
1373+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I1_SENT, &hip_hmac2_and_sign, 42000);
1374+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I1_SENT, &hip_add_rvs_relay_to, 43000);
1375+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I1_SENT, &hip_send_r2, 50000);
1376+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I2_SENT, &hip_check_i2, 20000);
1377+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I2_SENT, &hip_handle_i2_in_i2_sent, 21000);
1378+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I2_SENT, &hip_handle_i2, 30000);
1379+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30250);
1380+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I2_SENT, &hip_setup_ipsec_sa, 30500);
1381+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I2_SENT, &hip_create_r2, 40000);
1382+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I2_SENT, &hip_add_rvs_reg_from, 41000);
1383+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I2_SENT, &hip_hmac2_and_sign, 42000);
1384+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I2_SENT, &hip_add_rvs_relay_to, 43000);
1385+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_I2_SENT, &hip_send_r2, 50000);
1386+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_R2_SENT, &hip_check_i2, 20000);
1387+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_R2_SENT, &hip_handle_i2, 30000);
1388+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_R2_SENT, &hip_update_retransmissions, 30250);
1389+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_R2_SENT, &hip_setup_ipsec_sa, 30500);
1390+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_R2_SENT, &hip_create_r2, 40000);
1391+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_R2_SENT, &hip_add_rvs_reg_from, 41000);
1392+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_R2_SENT, &hip_hmac2_and_sign, 42000);
1393+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_R2_SENT, &hip_add_rvs_relay_to, 43000);
1394+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_R2_SENT, &hip_send_r2, 50000);
1395+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_ESTABLISHED, &hip_check_i2, 20000);
1396+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_ESTABLISHED, &hip_handle_i2, 30000);
1397+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 30250);
1398+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_ESTABLISHED, &hip_setup_ipsec_sa, 30500);
1399+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_ESTABLISHED, &hip_create_r2, 40000);
1400+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_ESTABLISHED, &hip_add_rvs_reg_from, 41000);
1401+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_ESTABLISHED, &hip_hmac2_and_sign, 42000);
1402+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_ESTABLISHED, &hip_add_rvs_relay_to, 43000);
1403+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_ESTABLISHED, &hip_send_r2, 50000);
1404+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSING, &hip_check_i2, 20000);
1405+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSING, &hip_handle_i2, 30000);
1406+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSING, &hip_update_retransmissions, 30250);
1407+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSING, &hip_setup_ipsec_sa, 30500);
1408+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSING, &hip_create_r2, 40000);
1409+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSING, &hip_add_rvs_reg_from, 41000);
1410+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSING, &hip_hmac2_and_sign, 42000);
1411+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSING, &hip_add_rvs_relay_to, 43000);
1412+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSING, &hip_send_r2, 50000);
1413+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSED, &hip_check_i2, 20000);
1414+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSED, &hip_handle_i2, 30000);
1415+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSED, &hip_update_retransmissions, 30250);
1416+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSED, &hip_setup_ipsec_sa, 30500);
1417+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSED, &hip_create_r2, 40000);
1418+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSED, &hip_add_rvs_reg_from, 41000);
1419+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSED, &hip_hmac2_and_sign, 42000);
1420+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSED, &hip_add_rvs_relay_to, 43000);
1421+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_CLOSED, &hip_send_r2, 50000);
1422+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_NONE, &hip_check_i2, 20000);
1423+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_NONE, &hip_handle_i2, 30000);
1424+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_NONE, &hip_update_retransmissions, 30250);
1425+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_NONE, &hip_setup_ipsec_sa, 30500);
1426+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_NONE, &hip_create_r2, 40000);
1427+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_NONE, &hip_add_rvs_reg_from, 41000);
1428+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_NONE, &hip_hmac2_and_sign, 42000);
1429+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_NONE, &hip_add_rvs_relay_to, 43000);
1430+ hip_register_handle_function(HIP_V2, HIP_I2, HIP_STATE_NONE, &hip_send_r2, 50000);
1431+
1432+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &hip_check_r1, 20000);
1433+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &hip_handle_r1, 30000);
1434+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &hip_update_retransmissions, 30500);
1435+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &hip_build_esp_info, 31000);
1436+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &hip_build_solution, 32000);
1437+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &hip_handle_diffie_hellman, 33000);
1438+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &esp_prot_r1_handle_transforms, 34000);
1439+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &hip_create_i2, 40000);
1440+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &hip_add_signed_echo_response, 41000);
1441+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &hip_mac_and_sign_handler, 42000);
1442+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &hip_add_unsigned_echo_response, 43000);
1443+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I1_SENT, &hip_send_i2, 50000);
1444+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &hip_check_r1, 20000);
1445+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &hip_handle_r1, 30000);
1446+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30500);
1447+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &hip_build_esp_info, 31000);
1448+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &hip_build_solution, 32000);
1449+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &hip_handle_diffie_hellman, 33000);
1450+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &esp_prot_r1_handle_transforms, 34000);
1451+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &hip_create_i2, 40000);
1452+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &hip_add_signed_echo_response, 41000);
1453+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &hip_mac_and_sign_handler, 42000);
1454+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &hip_add_unsigned_echo_response, 43000);
1455+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_I2_SENT, &hip_send_i2, 50000);
1456+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &hip_check_r1, 20000);
1457+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &hip_handle_r1, 30000);
1458+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &hip_update_retransmissions, 30500);
1459+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &hip_build_esp_info, 31000);
1460+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &hip_build_solution, 32000);
1461+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &hip_handle_diffie_hellman, 33000);
1462+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &esp_prot_r1_handle_transforms, 34000);
1463+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &hip_create_i2, 40000);
1464+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &hip_add_signed_echo_response, 41000);
1465+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &hip_mac_and_sign_handler, 42000);
1466+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &hip_add_unsigned_echo_response, 43000);
1467+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSING, &hip_send_i2, 50000);
1468+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &hip_check_r1, 20000);
1469+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &hip_handle_r1, 30000);
1470+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &hip_update_retransmissions, 30500);
1471+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &hip_build_esp_info, 31000);
1472+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &hip_build_solution, 32000);
1473+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &hip_handle_diffie_hellman, 33000);
1474+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &esp_prot_r1_handle_transforms, 34000);
1475+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &hip_create_i2, 40000);
1476+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &hip_add_signed_echo_response, 41000);
1477+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &hip_mac_and_sign_handler, 42000);
1478+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &hip_add_unsigned_echo_response, 43000);
1479+ hip_register_handle_function(HIP_V2, HIP_R1, HIP_STATE_CLOSED, &hip_send_i2, 50000);
1480+
1481+ hip_register_handle_function(HIP_V2, HIP_R2, HIP_STATE_I2_SENT, &hip_check_r2, 20000);
1482+ hip_register_handle_function(HIP_V2, HIP_R2, HIP_STATE_I2_SENT, &hip_handle_r2, 30000);
1483+ hip_register_handle_function(HIP_V2, HIP_R2, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30250);
1484+ hip_register_handle_function(HIP_V2, HIP_R2, HIP_STATE_I2_SENT, &hip_setup_ipsec_sa, 30500);
1485+
1486+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_I1_SENT, &hip_check_notify, 20000);
1487+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_I1_SENT, &hip_handle_notify, 30000);
1488+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_I2_SENT, &hip_check_notify, 20000);
1489+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_I2_SENT, &hip_handle_notify, 30000);
1490+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_R2_SENT, &hip_check_notify, 20000);
1491+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_R2_SENT, &hip_handle_notify, 30000);
1492+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_ESTABLISHED, &hip_check_notify, 20000);
1493+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_ESTABLISHED, &hip_handle_notify, 30000);
1494+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_CLOSING, &hip_check_notify, 20000);
1495+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_CLOSING, &hip_handle_notify, 30000);
1496+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_CLOSED, &hip_check_notify, 20000);
1497+ hip_register_handle_function(HIP_V2, HIP_NOTIFY, HIP_STATE_CLOSED, &hip_handle_notify, 30000);
1498+
1499+ hip_register_handle_function(HIP_V2, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_check_packet, 20000);
1500+ hip_register_handle_function(HIP_V2, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 25000);
1501+ hip_register_handle_function(HIP_V2, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_create_response, 30000);
1502+ hip_register_handle_function(HIP_V2, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_send_response, 40000);
1503+
1504+ hip_register_handle_function(HIP_V2, HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_check_packet, 20000);
1505+ hip_register_handle_function(HIP_V2, HIP_CLOSE, HIP_STATE_CLOSING, &hip_update_retransmissions, 25000);
1506+ hip_register_handle_function(HIP_V2, HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_create_response, 30000);
1507+ hip_register_handle_function(HIP_V2, HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_send_response, 40000);
1508+
1509+ hip_register_handle_function(HIP_V2, HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_close_ack_check_packet, 20000);
1510+ hip_register_handle_function(HIP_V2, HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_update_retransmissions, 25000);
1511+ hip_register_handle_function(HIP_V2, HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_close_ack_handle_packet, 30000);
1512+
1513+ hip_register_handle_function(HIP_V2, HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_close_ack_check_packet, 20000);
1514+ hip_register_handle_function(HIP_V2, HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_update_retransmissions, 25000);
1515+ hip_register_handle_function(HIP_V2, HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_close_ack_handle_packet, 30000);
1516+
1517+ hip_register_handle_function(HIP_V2, HIP_LUPDATE, HIP_STATE_ESTABLISHED, &esp_prot_handle_light_update, 20000);
1518+ hip_register_handle_function(HIP_V2, HIP_LUPDATE, HIP_STATE_R2_SENT, &esp_prot_handle_light_update, 20000);
1519+}
1520+
1521+static void init_handle_functions(void)
1522+{
1523+ init_handle_functions_v1();
1524+ init_handle_functions_v2();
1525+}
1526+
1527 static int libhip_init_handle_functions(void)
1528 {
1529 HIP_DEBUG("Initialize handle functions for libhip.\n");
1530
1531- hip_register_handle_function(HIP_I1, HIP_STATE_UNASSOCIATED, &hip_check_i1, 20000);
1532- hip_register_handle_function(HIP_I1, HIP_STATE_UNASSOCIATED, &hip_handle_i1, 30000);
1533- hip_register_handle_function(HIP_I1, HIP_STATE_UNASSOCIATED, &hip_update_retransmissions, 35000);
1534- hip_register_handle_function(HIP_I1, HIP_STATE_UNASSOCIATED, &hip_send_r1, 40000);
1535- hip_register_handle_function(HIP_I1, HIP_STATE_I1_SENT, &hip_check_i1, 20000);
1536- hip_register_handle_function(HIP_I1, HIP_STATE_I1_SENT, &hip_handle_i1, 30000);
1537- hip_register_handle_function(HIP_I1, HIP_STATE_I1_SENT, &hip_update_retransmissions, 35000);
1538- hip_register_handle_function(HIP_I1, HIP_STATE_I1_SENT, &hip_send_r1, 40000);
1539- hip_register_handle_function(HIP_I1, HIP_STATE_I2_SENT, &hip_check_i1, 20000);
1540- hip_register_handle_function(HIP_I1, HIP_STATE_I2_SENT, &hip_handle_i1, 30000);
1541- hip_register_handle_function(HIP_I1, HIP_STATE_I2_SENT, &hip_update_retransmissions, 35000);
1542- hip_register_handle_function(HIP_I1, HIP_STATE_I2_SENT, &hip_send_r1, 40000);
1543- hip_register_handle_function(HIP_I1, HIP_STATE_R2_SENT, &hip_check_i1, 20000);
1544- hip_register_handle_function(HIP_I1, HIP_STATE_R2_SENT, &hip_handle_i1, 30000);
1545- hip_register_handle_function(HIP_I1, HIP_STATE_R2_SENT, &hip_update_retransmissions, 35000);
1546- hip_register_handle_function(HIP_I1, HIP_STATE_R2_SENT, &hip_send_r1, 40000);
1547- hip_register_handle_function(HIP_I1, HIP_STATE_ESTABLISHED, &hip_check_i1, 20000);
1548- hip_register_handle_function(HIP_I1, HIP_STATE_ESTABLISHED, &hip_handle_i1, 30000);
1549- hip_register_handle_function(HIP_I1, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 35000);
1550- hip_register_handle_function(HIP_I1, HIP_STATE_ESTABLISHED, &hip_send_r1, 40000);
1551- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSING, &hip_check_i1, 20000);
1552- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSING, &hip_handle_i1, 30000);
1553- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSING, &hip_update_retransmissions, 35000);
1554- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSING, &hip_send_r1, 40000);
1555- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSED, &hip_check_i1, 20000);
1556- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSED, &hip_handle_i1, 30000);
1557- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSED, &hip_update_retransmissions, 35000);
1558- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSED, &hip_send_r1, 40000);
1559- hip_register_handle_function(HIP_I1, HIP_STATE_NONE, &hip_check_i1, 20000);
1560- hip_register_handle_function(HIP_I1, HIP_STATE_NONE, &hip_handle_i1, 30000);
1561- hip_register_handle_function(HIP_I1, HIP_STATE_NONE, &hip_update_retransmissions, 35000);
1562- hip_register_handle_function(HIP_I1, HIP_STATE_NONE, &hip_send_r1, 40000);
1563-
1564- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_check_i2, 20000);
1565- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_handle_i2, 30000);
1566- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_update_retransmissions, 30250);
1567- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_create_r2, 40000);
1568- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_add_rvs_reg_from, 41000);
1569- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_hmac2_and_sign, 42000);
1570- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_add_rvs_relay_to, 43000);
1571- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_send_r2, 50000);
1572- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_check_i2, 20000);
1573- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_handle_i2, 30000);
1574- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_update_retransmissions, 30250);
1575- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_create_r2, 40000);
1576- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_add_rvs_reg_from, 41000);
1577- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_hmac2_and_sign, 42000);
1578- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_add_rvs_relay_to, 43000);
1579- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_send_r2, 50000);
1580- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_check_i2, 20000);
1581- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_handle_i2_in_i2_sent, 21000);
1582- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_handle_i2, 30000);
1583- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30250);
1584- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_create_r2, 40000);
1585- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_add_rvs_reg_from, 41000);
1586- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_hmac2_and_sign, 42000);
1587- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_add_rvs_relay_to, 43000);
1588- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_send_r2, 50000);
1589- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_check_i2, 20000);
1590- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_handle_i2, 30000);
1591- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_update_retransmissions, 30250);
1592- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_create_r2, 40000);
1593- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_add_rvs_reg_from, 41000);
1594- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_hmac2_and_sign, 42000);
1595- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_add_rvs_relay_to, 43000);
1596- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_send_r2, 50000);
1597- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_check_i2, 20000);
1598- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_handle_i2, 30000);
1599- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 30250);
1600- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_create_r2, 40000);
1601- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_add_rvs_reg_from, 41000);
1602- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_hmac2_and_sign, 42000);
1603- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_add_rvs_relay_to, 43000);
1604- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_send_r2, 50000);
1605- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_check_i2, 20000);
1606- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_handle_i2, 30000);
1607- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_update_retransmissions, 30250);
1608- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_create_r2, 40000);
1609- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_add_rvs_reg_from, 41000);
1610- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_hmac2_and_sign, 42000);
1611- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_add_rvs_relay_to, 43000);
1612- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_send_r2, 50000);
1613- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_check_i2, 20000);
1614- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_handle_i2, 30000);
1615- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_update_retransmissions, 30250);
1616- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_create_r2, 40000);
1617- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_add_rvs_reg_from, 41000);
1618- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_hmac2_and_sign, 42000);
1619- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_add_rvs_relay_to, 43000);
1620- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_send_r2, 50000);
1621- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_check_i2, 20000);
1622- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_handle_i2, 30000);
1623- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_update_retransmissions, 30250);
1624- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_create_r2, 40000);
1625- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_add_rvs_reg_from, 41000);
1626- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_hmac2_and_sign, 42000);
1627- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_add_rvs_relay_to, 43000);
1628- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_send_r2, 50000);
1629-
1630- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_check_r1, 20000);
1631- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_handle_r1, 30000);
1632- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_update_retransmissions, 30500);
1633- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_build_esp_info, 31000);
1634- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_build_solution, 32000);
1635- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_handle_diffie_hellman, 33000);
1636- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &esp_prot_r1_handle_transforms, 34000);
1637- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_create_i2, 40000);
1638- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_add_signed_echo_response, 41000);
1639- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_mac_and_sign_handler, 42000);
1640- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_add_unsigned_echo_response, 43000);
1641- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_send_i2, 50000);
1642- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_check_r1, 20000);
1643- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_handle_r1, 30000);
1644- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30500);
1645- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_build_esp_info, 31000);
1646- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_build_solution, 32000);
1647- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_handle_diffie_hellman, 33000);
1648- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &esp_prot_r1_handle_transforms, 34000);
1649- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_create_i2, 40000);
1650- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_add_signed_echo_response, 41000);
1651- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_mac_and_sign_handler, 42000);
1652- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_add_unsigned_echo_response, 43000);
1653- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_send_i2, 50000);
1654- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_check_r1, 20000);
1655- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_handle_r1, 30000);
1656- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_update_retransmissions, 30500);
1657- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_build_esp_info, 31000);
1658- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_build_solution, 32000);
1659- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_handle_diffie_hellman, 33000);
1660- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &esp_prot_r1_handle_transforms, 34000);
1661- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_create_i2, 40000);
1662- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_add_signed_echo_response, 41000);
1663- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_mac_and_sign_handler, 42000);
1664- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_add_unsigned_echo_response, 43000);
1665- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_send_i2, 50000);
1666- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_check_r1, 20000);
1667- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_handle_r1, 30000);
1668- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_update_retransmissions, 30500);
1669- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_build_esp_info, 31000);
1670- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_build_solution, 32000);
1671- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_handle_diffie_hellman, 33000);
1672- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &esp_prot_r1_handle_transforms, 34000);
1673- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_create_i2, 40000);
1674- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_add_signed_echo_response, 41000);
1675- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_mac_and_sign_handler, 42000);
1676- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_add_unsigned_echo_response, 43000);
1677- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_send_i2, 50000);
1678-
1679- hip_register_handle_function(HIP_R2, HIP_STATE_I2_SENT, &hip_check_r2, 20000);
1680- hip_register_handle_function(HIP_R2, HIP_STATE_I2_SENT, &hip_handle_r2, 30000);
1681- hip_register_handle_function(HIP_R2, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30250);
1682-
1683- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I1_SENT, &hip_check_notify, 20000);
1684- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I1_SENT, &hip_handle_notify, 30000);
1685- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I2_SENT, &hip_check_notify, 20000);
1686- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I2_SENT, &hip_handle_notify, 30000);
1687- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_R2_SENT, &hip_check_notify, 20000);
1688- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_R2_SENT, &hip_handle_notify, 30000);
1689- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_ESTABLISHED, &hip_check_notify, 20000);
1690- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_ESTABLISHED, &hip_handle_notify, 30000);
1691- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSING, &hip_check_notify, 20000);
1692- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSING, &hip_handle_notify, 30000);
1693- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSED, &hip_check_notify, 20000);
1694- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSED, &hip_handle_notify, 30000);
1695-
1696- hip_register_handle_function(HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_check_packet, 20000);
1697- hip_register_handle_function(HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 25000);
1698- hip_register_handle_function(HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_create_response, 30000);
1699- hip_register_handle_function(HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_send_response, 40000);
1700-
1701- hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_check_packet, 20000);
1702- hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSING, &hip_update_retransmissions, 25000);
1703- hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_create_response, 30000);
1704- hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_send_response, 40000);
1705-
1706- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_close_ack_check_packet, 20000);
1707- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_update_retransmissions, 25000);
1708- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_close_ack_handle_packet, 30000);
1709-
1710- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_close_ack_check_packet, 20000);
1711- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_update_retransmissions, 25000);
1712- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_close_ack_handle_packet, 30000);
1713-
1714- hip_register_handle_function(HIP_LUPDATE, HIP_STATE_ESTABLISHED, &esp_prot_handle_light_update, 20000);
1715- hip_register_handle_function(HIP_LUPDATE, HIP_STATE_R2_SENT, &esp_prot_handle_light_update, 20000);
1716+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_check_i1, 20000);
1717+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_handle_i1, 30000);
1718+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_update_retransmissions, 35000);
1719+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_UNASSOCIATED, &hip_send_r1, 40000);
1720+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I1_SENT, &hip_check_i1, 20000);
1721+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I1_SENT, &hip_handle_i1, 30000);
1722+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I1_SENT, &hip_update_retransmissions, 35000);
1723+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I1_SENT, &hip_send_r1, 40000);
1724+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I2_SENT, &hip_check_i1, 20000);
1725+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I2_SENT, &hip_handle_i1, 30000);
1726+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I2_SENT, &hip_update_retransmissions, 35000);
1727+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_I2_SENT, &hip_send_r1, 40000);
1728+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_R2_SENT, &hip_check_i1, 20000);
1729+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_R2_SENT, &hip_handle_i1, 30000);
1730+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_R2_SENT, &hip_update_retransmissions, 35000);
1731+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_R2_SENT, &hip_send_r1, 40000);
1732+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_ESTABLISHED, &hip_check_i1, 20000);
1733+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_ESTABLISHED, &hip_handle_i1, 30000);
1734+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 35000);
1735+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_ESTABLISHED, &hip_send_r1, 40000);
1736+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSING, &hip_check_i1, 20000);
1737+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSING, &hip_handle_i1, 30000);
1738+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSING, &hip_update_retransmissions, 35000);
1739+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSING, &hip_send_r1, 40000);
1740+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSED, &hip_check_i1, 20000);
1741+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSED, &hip_handle_i1, 30000);
1742+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSED, &hip_update_retransmissions, 35000);
1743+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_CLOSED, &hip_send_r1, 40000);
1744+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_NONE, &hip_check_i1, 20000);
1745+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_NONE, &hip_handle_i1, 30000);
1746+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_NONE, &hip_update_retransmissions, 35000);
1747+ hip_register_handle_function(HIP_V1, HIP_I1, HIP_STATE_NONE, &hip_send_r1, 40000);
1748+
1749+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_check_i2, 20000);
1750+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_handle_i2, 30000);
1751+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_update_retransmissions, 30250);
1752+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_create_r2, 40000);
1753+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_add_rvs_reg_from, 41000);
1754+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_hmac2_and_sign, 42000);
1755+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_add_rvs_relay_to, 43000);
1756+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_UNASSOCIATED, &hip_send_r2, 50000);
1757+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_check_i2, 20000);
1758+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_handle_i2, 30000);
1759+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_update_retransmissions, 30250);
1760+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_create_r2, 40000);
1761+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_add_rvs_reg_from, 41000);
1762+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_hmac2_and_sign, 42000);
1763+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_add_rvs_relay_to, 43000);
1764+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I1_SENT, &hip_send_r2, 50000);
1765+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_check_i2, 20000);
1766+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_handle_i2_in_i2_sent, 21000);
1767+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_handle_i2, 30000);
1768+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30250);
1769+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_create_r2, 40000);
1770+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_add_rvs_reg_from, 41000);
1771+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_hmac2_and_sign, 42000);
1772+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_add_rvs_relay_to, 43000);
1773+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_I2_SENT, &hip_send_r2, 50000);
1774+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_check_i2, 20000);
1775+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_handle_i2, 30000);
1776+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_update_retransmissions, 30250);
1777+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_create_r2, 40000);
1778+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_add_rvs_reg_from, 41000);
1779+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_hmac2_and_sign, 42000);
1780+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_add_rvs_relay_to, 43000);
1781+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_R2_SENT, &hip_send_r2, 50000);
1782+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_check_i2, 20000);
1783+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_handle_i2, 30000);
1784+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 30250);
1785+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_create_r2, 40000);
1786+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_add_rvs_reg_from, 41000);
1787+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_hmac2_and_sign, 42000);
1788+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_add_rvs_relay_to, 43000);
1789+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_ESTABLISHED, &hip_send_r2, 50000);
1790+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_check_i2, 20000);
1791+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_handle_i2, 30000);
1792+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_update_retransmissions, 30250);
1793+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_create_r2, 40000);
1794+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_add_rvs_reg_from, 41000);
1795+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_hmac2_and_sign, 42000);
1796+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_add_rvs_relay_to, 43000);
1797+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSING, &hip_send_r2, 50000);
1798+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_check_i2, 20000);
1799+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_handle_i2, 30000);
1800+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_update_retransmissions, 30250);
1801+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_create_r2, 40000);
1802+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_add_rvs_reg_from, 41000);
1803+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_hmac2_and_sign, 42000);
1804+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_add_rvs_relay_to, 43000);
1805+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_CLOSED, &hip_send_r2, 50000);
1806+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_check_i2, 20000);
1807+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_handle_i2, 30000);
1808+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_update_retransmissions, 30250);
1809+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_create_r2, 40000);
1810+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_add_rvs_reg_from, 41000);
1811+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_hmac2_and_sign, 42000);
1812+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_add_rvs_relay_to, 43000);
1813+ hip_register_handle_function(HIP_V1, HIP_I2, HIP_STATE_NONE, &hip_send_r2, 50000);
1814+
1815+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_check_r1, 20000);
1816+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_handle_r1, 30000);
1817+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_update_retransmissions, 30500);
1818+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_build_esp_info, 31000);
1819+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_build_solution, 32000);
1820+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_handle_diffie_hellman, 33000);
1821+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &esp_prot_r1_handle_transforms, 34000);
1822+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_create_i2, 40000);
1823+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_add_signed_echo_response, 41000);
1824+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_mac_and_sign_handler, 42000);
1825+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_add_unsigned_echo_response, 43000);
1826+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I1_SENT, &hip_send_i2, 50000);
1827+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_check_r1, 20000);
1828+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_handle_r1, 30000);
1829+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30500);
1830+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_build_esp_info, 31000);
1831+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_build_solution, 32000);
1832+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_handle_diffie_hellman, 33000);
1833+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &esp_prot_r1_handle_transforms, 34000);
1834+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_create_i2, 40000);
1835+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_add_signed_echo_response, 41000);
1836+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_mac_and_sign_handler, 42000);
1837+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_add_unsigned_echo_response, 43000);
1838+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_I2_SENT, &hip_send_i2, 50000);
1839+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_check_r1, 20000);
1840+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_handle_r1, 30000);
1841+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_update_retransmissions, 30500);
1842+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_build_esp_info, 31000);
1843+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_build_solution, 32000);
1844+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_handle_diffie_hellman, 33000);
1845+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &esp_prot_r1_handle_transforms, 34000);
1846+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_create_i2, 40000);
1847+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_add_signed_echo_response, 41000);
1848+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_mac_and_sign_handler, 42000);
1849+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_add_unsigned_echo_response, 43000);
1850+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSING, &hip_send_i2, 50000);
1851+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_check_r1, 20000);
1852+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_handle_r1, 30000);
1853+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_update_retransmissions, 30500);
1854+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_build_esp_info, 31000);
1855+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_build_solution, 32000);
1856+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_handle_diffie_hellman, 33000);
1857+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &esp_prot_r1_handle_transforms, 34000);
1858+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_create_i2, 40000);
1859+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_add_signed_echo_response, 41000);
1860+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_mac_and_sign_handler, 42000);
1861+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_add_unsigned_echo_response, 43000);
1862+ hip_register_handle_function(HIP_V1, HIP_R1, HIP_STATE_CLOSED, &hip_send_i2, 50000);
1863+
1864+ hip_register_handle_function(HIP_V1, HIP_R2, HIP_STATE_I2_SENT, &hip_check_r2, 20000);
1865+ hip_register_handle_function(HIP_V1, HIP_R2, HIP_STATE_I2_SENT, &hip_handle_r2, 30000);
1866+ hip_register_handle_function(HIP_V1, HIP_R2, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30250);
1867+
1868+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_I1_SENT, &hip_check_notify, 20000);
1869+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_I1_SENT, &hip_handle_notify, 30000);
1870+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_I2_SENT, &hip_check_notify, 20000);
1871+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_I2_SENT, &hip_handle_notify, 30000);
1872+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_R2_SENT, &hip_check_notify, 20000);
1873+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_R2_SENT, &hip_handle_notify, 30000);
1874+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_ESTABLISHED, &hip_check_notify, 20000);
1875+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_ESTABLISHED, &hip_handle_notify, 30000);
1876+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_CLOSING, &hip_check_notify, 20000);
1877+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_CLOSING, &hip_handle_notify, 30000);
1878+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_CLOSED, &hip_check_notify, 20000);
1879+ hip_register_handle_function(HIP_V1, HIP_NOTIFY, HIP_STATE_CLOSED, &hip_handle_notify, 30000);
1880+
1881+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_check_packet, 20000);
1882+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 25000);
1883+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_create_response, 30000);
1884+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_send_response, 40000);
1885+
1886+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_check_packet, 20000);
1887+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_CLOSING, &hip_update_retransmissions, 25000);
1888+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_create_response, 30000);
1889+ hip_register_handle_function(HIP_V1, HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_send_response, 40000);
1890+
1891+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_close_ack_check_packet, 20000);
1892+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_update_retransmissions, 25000);
1893+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_close_ack_handle_packet, 30000);
1894+
1895+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_close_ack_check_packet, 20000);
1896+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_update_retransmissions, 25000);
1897+ hip_register_handle_function(HIP_V1, HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_close_ack_handle_packet, 30000);
1898+
1899+ hip_register_handle_function(HIP_V1, HIP_LUPDATE, HIP_STATE_ESTABLISHED, &esp_prot_handle_light_update, 20000);
1900+ hip_register_handle_function(HIP_V1, HIP_LUPDATE, HIP_STATE_R2_SENT, &esp_prot_handle_light_update, 20000);
1901
1902 return 0;
1903 }
1904
1905-static int init_handle_functions(void)
1906-{
1907- int err = 0;
1908-
1909- HIP_DEBUG("Initialize handle functions.\n");
1910-
1911- hip_register_handle_function(HIP_I1, HIP_STATE_UNASSOCIATED, &hip_check_i1, 20000);
1912- hip_register_handle_function(HIP_I1, HIP_STATE_UNASSOCIATED, &hip_handle_i1, 30000);
1913- hip_register_handle_function(HIP_I1, HIP_STATE_UNASSOCIATED, &hip_update_retransmissions, 35000);
1914- hip_register_handle_function(HIP_I1, HIP_STATE_UNASSOCIATED, &hip_send_r1, 40000);
1915- hip_register_handle_function(HIP_I1, HIP_STATE_I1_SENT, &hip_check_i1, 20000);
1916- hip_register_handle_function(HIP_I1, HIP_STATE_I1_SENT, &hip_handle_i1, 30000);
1917- hip_register_handle_function(HIP_I1, HIP_STATE_I1_SENT, &hip_update_retransmissions, 35000);
1918- hip_register_handle_function(HIP_I1, HIP_STATE_I1_SENT, &hip_send_r1, 40000);
1919- hip_register_handle_function(HIP_I1, HIP_STATE_I2_SENT, &hip_check_i1, 20000);
1920- hip_register_handle_function(HIP_I1, HIP_STATE_I2_SENT, &hip_handle_i1, 30000);
1921- hip_register_handle_function(HIP_I1, HIP_STATE_I2_SENT, &hip_update_retransmissions, 35000);
1922- hip_register_handle_function(HIP_I1, HIP_STATE_I2_SENT, &hip_send_r1, 40000);
1923- hip_register_handle_function(HIP_I1, HIP_STATE_R2_SENT, &hip_check_i1, 20000);
1924- hip_register_handle_function(HIP_I1, HIP_STATE_R2_SENT, &hip_handle_i1, 30000);
1925- hip_register_handle_function(HIP_I1, HIP_STATE_R2_SENT, &hip_update_retransmissions, 35000);
1926- hip_register_handle_function(HIP_I1, HIP_STATE_R2_SENT, &hip_send_r1, 40000);
1927- hip_register_handle_function(HIP_I1, HIP_STATE_ESTABLISHED, &hip_check_i1, 20000);
1928- hip_register_handle_function(HIP_I1, HIP_STATE_ESTABLISHED, &hip_handle_i1, 30000);
1929- hip_register_handle_function(HIP_I1, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 35000);
1930- hip_register_handle_function(HIP_I1, HIP_STATE_ESTABLISHED, &hip_send_r1, 40000);
1931- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSING, &hip_check_i1, 20000);
1932- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSING, &hip_handle_i1, 30000);
1933- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSING, &hip_update_retransmissions, 35000);
1934- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSING, &hip_send_r1, 40000);
1935- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSED, &hip_check_i1, 20000);
1936- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSED, &hip_handle_i1, 30000);
1937- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSED, &hip_update_retransmissions, 35000);
1938- hip_register_handle_function(HIP_I1, HIP_STATE_CLOSED, &hip_send_r1, 40000);
1939- hip_register_handle_function(HIP_I1, HIP_STATE_NONE, &hip_check_i1, 20000);
1940- hip_register_handle_function(HIP_I1, HIP_STATE_NONE, &hip_handle_i1, 30000);
1941- hip_register_handle_function(HIP_I1, HIP_STATE_NONE, &hip_update_retransmissions, 35000);
1942- hip_register_handle_function(HIP_I1, HIP_STATE_NONE, &hip_send_r1, 40000);
1943-
1944- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_check_i2, 20000);
1945- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_handle_i2, 30000);
1946- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_update_retransmissions, 30250);
1947- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_setup_ipsec_sa, 30500);
1948- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_create_r2, 40000);
1949- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_add_rvs_reg_from, 41000);
1950- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_hmac2_and_sign, 42000);
1951- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_add_rvs_relay_to, 43000);
1952- hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_send_r2, 50000);
1953- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_check_i2, 20000);
1954- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_handle_i2, 30000);
1955- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_update_retransmissions, 30250);
1956- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_setup_ipsec_sa, 30500);
1957- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_create_r2, 40000);
1958- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_add_rvs_reg_from, 41000);
1959- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_hmac2_and_sign, 42000);
1960- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_add_rvs_relay_to, 43000);
1961- hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_send_r2, 50000);
1962- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_check_i2, 20000);
1963- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_handle_i2_in_i2_sent, 21000);
1964- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_handle_i2, 30000);
1965- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30250);
1966- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_setup_ipsec_sa, 30500);
1967- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_create_r2, 40000);
1968- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_add_rvs_reg_from, 41000);
1969- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_hmac2_and_sign, 42000);
1970- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_add_rvs_relay_to, 43000);
1971- hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_send_r2, 50000);
1972- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_check_i2, 20000);
1973- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_handle_i2, 30000);
1974- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_update_retransmissions, 30250);
1975- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_setup_ipsec_sa, 30500);
1976- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_create_r2, 40000);
1977- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_add_rvs_reg_from, 41000);
1978- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_hmac2_and_sign, 42000);
1979- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_add_rvs_relay_to, 43000);
1980- hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_send_r2, 50000);
1981- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_check_i2, 20000);
1982- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_handle_i2, 30000);
1983- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 30250);
1984- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_setup_ipsec_sa, 30500);
1985- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_create_r2, 40000);
1986- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_add_rvs_reg_from, 41000);
1987- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_hmac2_and_sign, 42000);
1988- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_add_rvs_relay_to, 43000);
1989- hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_send_r2, 50000);
1990- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_check_i2, 20000);
1991- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_handle_i2, 30000);
1992- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_update_retransmissions, 30250);
1993- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_setup_ipsec_sa, 30500);
1994- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_create_r2, 40000);
1995- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_add_rvs_reg_from, 41000);
1996- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_hmac2_and_sign, 42000);
1997- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_add_rvs_relay_to, 43000);
1998- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_send_r2, 50000);
1999- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_check_i2, 20000);
2000- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_handle_i2, 30000);
2001- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_update_retransmissions, 30250);
2002- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_setup_ipsec_sa, 30500);
2003- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_create_r2, 40000);
2004- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_add_rvs_reg_from, 41000);
2005- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_hmac2_and_sign, 42000);
2006- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_add_rvs_relay_to, 43000);
2007- hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_send_r2, 50000);
2008- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_check_i2, 20000);
2009- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_handle_i2, 30000);
2010- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_update_retransmissions, 30250);
2011- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_setup_ipsec_sa, 30500);
2012- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_create_r2, 40000);
2013- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_add_rvs_reg_from, 41000);
2014- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_hmac2_and_sign, 42000);
2015- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_add_rvs_relay_to, 43000);
2016- hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_send_r2, 50000);
2017-
2018- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_check_r1, 20000);
2019- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_handle_r1, 30000);
2020- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_update_retransmissions, 30500);
2021- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_build_esp_info, 31000);
2022- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_build_solution, 32000);
2023- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_handle_diffie_hellman, 33000);
2024- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &esp_prot_r1_handle_transforms, 34000);
2025- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_create_i2, 40000);
2026- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_add_signed_echo_response, 41000);
2027- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_mac_and_sign_handler, 42000);
2028- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_add_unsigned_echo_response, 43000);
2029- hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_send_i2, 50000);
2030- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_check_r1, 20000);
2031- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_handle_r1, 30000);
2032- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30500);
2033- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_build_esp_info, 31000);
2034- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_build_solution, 32000);
2035- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_handle_diffie_hellman, 33000);
2036- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &esp_prot_r1_handle_transforms, 34000);
2037- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_create_i2, 40000);
2038- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_add_signed_echo_response, 41000);
2039- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_mac_and_sign_handler, 42000);
2040- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_add_unsigned_echo_response, 43000);
2041- hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_send_i2, 50000);
2042- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_check_r1, 20000);
2043- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_handle_r1, 30000);
2044- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_update_retransmissions, 30500);
2045- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_build_esp_info, 31000);
2046- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_build_solution, 32000);
2047- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_handle_diffie_hellman, 33000);
2048- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &esp_prot_r1_handle_transforms, 34000);
2049- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_create_i2, 40000);
2050- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_add_signed_echo_response, 41000);
2051- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_mac_and_sign_handler, 42000);
2052- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_add_unsigned_echo_response, 43000);
2053- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_send_i2, 50000);
2054- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_check_r1, 20000);
2055- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_handle_r1, 30000);
2056- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_update_retransmissions, 30500);
2057- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_build_esp_info, 31000);
2058- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_build_solution, 32000);
2059- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_handle_diffie_hellman, 33000);
2060- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &esp_prot_r1_handle_transforms, 34000);
2061- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_create_i2, 40000);
2062- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_add_signed_echo_response, 41000);
2063- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_mac_and_sign_handler, 42000);
2064- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_add_unsigned_echo_response, 43000);
2065- hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_send_i2, 50000);
2066-
2067- hip_register_handle_function(HIP_R2, HIP_STATE_I2_SENT, &hip_check_r2, 20000);
2068- hip_register_handle_function(HIP_R2, HIP_STATE_I2_SENT, &hip_handle_r2, 30000);
2069- hip_register_handle_function(HIP_R2, HIP_STATE_I2_SENT, &hip_update_retransmissions, 30250);
2070- hip_register_handle_function(HIP_R2, HIP_STATE_I2_SENT, &hip_setup_ipsec_sa, 30500);
2071-
2072- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I1_SENT, &hip_check_notify, 20000);
2073- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I1_SENT, &hip_handle_notify, 30000);
2074- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I2_SENT, &hip_check_notify, 20000);
2075- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I2_SENT, &hip_handle_notify, 30000);
2076- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_R2_SENT, &hip_check_notify, 20000);
2077- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_R2_SENT, &hip_handle_notify, 30000);
2078- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_ESTABLISHED, &hip_check_notify, 20000);
2079- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_ESTABLISHED, &hip_handle_notify, 30000);
2080- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSING, &hip_check_notify, 20000);
2081- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSING, &hip_handle_notify, 30000);
2082- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSED, &hip_check_notify, 20000);
2083- hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSED, &hip_handle_notify, 30000);
2084-
2085- hip_register_handle_function(HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_check_packet, 20000);
2086- hip_register_handle_function(HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_update_retransmissions, 25000);
2087- hip_register_handle_function(HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_create_response, 30000);
2088- hip_register_handle_function(HIP_CLOSE, HIP_STATE_ESTABLISHED, &hip_close_send_response, 40000);
2089-
2090- hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_check_packet, 20000);
2091- hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSING, &hip_update_retransmissions, 25000);
2092- hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_create_response, 30000);
2093- hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSING, &hip_close_send_response, 40000);
2094-
2095- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_close_ack_check_packet, 20000);
2096- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_update_retransmissions, 25000);
2097- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSING, &hip_close_ack_handle_packet, 30000);
2098-
2099- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_close_ack_check_packet, 20000);
2100- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_update_retransmissions, 25000);
2101- hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSED, &hip_close_ack_handle_packet, 30000);
2102-
2103- hip_register_handle_function(HIP_LUPDATE, HIP_STATE_ESTABLISHED, &esp_prot_handle_light_update, 20000);
2104- hip_register_handle_function(HIP_LUPDATE, HIP_STATE_R2_SENT, &esp_prot_handle_light_update, 20000);
2105-
2106- return err;
2107-}
2108-
2109 /**
2110 * set or unset close-on-exec flag for a given file descriptor
2111 *
2112@@ -1459,3 +1666,32 @@
2113 out_err:
2114 return err;
2115 }
2116+
2117+/**
2118+ * Set the default HIP version to be used for outgoing I1 messages.
2119+ *
2120+ * @param version HIP version to be used in I1 message by default. It should
2121+ * be greater than 0 and less than the @c HIP_MAX_VERSION.
2122+ * @return 0 on success, -1 on failure.
2123+ */
2124+int hip_set_default_version(uint8_t version)
2125+{
2126+ if (version <= 0 || version >= HIP_MAX_VERSION) {
2127+ HIP_ERROR("invalid default-hip-version: %d", version);
2128+ return -1;
2129+ }
2130+
2131+ hip_default_hip_version = version;
2132+
2133+ return 0;
2134+}
2135+
2136+/**
2137+ * Get the default HIP verison parameter.
2138+ *
2139+ * @return the default HIP version.
2140+ */
2141+uint8_t hip_get_default_version(void)
2142+{
2143+ return hip_default_hip_version;
2144+}
2145
2146=== modified file 'libhipl/init.h'
2147--- libhipl/init.h 2012-05-12 10:21:32 +0000
2148+++ libhipl/init.h 2012-07-07 13:45:26 +0000
2149@@ -62,6 +62,8 @@
2150 int is_output);
2151 void hip_exit(void);
2152
2153+int hip_set_default_version(uint8_t version);
2154+uint8_t hip_get_default_version(void);
2155 int hipl_lib_init(enum logdebug);
2156
2157 #endif /* HIPL_LIBHIPL_INIT_H */
2158
2159=== modified file 'libhipl/input.c'
2160--- libhipl/input.c 2012-05-12 10:21:32 +0000
2161+++ libhipl/input.c 2012-07-07 13:45:26 +0000
2162@@ -247,12 +247,12 @@
2163 HIP_IFEL(!(param = hip_get_param(ctx->input_msg, HIP_PARAM_HIP_TRANSFORM)),
2164 -EINVAL,
2165 "Could not find HIP transform\n");
2166- HIP_IFEL((hip_tfm = hip_select_hip_transform((const struct hip_hip_transform *) param)) == 0,
2167+ HIP_IFEL((hip_tfm = hip_select_hip_transform(param)) == 0,
2168 -EINVAL, "Could not select HIP transform\n");
2169 HIP_IFEL(!(param = hip_get_param(ctx->input_msg, HIP_PARAM_ESP_TRANSFORM)),
2170 -EINVAL,
2171 "Could not find ESP transform\n");
2172- HIP_IFEL((esp_tfm = hip_select_esp_transform((const struct hip_esp_transform *) param)) == 0,
2173+ HIP_IFEL((esp_tfm = hip_select_esp_transform(param)) == 0,
2174 -EINVAL, "Could not select proper ESP transform\n");
2175
2176 hip_transf_length = hip_transform_key_length(hip_tfm);
2177@@ -493,6 +493,7 @@
2178 {
2179 struct in6_addr ipv6_any_addr = IN6ADDR_ANY_INIT;
2180 uint32_t type, state;
2181+ uint8_t msg_hip_version;
2182
2183 if (hip_check_network_msg(ctx->input_msg)) {
2184 HIP_ERROR("Checking control message failed.\n");
2185@@ -529,10 +530,12 @@
2186 * printing packet data here works for all packets. To avoid excessive
2187 * debug printing do not print this information inside the individual
2188 * receive or handle functions. */
2189+ msg_hip_version = hip_get_msg_version(ctx->input_msg);
2190 HIP_INFO_IN6ADDR("Src IP", &ctx->src_addr);
2191 HIP_INFO_IN6ADDR("Dst IP", &ctx->dst_addr);
2192 HIP_DEBUG("Src port: %u\n", ctx->msg_ports.src_port);
2193 HIP_DEBUG("Dst port: %u\n", ctx->msg_ports.dst_port);
2194+ HIP_DEBUG("HIP version: %d\n", msg_hip_version);
2195 HIP_DUMP_MSG(ctx->input_msg);
2196
2197 type = hip_get_msg_type(ctx->input_msg);
2198@@ -557,6 +560,23 @@
2199
2200 if (ctx->hadb_entry) {
2201 state = ctx->hadb_entry->state;
2202+
2203+ /* If the HIP version of this hadb entry hasn't been set, we set it
2204+ * now so handler functions can access it later from packet context.
2205+ * If the hadb entry already records its HIP version, we check whether
2206+ * the version of the current receiving message equals the version in
2207+ * hadb and drop those messages with invalid version. */
2208+ if (ctx->hadb_entry->hip_version == 0) {
2209+ ctx->hadb_entry->hip_version = msg_hip_version;
2210+ HIP_DEBUG("Set HIP version of the hadb entry to %d\n",
2211+ msg_hip_version);
2212+ } else if (ctx->hadb_entry->hip_version != msg_hip_version) {
2213+ HIP_ERROR("The version of the inbound message (V%d) doesn't match"
2214+ "the version of the corresponding hadb record (V%d)\n",
2215+ ctx->hadb_entry->hip_version,
2216+ msg_hip_version);
2217+ return -1;
2218+ }
2219 } else {
2220 state = HIP_STATE_NONE;
2221 }
2222@@ -856,7 +876,8 @@
2223 HIP_I2,
2224 0,
2225 &ctx->input_msg->hit_receiver,
2226- &ctx->input_msg->hit_sender);
2227+ &ctx->input_msg->hit_sender,
2228+ ctx->hadb_entry->hip_version);
2229
2230 /* note: we could skip keying material generation in the case
2231 * of a retransmission but then we'd had to fill ctx->hmac etc */
2232@@ -1342,6 +1363,7 @@
2233 UNUSED const enum hip_state ha_state,
2234 struct hip_packet_context *ctx)
2235 {
2236+ int hip_version = 0;
2237 int err = 0, is_loopback = 0;
2238 bool skip_key_creation = false;
2239 uint16_t mask = HIP_PACKET_CTRL_ANON;
2240@@ -1410,6 +1432,7 @@
2241 skip_key_creation = true;
2242 } else {
2243 if (ctx->hadb_entry) {
2244+ hip_version = ctx->hadb_entry->hip_version;
2245 HIP_DEBUG("Removing existing state and creating new one.\n");
2246 HIP_IFEL(hip_del_peer_info_entry(ctx->hadb_entry),
2247 -1, "Deleting peer info failed\n");
2248@@ -1421,6 +1444,10 @@
2249 "Out of memory when allocating memory for a new HIP "
2250 "association. Dropping the I2 packet.\n");
2251
2252+ if (hip_version == 0) {
2253+ hip_version = hip_get_msg_version(ctx->input_msg);
2254+ }
2255+ ctx->hadb_entry->hip_version = hip_version;
2256 ipv6_addr_copy(&ctx->hadb_entry->hit_peer, &ctx->input_msg->hit_sender);
2257 ipv6_addr_copy(&ctx->hadb_entry->our_addr, &ctx->dst_addr);
2258 HIP_DEBUG("Initializing the HIP association.\n");
2259@@ -1440,7 +1467,8 @@
2260 HIP_IFEL(hip_verify_cookie(&ctx->src_addr,
2261 &ctx->dst_addr,
2262 ctx->input_msg,
2263- solution),
2264+ solution,
2265+ ctx->hadb_entry->hip_version),
2266 -EPROTO,
2267 "Cookie solution rejected. Dropping the I2 packet.\n");
2268
2269@@ -1659,12 +1687,12 @@
2270 UNUSED const enum hip_state ha_state,
2271 struct hip_packet_context *ctx)
2272 {
2273- int err = 0, if_index = 0;
2274- struct sockaddr_storage ss_addr = { 0 };
2275- struct sockaddr *addr = NULL;
2276- const struct hip_esp_info *esp_info = NULL;
2277- const struct hip_esp_transform *esp_tfm = NULL;
2278- const struct hip_locator *locator = NULL;
2279+ int err = 0, if_index = 0;
2280+ struct sockaddr_storage ss_addr = { 0 };
2281+ struct sockaddr *addr = NULL;
2282+ const struct hip_esp_info *esp_info = NULL;
2283+ const struct hip_tlv_common *esp_tfm = NULL;
2284+ const struct hip_locator *locator = NULL;
2285
2286 /* Get the interface index of the network device which has our
2287 * local IP address. */
2288@@ -1899,7 +1927,8 @@
2289 response,
2290 ctx->hadb_entry->local_controls,
2291 &ctx->hadb_entry->hit_our,
2292- &ctx->hadb_entry->hit_peer);
2293+ &ctx->hadb_entry->hit_peer,
2294+ ctx->hadb_entry->hip_version);
2295
2296 /* Calculate the HIP header length */
2297 hip_calc_hdr_len(ctx->output_msg);
2298
2299=== modified file 'libhipl/nat.c'
2300--- libhipl/nat.c 2012-05-12 10:21:32 +0000
2301+++ libhipl/nat.c 2012-07-07 13:45:26 +0000
2302@@ -121,7 +121,7 @@
2303
2304 hip_build_network_hdr(msg, HIP_NOTIFY,
2305 0, &entry->hit_our,
2306- &entry->hit_peer);
2307+ &entry->hit_peer, entry->hip_version);
2308
2309 /* Calculate the HIP header length */
2310 hip_calc_hdr_len(msg);
2311
2312=== modified file 'libhipl/netdev.c'
2313--- libhipl/netdev.c 2012-05-12 10:21:32 +0000
2314+++ libhipl/netdev.c 2012-07-07 13:45:26 +0000
2315@@ -69,6 +69,7 @@
2316 #include "config.h"
2317 #include "accessor.h"
2318 #include "hadb.h"
2319+#include "init.h"
2320 #include "hidb.h"
2321 #include "hipd.h"
2322 #include "hit_to_ip.h"
2323@@ -865,6 +866,7 @@
2324 entry = hip_hadb_find_byhits(src_hit, dst_hit);
2325 if (entry && !ipv6_addr_any(&entry->our_addr)) {
2326 reuse_hadb_local_address = 1;
2327+ entry->hip_version = hip_get_default_version();
2328 goto send_i1;
2329 }
2330
2331@@ -946,6 +948,7 @@
2332 entry->local_udp_port = ha_local_port;
2333 entry->peer_udp_port = ha_peer_port;
2334 entry->nat_mode = ha_nat_mode;
2335+ entry->hip_version = hip_get_default_version();
2336
2337 reuse_hadb_local_address = 1;
2338
2339
2340=== modified file 'libhipl/output.c'
2341--- libhipl/output.c 2012-05-12 10:21:32 +0000
2342+++ libhipl/output.c 2012-07-07 13:45:26 +0000
2343@@ -63,6 +63,7 @@
2344 #include "hidb.h"
2345 #include "hipd.h"
2346 #include "hiprelay.h"
2347+#include "init.h"
2348 #include "nat.h"
2349 #include "netdev.h"
2350 #include "registration.h"
2351@@ -208,7 +209,8 @@
2352
2353 i1 = hip_msg_alloc();
2354
2355- hip_build_network_hdr(i1, HIP_I1, mask, &entry->hit_our, dst_hit);
2356+ hip_build_network_hdr(i1, HIP_I1, mask, &entry->hit_our,
2357+ dst_hit, entry->hip_version);
2358
2359 /* Calculate the HIP header length */
2360 hip_calc_hdr_len(i1);
2361@@ -375,13 +377,13 @@
2362 UNUSED const enum hip_state ha_state,
2363 struct hip_packet_context *ctx)
2364 {
2365- hip_transform_suite transform_hip_suite, transform_esp_suite;
2366- const struct hip_param *param = NULL;
2367- struct hip_esp_info *esp_info = NULL;
2368- struct local_host_id *host_id_entry = NULL;
2369- char *enc_in_msg = NULL, *host_id_in_enc = NULL;
2370- unsigned char *iv = NULL;
2371- int err = 0, host_id_in_enc_len = 0;
2372+ hip_transform_suite transform_hip_suite, transform_esp_suite;
2373+ const struct hip_tlv_common *param = NULL;
2374+ struct hip_esp_info *esp_info = NULL;
2375+ struct local_host_id *host_id_entry = NULL;
2376+ char *enc_in_msg = NULL, *host_id_in_enc = NULL;
2377+ unsigned char *iv = NULL;
2378+ int err = 0, host_id_in_enc_len = 0;
2379
2380 HIP_IFEL(ctx->error, -1, "Abort packet processing.\n");
2381
2382@@ -409,7 +411,7 @@
2383 /********** HIP transform. **********/
2384 HIP_IFE(!(param = hip_get_param(ctx->input_msg, HIP_PARAM_HIP_TRANSFORM)),
2385 -ENOENT);
2386- HIP_IFEL((transform_hip_suite = hip_select_hip_transform((const struct hip_hip_transform *) param)) == 0,
2387+ HIP_IFEL((transform_hip_suite = hip_select_hip_transform(param)) == 0,
2388 -EINVAL, "Could not find acceptable HIP transform suite.\n");
2389
2390 /* Select only one transform */
2391@@ -483,7 +485,7 @@
2392 -ENOENT);
2393
2394 /* Select only one transform */
2395- HIP_IFEL((transform_esp_suite = hip_select_esp_transform((const struct hip_esp_transform *) param)) == 0,
2396+ HIP_IFEL((transform_esp_suite = hip_select_esp_transform(param)) == 0,
2397 -1, "Could not find acceptable hip transform suite\n");
2398 HIP_IFEL(hip_build_param_esp_transform(ctx->output_msg,
2399 &transform_esp_suite, 1), -1,
2400@@ -603,6 +605,7 @@
2401 * @param private_key a pointer to the local host private key
2402 * @param host_id_pub a pointer to the public host id of the local host
2403 * @param cookie_k the difficulty value for the puzzle
2404+ * @param hip_version HIP message version
2405 * @return 0 on success, a non-zero value on error.
2406 */
2407 int hip_create_r1(struct hip_common *const msg,
2408@@ -610,7 +613,8 @@
2409 int (*sign)(void *const key, struct hip_common *const m),
2410 void *const private_key,
2411 const struct hip_host_id *const host_id_pub,
2412- const int cookie_k)
2413+ const int cookie_k,
2414+ const uint8_t hip_version)
2415 {
2416 int err = 0;
2417 struct hip_srv service_list[HIP_TOTAL_EXISTING_SERVICES];
2418@@ -678,7 +682,7 @@
2419 /** @todo TH: hip_build_network_hdr has to be replaced with an
2420 * appropriate function pointer */
2421 HIP_DEBUG_HIT("src_hit used to build r1 network header", src_hit);
2422- hip_build_network_hdr(msg, HIP_R1, mask, src_hit, NULL);
2423+ hip_build_network_hdr(msg, HIP_R1, mask, src_hit, NULL, hip_version);
2424
2425 /********** R1_COUNTER (OPTIONAL) *********/
2426
2427@@ -863,7 +867,8 @@
2428 }
2429
2430 HIP_IFEL(!(r1pkt = hip_get_r1(r1_dst_addr, &ctx->dst_addr,
2431- &ctx->input_msg->hit_receiver)),
2432+ &ctx->input_msg->hit_receiver,
2433+ hip_get_msg_version(ctx->input_msg))),
2434 -ENOENT, "No precreated R1\n");
2435
2436 if (&ctx->input_msg->hit_sender) {
2437@@ -1037,7 +1042,8 @@
2438 * source HIT. */
2439 hip_build_network_hdr(ctx->output_msg, HIP_R2, mask,
2440 &ctx->hadb_entry->hit_our,
2441- &ctx->hadb_entry->hit_peer);
2442+ &ctx->hadb_entry->hit_peer,
2443+ ctx->hadb_entry->hip_version);
2444
2445 HIP_DUMP_MSG(ctx->output_msg);
2446
2447
2448=== modified file 'libhipl/output.h'
2449--- libhipl/output.h 2012-05-12 10:21:32 +0000
2450+++ libhipl/output.h 2012-07-07 13:45:26 +0000
2451@@ -52,7 +52,8 @@
2452 int (*sign)(void *const key, struct hip_common *const m),
2453 void *const private_key,
2454 const struct hip_host_id *const host_id_pub,
2455- const int cookie_k);
2456+ const int cookie_k,
2457+ const uint8_t hip_version);
2458
2459 int hip_send_r1(const uint8_t packet_type,
2460 const enum hip_state ha_state,
2461
2462=== modified file 'libhipl/pkt_handling.c'
2463--- libhipl/pkt_handling.c 2012-05-12 10:21:32 +0000
2464+++ libhipl/pkt_handling.c 2012-07-07 13:45:26 +0000
2465@@ -1,5 +1,5 @@
2466 /*
2467- * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University.
2468+ * Copyright (c) 2010-2012 Aalto University and RWTH Aachen University.
2469 *
2470 * Permission is hereby granted, free of charge, to any person
2471 * obtaining a copy of this software and associated documentation
2472@@ -30,6 +30,7 @@
2473
2474 #include <stdint.h>
2475
2476+#include "libcore/builder.h"
2477 #include "libcore/ife.h"
2478 #include "libcore/linkedlist.h"
2479 #include "libcore/protodefs.h"
2480@@ -46,25 +47,30 @@
2481 };
2482
2483 /**
2484- * @todo add description
2485+ * This three-dimension array stores lists of packet handling functions
2486+ * categorized by HIP version numbers, HIP packet types and HIP host
2487+ * association states. Each list contains corresponding handle functions
2488+ * sorted by priority.
2489 */
2490-static struct hip_ll *hip_handle_functions[HIP_MAX_PACKET_TYPE][HIP_MAX_HA_STATE];
2491+static struct hip_ll *hip_handle_functions[HIP_MAX_VERSION][HIP_MAX_PACKET_TYPE][HIP_MAX_HA_STATE];
2492
2493 /**
2494- * Register a function for handling of the specified combination from packet
2495- * type and host association state.
2496+ * Register a function for handling packets with specified combination from HIP
2497+ * version, packet type and host association state.
2498 *
2499- * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
2500- * @param ha_state The host association state (RFC 5201, 4.4.1.)
2501+ * @param hip_version HIP version
2502+ * @param packet_type The packet type of the control message
2503+ * (RFC 5201, 5.3.)
2504+ * @param ha_state The host association state (RFC 5201, 4.4.1.)
2505 * @param handle_function Pointer to the function which should be called
2506 * when the combination of packet type and host
2507 * association state is reached.
2508- * @param priority Execution priority for the handle function.
2509+ * @param priority Execution priority for the handle function.
2510 *
2511- * @return Success = 0
2512- * Error = -1
2513+ * @return 0 on success, -1 on error.
2514 */
2515-int hip_register_handle_function(const uint8_t packet_type,
2516+int hip_register_handle_function(const uint8_t hip_version,
2517+ const uint8_t packet_type,
2518 const enum hip_state ha_state,
2519 int (*handle_function)(const uint8_t packet_type,
2520 const enum hip_state ha_state,
2521@@ -74,6 +80,11 @@
2522 int err = 0;
2523 struct handle_function *new_entry = NULL;
2524
2525+ if (hip_version <= 0 || hip_version >= HIP_MAX_VERSION) {
2526+ HIP_ERROR("Invalid HIP version: %d\n", hip_version);
2527+ return -1;
2528+ }
2529+
2530 HIP_IFEL(packet_type > HIP_MAX_PACKET_TYPE,
2531 -1,
2532 "Maximum packet type exceeded.\n");
2533@@ -88,11 +99,11 @@
2534 new_entry->priority = priority;
2535 new_entry->func_ptr = handle_function;
2536
2537- hip_handle_functions[packet_type][ha_state] =
2538- lmod_register_function(hip_handle_functions[packet_type][ha_state],
2539+ hip_handle_functions[hip_version][packet_type][ha_state] =
2540+ lmod_register_function(hip_handle_functions[hip_version][packet_type][ha_state],
2541 new_entry,
2542 priority);
2543- if (!hip_handle_functions[packet_type][ha_state]) {
2544+ if (!hip_handle_functions[hip_version][packet_type][ha_state]) {
2545 HIP_ERROR("Error on registering a handle function.\n");
2546 err = -1;
2547 }
2548@@ -117,7 +128,8 @@
2549 const enum hip_state ha_state,
2550 struct hip_packet_context *ctx)
2551 {
2552- int err = 0;
2553+ int err = 0;
2554+ int hip_version;
2555 const struct hip_ll_node *iter = NULL;
2556
2557 HIP_IFEL(packet_type > HIP_MAX_PACKET_TYPE,
2558@@ -127,13 +139,15 @@
2559 -1,
2560 "Maximum host association state exceeded.\n");
2561
2562- HIP_IFEL(!hip_handle_functions[packet_type][ha_state],
2563+ hip_version = hip_get_msg_version(ctx->input_msg);
2564+
2565+ HIP_IFEL(!hip_handle_functions[hip_version][packet_type][ha_state],
2566 -1,
2567 "Error on running handle functions.\nPacket type: %d, HA state: %d\n",
2568 packet_type,
2569 ha_state);
2570
2571- while ((iter = hip_ll_iterate(hip_handle_functions[packet_type][ha_state],
2572+ while ((iter = hip_ll_iterate(hip_handle_functions[hip_version][packet_type][ha_state],
2573 iter))
2574 && !ctx->error) {
2575 err = ((struct handle_function *) iter->ptr)->func_ptr(packet_type,
2576@@ -155,13 +169,15 @@
2577 */
2578 void hip_uninit_handle_functions(void)
2579 {
2580- int i, j;
2581+ int i, j, k;
2582
2583- for (i = 0; i < HIP_MAX_PACKET_TYPE; i++) {
2584- for (j = 0; j < HIP_MAX_HA_STATE; j++) {
2585- if (hip_handle_functions[i][j]) {
2586- hip_ll_uninit(hip_handle_functions[i][j], free);
2587- free(hip_handle_functions[i][j]);
2588+ for (i = 0; i < HIP_MAX_VERSION; i++) {
2589+ for (j = 0; j < HIP_MAX_PACKET_TYPE; j++) {
2590+ for (k = 0; k < HIP_MAX_HA_STATE; k++) {
2591+ if (hip_handle_functions[i][j][k]) {
2592+ hip_ll_uninit(hip_handle_functions[i][j][k], free);
2593+ free(hip_handle_functions[i][j][k]);
2594+ }
2595 }
2596 }
2597 }
2598
2599=== modified file 'libhipl/pkt_handling.h'
2600--- libhipl/pkt_handling.h 2012-05-12 10:21:32 +0000
2601+++ libhipl/pkt_handling.h 2012-07-07 13:45:26 +0000
2602@@ -1,5 +1,5 @@
2603 /*
2604- * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University.
2605+ * Copyright (c) 2010-2012 Aalto University and RWTH Aachen University.
2606 *
2607 * Permission is hereby granted, free of charge, to any person
2608 * obtaining a copy of this software and associated documentation
2609@@ -31,7 +31,8 @@
2610 #include "libcore/protodefs.h"
2611 #include "libcore/state.h"
2612
2613-int hip_register_handle_function(const uint8_t packet_type,
2614+int hip_register_handle_function(const uint8_t hip_version,
2615+ const uint8_t packet_type,
2616 const enum hip_state ha_state,
2617 int (*handle_function)(const uint8_t packet_type,
2618 const enum hip_state ha_state,
2619
2620=== modified file 'libhipl/user.c'
2621--- libhipl/user.c 2012-05-12 10:21:32 +0000
2622+++ libhipl/user.c 2012-07-07 13:45:26 +0000
2623@@ -694,6 +694,19 @@
2624 HIP_DEBUG("hip_broadcast_status = %d (should be %d)\n",
2625 hip_broadcast_status, HIP_MSG_BROADCAST_OFF);
2626 break;
2627+
2628+ case HIP_MSG_DEFAULT_HIP_VERSION_1:
2629+ hip_set_default_version(HIP_V1);
2630+ HIP_DEBUG("hip_default_version has been set to: %d\n",
2631+ hip_get_default_version());
2632+ break;
2633+
2634+ case HIP_MSG_DEFAULT_HIP_VERSION_2:
2635+ hip_set_default_version(HIP_V2);
2636+ HIP_DEBUG("hip_default_version has been set to: %d\n",
2637+ hip_get_default_version());
2638+ break;
2639+
2640 case HIP_MSG_LSI_ON:
2641 lsi_status = HIP_MSG_LSI_ON;
2642 break;
2643
2644=== modified file 'modules/cert/hipd/cert.c'
2645--- modules/cert/hipd/cert.c 2012-05-12 10:21:32 +0000
2646+++ modules/cert/hipd/cert.c 2012-07-07 13:45:26 +0000
2647@@ -151,45 +151,48 @@
2648 */
2649 int hip_cert_init(void)
2650 {
2651- if (hip_register_handle_function(HIP_I2, HIP_STATE_NONE,
2652- &hip_add_certificate_r2, 40500)) {
2653- HIP_ERROR("Error on registering certificate handle function.\n");
2654- return -1;
2655- }
2656- if (hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED,
2657- &hip_add_certificate_r2, 40500)) {
2658- HIP_ERROR("Error on registering certificate handle function.\n");
2659- return -1;
2660- }
2661- if (hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT,
2662- &hip_add_certificate_r2, 40500)) {
2663- HIP_ERROR("Error on registering certificate handle function.\n");
2664- return -1;
2665- }
2666- if (hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT,
2667- &hip_add_certificate_r2, 40500)) {
2668- HIP_ERROR("Error on registering certificate handle function.\n");
2669- return -1;
2670- }
2671- if (hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT,
2672- &hip_add_certificate_r2, 40500)) {
2673- HIP_ERROR("Error on registering certificate handle function.\n");
2674- return -1;
2675- }
2676- if (hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED,
2677- &hip_add_certificate_r2, 40500)) {
2678- HIP_ERROR("Error on registering certificate handle function.\n");
2679- return -1;
2680- }
2681- if (hip_register_handle_function(HIP_UPDATE, HIP_STATE_ESTABLISHED,
2682- &hip_add_certificate_update, 20752)) {
2683- HIP_ERROR("Error on registering certificate handle function.\n");
2684- return -1;
2685- }
2686- if (hip_register_handle_function(HIP_UPDATE, HIP_STATE_R2_SENT,
2687- &hip_add_certificate_update, 20752)) {
2688- HIP_ERROR("Error on registering certificate handle function.\n");
2689- return -1;
2690+ int i;
2691+ for (i = 1; i < HIP_MAX_VERSION; i++) {
2692+ if (hip_register_handle_function(i, HIP_I2, HIP_STATE_NONE,
2693+ &hip_add_certificate_r2, 40500)) {
2694+ HIP_ERROR("Error on registering certificate handle function.\n");
2695+ return -1;
2696+ }
2697+ if (hip_register_handle_function(i, HIP_I2, HIP_STATE_UNASSOCIATED,
2698+ &hip_add_certificate_r2, 40500)) {
2699+ HIP_ERROR("Error on registering certificate handle function.\n");
2700+ return -1;
2701+ }
2702+ if (hip_register_handle_function(i, HIP_I2, HIP_STATE_I1_SENT,
2703+ &hip_add_certificate_r2, 40500)) {
2704+ HIP_ERROR("Error on registering certificate handle function.\n");
2705+ return -1;
2706+ }
2707+ if (hip_register_handle_function(i, HIP_I2, HIP_STATE_I2_SENT,
2708+ &hip_add_certificate_r2, 40500)) {
2709+ HIP_ERROR("Error on registering certificate handle function.\n");
2710+ return -1;
2711+ }
2712+ if (hip_register_handle_function(i, HIP_I2, HIP_STATE_R2_SENT,
2713+ &hip_add_certificate_r2, 40500)) {
2714+ HIP_ERROR("Error on registering certificate handle function.\n");
2715+ return -1;
2716+ }
2717+ if (hip_register_handle_function(i, HIP_I2, HIP_STATE_ESTABLISHED,
2718+ &hip_add_certificate_r2, 40500)) {
2719+ HIP_ERROR("Error on registering certificate handle function.\n");
2720+ return -1;
2721+ }
2722+ if (hip_register_handle_function(i, HIP_UPDATE, HIP_STATE_ESTABLISHED,
2723+ &hip_add_certificate_update, 20752)) {
2724+ HIP_ERROR("Error on registering certificate handle function.\n");
2725+ return -1;
2726+ }
2727+ if (hip_register_handle_function(i, HIP_UPDATE, HIP_STATE_R2_SENT,
2728+ &hip_add_certificate_update, 20752)) {
2729+ HIP_ERROR("Error on registering certificate handle function.\n");
2730+ return -1;
2731+ }
2732 }
2733
2734 if (!(host_cert = cert_load_x509_certificate(HIPL_SYSCONFDIR "/host-cert.der",
2735
2736=== modified file 'modules/midauth/hipd/midauth.c'
2737--- modules/midauth/hipd/midauth.c 2012-05-12 10:21:32 +0000
2738+++ modules/midauth/hipd/midauth.c 2012-07-07 13:45:26 +0000
2739@@ -166,12 +166,14 @@
2740 HIP_STATE_CLOSING,
2741 HIP_STATE_CLOSED };
2742 for (unsigned i = 0; i < ARRAY_SIZE(challenge_request_R1_states); i++) {
2743- if (hip_register_handle_function(HIP_R1,
2744- challenge_request_R1_states[i],
2745- &handle_challenge_request_param,
2746- 32500)) {
2747- HIP_ERROR("Error on registering MIDAUTH handle function.\n");
2748- return -1;
2749+ for (int j = 1; j < HIP_MAX_VERSION; j++) {
2750+ if (hip_register_handle_function(j, HIP_R1,
2751+ challenge_request_R1_states[i],
2752+ &handle_challenge_request_param,
2753+ 32500)) {
2754+ HIP_ERROR("Error on registering MIDAUTH handle function.\n");
2755+ return -1;
2756+ }
2757 }
2758 }
2759
2760@@ -189,12 +191,14 @@
2761 HIP_STATE_CLOSED,
2762 HIP_STATE_NONE };
2763 for (unsigned i = 0; i < ARRAY_SIZE(challenge_request_I2_states); i++) {
2764- if (hip_register_handle_function(HIP_I2,
2765- challenge_request_I2_states[i],
2766- &handle_challenge_request_param,
2767- 40322)) {
2768- HIP_ERROR("Error on registering MIDAUTH handle function.\n");
2769- return -1;
2770+ for (int j = 1; j < HIP_MAX_VERSION; j++) {
2771+ if (hip_register_handle_function(j, HIP_I2,
2772+ challenge_request_I2_states[i],
2773+ &handle_challenge_request_param,
2774+ 40322)) {
2775+ HIP_ERROR("Error on registering MIDAUTH handle function.\n");
2776+ return -1;
2777+ }
2778 }
2779 }
2780
2781@@ -206,20 +210,22 @@
2782 const enum hip_state challenge_request_UPDATE_states[] = { HIP_STATE_R2_SENT,
2783 HIP_STATE_ESTABLISHED };
2784 for (unsigned i = 0; i < ARRAY_SIZE(challenge_request_UPDATE_states); i++) {
2785- if (hip_register_handle_function(HIP_UPDATE,
2786- challenge_request_UPDATE_states[i],
2787- &handle_challenge_request_param,
2788- 20322)) {
2789- HIP_ERROR("Error on registering MIDAUTH handle function.\n");
2790- return -1;
2791- }
2792+ for (int j = 1; j < HIP_MAX_VERSION; j++) {
2793+ if (hip_register_handle_function(j, HIP_UPDATE,
2794+ challenge_request_UPDATE_states[i],
2795+ &handle_challenge_request_param,
2796+ 20322)) {
2797+ HIP_ERROR("Error on registering MIDAUTH handle function.\n");
2798+ return -1;
2799+ }
2800
2801- if (hip_register_handle_function(HIP_UPDATE,
2802- challenge_request_UPDATE_states[i],
2803- &add_host_id_param_update,
2804- 20750)) {
2805- HIP_ERROR("Error on registering MIDAUTH handle function.\n");
2806- return -1;
2807+ if (hip_register_handle_function(j, HIP_UPDATE,
2808+ challenge_request_UPDATE_states[i],
2809+ &add_host_id_param_update,
2810+ 20750)) {
2811+ HIP_ERROR("Error on registering MIDAUTH handle function.\n");
2812+ return -1;
2813+ }
2814 }
2815 }
2816
2817
2818=== modified file 'modules/update/hipd/update.c'
2819--- modules/update/hipd/update.c 2012-05-12 10:21:32 +0000
2820+++ modules/update/hipd/update.c 2012-07-07 13:45:26 +0000
2821@@ -84,7 +84,8 @@
2822 HIP_UPDATE,
2823 0,
2824 &ctx->hadb_entry->hit_our,
2825- &ctx->hadb_entry->hit_peer);
2826+ &ctx->hadb_entry->hit_peer,
2827+ ctx->hadb_entry->hip_version);
2828
2829 return 0;
2830 }
2831@@ -723,7 +724,8 @@
2832 HIP_UPDATE,
2833 0,
2834 &hadb_entry->hit_our,
2835- &hadb_entry->hit_peer);
2836+ &hadb_entry->hit_peer,
2837+ hadb_entry->hip_version);
2838
2839 HIP_IFEL(hip_build_param_esp_info(locator_update_packet,
2840 hadb_entry->current_keymat_index,
2841@@ -782,199 +784,201 @@
2842 -1,
2843 "Error on registering update state uninit function.\n");
2844
2845- HIP_IFEL(hip_register_handle_function(HIP_R1,
2846- HIP_STATE_I1_SENT,
2847- &hip_handle_locator, 31500),
2848- -1, "Error on registering LOCATOR handle function.\n");
2849- HIP_IFEL(hip_register_handle_function(HIP_R1,
2850- HIP_STATE_I2_SENT,
2851- &hip_handle_locator, 31500),
2852- -1, "Error on registering LOCATOR handle function.\n");
2853- HIP_IFEL(hip_register_handle_function(HIP_R1,
2854- HIP_STATE_CLOSING,
2855- &hip_handle_locator, 31500),
2856- -1, "Error on registering LOCATOR handle function.\n");
2857- HIP_IFEL(hip_register_handle_function(HIP_R1,
2858- HIP_STATE_CLOSED,
2859- &hip_handle_locator, 31500),
2860- -1, "Error on registering LOCATOR handle function.\n");
2861-
2862- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2863- HIP_STATE_R2_SENT,
2864- &check_update_freshness,
2865- 20000),
2866- -1, "Error on registering UPDATE handle function.\n");
2867- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2868- HIP_STATE_R2_SENT,
2869- &check_update_packet,
2870- 20100),
2871- -1, "Error on registering UPDATE handle function.\n");
2872- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2873- HIP_STATE_R2_SENT,
2874- &hip_update_retransmissions,
2875- 20150),
2876- -1, "Error on registering UPDATE handle function.\n");
2877- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2878- HIP_STATE_R2_SENT,
2879- &prepare_update_response,
2880- 20200),
2881- -1, "Error on registering UPDATE handle function.\n");
2882- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2883- HIP_STATE_R2_SENT,
2884- &hip_add_esp_info_param,
2885- 20300),
2886- -1, "Error on registering UPDATE handle function.\n");
2887- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2888- HIP_STATE_R2_SENT,
2889- &hip_handle_esp_info_param,
2890- 20400),
2891- -1, "Error on registering UPDATE handle function.\n");
2892- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2893- HIP_STATE_R2_SENT,
2894- &hip_handle_locator_parameter,
2895- 20500),
2896- -1, "Error on registering UPDATE handle function.\n");
2897- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2898- HIP_STATE_R2_SENT,
2899- &hip_add_seq_param,
2900- 20600),
2901- -1, "Error on registering UPDATE handle function.\n");
2902- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2903- HIP_STATE_R2_SENT,
2904- &hip_handle_seq_param,
2905- 20700),
2906- -1, "Error on registering UPDATE handle function.\n");
2907- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2908- HIP_STATE_R2_SENT,
2909- &hip_add_echo_request_param,
2910- 20800),
2911- -1, "Error on registering UPDATE handle function.\n");
2912- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2913- HIP_STATE_R2_SENT,
2914- &hip_handle_echo_request_sign_param,
2915- 20900),
2916- -1, "Error on registering UPDATE handle function.\n");
2917- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2918- HIP_STATE_R2_SENT,
2919- &hip_mac_and_sign_handler,
2920- 29900),
2921- -1, "Error on registering UPDATE handle function.\n");
2922- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2923- HIP_STATE_R2_SENT,
2924- &hip_handle_echo_request_param,
2925- 29950),
2926- -1, "Error on registering UPDATE handle function.\n");
2927- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2928- HIP_STATE_R2_SENT,
2929- &delete_ipsec_sa,
2930- 29990),
2931- -1, "Error on registering UPDATE handle function.\n");
2932- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2933- HIP_STATE_R2_SENT,
2934- &set_active_addresses,
2935- 29999),
2936- -1, "Error on registering UPDATE handle function.\n");
2937- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2938- HIP_STATE_R2_SENT,
2939- &send_update_packet,
2940- 30000),
2941- -1, "Error on registering UPDATE handle function.\n");
2942- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2943- HIP_STATE_R2_SENT,
2944- &create_ipsec_sa,
2945- 30500),
2946- -1, "Error on registering UPDATE handle function.\n");
2947- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2948- HIP_STATE_R2_SENT,
2949- &update_change_state,
2950- 40000),
2951- -1, "Error on registering UPDATE handle function.\n");
2952-
2953- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2954- HIP_STATE_ESTABLISHED,
2955- &check_update_freshness,
2956- 20000),
2957- -1, "Error on registering UPDATE handle function.\n");
2958- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2959- HIP_STATE_ESTABLISHED,
2960- &check_update_packet,
2961- 20100),
2962- -1, "Error on registering UPDATE handle function.\n");
2963- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2964- HIP_STATE_ESTABLISHED,
2965- &hip_update_retransmissions,
2966- 20150),
2967- -1, "Error on registering UPDATE handle function.\n");
2968- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2969- HIP_STATE_ESTABLISHED,
2970- &prepare_update_response,
2971- 20200),
2972- -1, "Error on registering UPDATE handle function.\n");
2973- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2974- HIP_STATE_ESTABLISHED,
2975- &hip_add_esp_info_param,
2976- 20300),
2977- -1, "Error on registering UPDATE handle function.\n");
2978- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2979- HIP_STATE_ESTABLISHED,
2980- &hip_handle_esp_info_param,
2981- 20400),
2982- -1, "Error on registering UPDATE handle function.\n");
2983- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2984- HIP_STATE_ESTABLISHED,
2985- &hip_handle_locator_parameter,
2986- 20500),
2987- -1, "Error on registering UPDATE handle function.\n");
2988- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2989- HIP_STATE_ESTABLISHED,
2990- &hip_add_seq_param,
2991- 20600),
2992- -1, "Error on registering UPDATE handle function.\n");
2993- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2994- HIP_STATE_ESTABLISHED,
2995- &hip_handle_seq_param,
2996- 20700),
2997- -1, "Error on registering UPDATE handle function.\n");
2998- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
2999- HIP_STATE_ESTABLISHED,
3000- &hip_add_echo_request_param,
3001- 20800),
3002- -1, "Error on registering UPDATE handle function.\n");
3003- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
3004- HIP_STATE_ESTABLISHED,
3005- &hip_handle_echo_request_sign_param,
3006- 20900),
3007- -1, "Error on registering UPDATE handle function.\n");
3008- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
3009- HIP_STATE_ESTABLISHED,
3010- &hip_mac_and_sign_handler,
3011- 29900),
3012- -1, "Error on registering UPDATE handle function.\n");
3013- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
3014- HIP_STATE_ESTABLISHED,
3015- &hip_handle_echo_request_param,
3016- 29950),
3017- -1, "Error on registering UPDATE handle function.\n");
3018- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
3019- HIP_STATE_ESTABLISHED,
3020- &delete_ipsec_sa,
3021- 29990),
3022- -1, "Error on registering UPDATE handle function.\n");
3023- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
3024- HIP_STATE_ESTABLISHED,
3025- &set_active_addresses,
3026- 29999),
3027- -1, "Error on registering UPDATE handle function.\n");
3028- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
3029- HIP_STATE_ESTABLISHED,
3030- &send_update_packet,
3031- 30000),
3032- -1, "Error on registering UPDATE handle function.\n");
3033- HIP_IFEL(hip_register_handle_function(HIP_UPDATE,
3034- HIP_STATE_ESTABLISHED,
3035- &create_ipsec_sa,
3036- 30500),
3037- -1, "Error on registering UPDATE handle function.\n");
3038+ for (int i = 1; i < HIP_MAX_VERSION; i++) {
3039+ HIP_IFEL(hip_register_handle_function(i, HIP_R1,
3040+ HIP_STATE_I1_SENT,
3041+ &hip_handle_locator, 31500),
3042+ -1, "Error on registering LOCATOR handle function.\n");
3043+ HIP_IFEL(hip_register_handle_function(i, HIP_R1,
3044+ HIP_STATE_I2_SENT,
3045+ &hip_handle_locator, 31500),
3046+ -1, "Error on registering LOCATOR handle function.\n");
3047+ HIP_IFEL(hip_register_handle_function(i, HIP_R1,
3048+ HIP_STATE_CLOSING,
3049+ &hip_handle_locator, 31500),
3050+ -1, "Error on registering LOCATOR handle function.\n");
3051+ HIP_IFEL(hip_register_handle_function(i, HIP_R1,
3052+ HIP_STATE_CLOSED,
3053+ &hip_handle_locator, 31500),
3054+ -1, "Error on registering LOCATOR handle function.\n");
3055+
3056+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3057+ HIP_STATE_R2_SENT,
3058+ &check_update_freshness,
3059+ 20000),
3060+ -1, "Error on registering UPDATE handle function.\n");
3061+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3062+ HIP_STATE_R2_SENT,
3063+ &check_update_packet,
3064+ 20100),
3065+ -1, "Error on registering UPDATE handle function.\n");
3066+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3067+ HIP_STATE_R2_SENT,
3068+ &hip_update_retransmissions,
3069+ 20150),
3070+ -1, "Error on registering UPDATE handle function.\n");
3071+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3072+ HIP_STATE_R2_SENT,
3073+ &prepare_update_response,
3074+ 20200),
3075+ -1, "Error on registering UPDATE handle function.\n");
3076+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3077+ HIP_STATE_R2_SENT,
3078+ &hip_add_esp_info_param,
3079+ 20300),
3080+ -1, "Error on registering UPDATE handle function.\n");
3081+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3082+ HIP_STATE_R2_SENT,
3083+ &hip_handle_esp_info_param,
3084+ 20400),
3085+ -1, "Error on registering UPDATE handle function.\n");
3086+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3087+ HIP_STATE_R2_SENT,
3088+ &hip_handle_locator_parameter,
3089+ 20500),
3090+ -1, "Error on registering UPDATE handle function.\n");
3091+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3092+ HIP_STATE_R2_SENT,
3093+ &hip_add_seq_param,
3094+ 20600),
3095+ -1, "Error on registering UPDATE handle function.\n");
3096+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3097+ HIP_STATE_R2_SENT,
3098+ &hip_handle_seq_param,
3099+ 20700),
3100+ -1, "Error on registering UPDATE handle function.\n");
3101+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3102+ HIP_STATE_R2_SENT,
3103+ &hip_add_echo_request_param,
3104+ 20800),
3105+ -1, "Error on registering UPDATE handle function.\n");
3106+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3107+ HIP_STATE_R2_SENT,
3108+ &hip_handle_echo_request_sign_param,
3109+ 20900),
3110+ -1, "Error on registering UPDATE handle function.\n");
3111+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3112+ HIP_STATE_R2_SENT,
3113+ &hip_mac_and_sign_handler,
3114+ 29900),
3115+ -1, "Error on registering UPDATE handle function.\n");
3116+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3117+ HIP_STATE_R2_SENT,
3118+ &hip_handle_echo_request_param,
3119+ 29950),
3120+ -1, "Error on registering UPDATE handle function.\n");
3121+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3122+ HIP_STATE_R2_SENT,
3123+ &delete_ipsec_sa,
3124+ 29990),
3125+ -1, "Error on registering UPDATE handle function.\n");
3126+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3127+ HIP_STATE_R2_SENT,
3128+ &set_active_addresses,
3129+ 29999),
3130+ -1, "Error on registering UPDATE handle function.\n");
3131+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3132+ HIP_STATE_R2_SENT,
3133+ &send_update_packet,
3134+ 30000),
3135+ -1, "Error on registering UPDATE handle function.\n");
3136+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3137+ HIP_STATE_R2_SENT,
3138+ &create_ipsec_sa,
3139+ 30500),
3140+ -1, "Error on registering UPDATE handle function.\n");
3141+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3142+ HIP_STATE_R2_SENT,
3143+ &update_change_state,
3144+ 40000),
3145+ -1, "Error on registering UPDATE handle function.\n");
3146+
3147+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3148+ HIP_STATE_ESTABLISHED,
3149+ &check_update_freshness,
3150+ 20000),
3151+ -1, "Error on registering UPDATE handle function.\n");
3152+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3153+ HIP_STATE_ESTABLISHED,
3154+ &check_update_packet,
3155+ 20100),
3156+ -1, "Error on registering UPDATE handle function.\n");
3157+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3158+ HIP_STATE_ESTABLISHED,
3159+ &hip_update_retransmissions,
3160+ 20150),
3161+ -1, "Error on registering UPDATE handle function.\n");
3162+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3163+ HIP_STATE_ESTABLISHED,
3164+ &prepare_update_response,
3165+ 20200),
3166+ -1, "Error on registering UPDATE handle function.\n");
3167+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3168+ HIP_STATE_ESTABLISHED,
3169+ &hip_add_esp_info_param,
3170+ 20300),
3171+ -1, "Error on registering UPDATE handle function.\n");
3172+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3173+ HIP_STATE_ESTABLISHED,
3174+ &hip_handle_esp_info_param,
3175+ 20400),
3176+ -1, "Error on registering UPDATE handle function.\n");
3177+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3178+ HIP_STATE_ESTABLISHED,
3179+ &hip_handle_locator_parameter,
3180+ 20500),
3181+ -1, "Error on registering UPDATE handle function.\n");
3182+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3183+ HIP_STATE_ESTABLISHED,
3184+ &hip_add_seq_param,
3185+ 20600),
3186+ -1, "Error on registering UPDATE handle function.\n");
3187+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3188+ HIP_STATE_ESTABLISHED,
3189+ &hip_handle_seq_param,
3190+ 20700),
3191+ -1, "Error on registering UPDATE handle function.\n");
3192+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3193+ HIP_STATE_ESTABLISHED,
3194+ &hip_add_echo_request_param,
3195+ 20800),
3196+ -1, "Error on registering UPDATE handle function.\n");
3197+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3198+ HIP_STATE_ESTABLISHED,
3199+ &hip_handle_echo_request_sign_param,
3200+ 20900),
3201+ -1, "Error on registering UPDATE handle function.\n");
3202+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3203+ HIP_STATE_ESTABLISHED,
3204+ &hip_mac_and_sign_handler,
3205+ 29900),
3206+ -1, "Error on registering UPDATE handle function.\n");
3207+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3208+ HIP_STATE_ESTABLISHED,
3209+ &hip_handle_echo_request_param,
3210+ 29950),
3211+ -1, "Error on registering UPDATE handle function.\n");
3212+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3213+ HIP_STATE_ESTABLISHED,
3214+ &delete_ipsec_sa,
3215+ 29990),
3216+ -1, "Error on registering UPDATE handle function.\n");
3217+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3218+ HIP_STATE_ESTABLISHED,
3219+ &set_active_addresses,
3220+ 29999),
3221+ -1, "Error on registering UPDATE handle function.\n");
3222+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3223+ HIP_STATE_ESTABLISHED,
3224+ &send_update_packet,
3225+ 30000),
3226+ -1, "Error on registering UPDATE handle function.\n");
3227+ HIP_IFEL(hip_register_handle_function(i, HIP_UPDATE,
3228+ HIP_STATE_ESTABLISHED,
3229+ &create_ipsec_sa,
3230+ 30500),
3231+ -1, "Error on registering UPDATE handle function.\n");
3232+ }
3233
3234 HIP_IFEL(hip_user_register_handle(HIP_MSG_MANUAL_UPDATE_PACKET,
3235 &update_manual_update,
3236
3237=== modified file 'test/libcore/cert.c'
3238--- test/libcore/cert.c 2012-05-12 06:54:33 +0000
3239+++ test/libcore/cert.c 2012-07-07 13:45:26 +0000
3240@@ -164,7 +164,7 @@
3241 ENCODING_FORMAT_PEM)) != NULL,
3242 NULL);
3243 msg = hip_msg_alloc();
3244- hip_build_network_hdr(msg, HIP_UPDATE, 0, &in6addr_any, &in6addr_any);
3245+ hip_build_network_hdr(msg, HIP_UPDATE, 0, &in6addr_any, &in6addr_any, HIP_V1);
3246 fail_unless((len = cert_X509_to_DER(cert, &buf)) > 0, NULL);
3247 fail_unless(hip_build_param_cert(msg, 0, 1, 1, HIP_CERT_X509V3, buf, len) == 0, NULL);
3248 fail_unless((cert2 = cert_get_X509_from_msg(msg)) != NULL, NULL);
3249
3250=== modified file 'test/libcore/gpl/pk.c'
3251--- test/libcore/gpl/pk.c 2012-05-12 06:54:33 +0000
3252+++ test/libcore/gpl/pk.c 2012-07-07 13:45:26 +0000
3253@@ -1,5 +1,5 @@
3254 /*
3255- * Copyright (c) 2011 Aalto University and RWTH Aachen University.
3256+ * Copyright (c) 2011-2012 Aalto University and RWTH Aachen University.
3257 *
3258 * Permission is hereby granted, free of charge, to any person
3259 * obtaining a copy of this software and associated documentation
3260@@ -52,7 +52,8 @@
3261 for (i = 0; i < sizeof(nids) / sizeof(int); i++) {
3262 eckey = create_ecdsa_key(nids[i]);
3263 msg = hip_msg_alloc();
3264- hip_build_network_hdr(msg, HIP_UPDATE, 0, &in6addr_any, &in6addr_loopback);
3265+ hip_build_network_hdr(msg, HIP_UPDATE, 0, &in6addr_any,
3266+ &in6addr_loopback, HIP_V1);
3267 hip_build_param_echo(msg, "AAAAA", 5, 1, 1);
3268
3269 fail_unless(hip_ecdsa_sign(eckey, msg) == 0, NULL);
3270@@ -82,7 +83,8 @@
3271 }
3272
3273 msg = hip_msg_alloc();
3274- hip_build_network_hdr(msg, HIP_UPDATE, 0, &in6addr_any, &in6addr_loopback);
3275+ hip_build_network_hdr(msg, HIP_UPDATE, 0, &in6addr_any,
3276+ &in6addr_loopback, HIP_V1);
3277 hip_build_param_echo(msg, "AAAAA", 5, 1, 1);
3278 fail_unless(hip_ecdsa_sign(eckeys[0], msg) == 0, NULL);
3279

Subscribers

People subscribed via source and target branches

to all changes: