]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ipfc.c
Default to first interface from pcap_findalldevs()
[tcpdump] / print-ipfc.c
index 6c92f901f1d81c68b410e4305db5f0310eaf1083..6907ba3ed10e222ddca3f91d0b57747590776529 100644 (file)
 #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"
@@ -71,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
@@ -101,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);
 }
 
 /*
@@ -128,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));
 }