John Hay's extentions to tcpdump to be able to differentiate between
IP and IPX packets over a PPP link. I added the hack to print the PPP protocol type for other (eg: LCP, CCP, etc) packets. Submitted by: John Hay <jhay@mikom.csir.co.za>, mods from me.
This commit is contained in:
parent
2868020397
commit
27e4bc762f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=14358
@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: ethertype.h,v 1.4 94/06/14 20:11:45 leres Exp $ (LBL)
|
||||
* @(#) $Header: /home/ncvs/src/usr.sbin/tcpdump/tcpdump/ethertype.h,v 1.1 1995/03/08 12:52:12 olah Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/* Map between Ethernet protocol types and names */
|
||||
@ -67,4 +67,7 @@
|
||||
#ifndef ETHERTYPE_NS
|
||||
#define ETHERTYPE_NS 0x0600
|
||||
#endif
|
||||
#ifndef ETHERTYPE_IPX
|
||||
#define ETHERTYPE_IPX 0x8137
|
||||
#endif
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static char rcsid[] =
|
||||
"@(#) $Header: print-ether.c,v 1.37 94/06/10 17:01:29 mccanne Exp $ (LBL)";
|
||||
"@(#) $Header: /home/ncvs/src/usr.sbin/tcpdump/tcpdump/print-ether.c,v 1.3 1995/03/08 12:52:30 olah Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -181,6 +181,10 @@ ether_encap_print(u_short ethertype, const u_char *p, int length, int caplen)
|
||||
aarp_print(p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_IPX:
|
||||
ipx_print(p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_LAT:
|
||||
case ETHERTYPE_MOPRC:
|
||||
case ETHERTYPE_MOPDL:
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static char rcsid[] =
|
||||
"@(#)$Header: print-ipx.c,v 1.6 94/06/20 19:44:38 leres Exp $";
|
||||
"@(#)$Header: /home/ncvs/src/usr.sbin/tcpdump/tcpdump/print-ipx.c,v 1.1 1995/03/08 12:52:34 olah Exp $";
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -94,7 +94,7 @@ ipxaddr_string(u_int32 net, const u_char *node)
|
||||
{
|
||||
static char line[256];
|
||||
|
||||
sprintf(line, "%lu.%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
sprintf(line, "%lx.%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
net, node[0], node[1], node[2], node[3], node[4], node[5]);
|
||||
|
||||
return line;
|
||||
@ -192,13 +192,13 @@ ipx_rip_print(const u_short *ipx, int length)
|
||||
case 1:
|
||||
(void)printf("ipx-rip-req");
|
||||
if (length > 0)
|
||||
(void)printf(" %lu/%d.%d", EXTRACT_LONG(&ipx[0]),
|
||||
(void)printf(" %lx/%d.%d", EXTRACT_LONG(&ipx[0]),
|
||||
EXTRACT_SHORT(&ipx[2]), EXTRACT_SHORT(&ipx[3]));
|
||||
break;
|
||||
case 2:
|
||||
(void)printf("ipx-rip-resp");
|
||||
for (i = 0; i < 50 && length > 0; i++) {
|
||||
(void)printf(" %lu/%d.%d", EXTRACT_LONG(&ipx[0]),
|
||||
(void)printf(" %lx/%d.%d", EXTRACT_LONG(&ipx[0]),
|
||||
EXTRACT_SHORT(&ipx[2]), EXTRACT_SHORT(&ipx[3]));
|
||||
|
||||
ipx += 4;
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] =
|
||||
"@(#)$Header: print-ppp.c,v 1.18 94/06/10 17:01:37 mccanne Exp $ (LBL)";
|
||||
"@(#)$Header: /home/ncvs/src/usr.sbin/tcpdump/tcpdump/print-ppp.c,v 1.2 1995/03/08 12:52:40 olah Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef PPP
|
||||
@ -44,11 +44,54 @@ static char rcsid[] =
|
||||
#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,
|
||||
@ -56,7 +99,6 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
|
||||
{
|
||||
register int length = h->len;
|
||||
register int caplen = h->caplen;
|
||||
const struct ip *ip;
|
||||
|
||||
ts_print(&h->ts);
|
||||
|
||||
@ -74,15 +116,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');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user