]>
The Tcpdump Group git mirrors - tcpdump/blob - print-pflog.c
1 /* $OpenBSD: print-pflog.c,v 1.9 2001/09/18 14:52:53 jakob Exp $ */
4 * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25 static const char rcsid
[] =
26 "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.5 2002-12-18 08:53:22 guy Exp $ (LBL)";
33 #include <tcpdump-stdinc.h>
38 #include "interface.h"
39 #include "addrtoname.h"
41 /* The header in OpenBSD pflog files. */
51 #define PFLOG_HDRLEN sizeof(struct pfloghdr)
62 static struct tok pf_reasons
[] = {
72 static struct tok pf_actions
[] = {
75 { PF_SCRUB
, "scrub" },
79 static struct tok pf_directions
[] = {
85 #define OPENBSD_AF_INET 2
86 #define OPENBSD_AF_INET6 24
89 pflog_print(const struct pfloghdr
*hdr
)
91 printf("rule %d/%s: %s %s on %s: ",
92 (short)ntohs(hdr
->rnr
),
93 tok2str(pf_reasons
, "unkn(%u)", ntohs(hdr
->reason
)),
94 tok2str(pf_actions
, "unkn(%u)", ntohs(hdr
->action
)),
95 tok2str(pf_directions
, "unkn(%u)", ntohs(hdr
->dir
)),
100 pflog_if_print(u_char
*user _U_
, const struct pcap_pkthdr
*h
,
101 register const u_char
*p
)
103 u_int length
= h
->len
;
104 u_int caplen
= h
->caplen
;
105 const struct pfloghdr
*hdr
;
110 if (caplen
< PFLOG_HDRLEN
) {
116 * Some printers want to check that they're not walking off the
118 * Rather than pass it all the way down, we set this global.
120 snapend
= p
+ caplen
;
122 hdr
= (const struct pfloghdr
*)p
;
126 length
-= PFLOG_HDRLEN
;
127 caplen
-= PFLOG_HDRLEN
;
131 case OPENBSD_AF_INET
:
136 case OPENBSD_AF_INET6
:
137 ip6_print(p
, length
);
142 /* address family not handled, print raw packet */
145 if (!xflag
&& !qflag
)
146 default_print(p
, caplen
);
150 default_print(p
, caplen
);