]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ipfc.c
Do the dump file Capsicum stuff in a common routine.
[tcpdump] / print-ipfc.c
index 3451b4b23530c93c66d44cd9ba404da4ab50f0a9..295ac0fdab3d4e568171bc533babf9e792a743f6 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.6 2003-11-16 09:36:24 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
-#include "ethertype.h"
 
 #include "ether.h"
-#include "ipfc.h"
 
 /*
  * RFC 2625 IP-over-Fibre Channel.
  */
 
+struct ipfc_header {
+       u_char  ipfc_dhost[8];
+       u_char  ipfc_shost[8];
+};
+
+#define IPFC_HDRLEN 16
+
 /* Extract src, dst addresses */
 static inline void
 extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc,
@@ -62,30 +61,31 @@ extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc,
  * Print the Network_Header
  */
 static inline void
-ipfc_hdr_print(register const struct ipfc_header *ipfcp _U_,
+ipfc_hdr_print(netdissect_options *ndo,
+          register const struct ipfc_header *ipfcp _U_,
           register u_int length, register const u_char *ipfcsrc,
           register const u_char *ipfcdst)
 {
        const char *srcname, *dstname;
 
-       srcname = etheraddr_string(ipfcsrc);
-       dstname = etheraddr_string(ipfcdst);
+       srcname = etheraddr_string(ndo, ipfcsrc);
+       dstname = etheraddr_string(ndo, ipfcdst);
 
        /*
         * XXX - show the upper 16 bits?  Do so only if "vflag" is set?
         */
-       (void) printf("%s %s %d: ", srcname, dstname, length);
+       ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
 }
 
 static void
-ipfc_print(const u_char *p, u_int length, u_int caplen)
+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;
 
        if (caplen < IPFC_HDRLEN) {
-               printf("[|ipfc]");
+               ND_PRINT((ndo, "[|ipfc]"));
                return;
        }
        /*
@@ -93,45 +93,43 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
         */
        extract_ipfc_addrs(ipfcp, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
 
-       if (eflag)
-               ipfc_hdr_print(ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
+       if (ndo->ndo_eflag)
+               ipfc_hdr_print(ndo, ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
 
        /* Skip over Network_Header */
        length -= IPFC_HDRLEN;
        p += IPFC_HDRLEN;
        caplen -= IPFC_HDRLEN;
 
-       /* Frame Control field determines interpretation of packet */
-       extracted_ethertype = 0;
        /* Try to print the LLC-layer header & higher layers */
-       if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
+       if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
            &extracted_ethertype) == 0) {
                /*
                 * Some kinds of LLC packet we cannot
                 * handle intelligently
                 */
-               if (!eflag)
-                       ipfc_hdr_print(ipfcp, length + IPFC_HDRLEN,
+               if (!ndo->ndo_eflag)
+                       ipfc_hdr_print(ndo, ipfcp, length + IPFC_HDRLEN,
                            ESRC(&ehdr), EDST(&ehdr));
                if (extracted_ethertype) {
-                       printf("(LLC %s) ",
-               etherproto_string(htons(extracted_ethertype)));
+                       ND_PRINT((ndo, "(LLC %s) ",
+               etherproto_string(htons(extracted_ethertype))));
                }
-               if (!xflag && !qflag)
-                       default_print(p, caplen);
+               if (!ndo->ndo_suppress_default_print)
+                       ND_DEFAULTPRINT(p, caplen);
        }
 }
 
 /*
  * This is the top level routine of the printer.  'p' points
  * to the Network_Header of the packet, 'h->ts' is the timestamp,
- * 'h->length' is the length of the packet off the wire, and 'h->caplen'
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
  * is the number of bytes actually captured.
  */
 u_int
-ipfc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+ipfc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
 {
-       ipfc_print(p, h->len, h->caplen);
+       ipfc_print(ndo, p, h->len, h->caplen);
 
        return (IPFC_HDRLEN);
 }