]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-pflog.c
Use more the ND_TTEST_1() macro
[tcpdump] / print-pflog.c
index 4263a469b527f5aa1e62c58629751c5a495f2c9c..d0269af04ab4fc5ac17675519529cca55cc86122 100644 (file)
@@ -19,7 +19,8 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
+/* \summary: OpenBSD packet filter log file printer */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -33,9 +34,9 @@
 #include <net/pfvar.h>
 #include <net/if_pflog.h>
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 
 static const char tstr[] = "[|pflog]";
@@ -89,8 +90,8 @@ pflog_print(netdissect_options *ndo, const struct pfloghdr *hdr)
 {
        uint32_t rulenr, subrulenr;
 
-       rulenr = EXTRACT_32BITS(&hdr->rulenr);
-       subrulenr = EXTRACT_32BITS(&hdr->subrulenr);
+       rulenr = EXTRACT_BE_U_4(&hdr->rulenr);
+       subrulenr = EXTRACT_BE_U_4(&hdr->subrulenr);
        if (subrulenr == (uint32_t)-1)
                ND_PRINT((ndo, "rule %u/", rulenr));
        else
@@ -105,7 +106,7 @@ pflog_print(netdissect_options *ndo, const struct pfloghdr *hdr)
 
 u_int
 pflog_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
-               register const u_char *p)
+               const u_char *p)
 {
        u_int length = h->len;
        u_int hdrlen;
@@ -120,7 +121,7 @@ pflog_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
        }
 
 #define MIN_PFLOG_HDRLEN       45
-       hdr = (struct pfloghdr *)p;
+       hdr = (const struct pfloghdr *)p;
        if (hdr->length < MIN_PFLOG_HDRLEN) {
                ND_PRINT((ndo, "[pflog: invalid header length!]"));
                return (hdr->length);   /* XXX: not really */
@@ -133,7 +134,6 @@ pflog_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
        }
 
        /* print what we know */
-       hdr = (struct pfloghdr *)p;
        ND_TCHECK(*hdr);
        if (ndo->ndo_eflag)
                pflog_print(ndo, hdr);
@@ -152,14 +152,16 @@ pflog_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
                        ip_print(ndo, p, length);
                        break;
 
-#ifdef INET6
+#if defined(AF_INET6) || defined(OPENBSD_AF_INET6)
+#ifdef AF_INET6
                case AF_INET6:
-#if OPENBSD_AF_INET6 != AF_INET6
+#endif /* AF_INET6 */
+#if !defined(AF_INET6) || OPENBSD_AF_INET6 != AF_INET6
                case OPENBSD_AF_INET6:          /* XXX: read pcap files */
-#endif
+#endif /* !defined(AF_INET6) || OPENBSD_AF_INET6 != AF_INET6 */
                        ip6_print(ndo, p, length);
                        break;
-#endif
+#endif /* defined(AF_INET6) || defined(OPENBSD_AF_INET6) */
 
        default:
                /* address family not handled, print raw packet */