1 diff -N -r -u --strip-trailing-cr tcpdump-orig/configure.in tcpdump/configure.in
2 --- tcpdump-orig/configure.in 2009-05-20 10:29:46.000000000 +0200
3 +++ tcpdump/configure.in 2009-05-17 12:13:13.000000000 +0200
5 --disable-ipv6 disable ipv6 support],
7 yes) AC_MSG_RESULT(yes)
8 - LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
9 + LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-hip.c $LOCALSRC"
13 diff -N -r -u --strip-trailing-cr tcpdump-orig/interface.h tcpdump/interface.h
14 --- tcpdump-orig/interface.h 2009-05-20 10:29:46.000000000 +0200
15 +++ tcpdump/interface.h 2009-05-17 12:15:00.000000000 +0200
17 extern int rt6_print(const u_char *, const u_char *);
18 extern void ospf6_print(const u_char *, u_int);
19 extern void dhcp6_print(const u_char *, u_int);
20 +extern void hip_print(const u_char *, u_int);
22 extern u_short in_cksum(const u_short *, register u_int, int);
23 extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
24 diff -N -r -u --strip-trailing-cr tcpdump-orig/ipproto.c tcpdump/ipproto.c
25 --- tcpdump-orig/ipproto.c 2009-05-20 10:29:46.000000000 +0200
26 +++ tcpdump/ipproto.c 2009-05-18 18:56:10.000000000 +0200
28 { IPPROTO_PGM, "PGM" },
29 { IPPROTO_SCTP, "SCTP" },
30 { IPPROTO_MOBILITY, "Mobility" },
31 + { IPPROTO_HIP, "HIP" },
35 diff -N -r -u --strip-trailing-cr tcpdump-orig/ipproto.h tcpdump/ipproto.h
36 --- tcpdump-orig/ipproto.h 2009-05-20 10:29:46.000000000 +0200
37 +++ tcpdump/ipproto.h 2009-05-17 12:33:07.000000000 +0200
39 #ifndef IPPROTO_MOBILITY
40 #define IPPROTO_MOBILITY 135
43 +#define IPPROTO_HIP 139
45 diff -N -r -u --strip-trailing-cr tcpdump-orig/Makefile.in tcpdump/Makefile.in
46 --- tcpdump-orig/Makefile.in 2009-05-20 10:29:46.000000000 +0200
47 +++ tcpdump/Makefile.in 2009-05-17 12:20:28.000000000 +0200
49 print-domain.c print-dtp.c print-dvmrp.c print-enc.c print-egp.c \
50 print-eap.c print-eigrp.c\
51 print-esp.c print-ether.c print-fddi.c print-fr.c \
52 - print-gre.c print-hsrp.c print-icmp.c print-igmp.c \
53 + print-gre.c print-hip.c print-hsrp.c print-icmp.c print-igmp.c \
54 print-igrp.c print-ip.c print-ipcomp.c print-ipfc.c \
55 print-ipx.c print-isoclns.c print-juniper.c print-krb.c \
56 print-l2tp.c print-lane.c print-ldp.c print-lldp.c print-llc.c \
57 diff -N -r -u --strip-trailing-cr tcpdump-orig/print-hip.c tcpdump/print-hip.c
58 --- tcpdump-orig/print-hip.c 1970-01-01 01:00:00.000000000 +0100
59 +++ tcpdump/print-hip.c 2009-07-28 00:47:40.000000000 +0200
62 + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
63 + * The Regents of the University of California. All rights reserved.
65 + * Redistribution and use in source and binary forms, with or without
66 + * modification, are permitted provided that: (1) source code distributions
67 + * retain the above copyright notice and this paragraph in its entirety, (2)
68 + * distributions including binary code include the above copyright notice and
69 + * this paragraph in its entirety in the documentation or other materials
70 + * provided with the distribution, and (3) all advertising materials mentioning
71 + * features or use of this software display the following acknowledgement:
72 + * ``This product includes software developed by the University of California,
73 + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
74 + * the University nor the names of its contributors may be used to endorse
75 + * or promote products derived from this software without specific prior
76 + * written permission.
77 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
78 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
79 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
81 + * Support for dissecting Host Identity Protocol (HIP)
82 + * RFCs 5201 - 5206, draft-ietf-hip-cert-00, draft-ietf-hip-nat-traversal-06
84 + * Author: Samu Varjonen <samu.varjonen@hiit.fi>
85 + * based on patch created by
86 + * Mika Kousa <mika.kousa@iki.fi>
87 + * Kristian Slavov <kslavov@piuha.net>
95 +#include <sys/param.h>
96 +#include <sys/time.h>
97 +#include <sys/types.h>
98 +#include <sys/socket.h>
100 +#include <netinet/in.h>
107 +#include <tcpdump-stdinc.h>
109 +#include "interface.h"
110 +#include "extract.h"
111 +#include "addrtoname.h"
113 +#define HIP_HI_DSA 3
114 +#define HIP_HI_RSA 5
121 +#define HIP_UPDATE 16
122 +#define HIP_NOTIFY 17
123 +#define HIP_CLOSE 18
124 +#define HIP_CLOSE_ACK 19
127 +#define HIP_ESP_RESERVED 0
128 +#define HIP_ESP_AES_SHA1 1
129 +#define HIP_ESP_3DES_SHA1 2
130 +#define HIP_ESP_3DES_MD5 3
131 +#define HIP_ESP_BLOWFISH_SHA1 4
132 +#define HIP_ESP_NULL_SHA1 5
133 +#define HIP_ESP_NULL_MD5 6
136 +#define HIP_DH_RESERVED 0
137 +#define HIP_DH_384 1
138 +#define HIP_DH_OAKLEY_1 2
139 +#define HIP_DH_OAKLEY_5 3
140 +#define HIP_DH_OAKLEY_15 4
141 +#define HIP_DH_OAKLEY_17 5
142 +#define HIP_DH_OAKLEY_18 6
145 +#define HIP_NAT_TRAVERSAL_MODE_RESERVED 0
146 +#define HIP_NAT_TRAVERSAL_MODE_UDP 1
147 +#define HIP_NAT_TRAVERSAL_MODE_ICE_STUN_UDP 2
149 +/* HIP TLV parameters listed in order of RFCs */
152 +#define HIP_PARAM_R1_COUNTER 128
153 +#define HIP_PARAM_PUZZLE 257
154 +#define HIP_PARAM_SOLUTION 321
155 +#define HIP_PARAM_SEQ 385
156 +#define HIP_PARAM_ACK 449
157 +#define HIP_PARAM_DIFFIE_HELLMAN 513
158 +#define HIP_PARAM_HIP_TRANSFORM 577
159 +#define HIP_PARAM_ENCRYPTED 641
160 +#define HIP_PARAM_HOST_ID 705
161 +/* Type number defined in RFC 5201 contents
162 + in draft-ietf-hip-cert-00 */
163 +#define HIP_PARAM_CERT 768
164 +#define HIP_PARAM_NOTIFICATION 832
165 +#define HIP_PARAM_ECHO_REQUEST_SIGNED 897
166 +#define HIP_PARAM_ECHO_RESPONSE_SIGNED 961
167 +#define HIP_PARAM_HMAC 61505
168 +#define HIP_PARAM_HMAC_2 61569
169 +#define HIP_PARAM_HIP_SIGNATURE_2 61633
170 +#define HIP_PARAM_HIP_SIGNATURE 61697
171 +#define HIP_PARAM_ECHO_REQUEST_UNSIGNED 63661
172 +#define HIP_PARAM_ECHO_RESPONSE_UNSIGNED 63425
174 +#define HIP_PARAM_ESP_INFO 65
175 +#define HIP_PARAM_ESP_TRANSFORM 4095
177 +#define HIP_PARAM_REG_INFO 930
178 +#define HIP_PARAM_REG_REQUEST 932
179 +#define HIP_PARAM_REG_RESPONSE 934
180 +#define HIP_PARAM_REG_FAILED 936
182 +#define HIP_PARAM_FROM 65498
183 +#define HIP_PARAM_RVS_HMAC 65500
184 +#define HIP_PARAM_VIA_RVS 65502
186 +#define HIP_PARAM_LOCATOR 193
187 +/* draft-ietf-hip-nat-raversal-06.txt */
188 +#define HIP_PARAM_NAT_TRAVERSAL_MODE 608
189 +#define HIP_PARAM_TRANSACTION_PACING 610
190 +#define HIP_PARAM_REG_FROM 950
191 +#define HIP_PARAM_RELAY_FROM 63998
192 +#define HIP_PARAM_RELAY_TO 64002
195 +#define HIP_PARAM_CRITICAL_BIT 0x0001
196 +/* See RFC 5201 section 5.1 */
197 +#define HIP_PACKET_TYPE_MASK 0x7F
198 +/* draft-ietf-shim6-proto-12 see section 5.3 */
199 +#define HIP_SHIM6_FIXED_BIT_P_MASK 0x80
200 +#define HIP_SHIM6_FIXED_BIT_S_MASK 0x01
201 +/* 00001110 Excluding the shim6 compatibility bit */
202 +#define HIP_RESERVED_MASK 0x0E
203 +#define HIP_VERSION_MASK 0xF0
204 +#define HIP_CONTROL_A_MASK 0x0001
205 +#define HIP_CONTROL_C_MASK 0x0002
207 +#define HI_HDR_FLAGS_MASK 0xFFFF0000
208 +#define HI_HDR_PROTO_MASK 0x0000FF00
209 +#define HI_HDR_ALG_MASK 0x000000FF
211 +#define HIP_LOCATOR_RESERVED_MASK 0xFE
212 +#define HIP_LOCATOR_PREFERRED_MASK 0x01
214 +#define HIP_TRANSFORM_HIP_MAX 6
215 +#define HIP_TRANSFORM_ESP_MAX 6
216 +#define HIP_NAT_TRAVERSAL_MODE_MAX 6
217 +#define HIP_MAX_PACKET 2048
218 +#define HIP_PUZZLE_OPAQUE_LEN 2
220 +#define HIP_AH_SHA_LEN 20
222 +typedef uint16_t hip_tlv_type_t;
223 +typedef uint16_t hip_tlv_len_t;
225 +/* Returns length of TLV option (contents) with padding. */
226 +#define HIP_LEN_PAD(len) \
227 + ((((len) & 0x07) == 0) ? (len) : ((((len) >> 3) << 3) + 8))
231 + uint8_t payload_proto;
232 + uint8_t payload_len;
239 + struct in6_addr hits; /* Sender HIT */
240 + struct in6_addr hitr; /* Receiver HIT */
241 +} __attribute__ ((packed));
243 +struct hip_tlv_common {
244 + hip_tlv_type_t type;
245 + hip_tlv_len_t length;
246 +} __attribute__ ((packed));
248 +struct hip_r1_counter {
249 + hip_tlv_type_t type;
250 + hip_tlv_len_t length;
253 + uint64_t generation;
254 +} __attribute__ ((packed));
257 + hip_tlv_type_t type;
258 + hip_tlv_len_t length;
262 + uint8_t opaque[HIP_PUZZLE_OPAQUE_LEN];
264 +} __attribute__ ((packed));
266 +struct hip_solution {
267 + hip_tlv_type_t type;
268 + hip_tlv_len_t length;
272 + uint8_t opaque[HIP_PUZZLE_OPAQUE_LEN];
275 +} __attribute__ ((packed));
278 + hip_tlv_type_t type;
279 + hip_tlv_len_t length;
281 + uint32_t update_id;
282 +} __attribute__ ((packed));
285 + hip_tlv_type_t type;
286 + hip_tlv_len_t length;
288 + uint32_t peer_update_id; /* n items */
289 +} __attribute__ ((packed));
291 +struct hip_diffie_hellman {
292 + hip_tlv_type_t type;
293 + hip_tlv_len_t length;
296 + /* fixed part ends */
297 + uint8_t public_value[0];
298 +} __attribute__ ((packed));
300 +typedef uint16_t hip_transform_suite_t;
302 +struct hip_hip_transform {
303 + hip_tlv_type_t type;
304 + hip_tlv_len_t length;
306 + hip_transform_suite_t suite_id[HIP_TRANSFORM_HIP_MAX];
307 +} __attribute__ ((packed));
309 +struct hip_encrypted_aes_sha1 {
310 + hip_tlv_type_t type;
311 + hip_tlv_len_t length;
315 + /* fixed part ends */
316 +} __attribute__ ((packed));
318 +struct hip_encrypted_3des_sha1 {
319 + hip_tlv_type_t type;
320 + hip_tlv_len_t length;
324 + /* fixed part ends */
325 +} __attribute__ ((packed));
327 +struct hip_encrypted_null_sha1 {
328 + hip_tlv_type_t type;
329 + hip_tlv_len_t length;
332 + /* fixed part ends */
333 +} __attribute__ ((packed));
335 +struct hip_host_id_key_rdata {
340 + /* fixed part ends */
341 +} __attribute__ ((packed));
343 +struct hip_host_id {
344 + hip_tlv_type_t type;
345 + hip_tlv_len_t length;
347 + uint16_t hi_length;
348 + uint16_t di_type_length;
350 + struct hip_host_id_key_rdata rdata;
351 + /* fixed part ends */
352 +} __attribute__ ((packed));
355 + hip_tlv_type_t type;
356 + hip_tlv_len_t length;
358 + uint8_t cert_group;
359 + uint8_t cert_count;
362 + /* end of fixed part */
363 +} __attribute__ ((packed));
365 +struct hip_notification {
366 + hip_tlv_type_t type;
367 + hip_tlv_len_t length;
371 + /* end of fixed part */
372 +} __attribute__ ((packed));
374 +struct hip_echo_request {
375 + hip_tlv_type_t type;
376 + hip_tlv_len_t length;
378 +} __attribute__ ((packed));
380 +struct hip_echo_response {
381 + hip_tlv_type_t type;
382 + hip_tlv_len_t length;
384 +} __attribute__ ((packed));
387 + hip_tlv_type_t type;
388 + hip_tlv_len_t length;
390 + uint8_t hmac_data[HIP_AH_SHA_LEN];
391 +} __attribute__ ((packed));
393 +/* HMAC2 is the same as above */
395 +/* HIP SIGNATURE2 is the same as below */
397 +struct hip_signature {
398 + hip_tlv_type_t type;
399 + hip_tlv_len_t length;
402 + uint8_t signature[0]; /* variable length */
403 + /* fixed part end */
404 +} __attribute__ ((packed));
406 +/* HIP_ECHO_REQUEST_UNSIGNED same as signed version above */
408 +/* HIP_ECHO_RESPONSE_UNSIGNED same as signed version above */
410 +struct hip_esp_info {
411 + hip_tlv_type_t type;
412 + hip_tlv_len_t length;
415 + uint16_t keymat_index;
418 +} __attribute__ ((packed));
420 +struct hip_esp_transform {
421 + hip_tlv_type_t type;
422 + hip_tlv_len_t length;
426 + hip_transform_suite_t suite_id[HIP_TRANSFORM_ESP_MAX];
427 +} __attribute__ ((packed));
429 +struct hip_reg_info {
430 + hip_tlv_type_t type;
431 + hip_tlv_len_t length;
433 + uint8_t min_lifetime;
434 + uint8_t max_lifetime;
436 + uint8_t reg_type[0]; /* Variable */
437 +} __attribute__ ((packed));
439 +struct hip_reg_request_response {
440 + hip_tlv_type_t type;
441 + hip_tlv_len_t length;
444 + uint8_t reg_type[0]; /* Variable */
445 +} __attribute__ ((packed));
447 +/* REG_REQUEST is exactly like RESPONSE see above */
449 +struct hip_reg_failed {
450 + hip_tlv_type_t type;
451 + hip_tlv_len_t length;
453 + uint8_t failure_type;
454 + uint8_t reg_type[0]; /* Variable */
455 +} __attribute__ ((packed));
458 + hip_tlv_type_t type;
459 + hip_tlv_len_t length;
460 + uint8_t address[16];
461 +} __attribute__ ((packed));
463 +struct hip_rvs_hmac {
464 + hip_tlv_type_t type;
465 + hip_tlv_len_t length;
466 + uint8_t hmac_data[HIP_AH_SHA_LEN];
467 +} __attribute__ ((packed));
469 +struct hip_via_rvs {
470 + hip_tlv_type_t type;
471 + hip_tlv_len_t length;
472 + uint8_t address[16];
473 + /* the rest of the addresses */
474 +} __attribute__ ((packed));
477 +struct hip_locator_info_addr_item {
478 + hip_tlv_type_t type;
479 + hip_tlv_len_t length;
480 + uint8_t traffic_type;
481 + uint8_t locator_type;
482 + uint8_t locator_length;
485 + /* end of fixed part - locator of arbitrary length follows but
486 + currently support only IPv6 */
487 + uint8_t locator[16];
488 +} __attribute__ ((packed));
491 +struct hip_locator_info_addr_item2 {
492 + hip_tlv_type_t type;
493 + hip_tlv_len_t length;
494 + uint8_t traffic_type;
495 + uint8_t locator_type;
496 + uint8_t locator_length;
499 + uint16_t transport_port;
500 + uint8_t transport_protocol;
504 + /* end of fixed part - locator of arbitrary length follows but
505 + currently support only IPv6 */
506 + uint8_t locator[16];
507 +} __attribute__ ((packed));
509 +struct hip_nat_traversal_mode {
510 + hip_tlv_type_t type;
511 + hip_tlv_len_t length;
515 + hip_transform_suite_t suite_id[HIP_NAT_TRAVERSAL_MODE_MAX];
516 +} __attribute__ ((packed));
518 +struct hip_transaction_pacing {
519 + hip_tlv_type_t type;
520 + hip_tlv_len_t length;
523 +} __attribute__ ((packed));
525 +struct hip_reg_from {
526 + hip_tlv_type_t type;
527 + hip_tlv_len_t length;
532 + uint8_t address[16];
533 +} __attribute__ ((packed));
535 +struct hip_relay_from {
536 + hip_tlv_type_t type;
537 + hip_tlv_len_t length;
542 + uint8_t address[16];
543 +} __attribute__ ((packed));
545 +struct hip_relay_to {
546 + hip_tlv_type_t type;
547 + hip_tlv_len_t length;
552 + uint8_t address[16];
553 +} __attribute__ ((packed));
555 +/*******************************************************************************
557 +*******************************************************************************/
559 +static struct tok hip_types[] = {
564 + { HIP_UPDATE, "UPDATE" },
565 + { HIP_NOTIFY, "NOTIFY" },
566 + { HIP_CLOSE, "CLOSE" },
567 + { HIP_CLOSE_ACK, "CLOSE_ACK" },
571 +static struct tok hip_param_types[] = {
572 + { HIP_PARAM_R1_COUNTER, "R1 COUNTER" },
573 + { HIP_PARAM_PUZZLE, "PUZZLE" },
574 + { HIP_PARAM_SOLUTION, "SOLUTION" },
575 + { HIP_PARAM_SEQ, "SEQ" },
576 + { HIP_PARAM_ACK, "ACK" },
577 + { HIP_PARAM_DIFFIE_HELLMAN, "DIFFIE_HELLMAN" },
578 + { HIP_PARAM_HIP_TRANSFORM, "HIP_TRANSFORM" },
579 + { HIP_PARAM_ENCRYPTED, "ENCRYPTED" },
580 + { HIP_PARAM_HOST_ID, "HOST_ID" },
581 + { HIP_PARAM_CERT, "CERT" },
582 + { HIP_PARAM_NOTIFICATION, "NOTIFICATION" },
583 + { HIP_PARAM_ECHO_REQUEST_SIGNED, "ECHO_REQUEST_SIGNED" },
584 + { HIP_PARAM_ECHO_RESPONSE_SIGNED, "ECHO_RESPONSE_SIGNED" },
585 + { HIP_PARAM_HMAC, "HMAC" },
586 + { HIP_PARAM_HMAC_2, "HMAC_2" },
587 + { HIP_PARAM_HIP_SIGNATURE_2, "HIP_SIGNATURE_2" },
588 + { HIP_PARAM_HIP_SIGNATURE, "HIP_SIGNATURE" },
589 + { HIP_PARAM_ECHO_REQUEST_UNSIGNED, "ECHO_REQUEST_UNSIGNED" },
590 + { HIP_PARAM_ECHO_RESPONSE_UNSIGNED, "ECHO_RESPONSE_UNSIGNED" },
591 + { HIP_PARAM_ESP_INFO, "ESP_INFO" },
592 + { HIP_PARAM_ESP_TRANSFORM, "ESP_TRANSFORM" },
593 + { HIP_PARAM_REG_INFO, "REG_INFO" },
594 + { HIP_PARAM_REG_REQUEST, "REG_REQUEST" },
595 + { HIP_PARAM_REG_RESPONSE, "REG_RESPONSE" },
596 + { HIP_PARAM_REG_FAILED, "REG_FAILED" },
597 + { HIP_PARAM_FROM, "FROM" },
598 + { HIP_PARAM_RVS_HMAC, "RVS_HMAC" },
599 + { HIP_PARAM_VIA_RVS, "VIA_RVS" },
600 + { HIP_PARAM_LOCATOR, "LOCATOR" },
601 + { HIP_PARAM_NAT_TRAVERSAL_MODE, "NAT_TRAVERSAL_MODE" },
602 + { HIP_PARAM_TRANSACTION_PACING, "TRANSACTION_PACING" },
603 + { HIP_PARAM_REG_FROM, "REG_FROM" },
604 + { HIP_PARAM_RELAY_FROM, "RELAY_FROM" },
605 + { HIP_PARAM_RELAY_TO, "RELAY_TO" },
609 +static struct tok hip_esp_transform_types[] = {
610 + { HIP_ESP_RESERVED, "Reserved" },
611 + { HIP_ESP_AES_SHA1, "AES-SHA1" },
612 + { HIP_ESP_3DES_SHA1, "3DES-SHA1" },
613 + { HIP_ESP_3DES_MD5, "3DES-MD5" },
614 + { HIP_ESP_BLOWFISH_SHA1, "BLOWFISH-SHA1" },
615 + { HIP_ESP_NULL_SHA1, "NULL-SHA1" },
616 + { HIP_ESP_NULL_MD5, "NULL-MD5" },
620 +#define hip_hip_transform_types hip_esp_transform_types
622 +static struct tok hip_rdata_algorithms[] = {
623 + { HIP_HI_DSA, "DSA" },
624 + { HIP_HI_RSA, "RSA" },
628 +static struct tok hip_dh_group_id_types[] = {
629 + { HIP_DH_RESERVED, "Reserved" },
630 + { HIP_DH_384, "384-bit group" },
631 + { HIP_DH_OAKLEY_1, "768-bit (OAKLEY 1)" },
632 + { HIP_DH_OAKLEY_5, "1536-bit (OAKLEY 5)" },
633 + { HIP_DH_OAKLEY_15, "3072-bit (OAKLEY 15)" },
634 + { HIP_DH_OAKLEY_17, "6144-bit (OAKLEY 17)" },
635 + { HIP_DH_OAKLEY_18, "8192-bit (OAKLEY 18)" },
639 +static struct tok hip_nat_traversal_modes[] = {
640 + { HIP_NAT_TRAVERSAL_MODE_RESERVED, "Reserved" },
641 + { HIP_NAT_TRAVERSAL_MODE_UDP, "UDP-encapsulation" },
642 + { HIP_NAT_TRAVERSAL_MODE_ICE_STUN_UDP, "ICE-STUN-UDP" },
646 +/*******************************************************************************
648 +*******************************************************************************/
651 +hip_hexdump(u_char *data, int len)
654 + for (i = 0; i < len; i++)
655 + printf("%02x", data[i]);
658 +/* supports only hex print, modified from print_int64 in print-nfs.c */
660 +hip_print_int64_hex (const u_char *dp, int hostorder)
663 + printf("0x%" PRIx64, EXTRACT_LE_64BITS(dp));
665 + printf("0x%" PRIx64, EXTRACT_64BITS(dp));
668 +/*******************************************************************************
669 +* Dissectors for HIP params *
670 +*******************************************************************************/
673 +hip_print_param_r1_counter (const struct hip_tlv_common * tlv)
675 + struct hip_r1_counter *p = (struct hip_r1_counter *) tlv;
677 + printf(" Reserved=%u", p->reserved);
678 + printf(", Generation net order=");
679 + hip_print_int64_hex((u_char *)&p->generation, 0);
680 + printf("/host order=");
681 + hip_print_int64_hex((u_char *)&p->generation, 1);
686 +hip_print_param_puzzle (const struct hip_tlv_common * tlv)
688 + struct hip_puzzle *p = (struct hip_puzzle *) tlv;
690 + printf("(K=%u, lifetime=%u, opaque=0x", p->K, p->lifetime);
691 + hip_hexdump((u_char *) &p->opaque, HIP_PUZZLE_OPAQUE_LEN);
692 + printf(", I net order=");
693 + hip_print_int64_hex((u_char *)&p->I, 0);
694 + printf("/host order=");
695 + hip_print_int64_hex((u_char *)&p->I, 1);
700 +hip_print_param_solution (const struct hip_tlv_common * tlv)
702 + struct hip_solution * p = (struct hip_solution *) tlv;
704 + printf("(K=%u, reserved=0x%x, opaque=0x", p->K, p->reserved);
705 + hip_hexdump((u_char *) &p->opaque, HIP_PUZZLE_OPAQUE_LEN);
706 + printf(", I net order=");
707 + hip_print_int64_hex((u_char *)&p->I, 0);
708 + printf("/host order=");
709 + hip_print_int64_hex((u_char *)&p->I, 1);
710 + printf(", J net order=");
711 + hip_print_int64_hex((u_char *)&p->J, 0);
712 + printf("/host order=");
713 + hip_print_int64_hex((u_char *)&p->J, 1);
718 +hip_print_param_seq (const struct hip_tlv_common * tlv)
720 + struct hip_seq * p = (struct hip_seq *) tlv;
722 + printf("(Update ID=%u)", ntohl(p->update_id));
726 +hip_print_param_ack (const struct hip_tlv_common * tlv)
728 + struct hip_ack * p = (struct hip_ack *) tlv;
730 + uint32_t * peer_update_id;
732 + if (ntohs(p->length) % sizeof(uint32_t))
735 + n = ntohs(p->length) / sizeof(uint32_t);
736 + peer_update_id = (uint32_t *) ((void *)p + sizeof(struct hip_tlv_common));
738 + for (i = 0; i < n; i++, peer_update_id++) {
739 + if (i) printf(",");
740 + printf("peer Update ID=%u", ntohl(* peer_update_id));
746 +hip_print_param_diffie_hellman (const struct hip_tlv_common * tlv)
748 + struct hip_diffie_hellman * p = (struct hip_diffie_hellman *) tlv;
750 + printf("(group_id=%s(%u), public value=0x",
751 + tok2str(hip_dh_group_id_types, NULL, p->group_id), p->group_id);
752 + hip_hexdump((u_char *)p + sizeof(struct hip_tlv_common)+sizeof(uint8_t),
753 + ntohs(p->length) - sizeof(uint8_t));
759 +hip_print_param_hip_transform (const struct hip_tlv_common * tlv)
761 + struct hip_hip_transform * p = (struct hip_hip_transform *) tlv;
766 + if (ntohs(p->length) == 0) {
767 + printf("no transforms)");
771 + n = ntohs(p->length) / sizeof(u_int16_t);
772 + if (n > HIP_TRANSFORM_HIP_MAX) {
773 + printf("too many Transform IDs (%d))", n);
777 + id = (u_int16_t *) ((u_char *)p + sizeof(struct hip_tlv_common));
778 + for (i = 1; i <= n; i++, id++) {
781 + printf("Transform ID #%d=%s(%d)", i,
782 + tok2str(hip_hip_transform_types, NULL, ntohs(* id)), ntohs(* id));
789 +hip_print_param_encrypted (const struct hip_tlv_common * tlv)
794 + cp = (u_char *)tlv + sizeof(struct hip_tlv_common) + sizeof(u_int32_t);
796 + for (i = 0; i < 8; i++)
797 + printf("%02x", *cp++);
798 + printf(", encrypted=0x");
799 + hip_hexdump(cp, ntohs(tlv->length) - sizeof(u_int32_t) - 8);
804 +hip_print_param_host_id (const struct hip_tlv_common * tlv)
806 + struct hip_host_id * p = (struct hip_host_id *) tlv;
809 + struct hip_host_id_key_rdata * rdata;
810 + int di_type, di_length;
812 + // di_type = ntohs(p->di_type_length) & 0xf000;
813 + di_type = ntohs(p->di_type_length) >> 12;
814 + di_length = ntohs(p->di_type_length) & 0x0fff;
815 + printf("(HI Length=%d, DI Type-Length=%d (DI-type=%d, DI Length=%d), ",
816 + ntohs(p->hi_length), ntohs(p->di_type_length), di_type, di_length);
818 + /* HOST ID is in RFC2535 KEY RDATA format */
819 + rdata = (struct hip_host_id_key_rdata *)((u_char *)p +
820 + sizeof(struct hip_tlv_common) +
821 + 2 * sizeof(uint16_t));
822 + cp = (u_char *) rdata;
823 + printf("HI: flags=0x%x, protocol=%d, algorithm=%d",
824 + rdata->flags, rdata->protocol, rdata->algorithm);
826 + /* check if algorithm is listed in HIP drafts */
828 + if (! (rdata->algorithm == HIP_HI_DSA || rdata->algorithm == HIP_HI_RSA) ) {
829 + printf(" unknown algorithm");
830 + cp += ntohs(p->hi_length);
834 + if (rdata->algorithm != HIP_HI_DSA) {
835 + printf(" RSA parsing not supported yet");
836 + cp += ntohs(p->hi_length);
840 + printf("(%s)", tok2str(hip_rdata_algorithms, "unknown", rdata->algorithm));
841 + cp = (u_char *)p + sizeof(struct hip_host_id);
842 + t = (u_int8_t) *cp;
843 + printf(" T=%d", t);
844 + if (ntohs(p->length) < (4 + 1 + 20 + 3 * (64 + t * 8))) {
845 + printf(", truncated RDATA)");
849 + printf(",Q=0x"); hip_hexdump(cp, 20);
851 + printf(",P=0x"); hip_hexdump(cp, 64 + t * 8);
853 + printf(",G=0x"); hip_hexdump(cp, 64 + t * 8);
855 + printf(",Y=0x"); hip_hexdump(cp, 64 + t * 8);
859 + hip_hexdump(cp, di_length);
864 +hip_print_param_cert (const struct hip_tlv_common * tlv)
866 + struct hip_cert *p = (struct hip_cert *)tlv;
867 + unsigned char *cert;
870 + printf(" Cert Group=%u", p->cert_group);
871 + printf(", Cert Count=%u", p->cert_count);
872 + printf(", Cert ID=%u", p->cert_id);
873 + printf(", Cert Type=%u", p->cert_type);
875 + /* Calculate the length of the certificate and dump it */
876 + printf(", Certificate=0x");
877 + cert_len = ntohs(tlv->length) - 4;
878 + cert = (((unsigned char *)p) + 4);
879 + hip_hexdump(cert, cert_len);
883 +hip_print_param_notification (const struct hip_tlv_common * tlv)
885 + struct hip_notification * p = (struct hip_notification *) tlv;
886 + printf("(Reserved=%x,Message Type=%u,Notification data=0x",
887 + ntohs(p->reserved), ntohs(p->msgtype));
888 + hip_hexdump((u_char *)p + sizeof(struct hip_tlv_common) +
889 + 2*sizeof(u_int16_t), ntohs(p->length)-2*sizeof(u_int16_t));
894 +hip_print_param_echo_request_signed (const struct hip_tlv_common * tlv)
896 + printf(" Opaque=0x");
897 + hip_hexdump((u_char*)tlv, ntohs(tlv->length));
901 +hip_print_param_echo_response_signed (const struct hip_tlv_common * tlv)
903 + printf(" Opaque=0x");
904 + hip_hexdump((u_char*)tlv, ntohs(tlv->length));
908 +hip_print_param_hmac (const struct hip_tlv_common * tlv)
910 + struct hip_hmac * p = (struct hip_hmac *) tlv;
912 + printf("(hmac data=0x");
913 + hip_hexdump((u_char *)&p->hmac_data,
914 + HIP_LEN_PAD(ntohs(tlv->length)) - sizeof(struct hip_tlv_common));
919 +hip_print_param_hmac_2 (const struct hip_tlv_common * tlv)
921 + struct hip_hmac * p = (struct hip_hmac *) tlv;
923 + printf("(hmac_2 data=0x");
924 + hip_hexdump((u_char *)&p->hmac_data,
925 + HIP_LEN_PAD(ntohs(tlv->length)) - sizeof(struct hip_tlv_common));
930 +hip_print_param_hip_signature_2 (const struct hip_tlv_common * tlv)
932 + struct hip_signature * p = (struct hip_signature *) tlv;
933 + /* draft: same algorithm as in ESP_TRANSFORM */
934 + printf("(algorithm=%s(%u),signature=0x",
935 + tok2str(hip_rdata_algorithms, NULL, p->algorithm), p->algorithm);
936 + hip_hexdump((u_char *)p + sizeof(struct hip_tlv_common) +
937 + sizeof(u_int8_t), ntohs(p->length)-sizeof(u_int8_t));
942 +hip_print_param_hip_signature (const struct hip_tlv_common * tlv)
944 + struct hip_signature * p = (struct hip_signature *) tlv;
945 + /* draft: same algorithm as in ESP_TRANSFORM */
946 + printf("(algorithm=%s(%u),signature=0x",
947 + tok2str(hip_rdata_algorithms, NULL, p->algorithm), p->algorithm);
948 + hip_hexdump((u_char *)p + sizeof(struct hip_tlv_common) +
949 + sizeof(u_int8_t), ntohs(p->length)-sizeof(u_int8_t));
954 +hip_print_param_echo_request_unsigned (const struct hip_tlv_common * tlv)
956 + printf(" Opaque=0x");
957 + hip_hexdump((u_char *)tlv, ntohs(tlv->length));
961 +hip_print_param_echo_response_unsigned (const struct hip_tlv_common * tlv)
963 + printf(" Opaque=0x");
964 + hip_hexdump((u_char*)tlv, ntohs(tlv->length));
968 +hip_print_param_esp_info (const struct hip_tlv_common * tlv)
970 + struct hip_esp_info *p = (struct hip_esp_info *)tlv;
972 + printf(" Reserved=%u", p->reserved);
973 + printf(", KEYMAT Index=0x%x", ntohs(p->keymat_index));
974 + printf(", Old SPI=0x%x", htonl(p->old_spi));
975 + printf(", New SPI=0x%x", htonl(p->new_spi));
979 +hip_print_param_esp_transform (const struct hip_tlv_common * tlv)
981 + struct hip_esp_transform * p = (struct hip_esp_transform *) tlv;
986 + printf("reserved=0x%x,", ntohs(p->reserved));
988 + if (ntohs(p->length) == 0) {
989 + printf("no transforms)");
993 + n = (ntohs(p->length)-sizeof(uint16_t)) / sizeof(u_int16_t);
994 + if (n > HIP_TRANSFORM_ESP_MAX) {
995 + printf("too many Suite IDs (%d))", n);
999 + id = (u_int16_t *) ((u_char *)p + sizeof(uint16_t) + sizeof(struct hip_tlv_common));
1000 + for (i = 1; i <= n; i++, id++) {
1003 + printf("Suite-ID #%d=%s(%d)", i,
1004 + tok2str(hip_esp_transform_types, NULL, ntohs(*id)), ntohs(*id));
1011 +hip_print_param_reg_info (const struct hip_tlv_common * tlv)
1013 + struct hip_reg_info *p = (struct hip_reg_info *)tlv;
1014 + int reg_type_count, i;
1015 + unsigned char * rt;
1017 + printf(" Min lifetime=%u", p->min_lifetime);
1018 + printf(", Max lifetime=%u", p->max_lifetime);
1019 + reg_type_count = ntohs(tlv->length) - 2;
1021 + for (i = 0; i < reg_type_count; i++) {
1022 + printf(", Reg type=0x%x", *rt);
1028 +hip_print_param_reg_request (const struct hip_tlv_common * tlv)
1030 + struct hip_reg_request_response *p = (struct hip_reg_request_response *)tlv;
1031 + int reg_type_count, i;
1032 + unsigned char * rt;
1034 + printf(" Lifetime=%u", p->lifetime);
1035 + reg_type_count = ntohs(tlv->length) - 1;
1037 + for (i = 0; i < reg_type_count; i++) {
1038 + printf(", Reg type=0x%x", *rt);
1044 +hip_print_param_reg_response (const struct hip_tlv_common * tlv)
1046 + struct hip_reg_request_response *p = (struct hip_reg_request_response *)tlv;
1047 + int reg_type_count, i;
1048 + unsigned char * rt;
1050 + printf(" Lifetime=%u", p->lifetime);
1051 + reg_type_count = ntohs(tlv->length) - 1;
1053 + for (i = 0; i < reg_type_count; i++) {
1054 + printf(", Reg type=0x%x", *rt);
1060 +hip_print_param_reg_failed (const struct hip_tlv_common * tlv)
1062 + struct hip_reg_failed *p = (struct hip_reg_failed *)tlv;
1063 + int reg_type_count, i;
1064 + unsigned char * rt;
1066 + printf(" Failure type=%u", p->failure_type);
1067 + reg_type_count = ntohs(tlv->length) - 1;
1069 + for (i = 0; i < reg_type_count; i++) {
1070 + printf(", Reg type=0x%x", *rt);
1076 +hip_print_param_from (const struct hip_tlv_common * tlv)
1078 + struct hip_from *p = (struct hip_from *)tlv;
1080 + (void)printf(" Address=%s ", ip6addr_string(&p->address));
1084 +hip_print_param_rvs_hmac (const struct hip_tlv_common * tlv)
1086 + struct hip_rvs_hmac *p = (struct hip_rvs_hmac *)tlv;
1088 + printf("(hmac data=0x");
1089 + hip_hexdump((u_char *)&p->hmac_data,
1090 + HIP_LEN_PAD(ntohs(tlv->length)) - sizeof(struct hip_tlv_common));
1095 +hip_print_param_via_rvs (const struct hip_tlv_common * tlv)
1097 + struct hip_via_rvs *p = (struct hip_via_rvs *)tlv;
1099 + (void)printf(" Address=%s ", ip6addr_string(&p->address));
1103 +hip_print_param_locator (const struct hip_tlv_common * tlv)
1107 + uint8_t preferred;
1110 + struct hip_locator_info_addr_item *p = NULL;
1111 + struct hip_locator_info_addr_item2 *p2 = NULL;
1113 + p = (struct hip_locator_info_addr_item *)tlv;
1115 + while (offset < htons(tlv->length)) {
1116 + printf("\n Traffic type=%u", p->traffic_type);
1117 + printf(", type=%u", p->locator_type);
1118 + printf(", length=%u", p->locator_length);
1119 + reserved = (p->reserved & HIP_LOCATOR_RESERVED_MASK) >> 1;
1120 + printf(", Reserved=%u", reserved);
1121 + preferred = p->reserved & HIP_LOCATOR_PREFERRED_MASK;
1122 + printf(", Preferred=%u", preferred);
1123 + printf(", Lifetime=0x%x", htonl(p->lifetime));
1125 + type = p->locator_type;
1126 + if (type == 0 || type == 1) {
1127 + (void)printf(" Locator=%s ", ip6addr_string(&p->locator));
1131 + p = (struct hip_locator_info_addr_item *)cp;
1132 + } else if (type == 2) {
1133 + p2 = (struct hip_locator_info_addr_item2 *)p;
1134 + printf(", Transport port=%u", p2->transport_port);
1135 + printf(", Transport protocol=%u", p2->transport_protocol);
1136 + printf(", Kind=%u", p2->kind);
1137 + printf(", Priority=0x%x", htonl(p2->priority));
1138 + printf(", SPI=0x%x", htonl(p2->spi));
1139 + (void)printf(" Locator=%s ", ip6addr_string(&p2->locator));
1143 + p = (struct hip_locator_info_addr_item *)cp;
1149 +hip_print_param_nat_traversal_mode (const struct hip_tlv_common * tlv)
1151 + struct hip_nat_traversal_mode *p = (struct hip_nat_traversal_mode *)tlv;
1156 + printf("reserved=0x%x,", ntohs(p->reserved));
1158 + if (ntohs(p->length) == 0) {
1159 + printf("no transforms)");
1163 + n = (ntohs(p->length)-sizeof(uint16_t)) / sizeof(u_int16_t);
1164 + if (n > HIP_NAT_TRAVERSAL_MODE_MAX) {
1165 + printf("too many Mode IDs (%d))", n);
1169 + id = (u_int16_t *) ((u_char *)p + sizeof(uint16_t) + sizeof(struct hip_tlv_common));
1170 + for (i = 1; i <= n; i++, id++) {
1173 + printf("Mode-ID #%d=%s(%d)", i,
1174 + tok2str(hip_nat_traversal_modes, NULL, ntohs(*id)), ntohs(*id));
1182 +hip_print_param_nat_transaction_pacing (const struct hip_tlv_common * tlv)
1184 + struct hip_transaction_pacing *p = (struct hip_transaction_pacing *)tlv;
1186 + printf(" Min Ta=0x%x", htonl(p->min_ta));
1190 +hip_print_param_reg_from (const struct hip_tlv_common * tlv)
1192 + struct hip_reg_from *p = (struct hip_reg_from *)tlv;
1194 + printf(" Port=%u", ntohs(p->port));
1195 + printf(", Protocol=%u", p->protocol);
1196 + printf(", Reserved=%u", p->reserved);
1197 + (void)printf(" Address=%s ", ip6addr_string(&p->address));
1201 +hip_print_param_relay_from (const struct hip_tlv_common * tlv)
1203 + struct hip_relay_from *p = (struct hip_relay_from *)tlv;
1205 + printf(" Port=%u", ntohs(p->port));
1206 + printf(", Protocol=%u", p->protocol);
1207 + printf(", Reserved=%u", p->reserved);
1208 + (void)printf(" Address=%s ", ip6addr_string(&p->address));
1212 +hip_print_param_relay_to (const struct hip_tlv_common * tlv)
1214 + struct hip_relay_to *p = (struct hip_relay_to *)tlv;
1216 + printf(" Port=%u", ntohs(p->port));
1217 + printf(", Protocol=%u", p->protocol);
1218 + printf(", Reserved=%u", p->reserved);
1219 + (void)printf(" Address=%s ", ip6addr_string(&p->address));
1223 +hip_print_param_unknown (const struct hip_tlv_common *tlv, u_int tlv_len)
1226 + hip_hexdump((u_char *)tlv + sizeof(struct hip_tlv_common),
1227 + ntohs(tlv->length) - 0 * sizeof(struct hip_tlv_common));
1231 +/*******************************************************************************
1232 +* Print a HIP datagram *
1233 +*******************************************************************************/
1236 +hip_print (register const u_char *bp, register u_int length)
1238 + register const struct hip_common *hip;
1239 + register u_int len;
1240 + register const u_char *cp;
1242 + struct tok *token;
1244 + hip = (const struct hip_common *) bp;
1247 + /* CHECK IF HIP HAS THE SAME CASE:
1248 + * The IP6 header is not 16-byte aligned, so copy into a buf. */
1249 + if ((u_long)hip & 15) {
1250 + static u_char *abuf;
1252 + if (abuf == NULL) {
1253 + abuf = malloc(snaplen);
1255 + error("hip_print: malloc");
1257 + memcpy(abuf, hip, min(length, snaplen));
1258 + snapend += abuf - (u_char *)hip;
1260 + hip = (struct hip_common *)abuf;
1265 + if (length < sizeof(struct hip_common)) {
1266 + (void)printf("Truncated - HIP (length=%d)", length);
1269 + if (length > HIP_MAX_PACKET) {
1270 + (void)printf("Oversized HIP (length=%d)", length);
1275 + len = (hip->payload_len+1) << 3;
1277 + (void)printf("Truncated HIP (%d bytes missing!)",
1280 + /* print common header */
1281 + (void)printf("HIP %s > %s: ", ip6addr_string(&hip->hits),
1282 + ip6addr_string(&hip->hitr));
1284 + /* XXTODO print out the fixed shim6 bits */
1287 + (void)printf("len=%d (%d bytes),type=%d,ver_res=0x%x,control=0x%x,"
1288 + "checksum=0x%x (checksum_host=0x%x) ",
1290 + 8 * hip->payload_len,
1293 + ntohs(hip->control),
1295 + ntohs(hip->checksum));
1298 + type = hip->type_hdr;
1300 + /* check that we support the packet type */
1301 + token = hip_types;
1302 + while (token->s) {
1303 + if (token->v == type)
1308 + printf("Unknown packet (type=%d)", type);
1311 + printf("%s", tok2str(hip_types, NULL, type));
1313 + /* print payloads */
1314 + cp = (const u_char *)(hip+1);
1315 + while (cp < snapend) {
1316 + struct hip_tlv_common *tlv;
1317 + u_int tlv_len, tlv_type;
1319 + tlv = (struct hip_tlv_common *) cp;
1320 + tlv_len = HIP_LEN_PAD(sizeof(struct hip_tlv_common) +
1321 + ntohs(((const struct hip_tlv_common *) tlv)->length));
1322 + tlv_type = ntohs(tlv->type);
1326 + if (cp + tlv_len > snapend) {
1327 + printf(" TLV type=%d exceeds packet\n", tlv_type);
1331 + printf(" TLV type=%d,len=%d: %s", tlv_type, tlv_len,
1332 + tok2str(hip_param_types, " Unknown parameter (type=%d)", tlv_type));
1334 + switch (tlv_type) {
1335 + case HIP_PARAM_ESP_INFO:
1336 + hip_print_param_esp_info(tlv);
1338 + case HIP_PARAM_R1_COUNTER:
1339 + hip_print_param_r1_counter(tlv);
1341 + case HIP_PARAM_LOCATOR:
1342 + hip_print_param_locator(tlv);
1344 + case HIP_PARAM_PUZZLE:
1345 + hip_print_param_puzzle(tlv);
1347 + case HIP_PARAM_SOLUTION:
1348 + hip_print_param_solution(tlv);
1350 + case HIP_PARAM_SEQ:
1351 + hip_print_param_seq(tlv);
1353 + case HIP_PARAM_ACK:
1354 + hip_print_param_ack(tlv);
1356 + case HIP_PARAM_DIFFIE_HELLMAN:
1357 + hip_print_param_diffie_hellman(tlv);
1359 + case HIP_PARAM_HIP_TRANSFORM:
1360 + hip_print_param_hip_transform(tlv);
1362 + case HIP_PARAM_NAT_TRAVERSAL_MODE:
1363 + hip_print_param_nat_traversal_mode(tlv);
1365 + case HIP_PARAM_TRANSACTION_PACING:
1366 + hip_print_param_nat_transaction_pacing(tlv);
1368 + case HIP_PARAM_ENCRYPTED:
1369 + hip_print_param_encrypted(tlv);
1371 + case HIP_PARAM_HOST_ID:
1372 + hip_print_param_host_id(tlv);
1374 + case HIP_PARAM_CERT:
1375 + hip_print_param_host_id(tlv);
1377 + case HIP_PARAM_NOTIFICATION:
1378 + hip_print_param_notification(tlv);
1380 + case HIP_PARAM_ECHO_REQUEST_SIGNED:
1381 + hip_print_param_echo_request_signed(tlv);
1383 + case HIP_PARAM_REG_INFO:
1384 + hip_print_param_reg_info(tlv);
1386 + case HIP_PARAM_REG_REQUEST:
1387 + hip_print_param_reg_request(tlv);
1389 + case HIP_PARAM_REG_RESPONSE:
1390 + hip_print_param_reg_response(tlv);
1392 + case HIP_PARAM_REG_FAILED:
1393 + hip_print_param_reg_failed(tlv);
1395 + case HIP_PARAM_REG_FROM:
1396 + hip_print_param_reg_from(tlv);
1398 + case HIP_PARAM_ECHO_RESPONSE_SIGNED:
1399 + hip_print_param_echo_response_signed(tlv);
1401 + case HIP_PARAM_ESP_TRANSFORM:
1402 + hip_print_param_esp_transform(tlv);
1404 + case HIP_PARAM_HMAC:
1405 + hip_print_param_hmac(tlv);
1407 + case HIP_PARAM_HMAC_2:
1408 + hip_print_param_hmac_2(tlv);
1410 + case HIP_PARAM_HIP_SIGNATURE_2:
1411 + hip_print_param_hip_signature_2(tlv);
1413 + case HIP_PARAM_HIP_SIGNATURE:
1414 + hip_print_param_hip_signature(tlv);
1416 + case HIP_PARAM_ECHO_REQUEST_UNSIGNED:
1417 + hip_print_param_echo_request_unsigned(tlv);
1419 + case HIP_PARAM_ECHO_RESPONSE_UNSIGNED:
1420 + hip_print_param_echo_response_unsigned(tlv);
1422 + case HIP_PARAM_RELAY_FROM:
1423 + hip_print_param_relay_from(tlv);
1425 + case HIP_PARAM_RELAY_TO:
1426 + hip_print_param_relay_to(tlv);
1428 + case HIP_PARAM_FROM:
1429 + hip_print_param_from(tlv);
1431 + case HIP_PARAM_RVS_HMAC:
1432 + hip_print_param_rvs_hmac(tlv);
1434 + case HIP_PARAM_VIA_RVS:
1435 + hip_print_param_via_rvs(tlv);
1438 + hip_print_param_unknown(tlv, tlv_len);
1448 + (void)printf("[|hip]");
1450 diff -N -r -u --strip-trailing-cr tcpdump-orig/print-ip6.c tcpdump/print-ip6.c
1451 --- tcpdump-orig/print-ip6.c 2009-05-20 10:29:46.000000000 +0200
1452 +++ tcpdump/print-ip6.c 2009-05-17 22:12:07.000000000 +0200
1453 @@ -220,6 +220,10 @@
1454 rsvp_print(cp, len);
1458 + hip_print(cp, len);
1462 (void)printf("no next header");
1464 diff -N -r -u --strip-trailing-cr tcpdump-orig/print-ip.c tcpdump/print-ip.c
1465 --- tcpdump-orig/print-ip.c 2009-05-20 10:29:46.000000000 +0200
1466 +++ tcpdump/print-ip.c 2009-07-28 01:28:46.000000000 +0200
1470 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
1471 * The Regents of the University of California. All rights reserved.
1472 @@ -519,6 +520,13 @@
1473 pgm_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
1478 + /* hip on top of ip */
1479 + hip_print(ipds->cp, ipds->len);
1484 if ((proto = getprotobynumber(ipds->nh)) != NULL)
1485 ND_PRINT((ndo, " %s", proto->p_name));
1486 diff -N -r -u --strip-trailing-cr tcpdump-orig/print-udp.c tcpdump/print-udp.c
1487 --- tcpdump-orig/print-udp.c 2009-05-20 10:29:46.000000000 +0200
1488 +++ tcpdump/print-udp.c 2009-07-03 13:38:21.000000000 +0200
1490 register const struct ip *ip;
1491 register const u_char *cp;
1492 register const u_char *ep = bp + length;
1493 + register const u_char *phip, *phipmagic;
1494 u_int16_t sport, dport, ulen;
1496 register const struct ip6_hdr *ip6;
1497 @@ -697,7 +698,23 @@
1498 sip_print((const u_char *)(up + 1), length);
1499 else if (ISPORT(SYSLOG_PORT))
1500 syslog_print((const u_char *)(up + 1), length);
1502 + else if (ISPORT(HIP_UDP_PORT))
1504 + /* see draft-ietf-hip-nat-traversal-06 for details */
1505 + phip = (const u_char *)(up+1);
1506 + phipmagic = (const u_char *)(phip+4);
1507 + /* Check the required NULL bytes and jump over them */
1508 + if (htonl(*(phip+3)) == 0)
1509 + hip_print(phip+4, length);
1510 + /* It was not HIP check if it is STUN used by HIP */
1511 + else if (htonl(*(phipmagic+3) == 0x2112A442))
1512 + printf("UDP encapsulated HIP STUN packet\n");
1513 + /* It must be UDP encapsulated ESP */
1515 + printf("UDP encapsulated ESP (HIP) packet\n");
1519 (void)printf("UDP, length %u",
1520 (u_int32_t)(ulen - sizeof(*up)));
1522 diff -N -r -u --strip-trailing-cr tcpdump-orig/udp.h tcpdump/udp.h
1523 --- tcpdump-orig/udp.h 2009-05-20 10:29:46.000000000 +0200
1524 +++ tcpdump/udp.h 2009-05-19 22:49:15.000000000 +0200
1526 #define SFLOW_PORT 6343 /* http://www.sflow.org/developers/specifications.php */
1527 #define LWAPP_DATA_PORT 12222 /* draft-ohara-capwap-lwapp-04.txt */
1528 #define LWAPP_CONTROL_PORT 12223 /* draft-ohara-capwap-lwapp-04.txt */
1529 +#define HIP_UDP_PORT 10500
1532 #define RIPNG_PORT 521 /*XXX*/