diff options
author | pst <pst@FreeBSD.org> | 1996-08-19 21:43:47 +0000 |
---|---|---|
committer | pst <pst@FreeBSD.org> | 1996-08-19 21:43:47 +0000 |
commit | ba60cfc23e33a3640ab71ab76c4423586661a70b (patch) | |
tree | 10c0af27627979e06595a6452411f316dff8b16b | |
parent | f47481b22a181d4a84c2efcdf075dcab684e2e4d (diff) | |
download | FreeBSD-src-ba60cfc23e33a3640ab71ab76c4423586661a70b.zip FreeBSD-src-ba60cfc23e33a3640ab71ab76c4423586661a70b.tar.gz |
Print IPX packets over a PPP link.
Always display IPX network number in decimal (industry standard).
Decode other PPP protocol types too.
Submitted by: peter, pst, John Hay <jhay@mikom.csir.co.za>
-rw-r--r-- | contrib/tcpdump/ethertype.h | 3 | ||||
-rw-r--r-- | contrib/tcpdump/print-ipx.c | 4 | ||||
-rw-r--r-- | contrib/tcpdump/print-ppp.c | 74 |
3 files changed, 71 insertions, 10 deletions
diff --git a/contrib/tcpdump/ethertype.h b/contrib/tcpdump/ethertype.h index 2403073..1d62670 100644 --- a/contrib/tcpdump/ethertype.h +++ b/contrib/tcpdump/ethertype.h @@ -71,6 +71,9 @@ #ifndef ETHERTYPE_AARP #define ETHERTYPE_AARP 0x80f3 #endif +#ifndef ETHERTYPE_IPX +#define ETHERTYPE_IPX 0x8137 +#endif #ifndef ETHERTYPE_LOOPBACK #define ETHERTYPE_LOOPBACK 0x9000 #endif diff --git a/contrib/tcpdump/print-ipx.c b/contrib/tcpdump/print-ipx.c index 77666ca1..8125e41 100644 --- a/contrib/tcpdump/print-ipx.c +++ b/contrib/tcpdump/print-ipx.c @@ -191,7 +191,7 @@ ipx_rip_print(const u_short *ipx, u_int length) (void)printf("ipx-rip-req"); if (length > 0) { TCHECK(ipx[3]); - (void)printf(" %u/%d.%d", EXTRACT_32BITS(&ipx[0]), + (void)printf(" %x/%d.%d", EXTRACT_32BITS(&ipx[0]), EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])); } break; @@ -199,7 +199,7 @@ ipx_rip_print(const u_short *ipx, u_int length) (void)printf("ipx-rip-resp"); for (i = 0; i < 50 && length > 0; i++) { TCHECK(ipx[3]); - (void)printf(" %u/%d.%d", EXTRACT_32BITS(&ipx[0]), + (void)printf(" %x/%d.%d", EXTRACT_32BITS(&ipx[0]), EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])); ipx += 4; diff --git a/contrib/tcpdump/print-ppp.c b/contrib/tcpdump/print-ppp.c index 5436551..2c21c2b 100644 --- a/contrib/tcpdump/print-ppp.c +++ b/contrib/tcpdump/print-ppp.c @@ -47,11 +47,54 @@ struct rtentry; #include <signal.h> #include <stdio.h> +#include <netinet/if_ether.h> +#include "ethertype.h" + +#include <net/ppp_defs.h> #include "interface.h" #include "addrtoname.h" -/* XXX This goes somewhere else. */ -#define PPP_HDRLEN 4 +struct protonames { + u_short protocol; + char *name; +}; + +static struct protonames protonames[] = { + /* + * Protocol field values. + */ + PPP_IP, "IP", /* Internet Protocol */ + PPP_XNS, "XNS", /* Xerox NS */ + PPP_IPX, "IPX", /* IPX Datagram (RFC1552) */ + PPP_VJC_COMP, "VJC_UNCOMP", /* VJ compressed TCP */ + PPP_VJC_UNCOMP, "VJC_UNCOMP", /* VJ uncompressed TCP */ + PPP_COMP, "COMP", /* compressed packet */ + PPP_IPCP, "IPCP", /* IP Control Protocol */ + PPP_IPXCP, "IPXCP", /* IPX Control Protocol (RFC1552) */ + PPP_CCP, "CCP", /* Compression Control Protocol */ + PPP_LCP, "LCP", /* Link Control Protocol */ + PPP_PAP, "PAP", /* Password Authentication Protocol */ + PPP_LQR, "LQR", /* Link Quality Report protocol */ + PPP_CHAP, "CHAP", /* Cryptographic Handshake Auth. Proto*/ +}; + +void +ppp_hdlc_print(const u_char *p, int length) +{ + int proto = PPP_PROTOCOL(p); + int i; + + printf("%4d %02x ", length, PPP_CONTROL(p)); + + for (i = (sizeof(protonames) / sizeof(protonames[0])) - 1; i >= 0; --i){ + if (proto == protonames[i].protocol) { + printf("%s: ", protonames[i].name); + break; + } + } + if (i < 0) + printf("%04x: ", proto); +} void ppp_if_print(u_char *user, const struct pcap_pkthdr *h, @@ -59,7 +102,6 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h, { register u_int length = h->len; register u_int caplen = h->caplen; - const struct ip *ip; ts_print(&h->ts); @@ -77,15 +119,31 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h, snapend = p + caplen; if (eflag) - printf("%c %4d %02x %04x: ", p[0] ? 'O' : 'I', length, - p[1], ntohs(*(u_short *)&p[2])); + ppp_hdlc_print(p, length); length -= PPP_HDRLEN; - ip = (struct ip *)(p + PPP_HDRLEN); - ip_print((const u_char *)ip, length); + + switch(PPP_PROTOCOL(p)) { + case PPP_IP: + case ETHERTYPE_IP: + ip_print((const u_char *)(p + PPP_HDRLEN), length); + break; + case PPP_IPX: + case ETHERTYPE_IPX: + ipx_print((const u_char *)(p + PPP_HDRLEN), length); + break; + + default: + if(!eflag) + ppp_hdlc_print(p, length); + if(!xflag) + default_print((const u_char *)(p + PPP_HDRLEN), + caplen - PPP_HDRLEN); + } if (xflag) - default_print((const u_char *)ip, caplen - PPP_HDRLEN); + default_print((const u_char *)(p + PPP_HDRLEN), + caplen - PPP_HDRLEN); out: putchar('\n'); } |