]> git.pld-linux.org Git - packages/tcpdump.git/blame - tcpdump-4.0.0-hip.04.patch
- hide -w option for rpmbuild
[packages/tcpdump.git] / tcpdump-4.0.0-hip.04.patch
CommitLineData
43eea335
TP
1diff -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
4@@ -158,7 +158,7 @@
5 --disable-ipv6 disable ipv6 support],
6 [ case "$enableval" in
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"
10 AC_DEFINE(INET6)
11 ipv6=yes
12 ;;
13diff -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
16@@ -336,6 +336,7 @@
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);
21 #endif /*INET6*/
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);
24diff -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
27@@ -55,6 +55,7 @@
28 { IPPROTO_PGM, "PGM" },
29 { IPPROTO_SCTP, "SCTP" },
30 { IPPROTO_MOBILITY, "Mobility" },
31+ { IPPROTO_HIP, "HIP" },
32 { 0, NULL }
33 };
34
35diff -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
38@@ -142,3 +142,6 @@
39 #ifndef IPPROTO_MOBILITY
40 #define IPPROTO_MOBILITY 135
41 #endif
42+#ifndef IPPROTO_HIP
43+#define IPPROTO_HIP 139
44+#endif
45diff -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
48@@ -76,7 +76,7 @@
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 \
57diff -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
60@@ -0,0 +1,1389 @@
61+/*
62+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
63+ * The Regents of the University of California. All rights reserved.
64+ *
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.
80+ *
81+ * Support for dissecting Host Identity Protocol (HIP)
82+ * RFCs 5201 - 5206, draft-ietf-hip-cert-00, draft-ietf-hip-nat-traversal-06
83+ *
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>
88+ *
89+ */
90+
91+#ifdef HAVE_CONFIG_H
92+#include "config.h"
93+#endif
94+
95+#include <sys/param.h>
96+#include <sys/time.h>
97+#include <sys/types.h>
98+#include <sys/socket.h>
99+
100+#include <netinet/in.h>
101+
102+#include <stdio.h>
103+#include <stdlib.h>
104+#include <unistd.h>
105+#include <string.h>
106+
107+#include <tcpdump-stdinc.h>
108+
109+#include "interface.h"
110+#include "extract.h"
111+#include "addrtoname.h"
112+
113+#define HIP_HI_DSA 3
114+#define HIP_HI_RSA 5
115+
116+/* RFC 5201 */
117+#define HIP_I1 1
118+#define HIP_R1 2
119+#define HIP_I2 3
120+#define HIP_R2 4
121+#define HIP_UPDATE 16
122+#define HIP_NOTIFY 17
123+#define HIP_CLOSE 18
124+#define HIP_CLOSE_ACK 19
125+
126+/* RFC 5202 */
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
134+
135+/* RFC 5201 */
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
143+
144+/**/
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
148+
149+/* HIP TLV parameters listed in order of RFCs */
150+
151+/* RFC 5201 */
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
173+/* RFC 5202 */
174+#define HIP_PARAM_ESP_INFO 65
175+#define HIP_PARAM_ESP_TRANSFORM 4095
176+/* RFC 5203 */
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
181+/* RFC 5204 */
182+#define HIP_PARAM_FROM 65498
183+#define HIP_PARAM_RVS_HMAC 65500
184+#define HIP_PARAM_VIA_RVS 65502
185+/* RFC 5206 */
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
193+
194+/* Bit masks */
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
206+
207+#define HI_HDR_FLAGS_MASK 0xFFFF0000
208+#define HI_HDR_PROTO_MASK 0x0000FF00
209+#define HI_HDR_ALG_MASK 0x000000FF
210+
211+#define HIP_LOCATOR_RESERVED_MASK 0xFE
212+#define HIP_LOCATOR_PREFERRED_MASK 0x01
213+
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
219+
220+#define HIP_AH_SHA_LEN 20
221+
222+typedef uint16_t hip_tlv_type_t;
223+typedef uint16_t hip_tlv_len_t;
224+
225+/* Returns length of TLV option (contents) with padding. */
226+#define HIP_LEN_PAD(len) \
227+ ((((len) & 0x07) == 0) ? (len) : ((((len) >> 3) << 3) + 8))
228+
229+/* Structs */
230+struct hip_common {
231+ uint8_t payload_proto;
232+ uint8_t payload_len;
233+ uint8_t type_hdr;
234+ uint8_t ver_res;
235+
236+ uint16_t checksum;
237+ uint16_t control;
238+
239+ struct in6_addr hits; /* Sender HIT */
240+ struct in6_addr hitr; /* Receiver HIT */
241+} __attribute__ ((packed));
242+
243+struct hip_tlv_common {
244+ hip_tlv_type_t type;
245+ hip_tlv_len_t length;
246+} __attribute__ ((packed));
247+
248+struct hip_r1_counter {
249+ hip_tlv_type_t type;
250+ hip_tlv_len_t length;
251+
252+ uint32_t reserved;
253+ uint64_t generation;
254+} __attribute__ ((packed));
255+
256+struct hip_puzzle {
257+ hip_tlv_type_t type;
258+ hip_tlv_len_t length;
259+
260+ uint8_t K;
261+ uint8_t lifetime;
262+ uint8_t opaque[HIP_PUZZLE_OPAQUE_LEN];
263+ uint64_t I;
264+} __attribute__ ((packed));
265+
266+struct hip_solution {
267+ hip_tlv_type_t type;
268+ hip_tlv_len_t length;
269+
270+ uint8_t K;
271+ uint8_t reserved;
272+ uint8_t opaque[HIP_PUZZLE_OPAQUE_LEN];
273+ uint64_t I;
274+ uint64_t J;
275+} __attribute__ ((packed));
276+
277+struct hip_seq {
278+ hip_tlv_type_t type;
279+ hip_tlv_len_t length;
280+
281+ uint32_t update_id;
282+} __attribute__ ((packed));
283+
284+struct hip_ack {
285+ hip_tlv_type_t type;
286+ hip_tlv_len_t length;
287+
288+ uint32_t peer_update_id; /* n items */
289+} __attribute__ ((packed));
290+
291+struct hip_diffie_hellman {
292+ hip_tlv_type_t type;
293+ hip_tlv_len_t length;
294+
295+ uint8_t group_id;
296+ /* fixed part ends */
297+ uint8_t public_value[0];
298+} __attribute__ ((packed));
299+
300+typedef uint16_t hip_transform_suite_t;
301+
302+struct hip_hip_transform {
303+ hip_tlv_type_t type;
304+ hip_tlv_len_t length;
305+
306+ hip_transform_suite_t suite_id[HIP_TRANSFORM_HIP_MAX];
307+} __attribute__ ((packed));
308+
309+struct hip_encrypted_aes_sha1 {
310+ hip_tlv_type_t type;
311+ hip_tlv_len_t length;
312+
313+ uint32_t reserved;
314+ uint8_t iv[16];
315+ /* fixed part ends */
316+} __attribute__ ((packed));
317+
318+struct hip_encrypted_3des_sha1 {
319+ hip_tlv_type_t type;
320+ hip_tlv_len_t length;
321+
322+ uint32_t reserved;
323+ uint8_t iv[8];
324+ /* fixed part ends */
325+} __attribute__ ((packed));
326+
327+struct hip_encrypted_null_sha1 {
328+ hip_tlv_type_t type;
329+ hip_tlv_len_t length;
330+
331+ uint32_t reserved;
332+ /* fixed part ends */
333+} __attribute__ ((packed));
334+
335+struct hip_host_id_key_rdata {
336+ uint16_t flags;
337+ uint8_t protocol;
338+ uint8_t algorithm;
339+
340+ /* fixed part ends */
341+} __attribute__ ((packed));
342+
343+struct hip_host_id {
344+ hip_tlv_type_t type;
345+ hip_tlv_len_t length;
346+
347+ uint16_t hi_length;
348+ uint16_t di_type_length;
349+
350+ struct hip_host_id_key_rdata rdata;
351+ /* fixed part ends */
352+} __attribute__ ((packed));
353+
354+struct hip_cert {
355+ hip_tlv_type_t type;
356+ hip_tlv_len_t length;
357+
358+ uint8_t cert_group;
359+ uint8_t cert_count;
360+ uint8_t cert_id;
361+ uint8_t cert_type;
362+ /* end of fixed part */
363+} __attribute__ ((packed));
364+
365+struct hip_notification {
366+ hip_tlv_type_t type;
367+ hip_tlv_len_t length;
368+
369+ uint16_t reserved;
370+ uint16_t msgtype;
371+ /* end of fixed part */
372+} __attribute__ ((packed));
373+
374+struct hip_echo_request {
375+ hip_tlv_type_t type;
376+ hip_tlv_len_t length;
377+ /* opaque */
378+} __attribute__ ((packed));
379+
380+struct hip_echo_response {
381+ hip_tlv_type_t type;
382+ hip_tlv_len_t length;
383+ /* opaque */
384+} __attribute__ ((packed));
385+
386+struct hip_hmac {
387+ hip_tlv_type_t type;
388+ hip_tlv_len_t length;
389+
390+ uint8_t hmac_data[HIP_AH_SHA_LEN];
391+} __attribute__ ((packed));
392+
393+/* HMAC2 is the same as above */
394+
395+/* HIP SIGNATURE2 is the same as below */
396+
397+struct hip_signature {
398+ hip_tlv_type_t type;
399+ hip_tlv_len_t length;
400+
401+ uint8_t algorithm;
402+ uint8_t signature[0]; /* variable length */
403+ /* fixed part end */
404+} __attribute__ ((packed));
405+
406+/* HIP_ECHO_REQUEST_UNSIGNED same as signed version above */
407+
408+/* HIP_ECHO_RESPONSE_UNSIGNED same as signed version above */
409+
410+struct hip_esp_info {
411+ hip_tlv_type_t type;
412+ hip_tlv_len_t length;
413+
414+ uint16_t reserved;
415+ uint16_t keymat_index;
416+ uint32_t old_spi;
417+ uint32_t new_spi;
418+} __attribute__ ((packed));
419+
420+struct hip_esp_transform {
421+ hip_tlv_type_t type;
422+ hip_tlv_len_t length;
423+
424+ uint16_t reserved;
425+
426+ hip_transform_suite_t suite_id[HIP_TRANSFORM_ESP_MAX];
427+} __attribute__ ((packed));
428+
429+struct hip_reg_info {
430+ hip_tlv_type_t type;
431+ hip_tlv_len_t length;
432+
433+ uint8_t min_lifetime;
434+ uint8_t max_lifetime;
435+
436+ uint8_t reg_type[0]; /* Variable */
437+} __attribute__ ((packed));
438+
439+struct hip_reg_request_response {
440+ hip_tlv_type_t type;
441+ hip_tlv_len_t length;
442+
443+ uint8_t lifetime;
444+ uint8_t reg_type[0]; /* Variable */
445+} __attribute__ ((packed));
446+
447+/* REG_REQUEST is exactly like RESPONSE see above */
448+
449+struct hip_reg_failed {
450+ hip_tlv_type_t type;
451+ hip_tlv_len_t length;
452+
453+ uint8_t failure_type;
454+ uint8_t reg_type[0]; /* Variable */
455+} __attribute__ ((packed));
456+
457+struct hip_from {
458+ hip_tlv_type_t type;
459+ hip_tlv_len_t length;
460+ uint8_t address[16];
461+} __attribute__ ((packed));
462+
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));
468+
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));
475+
476+/* Type 0 and 1 */
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;
483+ uint8_t reserved;
484+ uint32_t lifetime;
485+ /* end of fixed part - locator of arbitrary length follows but
486+ currently support only IPv6 */
487+ uint8_t locator[16];
488+} __attribute__ ((packed));
489+
490+/* Type 2 */
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;
497+ uint8_t reserved;
498+ uint32_t lifetime;
499+ uint16_t transport_port;
500+ uint8_t transport_protocol;
501+ uint8_t kind;
502+ uint32_t priority;
503+ uint32_t spi;
504+ /* end of fixed part - locator of arbitrary length follows but
505+ currently support only IPv6 */
506+ uint8_t locator[16];
507+} __attribute__ ((packed));
508+
509+struct hip_nat_traversal_mode {
510+ hip_tlv_type_t type;
511+ hip_tlv_len_t length;
512+
513+ uint16_t reserved;
514+
515+ hip_transform_suite_t suite_id[HIP_NAT_TRAVERSAL_MODE_MAX];
516+} __attribute__ ((packed));
517+
518+struct hip_transaction_pacing {
519+ hip_tlv_type_t type;
520+ hip_tlv_len_t length;
521+
522+ uint32_t min_ta;
523+} __attribute__ ((packed));
524+
525+struct hip_reg_from {
526+ hip_tlv_type_t type;
527+ hip_tlv_len_t length;
528+
529+ uint16_t port;
530+ uint8_t protocol;
531+ uint8_t reserved;
532+ uint8_t address[16];
533+} __attribute__ ((packed));
534+
535+struct hip_relay_from {
536+ hip_tlv_type_t type;
537+ hip_tlv_len_t length;
538+
539+ uint16_t port;
540+ uint8_t protocol;
541+ uint8_t reserved;
542+ uint8_t address[16];
543+} __attribute__ ((packed));
544+
545+struct hip_relay_to {
546+ hip_tlv_type_t type;
547+ hip_tlv_len_t length;
548+
549+ uint16_t port;
550+ uint8_t protocol;
551+ uint8_t reserved;
552+ uint8_t address[16];
553+} __attribute__ ((packed));
554+
555+/*******************************************************************************
556+* Token arrays *
557+*******************************************************************************/
558+
559+static struct tok hip_types[] = {
560+ { HIP_I1, "I1" },
561+ { HIP_R1, "R1" },
562+ { HIP_I2, "I2" },
563+ { HIP_R2, "R2" },
564+ { HIP_UPDATE, "UPDATE" },
565+ { HIP_NOTIFY, "NOTIFY" },
566+ { HIP_CLOSE, "CLOSE" },
567+ { HIP_CLOSE_ACK, "CLOSE_ACK" },
568+ { 0, NULL }
569+};
570+
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" },
606+ { 0, NULL }
607+};
608+
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" },
617+ { 0, NULL }
618+};
619+
620+#define hip_hip_transform_types hip_esp_transform_types
621+
622+static struct tok hip_rdata_algorithms[] = {
623+ { HIP_HI_DSA, "DSA" },
624+ { HIP_HI_RSA, "RSA" },
625+ { 0, NULL }
626+};
627+
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)" },
636+ { 0, NULL }
637+};
638+
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" },
643+ { 0, NULL }
644+};
645+
646+/*******************************************************************************
647+* Tool functions *
648+*******************************************************************************/
649+
650+void
651+hip_hexdump(u_char *data, int len)
652+{
653+ int i;
654+ for (i = 0; i < len; i++)
655+ printf("%02x", data[i]);
656+}
657+
658+/* supports only hex print, modified from print_int64 in print-nfs.c */
659+static void
660+hip_print_int64_hex (const u_char *dp, int hostorder)
661+{
662+ if (hostorder)
663+ printf("0x%" PRIx64, EXTRACT_LE_64BITS(dp));
664+ else
665+ printf("0x%" PRIx64, EXTRACT_64BITS(dp));
666+}
667+
668+/*******************************************************************************
669+* Dissectors for HIP params *
670+*******************************************************************************/
671+
672+void
673+hip_print_param_r1_counter (const struct hip_tlv_common * tlv)
674+{
675+ struct hip_r1_counter *p = (struct hip_r1_counter *) tlv;
676+
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);
682+
683+}
684+
685+void
686+hip_print_param_puzzle (const struct hip_tlv_common * tlv)
687+{
688+ struct hip_puzzle *p = (struct hip_puzzle *) tlv;
689+
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);
696+ printf(")");
697+}
698+
699+void
700+hip_print_param_solution (const struct hip_tlv_common * tlv)
701+{
702+ struct hip_solution * p = (struct hip_solution *) tlv;
703+
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);
714+ printf(")");
715+}
716+
717+void
718+hip_print_param_seq (const struct hip_tlv_common * tlv)
719+{
720+ struct hip_seq * p = (struct hip_seq *) tlv;
721+
722+ printf("(Update ID=%u)", ntohl(p->update_id));
723+}
724+
725+void
726+hip_print_param_ack (const struct hip_tlv_common * tlv)
727+{
728+ struct hip_ack * p = (struct hip_ack *) tlv;
729+ size_t n, i;
730+ uint32_t * peer_update_id;
731+
732+ if (ntohs(p->length) % sizeof(uint32_t))
733+ return;
734+
735+ n = ntohs(p->length) / sizeof(uint32_t);
736+ peer_update_id = (uint32_t *) ((void *)p + sizeof(struct hip_tlv_common));
737+ printf("(");
738+ for (i = 0; i < n; i++, peer_update_id++) {
739+ if (i) printf(",");
740+ printf("peer Update ID=%u", ntohl(* peer_update_id));
741+ }
742+ printf(")");
743+}
744+
745+void
746+hip_print_param_diffie_hellman (const struct hip_tlv_common * tlv)
747+{
748+ struct hip_diffie_hellman * p = (struct hip_diffie_hellman *) tlv;
749+
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));
754+ printf(")");
755+
756+}
757+
758+void
759+hip_print_param_hip_transform (const struct hip_tlv_common * tlv)
760+{
761+ struct hip_hip_transform * p = (struct hip_hip_transform *) tlv;
762+ u_int16_t *id;
763+ int i, n;
764+
765+ printf("(");
766+ if (ntohs(p->length) == 0) {
767+ printf("no transforms)");
768+ return;
769+ }
770+
771+ n = ntohs(p->length) / sizeof(u_int16_t);
772+ if (n > HIP_TRANSFORM_HIP_MAX) {
773+ printf("too many Transform IDs (%d))", n);
774+ return;
775+ }
776+
777+ id = (u_int16_t *) ((u_char *)p + sizeof(struct hip_tlv_common));
778+ for (i = 1; i <= n; i++, id++) {
779+ if (i > 1)
780+ printf(",");
781+ printf("Transform ID #%d=%s(%d)", i,
782+ tok2str(hip_hip_transform_types, NULL, ntohs(* id)), ntohs(* id));
783+ }
784+
785+ printf(")");
786+}
787+
788+void
789+hip_print_param_encrypted (const struct hip_tlv_common * tlv)
790+{
791+ int i;
792+ u_char *cp;
793+
794+ cp = (u_char *)tlv + sizeof(struct hip_tlv_common) + sizeof(u_int32_t);
795+ printf("(IV=0x");
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);
800+ printf(")");
801+}
802+
803+void
804+hip_print_param_host_id (const struct hip_tlv_common * tlv)
805+{
806+ struct hip_host_id * p = (struct hip_host_id *) tlv;
807+ u_int8_t t;
808+ u_char * cp;
809+ struct hip_host_id_key_rdata * rdata;
810+ int di_type, di_length;
811+
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);
817+
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);
825+
826+ /* check if algorithm is listed in HIP drafts */
827+ /* 3=DSA, 5=RSA */
828+ if (! (rdata->algorithm == HIP_HI_DSA || rdata->algorithm == HIP_HI_RSA) ) {
829+ printf(" unknown algorithm");
830+ cp += ntohs(p->hi_length);
831+ goto print_di;
832+ }
833+
834+ if (rdata->algorithm != HIP_HI_DSA) {
835+ printf(" RSA parsing not supported yet");
836+ cp += ntohs(p->hi_length);
837+ goto print_di;
838+ }
839+
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)");
846+ goto print_di;
847+ }
848+ cp++;
849+ printf(",Q=0x"); hip_hexdump(cp, 20);
850+ cp += 20;
851+ printf(",P=0x"); hip_hexdump(cp, 64 + t * 8);
852+ cp += 64 + t * 8;
853+ printf(",G=0x"); hip_hexdump(cp, 64 + t * 8);
854+ cp += 64 + t * 8;
855+ printf(",Y=0x"); hip_hexdump(cp, 64 + t * 8);
856+
857+ print_di:
858+ printf(" DI=0x");
859+ hip_hexdump(cp, di_length);
860+ printf(")");
861+}
862+
863+void
864+hip_print_param_cert (const struct hip_tlv_common * tlv)
865+{
866+ struct hip_cert *p = (struct hip_cert *)tlv;
867+ unsigned char *cert;
868+ int cert_len;
869+
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);
874+
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);
880+}
881+
882+void
883+hip_print_param_notification (const struct hip_tlv_common * tlv)
884+{
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));
890+ printf(")");
891+}
892+
893+void
894+hip_print_param_echo_request_signed (const struct hip_tlv_common * tlv)
895+{
896+ printf(" Opaque=0x");
897+ hip_hexdump((u_char*)tlv, ntohs(tlv->length));
898+}
899+
900+void
901+hip_print_param_echo_response_signed (const struct hip_tlv_common * tlv)
902+{
903+ printf(" Opaque=0x");
904+ hip_hexdump((u_char*)tlv, ntohs(tlv->length));
905+}
906+
907+void
908+hip_print_param_hmac (const struct hip_tlv_common * tlv)
909+{
910+ struct hip_hmac * p = (struct hip_hmac *) tlv;
911+
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));
915+ printf(")");
916+}
917+
918+void
919+hip_print_param_hmac_2 (const struct hip_tlv_common * tlv)
920+{
921+ struct hip_hmac * p = (struct hip_hmac *) tlv;
922+
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));
926+ printf(")");
927+}
928+
929+void
930+hip_print_param_hip_signature_2 (const struct hip_tlv_common * tlv)
931+{
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));
938+ printf(")");
939+}
940+
941+void
942+hip_print_param_hip_signature (const struct hip_tlv_common * tlv)
943+{
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));
950+ printf(")");
951+}
952+
953+void
954+hip_print_param_echo_request_unsigned (const struct hip_tlv_common * tlv)
955+{
956+ printf(" Opaque=0x");
957+ hip_hexdump((u_char *)tlv, ntohs(tlv->length));
958+}
959+
960+void
961+hip_print_param_echo_response_unsigned (const struct hip_tlv_common * tlv)
962+{
963+ printf(" Opaque=0x");
964+ hip_hexdump((u_char*)tlv, ntohs(tlv->length));
965+}
966+
967+void
968+hip_print_param_esp_info (const struct hip_tlv_common * tlv)
969+{
970+ struct hip_esp_info *p = (struct hip_esp_info *)tlv;
971+
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));
976+}
977+
978+void
979+hip_print_param_esp_transform (const struct hip_tlv_common * tlv)
980+{
981+ struct hip_esp_transform * p = (struct hip_esp_transform *) tlv;
982+ int i, n;
983+ u_int16_t *id;
984+
985+ printf("(");
986+ printf("reserved=0x%x,", ntohs(p->reserved));
987+
988+ if (ntohs(p->length) == 0) {
989+ printf("no transforms)");
990+ return;
991+ }
992+
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);
996+ return;
997+ }
998+
999+ id = (u_int16_t *) ((u_char *)p + sizeof(uint16_t) + sizeof(struct hip_tlv_common));
1000+ for (i = 1; i <= n; i++, id++) {
1001+ if (i > 1)
1002+ printf(",");
1003+ printf("Suite-ID #%d=%s(%d)", i,
1004+ tok2str(hip_esp_transform_types, NULL, ntohs(*id)), ntohs(*id));
1005+ }
1006+
1007+ printf(")");
1008+}
1009+
1010+void
1011+hip_print_param_reg_info (const struct hip_tlv_common * tlv)
1012+{
1013+ struct hip_reg_info *p = (struct hip_reg_info *)tlv;
1014+ int reg_type_count, i;
1015+ unsigned char * rt;
1016+
1017+ printf(" Min lifetime=%u", p->min_lifetime);
1018+ printf(", Max lifetime=%u", p->max_lifetime);
1019+ reg_type_count = ntohs(tlv->length) - 2;
1020+ rt = p->reg_type;
1021+ for (i = 0; i < reg_type_count; i++) {
1022+ printf(", Reg type=0x%x", *rt);
1023+ rt++;
1024+ }
1025+}
1026+
1027+void
1028+hip_print_param_reg_request (const struct hip_tlv_common * tlv)
1029+{
1030+ struct hip_reg_request_response *p = (struct hip_reg_request_response *)tlv;
1031+ int reg_type_count, i;
1032+ unsigned char * rt;
1033+
1034+ printf(" Lifetime=%u", p->lifetime);
1035+ reg_type_count = ntohs(tlv->length) - 1;
1036+ rt = p->reg_type;
1037+ for (i = 0; i < reg_type_count; i++) {
1038+ printf(", Reg type=0x%x", *rt);
1039+ rt++;
1040+ }
1041+}
1042+
1043+void
1044+hip_print_param_reg_response (const struct hip_tlv_common * tlv)
1045+{
1046+ struct hip_reg_request_response *p = (struct hip_reg_request_response *)tlv;
1047+ int reg_type_count, i;
1048+ unsigned char * rt;
1049+
1050+ printf(" Lifetime=%u", p->lifetime);
1051+ reg_type_count = ntohs(tlv->length) - 1;
1052+ rt = p->reg_type;
1053+ for (i = 0; i < reg_type_count; i++) {
1054+ printf(", Reg type=0x%x", *rt);
1055+ rt++;
1056+ }
1057+}
1058+
1059+void
1060+hip_print_param_reg_failed (const struct hip_tlv_common * tlv)
1061+{
1062+ struct hip_reg_failed *p = (struct hip_reg_failed *)tlv;
1063+ int reg_type_count, i;
1064+ unsigned char * rt;
1065+
1066+ printf(" Failure type=%u", p->failure_type);
1067+ reg_type_count = ntohs(tlv->length) - 1;
1068+ rt = p->reg_type;
1069+ for (i = 0; i < reg_type_count; i++) {
1070+ printf(", Reg type=0x%x", *rt);
1071+ rt++;
1072+ }
1073+}
1074+
1075+void
1076+hip_print_param_from (const struct hip_tlv_common * tlv)
1077+{
1078+ struct hip_from *p = (struct hip_from *)tlv;
1079+
1080+ (void)printf(" Address=%s ", ip6addr_string(&p->address));
1081+}
1082+
1083+void
1084+hip_print_param_rvs_hmac (const struct hip_tlv_common * tlv)
1085+{
1086+ struct hip_rvs_hmac *p = (struct hip_rvs_hmac *)tlv;
1087+
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));
1091+ printf(")");
1092+}
1093+
1094+void
1095+hip_print_param_via_rvs (const struct hip_tlv_common * tlv)
1096+{
1097+ struct hip_via_rvs *p = (struct hip_via_rvs *)tlv;
1098+
1099+ (void)printf(" Address=%s ", ip6addr_string(&p->address));
1100+}
1101+
1102+void
1103+hip_print_param_locator (const struct hip_tlv_common * tlv)
1104+{
1105+ uint8_t type;
1106+ uint8_t reserved;
1107+ uint8_t preferred;
1108+ int offset = 0;
1109+ char * cp = NULL;
1110+ struct hip_locator_info_addr_item *p = NULL;
1111+ struct hip_locator_info_addr_item2 *p2 = NULL;
1112+
1113+ p = (struct hip_locator_info_addr_item *)tlv;
1114+
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));
1124+
1125+ type = p->locator_type;
1126+ if (type == 0 || type == 1) {
1127+ (void)printf(" Locator=%s ", ip6addr_string(&p->locator));
1128+ offset += 24;
1129+ cp = (char *)p;
1130+ cp += 24;
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));
1140+ offset += 36;
1141+ cp = (char *)p;
1142+ cp += 36;
1143+ p = (struct hip_locator_info_addr_item *)cp;
1144+ }
1145+ }
1146+}
1147+
1148+void
1149+hip_print_param_nat_traversal_mode (const struct hip_tlv_common * tlv)
1150+{
1151+ struct hip_nat_traversal_mode *p = (struct hip_nat_traversal_mode *)tlv;
1152+ int i, n;
1153+ u_int16_t *id;
1154+
1155+ printf("(");
1156+ printf("reserved=0x%x,", ntohs(p->reserved));
1157+
1158+ if (ntohs(p->length) == 0) {
1159+ printf("no transforms)");
1160+ return;
1161+ }
1162+
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);
1166+ return;
1167+ }
1168+
1169+ id = (u_int16_t *) ((u_char *)p + sizeof(uint16_t) + sizeof(struct hip_tlv_common));
1170+ for (i = 1; i <= n; i++, id++) {
1171+ if (i > 1)
1172+ printf(",");
1173+ printf("Mode-ID #%d=%s(%d)", i,
1174+ tok2str(hip_nat_traversal_modes, NULL, ntohs(*id)), ntohs(*id));
1175+ }
1176+
1177+ printf(")");
1178+
1179+}
1180+
1181+void
1182+hip_print_param_nat_transaction_pacing (const struct hip_tlv_common * tlv)
1183+{
1184+ struct hip_transaction_pacing *p = (struct hip_transaction_pacing *)tlv;
1185+
1186+ printf(" Min Ta=0x%x", htonl(p->min_ta));
1187+}
1188+
1189+void
1190+hip_print_param_reg_from (const struct hip_tlv_common * tlv)
1191+{
1192+ struct hip_reg_from *p = (struct hip_reg_from *)tlv;
1193+
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));
1198+}
1199+
1200+void
1201+hip_print_param_relay_from (const struct hip_tlv_common * tlv)
1202+{
1203+ struct hip_relay_from *p = (struct hip_relay_from *)tlv;
1204+
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));
1209+}
1210+
1211+void
1212+hip_print_param_relay_to (const struct hip_tlv_common * tlv)
1213+{
1214+ struct hip_relay_to *p = (struct hip_relay_to *)tlv;
1215+
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));
1220+}
1221+
1222+void
1223+hip_print_param_unknown (const struct hip_tlv_common *tlv, u_int tlv_len)
1224+{
1225+ printf("(0x");
1226+ hip_hexdump((u_char *)tlv + sizeof(struct hip_tlv_common),
1227+ ntohs(tlv->length) - 0 * sizeof(struct hip_tlv_common));
1228+ printf(")");
1229+}
1230+
1231+/*******************************************************************************
1232+* Print a HIP datagram *
1233+*******************************************************************************/
1234+
1235+void
1236+hip_print (register const u_char *bp, register u_int length)
1237+{
1238+ register const struct hip_common *hip;
1239+ register u_int len;
1240+ register const u_char *cp;
1241+ int type;
1242+ struct tok *token;
1243+
1244+ hip = (const struct hip_common *) bp;
1245+
1246+#ifdef LBL_ALIGN
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;
1251+
1252+ if (abuf == NULL) {
1253+ abuf = malloc(snaplen);
1254+ if (abuf == NULL)
1255+ error("hip_print: malloc");
1256+ }
1257+ memcpy(abuf, hip, min(length, snaplen));
1258+ snapend += abuf - (u_char *)hip;
1259+ packetp = abuf;
1260+ hip = (struct hip_common *)abuf;
1261+ bp = abuf;
1262+ }
1263+#endif
1264+ TCHECK(*hip);
1265+ if (length < sizeof(struct hip_common)) {
1266+ (void)printf("Truncated - HIP (length=%d)", length);
1267+ return;
1268+ }
1269+ if (length > HIP_MAX_PACKET) {
1270+ (void)printf("Oversized HIP (length=%d)", length);
1271+ return;
1272+
1273+ }
1274+
1275+ len = (hip->payload_len+1) << 3;
1276+ if (length < len)
1277+ (void)printf("Truncated HIP (%d bytes missing!)",
1278+ len - length);
1279+
1280+ /* print common header */
1281+ (void)printf("HIP %s > %s: ", ip6addr_string(&hip->hits),
1282+ ip6addr_string(&hip->hitr));
1283+
1284+ /* XXTODO print out the fixed shim6 bits */
1285+
1286+ if (vflag) {
1287+ (void)printf("len=%d (%d bytes),type=%d,ver_res=0x%x,control=0x%x,"
1288+ "checksum=0x%x (checksum_host=0x%x) ",
1289+ hip->payload_len,
1290+ 8 * hip->payload_len,
1291+ hip->type_hdr,
1292+ hip->ver_res,
1293+ ntohs(hip->control),
1294+ hip->checksum,
1295+ ntohs(hip->checksum));
1296+ }
1297+
1298+ type = hip->type_hdr;
1299+
1300+ /* check that we support the packet type */
1301+ token = hip_types;
1302+ while (token->s) {
1303+ if (token->v == type)
1304+ break;
1305+ token++;
1306+ }
1307+ if (!token->s) {
1308+ printf("Unknown packet (type=%d)", type);
1309+ return;
1310+ }
1311+ printf("%s", tok2str(hip_types, NULL, type));
1312+ if (vflag > 1) {
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;
1318+
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);
1323+
1324+ printf("\n");
1325+
1326+ if (cp + tlv_len > snapend) {
1327+ printf(" TLV type=%d exceeds packet\n", tlv_type);
1328+ goto trunc;
1329+ }
1330+
1331+ printf(" TLV type=%d,len=%d: %s", tlv_type, tlv_len,
1332+ tok2str(hip_param_types, " Unknown parameter (type=%d)", tlv_type));
1333+ if (vflag > 2) {
1334+ switch (tlv_type) {
1335+ case HIP_PARAM_ESP_INFO:
1336+ hip_print_param_esp_info(tlv);
1337+ break;
1338+ case HIP_PARAM_R1_COUNTER:
1339+ hip_print_param_r1_counter(tlv);
1340+ break;
1341+ case HIP_PARAM_LOCATOR:
1342+ hip_print_param_locator(tlv);
1343+ break;
1344+ case HIP_PARAM_PUZZLE:
1345+ hip_print_param_puzzle(tlv);
1346+ break;
1347+ case HIP_PARAM_SOLUTION:
1348+ hip_print_param_solution(tlv);
1349+ break;
1350+ case HIP_PARAM_SEQ:
1351+ hip_print_param_seq(tlv);
1352+ break;
1353+ case HIP_PARAM_ACK:
1354+ hip_print_param_ack(tlv);
1355+ break;
1356+ case HIP_PARAM_DIFFIE_HELLMAN:
1357+ hip_print_param_diffie_hellman(tlv);
1358+ break;
1359+ case HIP_PARAM_HIP_TRANSFORM:
1360+ hip_print_param_hip_transform(tlv);
1361+ break;
1362+ case HIP_PARAM_NAT_TRAVERSAL_MODE:
1363+ hip_print_param_nat_traversal_mode(tlv);
1364+ break;
1365+ case HIP_PARAM_TRANSACTION_PACING:
1366+ hip_print_param_nat_transaction_pacing(tlv);
1367+ break;
1368+ case HIP_PARAM_ENCRYPTED:
1369+ hip_print_param_encrypted(tlv);
1370+ break;
1371+ case HIP_PARAM_HOST_ID:
1372+ hip_print_param_host_id(tlv);
1373+ break;
1374+ case HIP_PARAM_CERT:
1375+ hip_print_param_host_id(tlv);
1376+ break;
1377+ case HIP_PARAM_NOTIFICATION:
1378+ hip_print_param_notification(tlv);
1379+ break;
1380+ case HIP_PARAM_ECHO_REQUEST_SIGNED:
1381+ hip_print_param_echo_request_signed(tlv);
1382+ break;
1383+ case HIP_PARAM_REG_INFO:
1384+ hip_print_param_reg_info(tlv);
1385+ break;
1386+ case HIP_PARAM_REG_REQUEST:
1387+ hip_print_param_reg_request(tlv);
1388+ break;
1389+ case HIP_PARAM_REG_RESPONSE:
1390+ hip_print_param_reg_response(tlv);
1391+ break;
1392+ case HIP_PARAM_REG_FAILED:
1393+ hip_print_param_reg_failed(tlv);
1394+ break;
1395+ case HIP_PARAM_REG_FROM:
1396+ hip_print_param_reg_from(tlv);
1397+ break;
1398+ case HIP_PARAM_ECHO_RESPONSE_SIGNED:
1399+ hip_print_param_echo_response_signed(tlv);
1400+ break;
1401+ case HIP_PARAM_ESP_TRANSFORM:
1402+ hip_print_param_esp_transform(tlv);
1403+ break;
1404+ case HIP_PARAM_HMAC:
1405+ hip_print_param_hmac(tlv);
1406+ break;
1407+ case HIP_PARAM_HMAC_2:
1408+ hip_print_param_hmac_2(tlv);
1409+ break;
1410+ case HIP_PARAM_HIP_SIGNATURE_2:
1411+ hip_print_param_hip_signature_2(tlv);
1412+ break;
1413+ case HIP_PARAM_HIP_SIGNATURE:
1414+ hip_print_param_hip_signature(tlv);
1415+ break;
1416+ case HIP_PARAM_ECHO_REQUEST_UNSIGNED:
1417+ hip_print_param_echo_request_unsigned(tlv);
1418+ break;
1419+ case HIP_PARAM_ECHO_RESPONSE_UNSIGNED:
1420+ hip_print_param_echo_response_unsigned(tlv);
1421+ break;
1422+ case HIP_PARAM_RELAY_FROM:
1423+ hip_print_param_relay_from(tlv);
1424+ break;
1425+ case HIP_PARAM_RELAY_TO:
1426+ hip_print_param_relay_to(tlv);
1427+ break;
1428+ case HIP_PARAM_FROM:
1429+ hip_print_param_from(tlv);
1430+ break;
1431+ case HIP_PARAM_RVS_HMAC:
1432+ hip_print_param_rvs_hmac(tlv);
1433+ break;
1434+ case HIP_PARAM_VIA_RVS:
1435+ hip_print_param_via_rvs(tlv);
1436+ break;
1437+ default:
1438+ hip_print_param_unknown(tlv, tlv_len);
1439+ break;
1440+ }
1441+ }
1442+ cp += tlv_len;
1443+ }
1444+ }
1445+ printf("\n");
1446+ return;
1447+trunc:
1448+ (void)printf("[|hip]");
1449+}
1450diff -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);
1455 return;
1456
1457+ case IPPROTO_HIP:
1458+ hip_print(cp, len);
1459+ return;
1460+
1461 case IPPROTO_NONE:
1462 (void)printf("no next header");
1463 return;
1464diff -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
1467@@ -1,3 +1,4 @@
1468+
1469 /*
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);
1474 break;
1475
1476+#ifdef INET6
1477+ case IPPROTO_HIP:
1478+ /* hip on top of ip */
1479+ hip_print(ipds->cp, ipds->len);
1480+ break;
1481+#endif /*INET6*/
1482+
1483 default:
1484 if ((proto = getprotobynumber(ipds->nh)) != NULL)
1485 ND_PRINT((ndo, " %s", proto->p_name));
1486diff -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
1489@@ -423,6 +423,7 @@
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;
1495 #ifdef INET6
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);
1501- else
1502+ else if (ISPORT(HIP_UDP_PORT))
1503+ {
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 */
1514+ else
1515+ printf("UDP encapsulated ESP (HIP) packet\n");
1516+ }
1517+
1518+ else
1519 (void)printf("UDP, length %u",
1520 (u_int32_t)(ulen - sizeof(*up)));
1521 #undef ISPORT
1522diff -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
1525@@ -85,6 +85,7 @@
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
1530
1531 #ifdef INET6
1532 #define RIPNG_PORT 521 /*XXX*/
This page took 0.256402 seconds and 4 git commands to generate.