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

Proposed by Xin
Status: Merged
Merged at revision: 6388
Proposed branch: lp:~hipl-core/hipl/hipv2-modularization
Merge into: lp:hipl
Diff against target: 2866 lines (+1034/-664)
33 files modified
doc/HOWTO.xml.in (+43/-0)
hipd/hipd.conf (+1/-0)
libcore/builder.c (+166/-41)
libcore/builder.h (+12/-1)
libcore/conf.c (+56/-2)
libcore/icomm.h (+2/-0)
libcore/protodefs.h (+5/-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 (+419/-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 (+52/-23)
libhipl/pkt_handling.h (+3/-2)
libhipl/user.c (+13/-0)
modules/cert/hipd/cert.c (+32/-32)
modules/midauth/hipd/midauth.c (+4/-4)
modules/update/hipd/update.c (+43/-41)
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
Artturi Karila Approve
Christof Mroz Abstain
Miika Komu Approve
Review via email: mp+113825@code.launchpad.net

Description of the change

Jul 7 2012

I update the branch according to reviews from Diego and Christof.
Since the previous proposal has been quite a while, I submit a new one
instead. Sorry for my delay, last month I had to work on my thesis.

===========================================================================

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
Miika Komu (miika-iki) wrote :

Seems good to me. Any other comments?

Xin, can you assign a deadline for the comments after which you'll merge (assuming nobody opposes)?

review: Approve
Revision history for this message
Miika Komu (miika-iki) wrote :

FYI. After this branch is merged, Xin will propose ecdh branch to be merged.

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

I might not be able to review this fully before next month, sorry.

I did take a look at the byte order conversion however (which I commented on before) and it looks good. One remark:

> === modified file 'libcore/builder.c'
> --- libcore/builder.c 2012-05-12 10:21:32 +0000
> +++ libcore/builder.c 2012-07-07 13:54:21 +0000
> @@ -1556,6 +1611,68 @@
> + // host to network byte order transform
> + convert_byte_order(list_content, item_count, item_size, true);
...
> + /* network to host byte order transform */
> + convert_byte_order(buffer, actual_count, item_size, false);

There are at least two ways to make such code more self-documenting, and thus get rid of the comments:
- Introduce constants for the boolean switches, e.g.
 enum cbo_flags {
  CBO_HTON = true,
  CBO_NTOH = false
 }
- Write wrapper functions that pass true or false

review: Abstain
Revision history for this message
Xin (eric-nevup) wrote :

Hi,

On 07/07/2012 09:50 PM, Miika Komu wrote:
> Review: Approve
>
> Seems good to me. Any other comments?
>
> Xin, can you assign a deadline for the comments after which you'll merge (assuming nobody opposes)?

Since there are not so many changes this time, let's set the deadline to
the Friday next week (13 July).

Best regards,
Xin

Revision history for this message
Artturi Karila (artturi-karila) :
review: Approve
Revision history for this message
René Hummen (rene-hummen) wrote :

I don't have time for an in-depth review. Just one comment though:
In my opinion, it would make great sense to distinguish between HIP_V1, HIP_V2, and HIP_ALL in the register functions. This would remove the need to register functions twice and would show nicely which version a handle function applies to.

On 09.07.2012, at 11:39, Artturi Karila wrote:
> Review: Approve
>
>
> --
> https://code.launchpad.net/~hipl-core/hipl/hipv2-modularization/+merge/113825
> Your team HIPL core team is subscribed to branch lp:hipl.
>

--
Dipl.-Inform. Rene Hummen, Ph.D. Student
Chair of Communication and Distributed Systems
RWTH Aachen University, Germany
tel: +49 241 80 21429
web: http://www.comsys.rwth-aachen.de/team/rene-hummen/

6256. By Xin

Eliminate redundant code for handle function registration.

A HIP_ALL parameter is added as a special hip version, functions with HIP_ALL
will be registered to all HIP versions which are supported by HIPL.

6257. By Xin

Improve the code readability for byte order conversion.

Revision history for this message
Xin (eric-nevup) wrote :

Hi,

On 07/08/2012 02:01 PM, Christof Mroz wrote:
> Review: Abstain
>
> I might not be able to review this fully before next month, sorry.
>
> I did take a look at the byte order conversion however (which I commented on before) and it looks good. One remark:
>
>> === modified file 'libcore/builder.c'
>> --- libcore/builder.c 2012-05-12 10:21:32 +0000
>> +++ libcore/builder.c 2012-07-07 13:54:21 +0000
>> @@ -1556,6 +1611,68 @@
>> + // host to network byte order transform
>> + convert_byte_order(list_content, item_count, item_size, true);
> ...
>> + /* network to host byte order transform */
>> + convert_byte_order(buffer, actual_count, item_size, false);
> There are at least two ways to make such code more self-documenting, and thus get rid of the comments:
> - Introduce constants for the boolean switches, e.g.
> enum cbo_flags {
> CBO_HTON = true,
> CBO_NTOH = false
> }
> - Write wrapper functions that pass true or false

I follow your advice to update the code. You can check it in this commit:
http://bazaar.launchpad.net/~hipl-core/hipl/hipv2-modularization/revision/6257

Thanks

Best regards,
Xin

Revision history for this message
Xin (eric-nevup) wrote :

Hi,

On 07/09/2012 12:49 PM, René Hummen wrote:
> I don't have time for an in-depth review. Just one comment though:
> In my opinion, it would make great sense to distinguish between HIP_V1, HIP_V2, and HIP_ALL in the register functions. This would remove the need to register functions twice and would show nicely which version a handle function applies to.
>

I have added the "HIP_ALL" and you can check it in this commit:
http://bazaar.launchpad.net/~hipl-core/hipl/hipv2-modularization/revision/6256

Yes, it reduces quite a lot of code :)

I am not sure if I should make a new proposal. If you think it is fine,
I will keep the current one. Then if there is no any further comment on
this branch before Friday night, i will merge it. Thanks.

Best regards,
Xin

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

On 12.07.2012 14:01, Xin wrote:
> I follow your advice to update the code. You can check it in this commit:
> http://bazaar.launchpad.net/~hipl-core/hipl/hipv2-modularization/revision/6257

One more thing, see below :(

> === modified file 'libcore/builder.c'
> --- libcore/builder.c 2012-07-07 13:42:21 +0000
> +++ libcore/builder.c 2012-07-12 11:50:33 +0000
> @@ -109,6 +109,11 @@
>
> static enum select_dh_key_t select_dh_key = STRONGER_KEY;
>
> +enum cbo_flags {
> + CBO_HTON = true,
> + CBO_NTOH = false
> +};
> +
> /**
> * Convert the byte order of a list of items in one buffer.
> *
> @@ -118,6 +123,7 @@
> * items in 2 bytes or 4 bytes.
> * @param hton if true, perform host-to-network byte order transform,
> * other wise perform network-to-host transform.
> + * @see @c cbo_flags.
> */
> static void convert_byte_order(void *content, unsigned count,
> unsigned item_size, bool hton)

If you use the enum type rather than bool here, you don't need to
document the "@see ..." part explicitly.
Note that IIRC writing ::identifier creates a hyperlink to `identifier'
in doxygen (and should issue a warning if `identifier' gets deleted),
unlike @c.

Now that I think of it, using true and false for anything but bool is
probably unnecessarily confusing, sorry about that.
I'd rather use opaque numeric values for enums (and avoid to cast them
to bool implicitly), just like everywhere else in HIPL, even if C is
very relaxed about enum and bool.

6258. By Xin

Avoid implicitly casting for the parameter of the byte order conversion
function.

Revision history for this message
Xin (eric-nevup) wrote :

Hi,

On 07/12/2012 03:37 PM, Christof Mroz wrote:
> One more thing, see below :(
>
>> === modified file 'libcore/builder.c'
>> --- libcore/builder.c 2012-07-07 13:42:21 +0000
>> +++ libcore/builder.c 2012-07-12 11:50:33 +0000
>> @@ -109,6 +109,11 @@
>>
>> static enum select_dh_key_t select_dh_key = STRONGER_KEY;
>>
>> +enum cbo_flags {
>> + CBO_HTON = true,
>> + CBO_NTOH = false
>> +};
>> +
>> /**
>> * Convert the byte order of a list of items in one buffer.
>> *
>> @@ -118,6 +123,7 @@
>> * items in 2 bytes or 4 bytes.
>> * @param hton if true, perform host-to-network byte order transform,
>> * other wise perform network-to-host transform.
>> + * @see @c cbo_flags.
>> */
>> static void convert_byte_order(void *content, unsigned count,
>> unsigned item_size, bool hton)
> If you use the enum type rather than bool here, you don't need to
> document the "@see ..." part explicitly.
> Note that IIRC writing ::identifier creates a hyperlink to `identifier'
> in doxygen (and should issue a warning if `identifier' gets deleted),
> unlike @c.
>
> Now that I think of it, using true and false for anything but bool is
> probably unnecessarily confusing, sorry about that.
> I'd rather use opaque numeric values for enums (and avoid to cast them
> to bool implicitly), just like everywhere else in HIPL, even if C is
> very relaxed about enum and bool.
>

Ah, OK. Is this time better?
http://bazaar.launchpad.net/~hipl-core/hipl/hipv2-modularization/revision/6258

Best regards,
Xin

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

On 12.07.2012 15:01, Xin wrote:
>> Now that I think of it, using true and false for anything but bool is
>> probably unnecessarily confusing, sorry about that.
>> I'd rather use opaque numeric values for enums (and avoid to cast them
>> to bool implicitly), just like everywhere else in HIPL, even if C is
>> very relaxed about enum and bool.
>>
>
> Ah, OK. Is this time better?
> http://bazaar.launchpad.net/~hipl-core/hipl/hipv2-modularization/revision/6258

Good, that's exactly what I meant.

Revision history for this message
Diego Biurrun (diego-biurrun) wrote :
Download full text (6.6 KiB)

 review needs-fixing

On Sat, Jul 07, 2012 at 01:55:22PM +0000, Xin wrote:
> --- doc/HOWTO.xml.in 2012-05-12 07:08:30 +0000
> +++ doc/HOWTO.xml.in 2012-07-07 13:54:21 +0000
> @@ -2607,6 +2607,49 @@
>
> + <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 a HIPv1 association with one peer, while maintaining a HIPv2
> + association with another peer.</para>
> + <para>HIPL dual-version support also enables a host to choose the default
> + HIP version for HIP association initiation. This behavior can be configured
> + via both the hipd configuration file and the hipconf command line tool.
> + </para>

I think you mean "HIP dual-version support" and not "HIPL" here, since
you are referring to the protocol, not the Linux implementation.

> + <para>The configuration parameter: <emphasis>hip-default-version</emphasis>
> + in the hipd.conf file accepts two value: 1 and 2, which stands for HIPv1

two value_s_, which stand_ for

> + and HIPv2 respectively. If the hipd cannot find this parameter in the
> + configuration file, HIPv1 will be used as a default value.

s/as a/as/

> + <para>Modification of the configuration parameter: <emphasis>
> + hip-default-version</emphasis> in the hipconf command line takes effect
> + immediately and no restart of the daemon is required. Any HA before
> + the modification keeps unchanged and all new HIP initiation messages

s/keeps/remains/

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

(I1 messages)

> --- hipd/hipd.conf 2011-12-12 14:26:13 +0000
> +++ hipd/hipd.conf 2012-07-07 13:54:21 +0000
> @@ -19,3 +19,4 @@
> debug medium # debug verbosity: all, medium, low or none
> +default-hip-version 1 # default HIP version number for the I1 message. (1=HIPV1, 2=HIPV2)

HIPv1, HIPv2

> --- libcore/builder.c 2012-05-12 10:21:32 +0000
> +++ libcore/builder.c 2012-07-07 13:54:21 +0000
> @@ -286,6 +318,28 @@
>
> /**
> + * Get the HIP version number from a HIP message header
> + *
> +
> +/**
> + * Set HIP version number to a given HIP message header
> + *

End sentences in periods please.

> @@ -1556,6 +1611,68 @@
>
> +/**
> + * Fetch the content of a HIP list-like parameter to a specified buffer.
> + *
> + * If the buffer size is smaller than the size of all items in the list, the
> + * result in the buffer will be truncated to first N items
> + * (N <= @c item_number). If the @c item_size is 2 bytes or 4 bytes, result
> + * items will be transformed from network byte order to host byte order.
> + *
> + * @param param pointer to the HIP list parameter.
> + * @param buffer the buffer for holding items of the list parameter.
> + * @param item_number a value-result argument. The caller must initialize it to
> + * the number of items @c buffer can h...

Read more...

review: Needs Fixing
6259. By Xin

Improve the list parameter handling API and revise documents.

Revision history for this message
Xin (eric-nevup) wrote :

Hi,

On 07/12/2012 07:46 PM, Diego Biurrun wrote:
> Review: Needs Fixing
>
> review needs-fixing
>
>

This commit should reflect all your comments:
http://bazaar.launchpad.net/~hipl-core/hipl/hipv2-modularization/revision/6259
<http://bazaar.launchpad.net/%7Ehipl-core/hipl/hipv2-modularization/revision/6259>

Thanks

Xin

Revision history for this message
Miika Komu (miika-iki) wrote :

FYI,

this branch was merged because Xin addressed the comments; ECDH branch is pending on this, and Xin is leaving Finland in July.

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

Subscribers

People subscribed via source and target branches

to all changes: