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