diff options
author | guy <guy> | 2002-12-19 09:39:10 +0000 |
---|---|---|
committer | guy <guy> | 2002-12-19 09:39:10 +0000 |
commit | 4bec97f457e593be925e92fa28d73af6a57d81cf (patch) | |
tree | fcb53f0e4e3a5749d84858f128e7f6c7e352c23e /print-sl.c | |
parent | 60761585472a90c34d7de7bdf50475f0d7261b2d (diff) | |
download | tcpdump-4bec97f457e593be925e92fa28d73af6a57d81cf.tar.gz |
Hoist a bunch of stuff that should be done by all if_print routines into
tcpdump.c. Have if_print routines return the length of the link-layer
header, so that the common code knows how to skip the link-layer header
when printing the packet in hex/ASCII.
Diffstat (limited to 'print-sl.c')
-rw-r--r-- | print-sl.c | 51 |
1 files changed, 9 insertions, 42 deletions
@@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.61 2002-12-18 09:41:17 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.62 2002-12-19 09:39:15 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -48,28 +48,18 @@ static u_int lastconn = 255; static void sliplink_print(const u_char *, const struct ip *, u_int); static void compressed_sl_print(const u_char *, const struct ip *, u_int, int); -void -sl_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p) +u_int +sl_if_print(const struct pcap_pkthdr *h, const u_char *p) { register u_int caplen = h->caplen; register u_int length = h->len; register const struct ip *ip; - ++infodelay; - ts_print(&h->ts); - if (caplen < SLIP_HDRLEN) { printf("[|slip]"); - goto out; + return (caplen); } - /* - * Some printers want to check that they're not walking off the - * end of the packet. - * Rather than pass it all the way down, we set this global. - */ - snapend = p + caplen; - length -= SLIP_HDRLEN; ip = (struct ip *)(p + SLIP_HDRLEN); @@ -90,38 +80,21 @@ sl_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p) printf ("ip v%d", IP_V(ip)); } - if (xflag) - default_print_packet(p, caplen, SLIP_HDRLEN); - out: - putchar('\n'); - --infodelay; - if (infoprint) - info(0); + return (SLIP_HDRLEN); } - -void -sl_bsdos_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p) +u_int +sl_bsdos_if_print(const struct pcap_pkthdr *h, const u_char *p) { register u_int caplen = h->caplen; register u_int length = h->len; register const struct ip *ip; - ++infodelay; - ts_print(&h->ts); - if (caplen < SLIP_HDRLEN) { printf("[|slip]"); - goto out; + return (caplen); } - /* - * Some printers want to check that they're not walking off the - * end of the packet. - * Rather than pass it all the way down, we set this global. - */ - snapend = p + caplen; - length -= SLIP_HDRLEN; ip = (struct ip *)(p + SLIP_HDRLEN); @@ -133,13 +106,7 @@ sl_bsdos_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p ip_print((u_char *)ip, length); - if (xflag) - default_print_packet(p, caplen, SLIP_HDRLEN); - out: - putchar('\n'); - --infodelay; - if (infoprint) - info(0); + return (SLIP_HDRLEN); } static void |