]>
The Tcpdump Group git mirrors - tcpdump/blob - print-dvmrp.c
6cc7da7c5530033526d21e3b29ca4677c7172807
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.
22 /* \summary: Distance Vector Multicast Routing Protocol printer */
28 #include "netdissect-stdinc.h"
30 #include "netdissect.h"
32 #include "addrtoname.h"
35 * See: RFC 1075 and draft-ietf-idmr-dvmrp-v3
37 * DVMRP message types and flag values shamelessly stolen from
40 #define DVMRP_PROBE 1 /* for finding neighbors */
41 #define DVMRP_REPORT 2 /* for reporting some or all routes */
42 #define DVMRP_ASK_NEIGHBORS 3 /* sent by mapper, asking for a list */
43 /* of this router's neighbors */
44 #define DVMRP_NEIGHBORS 4 /* response to such a request */
45 #define DVMRP_ASK_NEIGHBORS2 5 /* as above, want new format reply */
46 #define DVMRP_NEIGHBORS2 6
47 #define DVMRP_PRUNE 7 /* prune message */
48 #define DVMRP_GRAFT 8 /* graft message */
49 #define DVMRP_GRAFT_ACK 9 /* graft acknowledgement */
52 * 'flags' byte values in DVMRP_NEIGHBORS2 reply.
54 #define DVMRP_NF_TUNNEL 0x01 /* neighbors reached via tunnel */
55 #define DVMRP_NF_SRCRT 0x02 /* tunnel uses IP source routing */
56 #define DVMRP_NF_DOWN 0x10 /* kernel state of interface */
57 #define DVMRP_NF_DISABLED 0x20 /* administratively disabled */
58 #define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */
60 static int print_probe(netdissect_options
*, const u_char
*, const u_char
*, u_int
);
61 static int print_report(netdissect_options
*, const u_char
*, const u_char
*, u_int
);
62 static int print_neighbors(netdissect_options
*, const u_char
*, const u_char
*, u_int
);
63 static int print_neighbors2(netdissect_options
*, const u_char
*, const u_char
*, u_int
, uint8_t, uint8_t);
64 static int print_prune(netdissect_options
*, const u_char
*);
65 static int print_graft(netdissect_options
*, const u_char
*);
66 static int print_graft_ack(netdissect_options
*, const u_char
*);
69 dvmrp_print(netdissect_options
*ndo
,
70 const u_char
*bp
, u_int len
)
74 uint8_t major_version
, minor_version
;
76 ndo
->ndo_protocol
= "dvmrp";
77 ep
= ndo
->ndo_snapend
;
82 type
= EXTRACT_U_1(bp
+ 1);
84 /* Skip IGMP header */
93 if (print_probe(ndo
, bp
, ep
, len
) < 0)
100 if (ndo
->ndo_vflag
> 1) {
101 if (print_report(ndo
, bp
, ep
, len
) < 0)
106 case DVMRP_ASK_NEIGHBORS
:
107 ND_PRINT(" Ask-neighbors(old)");
110 case DVMRP_NEIGHBORS
:
111 ND_PRINT(" Neighbors(old)");
112 if (print_neighbors(ndo
, bp
, ep
, len
) < 0)
116 case DVMRP_ASK_NEIGHBORS2
:
117 ND_PRINT(" Ask-neighbors2");
120 case DVMRP_NEIGHBORS2
:
121 ND_PRINT(" Neighbors2");
123 * extract version from IGMP group address field
127 major_version
= EXTRACT_U_1(bp
+ 3);
128 minor_version
= EXTRACT_U_1(bp
+ 2);
130 if (print_neighbors2(ndo
, bp
, ep
, len
, major_version
,
137 if (print_prune(ndo
, bp
) < 0)
143 if (print_graft(ndo
, bp
) < 0)
147 case DVMRP_GRAFT_ACK
:
148 ND_PRINT(" Graft-ACK");
149 if (print_graft_ack(ndo
, bp
) < 0)
154 ND_PRINT(" [type %u]", type
);
160 ND_PRINT("[|dvmrp]");
165 print_report(netdissect_options
*ndo
,
166 const u_char
*bp
, const u_char
*ep
,
169 uint32_t mask
, origin
;
179 mask
= (uint32_t)0xff << 24 | EXTRACT_U_1(bp
) << 16 |
180 EXTRACT_U_1(bp
+ 1) << 8 | EXTRACT_U_1(bp
+ 2);
184 if (EXTRACT_U_1(bp
+ 1))
186 if (EXTRACT_U_1(bp
+ 2))
189 ND_PRINT("\n\tMask %s", intoa(htonl(mask
)));
193 if (bp
+ width
+ 1 > ep
) {
197 if (len
< width
+ 1) {
198 ND_PRINT("\n\t [Truncated Report]");
202 for (i
= 0; i
< width
; ++i
) {
204 origin
= origin
<< 8 | EXTRACT_U_1(bp
);
211 metric
= EXTRACT_U_1(bp
);
213 done
= metric
& 0x80;
215 ND_PRINT("\n\t %s metric %u", intoa(htonl(origin
)),
226 print_probe(netdissect_options
*ndo
,
227 const u_char
*bp
, const u_char
*ep
,
233 if ((len
< 4) || ((bp
+ 4) > ep
)) {
238 genid
= (EXTRACT_U_1(bp
) << 24) | (EXTRACT_U_1(bp
+ 1) << 16) |
239 (EXTRACT_U_1(bp
+ 2) << 8) | EXTRACT_U_1(bp
+ 3);
242 ND_PRINT(ndo
->ndo_vflag
> 1 ? "\n\t" : " ");
243 ND_PRINT("genid %u", genid
);
244 if (ndo
->ndo_vflag
< 2)
247 while ((len
> 0) && (bp
< ep
)) {
249 ND_PRINT("\n\tneighbor %s", ipaddr_string(ndo
, bp
));
258 print_neighbors(netdissect_options
*ndo
,
259 const u_char
*bp
, const u_char
*ep
,
267 while (len
> 0 && bp
< ep
) {
271 metric
= EXTRACT_U_1(bp
);
273 thresh
= EXTRACT_U_1(bp
);
275 ncount
= EXTRACT_U_1(bp
);
278 while (--ncount
>= 0) {
280 ND_PRINT(" [%s ->", ipaddr_string(ndo
, laddr
));
281 ND_PRINT(" %s, (%u/%u)]",
282 ipaddr_string(ndo
, bp
), metric
, thresh
);
293 print_neighbors2(netdissect_options
*ndo
,
294 const u_char
*bp
, const u_char
*ep
,
295 u_int len
, uint8_t major_version
,
296 uint8_t minor_version
)
299 u_char metric
, thresh
, flags
;
302 ND_PRINT(" (v %u.%u):", major_version
, minor_version
);
304 while (len
> 0 && bp
< ep
) {
308 metric
= EXTRACT_U_1(bp
);
310 thresh
= EXTRACT_U_1(bp
);
312 flags
= EXTRACT_U_1(bp
);
314 ncount
= EXTRACT_U_1(bp
);
317 while (--ncount
>= 0 && (len
>= 4) && (bp
+ 4) <= ep
) {
318 ND_PRINT(" [%s -> ", ipaddr_string(ndo
, laddr
));
319 ND_PRINT("%s (%u/%u", ipaddr_string(ndo
, bp
),
321 if (flags
& DVMRP_NF_TUNNEL
)
323 if (flags
& DVMRP_NF_SRCRT
)
325 if (flags
& DVMRP_NF_QUERIER
)
326 ND_PRINT("/querier");
327 if (flags
& DVMRP_NF_DISABLED
)
328 ND_PRINT("/disabled");
329 if (flags
& DVMRP_NF_DOWN
)
346 print_prune(netdissect_options
*ndo
,
349 ND_TCHECK_LEN(bp
, 12);
350 ND_PRINT(" src %s grp %s", ipaddr_string(ndo
, bp
), ipaddr_string(ndo
, bp
+ 4));
353 unsigned_relts_print(ndo
, EXTRACT_BE_U_4(bp
));
360 print_graft(netdissect_options
*ndo
,
364 ND_PRINT(" src %s grp %s", ipaddr_string(ndo
, bp
), ipaddr_string(ndo
, bp
+ 4));
371 print_graft_ack(netdissect_options
*ndo
,
375 ND_PRINT(" src %s grp %s", ipaddr_string(ndo
, bp
), ipaddr_string(ndo
, bp
+ 4));