diff options
Diffstat (limited to 'contrib/tcpdump/print-fddi.c')
-rw-r--r-- | contrib/tcpdump/print-fddi.c | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/contrib/tcpdump/print-fddi.c b/contrib/tcpdump/print-fddi.c index 2b53c45..2780378 100644 --- a/contrib/tcpdump/print-fddi.c +++ b/contrib/tcpdump/print-fddi.c @@ -17,20 +17,19 @@ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $FreeBSD$ */ -#define NETDISSECT_REWORKED +/* \summary: Fiber Distributed Data Interface (FDDI) printer */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <tcpdump-stdinc.h> +#include <netdissect-stdinc.h> #include <string.h> -#include "interface.h" +#include "netdissect.h" #include "addrtoname.h" #include "ether.h" @@ -86,9 +85,9 @@ struct fddi_header { * Some FDDI interfaces use bit-swapped addresses. */ #if defined(ultrix) || defined(__alpha) || defined(__bsdi) || defined(__NetBSD__) || defined(__linux__) -int fddi_bitswap = 0; +static int fddi_bitswap = 0; #else -int fddi_bitswap = 1; +static int fddi_bitswap = 1; #endif /* @@ -261,17 +260,11 @@ fddi_hdr_print(netdissect_options *ndo, srcname = etheraddr_string(ndo, fsrc); dstname = etheraddr_string(ndo, fdst); - if (ndo->ndo_vflag) - ND_PRINT((ndo, "%02x %s %s %d: ", - fddip->fddi_fc, - srcname, dstname, - length)); - else if (ndo->ndo_qflag) - ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length)); - else { + if (!ndo->ndo_qflag) print_fddi_fc(ndo, fddip->fddi_fc); - ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length)); - } + ND_PRINT((ndo, "%s > %s, length %u: ", + srcname, dstname, + length)); } static inline void @@ -280,16 +273,17 @@ fddi_smt_print(netdissect_options *ndo, const u_char *p _U_, u_int length _U_) ND_PRINT((ndo, "<SMT printer not yet implemented>")); } -void +u_int fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) { const struct fddi_header *fddip = (const struct fddi_header *)p; struct ether_header ehdr; - u_short extracted_ethertype; + struct lladdr_info src, dst; + int llc_hdrlen; if (caplen < FDDI_HDRLEN) { ND_PRINT((ndo, "[|fddi]")); - return; + return (caplen); } /* @@ -300,6 +294,11 @@ fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) if (ndo->ndo_eflag) fddi_hdr_print(ndo, fddip, length, ESRC(&ehdr), EDST(&ehdr)); + src.addr = ESRC(&ehdr); + src.addr_string = etheraddr_string; + dst.addr = EDST(&ehdr); + dst.addr_string = etheraddr_string; + /* Skip over FDDI MAC header */ length -= FDDI_HDRLEN; p += FDDI_HDRLEN; @@ -308,32 +307,29 @@ fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) /* Frame Control field determines interpretation of packet */ if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) { /* Try to print the LLC-layer header & higher layers */ - if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr), - &extracted_ethertype) == 0) { + llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst); + if (llc_hdrlen < 0) { /* * Some kinds of LLC packet we cannot * handle intelligently */ - if (!ndo->ndo_eflag) - fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, - ESRC(&ehdr), EDST(&ehdr)); - if (extracted_ethertype) { - ND_PRINT((ndo, "(LLC %s) ", - etherproto_string(htons(extracted_ethertype)))); - } if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(p, caplen); + llc_hdrlen = -llc_hdrlen; } - } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT) + } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT) { fddi_smt_print(ndo, p, caplen); - else { + llc_hdrlen = 0; + } else { /* Some kinds of FDDI packet we cannot handle intelligently */ if (!ndo->ndo_eflag) fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, ESRC(&ehdr), EDST(&ehdr)); if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(p, caplen); + llc_hdrlen = 0; } + return (FDDI_HDRLEN + llc_hdrlen); } /* @@ -345,7 +341,5 @@ fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) u_int fddi_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { - fddi_print(ndo, p, h->len, h->caplen); - - return (FDDI_HDRLEN); + return (fddi_print(ndo, p, h->len, h->caplen)); } |