]>
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.
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 */
50 static const struct tok dvmrp_msgtype_str
[] = {
51 { DVMRP_PROBE
, "Probe" },
52 { DVMRP_REPORT
, "Report" },
53 { DVMRP_ASK_NEIGHBORS
, "Ask-neighbors(old)" },
54 { DVMRP_NEIGHBORS
, "Neighbors(old)" },
55 { DVMRP_ASK_NEIGHBORS2
, "Ask-neighbors2" },
56 { DVMRP_NEIGHBORS2
, "Neighbors2" },
57 { DVMRP_PRUNE
, "Prune" },
58 { DVMRP_GRAFT
, "Graft" },
59 { DVMRP_GRAFT_ACK
, "Graft-ACK" },
64 * 'flags' byte values in DVMRP_NEIGHBORS2 reply.
66 #define DVMRP_NF_TUNNEL 0x01 /* neighbors reached via tunnel */
67 #define DVMRP_NF_SRCRT 0x02 /* tunnel uses IP source routing */
68 #define DVMRP_NF_DOWN 0x10 /* kernel state of interface */
69 #define DVMRP_NF_DISABLED 0x20 /* administratively disabled */
70 #define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */
72 static void print_probe(netdissect_options
*, const u_char
*, u_int
);
73 static void print_report(netdissect_options
*, const u_char
*, u_int
);
74 static void print_neighbors(netdissect_options
*, const u_char
*, u_int
);
75 static void print_neighbors2(netdissect_options
*, const u_char
*, u_int
, uint8_t, uint8_t);
78 dvmrp_print(netdissect_options
*ndo
,
79 const u_char
*bp
, u_int len
)
82 uint8_t major_version
, minor_version
;
84 ndo
->ndo_protocol
= "dvmrp";
86 ND_PRINT(" [length %u < 8]", len
);
90 type
= GET_U_1(bp
+ 1);
92 /* Skip IGMP header */
96 ND_PRINT(" %s", tok2str(dvmrp_msgtype_str
, "[type %u]", type
));
100 if (ndo
->ndo_vflag
) {
101 print_probe(ndo
, bp
, len
);
106 if (ndo
->ndo_vflag
> 1) {
107 print_report(ndo
, bp
, len
);
111 case DVMRP_NEIGHBORS
:
112 print_neighbors(ndo
, bp
, len
);
115 case DVMRP_NEIGHBORS2
:
117 * extract version from IGMP group address field
120 major_version
= GET_U_1(bp
+ 3);
121 minor_version
= GET_U_1(bp
+ 2);
123 print_neighbors2(ndo
, bp
, len
, major_version
, minor_version
);
127 ND_PRINT(" src %s grp %s", GET_IPADDR_STRING(bp
), GET_IPADDR_STRING(bp
+ 4));
129 unsigned_relts_print(ndo
, GET_BE_U_4(bp
+ 8));
133 ND_PRINT(" src %s grp %s", GET_IPADDR_STRING(bp
), GET_IPADDR_STRING(bp
+ 4));
136 case DVMRP_GRAFT_ACK
:
137 ND_PRINT(" src %s grp %s", GET_IPADDR_STRING(bp
), GET_IPADDR_STRING(bp
+ 4));
143 nd_print_invalid(ndo
);
147 print_report(netdissect_options
*ndo
,
151 uint32_t mask
, origin
;
157 ND_PRINT(" [length %u < 3]", len
);
160 mask
= (uint32_t)0xff << 24 | GET_U_1(bp
) << 16 |
161 GET_U_1(bp
+ 1) << 8 | GET_U_1(bp
+ 2);
170 ND_PRINT("\n\tMask %s", intoa(htonl(mask
)));
174 if (len
< width
+ 1) {
175 ND_PRINT("\n\t [Truncated Report]");
179 for (i
= 0; i
< width
; ++i
) {
180 origin
= origin
<< 8 | GET_U_1(bp
);
186 metric
= GET_U_1(bp
);
188 done
= metric
& 0x80;
190 ND_PRINT("\n\t %s metric %u", intoa(htonl(origin
)),
198 nd_print_invalid(ndo
);
202 print_probe(netdissect_options
*ndo
,
207 ND_PRINT(" [full length %u < 4]", len
);
210 ND_PRINT(ndo
->ndo_vflag
> 1 ? "\n\t" : " ");
211 ND_PRINT("genid %u", GET_BE_U_4(bp
));
212 if (ndo
->ndo_vflag
< 2)
219 ND_PRINT("[remaining length %u < 4]", len
);
222 ND_PRINT("\n\tneighbor %s", GET_IPADDR_STRING(bp
));
228 nd_print_invalid(ndo
);
232 print_neighbors(netdissect_options
*ndo
,
243 ND_PRINT(" [length %u < 7]", len
);
248 metric
= GET_U_1(bp
);
250 thresh
= GET_U_1(bp
);
252 ncount
= GET_U_1(bp
);
255 while (--ncount
>= 0) {
257 ND_PRINT(" [length %u < 4]", len
);
260 ND_PRINT(" [%s ->", GET_IPADDR_STRING(laddr
));
261 ND_PRINT(" %s, (%u/%u)]",
262 GET_IPADDR_STRING(bp
), metric
, thresh
);
270 nd_print_invalid(ndo
);
274 print_neighbors2(netdissect_options
*ndo
,
276 u_int len
, uint8_t major_version
,
277 uint8_t minor_version
)
280 u_char metric
, thresh
, flags
;
283 ND_PRINT(" (v %u.%u):", major_version
, minor_version
);
287 ND_PRINT(" [length %u < 8]", len
);
292 metric
= GET_U_1(bp
);
294 thresh
= GET_U_1(bp
);
298 ncount
= GET_U_1(bp
);
301 while (--ncount
>= 0 && len
> 0) {
303 ND_PRINT(" [length %u < 4]", len
);
306 ND_PRINT(" [%s -> ", GET_IPADDR_STRING(laddr
));
307 ND_PRINT("%s (%u/%u", GET_IPADDR_STRING(bp
),
309 if (flags
& DVMRP_NF_TUNNEL
)
311 if (flags
& DVMRP_NF_SRCRT
)
313 if (flags
& DVMRP_NF_QUERIER
)
314 ND_PRINT("/querier");
315 if (flags
& DVMRP_NF_DISABLED
)
316 ND_PRINT("/disabled");
317 if (flags
& DVMRP_NF_DOWN
)
324 ND_PRINT(" [ncount %d]", ncount
);
331 nd_print_invalid(ndo
);