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