Home | History | Annotate | Line # | Download | only in dist
print-rip.c revision 1.1.1.7
      1      1.1  christos /*
      2      1.1  christos  * Copyright (c) 1989, 1990, 1991, 1993, 1994, 1996
      3      1.1  christos  *	The Regents of the University of California.  All rights reserved.
      4      1.1  christos  *
      5      1.1  christos  * Redistribution and use in source and binary forms, with or without
      6      1.1  christos  * modification, are permitted provided that: (1) source code distributions
      7      1.1  christos  * retain the above copyright notice and this paragraph in its entirety, (2)
      8      1.1  christos  * distributions including binary code include the above copyright notice and
      9      1.1  christos  * this paragraph in its entirety in the documentation or other materials
     10      1.1  christos  * provided with the distribution, and (3) all advertising materials mentioning
     11      1.1  christos  * features or use of this software display the following acknowledgement:
     12      1.1  christos  * ``This product includes software developed by the University of California,
     13      1.1  christos  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
     14      1.1  christos  * the University nor the names of its contributors may be used to endorse
     15      1.1  christos  * or promote products derived from this software without specific prior
     16      1.1  christos  * written permission.
     17      1.1  christos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
     18      1.1  christos  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
     19      1.1  christos  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
     20      1.1  christos  */
     21      1.1  christos 
     22  1.1.1.6       spz /* \summary: Routing Information Protocol (RIP) printer */
     23  1.1.1.6       spz 
     24  1.1.1.7  christos /* specification: RFC 1058, RFC 2453, RFC 4822 */
     25  1.1.1.7  christos 
     26      1.1  christos #ifdef HAVE_CONFIG_H
     27  1.1.1.7  christos #include <config.h>
     28      1.1  christos #endif
     29      1.1  christos 
     30  1.1.1.7  christos #include "netdissect-stdinc.h"
     31      1.1  christos 
     32  1.1.1.5  christos #include "netdissect.h"
     33      1.1  christos #include "addrtoname.h"
     34  1.1.1.5  christos #include "extract.h"
     35      1.1  christos 
     36      1.1  christos #include "af.h"
     37      1.1  christos 
     38  1.1.1.4  christos 
     39  1.1.1.7  christos /*
     40  1.1.1.7  christos  * RFC 1058 and RFC 2453 header of packet.
     41  1.1.1.7  christos  *
     42  1.1.1.7  christos  *  0                   1                   2                   3 3
     43  1.1.1.7  christos  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
     44  1.1.1.7  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     45  1.1.1.7  christos  * | Command (1)   | Version (1)   |           unused              |
     46  1.1.1.7  christos  * +---------------+---------------+-------------------------------+
     47  1.1.1.7  christos  */
     48      1.1  christos struct rip {
     49  1.1.1.7  christos 	nd_uint8_t rip_cmd;		/* request/response */
     50  1.1.1.7  christos 	nd_uint8_t rip_vers;		/* protocol version # */
     51  1.1.1.7  christos 	nd_byte    unused[2];		/* unused */
     52      1.1  christos };
     53      1.1  christos 
     54      1.1  christos #define	RIPCMD_REQUEST		1	/* want info */
     55      1.1  christos #define	RIPCMD_RESPONSE		2	/* responding to request */
     56      1.1  christos #define	RIPCMD_TRACEON		3	/* turn tracing on */
     57      1.1  christos #define	RIPCMD_TRACEOFF		4	/* turn it off */
     58      1.1  christos #define	RIPCMD_POLL		5	/* want info from everybody */
     59      1.1  christos #define	RIPCMD_POLLENTRY	6	/* poll for entry */
     60      1.1  christos 
     61      1.1  christos static const struct tok rip_cmd_values[] = {
     62      1.1  christos     { RIPCMD_REQUEST,	        "Request" },
     63      1.1  christos     { RIPCMD_RESPONSE,	        "Response" },
     64      1.1  christos     { RIPCMD_TRACEON,	        "Trace on" },
     65      1.1  christos     { RIPCMD_TRACEOFF,	        "Trace off" },
     66      1.1  christos     { RIPCMD_POLL,	        "Poll" },
     67      1.1  christos     { RIPCMD_POLLENTRY,	        "Poll Entry" },
     68      1.1  christos     { 0, NULL}
     69      1.1  christos };
     70      1.1  christos 
     71      1.1  christos #define RIP_AUTHLEN  16
     72      1.1  christos #define RIP_ROUTELEN 20
     73      1.1  christos 
     74      1.1  christos /*
     75  1.1.1.7  christos  * First 4 bytes of all RIPv1/RIPv2 entries.
     76  1.1.1.7  christos  */
     77  1.1.1.7  christos struct rip_entry_header {
     78  1.1.1.7  christos 	nd_uint16_t rip_family;
     79  1.1.1.7  christos 	nd_uint16_t rip_tag;
     80  1.1.1.7  christos };
     81  1.1.1.7  christos 
     82  1.1.1.7  christos /*
     83  1.1.1.7  christos  * RFC 1058 entry.
     84  1.1.1.7  christos  *
     85  1.1.1.7  christos  *  0                   1                   2                   3 3
     86  1.1.1.7  christos  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
     87  1.1.1.7  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     88  1.1.1.7  christos  * | Address Family Identifier (2) |       must be zero (2)        |
     89  1.1.1.7  christos  * +-------------------------------+-------------------------------+
     90  1.1.1.7  christos  * |                         IP Address (4)                        |
     91  1.1.1.7  christos  * +---------------------------------------------------------------+
     92  1.1.1.7  christos  * |                        must be zero (4)                       |
     93  1.1.1.7  christos  * +---------------------------------------------------------------+
     94  1.1.1.7  christos  * |                        must be zero (4)                       |
     95  1.1.1.7  christos  * +---------------------------------------------------------------+
     96  1.1.1.7  christos  * |                         Metric (4)                            |
     97  1.1.1.7  christos  * +---------------------------------------------------------------+
     98  1.1.1.7  christos  */
     99  1.1.1.7  christos struct rip_netinfo_v1 {
    100  1.1.1.7  christos 	nd_uint16_t rip_family;
    101  1.1.1.7  christos 	nd_byte     rip_mbz1[2];
    102  1.1.1.7  christos 	nd_ipv4     rip_dest;
    103  1.1.1.7  christos 	nd_byte     rip_mbz2[4];
    104  1.1.1.7  christos 	nd_byte     rip_mbz3[4];
    105  1.1.1.7  christos 	nd_uint32_t rip_metric;		/* cost of route */
    106  1.1.1.7  christos };
    107  1.1.1.7  christos 
    108  1.1.1.7  christos 
    109  1.1.1.7  christos /*
    110  1.1.1.7  christos  * RFC 2453 route entry
    111  1.1.1.4  christos  *
    112      1.1  christos  *  0                   1                   2                   3 3
    113      1.1  christos  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    114      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    115      1.1  christos  * | Address Family Identifier (2) |        Route Tag (2)          |
    116      1.1  christos  * +-------------------------------+-------------------------------+
    117      1.1  christos  * |                         IP Address (4)                        |
    118      1.1  christos  * +---------------------------------------------------------------+
    119      1.1  christos  * |                         Subnet Mask (4)                       |
    120      1.1  christos  * +---------------------------------------------------------------+
    121      1.1  christos  * |                         Next Hop (4)                          |
    122      1.1  christos  * +---------------------------------------------------------------+
    123      1.1  christos  * |                         Metric (4)                            |
    124      1.1  christos  * +---------------------------------------------------------------+
    125      1.1  christos  *
    126      1.1  christos  */
    127      1.1  christos 
    128  1.1.1.7  christos struct rip_netinfo_v2 {
    129  1.1.1.7  christos 	nd_uint16_t rip_family;
    130  1.1.1.7  christos 	nd_uint16_t rip_tag;
    131  1.1.1.7  christos 	nd_ipv4     rip_dest;
    132  1.1.1.7  christos 	nd_uint32_t rip_dest_mask;
    133  1.1.1.7  christos 	nd_ipv4     rip_router;
    134  1.1.1.7  christos 	nd_uint32_t rip_metric;		/* cost of route */
    135  1.1.1.7  christos };
    136  1.1.1.7  christos 
    137  1.1.1.7  christos /*
    138  1.1.1.7  christos  * RFC 2453 authentication entry
    139  1.1.1.7  christos  *
    140  1.1.1.7  christos  *  0                   1                   2                   3 3
    141  1.1.1.7  christos  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    142  1.1.1.7  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    143  1.1.1.7  christos  * |            0xFFFF             |    Authentication Type (2)    |
    144  1.1.1.7  christos  * +-------------------------------+-------------------------------+
    145  1.1.1.7  christos  * -                      Authentication (16)                      -
    146  1.1.1.7  christos  * +---------------------------------------------------------------+
    147  1.1.1.7  christos  */
    148  1.1.1.7  christos 
    149  1.1.1.7  christos struct rip_auth_v2 {
    150  1.1.1.7  christos 	nd_uint16_t rip_family;
    151  1.1.1.7  christos 	nd_uint16_t rip_tag;
    152  1.1.1.7  christos 	nd_byte     rip_auth[16];
    153      1.1  christos };
    154      1.1  christos 
    155  1.1.1.7  christos /*
    156  1.1.1.7  christos  * RFC 4822 Cryptographic Authentication entry.
    157  1.1.1.7  christos  *
    158  1.1.1.7  christos  *  0                   1                   2                   3 3
    159  1.1.1.7  christos  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    160  1.1.1.7  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    161  1.1.1.7  christos  * |     RIPv2 Packet Length       |   Key ID      | Auth Data Len |
    162  1.1.1.7  christos  * +---------------+---------------+---------------+---------------+
    163  1.1.1.7  christos  * |               Sequence Number (non-decreasing)                |
    164  1.1.1.7  christos  * +---------------+---------------+---------------+---------------+
    165  1.1.1.7  christos  * |                      reserved must be zero                    |
    166  1.1.1.7  christos  * +---------------+---------------+---------------+---------------+
    167  1.1.1.7  christos  * |                      reserved must be zero                    |
    168  1.1.1.7  christos  * +---------------+---------------+---------------+---------------+
    169  1.1.1.7  christos  */
    170  1.1.1.7  christos struct rip_auth_crypto_v2 {
    171  1.1.1.7  christos 	nd_uint16_t rip_packet_len;
    172  1.1.1.7  christos 	nd_uint8_t  rip_key_id;
    173  1.1.1.7  christos 	nd_uint8_t  rip_auth_data_len;
    174  1.1.1.7  christos 	nd_uint32_t rip_seq_num;
    175  1.1.1.7  christos 	nd_byte     rip_mbz1[4];
    176  1.1.1.7  christos 	nd_byte     rip_mbz2[4];
    177  1.1.1.7  christos };
    178  1.1.1.7  christos 
    179  1.1.1.7  christos static unsigned
    180  1.1.1.7  christos rip_entry_print_v1(netdissect_options *ndo, const u_char *p,
    181  1.1.1.7  christos 		   unsigned remaining)
    182      1.1  christos {
    183  1.1.1.7  christos 	const struct rip_entry_header *eh = (const struct rip_entry_header *)p;
    184  1.1.1.7  christos 	u_short family;
    185  1.1.1.7  christos 	const struct rip_netinfo_v1 *ni = (const struct rip_netinfo_v1 *)p;
    186      1.1  christos 
    187      1.1  christos 	/* RFC 1058 */
    188  1.1.1.7  christos 	if (remaining < RIP_ROUTELEN)
    189  1.1.1.7  christos 		return (0);
    190  1.1.1.7  christos 	ND_TCHECK_SIZE(ni);
    191  1.1.1.7  christos 	family = GET_BE_U_2(ni->rip_family);
    192  1.1.1.3  christos 	if (family != BSD_AFNUM_INET && family != 0) {
    193  1.1.1.7  christos 		ND_PRINT("\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family));
    194  1.1.1.7  christos 		print_unknown_data(ndo, p + sizeof(*eh), "\n\t  ", RIP_ROUTELEN - sizeof(*eh));
    195  1.1.1.7  christos 		return (RIP_ROUTELEN);
    196      1.1  christos 	}
    197  1.1.1.7  christos 	if (GET_BE_U_2(ni->rip_mbz1) ||
    198  1.1.1.7  christos 	    GET_BE_U_4(ni->rip_mbz2) ||
    199  1.1.1.7  christos 	    GET_BE_U_4(ni->rip_mbz3)) {
    200      1.1  christos 		/* MBZ fields not zero */
    201  1.1.1.7  christos 		print_unknown_data(ndo, p, "\n\t  ", RIP_ROUTELEN);
    202  1.1.1.7  christos 		return (RIP_ROUTELEN);
    203  1.1.1.3  christos 	}
    204  1.1.1.3  christos 	if (family == 0) {
    205  1.1.1.7  christos 		ND_PRINT("\n\t  AFI 0, %s, metric: %u",
    206  1.1.1.7  christos 			 GET_IPADDR_STRING(ni->rip_dest),
    207  1.1.1.7  christos 			 GET_BE_U_4(ni->rip_metric));
    208  1.1.1.7  christos 		return (RIP_ROUTELEN);
    209      1.1  christos 	} /* BSD_AFNUM_INET */
    210  1.1.1.7  christos 	ND_PRINT("\n\t  %s, metric: %u",
    211  1.1.1.7  christos 		 GET_IPADDR_STRING(ni->rip_dest),
    212  1.1.1.7  christos 		 GET_BE_U_4(ni->rip_metric));
    213  1.1.1.7  christos 	return (RIP_ROUTELEN);
    214  1.1.1.7  christos trunc:
    215  1.1.1.7  christos 	return 0;
    216      1.1  christos }
    217      1.1  christos 
    218  1.1.1.3  christos static unsigned
    219  1.1.1.7  christos rip_entry_print_v2(netdissect_options *ndo, const u_char *p,
    220  1.1.1.7  christos 		   unsigned remaining)
    221      1.1  christos {
    222  1.1.1.7  christos 	const struct rip_entry_header *eh = (const struct rip_entry_header *)p;
    223  1.1.1.7  christos 	u_short family;
    224  1.1.1.7  christos 	const struct rip_netinfo_v2 *ni;
    225  1.1.1.7  christos 
    226  1.1.1.7  christos 	if (remaining < sizeof(*eh))
    227  1.1.1.7  christos 		return (0);
    228  1.1.1.7  christos 	ND_TCHECK_SIZE(eh);
    229  1.1.1.7  christos 	family = GET_BE_U_2(eh->rip_family);
    230  1.1.1.3  christos 	if (family == 0xFFFF) { /* variable-sized authentication structures */
    231  1.1.1.7  christos 		uint16_t auth_type = GET_BE_U_2(eh->rip_tag);
    232  1.1.1.7  christos 
    233  1.1.1.7  christos 		p += sizeof(*eh);
    234  1.1.1.7  christos 		remaining -= sizeof(*eh);
    235  1.1.1.3  christos 		if (auth_type == 2) {
    236  1.1.1.7  christos 			ND_PRINT("\n\t  Simple Text Authentication data: ");
    237  1.1.1.7  christos 			nd_printjnp(ndo, p, RIP_AUTHLEN);
    238  1.1.1.3  christos 		} else if (auth_type == 3) {
    239  1.1.1.7  christos 			const struct rip_auth_crypto_v2 *ch;
    240  1.1.1.7  christos 
    241  1.1.1.7  christos 			ch = (const struct rip_auth_crypto_v2 *)p;
    242  1.1.1.7  christos 			ND_TCHECK_SIZE(ch);
    243  1.1.1.7  christos 			if (remaining < sizeof(*ch))
    244  1.1.1.7  christos 				return (0);
    245  1.1.1.7  christos 			ND_PRINT("\n\t  Auth header:");
    246  1.1.1.7  christos 			ND_PRINT(" Packet Len %u,",
    247  1.1.1.7  christos 				 GET_BE_U_2(ch->rip_packet_len));
    248  1.1.1.7  christos 			ND_PRINT(" Key-ID %u,", GET_U_1(ch->rip_key_id));
    249  1.1.1.7  christos 			ND_PRINT(" Auth Data Len %u,",
    250  1.1.1.7  christos 				 GET_U_1(ch->rip_auth_data_len));
    251  1.1.1.7  christos 			ND_PRINT(" SeqNo %u,", GET_BE_U_4(ch->rip_seq_num));
    252  1.1.1.7  christos 			ND_PRINT(" MBZ %u,", GET_BE_U_4(ch->rip_mbz1));
    253  1.1.1.7  christos 			ND_PRINT(" MBZ %u", GET_BE_U_4(ch->rip_mbz2));
    254  1.1.1.3  christos 		} else if (auth_type == 1) {
    255  1.1.1.7  christos 			ND_PRINT("\n\t  Auth trailer:");
    256  1.1.1.7  christos 			print_unknown_data(ndo, p, "\n\t  ", remaining);
    257  1.1.1.7  christos 			return (sizeof(*eh) + remaining); /* AT spans till the packet end */
    258  1.1.1.4  christos 		} else {
    259  1.1.1.7  christos 			ND_PRINT("\n\t  Unknown (%u) Authentication data:",
    260  1.1.1.7  christos 				 auth_type);
    261  1.1.1.7  christos 			print_unknown_data(ndo, p, "\n\t  ", remaining);
    262  1.1.1.7  christos 			return (sizeof(*eh) + remaining); /* we don't know how long this is, so we go to the packet end */
    263      1.1  christos 		}
    264  1.1.1.3  christos 	} else if (family != BSD_AFNUM_INET && family != 0) {
    265  1.1.1.7  christos 		ND_PRINT("\n\t  AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family));
    266  1.1.1.7  christos 		print_unknown_data(ndo, p + sizeof(*eh), "\n\t  ", RIP_ROUTELEN - sizeof(*eh));
    267  1.1.1.3  christos 	} else { /* BSD_AFNUM_INET or AFI 0 */
    268  1.1.1.7  christos 		ni = (const struct rip_netinfo_v2 *)p;
    269  1.1.1.7  christos 		ND_TCHECK_SIZE(ni);
    270  1.1.1.7  christos 		if (remaining < sizeof(*ni))
    271  1.1.1.7  christos 			return (0);
    272  1.1.1.7  christos 		ND_PRINT("\n\t  AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
    273  1.1.1.7  christos 			 tok2str(bsd_af_values, "%u", family),
    274  1.1.1.7  christos 			 GET_IPADDR_STRING(ni->rip_dest),
    275  1.1.1.7  christos 			 mask2plen(GET_BE_U_4(ni->rip_dest_mask)),
    276  1.1.1.7  christos 			 GET_BE_U_2(ni->rip_tag),
    277  1.1.1.7  christos 			 GET_BE_U_4(ni->rip_metric));
    278  1.1.1.7  christos 		if (GET_BE_U_4(ni->rip_router))
    279  1.1.1.7  christos 			ND_PRINT("%s", GET_IPADDR_STRING(ni->rip_router));
    280  1.1.1.4  christos 		else
    281  1.1.1.7  christos 			ND_PRINT("self");
    282      1.1  christos 	}
    283  1.1.1.7  christos 	return (RIP_ROUTELEN);
    284  1.1.1.7  christos trunc:
    285  1.1.1.7  christos 	return 0;
    286      1.1  christos }
    287      1.1  christos 
    288      1.1  christos void
    289  1.1.1.4  christos rip_print(netdissect_options *ndo,
    290  1.1.1.7  christos 	  const u_char *dat, u_int length)
    291      1.1  christos {
    292  1.1.1.7  christos 	const struct rip *rp;
    293  1.1.1.7  christos 	uint8_t vers, cmd;
    294  1.1.1.7  christos 	const u_char *p;
    295  1.1.1.7  christos 	u_int len, routecount;
    296  1.1.1.7  christos 	unsigned entry_size;
    297      1.1  christos 
    298  1.1.1.7  christos 	ndo->ndo_protocol = "rip";
    299  1.1.1.4  christos 	if (ndo->ndo_snapend < dat) {
    300  1.1.1.7  christos 		nd_print_trunc(ndo);
    301      1.1  christos 		return;
    302      1.1  christos 	}
    303  1.1.1.7  christos 	len = ND_BYTES_AVAILABLE_AFTER(dat);
    304  1.1.1.7  christos 	if (len > length)
    305  1.1.1.7  christos 		len = length;
    306  1.1.1.7  christos 	if (len < sizeof(*rp)) {
    307  1.1.1.7  christos 		nd_print_trunc(ndo);
    308      1.1  christos 		return;
    309      1.1  christos 	}
    310  1.1.1.7  christos 	len -= sizeof(*rp);
    311      1.1  christos 
    312  1.1.1.5  christos 	rp = (const struct rip *)dat;
    313      1.1  christos 
    314  1.1.1.7  christos 	ND_TCHECK_SIZE(rp);
    315  1.1.1.7  christos 	vers = GET_U_1(rp->rip_vers);
    316  1.1.1.7  christos 	ND_PRINT("%sRIPv%u",
    317  1.1.1.7  christos 		 (ndo->ndo_vflag >= 1) ? "\n\t" : "",
    318  1.1.1.7  christos 		 vers);
    319      1.1  christos 
    320  1.1.1.7  christos 	if (vers == 0) {
    321      1.1  christos 		/*
    322      1.1  christos 		 * RFC 1058.
    323      1.1  christos 		 *
    324      1.1  christos 		 * XXX - RFC 1058 says
    325      1.1  christos 		 *
    326      1.1  christos 		 * 0  Datagrams whose version number is zero are to be ignored.
    327      1.1  christos 		 *    These are from a previous version of the protocol, whose
    328      1.1  christos 		 *    packet format was machine-specific.
    329      1.1  christos 		 *
    330      1.1  christos 		 * so perhaps we should just dump the packet, in hex.
    331      1.1  christos 		 */
    332  1.1.1.7  christos 		print_unknown_data(ndo, (const uint8_t *)&rp->rip_cmd, "\n\t", length);
    333  1.1.1.7  christos 		return;
    334  1.1.1.7  christos 	}
    335  1.1.1.7  christos 
    336  1.1.1.7  christos 	/* dump version and lets see if we know the commands name*/
    337  1.1.1.7  christos 	cmd = GET_U_1(rp->rip_cmd);
    338  1.1.1.7  christos 	ND_PRINT(", %s, length: %u",
    339  1.1.1.7  christos 		tok2str(rip_cmd_values, "unknown command (%u)", cmd),
    340  1.1.1.7  christos 		length);
    341  1.1.1.7  christos 
    342  1.1.1.7  christos 	if (ndo->ndo_vflag < 1)
    343  1.1.1.7  christos 		return;
    344  1.1.1.7  christos 
    345  1.1.1.7  christos 	switch (cmd) {
    346  1.1.1.7  christos 
    347  1.1.1.7  christos 	case RIPCMD_REQUEST:
    348  1.1.1.7  christos 	case RIPCMD_RESPONSE:
    349  1.1.1.7  christos 		switch (vers) {
    350  1.1.1.7  christos 
    351  1.1.1.7  christos 		case 1:
    352  1.1.1.7  christos 			routecount = length / RIP_ROUTELEN;
    353  1.1.1.7  christos 			ND_PRINT(", routes: %u", routecount);
    354  1.1.1.7  christos 			p = (const u_char *)(rp + 1);
    355  1.1.1.7  christos 			while (len != 0) {
    356  1.1.1.7  christos 				entry_size = rip_entry_print_v1(ndo, p, len);
    357  1.1.1.7  christos 				if (entry_size == 0) {
    358  1.1.1.7  christos 					/* Error */
    359  1.1.1.7  christos 					nd_print_trunc(ndo);
    360  1.1.1.7  christos 					break;
    361  1.1.1.3  christos 				}
    362  1.1.1.7  christos 				if (len < entry_size) {
    363  1.1.1.7  christos 					ND_PRINT(" [remaining entries length %u < %u]",
    364  1.1.1.7  christos 						 len, entry_size);
    365  1.1.1.7  christos 					nd_print_invalid(ndo);
    366  1.1.1.7  christos 					break;
    367  1.1.1.7  christos 				}
    368  1.1.1.7  christos 				p += entry_size;
    369  1.1.1.7  christos 				len -= entry_size;
    370      1.1  christos 			}
    371      1.1  christos 			break;
    372      1.1  christos 
    373  1.1.1.7  christos 		case 2:
    374  1.1.1.7  christos 			routecount = length / RIP_ROUTELEN;
    375  1.1.1.7  christos 			ND_PRINT(", routes: %u or less", routecount);
    376  1.1.1.7  christos 			p = (const u_char *)(rp + 1);
    377  1.1.1.7  christos 			while (len != 0) {
    378  1.1.1.7  christos 				entry_size = rip_entry_print_v2(ndo, p, len);
    379  1.1.1.7  christos 				if (entry_size == 0) {
    380  1.1.1.7  christos 					/* Error */
    381  1.1.1.7  christos 					nd_print_trunc(ndo);
    382  1.1.1.7  christos 					break;
    383  1.1.1.7  christos 				}
    384  1.1.1.7  christos 				if (len < entry_size) {
    385  1.1.1.7  christos 					ND_PRINT(" [remaining entries length %u < %u]",
    386  1.1.1.7  christos 						 len, entry_size);
    387  1.1.1.7  christos 					nd_print_invalid(ndo);
    388  1.1.1.7  christos 					break;
    389  1.1.1.7  christos 				}
    390  1.1.1.7  christos 				p += entry_size;
    391  1.1.1.7  christos 				len -= entry_size;
    392  1.1.1.7  christos 			}
    393      1.1  christos 			break;
    394      1.1  christos 
    395  1.1.1.7  christos 		default:
    396  1.1.1.7  christos 			ND_PRINT(", unknown version");
    397  1.1.1.7  christos 			break;
    398  1.1.1.7  christos 		}
    399  1.1.1.7  christos 		break;
    400      1.1  christos 
    401  1.1.1.7  christos 	case RIPCMD_TRACEOFF:
    402  1.1.1.7  christos 	case RIPCMD_POLL:
    403  1.1.1.7  christos 	case RIPCMD_POLLENTRY:
    404  1.1.1.7  christos 		break;
    405      1.1  christos 
    406  1.1.1.7  christos 	case RIPCMD_TRACEON:
    407  1.1.1.7  christos 		/* fall through */
    408  1.1.1.7  christos 	default:
    409  1.1.1.7  christos 		if (ndo->ndo_vflag <= 1) {
    410  1.1.1.7  christos 			if (!print_unknown_data(ndo, (const uint8_t *)rp, "\n\t", length))
    411  1.1.1.7  christos 				return;
    412  1.1.1.7  christos 		}
    413  1.1.1.7  christos 		break;
    414  1.1.1.7  christos 	}
    415  1.1.1.7  christos 	/* do we want to see an additionally hexdump ? */
    416  1.1.1.7  christos 	if (ndo->ndo_vflag> 1) {
    417  1.1.1.7  christos 		if (!print_unknown_data(ndo, (const uint8_t *)rp, "\n\t", length))
    418  1.1.1.7  christos 			return;
    419  1.1.1.7  christos 	}
    420  1.1.1.7  christos trunc:
    421  1.1.1.7  christos 	return;
    422  1.1.1.7  christos }
    423