X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/59864b113d8f2310a38d916e11a27c6f7e979ad9..0845bc813c1cc48b18cdefff0b387c110647463c:/print-fddi.c diff --git a/print-fddi.c b/print-fddi.c index 9e6ec0b1..4b5be590 100644 --- a/print-fddi.c +++ b/print-fddi.c @@ -27,7 +27,7 @@ #include -#include "interface.h" +#include "netdissect.h" #include "addrtoname.h" #include "ether.h" @@ -258,17 +258,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 @@ -277,15 +271,16 @@ fddi_smt_print(netdissect_options *ndo, const u_char *p _U_, u_int length _U_) ND_PRINT((ndo, "")); } -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; + int llc_hdrlen; if (caplen < FDDI_HDRLEN) { ND_PRINT((ndo, "[|fddi]")); - return; + return (caplen); } /* @@ -304,24 +299,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)) == 0) { + llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr)); + if (llc_hdrlen < 0) { /* * Some kinds of LLC packet we cannot * handle intelligently */ 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); } /* @@ -333,7 +333,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)); }