diff options
Diffstat (limited to 'contrib/tcpdump/print-ipfc.c')
-rw-r--r-- | contrib/tcpdump/print-ipfc.c | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/contrib/tcpdump/print-ipfc.c b/contrib/tcpdump/print-ipfc.c index 295ac0f..b8a08e9 100644 --- a/contrib/tcpdump/print-ipfc.c +++ b/contrib/tcpdump/print-ipfc.c @@ -19,24 +19,23 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define NETDISSECT_REWORKED +/* \summary: IP over Fibre Channel printer */ + +/* specification: RFC 2625 */ + #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" -/* - * RFC 2625 IP-over-Fibre Channel. - */ - struct ipfc_header { u_char ipfc_dhost[8]; u_char ipfc_shost[8]; @@ -72,21 +71,34 @@ 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; + struct lladdr_info src, dst; + int llc_hdrlen; if (caplen < IPFC_HDRLEN) { ND_PRINT((ndo, "[|ipfc]")); - return; + return (caplen); } /* * Get the network addresses into a canonical form @@ -96,28 +108,28 @@ ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) if (ndo->ndo_eflag) ipfc_hdr_print(ndo, ipfcp, 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 Network_Header */ length -= IPFC_HDRLEN; p += IPFC_HDRLEN; 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, &src, &dst); + 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 +141,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)); } |