1 /* packet-hip.c
2 * Definitions and routines for HIP control packet disassembly
3 * Samu Varjonen <samu.varjonen@hiit.fi>
4 *
5 * Based on dissector originally created by
6 * Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
7 * Thomas Henderson <thomas.r.henderson@boeing.com>
8 * Samu Varjonen <samu.varjonen@hiit.fi>
9 * Thomas Jansen <mithi@mithi.net>
10 *
11 * Packet dissector for Host Identity Protocol (HIP) packets.
12 * This tool displays the TLV structure, verifies checksums,
13 * and shows NULL encrypted parameters, but will not verify
14 * signatures or decode encrypted parameters.
15 *
16 * Wireshark - Network traffic analyzer
17 * By Gerald Combs <gerald@wireshark.org>
18 * Copyright 1998 Gerald Combs
19 *
20 * SPDX-License-Identifier: GPL-2.0-or-later
21 */
22
23 #include "config.h"
24
25 #include <epan/packet.h>
26 #include <epan/expert.h>
27
28 #include <epan/ipproto.h>
29 #include <epan/in_cksum.h>
30
31 void proto_register_hip(void);
32 void proto_reg_handoff_hip(void);
33
34 #define HIP_UDP_PORT 10500
35
36 #define HI_ALG_DSA 3
37 #define HI_ALG_RSA 5
38
39 /* HIP packet types */
40 typedef enum {
41 HIP_I1=1,
42 HIP_R1,
43 HIP_I2,
44 HIP_R2,
45 HIP_UPDATE=16,
46 HIP_NOTIFY=17,
47 HIP_CLOSE=18,
48 HIP_CLOSE_ACK=19
49 } HIP_PACKETS;
50
51 /* HIP TLV parameters listed in order of RFCs */
52
53 /* RFC 5201 */
54 #define PARAM_R1_COUNTER 128
55 #define PARAM_PUZZLE 257
56 #define PARAM_SOLUTION 321
57 #define PARAM_SEQ 385
58 #define PARAM_ACK 449
59 #define PARAM_DIFFIE_HELLMAN 513
60 #define PARAM_HIP_TRANSFORM 577
61 #define PARAM_ENCRYPTED 641
62 #define PARAM_HOST_ID 705
63 /* Type number defined in RFC 5201 contents
64 in draft-ietf-hip-cert-00 */
65 #define PARAM_CERT 768
66 #define PARAM_NOTIFICATION 832
67 #define PARAM_ECHO_REQUEST_SIGNED 897
68 #define PARAM_ECHO_RESPONSE_SIGNED 961
69 #define PARAM_HMAC 61505
70 #define PARAM_HMAC_2 61569
71 #define PARAM_HIP_SIGNATURE_2 61633
72 #define PARAM_HIP_SIGNATURE 61697
73 #define PARAM_ECHO_REQUEST_UNSIGNED 63661
74 #define PARAM_ECHO_RESPONSE_UNSIGNED 63425
75 /* RFC 5202 */
76 #define PARAM_ESP_INFO 65
77 #define PARAM_ESP_TRANSFORM 4095
78 /* RFC 5203 */
79 #define PARAM_REG_INFO 930
80 #define PARAM_REG_REQUEST 932
81 #define PARAM_REG_RESPONSE 934
82 #define PARAM_REG_FAILED 936
83 /* RFC 5204 */
84 #define PARAM_FROM 65498
85 #define PARAM_RVS_HMAC 65500
86 #define PARAM_VIA_RVS 65502
87 /* RFC 5206 */
88 #define PARAM_LOCATOR 193
89 /* RFC 5770 */
90 #define PARAM_NAT_TRAVERSAL_MODE 608
91 #define PARAM_TRANSACTION_PACING 610
92 #define PARAM_REG_FROM 950
93 #define PARAM_RELAY_FROM 63998
94 #define PARAM_RELAY_TO 64002
95 #define PARAM_RELAY_HMAC 65520
96 /* HIPv2 draft-ietf-hip-rfc5201-bis-08 see section 5.2 */
97 #define PARAM_HIP_CIPHER 579
98 #define PARAM_HIT_SUITE_LIST 715
99 /* Bit masks */
100 #define PARAM_CRITICAL_BIT 0x0001
101 /* See RFC 5201 section 5.1 */
102 #define HIP_PACKET_TYPE_MASK 0x7F
103 /* draft-ietf-shim6-proto-12 see section 5.3 */
104 #define HIP_SHIM6_FIXED_BIT_P_MASK 0x80
105 #define HIP_SHIM6_FIXED_BIT_S_MASK 0x01
106 /* 00001110 Excluding the shim6 compatibility bit */
107 #define HIP_RESERVED_MASK 0x0E
108 #define HIP_VERSION_MASK 0xF0
109 #define HIP_CONTROL_A_MASK 0x0001
110 #define HIP_CONTROL_C_MASK 0x0002
111 #define HI_HDR_FLAGS_MASK 0xFFFF0000
112 #define HI_HDR_PROTO_MASK 0x0000FF00
113 #define HI_HDR_ALG_MASK 0x000000FF
114
115 static const value_string pinfo_vals[] = {
116 { HIP_I1, "HIP I1 (HIP Initiator Packet)" },
117 { HIP_R1, "HIP R1 (HIP Responder Packet)" },
118 { HIP_I2, "HIP I2 (Second HIP Initiator Packet)" },
119 { HIP_R2, "HIP R2 (Second HIP Responder Packet)" },
120 { HIP_UPDATE, "HIP UPDATE (HIP Update Packet)" },
121 { HIP_NOTIFY, "HIP NOTIFY (HIP Notify Packet)" },
122 { HIP_CLOSE, "HIP CLOSE (HIP Close Packet)" },
123 { HIP_CLOSE_ACK, "HIP CLOSE_ACK (HIP Close Acknowledgment Packet)" },
124 { 0, NULL }
125 };
126
127 static const value_string hip_param_vals[] = {
128 { PARAM_ESP_INFO, "ESP_INFO" },
129 { PARAM_R1_COUNTER, "R1_COUNTER" },
130 { PARAM_LOCATOR, "LOCATOR" },
131 { PARAM_PUZZLE, "PUZZLE" },
132 { PARAM_SOLUTION, "SOLUTION" },
133 { PARAM_SEQ, "SEQ" },
134 { PARAM_ACK, "ACK" },
135 { PARAM_DIFFIE_HELLMAN, "DIFFIE_HELLMAN" },
136 { PARAM_HIP_TRANSFORM, "HIP_TRANSFORM" },
137 { PARAM_ENCRYPTED, "ENCRYPTED" },
138 { PARAM_HOST_ID, "HOST_ID" },
139 { PARAM_CERT, "CERT" },
140 { PARAM_NOTIFICATION, "NOTIFICATION" },
141 { PARAM_ECHO_REQUEST_SIGNED, "ECHO_REQUEST_SIGNED" },
142 { PARAM_ECHO_RESPONSE_SIGNED, "ECHO_RESPONSE_SIGNED" },
143 { PARAM_ESP_TRANSFORM, "ESP_TRANSFORM" },
144 { PARAM_HMAC, "HMAC" },
145 { PARAM_HMAC_2, "HMAC_2" },
146 { PARAM_HIP_SIGNATURE, "HIP_SIGNATURE" },
147 { PARAM_HIP_SIGNATURE_2, "HIP_SIGNATURE_2" },
148 { PARAM_ECHO_REQUEST_UNSIGNED, "ECHO_REQUEST_UNSIGNED" },
149 { PARAM_ECHO_RESPONSE_UNSIGNED, "ECHO_RESPONSE_UNSIGNED" },
150 { PARAM_NAT_TRAVERSAL_MODE, "NAT_TRAVERSAL_MODE" },
151 { PARAM_TRANSACTION_PACING, "TRANSACTION_PACING" },
152 { PARAM_RELAY_FROM, "RELAY_FROM" },
153 { PARAM_RELAY_TO, "RELAY_TO" },
154 { PARAM_RELAY_HMAC, "RELAY_HMAC" },
155 { PARAM_REG_INFO, "REG_INFO" },
156 { PARAM_REG_REQUEST, "REG_REQUEST" },
157 { PARAM_REG_RESPONSE, "REG_RESPONSE" },
158 { PARAM_REG_FROM, "REG_FROM" },
159 { PARAM_HIP_CIPHER, "HIP_CIPHER"},
160 { PARAM_HIT_SUITE_LIST, "HIT_SUITE_LIST"},
161 { 0, NULL }
162 };
163
164 /* RFC 5201 section 5.2.6. */
165 static const value_string dh_group_id_vals[] = {
166 { 0x0, "Reserved" },
167 { 0x01, "384-bit group" },
168 { 0x02, "OAKLEY well-known group 1" },
169 { 0x03, "1536-bit MODP group" },
170 { 0x04, "3072-bit MODP group" },
171 { 0x05, "6144-bit MODP group" },
172 { 0x06, "8192-bit MODP group" },
173 { 0, NULL }
174 };
175
176 /* RFC 5202 section 5.1.2. */
177 static const value_string transform_id_vals[] = {
178 { 0x0, "Reserved" },
179 { 0x01, "AES-CBC with HMAC-SHA1" },
180 { 0x02, "3DES-CBC with HMAC-SHA1" },
181 { 0x03, "3DES-CBC with HMAC-MD5" },
182 { 0x04, "BLOWFISH-CBC with HMAC-SHA1" },
183 { 0x05, "NULL with HMAC-SHA1" },
184 { 0x06, "NULL with HMAC-MD5" },
185 { 0, NULL }
186 };
187
188 static const value_string reg_type_vals[] = {
189 { 0x01, "RENDEZVOUS" }, /* RFC 5204 */
190 { 0x02, "RELAY_UDP_HIP" }, /* RFC 5770 */
191 { 0, NULL }
192 };
193
194 /* RFC 5201 section 5.2.8 */
195 static const value_string sig_alg_vals[] = {
196 { 0x0, "Reserved" },
197 { HI_ALG_DSA, "DSA" },
198 { HI_ALG_RSA, "RSA" },
199 { 0, NULL }
200 };
201
202 /* RFC 5770 */
203 static const value_string mode_id_vals[] = {
204 { 0x0, "Reserved" },
205 { 0x01, "UDP-encapsulation" },
206 { 0x02, "ICE-STUN-UDP" },
207 { 0, NULL }
208 };
209
210 static const value_string hi_hdr_flags_vals[] = {
211 { 0x0, "Other" },
212 { 0x0200, "Key is associated with a user" },
213 { 0x0201, "Zone key" },
214 { 0x0202, "Key is associated with non-zone entity" },
215 { 0, NULL }
216 };
217
218 /* RFC 2535 section 3.1.3 */
219 static const value_string hi_hdr_proto_vals[] = {
220 { 0x01, "Key is used for TLS" },
221 { 0x02, "Key is used for email" },
222 { 0x03, "Key is used for DNS security" },
223 { 0x04, "Key is used for Oakley/IPSEC" },
224 { 0xFF, "Key is valid for any protocol" },
225 { 0, NULL }
226 };
227
228 /* RFC 2535 section 3.2 */
229 static const value_string hi_hdr_alg_vals[] = {
230 { 0x00, "Reserved" },
231 { 0x01, "RSA/MD5" },
232 { 0x02, "Diffie-Hellman" },
233 { 0x03, "DSA" },
234 { 0x04, "elliptic curve crypto" },
235 { 0x05, "RSA" },
236 { 0xFF, "Reserved" },
237 { 0, NULL }
238 };
239
240 /* RFC 5201 */
241 static const value_string notification_vals[] = {
242 { 1, "Unsupported critical parameter type" },
243 { 7, "Invalid syntax" },
244 { 14, "No Diffie-Hellman proposal chosen" },
245 { 15, "Invalid Diffie-Hellman chosen" },
246 { 16, "No HIP proposal chosen" },
247 { 17, "Invalid HIP transform chosen" },
248 { 18, "No ESP proposal chosen" },
249 { 19, "Invalid ESP transform chosen" },
250 { 24, "Authentication failed" },
251 { 26, "Checksum failed" },
252 { 28, "HMAC failed" },
253 { 32, "Encryption failed" },
254 { 40, "Invalid HIT" },
255 { 42, "Blocked by policy" },
256 { 44, "Server busy please retry" },
257 { 0, NULL }
258 };
259
260 #if 0
261 /* RFC 5770 */
262 static const value_string nat_traversal_mode_vals[] = {
263 { 0, "Reserved"},
264 { 1, "UDP-encapsulation"},
265 { 2, "ICE-STUN-UDP"},
266 { 0, NULL }
267 };
268 #endif
269
270 /* HIPv2 draft-ietf-hip-rfc5201-bis-08 Section 5.2 */
271 static const value_string cipher_vals[] = {
272 { 0x0, "Reserved" },
273 { 0x01, "NULL-ENCRYPT" },
274 { 0x02, "AES-128-CBC" },
275 { 0x03, "3DES-CBC" },
276 { 0x04, "AES-256-CBC" },
277 { 0, NULL }
278 };
279
280 static const value_string hit_suite_vals[] = {
281 { 0x00, "Reserved" },
282 { 0x01, "RSA,DSA/SHA-256" },
283 { 0x02, "ECDSA/SHA384" },
284 { 0x03, "ECDSA_LOW/SHA-1" },
285 { 0, NULL }
286 };
287
288 /* functions */
289 static int dissect_hip_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_item *ti, int type, int tlv_len);
290
291 static int proto_hip = -1;
292 static int hf_hip_proto = -1;
293 static int hf_hip_hdr_len = -1;
294 static int hf_hip_shim6_fixed_bit_p = -1;
295 static int hf_hip_packet_type = -1;
296 static int hf_hip_version = -1;
297 static int hf_hip_shim6_fixed_bit_s = -1;
298 static int hf_hip_controls = -1;
299 static int hf_hip_controls_anon = -1;
300 static int hf_hip_checksum = -1;
301 static int hf_hip_checksum_status = -1;
302 static int hf_hip_hit_sndr = -1;
303 static int hf_hip_hit_rcvr = -1;
304
305 static int hf_hip_type = -1;
306 static int hf_hip_tlv_ei_res = -1;
307 static int hf_hip_tlv_ei_keyidx = -1;
308 static int hf_hip_tlv_ei_oldspi = -1;
309 static int hf_hip_tlv_ei_newspi = -1;
310 static int hf_hip_tlv_r1_res = -1;
311 static int hf_hip_tlv_r1count = -1;
312 static int hf_hip_tlv_puzzle_k = -1;
313 static int hf_hip_tlv_puzzle_life = -1;
314 static int hf_hip_tlv_puzzle_o = -1;
315 static int hf_hip_tlv_puzzle_i = -1;
316 static int hf_hip_tlv_solution_k = -1;
317 static int hf_hip_tlv_solution_reserved = -1;
318 static int hf_hip_tlv_solution_o = -1;
319 static int hf_hip_tlv_solution_i = -1;
320 static int hf_hip_tlv_solution_j = -1;
321 static int hf_hip_tlv_seq_updid = -1;
322 static int hf_hip_tlv_ack_updid = -1;
323 static int hf_hip_tlv_dh_group_id = -1;
324 static int hf_hip_tlv_dh_pub = -1;
325 static int hf_hip_tlv_dh_pv_length = -1;
326 static int hf_hip_tlv_trans_id = -1;
327 static int hf_hip_tlv_esp_reserved = -1;
328 static int hf_hip_tlv_cipher_id = -1;
329 static int hf_hip_tlv_hit_suite_id = -1;
330 static int hf_hip_tlv_host_id_len = -1;
331 static int hf_hip_tlv_host_di_type = -1;
332 static int hf_hip_tlv_host_di_len = -1;
333 static int hf_hip_tlv_host_id_hdr = -1;
334 static int hf_hip_tlv_host_id_hdr_flags = -1;
335 static int hf_hip_tlv_host_id_hdr_proto = -1;
336 static int hf_hip_tlv_host_id_hdr_alg = -1;
337 static int hf_hip_tlv_host_id_t = -1;
338 static int hf_hip_tlv_host_id_q = -1;
339 static int hf_hip_tlv_host_id_p = -1;
340 static int hf_hip_tlv_host_id_g = -1;
341 static int hf_hip_tlv_host_id_y = -1;
342 static int hf_hip_tlv_host_id_e_len = -1;
343 static int hf_hip_tlv_host_id_e = -1;
344 static int hf_hip_tlv_host_id_n = -1;
345 static int hf_hip_tlv_notification_res = -1;
346 static int hf_hip_tlv_notification_type = -1;
347 static int hf_hip_tlv_notification_data = -1;
348 static int hf_hip_tlv_opaque_data = -1;
349 static int hf_hip_tlv_reg_ltmin = -1;
350 static int hf_hip_tlv_reg_ltmax = -1;
351 static int hf_hip_tlv_reg_lt = -1;
352 static int hf_hip_tlv_reg_type = -1;
353 static int hf_hip_tlv_reg_failtype = -1;
354 static int hf_hip_tlv_hmac = -1;
355 static int hf_hip_tlv_sig_alg = -1;
356 static int hf_hip_tlv_sig = -1;
357 static int hf_hip_tlv_enc_reserved = -1;
358 static int hf_hip_tlv_locator_traffic_type = -1;
359 static int hf_hip_tlv_locator_type = -1;
360 static int hf_hip_tlv_locator_len = -1;
361 static int hf_hip_tlv_locator_reserved = -1;
362 static int hf_hip_tlv_locator_lifetime = -1;
363 static int hf_hip_tlv_locator_port = -1;
364 static int hf_hip_tlv_locator_transport_protocol = -1;
365 static int hf_hip_tlv_locator_kind = -1;
366 static int hf_hip_tlv_locator_priority = -1;
367 static int hf_hip_tlv_locator_spi = -1;
368 static int hf_hip_tlv_locator_address = -1;
369
370 static int hf_hip_tlv_cert_group = -1;
371 static int hf_hip_tlv_cert_count = -1;
372 static int hf_hip_tlv_cert_id = -1;
373 static int hf_hip_tlv_cert_type = -1;
374 static int hf_hip_tlv_certificate = -1;
375
376 static int hf_hip_tlv_from_address = -1;
377 static int hf_hip_tlv_rvs_address = -1;
378
379 static int hf_hip_tlv_nat_traversal_mode_id = -1;
380 static int hf_hip_tlv_transaction_minta = -1;
381 static int hf_hip_tlv_relay_from_port = -1;
382 static int hf_hip_tlv_relay_from_protocol = -1;
383 static int hf_hip_tlv_relay_from_reserved = -1;
384 static int hf_hip_tlv_relay_from_address = -1;
385 static int hf_hip_tlv_relay_to_port = -1;
386 static int hf_hip_tlv_relay_to_protocol = -1;
387 static int hf_hip_tlv_relay_to_reserved = -1;
388 static int hf_hip_tlv_relay_to_address = -1;
389 static int hf_hip_tlv_reg_from_port = -1;
390 static int hf_hip_tlv_reg_from_protocol = -1;
391 static int hf_hip_tlv_reg_from_reserved = -1;
392 static int hf_hip_tlv_reg_from_address = -1;
393 static int hf_hip_encrypted_parameter_data = -1;
394 static int hf_hip_fqdn = -1;
395 static int hf_hip_nai = -1;
396
397 static gint ett_hip = -1;
398 static gint ett_hip_controls = -1;
399 static gint ett_hip_tlv = -1;
400 static gint ett_hip_tlv_data = -1;
401 static gint ett_hip_tlv_host_id_hdr = -1;
402 static gint ett_hip_locator_data = -1;
403
404 static expert_field ei_hip_tlv_host_id_len = EI_INIT;
405 /* static expert_field ei_hip_tlv_host_id_e_len = EI_INIT; */
406 static expert_field ei_hip_tlv_host_id_hdr_alg = EI_INIT;
407 static expert_field ei_hip_checksum = EI_INIT;
408
409 /* Dissect the HIP packet */
410 static void
dissect_hip_common(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,gboolean udp)411 dissect_hip_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp)
412 {
413 proto_tree *hip_tree, *hip_tlv_tree=NULL;
414 proto_item *ti, *ti_tlv;
415 int length, offset = 0, newoffset = 0;
416 guint16 control_h, checksum_h;
417 guint16 tlv_type_h, tlv_length_h; /* For storing in host order */
418 guint len;
419 guint reported_len;
420 vec_t cksum_vec[4];
421 guint32 phdr[2];
422
423 /* Payload format RFC 5201 section 5.1 */
424 /* hiph_proto; */ /* payload protocol */
425 guint8 hiph_hdr_len; /* header length */
426 guint8 hiph_shim6_fixed_bit_s; /* This is always 0 */
427 guint8 hiph_packet_type; /* packet type */
428 guint8 hiph_res_ver, hiph_version, hiph_reserved;
429 /* byte for reserved and version */
430 guint8 hiph_shim6_fixed_bit_p; /* This is always 1 */
431 /* checksum_h */ /* checksum */
432 /* control_h */ /* control */
433 /* HIP parameters ... */
434
435 /* load the top pane info. This should be overwritten by
436 the next protocol in the stack */
437 col_set_str(pinfo->cinfo, COL_PROTOCOL, "HIP");
438 col_clear(pinfo->cinfo, COL_INFO);
439
440 newoffset = offset;
441 /* hiph Proto */
442 newoffset++;
443 hiph_hdr_len = tvb_get_guint8(tvb, newoffset);
444 newoffset++;
445 hiph_packet_type = tvb_get_guint8(tvb, newoffset);
446 /* draft-ietf-shim6-proto-12 see section 5.3 */
447 hiph_shim6_fixed_bit_p = (hiph_packet_type & HIP_SHIM6_FIXED_BIT_P_MASK) >> 7;
448 hiph_packet_type = hiph_packet_type & HIP_PACKET_TYPE_MASK;
449 newoffset++;
450 hiph_res_ver = tvb_get_guint8(tvb, newoffset);
451 /* divide to reserved and version and shim6_fixed_bit_s
452 draft-ietf-shim6-proto-12 see section 5.3 */
453 hiph_version = (hiph_res_ver & HIP_VERSION_MASK) >> 4;
454 hiph_reserved = hiph_res_ver & HIP_RESERVED_MASK;
455 hiph_shim6_fixed_bit_s = hiph_res_ver & HIP_SHIM6_FIXED_BIT_S_MASK;
456 newoffset++;
457 checksum_h = tvb_get_ntohs(tvb, newoffset);
458 newoffset += 2;
459 control_h = tvb_get_ntohs(tvb, newoffset);
460
461 col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(hiph_packet_type, pinfo_vals, "Unknown"));
462
463 /* populate a tree in the second pane with the status of the link layer (i.e. none) */
464 ti = proto_tree_add_item(tree, proto_hip, tvb, 0, -1, ENC_NA);
465
466 hip_tree = proto_item_add_subtree(ti, ett_hip);
467 proto_tree_add_item(hip_tree, hf_hip_proto, tvb, offset, 1, ENC_BIG_ENDIAN);
468 proto_tree_add_item(hip_tree, hf_hip_hdr_len, tvb, offset+1, 1, ENC_BIG_ENDIAN);
469 proto_tree_add_uint_format(hip_tree, hf_hip_shim6_fixed_bit_p, tvb, offset+2, 1,
470 hiph_shim6_fixed_bit_p,
471 "Fixed P-bit: %u (Always zero)",
472 hiph_shim6_fixed_bit_p);
473 proto_tree_add_uint(hip_tree, hf_hip_packet_type, tvb, offset+2, 1,
474 hiph_packet_type);
475 proto_tree_add_uint_format_value(hip_tree, hf_hip_version, tvb, offset+3, 1,
476 hiph_version, "%u, Reserved: %u",
477 hiph_version, hiph_reserved);
478 proto_tree_add_uint_format(hip_tree, hf_hip_shim6_fixed_bit_s, tvb, offset+3, 1,
479 hiph_shim6_fixed_bit_s,
480 "Fixed S-bit: %u (%s)",
481 hiph_shim6_fixed_bit_s,
482 ((hiph_shim6_fixed_bit_s) ? "HIP" : "SHIM6"));
483
484 /* Checksum - this is the same algorithm from UDP, ICMPv6 */
485 reported_len = tvb_reported_length(tvb);
486 len = tvb_captured_length(tvb);
487 if (!pinfo->fragmented && len >= reported_len) {
488 /* IPv4 or IPv6 addresses */
489 SET_CKSUM_VEC_PTR(cksum_vec[0], (const guint8 *)pinfo->src.data, pinfo->src.len);
490 SET_CKSUM_VEC_PTR(cksum_vec[1], (const guint8 *)pinfo->dst.data, pinfo->dst.len);
491
492 /* the rest of the pseudo-header */
493 if (pinfo->src.type == AT_IPv6) {
494 phdr[0] = reported_len;
495 phdr[0] = g_htonl(phdr[0]); /* Note: g_htonl() macro may eval arg multiple times */
496 phdr[1] = g_htonl(IP_PROTO_HIP);
497 SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)&phdr, 8);
498 } else {
499 phdr[0] = (IP_PROTO_HIP<<16)+reported_len;
500 phdr[0] = g_htonl(phdr[0]); /* Note: g_htonl() macro may eval arg multiple times */
501 SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)&phdr, 4);
502 }
503 /* pointer to the HIP header (packet data) */
504 SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, reported_len);
505 if (checksum_h == 0 && udp) {
506 proto_tree_add_checksum(hip_tree, tvb, offset+4, hf_hip_checksum, hf_hip_checksum_status, &ei_hip_checksum, pinfo, 0,
507 ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
508 } else {
509 proto_tree_add_checksum(hip_tree, tvb, offset+4, hf_hip_checksum, hf_hip_checksum_status, &ei_hip_checksum, pinfo, in_cksum(cksum_vec, 4),
510 ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
511 }
512 } else {
513 proto_tree_add_checksum(hip_tree, tvb, offset+4, hf_hip_checksum, hf_hip_checksum_status, &ei_hip_checksum, pinfo, 0,
514 ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
515 }
516
517 ti = proto_tree_add_item(hip_tree, hf_hip_controls, tvb, offset+6, 2, ENC_BIG_ENDIAN);
518 if (ti) {
519 /* HIP Controls subtree */
520 ti = proto_item_add_subtree(ti, ett_hip_controls);
521 proto_tree_add_boolean(ti, hf_hip_controls_anon, tvb,
522 offset+7,1, control_h);
523 }
524
525 offset += 8;
526 proto_tree_add_item(hip_tree, hf_hip_hit_sndr, tvb, offset,
527 16, ENC_NA);
528 offset += 16;
529 proto_tree_add_item(hip_tree, hf_hip_hit_rcvr, tvb, offset,
530 16, ENC_NA);
531 offset += 16;
532
533 length = (hiph_hdr_len + 1) * 8;
534 /* Begin TLV parsing */
535 if (offset < length) {
536 hip_tlv_tree = proto_tree_add_subtree(hip_tree, tvb, offset,
537 -1, ett_hip_tlv, NULL, "HIP Parameters");
538 }
539 /* Parse type and length in TLV */
540 while (offset < length)
541 {
542 tlv_type_h = tvb_get_ntohs(tvb, offset);
543 tlv_length_h = tvb_get_ntohs(tvb, offset + 2);
544 ti_tlv = proto_tree_add_uint_format(hip_tlv_tree, hf_hip_type, tvb,
545 offset, 4 + tlv_length_h, tlv_type_h,
546 "%s (type=%u, length=%u)",
547 val_to_str_const(tlv_type_h, hip_param_vals, "Unknown"),
548 tlv_type_h, tlv_length_h);
549
550 /* Parse value */
551 dissect_hip_tlv(tvb, pinfo, offset, ti_tlv, tlv_type_h, tlv_length_h);
552
553 offset += 11 + tlv_length_h - (tlv_length_h + 3) % 8;
554 }
555 }
556
557 static int
dissect_hip(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)558 dissect_hip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
559 {
560 dissect_hip_common(tvb, pinfo, tree, FALSE);
561 return tvb_captured_length(tvb);
562 }
563
564 static int
dissect_hip_in_udp(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)565 dissect_hip_in_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
566 {
567 guint32 nullbytes;
568 tvbuff_t *newtvb;
569
570 if (tvb_captured_length(tvb) < 4)
571 return 0;
572
573 nullbytes = tvb_get_ntohl(tvb, 0);
574 if (nullbytes != 0)
575 return 0;
576
577 newtvb = tvb_new_subset_remaining(tvb, 4);
578 dissect_hip_common(newtvb, pinfo, tree, TRUE);
579
580 return tvb_captured_length(tvb);
581 }
582
583
584 static int
dissect_hip_tlv(tvbuff_t * tvb,packet_info * pinfo,int offset,proto_item * ti,int type,int tlv_len)585 dissect_hip_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_item *ti, int type, int tlv_len)
586 {
587 proto_tree *t=NULL;
588 proto_item *ti_tlv, *ti_loc, *hi_len_item, *e_len_item, *arg_item;
589 guint8 n, algorithm, reg_type;
590 guint16 trans, hi_len, di_len, di_type, e_len, pv_len;
591 guint32 reserved, hi_hdr;
592 guint8 transport_proto;
593 guint8 locator_type;
594 int newoffset, newlen, hi_t;
595
596 /* move over the TLV */
597 newoffset = offset + 4;
598 t = proto_item_add_subtree(ti, ett_hip_tlv_data);
599 switch (type)
600 {
601 case PARAM_ESP_INFO:
602 /* Reserved */
603 proto_tree_add_item(t, hf_hip_tlv_ei_res, tvb, newoffset, 2, ENC_BIG_ENDIAN);
604 /* KEYMAT index */
605 newoffset += 2;
606 proto_tree_add_item(t, hf_hip_tlv_ei_keyidx, tvb, newoffset, 2, ENC_BIG_ENDIAN);
607 /* OLD SPI */
608 newoffset += 2;
609 proto_tree_add_item(t, hf_hip_tlv_ei_oldspi, tvb, newoffset, 4, ENC_BIG_ENDIAN);
610 /* NEW SPI */
611 newoffset += 4;
612 proto_tree_add_item(t, hf_hip_tlv_ei_newspi, tvb, newoffset, 4, ENC_BIG_ENDIAN);
613 break;
614 case PARAM_R1_COUNTER:
615 /* Reserved */
616 proto_tree_add_item(t, hf_hip_tlv_r1_res, tvb, newoffset, 4, ENC_BIG_ENDIAN);
617 /* R1 generation counter */
618 newoffset += 4;
619 proto_tree_add_item(t, hf_hip_tlv_r1count, tvb, newoffset, 8, ENC_NA);
620 break;
621 case PARAM_LOCATOR:
622 /* RFC 5206 section 4. and RFC 5770 section 5.7. for type 2 locators
623 */
624 tlv_len -= 4;
625 /* loop through included locators */
626 while (tlv_len > 0) {
627 /* Every locator to new tree node
628 * Skip ahead and read the 0 or 1 type locator from 8 bytes
629 * and type 2 locator from 20 bytes to be used as the top level
630 * tree_item for this subtree
631 */
632 locator_type = tvb_get_guint8(tvb, newoffset + 1);
633 if (locator_type == 0) {
634 ti_loc = proto_tree_add_item(t, hf_hip_tlv_locator_address,
635 tvb, newoffset + 8, 16, ENC_NA);
636 } else if (locator_type == 1) {
637 ti_loc = proto_tree_add_item(t, hf_hip_tlv_locator_address,
638 tvb, newoffset + 12, 16, ENC_NA);
639 } else if (locator_type == 2) {
640 ti_loc = proto_tree_add_item(t, hf_hip_tlv_locator_address,
641 tvb, newoffset + 20, 16, ENC_NA);
642 } else {
643 /* unknown or malformed locator type jumping over it */
644 ti_loc = NULL;
645 newoffset += (1 + tvb_get_guint8(tvb, newoffset + 2));
646 tlv_len -= (1 + tvb_get_guint8(tvb, newoffset + 2));
647 }
648 if (locator_type <= 2) {
649 ti_loc = proto_item_add_subtree(ti_loc, ett_hip_locator_data);
650 /* Traffic type */
651 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_traffic_type, tvb,
652 newoffset, 1, ENC_BIG_ENDIAN);
653 newoffset++;
654 /* Locator type */
655 #if 0
656 locator_type = tvb_get_guint8(tvb, newoffset);
657 #endif
658 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_type, tvb, newoffset, 1, ENC_BIG_ENDIAN);
659 newoffset++;
660 /* Locator length */
661 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_len, tvb, newoffset, 1, ENC_BIG_ENDIAN);
662 newoffset++;
663 /* Reserved includes the Preferred bit */
664 reserved = tvb_get_guint8(tvb, newoffset);
665 proto_tree_add_uint_format_value(ti_loc, hf_hip_tlv_locator_reserved, tvb,
666 newoffset, 1, reserved,
667 "0x%x %s", reserved,
668 (reserved >> 31) ? "(Preferred)" : "");
669 newoffset++;
670 /* Locator lifetime */
671 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_lifetime, tvb,
672 newoffset, 4, ENC_BIG_ENDIAN);
673 newoffset += 4;
674 if (locator_type == 0) {
675 /* Locator types 1 and 0 RFC 5206 section 4.2.*/
676 /* Locator */
677 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_address,
678 tvb, newoffset, 16, ENC_NA);
679 newoffset += 16;
680 tlv_len -= 24;
681 } else if (locator_type == 1) {
682 /* Locator types 1 and 0 RFC 5206 section 4.2.*/
683 /* SPI */
684 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_spi, tvb,
685 newoffset, 4, ENC_BIG_ENDIAN);
686 newoffset += 4;
687 /* Locator */
688 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_address,
689 tvb, newoffset, 16, ENC_NA);
690 newoffset += 16;
691 tlv_len -= 28;
692 } else if (locator_type == 2) {
693 /* Locator type 2 RFC 5770 section 5.7. */
694 /* Tansport port */
695 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_port, tvb,
696 newoffset, 2, ENC_BIG_ENDIAN);
697 newoffset += 2;
698 /* Transport protocol */
699 transport_proto = tvb_get_guint8(tvb, newoffset);
700 /* RFC 5770 section 5.6 */
701 proto_tree_add_uint_format(ti_loc, hf_hip_tlv_locator_transport_protocol,
702 tvb, newoffset, 1, transport_proto,
703 "Transport protocol: %d %s",
704 transport_proto,
705 (transport_proto == 17) ?
706 "(UDP)" : "");
707 newoffset++;
708 /* Kind */
709 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_kind, tvb,
710 newoffset, 1, ENC_BIG_ENDIAN);
711 newoffset++;
712 /* Priority */
713 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_priority, tvb,
714 newoffset, 4, ENC_BIG_ENDIAN);
715 newoffset += 4;
716 /* SPI */
717 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_spi, tvb,
718 newoffset, 4, ENC_BIG_ENDIAN);
719 newoffset += 4;
720 /* Locator */
721 proto_tree_add_item(ti_loc, hf_hip_tlv_locator_address,
722 tvb, newoffset, 16, ENC_NA);
723 newoffset += 16;
724 tlv_len -= 36;
725 }
726 }
727 }
728 break;
729 case PARAM_PUZZLE:
730 /* K number of verified bits */
731 proto_tree_add_item(t, hf_hip_tlv_puzzle_k, tvb, newoffset, 1, ENC_BIG_ENDIAN);
732 /* Puzzle lifetime */
733 newoffset++;
734 proto_tree_add_item(t, hf_hip_tlv_puzzle_life, tvb, newoffset, 1, ENC_BIG_ENDIAN);
735 /* Puzzle O*/
736 newoffset++;
737 proto_tree_add_item(t, hf_hip_tlv_puzzle_o, tvb, newoffset, 2, ENC_BIG_ENDIAN);
738 /* Puzzle I */
739 newoffset += 2;
740 proto_tree_add_item(t, hf_hip_tlv_puzzle_i, tvb,newoffset, tlv_len - 4, ENC_NA);
741 break;
742 case PARAM_SOLUTION:
743 /* K number of verified bits */
744 proto_tree_add_item(t, hf_hip_tlv_solution_k, tvb, newoffset, 1, ENC_BIG_ENDIAN);
745 /* Solution Reserved */
746 newoffset++;
747 proto_tree_add_item(t, hf_hip_tlv_solution_reserved, tvb, newoffset, 1, ENC_BIG_ENDIAN);
748 /* Solution Opaque */
749 newoffset++;
750 proto_tree_add_item(t, hf_hip_tlv_solution_o, tvb,newoffset, 2, ENC_BIG_ENDIAN);
751 /* Solution I */
752 newoffset += 2;
753 proto_tree_add_item(t, hf_hip_tlv_solution_i, tvb, newoffset, (tlv_len - 4)/2, ENC_NA);
754 /* Solution J */
755 newoffset += (tlv_len - 4) /2;
756 proto_tree_add_item(t, hf_hip_tlv_solution_j, tvb, newoffset, (tlv_len -4)/2, ENC_NA);
757 break;
758 case PARAM_SEQ:
759 /* Update ID */
760 proto_tree_add_item(t, hf_hip_tlv_seq_updid, tvb, newoffset, 4, ENC_BIG_ENDIAN);
761 break;
762 case PARAM_ACK:
763 /* Can contain multiple Update IDs from peer */
764 while (tlv_len > 0) {
765 /* peer Update ID */
766 proto_tree_add_item(t, hf_hip_tlv_ack_updid, tvb, newoffset, 4, ENC_BIG_ENDIAN);
767 newoffset += 4;
768 tlv_len -= 4;
769 }
770 break;
771 case PARAM_DIFFIE_HELLMAN:
772 n = tvb_get_guint8(tvb, newoffset);
773 /* First Group ID*/
774 proto_tree_add_uint_format(t, hf_hip_tlv_dh_group_id, tvb, newoffset,
775 1, n, "%u (%s)", n,
776 val_to_str_const(n, dh_group_id_vals, "Unknown"));
777 /* First Public value len */
778 newoffset++;
779 pv_len = tvb_get_ntohs(tvb, newoffset);
780 proto_tree_add_item(t, hf_hip_tlv_dh_pv_length, tvb, newoffset, 2, ENC_BIG_ENDIAN);
781
782 /* First Public value */
783 newoffset += 2;
784 proto_tree_add_item(t, hf_hip_tlv_dh_pub, tvb, newoffset, pv_len, ENC_NA);
785 /* Check for the second group */
786 if ((pv_len + newoffset) < tlv_len) {
787 /* Second Group ID*/
788 newoffset += pv_len;
789 proto_tree_add_uint_format(t, hf_hip_tlv_dh_group_id, tvb, newoffset,
790 1, n, "%u (%s)", n,
791 val_to_str_const(n, dh_group_id_vals, "Unknown"));
792 /* Second Public value len */
793 newoffset += 1;
794 pv_len = tvb_get_ntohs(tvb, newoffset);
795 proto_tree_add_item(t, hf_hip_tlv_dh_pv_length, tvb, newoffset, 2, ENC_BIG_ENDIAN);
796 /* Second Public Value */
797 newoffset += 2;
798 proto_tree_add_item(t, hf_hip_tlv_dh_pub, tvb, newoffset,
799 pv_len, ENC_NA);
800 }
801 break;
802 case PARAM_ESP_TRANSFORM:
803 /* Reserved */
804 proto_tree_add_item(t, hf_hip_tlv_esp_reserved, tvb, newoffset, 2, ENC_BIG_ENDIAN);
805 newoffset +=2;
806 tlv_len -= 2;
807 while (tlv_len > 0) {
808 /* Suite # 1, 2, ..., n
809 * two bytes per transform id
810 */
811 trans = tvb_get_ntohs(tvb, newoffset);
812 proto_tree_add_uint_format(t, hf_hip_tlv_trans_id, tvb,
813 newoffset, 2, trans, "%u (%s)", trans,
814 val_to_str_const(trans, transform_id_vals, "Unknown"));
815 tlv_len -= 2;
816 newoffset += 2;
817 }
818 break;
819 case PARAM_HIP_TRANSFORM:
820 while (tlv_len > 0) {
821 /* Suite # 1, 2, ..., n
822 two bytes per transform id */
823 trans = tvb_get_ntohs(tvb, newoffset);
824 proto_tree_add_uint_format(t, hf_hip_tlv_trans_id, tvb,
825 newoffset, 2, trans, "%u (%s)", trans,
826 val_to_str_const(trans, transform_id_vals, "Unknown"));
827 tlv_len -= 2;
828 newoffset += 2;
829 }
830 break;
831 case PARAM_NAT_TRAVERSAL_MODE:
832 /* Reserved */
833 proto_tree_add_item(t, hf_hip_tlv_esp_reserved, tvb, newoffset, 2, ENC_BIG_ENDIAN);
834 newoffset += 2;
835 tlv_len -= 2;
836 while (tlv_len > 0) {
837 /* Suite # 1, 2, ..., n
838 two bytes per mode id */
839 trans = tvb_get_ntohs(tvb, newoffset);
840 proto_tree_add_uint_format(t, hf_hip_tlv_nat_traversal_mode_id, tvb,
841 newoffset, 2, trans, "%u (%s)", trans,
842 val_to_str_const(trans, mode_id_vals, "Unknown"));
843 tlv_len -= 2;
844 newoffset += 2;
845 }
846 break;
847 case PARAM_TRANSACTION_PACING:
848 /* Min Ta */
849 proto_tree_add_item(t, hf_hip_tlv_transaction_minta, tvb, newoffset, 4, ENC_BIG_ENDIAN);
850 break;
851 case PARAM_ENCRYPTED:
852 /* Reserved */
853 proto_tree_add_item(t, hf_hip_tlv_enc_reserved, tvb, newoffset, 4, ENC_BIG_ENDIAN);
854 newoffset += 4;
855 /* IV
856 * 16 bytes IV for AES CBC RFC 3602
857 * 8 bytes IV for 3DES CBC RFC 2405
858 * 0 bytes IV for NULL
859 * and
860 * encrypted data after that.
861 */
862 proto_tree_add_item(t, hf_hip_encrypted_parameter_data, tvb, newoffset, tlv_len - 4, ENC_NA);
863 break;
864 case PARAM_HIP_CIPHER:
865 while (tlv_len > 0) {
866 /* Suite # 1, 2, ..., n
867 two bytes per Cipher Suite id */
868 proto_tree_add_item(t, hf_hip_tlv_cipher_id, tvb, newoffset, 2, ENC_BIG_ENDIAN);
869 tlv_len -= 2;
870 newoffset += 2;
871 }
872 break;
873 case PARAM_HIT_SUITE_LIST:
874 while (tlv_len > 0) {
875 /* Suite # 1, 2, ..., n
876 one byte per HIT Suite id.
877 According to specification, HIT_SUITE_LIST is defined as eight-bit field,
878 current four-bit HIT Suite-IDs only use the four higher order bits in the ID Field.*/
879 proto_tree_add_item(t, hf_hip_tlv_hit_suite_id, tvb, newoffset, 1, ENC_BIG_ENDIAN);
880 tlv_len -= 1;
881 newoffset += 1;
882 }
883 break;
884 case PARAM_HOST_ID:
885 hi_len = tvb_get_ntohs(tvb, newoffset);
886 hi_len_item = proto_tree_add_item(t, hf_hip_tlv_host_id_len, tvb, newoffset, 2, ENC_BIG_ENDIAN);
887 newoffset += 2;
888 di_len = tvb_get_ntohs(tvb, newoffset);
889 di_type = (di_len >> 12) & 0x000F; /* get 4 bits for DI type */
890 di_len = di_len & 0x0FFF; /* 12 bits for DI length */
891 /* DI type */
892 proto_tree_add_item(t, hf_hip_tlv_host_di_type, tvb, newoffset, 1, ENC_BIG_ENDIAN);
893 /* DI len */
894 proto_tree_add_item(t, hf_hip_tlv_host_di_len, tvb, newoffset, 2, ENC_BIG_ENDIAN);
895 newoffset += 2;
896 /* hi_hdr - first 4 bytes are 0200ff03 (KEY RR in RFC 2535)
897 * flags 2 octets
898 * protocol 1 octet
899 * algorithm 1 octet (DSA or RSA)
900 * <public key>
901 */
902 hi_hdr = tvb_get_ntohl(tvb, newoffset);
903 ti_tlv = proto_tree_add_item(t, hf_hip_tlv_host_id_hdr,
904 tvb, newoffset, 4, ENC_BIG_ENDIAN);
905
906 ti_tlv = proto_item_add_subtree(ti_tlv, ett_hip_tlv_host_id_hdr);
907 /* HDR Flags*/
908 proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_flags, tvb,
909 newoffset, 2, hi_hdr);
910 newoffset += 2;
911 /* HDR Protocol */
912 proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_proto, tvb,
913 newoffset, 1, hi_hdr);
914 newoffset += 1;
915 /* HDR Algorithm */
916 algorithm = tvb_get_guint8(tvb, newoffset);
917 arg_item = proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_alg, tvb,
918 newoffset, 1, hi_hdr);
919
920 switch (algorithm) {
921 case HI_ALG_DSA:
922 /* DSA KEY RR RFC 2536
923 * T 1 octet
924 * Q 20 octets
925 * P 64 + T*8 octets
926 * G 64 + T*8 octets
927 * Y 64 + T*8 octets
928 */
929 newoffset++; /* 12 + offset */
930 /* T */
931 proto_tree_add_item(t, hf_hip_tlv_host_id_t, tvb, newoffset, 1, ENC_BIG_ENDIAN);
932 hi_t = tvb_get_guint8(tvb, newoffset);
933 newoffset++;
934 /* Q */
935 proto_tree_add_item(t, hf_hip_tlv_host_id_q, tvb, newoffset,
936 20, ENC_NA);
937 newoffset += 20;
938 if (hi_t > 56) /* max 4096 bits */
939 break;
940 /* P */
941 newlen = 64 + (hi_t * 8);
942 proto_tree_add_item(t, hf_hip_tlv_host_id_p, tvb, newoffset,
943 newlen, ENC_NA);
944 /* G */
945 newoffset += newlen;
946 proto_tree_add_item(t, hf_hip_tlv_host_id_g, tvb, newoffset,
947 newlen, ENC_NA);
948 /* Y */
949 newoffset += newlen;
950 proto_tree_add_item(t, hf_hip_tlv_host_id_y, tvb, newoffset,
951 newlen, ENC_NA);
952 break;
953 case HI_ALG_RSA:
954 /* RSA KEY RR RFC 3110
955 * e_len 1 or 3 octets
956 * e specified by e_len
957 * n variable length public modulus
958 */
959 newoffset++; /* 12 + offset */
960 /* E len */
961 e_len = tvb_get_guint8(tvb, newoffset);
962 e_len_item = proto_tree_add_item(t, hf_hip_tlv_host_id_e_len, tvb, newoffset,
963 (e_len > 255) ? 3 : 1, ENC_BIG_ENDIAN);
964 newoffset++;
965 hi_len -= 5; /* subtract RDATA + e_len */
966 if (e_len == 0) { /* e_len is 0 followed by 16-bit value */
967 e_len = tvb_get_ntohs(tvb, newoffset);
968 newoffset += 2;
969 hi_len -= 2;
970 }
971 if (e_len > 512) { /* per, RFC 3110 < 4096 bits */
972 expert_add_info(pinfo, e_len_item, &ei_hip_tlv_host_id_len);
973 break;
974 }
975 /* e */
976 proto_tree_add_item(t, hf_hip_tlv_host_id_e, tvb, newoffset,
977 e_len, ENC_NA);
978 newoffset += e_len;
979 hi_len -= e_len;
980
981 if (hi_len > 512) {
982 expert_add_info(pinfo, hi_len_item, &ei_hip_tlv_host_id_len);
983 break;
984 }
985
986 /* RSA public modulus n */
987 proto_tree_add_item(t, hf_hip_tlv_host_id_n, tvb, newoffset,
988 hi_len, ENC_NA);
989 break;
990 default:
991 expert_add_info(pinfo, arg_item, &ei_hip_tlv_host_id_hdr_alg);
992
993 break;
994 }
995 /* FQDN */
996 if (di_type == 0)
997 break;
998 if (di_type == 1) {
999 /* RFC 1035 */
1000 proto_tree_add_item(t, hf_hip_fqdn, tvb, offset+16+hi_len, di_len, ENC_ASCII|ENC_NA);
1001 } else if (di_type == 2) {
1002 /* RFC 4282 */
1003 proto_tree_add_item(t, hf_hip_nai, tvb, offset+16+hi_len, di_len, ENC_ASCII|ENC_NA);
1004 }
1005 break;
1006 case PARAM_CERT: /* CERT */
1007 /* Cert Group */
1008 proto_tree_add_item(t, hf_hip_tlv_cert_group, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1009 newoffset++;
1010 /* Cert Count */
1011 proto_tree_add_item(t, hf_hip_tlv_cert_count, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1012 newoffset++;
1013 /* Cert ID */
1014 proto_tree_add_item(t, hf_hip_tlv_cert_id, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1015 newoffset++;
1016 /* Cert Type */
1017 proto_tree_add_item(t, hf_hip_tlv_cert_type, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1018 newoffset++;
1019 /* Certificate */
1020 proto_tree_add_item(t, hf_hip_tlv_certificate, tvb, newoffset,
1021 tlv_len-4, ENC_NA);
1022 break;
1023 case PARAM_NOTIFICATION:
1024 /* Reserved */
1025 proto_tree_add_item(t, hf_hip_tlv_notification_res, tvb, newoffset, 2, ENC_BIG_ENDIAN);
1026 newoffset += 2;
1027 /* Notification Message Type */
1028 proto_tree_add_item(t, hf_hip_tlv_notification_type, tvb, newoffset, 2, ENC_BIG_ENDIAN);
1029 newoffset += 2;
1030 /* Notification Data */
1031 proto_tree_add_item(t, hf_hip_tlv_notification_data, tvb, newoffset,
1032 tlv_len-4, ENC_NA);
1033 break;
1034 case PARAM_ECHO_REQUEST_SIGNED:
1035 case PARAM_ECHO_RESPONSE_SIGNED:
1036 case PARAM_ECHO_REQUEST_UNSIGNED:
1037 case PARAM_ECHO_RESPONSE_UNSIGNED:
1038 /* Variable length Opaque Data */
1039 proto_tree_add_item(t, hf_hip_tlv_opaque_data, tvb, newoffset,
1040 tlv_len, ENC_NA);
1041 break;
1042 case PARAM_REG_INFO:
1043 case PARAM_REG_REQUEST:
1044 case PARAM_REG_RESPONSE:
1045 case PARAM_REG_FAILED:
1046 if (type == PARAM_REG_INFO) {
1047 /* Min Lifetime */
1048 proto_tree_add_item(t, hf_hip_tlv_reg_ltmin, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1049 newoffset++;
1050 /* Max Lifetime */
1051 proto_tree_add_item(t, hf_hip_tlv_reg_ltmax, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1052 newoffset++;
1053 tlv_len -= 2;
1054 } else if (type == PARAM_REG_FAILED) {
1055 /* Failure Type */
1056 proto_tree_add_item(t, hf_hip_tlv_reg_failtype, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1057 newoffset++;
1058 tlv_len--;
1059 } else {
1060 /* Lifetime */
1061 proto_tree_add_item(t, hf_hip_tlv_reg_lt, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1062 newoffset++;
1063 tlv_len--;
1064 }
1065 /* Reg Type 1 ... n, Padding */
1066 while (tlv_len > 0) {
1067 reg_type = tvb_get_guint8(tvb, newoffset);
1068 proto_tree_add_uint_format(t, hf_hip_tlv_reg_type, tvb,
1069 newoffset, 1, reg_type, "%u (%s)", reg_type,
1070 val_to_str_const(reg_type, reg_type_vals, "Unknown"));
1071 /* one byte per registration type */
1072 tlv_len--;
1073 newoffset++;
1074 }
1075 break;
1076 case PARAM_HMAC:
1077 case PARAM_HMAC_2:
1078 case PARAM_RVS_HMAC:
1079 case PARAM_RELAY_HMAC:
1080 /* HMAC */
1081 proto_tree_add_item(t, hf_hip_tlv_hmac, tvb, offset+4,
1082 tlv_len, ENC_NA);
1083 break;
1084 case PARAM_HIP_SIGNATURE:
1085 case PARAM_HIP_SIGNATURE_2:
1086 /* Signature algorithm */
1087 n = tvb_get_guint8(tvb, offset+4);
1088 proto_tree_add_uint_format(t, hf_hip_tlv_sig_alg, tvb, newoffset, 1,
1089 n, "%u (%s)", n,
1090 val_to_str_const(n, sig_alg_vals, "Unknown"));
1091 newoffset++;
1092 /* Signature */
1093 proto_tree_add_item(t, hf_hip_tlv_sig, tvb, newoffset, tlv_len-1,
1094 ENC_NA);
1095 break;
1096 case PARAM_FROM:
1097 /* Address */
1098 proto_tree_add_item(t, hf_hip_tlv_from_address, tvb, newoffset, 16, ENC_NA);
1099 break;
1100 case PARAM_VIA_RVS:
1101 /* RVS Addresses */
1102 while (tlv_len > 0) {
1103 proto_tree_add_item(t, hf_hip_tlv_rvs_address, tvb, newoffset, 16, ENC_NA);
1104 tlv_len -= 16;
1105 newoffset += 16;
1106 }
1107 break;
1108 case PARAM_RELAY_FROM:
1109 /* Port */
1110 proto_tree_add_item(t, hf_hip_tlv_relay_from_port, tvb, newoffset, 2, ENC_BIG_ENDIAN);
1111 newoffset += 2;
1112 /* Protocol */
1113 proto_tree_add_item(t, hf_hip_tlv_relay_from_protocol, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1114 newoffset += 1;
1115 /* Reserved */
1116 proto_tree_add_item(t, hf_hip_tlv_relay_from_reserved, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1117 newoffset += 1;
1118 /* Address */
1119 proto_tree_add_item(t, hf_hip_tlv_relay_from_address, tvb, newoffset, 16, ENC_NA);
1120 break;
1121 case PARAM_RELAY_TO:
1122 /* Port */
1123 proto_tree_add_item(t, hf_hip_tlv_relay_to_port, tvb, newoffset, 2, ENC_BIG_ENDIAN);
1124 newoffset += 2;
1125 /* Protocol */
1126 proto_tree_add_item(t, hf_hip_tlv_relay_to_protocol, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1127 newoffset += 1;
1128 /* Reserved */
1129 proto_tree_add_item(t, hf_hip_tlv_relay_to_reserved, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1130 newoffset += 1;
1131 /* Address */
1132 proto_tree_add_item(t, hf_hip_tlv_relay_to_address, tvb, newoffset, 16, ENC_NA);
1133 break;
1134 case PARAM_REG_FROM:
1135 /* Port */
1136 proto_tree_add_item(t, hf_hip_tlv_reg_from_port, tvb, newoffset, 2, ENC_BIG_ENDIAN);
1137 newoffset += 2;
1138 /* Protocol */
1139 proto_tree_add_item(t, hf_hip_tlv_reg_from_protocol, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1140 newoffset += 1;
1141 /* Reserved */
1142 proto_tree_add_item(t, hf_hip_tlv_reg_from_reserved, tvb, newoffset, 1, ENC_BIG_ENDIAN);
1143 newoffset += 1;
1144 /* Address */
1145 proto_tree_add_item(t, hf_hip_tlv_reg_from_address, tvb, newoffset, 16, ENC_NA);
1146 break;
1147 default:
1148 break;
1149 }
1150 return (0);
1151 }
1152
1153 void
proto_register_hip(void)1154 proto_register_hip(void)
1155 {
1156 static hf_register_info hf[] = {
1157 { &hf_hip_proto,
1158 { "Payload Protocol", "hip.proto",
1159 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1160
1161 { &hf_hip_hdr_len,
1162 { "Header Length", "hip.hdr_len",
1163 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1164
1165 { &hf_hip_packet_type,
1166 { "Packet Type", "hip.packet_type",
1167 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1168
1169 { &hf_hip_shim6_fixed_bit_p,
1170 { "Header fixed bit P", "hip.shim6_fixed_p",
1171 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1172
1173 { &hf_hip_version,
1174 { "Version", "hip.version",
1175 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1176
1177 { &hf_hip_shim6_fixed_bit_s,
1178 { "Header fixed bit S", "hip.shim6_fixed_s",
1179 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1180
1181 { &hf_hip_controls,
1182 { "HIP Controls", "hip.controls",
1183 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1184
1185 { &hf_hip_controls_anon,
1186 { "Anonymous (Sender's HI is anonymous)", "hip.controls.a",
1187 FT_BOOLEAN, 16, NULL, HIP_CONTROL_A_MASK, NULL, HFILL }},
1188
1189 { &hf_hip_checksum,
1190 { "Checksum", "hip.checksum",
1191 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1192
1193 { &hf_hip_checksum_status,
1194 { "Checksum Status", "hip.checksum.status",
1195 FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
1196
1197 { &hf_hip_hit_sndr,
1198 { "Sender's HIT", "hip.hit_sndr",
1199 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1200
1201 { &hf_hip_hit_rcvr,
1202 { "Receiver's HIT", "hip.hit_rcvr",
1203 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1204
1205 { &hf_hip_type,
1206 { "Type", "hip.type",
1207 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1208
1209 { &hf_hip_tlv_r1_res,
1210 { "Reserved", "hip.tlv.r1_reserved",
1211 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1212
1213 { &hf_hip_tlv_r1count,
1214 { "R1 Counter", "hip.tlv.r1_counter",
1215 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1216
1217 { &hf_hip_tlv_puzzle_k,
1218 { "Difficulty (K)", "hip.tlv_puzzle_k",
1219 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1220
1221 { &hf_hip_tlv_puzzle_life,
1222 { "Lifetime", "hip.tlv_puzzle_lifetime",
1223 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1224
1225 { &hf_hip_tlv_puzzle_o,
1226 { "Opaque Data", "hip.tlv_puzzle_opaque",
1227 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1228
1229 { &hf_hip_tlv_puzzle_i,
1230 { "Random number (I)", "hip.tlv.puzzle_random_i",
1231 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1232
1233 { &hf_hip_tlv_solution_k,
1234 { "Difficulty (K)", "hip.tlv_solution_k",
1235 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1236
1237 { &hf_hip_tlv_solution_reserved,
1238 { "Reserved", "hip.tlv_solution_reserved",
1239 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1240
1241 { &hf_hip_tlv_solution_o,
1242 { "Opaque Data", "hip.tlv_solution_opaque",
1243 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1244
1245 { &hf_hip_tlv_solution_i,
1246 { "Random number (I)", "hip.tlv.solution_random_i",
1247 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1248
1249 { &hf_hip_tlv_solution_j,
1250 { "Solution (J)", "hip.tlv_solution_j",
1251 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1252
1253 { &hf_hip_tlv_ei_res,
1254 { "Reserved", "hip.tlv_esp_info_reserved",
1255 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1256
1257 { &hf_hip_tlv_ei_keyidx,
1258 { "Keymaterial Index", "hip.tlv_esp_info_key_index",
1259 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1260
1261 { &hf_hip_tlv_ei_oldspi,
1262 { "Old SPI", "hip.tlv_esp_info_old_spi",
1263 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1264
1265 { &hf_hip_tlv_ei_newspi,
1266 { "New SPI", "hip.tlv_esp_info_new_spi",
1267 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1268
1269 { &hf_hip_tlv_seq_updid,
1270 { "Seq Update ID", "hip.tlv_seq_update_id",
1271 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1272
1273 { &hf_hip_tlv_ack_updid,
1274 { "ACKed Peer Update ID", "hip.tlv_ack_updid",
1275 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1276
1277 { &hf_hip_tlv_dh_group_id,
1278 { "Group ID", "hip.tlv.dh_group_id",
1279 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1280
1281 { &hf_hip_tlv_dh_pv_length,
1282 { "Public Value Length", "hip.tlv.dh_pv_length",
1283 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1284
1285 { &hf_hip_tlv_dh_pub,
1286 { "Public Value", "hip.tlv.dh_public_value",
1287 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1288
1289 { &hf_hip_tlv_trans_id,
1290 { "Transform ID", "hip.tlv.trans_id",
1291 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1292
1293 { &hf_hip_tlv_esp_reserved,
1294 { "Reserved", "hip.tlv.esp_trans_res",
1295 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1296
1297 { &hf_hip_tlv_cipher_id,
1298 { "Cipher ID", "hip.tlv.cipher_id",
1299 FT_UINT16, BASE_DEC, VALS(cipher_vals), 0x0, NULL, HFILL }},
1300
1301 { &hf_hip_tlv_hit_suite_id,
1302 { "HIT Suite ID", "hip.tlv.hit_suite_id",
1303 FT_UINT8, BASE_DEC, VALS(hit_suite_vals), 0xF0, NULL, HFILL }},
1304
1305 { &hf_hip_tlv_host_id_len,
1306 { "Host Identity Length", "hip.tlv.host_id_length",
1307 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1308
1309 { &hf_hip_tlv_host_di_type,
1310 { "Domain Identifier Type", "hip.tlv.host_domain_id_type",
1311 FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL }},
1312
1313 { &hf_hip_tlv_host_di_len,
1314 { "Domain Identifier Length", "hip.tlv.host_domain_id_length",
1315 FT_UINT16, BASE_DEC, NULL, 0x0FFF, NULL, HFILL }},
1316
1317 { &hf_hip_tlv_host_id_hdr,
1318 { "Host Identity flags", "hip.tlv.host_id_hdr",
1319 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1320
1321 { &hf_hip_tlv_host_id_hdr_flags,
1322 { "Host Identity Header Flags", "hip.tlv.host_id_header_flags",
1323 FT_UINT32, BASE_HEX, VALS(hi_hdr_flags_vals),
1324 HI_HDR_FLAGS_MASK, NULL, HFILL }},
1325
1326 { &hf_hip_tlv_host_id_hdr_proto,
1327 { "Host Identity Header Protocol", "hip.tlv.host_id_header_proto",
1328 FT_UINT32, BASE_HEX, VALS(hi_hdr_proto_vals),
1329 HI_HDR_PROTO_MASK, NULL, HFILL }},
1330
1331 { &hf_hip_tlv_host_id_hdr_alg,
1332 { "Host Identity Header Algorithm", "hip.tlv.host_id_header_algo",
1333 FT_UINT32, BASE_HEX, VALS(hi_hdr_alg_vals),
1334 HI_HDR_ALG_MASK, NULL, HFILL }},
1335
1336 { &hf_hip_tlv_host_id_t,
1337 { "Host Identity T", "hip.tlv.host_identity_t",
1338 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1339
1340 { &hf_hip_tlv_host_id_q,
1341 { "Host Identity Q", "hip.tlv.host_identity_q",
1342 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1343
1344 { &hf_hip_tlv_host_id_p,
1345 { "Host Identity P", "hip.tlv.host_id_p",
1346 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1347
1348 { &hf_hip_tlv_host_id_g,
1349 { "Host Identity G", "hip.tlv.host_id_g",
1350 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1351
1352 { &hf_hip_tlv_host_id_y,
1353 { "Host Identity Y (public value)", "hip.tlv.host_id_y",
1354 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1355
1356 { &hf_hip_tlv_host_id_e_len,
1357 { "RSA Host Identity exponent length (e_len)", "hip.tlv.host_id_e_length",
1358 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1359
1360 { &hf_hip_tlv_host_id_e,
1361 { "RSA Host Identity exponent (e)", "hip.tlv.host_id_e",
1362 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1363
1364 { &hf_hip_tlv_host_id_n,
1365 { "RSA Host Identity public modulus (n)", "hip.tlv.host_id_n",
1366 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1367
1368 { &hf_hip_tlv_notification_res,
1369 { "Notification Reserved", "hip.tlv.notification_res",
1370 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1371
1372 { &hf_hip_tlv_notification_type,
1373 { "Notification Message Type", "hip.tlv.notification_type",
1374 FT_UINT16, BASE_DEC, VALS(notification_vals), 0xFFFF, NULL, HFILL }},
1375
1376 { &hf_hip_tlv_notification_data,
1377 { "Notification Data", "hip.tlv.notification_data",
1378 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1379
1380 { &hf_hip_tlv_opaque_data,
1381 { "Opaque Data", "hip.tlv.opaque_data",
1382 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1383
1384 { &hf_hip_tlv_reg_ltmin,
1385 { "Minimum Registration Lifetime", "hip.tlv.reg_ltmin",
1386 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1387
1388 { &hf_hip_tlv_reg_ltmax,
1389 { "Maximum Registration Lifetime", "hip.tlv.reg_ltmax",
1390 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1391
1392 { &hf_hip_tlv_reg_lt,
1393 { "Registration Lifetime", "hip.tlv.reg_lt",
1394 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1395
1396 { &hf_hip_tlv_reg_type,
1397 { "Registration Type", "hip.tlv.reg_type",
1398 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1399
1400 { &hf_hip_tlv_reg_failtype,
1401 { "Registration Failure Type", "hip.tlv.reg_failtype",
1402 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1403
1404 { &hf_hip_tlv_hmac,
1405 { "HMAC", "hip.tlv.hmac",
1406 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1407
1408 { &hf_hip_tlv_sig_alg,
1409 { "Signature Algorithm", "hip.tlv.sig_alg",
1410 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1411
1412 { &hf_hip_tlv_sig,
1413 { "Signature", "hip.tlv.sig",
1414 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1415
1416 { &hf_hip_tlv_enc_reserved,
1417 { "Reserved", "hip.tlv.enc_reserved",
1418 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1419
1420 { &hf_hip_tlv_locator_traffic_type,
1421 { "Traffic Type", "hip.tlv.locator_traffic_type",
1422 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1423
1424 { &hf_hip_tlv_locator_type,
1425 { "Locator Type", "hip.tlv.locator_type",
1426 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1427
1428 { &hf_hip_tlv_locator_len,
1429 { "Locator Length", "hip.tlv.locator_len",
1430 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1431
1432 { &hf_hip_tlv_locator_reserved,
1433 { "Reserved", "hip.tlv.locator_reserved",
1434 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1435
1436 { &hf_hip_tlv_locator_lifetime,
1437 { "Locator Lifetime", "hip.tlv.locator_lifetime",
1438 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1439
1440 { &hf_hip_tlv_locator_port,
1441 { "Locator port", "hip.tlv.locator_port",
1442 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1443
1444 { &hf_hip_tlv_locator_transport_protocol,
1445 { "Locator transport protocol", "hip.tlv.locator_transport_protocol",
1446 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1447
1448 { &hf_hip_tlv_locator_kind,
1449 { "Locator kind", "hip.tlv.locator_kind",
1450 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1451
1452 { &hf_hip_tlv_locator_priority,
1453 { "Locator priority", "hip.tlv.locator_priority",
1454 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1455
1456 { &hf_hip_tlv_locator_spi,
1457 { "Locator SPI", "hip.tlv.locator_spi",
1458 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1459
1460 { &hf_hip_tlv_locator_address,
1461 { "Locator" , "hip.tlv.locator_address",
1462 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1463
1464 { &hf_hip_tlv_cert_group,
1465 { "Cert group", "hip.tlv.cert_group",
1466 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1467
1468 { &hf_hip_tlv_cert_count,
1469 { "Cert count", "hip.tlv.cert_count",
1470 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1471
1472 { &hf_hip_tlv_cert_id,
1473 { "Cert ID", "hip.tlv.cert_id",
1474 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1475
1476 { &hf_hip_tlv_cert_type,
1477 { "Cert type", "hip.tlv.cert_type",
1478 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1479
1480 { &hf_hip_tlv_certificate,
1481 { "Certificate", "hip.tlv.certificate",
1482 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1483
1484 { &hf_hip_tlv_nat_traversal_mode_id,
1485 { "NAT Traversal Mode ID", "hip.tlv.nat_traversal_mode_id",
1486 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1487
1488 { &hf_hip_tlv_relay_from_port,
1489 { "Relay From Port", "hip.tlv.relay_from_port",
1490 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1491
1492 { &hf_hip_tlv_relay_to_port,
1493 { "Relay To Port", "hip.tlv.relay_to_port",
1494 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1495
1496 { &hf_hip_tlv_reg_from_port,
1497 { "Port", "hip.tlv.reg_from_port",
1498 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1499
1500 { &hf_hip_tlv_transaction_minta,
1501 { "Min Ta" , "hip.tlv_transaction_minta",
1502 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1503
1504 { &hf_hip_tlv_from_address,
1505 { "Address" , "hip.tlv_from_address",
1506 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1507
1508 { &hf_hip_tlv_rvs_address,
1509 { "RVS Address" , "hip.tlv_rvs_address",
1510 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1511
1512 { &hf_hip_tlv_relay_from_protocol,
1513 { "Protocol" , "hip.tlv_relay_from_protocol",
1514 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1515
1516 { &hf_hip_tlv_relay_from_reserved,
1517 { "Reserved" , "hip.tlv_relay_from_reserved",
1518 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1519
1520 { &hf_hip_tlv_relay_from_address,
1521 { "Address" , "hip.tlv_relay_from_address",
1522 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1523
1524 { &hf_hip_tlv_relay_to_protocol,
1525 { "Protocol" , "hip.tlv_relay_to_protocol",
1526 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1527
1528 { &hf_hip_tlv_relay_to_reserved,
1529 { "Reserved" , "hip.tlv_relay_to_reserved",
1530 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1531
1532 { &hf_hip_tlv_relay_to_address,
1533 { "Address" , "hip.tlv_relay_to_address",
1534 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1535
1536 { &hf_hip_tlv_reg_from_protocol,
1537 { "Protocol" , "hip.tlv_reg_from_protocol",
1538 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1539
1540 { &hf_hip_tlv_reg_from_reserved,
1541 { "Reserved" , "hip.tlv_reg_from_reserved",
1542 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1543
1544 { &hf_hip_tlv_reg_from_address,
1545 { "Address" , "hip.tlv_reg_from_address",
1546 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1547
1548 { &hf_hip_encrypted_parameter_data,
1549 { "Encrypted Parameter Data" , "hip.encrypted_parameter_data",
1550 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1551
1552 { &hf_hip_fqdn,
1553 { "FQDN" , "hip.fqdn",
1554 FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1555
1556 { &hf_hip_nai,
1557 { "NAI" , "hip.nai",
1558 FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1559
1560 };
1561
1562 static gint *ett[] = {
1563 &ett_hip,
1564 &ett_hip_controls,
1565 &ett_hip_tlv,
1566 &ett_hip_tlv_data,
1567 &ett_hip_tlv_host_id_hdr,
1568 &ett_hip_locator_data,
1569 };
1570
1571 static ei_register_info ei[] = {
1572 { &ei_hip_tlv_host_id_len, { "hip.tlv.host_id_length.invalid", PI_PROTOCOL, PI_WARN, "Invalid HI length", EXPFILL }},
1573 #if 0
1574 { &ei_hip_tlv_host_id_e_len, { "hip.tlv.host_id_e_length.invalid", PI_PROTOCOL, PI_WARN, "e_len too large", EXPFILL }},
1575 #endif
1576 { &ei_hip_tlv_host_id_hdr_alg, { "hip.tlv.host_id_header_algo.invalid", PI_PROTOCOL, PI_WARN, "Unknown algorithm type", EXPFILL }},
1577 { &ei_hip_checksum, { "hip.bad_checksum", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
1578 };
1579
1580 expert_module_t* expert_hip;
1581
1582 proto_hip = proto_register_protocol("Host Identity Protocol", "HIP", "hip");
1583
1584 proto_register_field_array(proto_hip, hf, array_length(hf));
1585 proto_register_subtree_array(ett, array_length(ett));
1586 expert_hip = expert_register_protocol(proto_hip);
1587 expert_register_field_array(expert_hip, ei, array_length(ei));
1588 }
1589
1590 void
proto_reg_handoff_hip(void)1591 proto_reg_handoff_hip(void)
1592 {
1593 dissector_handle_t hip_handle;
1594 dissector_handle_t hip_handle2;
1595
1596 hip_handle = create_dissector_handle(dissect_hip, proto_hip);
1597 dissector_add_uint("ip.proto", IP_PROTO_HIP, hip_handle);
1598
1599 hip_handle2 = create_dissector_handle(dissect_hip_in_udp, proto_hip);
1600 dissector_add_uint_with_preference("udp.port", HIP_UDP_PORT, hip_handle2);
1601 }
1602 /*
1603 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1604 *
1605 * Local variables:
1606 * c-basic-offset: 8
1607 * tab-width: 8
1608 * indent-tabs-mode: nil
1609 * End:
1610 *
1611 * vi: set shiftwidth=8 tabstop=8 expandtab:
1612 * :indentSize=8:tabSize=8:noTabs=true:
1613 */
1614