1999-10-08 07:47:09 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995, 1996
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that: (1) source code distributions
|
|
|
|
* retain the above copyright notice and this paragraph in its entirety, (2)
|
|
|
|
* distributions including binary code include the above copyright notice and
|
|
|
|
* this paragraph in its entirety in the documentation or other materials
|
|
|
|
* provided with the distribution, and (3) all advertising materials mentioning
|
|
|
|
* features or use of this software display the following acknowledgement:
|
|
|
|
* ``This product includes software developed by the University of California,
|
|
|
|
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
|
|
|
* the University nor the names of its contributors may be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
|
|
|
|
2016-08-14 21:42:19 +08:00
|
|
|
/* \summary: Distance Vector Multicast Routing Protocol printer */
|
|
|
|
|
1999-11-21 17:36:43 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2018-01-22 04:27:08 +08:00
|
|
|
#include <config.h>
|
1999-10-08 07:47:09 +08:00
|
|
|
#endif
|
|
|
|
|
2018-01-20 22:59:49 +08:00
|
|
|
#include "netdissect-stdinc.h"
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2015-09-06 05:35:58 +08:00
|
|
|
#include "netdissect.h"
|
1999-11-22 12:30:34 +08:00
|
|
|
#include "extract.h"
|
1999-10-08 07:47:09 +08:00
|
|
|
#include "addrtoname.h"
|
|
|
|
|
|
|
|
/*
|
2017-11-23 02:54:31 +08:00
|
|
|
* See: RFC 1075 and draft-ietf-idmr-dvmrp-v3
|
|
|
|
*
|
1999-10-08 07:47:09 +08:00
|
|
|
* DVMRP message types and flag values shamelessly stolen from
|
|
|
|
* mrouted/dvmrp.h.
|
|
|
|
*/
|
|
|
|
#define DVMRP_PROBE 1 /* for finding neighbors */
|
|
|
|
#define DVMRP_REPORT 2 /* for reporting some or all routes */
|
|
|
|
#define DVMRP_ASK_NEIGHBORS 3 /* sent by mapper, asking for a list */
|
2001-05-10 13:30:20 +08:00
|
|
|
/* of this router's neighbors */
|
1999-10-08 07:47:09 +08:00
|
|
|
#define DVMRP_NEIGHBORS 4 /* response to such a request */
|
|
|
|
#define DVMRP_ASK_NEIGHBORS2 5 /* as above, want new format reply */
|
|
|
|
#define DVMRP_NEIGHBORS2 6
|
|
|
|
#define DVMRP_PRUNE 7 /* prune message */
|
|
|
|
#define DVMRP_GRAFT 8 /* graft message */
|
|
|
|
#define DVMRP_GRAFT_ACK 9 /* graft acknowledgement */
|
2020-12-04 09:35:32 +08:00
|
|
|
static const struct tok dvmrp_msgtype_str[] = {
|
|
|
|
{ DVMRP_PROBE, "Probe" },
|
|
|
|
{ DVMRP_REPORT, "Report" },
|
|
|
|
{ DVMRP_ASK_NEIGHBORS, "Ask-neighbors(old)" },
|
|
|
|
{ DVMRP_NEIGHBORS, "Neighbors(old)" },
|
|
|
|
{ DVMRP_ASK_NEIGHBORS2, "Ask-neighbors2" },
|
|
|
|
{ DVMRP_NEIGHBORS2, "Neighbors2" },
|
|
|
|
{ DVMRP_PRUNE, "Prune" },
|
|
|
|
{ DVMRP_GRAFT, "Graft" },
|
|
|
|
{ DVMRP_GRAFT_ACK, "Graft-ACK" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
1999-10-08 07:47:09 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 'flags' byte values in DVMRP_NEIGHBORS2 reply.
|
|
|
|
*/
|
|
|
|
#define DVMRP_NF_TUNNEL 0x01 /* neighbors reached via tunnel */
|
|
|
|
#define DVMRP_NF_SRCRT 0x02 /* tunnel uses IP source routing */
|
|
|
|
#define DVMRP_NF_DOWN 0x10 /* kernel state of interface */
|
|
|
|
#define DVMRP_NF_DISABLED 0x20 /* administratively disabled */
|
|
|
|
#define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */
|
|
|
|
|
2020-12-04 09:35:32 +08:00
|
|
|
static void print_probe(netdissect_options *, const u_char *, u_int);
|
|
|
|
static void print_report(netdissect_options *, const u_char *, u_int);
|
|
|
|
static void print_neighbors(netdissect_options *, const u_char *, u_int);
|
|
|
|
static void print_neighbors2(netdissect_options *, const u_char *, u_int, uint8_t, uint8_t);
|
1999-10-08 07:47:09 +08:00
|
|
|
|
|
|
|
void
|
2014-03-21 20:48:24 +08:00
|
|
|
dvmrp_print(netdissect_options *ndo,
|
2017-12-14 02:17:47 +08:00
|
|
|
const u_char *bp, u_int len)
|
1999-10-08 07:47:09 +08:00
|
|
|
{
|
2017-12-14 02:17:47 +08:00
|
|
|
u_char type;
|
2017-11-23 02:54:31 +08:00
|
|
|
uint8_t major_version, minor_version;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2018-03-14 23:54:17 +08:00
|
|
|
ndo->ndo_protocol = "dvmrp";
|
2020-12-04 09:35:32 +08:00
|
|
|
if (len < 8) {
|
|
|
|
ND_PRINT(" [length %u < 8]", len);
|
|
|
|
goto invalid;
|
|
|
|
}
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
type = GET_U_1(bp + 1);
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2001-05-10 13:30:20 +08:00
|
|
|
/* Skip IGMP header */
|
|
|
|
bp += 8;
|
1999-10-08 07:47:09 +08:00
|
|
|
len -= 8;
|
|
|
|
|
2020-12-04 09:35:32 +08:00
|
|
|
ND_PRINT(" %s", tok2str(dvmrp_msgtype_str, "[type %u]", type));
|
1999-10-08 07:47:09 +08:00
|
|
|
switch (type) {
|
|
|
|
|
|
|
|
case DVMRP_PROBE:
|
2014-03-21 20:48:24 +08:00
|
|
|
if (ndo->ndo_vflag) {
|
2020-12-04 09:35:32 +08:00
|
|
|
print_probe(ndo, bp, len);
|
2003-11-19 17:42:04 +08:00
|
|
|
}
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DVMRP_REPORT:
|
2014-03-21 20:48:24 +08:00
|
|
|
if (ndo->ndo_vflag > 1) {
|
2020-12-04 09:35:32 +08:00
|
|
|
print_report(ndo, bp, len);
|
2003-11-19 17:42:04 +08:00
|
|
|
}
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DVMRP_NEIGHBORS:
|
2020-12-04 09:35:32 +08:00
|
|
|
print_neighbors(ndo, bp, len);
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DVMRP_NEIGHBORS2:
|
|
|
|
/*
|
2017-11-23 02:54:31 +08:00
|
|
|
* extract version from IGMP group address field
|
1999-10-08 07:47:09 +08:00
|
|
|
*/
|
|
|
|
bp -= 4;
|
2018-06-16 23:23:21 +08:00
|
|
|
major_version = GET_U_1(bp + 3);
|
|
|
|
minor_version = GET_U_1(bp + 2);
|
1999-10-08 07:47:09 +08:00
|
|
|
bp += 4;
|
2020-12-04 09:35:32 +08:00
|
|
|
print_neighbors2(ndo, bp, len, major_version, minor_version);
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DVMRP_PRUNE:
|
2020-12-04 09:35:32 +08:00
|
|
|
ND_PRINT(" src %s grp %s", GET_IPADDR_STRING(bp), GET_IPADDR_STRING(bp + 4));
|
|
|
|
ND_PRINT(" timer ");
|
|
|
|
unsigned_relts_print(ndo, GET_BE_U_4(bp + 8));
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DVMRP_GRAFT:
|
2020-12-04 09:35:32 +08:00
|
|
|
ND_PRINT(" src %s grp %s", GET_IPADDR_STRING(bp), GET_IPADDR_STRING(bp + 4));
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DVMRP_GRAFT_ACK:
|
2020-12-04 09:35:32 +08:00
|
|
|
ND_PRINT(" src %s grp %s", GET_IPADDR_STRING(bp), GET_IPADDR_STRING(bp + 4));
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
}
|
2003-11-19 17:42:04 +08:00
|
|
|
return;
|
|
|
|
|
2020-12-04 09:35:32 +08:00
|
|
|
invalid:
|
|
|
|
nd_print_invalid(ndo);
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:35:32 +08:00
|
|
|
static void
|
2014-03-21 20:48:24 +08:00
|
|
|
print_report(netdissect_options *ndo,
|
2020-12-04 09:35:32 +08:00
|
|
|
const u_char *bp,
|
2017-12-14 02:17:47 +08:00
|
|
|
u_int len)
|
1999-10-08 07:47:09 +08:00
|
|
|
{
|
2017-12-14 02:17:47 +08:00
|
|
|
uint32_t mask, origin;
|
2018-01-12 03:52:30 +08:00
|
|
|
u_int metric, done;
|
2017-12-14 02:17:47 +08:00
|
|
|
u_int i, width;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
|
|
|
while (len > 0) {
|
|
|
|
if (len < 3) {
|
2020-12-04 09:35:32 +08:00
|
|
|
ND_PRINT(" [length %u < 3]", len);
|
|
|
|
goto invalid;
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
2018-06-16 23:23:21 +08:00
|
|
|
mask = (uint32_t)0xff << 24 | GET_U_1(bp) << 16 |
|
|
|
|
GET_U_1(bp + 1) << 8 | GET_U_1(bp + 2);
|
1999-10-08 07:47:09 +08:00
|
|
|
width = 1;
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(bp))
|
1999-10-08 07:47:09 +08:00
|
|
|
width = 2;
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(bp + 1))
|
1999-10-08 07:47:09 +08:00
|
|
|
width = 3;
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(bp + 2))
|
1999-10-08 07:47:09 +08:00
|
|
|
width = 4;
|
|
|
|
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\n\tMask %s", intoa(htonl(mask)));
|
1999-10-08 07:47:09 +08:00
|
|
|
bp += 3;
|
|
|
|
len -= 3;
|
|
|
|
do {
|
|
|
|
if (len < width + 1) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\n\t [Truncated Report]");
|
2020-12-04 09:35:32 +08:00
|
|
|
goto invalid;
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
|
|
|
origin = 0;
|
2003-11-19 17:42:04 +08:00
|
|
|
for (i = 0; i < width; ++i) {
|
2018-06-16 23:23:21 +08:00
|
|
|
origin = origin << 8 | GET_U_1(bp);
|
2017-11-20 09:59:51 +08:00
|
|
|
bp++;
|
2003-11-19 17:42:04 +08:00
|
|
|
}
|
1999-10-08 07:47:09 +08:00
|
|
|
for ( ; i < 4; ++i)
|
|
|
|
origin <<= 8;
|
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
metric = GET_U_1(bp);
|
2017-11-20 09:59:51 +08:00
|
|
|
bp++;
|
1999-10-08 07:47:09 +08:00
|
|
|
done = metric & 0x80;
|
|
|
|
metric &= 0x7f;
|
2018-01-12 03:52:30 +08:00
|
|
|
ND_PRINT("\n\t %s metric %u", intoa(htonl(origin)),
|
2018-01-07 18:47:30 +08:00
|
|
|
metric);
|
1999-10-08 07:47:09 +08:00
|
|
|
len -= width + 1;
|
|
|
|
} while (!done);
|
|
|
|
}
|
2020-12-04 09:35:32 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
invalid:
|
|
|
|
nd_print_invalid(ndo);
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:35:32 +08:00
|
|
|
static void
|
2014-03-21 20:48:24 +08:00
|
|
|
print_probe(netdissect_options *ndo,
|
2020-12-04 09:35:32 +08:00
|
|
|
const u_char *bp,
|
2017-12-14 02:17:47 +08:00
|
|
|
u_int len)
|
1999-10-08 07:47:09 +08:00
|
|
|
{
|
2020-12-04 09:35:32 +08:00
|
|
|
if (len < 4) {
|
|
|
|
ND_PRINT(" [full length %u < 4]", len);
|
|
|
|
goto invalid;
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(ndo->ndo_vflag > 1 ? "\n\t" : " ");
|
2020-12-04 09:35:32 +08:00
|
|
|
ND_PRINT("genid %u", GET_BE_U_4(bp));
|
2014-03-21 20:48:24 +08:00
|
|
|
if (ndo->ndo_vflag < 2)
|
2020-12-04 09:35:32 +08:00
|
|
|
return;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2020-12-04 09:35:32 +08:00
|
|
|
bp += 4;
|
|
|
|
len -= 4;
|
|
|
|
while (len > 0) {
|
|
|
|
if (len < 4) {
|
|
|
|
ND_PRINT("[remaining length %u < 4]", len);
|
|
|
|
goto invalid;
|
|
|
|
}
|
2020-01-20 11:55:38 +08:00
|
|
|
ND_PRINT("\n\tneighbor %s", GET_IPADDR_STRING(bp));
|
1999-11-22 12:30:34 +08:00
|
|
|
bp += 4; len -= 4;
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
2020-12-04 09:35:32 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
invalid:
|
|
|
|
nd_print_invalid(ndo);
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:35:32 +08:00
|
|
|
static void
|
2014-03-21 20:48:24 +08:00
|
|
|
print_neighbors(netdissect_options *ndo,
|
2020-12-04 09:35:32 +08:00
|
|
|
const u_char *bp,
|
2017-12-14 02:17:47 +08:00
|
|
|
u_int len)
|
1999-10-08 07:47:09 +08:00
|
|
|
{
|
1999-11-22 12:30:34 +08:00
|
|
|
const u_char *laddr;
|
2017-12-14 02:17:47 +08:00
|
|
|
u_char metric;
|
|
|
|
u_char thresh;
|
|
|
|
int ncount;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2020-12-04 09:35:32 +08:00
|
|
|
while (len > 0) {
|
|
|
|
if (len < 7) {
|
|
|
|
ND_PRINT(" [length %u < 7]", len);
|
|
|
|
goto invalid;
|
|
|
|
}
|
1999-11-22 12:30:34 +08:00
|
|
|
laddr = bp;
|
|
|
|
bp += 4;
|
2018-06-16 23:23:21 +08:00
|
|
|
metric = GET_U_1(bp);
|
2017-11-20 09:59:51 +08:00
|
|
|
bp++;
|
2018-06-16 23:23:21 +08:00
|
|
|
thresh = GET_U_1(bp);
|
2017-11-20 09:59:51 +08:00
|
|
|
bp++;
|
2018-06-16 23:23:21 +08:00
|
|
|
ncount = GET_U_1(bp);
|
2017-11-20 09:59:51 +08:00
|
|
|
bp++;
|
1999-10-08 07:47:09 +08:00
|
|
|
len -= 7;
|
1999-11-22 12:30:34 +08:00
|
|
|
while (--ncount >= 0) {
|
2020-12-04 09:35:32 +08:00
|
|
|
if (len < 4) {
|
|
|
|
ND_PRINT(" [length %u < 4]", len);
|
|
|
|
goto invalid;
|
|
|
|
}
|
2020-01-20 11:55:38 +08:00
|
|
|
ND_PRINT(" [%s ->", GET_IPADDR_STRING(laddr));
|
2018-01-12 03:52:30 +08:00
|
|
|
ND_PRINT(" %s, (%u/%u)]",
|
2020-01-20 11:55:38 +08:00
|
|
|
GET_IPADDR_STRING(bp), metric, thresh);
|
1999-11-22 12:30:34 +08:00
|
|
|
bp += 4;
|
1999-10-08 07:47:09 +08:00
|
|
|
len -= 4;
|
|
|
|
}
|
|
|
|
}
|
2020-12-04 09:35:32 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
invalid:
|
|
|
|
nd_print_invalid(ndo);
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
|
|
|
|
2020-12-04 09:35:32 +08:00
|
|
|
static void
|
2014-03-21 20:48:24 +08:00
|
|
|
print_neighbors2(netdissect_options *ndo,
|
2020-12-04 09:35:32 +08:00
|
|
|
const u_char *bp,
|
2017-12-14 02:17:47 +08:00
|
|
|
u_int len, uint8_t major_version,
|
2017-11-23 02:54:31 +08:00
|
|
|
uint8_t minor_version)
|
1999-10-08 07:47:09 +08:00
|
|
|
{
|
1999-11-22 12:30:34 +08:00
|
|
|
const u_char *laddr;
|
2017-12-14 02:17:47 +08:00
|
|
|
u_char metric, thresh, flags;
|
|
|
|
int ncount;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" (v %u.%u):", major_version, minor_version);
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2020-12-04 09:35:32 +08:00
|
|
|
while (len > 0) {
|
|
|
|
if (len < 8) {
|
|
|
|
ND_PRINT(" [length %u < 8]", len);
|
|
|
|
goto invalid;
|
|
|
|
}
|
1999-11-22 12:30:34 +08:00
|
|
|
laddr = bp;
|
|
|
|
bp += 4;
|
2018-06-16 23:23:21 +08:00
|
|
|
metric = GET_U_1(bp);
|
2017-11-20 09:59:51 +08:00
|
|
|
bp++;
|
2018-06-16 23:23:21 +08:00
|
|
|
thresh = GET_U_1(bp);
|
2017-11-20 09:59:51 +08:00
|
|
|
bp++;
|
2018-06-16 23:23:21 +08:00
|
|
|
flags = GET_U_1(bp);
|
2017-11-20 09:59:51 +08:00
|
|
|
bp++;
|
2018-06-16 23:23:21 +08:00
|
|
|
ncount = GET_U_1(bp);
|
2017-11-20 09:59:51 +08:00
|
|
|
bp++;
|
1999-10-08 07:47:09 +08:00
|
|
|
len -= 8;
|
2020-12-04 09:35:32 +08:00
|
|
|
while (--ncount >= 0 && len > 0) {
|
|
|
|
if (len < 4) {
|
|
|
|
ND_PRINT(" [length %u < 4]", len);
|
|
|
|
goto invalid;
|
|
|
|
}
|
2020-01-20 11:55:38 +08:00
|
|
|
ND_PRINT(" [%s -> ", GET_IPADDR_STRING(laddr));
|
|
|
|
ND_PRINT("%s (%u/%u", GET_IPADDR_STRING(bp),
|
2018-01-07 18:47:30 +08:00
|
|
|
metric, thresh);
|
1999-10-08 07:47:09 +08:00
|
|
|
if (flags & DVMRP_NF_TUNNEL)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("/tunnel");
|
1999-10-08 07:47:09 +08:00
|
|
|
if (flags & DVMRP_NF_SRCRT)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("/srcrt");
|
1999-10-08 07:47:09 +08:00
|
|
|
if (flags & DVMRP_NF_QUERIER)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("/querier");
|
1999-10-08 07:47:09 +08:00
|
|
|
if (flags & DVMRP_NF_DISABLED)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("/disabled");
|
1999-10-08 07:47:09 +08:00
|
|
|
if (flags & DVMRP_NF_DOWN)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("/down");
|
|
|
|
ND_PRINT(")]");
|
1999-11-22 12:30:34 +08:00
|
|
|
bp += 4;
|
1999-10-08 07:47:09 +08:00
|
|
|
len -= 4;
|
|
|
|
}
|
|
|
|
if (ncount != -1) {
|
2020-12-04 09:35:32 +08:00
|
|
|
ND_PRINT(" [invalid ncount]");
|
|
|
|
goto invalid;
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
|
|
|
}
|
2020-12-04 09:35:32 +08:00
|
|
|
return;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2020-12-04 09:35:32 +08:00
|
|
|
invalid:
|
|
|
|
nd_print_invalid(ndo);
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|