]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-pflog.c
NDOize AH, BEEP and DTP decoders
[tcpdump] / print-pflog.c
index 463cd18bbd011f13de1cbed7903ff3370b4f2011..f5f8d424d208d2abcce3f19f8c5fc1138cad8d9f 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.12 2004-04-02 06:48:10 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>
 #include <pcap.h>
 
+#include "extract.h"
 #include "interface.h"
-#include "addrtoname.h"
-#include "pf.h"
 
-static struct tok pf_reasons[] = {
+static const char tstr[] = "[|pflog]";
+
+static const struct tok pf_reasons[] = {
        { 0,    "0(match)" },
        { 1,    "1(bad-offset)" },
        { 2,    "2(fragment)" },
        { 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 }
 };
 
-static struct tok pf_actions[] = {
+static const struct tok pf_actions[] = {
        { PF_PASS,              "pass" },
        { PF_DROP,              "block" },
        { PF_SCRUB,             "scrub" },
@@ -61,7 +75,7 @@ static struct tok pf_actions[] = {
        { 0,                    NULL }
 };
 
-static struct tok pf_directions[] = {
+static const struct tok pf_directions[] = {
        { PF_INOUT,     "in/out" },
        { PF_IN,        "in" },
        { PF_OUT,       "out" },
@@ -77,8 +91,8 @@ pflog_print(const struct pfloghdr *hdr)
 {
        u_int32_t rulenr, subrulenr;
 
-       rulenr = ntohl(hdr->rulenr);
-       subrulenr = ntohl(hdr->subrulenr);
+       rulenr = EXTRACT_32BITS(&hdr->rulenr);
+       subrulenr = EXTRACT_32BITS(&hdr->subrulenr);
        if (subrulenr == (u_int32_t)-1)
                printf("rule %u/", rulenr);
        else
@@ -102,7 +116,7 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
 
        /* check length */
        if (caplen < sizeof(u_int8_t)) {
-               printf("[|pflog]");
+               printf("%s", tstr);
                return (caplen);
        }
 
@@ -115,7 +129,7 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
        hdrlen = BPF_WORDALIGN(hdr->length);
 
        if (caplen < hdrlen) {
-               printf("[|pflog]");
+               printf("%s", tstr);
                return (hdrlen);        /* XXX: true? */
        }
 
@@ -124,7 +138,7 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
        TCHECK(*hdr);
        if (eflag)
                pflog_print(hdr);
-       
+
        /* skip to the real packet */
        af = hdr->af;
        length -= hdrlen;
@@ -136,7 +150,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
@@ -144,7 +158,7 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
 #if OPENBSD_AF_INET6 != AF_INET6
                case OPENBSD_AF_INET6:          /* XXX: read pcap files */
 #endif
-                       ip6_print(p, length);
+                       ip6_print(gndo, p, length);
                        break;
 #endif
 
@@ -152,12 +166,19 @@ 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);
        }
-       
+
        return (hdrlen);
 trunc:
-       printf("[|pflog]");
+       printf("%s", tstr);
        return (hdrlen);
 }
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */