]> The Tcpdump Group git mirrors - tcpdump/blob - print-rt6.c
Bring in KAME IPv6 tcpdump. replaces esp/ah/isakmp decoder.
[tcpdump] / print-rt6.c
1 /*
2 * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 */
21
22 #ifndef lint
23 static const char rcsid[] =
24 "@(#) /master/usr.sbin/tcpdump/tcpdump/print-icmp.c,v 2.1 1995/02/03 18:14:42 polk Exp (LBL)";
25 #endif
26
27 #ifdef INET6
28
29 #include <sys/param.h>
30 #include <sys/time.h>
31 #include <sys/types.h>
32 #include <sys/socket.h>
33
34 #include <net/if.h>
35
36 #include <netinet/in.h>
37 #include <netinet/if_ether.h>
38 #include <netinet/in_systm.h>
39 #include <netinet/ip.h>
40 #include <netinet/ip_icmp.h>
41 #include <netinet/ip_var.h>
42 #include <netinet/udp.h>
43 #include <netinet/udp_var.h>
44 #include <netinet/tcp.h>
45
46 #include <stdio.h>
47
48 #include <netinet/ip6.h>
49
50 #include "interface.h"
51 #include "addrtoname.h"
52
53 int
54 rt6_print(register const u_char *bp, register const u_char *bp2)
55 {
56 register const struct ip6_rthdr0 *dp;
57 register const struct ip6_hdr *ip;
58 register const u_char *ep;
59 u_long bitmap = 0x0800;
60 u_long slmap;
61 int i, len;
62
63 #if 0
64 #define TCHECK(var) if ((u_char *)&(var) >= ep - sizeof(var)) goto trunc
65 #endif
66
67 dp = (struct ip6_rthdr0 *)bp;
68 ip = (struct ip6_hdr *)bp2;
69 len = dp->ip6r0_len;
70
71 /* 'ep' points to the end of avaible data. */
72 ep = snapend;
73
74 printf("%s > %s: ",
75 ip6addr_string(&ip->ip6_src),
76 ip6addr_string(&ip->ip6_dst));
77
78 TCHECK(dp->ip6r0_slmap[2]);
79 printf("srcrt (len=%d, ", dp->ip6r0_len);
80 printf("type=%d, ", dp->ip6r0_type);
81 printf("segleft=%d, ", dp->ip6r0_segleft);
82 if (dp->ip6r0_type != 0)
83 goto trunc;
84 slmap = (dp->ip6r0_slmap[0] << 16)
85 | (dp->ip6r0_slmap[1] << 8)
86 | (dp->ip6r0_slmap[2]);
87 printf("bitmap=");
88 for (i = 24; i > 0; i--) {
89 if (slmap & bitmap)
90 printf("S");
91 else
92 printf("L");
93 bitmap >>= 1;
94 }
95 if (len % 2 == 1)
96 goto trunc;
97 len >>= 1;
98 printf(", ");
99 for (i = 0; i < len; i++) {
100 if ((((u_char *)&(dp->ip6r0_reserved)) + sizeof(u_long)
101 + (i<<4)) > ep) goto trunc;
102 printf(" [%d]%s", i,
103 ip6addr_string(((u_char *)&(dp->ip6r0_reserved)) +
104 sizeof(u_long) + (i<<4)));
105 if (i != len - 1)
106 printf(", ");
107
108 }
109 printf(")");
110 return((dp->ip6r0_len + 1) << 3);
111 trunc:
112 fputs("[|srcrt]", stdout);
113 return 65535;
114 #undef TCHECK
115 }
116 #endif /* INET6 */