diff options
author | hannes <hannes> | 2006-03-23 14:58:44 +0000 |
---|---|---|
committer | hannes <hannes> | 2006-03-23 14:58:44 +0000 |
commit | 5636348412ff1463a2b26f035237cf7cedef5cab (patch) | |
tree | 462be41ea2a72960a23172c72b1a7f50635b0dea | |
parent | 3820594d702f863088754f590546f21cfe3c562c (diff) | |
download | tcpdump-5636348412ff1463a2b26f035237cf7cedef5cab.tar.gz |
move the BSD AF defs into af.h and make the null and rip printer make use of it
-rw-r--r-- | af.c | 14 | ||||
-rw-r--r-- | af.h | 19 | ||||
-rw-r--r-- | print-null.c | 46 | ||||
-rw-r--r-- | print-rip.c | 16 |
4 files changed, 48 insertions, 47 deletions
@@ -17,7 +17,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/af.c,v 1.2 2006-02-27 07:25:27 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/af.c,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -49,3 +49,15 @@ struct tok af_values[] = { { AFNUM_VPLS, "VPLS"}, { 0, NULL}, }; + +struct tok bsd_af_values[] = { + { BSD_AFNUM_INET, "IPv4" }, + { BSD_AFNUM_NS, "NS" }, + { BSD_AFNUM_ISO, "ISO" }, + { BSD_AFNUM_APPLETALK, "Appletalk" }, + { BSD_AFNUM_IPX, "IPX" }, + { BSD_AFNUM_INET6_BSD, "IPv6" }, + { BSD_AFNUM_INET6_FREEBSD, "IPv6" }, + { BSD_AFNUM_INET6_DARWIN, "IPv6" }, + { 0, NULL} +}; @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/af.h,v 1.2 2006-02-27 07:25:27 hannes Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/af.h,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL) */ /* * Copyright (c) 1998-2006 The TCPDUMP project @@ -18,6 +18,7 @@ */ extern struct tok af_values[]; +extern struct tok bsd_af_values[]; /* RFC1700 address family numbers */ #define AFNUM_INET 1 @@ -38,3 +39,19 @@ extern struct tok af_values[]; #define AFNUM_VPLS 25 /* draft-kompella-ppvpn-l2vpn */ #define AFNUM_L2VPN 196 /* still to be approved by IANA */ + +/* + * BSD AF_ values. + * + * Unfortunately, the BSDs don't all use the same value for AF_INET6, + * so, because we want to be able to read captures from all of the BSDs, + * we check for all of them. + */ +#define BSD_AFNUM_INET 2 +#define BSD_AFNUM_NS 6 /* XEROX NS protocols */ +#define BSD_AFNUM_ISO 7 +#define BSD_AFNUM_APPLETALK 16 +#define BSD_AFNUM_IPX 23 +#define BSD_AFNUM_INET6_BSD 24 /* OpenBSD (and probably NetBSD), BSD/OS */ +#define BSD_AFNUM_INET6_FREEBSD 28 +#define BSD_AFNUM_INET6_DARWIN 30 diff --git a/print-null.c b/print-null.c index 6de6d489..a69997da 100644 --- a/print-null.c +++ b/print-null.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.56 2005-07-07 01:22:19 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.57 2006-03-23 14:58:44 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -41,6 +41,7 @@ static const char rcsid[] _U_ = #ifdef INET6 #include "ip6.h" #endif +#include "af.h" /* * The DLT_NULL packet header is 4 bytes long. It contains a host-byte-order @@ -55,35 +56,6 @@ static const char rcsid[] _U_ = #define NULL_HDRLEN 4 /* - * BSD AF_ values. - * - * Unfortunately, the BSDs don't all use the same value for AF_INET6, - * so, because we want to be able to read captures from all of the BSDs, - * we check for all of them. - */ -#define BSD_AF_INET 2 -#define BSD_AF_NS 6 /* XEROX NS protocols */ -#define BSD_AF_ISO 7 -#define BSD_AF_APPLETALK 16 -#define BSD_AF_IPX 23 -#define BSD_AF_INET6_BSD 24 /* OpenBSD (and probably NetBSD), BSD/OS */ -#define BSD_AF_INET6_FREEBSD 28 -#define BSD_AF_INET6_DARWIN 30 - -const struct tok bsd_af_values[] = { - { BSD_AF_INET, "IPv4" }, - { BSD_AF_NS, "NS" }, - { BSD_AF_ISO, "ISO" }, - { BSD_AF_APPLETALK, "Appletalk" }, - { BSD_AF_IPX, "IPX" }, - { BSD_AF_INET6_BSD, "IPv6" }, - { BSD_AF_INET6_FREEBSD, "IPv6" }, - { BSD_AF_INET6_DARWIN, "IPv6" }, - { 0, NULL} -}; - - -/* * Byte-swap a 32-bit number. * ("htonl()" or "ntohl()" won't work - we want to byte-swap even on * big-endian platforms.) @@ -145,27 +117,27 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p) switch (family) { - case BSD_AF_INET: + case BSD_AFNUM_INET: ip_print(gndo, p, length); break; #ifdef INET6 - case BSD_AF_INET6_BSD: - case BSD_AF_INET6_FREEBSD: - case BSD_AF_INET6_DARWIN: + case BSD_AFNUM_INET6_BSD: + case BSD_AFNUM_INET6_FREEBSD: + case BSD_AFNUM_INET6_DARWIN: ip6_print(p, length); break; #endif - case BSD_AF_ISO: + case BSD_AFNUM_ISO: isoclns_print(p, length, caplen); break; - case BSD_AF_APPLETALK: + case BSD_AFNUM_APPLETALK: atalk_print(p, length); break; - case BSD_AF_IPX: + case BSD_AFNUM_IPX: ipx_print(p, length); break; diff --git a/print-rip.c b/print-rip.c index c66c86db..27446a68 100644 --- a/print-rip.c +++ b/print-rip.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.58 2006-02-21 10:27:40 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.59 2006-03-23 14:58:44 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -102,8 +102,8 @@ rip_entry_print_v1(register const struct rip_netinfo *ni) /* RFC 1058 */ family = EXTRACT_16BITS(&ni->rip_family); - if (family != AF_INET) { - printf("\n\t AFI %s, ", tok2str(af_values, "Unknown (%u)", family)); + if (family != BSD_AFNUM_INET) { + printf("\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family)); print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t ",RIP_ROUTELEN); return; } @@ -113,7 +113,7 @@ rip_entry_print_v1(register const struct rip_netinfo *ni) /* MBZ fields not zero */ print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t ",RIP_ROUTELEN); return; - } /* AF_INET */ + } /* BSD_AFNUM_INET */ printf("\n\t %s, metric: %u", ipaddr_string(&ni->rip_dest), EXTRACT_32BITS(&ni->rip_metric)); @@ -141,13 +141,13 @@ rip_entry_print_v2(register const struct rip_netinfo *ni) EXTRACT_16BITS(&ni->rip_tag)); print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t ",RIP_AUTHLEN); } - } else if (family != AF_INET) { - printf("\n\t AFI %s", tok2str(af_values, "Unknown (%u)", family)); + } else if (family != BSD_AFNUM_INET) { + printf("\n\t AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family)); print_unknown_data((u_int8_t *)&ni->rip_tag,"\n\t ",RIP_ROUTELEN-2); return; - } else { /* AF_INET */ + } else { /* BSD_AFNUM_INET */ printf("\n\t AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ", - tok2str(af_values, "Unknown (%u)", family), + tok2str(bsd_af_values, "Unknown (%u)", family), ipaddr_string(&ni->rip_dest), mask2plen(EXTRACT_32BITS(&ni->rip_dest_mask)), EXTRACT_16BITS(&ni->rip_tag), |