]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-pflog.c
Process VLAN frames and Alteon jumbo frames in the Ethernet printer.
[tcpdump] / print-pflog.c
index 7b46749b47cc4e40c57ad4de4c86c2a7b6c3066b..d1a461561ee204dc617a965272e2e97077c55570 100644 (file)
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.10 2004-03-28 20:33:28 fenner Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.16 2007-09-12 19:36:18 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#ifndef HAVE_NET_PFVAR_H
+#error "No pf headers available"
+#endif
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/pfvar.h>
+#include <net/if_pflog.h>
+
 #include <tcpdump-stdinc.h>
 
 #include <stdio.h>
@@ -35,7 +44,6 @@ static const char rcsid[] _U_ =
 
 #include "interface.h"
 #include "addrtoname.h"
-#include "pf.h"
 
 static struct tok pf_reasons[] = {
        { 0,    "0(match)" },
@@ -44,6 +52,15 @@ static struct tok pf_reasons[] = {
        { 3,    "3(short)" },
        { 4,    "4(normalize)" },
        { 5,    "5(memory)" },
+       { 6,    "6(bad-timestamp)" },
+       { 7,    "7(congestion)" },
+       { 8,    "8(ip-option)" },
+       { 9,    "9(proto-cksum)" },
+       { 10,   "10(state-mismatch)" },
+       { 11,   "11(state-insert)" },
+       { 12,   "12(state-limit)" },
+       { 13,   "13(src-limit)" },
+       { 14,   "14(synproxy)" },
        { 0,    NULL }
 };
 
@@ -75,11 +92,14 @@ static struct tok pf_directions[] = {
 static void
 pflog_print(const struct pfloghdr *hdr)
 {
-       if (ntohl(hdr->subrulenr) == (u_int32_t)-1)
-               printf("rule %u/", ntohl(hdr->rulenr));
+       u_int32_t rulenr, subrulenr;
+
+       rulenr = EXTRACT_32BITS(&hdr->rulenr);
+       subrulenr = EXTRACT_32BITS(&hdr->subrulenr);
+       if (subrulenr == (u_int32_t)-1)
+               printf("rule %u/", rulenr);
        else
-               printf("rule %u.%s.%u/", ntohl(hdr->rulenr), hdr->ruleset,
-                   ntohl(hdr->subrulenr));
+               printf("rule %u.%s.%u/", rulenr, hdr->ruleset, subrulenr);
 
        printf("%s: %s %s on %s: ",
            tok2str(pf_reasons, "unkn(%u)", hdr->reason),
@@ -94,10 +114,6 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
        u_int length = h->len;
        u_int hdrlen;
        u_int caplen = h->caplen;
-       const struct ip *ip;
-#ifdef INET6
-       const struct ip6_hdr *ip6;
-#endif
        const struct pfloghdr *hdr;
        u_int8_t af;
 
@@ -137,7 +153,7 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
 #if OPENBSD_AF_INET != AF_INET
                case OPENBSD_AF_INET:           /* XXX: read pcap files */
 #endif
-                       ip_print(p, length);
+                       ip_print(gndo, p, length);
                        break;
 
 #ifdef INET6
@@ -153,7 +169,7 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
                /* address family not handled, print raw packet */
                if (!eflag)
                        pflog_print(hdr);
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        }
        
@@ -162,3 +178,10 @@ trunc:
        printf("[|pflog]");
        return (hdrlen);
 }
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */