]>
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 */
26 #include "netdissect-stdinc.h"
28 #include "netdissect.h"
30 #include "addrtoname.h"
33 * See: RFC 1075 and draft-ietf-idmr-dvmrp-v3
35 * DVMRP message types and flag values shamelessly stolen from
38 #define DVMRP_PROBE 1 /* for finding neighbors */
39 #define DVMRP_REPORT 2 /* for reporting some or all routes */
40 #define DVMRP_ASK_NEIGHBORS 3 /* sent by mapper, asking for a list */
41 /* of this router's neighbors */
42 #define DVMRP_NEIGHBORS 4 /* response to such a request */
43 #define DVMRP_ASK_NEIGHBORS2 5 /* as above, want new format reply */
44 #define DVMRP_NEIGHBORS2 6
45 #define DVMRP_PRUNE 7 /* prune message */
46 #define DVMRP_GRAFT 8 /* graft message */
47 #define DVMRP_GRAFT_ACK 9 /* graft acknowledgement */
48 static const struct tok dvmrp_msgtype_str
[] = {
49 { DVMRP_PROBE
, "Probe" },
50 { DVMRP_REPORT
, "Report" },
51 { DVMRP_ASK_NEIGHBORS
, "Ask-neighbors(old)" },
52 { DVMRP_NEIGHBORS
, "Neighbors(old)" },
53 { DVMRP_ASK_NEIGHBORS2
, "Ask-neighbors2" },
54 { DVMRP_NEIGHBORS2
, "Neighbors2" },
55 { DVMRP_PRUNE
, "Prune" },
56 { DVMRP_GRAFT
, "Graft" },
57 { DVMRP_GRAFT_ACK
, "Graft-ACK" },
62 * 'flags' byte values in DVMRP_NEIGHBORS2 reply.
64 #define DVMRP_NF_TUNNEL 0x01 /* neighbors reached via tunnel */
65 #define DVMRP_NF_SRCRT 0x02 /* tunnel uses IP source routing */
66 #define DVMRP_NF_DOWN 0x10 /* kernel state of interface */
67 #define DVMRP_NF_DISABLED 0x20 /* administratively disabled */
68 #define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */
70 static void print_probe(netdissect_options
*, const u_char
*, u_int
);
71 static void print_report(netdissect_options
*, const u_char
*, u_int
);
72 static void print_neighbors(netdissect_options
*, const u_char
*, u_int
);
73 static void print_neighbors2(netdissect_options
*, const u_char
*, u_int
, uint8_t, uint8_t);
76 dvmrp_print(netdissect_options
*ndo
,
77 const u_char
*bp
, u_int len
)
80 uint8_t major_version
, minor_version
;
82 ndo
->ndo_protocol
= "dvmrp";
84 ND_PRINT(" [length %u < 8]", len
);
88 type
= GET_U_1(bp
+ 1);
90 /* Skip IGMP header */
94 ND_PRINT(" %s", tok2str(dvmrp_msgtype_str
, "[type %u]", type
));
99 print_probe(ndo
, bp
, len
);
104 if (ndo
->ndo_vflag
> 1) {
105 print_report(ndo
, bp
, len
);
109 case DVMRP_NEIGHBORS
:
110 print_neighbors(ndo
, bp
, len
);
113 case DVMRP_NEIGHBORS2
:
115 * extract version from IGMP group address field
118 major_version
= GET_U_1(bp
+ 3);
119 minor_version
= GET_U_1(bp
+ 2);
121 print_neighbors2(ndo
, bp
, len
, major_version
, minor_version
);
125 ND_PRINT(" src %s grp %s", GET_IPADDR_STRING(bp
), GET_IPADDR_STRING(bp
+ 4));
127 unsigned_relts_print(ndo
, GET_BE_U_4(bp
+ 8));
131 ND_PRINT(" src %s grp %s", GET_IPADDR_STRING(bp
), GET_IPADDR_STRING(bp
+ 4));
134 case DVMRP_GRAFT_ACK
:
135 ND_PRINT(" src %s grp %s", GET_IPADDR_STRING(bp
), GET_IPADDR_STRING(bp
+ 4));
141 nd_print_invalid(ndo
);
145 print_report(netdissect_options
*ndo
,
149 uint32_t mask
, origin
;
155 ND_PRINT(" [length %u < 3]", len
);
158 mask
= (uint32_t)0xff << 24 | GET_U_1(bp
) << 16 |
159 GET_U_1(bp
+ 1) << 8 | GET_U_1(bp
+ 2);
168 ND_PRINT("\n\tMask %s", intoa(htonl(mask
)));
172 if (len
< width
+ 1) {
173 ND_PRINT("\n\t [Truncated Report]");
177 for (i
= 0; i
< width
; ++i
) {
178 origin
= origin
<< 8 | GET_U_1(bp
);
184 metric
= GET_U_1(bp
);
186 done
= metric
& 0x80;
188 ND_PRINT("\n\t %s metric %u", intoa(htonl(origin
)),
196 nd_print_invalid(ndo
);
200 print_probe(netdissect_options
*ndo
,
205 ND_PRINT(" [full length %u < 4]", len
);
208 ND_PRINT(ndo
->ndo_vflag
> 1 ? "\n\t" : " ");
209 ND_PRINT("genid %u", GET_BE_U_4(bp
));
210 if (ndo
->ndo_vflag
< 2)
217 ND_PRINT("[remaining length %u < 4]", len
);
220 ND_PRINT("\n\tneighbor %s", GET_IPADDR_STRING(bp
));
226 nd_print_invalid(ndo
);
230 print_neighbors(netdissect_options
*ndo
,
241 ND_PRINT(" [length %u < 7]", len
);
246 metric
= GET_U_1(bp
);
248 thresh
= GET_U_1(bp
);
250 ncount
= GET_U_1(bp
);
253 while (--ncount
>= 0) {
255 ND_PRINT(" [length %u < 4]", len
);
258 ND_PRINT(" [%s ->", GET_IPADDR_STRING(laddr
));
259 ND_PRINT(" %s, (%u/%u)]",
260 GET_IPADDR_STRING(bp
), metric
, thresh
);
268 nd_print_invalid(ndo
);
272 print_neighbors2(netdissect_options
*ndo
,
274 u_int len
, uint8_t major_version
,
275 uint8_t minor_version
)
278 u_char metric
, thresh
, flags
;
281 ND_PRINT(" (v %u.%u):", major_version
, minor_version
);
285 ND_PRINT(" [length %u < 8]", len
);
290 metric
= GET_U_1(bp
);
292 thresh
= GET_U_1(bp
);
296 ncount
= GET_U_1(bp
);
299 while (--ncount
>= 0 && len
!= 0) {
301 ND_PRINT(" [length %u < 4]", len
);
304 ND_PRINT(" [%s -> ", GET_IPADDR_STRING(laddr
));
305 ND_PRINT("%s (%u/%u", GET_IPADDR_STRING(bp
),
307 if (flags
& DVMRP_NF_TUNNEL
)
309 if (flags
& DVMRP_NF_SRCRT
)
311 if (flags
& DVMRP_NF_QUERIER
)
312 ND_PRINT("/querier");
313 if (flags
& DVMRP_NF_DISABLED
)
314 ND_PRINT("/disabled");
315 if (flags
& DVMRP_NF_DOWN
)
322 ND_PRINT(" [ncount %d]", ncount
);
329 nd_print_invalid(ndo
);