diff options
author | Bill Fenner <fenner@FreeBSD.org> | 2002-06-21 00:43:23 +0000 |
---|---|---|
committer | Bill Fenner <fenner@FreeBSD.org> | 2002-06-21 00:43:23 +0000 |
commit | a90e161be323456b08b7fe13acb201536809510f (patch) | |
tree | bfb72dba6e8e623feaf334f1b808f93f5e292c68 /contrib/tcpdump/print-chdlc.c | |
parent | 39eaefddae4491b77468e6ff0cd5f9a6b9acbf3d (diff) | |
download | src-a90e161be323456b08b7fe13acb201536809510f.tar.gz src-a90e161be323456b08b7fe13acb201536809510f.zip |
Import tcpdump 3.7.1, from
Notes
Notes:
svn path=/vendor/tcpdump/dist/; revision=98524
Diffstat (limited to 'contrib/tcpdump/print-chdlc.c')
-rw-r--r-- | contrib/tcpdump/print-chdlc.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/contrib/tcpdump/print-chdlc.c b/contrib/tcpdump/print-chdlc.c index 09c58abb41f4..f6ff53378686 100644 --- a/contrib/tcpdump/print-chdlc.c +++ b/contrib/tcpdump/print-chdlc.c @@ -22,7 +22,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.11 2000/10/09 01:53:19 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.13 2001/09/17 21:57:57 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -42,6 +42,7 @@ static const char rcsid[] = #include "interface.h" #include "addrtoname.h" #include "ethertype.h" +#include "extract.h" #include "ppp.h" #include "chdlc.h" @@ -54,25 +55,38 @@ chdlc_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; - u_int proto; + ++infodelay; ts_print(&h->ts); - if (caplen < CHDLC_HDRLEN) { - printf("[|chdlc]"); - goto out; - } - /* * Some printers want to get back at the link level addresses, * and/or check that they're not walking off the end of the packet. * Rather than pass them all the way down, we set these globals. */ - proto = ntohs(*(u_short *)&p[2]); packetp = p; snapend = p + caplen; + chdlc_print(p, length, caplen); + + putchar('\n'); + --infodelay; + if (infoprint) + info(0); +} + +void +chdlc_print(register const u_char *p, u_int length, u_int caplen) +{ + const struct ip *ip; + u_int proto; + + if (caplen < CHDLC_HDRLEN) { + printf("[|chdlc]"); + return; + } + + proto = EXTRACT_16BITS(&p[2]); if (eflag) { switch (p[0]) { case CHDLC_UNICAST: @@ -89,7 +103,7 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h, } length -= CHDLC_HDRLEN; - ip = (struct ip *)(p + CHDLC_HDRLEN); + ip = (const struct ip *)(p + CHDLC_HDRLEN); switch (proto) { case ETHERTYPE_IP: ip_print((const u_char *)ip, length); @@ -110,8 +124,6 @@ chdlc_if_print(u_char *user, const struct pcap_pkthdr *h, } if (xflag) default_print((const u_char *)ip, caplen - CHDLC_HDRLEN); -out: - putchar('\n'); } struct cisco_slarp { @@ -140,14 +152,14 @@ struct cisco_slarp { static void chdlc_slarp_print(const u_char *cp, u_int length) { - struct cisco_slarp *slarp; + const struct cisco_slarp *slarp; if (length < SLARP_LEN) { printf("[|slarp]"); return; } - slarp = (struct cisco_slarp *)cp; + slarp = (const struct cisco_slarp *)cp; switch (ntohl(slarp->code)) { case SLARP_REQUEST: printf("slarp-request"); |