X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/bbedebc666a341d8e14922dce37a92766400c798..refs/pull/482/head:/print-ipfc.c?ds=inline diff --git a/print-ipfc.c b/print-ipfc.c index 295ac0fd..6907ba3e 100644 --- a/print-ipfc.c +++ b/print-ipfc.c @@ -19,16 +19,15 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define NETDISSECT_REWORKED #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include +#include #include -#include "interface.h" +#include "netdissect.h" #include "addrtoname.h" #include "ether.h" @@ -72,21 +71,33 @@ ipfc_hdr_print(netdissect_options *ndo, dstname = etheraddr_string(ndo, ipfcdst); /* - * XXX - show the upper 16 bits? Do so only if "vflag" is set? + * XXX - should we show the upper 16 bits of the addresses? + * Do so only if "vflag" is set? + * Section 3.3 "FC Port and Node Network Addresses" says that + * + * In this specification, both the Source and Destination + * 4-bit NAA identifiers SHALL be set to binary '0001' + * indicating that an IEEE 48-bit MAC address is contained + * in the lower 48 bits of the network address fields. The + * high order 12 bits in the network address fields SHALL + * be set to 0x0000. + * + * so, for captures following this specification, the upper 16 + * bits should be 0x1000, followed by a MAC address. */ - ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length)); + ND_PRINT((ndo, "%s > %s, length %u: ", srcname, dstname, length)); } -static void +static u_int ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) { const struct ipfc_header *ipfcp = (const struct ipfc_header *)p; struct ether_header ehdr; - u_short extracted_ethertype; + int llc_hdrlen; if (caplen < IPFC_HDRLEN) { ND_PRINT((ndo, "[|ipfc]")); - return; + return (caplen); } /* * Get the network addresses into a canonical form @@ -102,22 +113,17 @@ ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) caplen -= IPFC_HDRLEN; /* 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, ESRC(&ehdr), EDST(&ehdr)); + if (llc_hdrlen < 0) { /* * Some kinds of LLC packet we cannot * handle intelligently */ - if (!ndo->ndo_eflag) - ipfc_hdr_print(ndo, ipfcp, length + IPFC_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; } + return (IPFC_HDRLEN + llc_hdrlen); } /* @@ -129,7 +135,5 @@ ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) u_int ipfc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { - ipfc_print(ndo, p, h->len, h->caplen); - - return (IPFC_HDRLEN); + return (ipfc_print(ndo, p, h->len, h->caplen)); }