]>
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.2 2002-02-06 11:05:35 guy Exp $ (LBL)";
33 #include <sys/param.h>
35 #include <sys/socket.h>
37 #include <netinet/in.h>
42 #include "interface.h"
43 #include "addrtoname.h"
45 /* The header in OpenBSD pflog files. */
55 #define PFLOG_HDRLEN sizeof(struct pfloghdr)
66 static struct tok pf_reasons
[] = {
76 static struct tok pf_actions
[] = {
79 { PF_SCRUB
, "scrub" },
83 static struct tok pf_directions
[] = {
89 #define OPENBSD_AF_INET 2
90 #define OPENBSD_AF_INET6 24
93 pflog_print(const struct pfloghdr
*hdr
)
95 printf("rule %d/%s: %s %s on %s: ",
96 (short)ntohs(hdr
->rnr
),
97 tok2str(pf_reasons
, "unkn(%u)", ntohs(hdr
->reason
)),
98 tok2str(pf_actions
, "unkn(%u)", ntohs(hdr
->action
)),
99 tok2str(pf_directions
, "unkn(%u)", ntohs(hdr
->dir
)),
104 pflog_if_print(u_char
*user
, const struct pcap_pkthdr
*h
,
105 register const u_char
*p
)
107 u_int length
= h
->len
;
108 u_int caplen
= h
->caplen
;
109 const struct pfloghdr
*hdr
;
114 if (caplen
< PFLOG_HDRLEN
) {
120 * Some printers want to get back at the link level addresses,
121 * and/or check that they're not walking off the end of the packet.
122 * Rather than pass them all the way down, we set these globals.
125 snapend
= p
+ caplen
;
127 hdr
= (const struct pfloghdr
*)p
;
131 length
-= PFLOG_HDRLEN
;
132 caplen
-= PFLOG_HDRLEN
;
136 case OPENBSD_AF_INET
:
141 case OPENBSD_AF_INET6
:
142 ip6_print(p
, length
);
147 /* address family not handled, print raw packet */
150 if (!xflag
&& !qflag
)
151 default_print(p
, caplen
);
155 default_print(p
, caplen
);