]>
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.18 2000-09-23 08:26:33 guy Exp $ (LBL)";
31 #include <sys/param.h>
33 #include <sys/socket.h>
35 #include <netinet/in.h>
36 #include <netinet/in_systm.h>
37 #include <netinet/ip.h>
38 #include <netinet/ip_var.h>
45 #include "interface.h"
47 #include "addrtoname.h"
50 * DVMRP message types and flag values shamelessly stolen from
53 #define DVMRP_PROBE 1 /* for finding neighbors */
54 #define DVMRP_REPORT 2 /* for reporting some or all routes */
55 #define DVMRP_ASK_NEIGHBORS 3 /* sent by mapper, asking for a list */
57 * of this router's neighbors
59 #define DVMRP_NEIGHBORS 4 /* response to such a request */
60 #define DVMRP_ASK_NEIGHBORS2 5 /* as above, want new format reply */
61 #define DVMRP_NEIGHBORS2 6
62 #define DVMRP_PRUNE 7 /* prune message */
63 #define DVMRP_GRAFT 8 /* graft message */
64 #define DVMRP_GRAFT_ACK 9 /* graft acknowledgement */
67 * 'flags' byte values in DVMRP_NEIGHBORS2 reply.
69 #define DVMRP_NF_TUNNEL 0x01 /* neighbors reached via tunnel */
70 #define DVMRP_NF_SRCRT 0x02 /* tunnel uses IP source routing */
71 #define DVMRP_NF_DOWN 0x10 /* kernel state of interface */
72 #define DVMRP_NF_DISABLED 0x20 /* administratively disabled */
73 #define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */
75 static void print_probe(const u_char
*, const u_char
*, u_int
);
76 static void print_report(const u_char
*, const u_char
*, u_int
);
77 static void print_neighbors(const u_char
*, const u_char
*, u_int
);
78 static void print_neighbors2(const u_char
*, const u_char
*, u_int
);
79 static void print_prune(const u_char
*, const u_char
*, u_int
);
80 static void print_graft(const u_char
*, const u_char
*, u_int
);
81 static void print_graft_ack(const u_char
*, const u_char
*, u_int
);
83 static u_int32_t target_level
;
86 dvmrp_print(register const u_char
*bp
, register u_int len
)
88 register const u_char
*ep
;
91 ep
= (const u_char
*)snapend
;
108 print_probe(bp
, ep
, len
);
114 print_report(bp
, ep
, len
);
117 case DVMRP_ASK_NEIGHBORS
:
118 printf(" Ask-neighbors(old)");
121 case DVMRP_NEIGHBORS
:
122 printf(" Neighbors(old)");
123 print_neighbors(bp
, ep
, len
);
126 case DVMRP_ASK_NEIGHBORS2
:
127 printf(" Ask-neighbors2");
130 case DVMRP_NEIGHBORS2
:
131 printf(" Neighbors2");
133 * extract version and capabilities from IGMP group
137 target_level
= (bp
[0] << 24) | (bp
[1] << 16) |
138 (bp
[2] << 8) | bp
[3];
140 print_neighbors2(bp
, ep
, len
);
145 print_prune(bp
, ep
, len
);
150 print_graft(bp
, ep
, len
);
153 case DVMRP_GRAFT_ACK
:
154 printf(" Graft-ACK");
155 print_graft_ack(bp
, ep
, len
);
159 printf(" [type %d]", type
);
165 print_report(register const u_char
*bp
, register const u_char
*ep
,
168 register u_int32_t mask
, origin
;
169 register int metric
, i
, width
, done
;
176 mask
= (u_int32_t
)0xff << 24 | bp
[0] << 16 | bp
[1] << 8 | bp
[2];
185 printf("\n\tMask %s", intoa(htonl(mask
)));
189 if (bp
+ width
+ 1 > ep
) {
193 if (len
< width
+ 1) {
194 printf("\n\t [Truncated Report]");
198 for (i
= 0; i
< width
; ++i
)
199 origin
= origin
<< 8 | *bp
++;
204 done
= metric
& 0x80;
206 printf("\n\t %s metric %d", intoa(htonl(origin
)),
214 print_probe(register const u_char
*bp
, register const u_char
*ep
,
217 register u_int32_t genid
;
220 if ((len
< 4) || ((bp
+ 4) > ep
)) {
225 genid
= (bp
[0] << 24) | (bp
[1] << 16) | (bp
[2] << 8) | bp
[3];
228 printf("\n\tgenid %u", genid
);
230 while ((len
> 0) && (bp
< ep
)) {
232 printf("\n\tneighbor %s", ipaddr_string(bp
));
237 (void)printf("[|dvmrp]");
241 print_neighbors(register const u_char
*bp
, register const u_char
*ep
,
245 register u_char metric
;
246 register u_char thresh
;
249 while (len
> 0 && bp
< ep
) {
257 while (--ncount
>= 0) {
259 printf(" [%s ->", ipaddr_string(laddr
));
260 printf(" %s, (%d/%d)]",
261 ipaddr_string(bp
), metric
, thresh
);
268 (void)printf("[|dvmrp]");
272 print_neighbors2(register const u_char
*bp
, register const u_char
*ep
,
276 register u_char metric
, thresh
, flags
;
279 printf(" (v %d.%d):",
280 (int)target_level
& 0xff,
281 (int)(target_level
>> 8) & 0xff);
283 while (len
> 0 && bp
< ep
) {
292 while (--ncount
>= 0 && (len
>= 4) && (bp
+ 4) <= ep
) {
293 printf(" [%s -> ", ipaddr_string(laddr
));
294 printf("%s (%d/%d", ipaddr_string(bp
),
296 if (flags
& DVMRP_NF_TUNNEL
)
298 if (flags
& DVMRP_NF_SRCRT
)
300 if (flags
& DVMRP_NF_QUERIER
)
302 if (flags
& DVMRP_NF_DISABLED
)
304 if (flags
& DVMRP_NF_DOWN
)
317 (void)printf("[|dvmrp]");
321 print_prune(register const u_char
*bp
, register const u_char
*ep
,
325 printf(" src %s grp %s", ipaddr_string(bp
), ipaddr_string(bp
+ 4));
327 (void)printf(" timer ");
328 relts_print(EXTRACT_32BITS(bp
));
331 (void)printf("[|dvmrp]");
335 print_graft(register const u_char
*bp
, register const u_char
*ep
,
339 printf(" src %s grp %s", ipaddr_string(bp
), ipaddr_string(bp
+ 4));
342 (void)printf("[|dvmrp]");
346 print_graft_ack(register const u_char
*bp
, register const u_char
*ep
,
350 printf(" src %s grp %s", ipaddr_string(bp
), ipaddr_string(bp
+ 4));
353 (void)printf("[|dvmrp]");