]>
The Tcpdump Group git mirrors - tcpdump/blob - print-dvmrp.c
2 * Copyright (c) 1995, 1996
3 * The Regents of the University of California. All rights reserved.
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
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.
23 static const char rcsid
[] =
24 "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.22 2002-08-01 08:53:05 risso Exp $ (LBL)";
31 #include <tcpdump-stdinc.h>
37 #include "interface.h"
39 #include "addrtoname.h"
42 * DVMRP message types and flag values shamelessly stolen from
45 #define DVMRP_PROBE 1 /* for finding neighbors */
46 #define DVMRP_REPORT 2 /* for reporting some or all routes */
47 #define DVMRP_ASK_NEIGHBORS 3 /* sent by mapper, asking for a list */
48 /* of this router's neighbors */
49 #define DVMRP_NEIGHBORS 4 /* response to such a request */
50 #define DVMRP_ASK_NEIGHBORS2 5 /* as above, want new format reply */
51 #define DVMRP_NEIGHBORS2 6
52 #define DVMRP_PRUNE 7 /* prune message */
53 #define DVMRP_GRAFT 8 /* graft message */
54 #define DVMRP_GRAFT_ACK 9 /* graft acknowledgement */
57 * 'flags' byte values in DVMRP_NEIGHBORS2 reply.
59 #define DVMRP_NF_TUNNEL 0x01 /* neighbors reached via tunnel */
60 #define DVMRP_NF_SRCRT 0x02 /* tunnel uses IP source routing */
61 #define DVMRP_NF_DOWN 0x10 /* kernel state of interface */
62 #define DVMRP_NF_DISABLED 0x20 /* administratively disabled */
63 #define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */
65 static void print_probe(const u_char
*, const u_char
*, u_int
);
66 static void print_report(const u_char
*, const u_char
*, u_int
);
67 static void print_neighbors(const u_char
*, const u_char
*, u_int
);
68 static void print_neighbors2(const u_char
*, const u_char
*, u_int
);
69 static void print_prune(const u_char
*, const u_char
*, u_int
);
70 static void print_graft(const u_char
*, const u_char
*, u_int
);
71 static void print_graft_ack(const u_char
*, const u_char
*, u_int
);
73 static u_int32_t target_level
;
76 dvmrp_print(register const u_char
*bp
, register u_int len
)
78 register const u_char
*ep
;
81 ep
= (const u_char
*)snapend
;
87 /* Skip IGMP header */
96 print_probe(bp
, ep
, len
);
102 print_report(bp
, ep
, len
);
105 case DVMRP_ASK_NEIGHBORS
:
106 printf(" Ask-neighbors(old)");
109 case DVMRP_NEIGHBORS
:
110 printf(" Neighbors(old)");
111 print_neighbors(bp
, ep
, len
);
114 case DVMRP_ASK_NEIGHBORS2
:
115 printf(" Ask-neighbors2");
118 case DVMRP_NEIGHBORS2
:
119 printf(" Neighbors2");
121 * extract version and capabilities from IGMP group
125 target_level
= (bp
[0] << 24) | (bp
[1] << 16) |
126 (bp
[2] << 8) | bp
[3];
128 print_neighbors2(bp
, ep
, len
);
133 print_prune(bp
, ep
, len
);
138 print_graft(bp
, ep
, len
);
141 case DVMRP_GRAFT_ACK
:
142 printf(" Graft-ACK");
143 print_graft_ack(bp
, ep
, len
);
147 printf(" [type %d]", type
);
153 print_report(register const u_char
*bp
, register const u_char
*ep
,
156 register u_int32_t mask
, origin
;
157 register int metric
, i
, width
, done
;
164 mask
= (u_int32_t
)0xff << 24 | bp
[0] << 16 | bp
[1] << 8 | bp
[2];
173 printf("\n\tMask %s", intoa(htonl(mask
)));
177 if (bp
+ width
+ 1 > ep
) {
181 if (len
< width
+ 1) {
182 printf("\n\t [Truncated Report]");
186 for (i
= 0; i
< width
; ++i
)
187 origin
= origin
<< 8 | *bp
++;
192 done
= metric
& 0x80;
194 printf("\n\t %s metric %d", intoa(htonl(origin
)),
202 print_probe(register const u_char
*bp
, register const u_char
*ep
,
205 register u_int32_t genid
;
208 if ((len
< 4) || ((bp
+ 4) > ep
)) {
213 genid
= (bp
[0] << 24) | (bp
[1] << 16) | (bp
[2] << 8) | bp
[3];
220 printf("genid %u", genid
);
224 while ((len
> 0) && (bp
< ep
)) {
226 printf("\n\tneighbor %s", ipaddr_string(bp
));
231 (void)printf("[|dvmrp]");
235 print_neighbors(register const u_char
*bp
, register const u_char
*ep
,
239 register u_char metric
;
240 register u_char thresh
;
243 while (len
> 0 && bp
< ep
) {
251 while (--ncount
>= 0) {
253 printf(" [%s ->", ipaddr_string(laddr
));
254 printf(" %s, (%d/%d)]",
255 ipaddr_string(bp
), metric
, thresh
);
262 (void)printf("[|dvmrp]");
266 print_neighbors2(register const u_char
*bp
, register const u_char
*ep
,
270 register u_char metric
, thresh
, flags
;
273 printf(" (v %d.%d):",
274 (int)target_level
& 0xff,
275 (int)(target_level
>> 8) & 0xff);
277 while (len
> 0 && bp
< ep
) {
286 while (--ncount
>= 0 && (len
>= 4) && (bp
+ 4) <= ep
) {
287 printf(" [%s -> ", ipaddr_string(laddr
));
288 printf("%s (%d/%d", ipaddr_string(bp
),
290 if (flags
& DVMRP_NF_TUNNEL
)
292 if (flags
& DVMRP_NF_SRCRT
)
294 if (flags
& DVMRP_NF_QUERIER
)
296 if (flags
& DVMRP_NF_DISABLED
)
298 if (flags
& DVMRP_NF_DOWN
)
311 (void)printf("[|dvmrp]");
315 print_prune(register const u_char
*bp
, register const u_char
*ep
,
319 printf(" src %s grp %s", ipaddr_string(bp
), ipaddr_string(bp
+ 4));
321 (void)printf(" timer ");
322 relts_print(EXTRACT_32BITS(bp
));
325 (void)printf("[|dvmrp]");
329 print_graft(register const u_char
*bp
, register const u_char
*ep
,
333 printf(" src %s grp %s", ipaddr_string(bp
), ipaddr_string(bp
+ 4));
336 (void)printf("[|dvmrp]");
340 print_graft_ack(register const u_char
*bp
, register const u_char
*ep
,
344 printf(" src %s grp %s", ipaddr_string(bp
), ipaddr_string(bp
+ 4));
347 (void)printf("[|dvmrp]");