]> git.pld-linux.org Git - packages/wireshark.git/blame - wireshark-0.99.5-hip-base05.patch
- better patch
[packages/wireshark.git] / wireshark-0.99.5-hip-base05.patch
CommitLineData
6da1db33
AG
1diff -burN wireshark-0.99.6.orig/epan/dissectors/Makefile.common wireshark-0.99.6/epan/dissectors/Makefile.common
2--- wireshark-0.99.6.orig/epan/dissectors/Makefile.common 2007-08-21 09:41:51.249801823 +0200
3+++ wireshark-0.99.6/epan/dissectors/Makefile.common 2007-08-21 09:42:11.955168892 +0200
4@@ -327,6 +327,7 @@
5 packet-dis-fields.c \
6 packet-dis-pdus.c \
7 packet-diffserv-mpls-common.c \
8+ packet-hip.c \
9 packet-distcc.c \
10 packet-dlsw.c \
11 packet-dmp.c \
12diff -burN wireshark-0.99.6.orig/epan/dissectors/Makefile.in wireshark-0.99.6/epan/dissectors/Makefile.in
13--- wireshark-0.99.6.orig/epan/dissectors/Makefile.in 2007-08-21 09:41:51.249801823 +0200
14+++ wireshark-0.99.6/epan/dissectors/Makefile.in 2007-08-21 09:42:56.306096587 +0200
15@@ -392,6 +392,7 @@
16 libcleandissectors_la-packet-hci_h4.lo \
17 libcleandissectors_la-packet-hclnfsd.lo \
18 libcleandissectors_la-packet-homeplug.lo \
19+ libcleandissectors_la-packet-hip.lo \
20 libcleandissectors_la-packet-hpext.lo \
21 libcleandissectors_la-packet-hpsw.lo \
22 libcleandissectors_la-packet-hsrp.lo \
23@@ -858,6 +859,7 @@
24 INSTALL_DATA = @INSTALL_DATA@
25 INSTALL_PROGRAM = @INSTALL_PROGRAM@
26 INSTALL_SCRIPT = @INSTALL_SCRIPT@
27+ packet-hip.c \
28 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
29 KRB5_CONFIG = @KRB5_CONFIG@
30 KRB5_LIBS = @KRB5_LIBS@
31@@ -1848,6 +1850,7 @@
32 packet-frame.h \
33 packet-ftam.h \
34 packet-ftbp.h \
35+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packet-hip.Plo@am__quote@
36 packet-giop.h \
37 packet-gnm.h \
38 packet-gnutella.h \
39diff -burN wireshark-0.99.6.orig/epan/dissectors/packet-hip.c wireshark-0.99.6/epan/dissectors/packet-hip.c
40--- wireshark-0.99.6.orig/epan/dissectors/packet-hip.c 1970-01-01 01:00:00.000000000 +0100
41+++ wireshark-0.99.6/epan/dissectors/packet-hip.c 2007-08-21 09:42:11.959169156 +0200
42@@ -0,0 +1,1235 @@
43+/* packet-hip.c
44+ * Routines for HIP packet disassembly
45+ *
46+ * 03/2006 draft-ietf-hip-base-05, -esp-02, -mm-03, -registration-01, -rvs-04
47+ * 07/2005 draft-ietf-hip-base-03, -esp-00, and -mm-02
48+ * 03/2005 draft-ietf-hip-base-01
49+ * 11/2004 RSA and draft-ietf-hip-mm-00
50+ * 09/2004 draft-nikander-hip-mm-02
51+ * 07/2004 draft-ietf-hip-base-00
52+ * 02/2004
53+ * 03/2003
54+ *
55+ * Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
56+ * Thomas Henderson <thomas.r.henderson@boeing.com>
57+ *
58+ * Packet dissector for Host Identity Protocol (HIP) packets.
59+ * This tool displays the TLV structure, verifies checksums,
60+ * and shows NULL encrypted parameters, but will not verify
61+ * signatures or decode encrypted parameters.
62+ *
63+ * $Id$
64+ *
65+ * Ethereal - Network traffic analyzer
66+ * By Gerald Combs <gerald@ethereal.com>
67+ * Copyright 1998 Gerald Combs
68+ *
69+ * This program is free software; you can redistribute it and/or
70+ * modify it under the terms of the GNU General Public License
71+ * as published by the Free Software Foundation; either version 2
72+ * of the License, or (at your option) any later version.
73+ *
74+ * This program is distributed in the hope that it will be useful,
75+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
76+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
77+ * GNU General Public License for more details.
78+ *
79+ * You should have received a copy of the GNU General Public License
80+ * along with this program; if not, write to the Free Software
81+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
82+ */
85ee19fb 83+
6da1db33
AG
84+#ifdef HAVE_CONFIG_H
85+# include "config.h"
86+#endif
87+
88+#include <stdio.h>
89+#include <stdlib.h>
90+#include <string.h>
91+
92+#include <glib.h>
93+#include <epan/packet.h>
94+#include <epan/addr_resolv.h>
95+#include "ipproto.h"
96+#include "in_cksum.h"
97+#include "prefs.h"
98+
99+
100+#include "packet-ip.h"
101+#include <epan/conversation.h>
102+
103+static int proto_hip = -1;
104+static int hf_hip_proto = -1;
105+static int hf_hip_hdr_len = -1;
106+static int hf_hip_packet_type = -1;
107+static int hf_hip_version = -1;
108+static int hf_hip_res = -1;
109+static int hf_hip_controls = -1;
110+static int hf_hip_controls_cert = -1;
111+static int hf_hip_controls_anon = -1;
112+static int hf_hip_checksum = -1;
113+static int hf_hip_hit_sndr = -1;
114+static int hf_hip_hit_rcvr = -1;
115+
116+static int hf_hip_type = -1;
117+static int hf_hip_tlv_ei_res = -1;
118+static int hf_hip_tlv_ei_keyidx = -1;
119+static int hf_hip_tlv_ei_oldspi = -1;
120+static int hf_hip_tlv_ei_newspi = -1;
121+static int hf_hip_tlv_r1_res = -1;
122+static int hf_hip_tlv_r1count = -1;
123+static int hf_hip_tlv_puzzle_k = -1;
124+static int hf_hip_tlv_puzzle_life = -1;
125+static int hf_hip_tlv_puzzle_o = -1;
126+static int hf_hip_tlv_puzzle_i = -1;
127+static int hf_hip_tlv_puzzle_j = -1;
128+static int hf_hip_tlv_seq_updid = -1;
129+static int hf_hip_tlv_ack_updid = -1;
130+static int hf_hip_tlv_dh_group_id = -1;
131+static int hf_hip_tlv_dh_pub = -1;
132+static int hf_hip_tlv_trans_id = -1;
133+static int hf_hip_tlv_esp_reserved = -1;
134+static int hf_hip_tlv_host_id_len = -1;
135+static int hf_hip_tlv_host_di_type = -1;
136+static int hf_hip_tlv_host_di_len = -1;
137+static int hf_hip_tlv_host_id_hdr = -1;
138+static int hf_hip_tlv_host_id_hdr_flags = -1;
139+static int hf_hip_tlv_host_id_hdr_proto = -1;
140+static int hf_hip_tlv_host_id_hdr_alg = -1;
141+static int hf_hip_tlv_host_id_t = -1;
142+static int hf_hip_tlv_host_id_q = -1;
143+static int hf_hip_tlv_host_id_p = -1;
144+static int hf_hip_tlv_host_id_g = -1;
145+static int hf_hip_tlv_host_id_y = -1;
146+static int hf_hip_tlv_host_id_e_len = -1;
147+static int hf_hip_tlv_host_id_e = -1;
148+static int hf_hip_tlv_host_id_n = -1;
149+static int hf_hip_tlv_cert_count = -1;
150+static int hf_hip_tlv_cert_id = -1;
151+static int hf_hip_tlv_cert_type = -1;
152+static int hf_hip_tlv_certificate = -1;
153+static int hf_hip_tlv_notify_res = -1;
154+static int hf_hip_tlv_notify_type = -1;
155+static int hf_hip_tlv_notify_data = -1;
156+static int hf_hip_tlv_opaque_data = -1;
157+static int hf_hip_tlv_reg_ltmin = -1;
158+static int hf_hip_tlv_reg_ltmax = -1;
159+static int hf_hip_tlv_reg_lt = -1;
160+static int hf_hip_tlv_reg_type = -1;
161+static int hf_hip_tlv_reg_failtype = -1;
162+static int hf_hip_tlv_hmac = -1;
163+static int hf_hip_tlv_sig_alg = -1;
164+static int hf_hip_tlv_sig = -1;
165+static int hf_hip_tlv_id = -1;
166+static int hf_hip_tlv_enc_reserved = -1;
167+static int hf_hip_tlv_enc_iv = -1;
168+static int hf_hip_tlv_locator_traffic_type = -1;
169+static int hf_hip_tlv_locator_type = -1;
170+static int hf_hip_tlv_locator_len = -1;
171+static int hf_hip_tlv_locator_reserved = -1;
172+static int hf_hip_tlv_locator_lifetime = -1;
173+static int hip_transform = 0;
174+
175+static gint ett_hip = -1;
176+static gint ett_hip_controls = -1;
177+static gint ett_hip_tlv = -1;
178+static gint ett_hip_tlv_data = -1;
179+static gint ett_hip_tlv_host_id_hdr = -1;
180+
181+/* Place HIP summary in protocol tree */
182+static gboolean hip_summary_in_tree = TRUE;
183+
184+/* This minimal structure used to get at the Type field*/
185+struct newhip {
186+ guint16 nextpluslen; /* Next header, plus length */
187+ guint8 hiptype; /* Type (what we are after) */
188+ guint8 hipreserved; /* Reserved (what we are after) */
189+ /*variable size*/ /* (IV and) Payload data */
190+};
191+
192+/* 128-bit Host Identity Tag */
193+#define HIT_BITSIZE 128
194+typedef unsigned char hip_hit [HIT_BITSIZE/8];
195+
196+#define HI_ALG_DSA 3
197+#define HI_ALG_RSA 5
198+
199+/* HIP packet types */
200+typedef enum {
201+ HIP_I1=1,
202+ HIP_R1,
203+ HIP_I2,
204+ HIP_R2,
205+ CER, /* 5 - removed from draft-ietf-hip-base-03 */
206+ BOS=11, /* 11 - removed from draft-ietf-hip-base-01 */
207+ UPDATE=16, /* 16 */
208+ NOTIFY=17, /* 17 */
209+ CLOSE=18, /* 18 */
210+ CLOSE_ACK=19, /* 19 */
211+} HIP_PACKETS;
212+
213+/* HIP TLV parameters */
214+/* 03/2006 draft-ietf-hip-base-05, -esp-02, -mm-03, -registration-01, -rvs-04 */
215+#define PARAM_ESP_INFO 65
216+#define PARAM_R1_COUNTER 128
217+#define PARAM_LOCATOR 193
218+#define PARAM_PUZZLE 257
219+#define PARAM_SOLUTION 321
220+#define PARAM_SEQ 385
221+#define PARAM_ACK 449
222+#define PARAM_DIFFIE_HELLMAN 513
223+#define PARAM_HIP_TRANSFORM 577
224+#define PARAM_ENCRYPTED 641
225+#define PARAM_HOST_ID 705
226+#define PARAM_CERT 768
227+#define PARAM_NOTIFY 832
228+#define PARAM_ECHO_REQUEST 897
229+#define PARAM_REG_INFO 930
230+#define PARAM_REG_REQUEST 932
231+#define PARAM_REG_RESPONSE 934
232+#define PARAM_REG_FAILED 936
233+#define PARAM_ECHO_RESPONSE 961
234+#define PARAM_ESP_TRANSFORM 4095
235+#define PARAM_TRANSFORM_LOW 2048 /* defines range for transforms */
236+#define PARAM_TRANSFORM_HIGH 4095
237+#define PARAM_HMAC 61505
238+#define PARAM_HMAC_2 61569
239+#define PARAM_HIP_SIGNATURE_2 61633
240+#define PARAM_HIP_SIGNATURE 61697
241+#define PARAM_ECHO_REQUEST_NOSIG 63661
242+#define PARAM_ECHO_RESPONSE_NOSIG 63425
243+#define PARAM_FROM 65498
244+#define PARAM_RVS_HMAC 65500
245+#define PARAM_VIA_RVS 65502
246+#define PARAM_CRITICAL_BIT 0x0001
247+
248+#define HIP_CONTROL_C_MASK 0x0002
249+#define HIP_CONTROL_A_MASK 0x0001
250+
251+#define HI_HDR_FLAGS_MASK 0xFFFF0000
252+#define HI_HDR_PROTO_MASK 0x0000FF00
253+#define HI_HDR_ALG_MASK 0x000000FF
254+
255+const value_string hi_hdr_flags_vals[] = {
256+ { 0x0200, "key is associated with a user" },
257+ { 0x0201, "zone key" },
258+ { 0x0202, "key is associated with non-zone entity" },
259+ { 0x0, "Other" },
260+};
261+
262+const value_string hi_hdr_proto_vals[] = {
263+ { 0x01, "key is used for TLS" },
264+ { 0x02, "key is used for email" },
265+ { 0x03, "key is used for DNS security" },
266+ { 0x04, "key is used for Oakley/IPSEC" },
267+ { 0xFF, "key is valid for any protocol" },
268+ { 0x0, NULL },
269+};
270+
271+const value_string hi_hdr_alg_vals[] = {
272+ { 0x00, "reserved" },
273+ { 0x01, "RSA/MD5" },
274+ { 0x02, "Diffie-Hellman" },
275+ { 0x03, "DSA" },
276+ { 0x04, "elliptic curve crypto" },
277+ { 0x05, "RSA" },
278+ { 0xFF, "reserved" },
279+};
280+
281+const value_string notify_vals[] = {
282+ { 1, "Unsupported critical parameter type" },
283+ { 7, "Invalid syntax" },
284+ { 14, "No Diffie-Hellman proposal chosen" },
285+ { 15, "Invalid Diffie-Hellman chosen" },
286+ { 16, "No HIP proposal chosen" },
287+ { 17, "Invalid HIP transform chosen" },
288+ { 18, "No ESP proposal chosen" },
289+ { 19, "Invalid ESP transform chosen" },
290+ { 24, "Authentication failed" },
291+ { 26, "Checksum failed" },
292+ { 28, "HMAC failed" },
293+ { 32, "Encryption failed" },
294+ { 40, "Invalid HIT" },
295+ { 42, "Blocked by policy" },
296+ { 44, "Server busy please retry" },
297+ { 46, "I2 acknowledgement" },
298+ { 0x0, NULL },
299+};
300+
301+typedef struct _hiphdr {
302+ guint8 proto; /* payload protocol */
303+ guint8 hdr_len; /* header length */
304+ guint8 packet_type; /* packet type */
305+ guint8 res:4,version:4; /* version, reserved */
306+ guint16 checksum; /* checksum */
307+ guint16 control; /* control */
308+ hip_hit hit_sndr; /* Sender's Host Identity Tag */
309+ hip_hit hit_rcvr; /* Receiver's Host Identity Tag*/
310+ /* HIP parameters ... */
311+} hiphdr;
312+
313+typedef struct _tlv_head
314+{
315+ guint16 type;
316+ guint16 length;
317+} tlv_head;
318+
319+
320+/* functions */
321+char * hip_param(int n);
322+char *dh_group_id_label(int groupid);
323+char *transform_id_label(int transform);
324+char *sig_alg_label(int alg);
325+int dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len);
326+
327+static dissector_handle_t data_handle;
328+
329+/**** end defs from hip.h ****/
330+
331+/*
332+ * Dissect the HIP packet
333+ */
334+static void
335+dissect_hip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
336+{
337+ proto_tree *hip_tree, *hip_tlv_tree=NULL;
338+ proto_item *ti, *ti_tlv;
339+ hiphdr hiph;
340+ tlv_head tlv;
341+ int length, offset = 0;
342+ guint16 control_h, checksum_h, computed_checksum;
343+ guint16 tlv_type_h, tlv_length_h; /* For storing in host order */
344+ vec_t cksum_vec[4];
345+ guint32 phdr[2];
346+
347+ /*
348+ * load the top pane info. This should be overwritten by
349+ * the next protocol in the stack
350+ */
351+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
352+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "HIP");
353+ if (check_col(pinfo->cinfo, COL_INFO))
354+ col_clear(pinfo->cinfo, COL_INFO);
355+
356+ /* Convert control and checksum to host order */
357+
358+ tvb_memcpy(tvb, (guint8 *)&hiph, 0, sizeof(hiphdr));
359+ control_h = g_ntohs(hiph.control);
360+ checksum_h = g_ntohs(hiph.checksum);
361+
362+ if (check_col(pinfo->cinfo, COL_INFO)) {
363+ switch (hiph.packet_type) {
364+ case HIP_I1:
365+ col_add_fstr(pinfo->cinfo, COL_INFO,
366+ "HIP I1 (HIP Initiator Packet)");
367+ break;
368+ case HIP_R1:
369+ col_add_fstr(pinfo->cinfo, COL_INFO,
370+ "HIP R1 (HIP Responder Packet)");
371+ break;
372+ case HIP_I2:
373+ col_add_fstr(pinfo->cinfo, COL_INFO,
374+ "HIP I2 (Second HIP Initiator Packet)");
375+ break;
376+ case HIP_R2:
377+ col_add_fstr(pinfo->cinfo, COL_INFO,
378+ "HIP R2 (Second HIP Responder Packet)");
379+ break;
380+ case UPDATE:
381+ col_add_fstr(pinfo->cinfo, COL_INFO,
382+ "HIP UPDATE (HIP Update Packet)");
383+ break;
384+ case CER:
385+ col_add_fstr(pinfo->cinfo, COL_INFO,
386+ "HIP CER (HIP Certificate Packet)");
387+ break;
388+ case BOS:
389+ col_add_fstr(pinfo->cinfo, COL_INFO,
390+ "HIP BOS (HIP Bootstrap Packet)");
391+ break;
392+ case NOTIFY:
393+ col_add_fstr(pinfo->cinfo, COL_INFO,
394+ "HIP NOTIFY (HIP Notification Packet)");
395+ break;
396+ case CLOSE:
397+ col_add_fstr(pinfo->cinfo, COL_INFO,
398+ "HIP CLOSE (HIP Close Packet)");
399+ break;
400+ case CLOSE_ACK:
401+ col_add_fstr(pinfo->cinfo, COL_INFO,
402+ "HIP CLOSE_ACK (HIP Close Acknowledgement Packet)");
403+ break;
404+ default:
405+ col_add_fstr(pinfo->cinfo, COL_INFO, "HIP Unknown type");
406+ break;
407+ }
408+ }
409+
410+ /*
411+ * populate a tree in the second pane with the status of the link layer
412+ * (ie none)
413+ */
414+ if(tree) {
415+ if (hip_summary_in_tree) {
416+ ti = proto_tree_add_protocol_format(tree, proto_hip, tvb, 0, -1, "Host Identity Protocol");
417+ } else {
418+ ti = proto_tree_add_item(tree, proto_hip, tvb, 0, -1, FALSE);
419+ }
420+
421+ hip_tree = proto_item_add_subtree(ti, ett_hip);
422+ proto_tree_add_uint(hip_tree, hf_hip_proto, tvb, offset, 1, hiph.proto);
423+ proto_tree_add_uint(hip_tree, hf_hip_hdr_len, tvb, offset+1, 1, hiph.hdr_len);
424+ proto_tree_add_uint(hip_tree, hf_hip_packet_type, tvb, offset+2, 1, hiph.packet_type);
425+ proto_tree_add_uint_format(hip_tree, hf_hip_version, tvb, offset+3, 1, hiph.version,
426+ "Version: %u, Reserved: %u", hiph.version, hiph.res);
427+ ti = proto_tree_add_uint(hip_tree, hf_hip_controls, tvb, offset+4, 2, control_h);
428+ if (ti) { /* HIP Controls subtree*/
429+ ti = proto_item_add_subtree(ti, ett_hip_controls);
430+ proto_tree_add_boolean(ti, hf_hip_controls_cert, tvb, offset+5,1, control_h);
431+ proto_tree_add_boolean(ti, hf_hip_controls_anon, tvb, offset+5,1, control_h);
432+ }
433+
434+
435+ /* Checksum - this is the same algorithm from UDP, ICMPv6 */
436+ if (!pinfo->fragmented) {
437+ /* IPv4 or IPv6 addresses */
438+ cksum_vec[0].ptr = pinfo->src.data;
439+ cksum_vec[0].len = pinfo->src.len;
440+ cksum_vec[1].ptr = pinfo->dst.data;
441+ cksum_vec[1].len = pinfo->dst.len;
442+ /* the rest of the pseudo-header */
443+ if (pinfo->src.type == AT_IPv6) {
444+ cksum_vec[2].ptr = (const guint8 *)&phdr;
445+ phdr[0] = g_htonl(tvb_reported_length(tvb));
446+ phdr[1] = g_htonl(IP_PROTO_HIP);
447+ cksum_vec[2].len = 8;
448+ } else {
449+ cksum_vec[2].ptr = (const guint8 *)&phdr;
450+ phdr[0] = g_htonl((IP_PROTO_HIP<<16)+tvb_reported_length(tvb));
451+ cksum_vec[2].len = 4;
452+ }
453+ /* pointer to the HIP header (packet data) */
454+ cksum_vec[3].len = tvb_reported_length(tvb);
455+ cksum_vec[3].ptr = tvb_get_ptr(tvb, 0, cksum_vec[3].len);
456+ computed_checksum = in_cksum(cksum_vec, 4);
457+ if (computed_checksum == 0) {
458+ proto_tree_add_uint_format(hip_tree, hf_hip_checksum, tvb,
459+ offset+6, 2, checksum_h, "Checksum: 0x%04x (correct)",
460+ checksum_h);
461+ } else {
462+ proto_tree_add_uint_format(hip_tree, hf_hip_checksum, tvb,
463+ offset+6, 2, checksum_h,
464+ "Checksum: 0x%04x (incorrect, should be 0x%04x)",
465+ checksum_h,
466+ in_cksum_shouldbe(checksum_h, computed_checksum));
467+ }
468+ } else {
469+ proto_tree_add_uint_format(hip_tree, hf_hip_checksum, tvb,
470+ offset+6, 2, checksum_h,"Checksum: 0x%04x (unverified)",
471+ checksum_h);
472+ }
473+ offset += 8;
474+ proto_tree_add_bytes(hip_tree, hf_hip_hit_sndr, tvb, offset, sizeof(hip_hit), hiph.hit_sndr);
475+ offset += sizeof(hip_hit);
476+ proto_tree_add_bytes(hip_tree, hf_hip_hit_rcvr, tvb, offset, sizeof(hip_hit), hiph.hit_rcvr);
477+ offset += sizeof(hip_hit);
478+
479+ length = (hiph.hdr_len+1)*8;
480+ /* Begin TLV parsing */
481+ if (offset < length) {
482+ ti_tlv = proto_tree_add_text(hip_tree, tvb, offset, tvb_length(tvb), "HIP Parameters");
483+ hip_tlv_tree = proto_item_add_subtree(ti_tlv, ett_hip_tlv);
484+ }
485+ /* Parse type and length in TLV */
486+ while (offset < length)
487+ {
488+ tvb_memcpy(tvb, (guint8 *)&tlv, offset, sizeof(tlv_head));
489+ tlv_type_h = g_ntohs(tlv.type);
490+ tlv_length_h = g_ntohs(tlv.length);
491+ ti_tlv = proto_tree_add_uint_format(hip_tlv_tree, hf_hip_type, tvb,
492+ offset, 4+tlv_length_h, tlv.type, "%s (type=%u, length=%u)",
493+ hip_param(tlv_type_h), tlv_type_h, tlv_length_h);
494+
495+ /* Parse value */
496+ dissect_hip_tlv(tvb, offset, ti_tlv, tlv_type_h, tlv_length_h);
497+
498+ offset += 11 + tlv_length_h - (tlv_length_h + 3) % 8;
499+ }
500+
501+ }
502+}
503+
504+void
505+proto_register_hip(void)
506+{
507+/* Most of this stuff is unused */
508+ module_t *hip_module;
509+ static hf_register_info hf[] = {
510+ { &hf_hip_proto,
511+ { "Payload Protocol", "hip.proto", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
512+
513+ { &hf_hip_hdr_len,
514+ { "Header Length", "hip.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
515+
516+ { &hf_hip_packet_type,
517+ { "Packet Type", "hip.packet_type", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
518+
519+ { &hf_hip_version,
520+ { "Version", "hip.version", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
521+
522+ { &hf_hip_res,
523+ { "Reserved", "hip.res", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
524+
525+ { &hf_hip_controls,
526+ { "HIP Controls", "hip.controls", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
527+
528+ { &hf_hip_controls_cert,
529+ { "Certificate (One or more CER packets follows)", "hip.controls.c", FT_BOOLEAN, 16, NULL, HIP_CONTROL_C_MASK, "", HFILL }},
530+
531+ { &hf_hip_controls_anon,
532+ { "Anonymous (Sender's HI is anonymous)", "hip.controls.a", FT_BOOLEAN, 16, NULL, HIP_CONTROL_A_MASK, "", HFILL }},
533+
534+ { &hf_hip_checksum,
535+ { "Checksum", "hip.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
536+
537+ { &hf_hip_hit_sndr,
538+ { "Sender's HIT", "hip.hit_sndr", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
539+
540+ { &hf_hip_hit_rcvr,
541+ { "Receiver's HIT", "hip.hit_rcvr", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
542+
543+ { &hf_hip_type,
544+ { "Type", "hip.type", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
545+
546+ { &hf_hip_tlv_r1_res,
547+ { "Reserved", "hip.tlv.r1_res", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
548+
549+ { &hf_hip_tlv_r1count,
550+ { "R1 Counter", "hip.tlv.r1count", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
551+
552+ { &hf_hip_tlv_puzzle_k,
553+ { "Puzzle Difficulty K","hip.tlv_puzzle_k", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
554+
555+ { &hf_hip_tlv_puzzle_life,
556+ { "Puzzle Lifetime","hip.tlv_puzzle_life", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
557+
558+ { &hf_hip_tlv_puzzle_o,
559+ { "Opaque Data","hip.tlv_puzzle_o", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
560+
561+ { &hf_hip_tlv_puzzle_i,
562+ { "Puzzle Random I", "hip.tlv.puzzle_i", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
563+
564+ { &hf_hip_tlv_puzzle_j,
565+ { "Puzzle Solution J", "hip.tlv_puzzle_j", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
566+
567+ { &hf_hip_tlv_ei_res,
568+ { "Reserved", "hip.tlv_ei_res", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
569+
570+ { &hf_hip_tlv_ei_keyidx,
571+ { "Keymat Index", "hip.tlv_ei_keyidx", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
572+
573+ { &hf_hip_tlv_ei_oldspi,
574+ { "Old SPI", "hip.tlv_ei_oldspi", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
575+
576+ { &hf_hip_tlv_ei_newspi,
577+ { "New SPI", "hip.tlv_ei_newspi", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
578+
579+ { &hf_hip_tlv_seq_updid,
580+ { "Update ID", "hip.tlv_seq_updid", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
581+
582+ { &hf_hip_tlv_ack_updid,
583+ { "ACKed Peer Update ID", "hip.tlv_ack_updid", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
584+
585+ { &hf_hip_tlv_dh_group_id,
586+ { "Group ID", "hip.tlv.dh_group_id", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
587+
588+ { &hf_hip_tlv_dh_pub,
589+ { "Public Value", "hip.tlv.dh_pub", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
590+
591+ { &hf_hip_tlv_trans_id,
592+ { "Transform ID", "hip.tlv.trans_id", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
593+
594+ { &hf_hip_tlv_esp_reserved,
595+ { "Reserved", "hip.tlv.esp_reserved", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
596+
597+ { &hf_hip_tlv_host_id_len,
598+ { "Host Identity Length","hip.tlv.host_id_len", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
599+
600+ { &hf_hip_tlv_host_di_type,
601+ { "Domain Identifier Type","hip.tlv.host_di_type", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
602+
603+ { &hf_hip_tlv_host_di_len,
604+ { "Domain Identifier Length","hip.tlv.host_di_len", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
605+
606+ { &hf_hip_tlv_host_id_hdr,
607+ { "Host Identity flags","hip.tlv.host_id_hdr", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
608+
609+ { &hf_hip_tlv_host_id_hdr_flags,
610+ { "Flags","hip.tlv.host_id_hdr_flags", FT_UINT32, BASE_HEX, VALS(hi_hdr_flags_vals), HI_HDR_FLAGS_MASK, "", HFILL }},
611+
612+ { &hf_hip_tlv_host_id_hdr_proto,
613+ { "Protocol","hip.tlv.host_id_hdr_flags", FT_UINT32, BASE_HEX, VALS(hi_hdr_proto_vals), HI_HDR_PROTO_MASK, "", HFILL }},
614+
615+ { &hf_hip_tlv_host_id_hdr_alg,
616+ { "Algorithm","hip.tlv.host_id_hdr_alg", FT_UINT32, BASE_HEX, VALS(hi_hdr_alg_vals), HI_HDR_ALG_MASK, "", HFILL }},
617+
618+ { &hf_hip_tlv_host_id_t,
619+ { "Host Identity T","hip.tlv.host_id_t", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
620+
621+ { &hf_hip_tlv_host_id_q,
622+ { "Host Identity Q","hip.tlv.host_id_q", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
623+
624+ { &hf_hip_tlv_host_id_p,
625+ { "Host Identity P","hip.tlv.host_id_p", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
626+
627+ { &hf_hip_tlv_host_id_g,
628+ { "Host Identity G","hip.tlv.host_id_g", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
629+
630+ { &hf_hip_tlv_host_id_y,
631+ { "Host Identity Y (public value)", "hip.tlv.host_id_y", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
632+
633+ { &hf_hip_tlv_host_id_e_len,
634+ { "RSA Host Identity e_len (exponent length)",
635+ "hip.tlv.host_id_e_len", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
636+
637+ { &hf_hip_tlv_host_id_e,
638+ { "RSA Host Identity e (exponent)", "hip.tlv.host_id_e", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
639+
640+ { &hf_hip_tlv_host_id_n,
641+ { "RSA Host Identity n (public modulus)", "hip.tlv.host_id_n", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
642+
643+ { &hf_hip_tlv_cert_count,
644+ { "Cert count","hip.tlv.cert_count", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
645+
646+ { &hf_hip_tlv_cert_id,
647+ { "Cert ID","hip.tlv.cert_id", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
648+
649+ { &hf_hip_tlv_cert_type,
650+ { "Cert type","hip.tlv.cert_type", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
651+
652+ { &hf_hip_tlv_certificate,
653+ { "Certificate","hip.tlv.certificate", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
654+
655+ { &hf_hip_tlv_notify_res,
656+ { "Reserved","hip.tlv.notify_res", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
657+
658+ { &hf_hip_tlv_notify_type,
659+ { "Notify Message Type","hip.tlv.notify_type", FT_UINT16, BASE_DEC, VALS(notify_vals), 0xFFFF, "", HFILL }},
660+
661+ { &hf_hip_tlv_notify_data,
662+ { "Notification Data","hip.tlv.notify_data", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
663+
664+ { &hf_hip_tlv_opaque_data,
665+ { "Opaque Data","hip.tlv.opaque_data", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
666+
667+ { &hf_hip_tlv_reg_ltmin,
668+ { "Minimum Registration Lifetime","hip.tlv.reg_ltmin", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
669+
670+ { &hf_hip_tlv_reg_ltmax,
671+ { "Maximum Registration Lifetime","hip.tlv.reg_ltmax", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
672+
673+ { &hf_hip_tlv_reg_lt,
674+ { "Registration Lifetime","hip.tlv.reg_lt", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
675+
676+ { &hf_hip_tlv_reg_type,
677+ { "Registration Type","hip.tlv.reg_type", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
678+
679+ { &hf_hip_tlv_reg_failtype,
680+ { "Registration Failure Type","hip.tlv.reg_failtype", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
681+
682+ { &hf_hip_tlv_hmac,
683+ { "HMAC","hip.tlv.hmac", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
684+
685+ { &hf_hip_tlv_sig_alg,
686+ { "Signature Algorithm","hip.tlv.sig_alg", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
687+
688+ { &hf_hip_tlv_sig,
689+ { "Signature", "hip.tlv.sig", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
690+
691+ { &hf_hip_tlv_id,
692+ { "ID", "hip.tlv.id", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
693+
694+ { &hf_hip_tlv_enc_reserved,
695+ { "Reserved", "hip.tlv.enc_reserved", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
696+
697+ { &hf_hip_tlv_enc_iv,
698+ { "IV", "hip.tlv.enc_iv", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
699+
700+ { &hf_hip_tlv_locator_traffic_type,
701+ { "Traffic Type", "hip.tlv.locator_traffic_type", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
702+
703+ { &hf_hip_tlv_locator_type,
704+ { "Locator Type", "hip.tlv.locator_type", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
705+
706+ { &hf_hip_tlv_locator_len,
707+ { "Locator Length", "hip.tlv.locator_len", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
708+
709+ { &hf_hip_tlv_locator_reserved,
710+ { "Reserved | P bit", "hip.tlv.locator_reserved", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
711+
712+ { &hf_hip_tlv_locator_lifetime,
713+ { "Locator Lifetime", "hip.tlv.locator_lifetime", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
714+
715+ };
716+ static gint *ett[] = {
717+ &ett_hip,
718+ &ett_hip_controls,
719+ &ett_hip_tlv,
720+ &ett_hip_tlv_data,
721+ &ett_hip_tlv_host_id_hdr,
722+ };
723+
724+ proto_hip = proto_register_protocol("Host Identity Protocol",
725+ "HIP", "hip");
726+
727+ proto_register_field_array(proto_hip, hf, array_length(hf));
728+ proto_register_subtree_array(ett, array_length(ett));
729+
730+ /* Register configuration preferences */
731+ hip_module = prefs_register_protocol(proto_hip, NULL);
732+ prefs_register_bool_preference(hip_module, "summary_in_tree",
733+ "Show HIP summary in protocol tree",
734+ "Whether the HIP summary line should be shown in the protocol tree",
735+ &hip_summary_in_tree);
736+}
737+
738+void
739+proto_reg_handoff_hip(void)
740+{
741+ dissector_handle_t hip_handle;
742+
743+ hip_handle = create_dissector_handle(dissect_hip, proto_hip);
744+ dissector_add("ip.proto", IP_PROTO_HIP, hip_handle);
745+ data_handle = find_dissector("data");
746+}
747+
748+char * hip_param(int n)
749+{
750+ static char s[24];
751+
752+ switch (n)
753+ {
754+ //case 0: /* sometimes extra padding */
755+ // return NULL;
756+ // break;
757+ case PARAM_ESP_INFO:
758+ sprintf(s, "ESP INFO");
759+ break;
760+ case PARAM_R1_COUNTER:
761+ sprintf(s, "R1 COUNTER");
762+ break;
763+ case PARAM_LOCATOR:
764+ sprintf(s, "LOCATOR");
765+ break;
766+ case PARAM_PUZZLE:
767+ sprintf(s, "PUZZLE");
768+ break;
769+ case PARAM_SOLUTION:
770+ sprintf(s, "SOLUTION");
771+ break;
772+ case PARAM_SEQ:
773+ sprintf(s, "SEQ");
774+ break;
775+ case PARAM_ACK:
776+ sprintf(s, "ACK");
777+ break;
778+ case PARAM_DIFFIE_HELLMAN:
779+ sprintf(s, "DIFFIE_HELLMAN");
780+ break;
781+ case PARAM_HIP_TRANSFORM:
782+ sprintf(s, "HIP_TRANSFORM");
783+ break;
784+ case PARAM_ENCRYPTED:
785+ sprintf(s, "ENCRYPTED");
786+ break;
787+ case PARAM_HOST_ID:
788+ sprintf(s, "HOST_ID");
789+ break;
790+ case PARAM_CERT:
791+ sprintf(s, "CERT");
792+ break;
793+ case PARAM_NOTIFY:
794+ sprintf(s, "NOTIFY");
795+ break;
796+ case PARAM_ECHO_REQUEST:
797+ sprintf(s, "ECHO_REQUEST");
798+ break;
799+ case PARAM_ECHO_RESPONSE:
800+ sprintf(s, "ECHO_RESPONSE");
801+ break;
802+ case PARAM_ESP_TRANSFORM:
803+ sprintf(s, "ESP_TRANSFORM");
804+ break;
805+ case PARAM_HMAC:
806+ sprintf(s, "HMAC");
807+ break;
808+ case PARAM_HMAC_2:
809+ sprintf(s, "HMAC_2");
810+ break;
811+ case PARAM_HIP_SIGNATURE_2:
812+ sprintf(s, "HIP_SIGNATURE_2");
813+ break;
814+ case PARAM_HIP_SIGNATURE:
815+ sprintf(s, "HIP_SIGNATURE");
816+ break;
817+ case PARAM_ECHO_REQUEST_NOSIG:
818+ sprintf(s, "ECHO_REQUEST (No sig.)");
819+ break;
820+ case PARAM_ECHO_RESPONSE_NOSIG:
821+ sprintf(s, "ECHO_RESPONSE (No sig.)");
822+ break;
823+ default:
824+ sprintf(s, "?UNKNOWN?");
825+ break;
826+ }
827+
828+ return s;
829+}
830+
831+char *dh_group_id_label(int groupid)
832+{
833+ static char s[26];
834+ switch(groupid)
835+ {
836+ case 0:
837+ sprintf(s, "Reserved");
838+ break;
839+ case 1:
840+ sprintf(s, "384-bit group");
841+ break;
842+ case 2:
843+ sprintf(s, "OAKLEY well-known group 1");
844+ break;
845+ case 3:
846+ sprintf(s, "1536-bit MODP group");
847+ break;
848+ case 4:
849+ sprintf(s, "3072-bit MODP group");
850+ break;
851+ case 5:
852+ sprintf(s, "6144-bit MODP group");
853+ break;
854+ case 6:
855+ sprintf(s, "8192-bit MODP group");
856+ break;
857+ default:
858+ sprintf(s, "UNKNOWN?");
859+ break;
860+ }
861+ return s;
862+
863+}
864+
865+char *transform_id_label(int transform)
866+{
867+ static char s[32];
868+ switch (transform)
869+ {
870+ case 0:
871+ sprintf(s, "Reserved");
872+ break;
873+ case 1:
874+ sprintf(s, "AES-CBC with HMAC-SHA1");
875+ break;
876+ case 2:
877+ sprintf(s, "3DES-CBC with HMAC-SHA1");
878+ break;
879+ case 3:
880+ sprintf(s, "3DES-CBC with HMAC-MD5");
881+ break;
882+ case 4:
883+ sprintf(s, "BLOWFISH-CBC with HMAC-SHA1");
884+ break;
885+ case 5:
886+ sprintf(s, "NULL with HMAC-SHA1");
887+ break;
888+ case 6:
889+ sprintf(s, "NULL with HMAC-MD5");
890+ break;
891+ default:
892+ sprintf(s, "UNKNOWN?");
893+ break;
894+
895+ }
896+ return s;
897+}
898+
899+char *sig_alg_label(int alg)
900+{
901+ static char s[10];
902+ switch (alg)
903+ {
904+ case 0:
905+ sprintf(s, "Reserved");
906+ break;
907+ case HI_ALG_DSA:
908+ sprintf(s, "DSA");
909+ break;
910+ case HI_ALG_RSA:
911+ sprintf(s, "RSA");
912+ break;
913+ default:
914+ sprintf(s, "UNKNOWN?");
915+ break;
916+
917+ }
918+ return s;
919+}
920+
921+
922+int dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len)
923+{
924+ proto_tree *t=NULL;
925+ proto_item *ti_tlv;
926+ guint8 data[512];
927+ guint8 n, algorithm, reg_type;
928+ guint16 trans, hi_len, di_len, di_type, e_len;
929+ guint32 reserved, hi_hdr;
930+ int newoffset, newlen, hi_t;
931+
932+ switch (type)
933+ {
934+ case PARAM_ESP_INFO:
935+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
936+ proto_tree_add_uint(t, hf_hip_tlv_ei_res, tvb, offset+4, 2,
937+ tvb_get_ntohs(tvb, offset+4));
938+ proto_tree_add_uint(t, hf_hip_tlv_ei_keyidx, tvb, offset+6, 2,
939+ tvb_get_ntohs(tvb, offset+6));
940+ proto_tree_add_uint(t, hf_hip_tlv_ei_oldspi, tvb, offset+8, 4,
941+ tvb_get_ntohl(tvb, offset+8));
942+ proto_tree_add_uint(t, hf_hip_tlv_ei_newspi, tvb, offset+12, 4,
943+ tvb_get_ntohl(tvb, offset+12));
944+ break;
945+ case PARAM_R1_COUNTER:
946+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
947+ proto_tree_add_uint(t, hf_hip_tlv_r1_res, tvb, offset+4, 4,
948+ tvb_get_ntohl(tvb, offset+4));
949+ tvb_memcpy(tvb, (guint8*)data, offset+8, 8);
950+ proto_tree_add_bytes(t, hf_hip_tlv_r1count, tvb, offset+8, 8, data);
951+ break;
952+ case PARAM_LOCATOR:
953+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
954+ tlv_len -= 4;
955+ newoffset = offset + 4;
956+ while (tlv_len > 0) {
957+ proto_tree_add_uint(t, hf_hip_tlv_locator_traffic_type, tvb,
958+ newoffset, 1, tvb_get_guint8(tvb, newoffset));
959+ newoffset++;
960+ proto_tree_add_uint(t, hf_hip_tlv_locator_type, tvb,
961+ newoffset, 1, tvb_get_guint8(tvb, newoffset));
962+ newoffset++;
963+ proto_tree_add_uint(t, hf_hip_tlv_locator_len, tvb,
964+ newoffset, 1, tvb_get_guint8(tvb, newoffset));
965+ newoffset++;
966+ reserved = tvb_get_guint8(tvb, newoffset);
967+ proto_tree_add_uint_format(t, hf_hip_tlv_locator_reserved, tvb,
968+ newoffset, 1, reserved, "Reserved: 0x%x %s", reserved,
969+ (reserved >> 31) ? "(Preferred)" : "");
970+ newoffset++;
971+ proto_tree_add_uint(t, hf_hip_tlv_locator_lifetime, tvb,
972+ newoffset, 4, tvb_get_ntohl(tvb, newoffset));
973+ newoffset += 4;
974+ proto_tree_add_text(t, tvb, newoffset, 16, "Address: %s",
975+ ip6_to_str((const struct e_in6_addr*)
976+ tvb_get_ptr(tvb, newoffset, 16)));
977+ newoffset += 16;
978+ tlv_len -= 32;
979+ }
980+ break;
981+ case PARAM_PUZZLE:
982+ case PARAM_SOLUTION:
983+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
984+ proto_tree_add_uint(t, hf_hip_tlv_puzzle_k, tvb, offset+4, 1,
985+ tvb_get_guint8(tvb, offset+4));
986+ proto_tree_add_uint(t, hf_hip_tlv_puzzle_life, tvb, offset+5, 1,
987+ tvb_get_guint8(tvb, offset+5));
988+ proto_tree_add_uint(t, hf_hip_tlv_puzzle_o, tvb,offset+6, 2,
989+ tvb_get_ntohs(tvb, offset+6));
990+ tvb_memcpy(tvb, (guint8*)data, offset+8, 8);
991+ proto_tree_add_bytes(t, hf_hip_tlv_puzzle_i, tvb,offset+8, 8, data);
992+ if (type == PARAM_SOLUTION) { /* solution also contains J */
993+ tvb_memcpy(tvb, (guint8*)data, offset+16, 8);
994+ proto_tree_add_bytes(t, hf_hip_tlv_puzzle_j, tvb, offset+16, 8,
995+ data);
996+ }
997+ break;
998+ case PARAM_SEQ: /* SEQ */
999+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1000+ proto_tree_add_uint(t, hf_hip_tlv_seq_updid, tvb, offset+4, 4,
1001+ tvb_get_ntohl(tvb, offset+4));
1002+ break;
1003+ case PARAM_ACK: /* ACK */
1004+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1005+ newoffset = offset + 4;
1006+ while (tlv_len > 0) {
1007+ proto_tree_add_uint(t, hf_hip_tlv_ack_updid, tvb, newoffset, 4, tvb_get_ntohl(tvb, newoffset));
1008+ newoffset += 4;
1009+ tlv_len -= 4;
1010+ }
1011+ break;
1012+ case PARAM_DIFFIE_HELLMAN: /* DIFFIE_HELLMAN */
1013+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1014+ n = tvb_get_guint8(tvb, offset+4);
1015+ proto_tree_add_uint_format(t, hf_hip_tlv_dh_group_id, tvb, offset+4,
1016+ 1, n, "%u (%s)", n, dh_group_id_label(n));
1017+ tvb_memcpy(tvb, (guint8*)data, offset+5, tlv_len-1);
1018+ proto_tree_add_bytes(t, hf_hip_tlv_dh_pub, tvb, offset+5, tlv_len-1,
1019+ data);
1020+ break;
1021+ case PARAM_ESP_TRANSFORM: /* ESP_TRANSFORM */
1022+ case PARAM_HIP_TRANSFORM: /* HIP_TRANSFORM */
1023+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1024+ /* ESP transform may have E bit*/
1025+ if (type == PARAM_ESP_TRANSFORM) {
1026+ proto_tree_add_uint(t, hf_hip_tlv_esp_reserved, tvb,
1027+ offset+4, 2, tvb_get_ntohs(tvb, offset+4));
1028+ newoffset = offset + 6;
1029+ tlv_len -= 2;
1030+ } else {
1031+ newoffset = offset + 4;
1032+ /* check for NULL as only HIP transform */
1033+ if (tlv_len == 2)
1034+ hip_transform = tvb_get_ntohs(tvb, newoffset);
1035+ else
1036+ hip_transform = 0;
1037+ }
1038+ while (tlv_len > 0) {
1039+ trans = tvb_get_ntohs(tvb, newoffset);
1040+ proto_tree_add_uint_format(t, hf_hip_tlv_trans_id, tvb,
1041+ newoffset, 2, trans, "%u (%s)", trans,
1042+ transform_id_label(trans));
1043+ tlv_len -= 2; /* two bytes per transform id */
1044+ newoffset += 2;
1045+ }
1046+ break;
1047+ case PARAM_ENCRYPTED: /* ENCRYPTED */
1048+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1049+ proto_tree_add_uint(t, hf_hip_tlv_enc_reserved, tvb, offset+4, 4,
1050+ tvb_get_ntohl(tvb, offset+4));
1051+ if (hip_transform == 5) { /* null encryption, no IV */
1052+ offset += 8;
1053+ t = proto_item_add_subtree(t, ett_hip_tlv_data);
1054+ } else { /* encrypted data */
1055+ tvb_memcpy(tvb, (guint8*)data, offset+8, 8);
1056+ proto_tree_add_bytes(t, hf_hip_tlv_enc_iv,tvb,offset+8,8,data);
1057+ proto_tree_add_text(t, tvb, offset+16, tlv_len-12,
1058+ "Encrypted Data (%u bytes)", tlv_len-12);
1059+ break;
1060+ }
1061+ case PARAM_HOST_ID: /* HOST_ID */
1062+ if (type != PARAM_ENCRYPTED)
1063+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1064+ /* hi_length, fqdn_length */
1065+ hi_len = tvb_get_ntohs(tvb, offset+4);
1066+ di_len = tvb_get_ntohs(tvb, offset+6);
1067+ di_type = (di_len >> 12) & 0x000F; /* get 4 bits for DI type */
1068+ di_len = di_len & 0x0FFF; /* 12 bits for DI length */
1069+ proto_tree_add_uint(t, hf_hip_tlv_host_id_len, tvb, offset+4, 2,
1070+ hi_len);
1071+ proto_tree_add_uint(t, hf_hip_tlv_host_di_type, tvb, offset+6, 1,
1072+ di_type);
1073+ proto_tree_add_uint(t, hf_hip_tlv_host_di_len, tvb, offset+6, 2,
1074+ di_len);
1075+ /* hi_hdr - first 4 bytes are 0200ff03 (RFC 2535)
1076+ * flags 2 octets
1077+ * protocol 1 octet
1078+ * algorithm 1 octet (DSA or RSA)
1079+ */
1080+ hi_hdr = tvb_get_ntohl(tvb, offset+8);
1081+ ti_tlv = proto_tree_add_uint(t, hf_hip_tlv_host_id_hdr, tvb, offset+8, 4, hi_hdr);
1082+ if (ti_tlv) {
1083+ ti_tlv = proto_item_add_subtree(ti_tlv,ett_hip_tlv_host_id_hdr);
1084+ proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_flags, tvb, offset+8,2, hi_hdr);
1085+ proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_proto, tvb, offset+10,1, hi_hdr);
1086+ proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_alg, tvb, offset+11,1, hi_hdr);
1087+ }
1088+ algorithm = tvb_get_guint8(tvb, offset+11);
1089+ switch (algorithm) {
1090+ case HI_ALG_DSA:
1091+ /* DSA
1092+ * T 1 octet
1093+ * Q 20 octets
1094+ * P 64 + T*8 octets
1095+ * G 64 + T*8 octets
1096+ * Y 64 + T*8 octets
1097+ */
1098+ /* hi_t */
1099+ proto_tree_add_uint(t, hf_hip_tlv_host_id_t, tvb, offset+12, 1,
1100+ tvb_get_guint8(tvb, offset+12));
1101+ hi_t = tvb_get_guint8(tvb, offset+12);
1102+ tvb_memcpy(tvb, (guint8*)data, offset+13, 20);
1103+ proto_tree_add_bytes(t, hf_hip_tlv_host_id_q, tvb, offset+13,
1104+ 20, data);
1105+ newoffset = offset + 33;
1106+ if (hi_t > 56) /* max 4096 bits */
1107+ break;
1108+ newlen = 64 + (hi_t * 8);
1109+ tvb_memcpy(tvb, (guint8*)data, newoffset, newlen);
1110+ proto_tree_add_bytes(t, hf_hip_tlv_host_id_p, tvb, newoffset,
1111+ newlen, data);
1112+ newoffset += newlen;
1113+ tvb_memcpy(tvb, (guint8*)data, newoffset, newlen);
1114+ proto_tree_add_bytes(t, hf_hip_tlv_host_id_g, tvb, newoffset,
1115+ newlen, data);
1116+ newoffset += newlen;
1117+ tvb_memcpy(tvb, (guint8*)data, newoffset, newlen);
1118+ proto_tree_add_bytes(t, hf_hip_tlv_host_id_y, tvb, newoffset,
1119+ newlen, data);
1120+ break;
1121+ case HI_ALG_RSA:
1122+ /* RSA
1123+ * e_len 1 or 3 octets
1124+ * e specified by e_len
1125+ * n variable length public modulus
1126+ */
1127+ e_len = tvb_get_guint8(tvb, offset+12);
1128+ newoffset = offset+13;
1129+ hi_len -= 5; /* subtract RDATA + e_len */
1130+ if (e_len == 0) { /* e_len is 0 followed by 16-bit value */
1131+ e_len = tvb_get_ntohs(tvb, offset+13);
1132+ newoffset += 2;
1133+ hi_len -= 2;
1134+ }
1135+ if (e_len > 512) { /* per, RFC 3110 < 4096 bits */
1136+ proto_tree_add_text(t, tvb, offset+13, 2,
1137+ "<< e_len too large >>");
1138+ break;
1139+ }
1140+ proto_tree_add_uint(t, hf_hip_tlv_host_id_e_len, tvb, offset+12,
1141+ (e_len > 255) ? 3:1, e_len);
1142+ proto_tree_add_bytes(t, hf_hip_tlv_host_id_e, tvb, newoffset,
1143+ e_len, tvb_get_ptr(tvb, newoffset, e_len));
1144+ newoffset += e_len;
1145+ hi_len -= e_len;
1146+ if ((hi_len > 512) || (hi_len < 0)) {
1147+ proto_tree_add_text(t, tvb, newoffset, 1,
1148+ "<< Invalid HI length >>");
1149+ break;
1150+ }
1151+ /* RSA public modulus n */
1152+ proto_tree_add_bytes(t, hf_hip_tlv_host_id_n, tvb, newoffset,
1153+ hi_len, tvb_get_ptr(tvb,newoffset,hi_len));
1154+ break;
1155+ default:
1156+ proto_tree_add_text(t, tvb, offset+11, 1,
1157+ "Unknown algorithm type (%d).\n", algorithm);
1158+
1159+ break;
1160+ }
1161+ /* FQDN */
1162+ if (di_type == 0)
1163+ break;
1164+ if (di_len > sizeof(data))
1165+ di_len = sizeof(data) - 1;
1166+ memset(data,0,sizeof(data)); /* this null-terminates the string */
1167+ tvb_memcpy(tvb, (guint8*)data, offset+16+hi_len, di_len);
1168+ if (di_type == 1) {
1169+ proto_tree_add_text(t, tvb, offset+16+hi_len, di_len,
1170+ "FQDN: %s", data);
1171+ } else if (di_type == 2) {
1172+ proto_tree_add_text(t, tvb, offset+16+hi_len, di_len,
1173+ "NAI: %s", data);
1174+ }
1175+ break;
1176+ case PARAM_CERT: /* CERT */
1177+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1178+ proto_tree_add_uint(t, hf_hip_tlv_cert_count, tvb, offset+4, 1,
1179+ tvb_get_guint8(tvb, offset+4));
1180+ proto_tree_add_uint(t, hf_hip_tlv_cert_id, tvb, offset+5, 1,
1181+ tvb_get_guint8(tvb, offset+5));
1182+ proto_tree_add_uint(t, hf_hip_tlv_cert_type, tvb, offset+6, 1,
1183+ tvb_get_guint8(tvb, offset+6));
1184+ tvb_memcpy(tvb, (guint8*)data, offset+7, tlv_len-3);
1185+ proto_tree_add_bytes(t, hf_hip_tlv_certificate, tvb, offset+7,
1186+ tlv_len-3, data);
1187+ break;
1188+ case PARAM_NOTIFY: /* NOTIFY */
1189+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1190+ proto_tree_add_uint(t, hf_hip_tlv_notify_res, tvb, offset+4, 2,
1191+ tvb_get_ntohs(tvb, offset+4));
1192+ proto_tree_add_uint(t, hf_hip_tlv_notify_type, tvb, offset+6, 2,
1193+ tvb_get_ntohs(tvb, offset+6));
1194+ tvb_memcpy(tvb, (guint8*)data, offset+8, tlv_len-4);
1195+ proto_tree_add_bytes(t, hf_hip_tlv_notify_data, tvb, offset+8,
1196+ tlv_len-4, data);
1197+
1198+ break;
1199+ case PARAM_ECHO_REQUEST: /* ECHO REQUEST */
1200+ case PARAM_ECHO_RESPONSE: /* ECHO RESPONSE */
1201+ case PARAM_ECHO_REQUEST_NOSIG: /* ECHO REQUEST */
1202+ case PARAM_ECHO_RESPONSE_NOSIG: /* ECHO RESPONSE */
1203+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1204+ tvb_memcpy(tvb, (guint8*)data, offset+4, tlv_len);
1205+ proto_tree_add_bytes(t, hf_hip_tlv_opaque_data, tvb, offset+4,
1206+ tlv_len, data);
1207+ break;
1208+ case PARAM_REG_INFO:
1209+ case PARAM_REG_REQUEST:
1210+ case PARAM_REG_RESPONSE:
1211+ case PARAM_REG_FAILED:
1212+ /* min lt, max lt | lifetime | failuretype */
1213+ if (type == PARAM_REG_INFO) { /* min lt, max lt */
1214+ proto_tree_add_uint(t, hf_hip_tlv_reg_ltmin, tvb, offset+4,
1215+ 1, tvb_get_guint8(tvb, offset+4));
1216+ proto_tree_add_uint(t, hf_hip_tlv_reg_ltmax, tvb, offset+5,
1217+ 1, tvb_get_guint8(tvb, offset+5));
1218+ newoffset = 6;
1219+ } else if (type == PARAM_REG_FAILED) { /* failure type */
1220+ proto_tree_add_uint(t, hf_hip_tlv_reg_failtype, tvb, offset+4,
1221+ 1, tvb_get_guint8(tvb, offset+4));
1222+ newoffset = 5;
1223+ } else { /* lifetime */
1224+ proto_tree_add_uint(t, hf_hip_tlv_reg_lt, tvb, offset+4,
1225+ 1, tvb_get_guint8(tvb, offset+4));
1226+ newoffset = 5;
1227+ }
1228+ /* reg type 1 ... n, padding */
1229+ while (tlv_len > 0) {
1230+ reg_type = tvb_get_guint8(tvb, newoffset);
1231+ proto_tree_add_uint(t, hf_hip_tlv_reg_type, tvb, newoffset, 1,
1232+ reg_type);
1233+ tlv_len--; /* one byte per registration type */
1234+ newoffset++;
1235+ }
1236+ break;
1237+ case PARAM_RVS_HMAC: /* RVS HMAC */
1238+ case PARAM_HMAC: /* HMAC */
1239+ case PARAM_HMAC_2: /* HMAC */
1240+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1241+ tvb_memcpy(tvb, (guint8*)data, offset+4, tlv_len);
1242+ proto_tree_add_bytes(t, hf_hip_tlv_hmac, tvb, offset+4,
1243+ tlv_len,data);
1244+ break;
1245+ case PARAM_HIP_SIGNATURE_2: /* HIP_SIGNATURE_2 */
1246+ case PARAM_HIP_SIGNATURE: /* HIP_SIGNATURE */
1247+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1248+ n = tvb_get_guint8(tvb, offset+4);
1249+ proto_tree_add_uint_format(t, hf_hip_tlv_sig_alg, tvb, offset+4, 1,
1250+ n, "%u (%s)", n, sig_alg_label(n));
1251+ tvb_memcpy(tvb, (guint8*)data, offset+5, tlv_len-1);
1252+ proto_tree_add_bytes(t, hf_hip_tlv_sig, tvb, offset+5, tlv_len-1,
1253+ data);
1254+ break;
1255+ case PARAM_FROM:
1256+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1257+ proto_tree_add_text(t, tvb, offset+4, 16, "Address: %s",
1258+ ip6_to_str((const struct e_in6_addr*)
1259+ tvb_get_ptr(tvb, offset+4, 16)));
1260+ break;
1261+ case PARAM_VIA_RVS:
1262+ t = proto_item_add_subtree(ti, ett_hip_tlv_data);
1263+ newoffset = offset + 4;
1264+ while (tlv_len > 0) {
1265+ proto_tree_add_text(t, tvb, newoffset, 16, "RVS Address: %s",
1266+ ip6_to_str((const struct e_in6_addr*)
1267+ tvb_get_ptr(tvb, newoffset, 16)));
1268+ tlv_len -= 16;
1269+ newoffset += 16;
1270+ }
1271+ break;
1272+ default:
1273+ break;
1274+ }
1275+ return (0);
1276+}
1277+
1278diff -burN wireshark-0.99.6.orig/epan/dissectors/register.c wireshark-0.99.6/epan/dissectors/register.c
1279--- wireshark-0.99.6.orig/epan/dissectors/register.c 2007-08-21 09:41:51.153795484 +0200
1280+++ wireshark-0.99.6/epan/dissectors/register.c 2007-08-21 09:42:11.955168892 +0200
1281@@ -246,6 +246,7 @@
1282 {extern void proto_register_fp (void); if(cb) (*cb)(RA_REGISTER, "proto_register_fp", client_data); proto_register_fp ();}
1283 {extern void proto_register_fr (void); if(cb) (*cb)(RA_REGISTER, "proto_register_fr", client_data); proto_register_fr ();}
1284 {extern void proto_register_fractalgeneratorprotocol (void); if(cb) (*cb)(RA_REGISTER, "proto_register_fractalgeneratorprotocol", client_data); proto_register_fractalgeneratorprotocol ();}
1285+ {extern void proto_register_hip (void); proto_register_hip ();}
1286 {extern void proto_register_frame (void); if(cb) (*cb)(RA_REGISTER, "proto_register_frame", client_data); proto_register_frame ();}
1287 {extern void proto_register_ftam (void); if(cb) (*cb)(RA_REGISTER, "proto_register_ftam", client_data); proto_register_ftam ();}
1288 {extern void proto_register_ftbp (void); if(cb) (*cb)(RA_REGISTER, "proto_register_ftbp", client_data); proto_register_ftbp ();}
1289@@ -868,6 +869,7 @@
1290 {extern void proto_reg_handoff_dcerpc_frsapi (void); if(cb) (*cb)(RA_HANDOFF, "proto_reg_handoff_dcerpc_frsapi", client_data); proto_reg_handoff_dcerpc_frsapi ();}
1291 {extern void proto_reg_handoff_dcerpc_frsrpc (void); if(cb) (*cb)(RA_HANDOFF, "proto_reg_handoff_dcerpc_frsrpc", client_data); proto_reg_handoff_dcerpc_frsrpc ();}
1292 {extern void proto_reg_handoff_dcerpc_initshutdown (void); if(cb) (*cb)(RA_HANDOFF, "proto_reg_handoff_dcerpc_initshutdown", client_data); proto_reg_handoff_dcerpc_initshutdown ();}
1293+ {extern void proto_reg_handoff_hip (void); proto_reg_handoff_hip ();}
1294 {extern void proto_reg_handoff_dcerpc_lsa (void); if(cb) (*cb)(RA_HANDOFF, "proto_reg_handoff_dcerpc_lsa", client_data); proto_reg_handoff_dcerpc_lsa ();}
1295 {extern void proto_reg_handoff_dcerpc_mapi (void); if(cb) (*cb)(RA_HANDOFF, "proto_reg_handoff_dcerpc_mapi", client_data); proto_reg_handoff_dcerpc_mapi ();}
1296 {extern void proto_reg_handoff_dcerpc_messenger (void); if(cb) (*cb)(RA_HANDOFF, "proto_reg_handoff_dcerpc_messenger", client_data); proto_reg_handoff_dcerpc_messenger ();}
1297diff -burN wireshark-0.99.6.orig/epan/ipproto.h wireshark-0.99.6/epan/ipproto.h
1298--- wireshark-0.99.6.orig/epan/ipproto.h 2007-08-21 09:41:51.149795220 +0200
1299+++ wireshark-0.99.6/epan/ipproto.h 2007-08-21 09:42:11.959169156 +0200
1300@@ -187,6 +187,7 @@
1301 #define IP_PROTO_MPLS_IN_IP 137 /* MPLS in IP - RFC4023 */
1302 #define IP_PROTO_AX4000 173 /* AX/4000 Testblock - non IANA */
1303 #define IP_PROTO_NCS_HEARTBEAT 224 /* Novell NCS Heartbeat - http://support.novell.com/cgi-bin/search/searchtid.cgi?/10071158.htm */
1304+#define IP_PROTO_HIP 253 /* Host Identity Protocol */
1305
1306 extern const char *ipprotostr(int proto);
1307
1308diff -burN wireshark-0.99.6.orig/epan/prefs.c wireshark-0.99.6/epan/prefs.c
1309--- wireshark-0.99.6.orig/epan/prefs.c 2007-08-21 09:41:51.145794955 +0200
1310+++ wireshark-0.99.6/epan/prefs.c 2007-08-21 09:42:11.959169156 +0200
1311@@ -2168,6 +2168,10 @@
1312 /* Handle old names for UDP preferences. */
1313 if (strcmp(dotp, "udp_summary_in_tree") == 0)
1314 pref = find_preference(module, "summary_in_tree");
1315+ } else if (strcmp(module->name, "hip") == 0) {
1316+ /* Handle old names for HIP preferences. */
1317+ if (strcmp(dotp, "hip_summary_in_tree") == 0)
1318+ pref = find_preference(module, "summary_in_tree");
1319 } else if (strcmp(module->name, "ndps") == 0) {
1320 /* Handle old names for NDPS preferences. */
1321 if (strcmp(dotp, "desegment_ndps") == 0)
This page took 0.182291 seconds and 4 git commands to generate.