xref: /xnu-8792.61.2/bsd/net/if_pflog.h (revision 42e220869062b56f8d7d0726fd4c88954f87902c)
1*42e22086SApple OSS Distributions /*
2*42e22086SApple OSS Distributions  * Copyright (c) 2007-2018 Apple Inc. All rights reserved.
3*42e22086SApple OSS Distributions  *
4*42e22086SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*42e22086SApple OSS Distributions  *
6*42e22086SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*42e22086SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*42e22086SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*42e22086SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*42e22086SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*42e22086SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*42e22086SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*42e22086SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*42e22086SApple OSS Distributions  *
15*42e22086SApple OSS Distributions  * Please obtain a copy of the License at
16*42e22086SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*42e22086SApple OSS Distributions  *
18*42e22086SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*42e22086SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*42e22086SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*42e22086SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*42e22086SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*42e22086SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*42e22086SApple OSS Distributions  * limitations under the License.
25*42e22086SApple OSS Distributions  *
26*42e22086SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*42e22086SApple OSS Distributions  */
28*42e22086SApple OSS Distributions 
29*42e22086SApple OSS Distributions /* $apfw: if_pflog.h,v 1.3 2007/08/13 22:18:33 jhw Exp $ */
30*42e22086SApple OSS Distributions /* $OpenBSD: if_pflog.h,v 1.14 2006/10/25 11:27:01 henning Exp $ */
31*42e22086SApple OSS Distributions /*
32*42e22086SApple OSS Distributions  * Copyright 2001 Niels Provos <[email protected]>
33*42e22086SApple OSS Distributions  * All rights reserved.
34*42e22086SApple OSS Distributions  *
35*42e22086SApple OSS Distributions  * Redistribution and use in source and binary forms, with or without
36*42e22086SApple OSS Distributions  * modification, are permitted provided that the following conditions
37*42e22086SApple OSS Distributions  * are met:
38*42e22086SApple OSS Distributions  * 1. Redistributions of source code must retain the above copyright
39*42e22086SApple OSS Distributions  *    notice, this list of conditions and the following disclaimer.
40*42e22086SApple OSS Distributions  * 2. Redistributions in binary form must reproduce the above copyright
41*42e22086SApple OSS Distributions  *    notice, this list of conditions and the following disclaimer in the
42*42e22086SApple OSS Distributions  *    documentation and/or other materials provided with the distribution.
43*42e22086SApple OSS Distributions  *
44*42e22086SApple OSS Distributions  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
45*42e22086SApple OSS Distributions  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
46*42e22086SApple OSS Distributions  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
47*42e22086SApple OSS Distributions  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
48*42e22086SApple OSS Distributions  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
49*42e22086SApple OSS Distributions  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50*42e22086SApple OSS Distributions  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51*42e22086SApple OSS Distributions  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52*42e22086SApple OSS Distributions  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
53*42e22086SApple OSS Distributions  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54*42e22086SApple OSS Distributions  */
55*42e22086SApple OSS Distributions 
56*42e22086SApple OSS Distributions #ifndef _NET_IF_PFLOG_H_
57*42e22086SApple OSS Distributions #define _NET_IF_PFLOG_H_
58*42e22086SApple OSS Distributions 
59*42e22086SApple OSS Distributions #if PF || !defined(KERNEL)
60*42e22086SApple OSS Distributions 
61*42e22086SApple OSS Distributions #ifdef  __cplusplus
62*42e22086SApple OSS Distributions extern "C" {
63*42e22086SApple OSS Distributions #endif
64*42e22086SApple OSS Distributions 
65*42e22086SApple OSS Distributions #define PFLOGIFS_MAX            16
66*42e22086SApple OSS Distributions #define PFLOGIF_ZONE_MAX_ELEM           MIN(IFNETS_MAX, PFLOGIFS_MAX)
67*42e22086SApple OSS Distributions 
68*42e22086SApple OSS Distributions #if KERNEL_PRIVATE
69*42e22086SApple OSS Distributions struct pflog_softc {
70*42e22086SApple OSS Distributions 	struct ifnet            *sc_if;         /* back ptr to interface */
71*42e22086SApple OSS Distributions 	u_int32_t               sc_flags;
72*42e22086SApple OSS Distributions #define IFPFLF_DETACHING        0x1
73*42e22086SApple OSS Distributions 	int                     sc_unit;
74*42e22086SApple OSS Distributions 	LIST_ENTRY(pflog_softc) sc_list;
75*42e22086SApple OSS Distributions };
76*42e22086SApple OSS Distributions #endif /* KERNEL_PRIVATE */
77*42e22086SApple OSS Distributions 
78*42e22086SApple OSS Distributions #define PFLOG_RULESET_NAME_SIZE 16
79*42e22086SApple OSS Distributions 
80*42e22086SApple OSS Distributions struct pfloghdr {
81*42e22086SApple OSS Distributions 	u_int8_t        length;
82*42e22086SApple OSS Distributions 	sa_family_t     af;
83*42e22086SApple OSS Distributions 	u_int8_t        action;
84*42e22086SApple OSS Distributions 	u_int8_t        reason;
85*42e22086SApple OSS Distributions 	char            ifname[IFNAMSIZ];
86*42e22086SApple OSS Distributions 	char            ruleset[PFLOG_RULESET_NAME_SIZE];
87*42e22086SApple OSS Distributions 	u_int32_t       rulenr;
88*42e22086SApple OSS Distributions 	u_int32_t       subrulenr;
89*42e22086SApple OSS Distributions 	uid_t           uid;
90*42e22086SApple OSS Distributions 	pid_t           pid;
91*42e22086SApple OSS Distributions 	uid_t           rule_uid;
92*42e22086SApple OSS Distributions 	pid_t           rule_pid;
93*42e22086SApple OSS Distributions 	u_int8_t        dir;
94*42e22086SApple OSS Distributions 	u_int8_t        pad[3];
95*42e22086SApple OSS Distributions };
96*42e22086SApple OSS Distributions 
97*42e22086SApple OSS Distributions #define PFLOG_HDRLEN            sizeof(struct pfloghdr)
98*42e22086SApple OSS Distributions /* minus pad, also used as a signature */
99*42e22086SApple OSS Distributions #define PFLOG_REAL_HDRLEN       offsetof(struct pfloghdr, pad)
100*42e22086SApple OSS Distributions 
101*42e22086SApple OSS Distributions #ifdef KERNEL_PRIVATE
102*42e22086SApple OSS Distributions 
103*42e22086SApple OSS Distributions #if PFLOG
104*42e22086SApple OSS Distributions #define PFLOG_PACKET(i, x, a, b, c, d, e, f, g, h) pflog_packet(i,a,b,c,d,e,f,g,h)
105*42e22086SApple OSS Distributions #else
106*42e22086SApple OSS Distributions #define PFLOG_PACKET(i, x, a, b, c, d, e, f, g, h) ((void)0)
107*42e22086SApple OSS Distributions #endif /* PFLOG */
108*42e22086SApple OSS Distributions 
109*42e22086SApple OSS Distributions __private_extern__ void pfloginit(void);
110*42e22086SApple OSS Distributions #endif /* KERNEL_PRIVATE */
111*42e22086SApple OSS Distributions 
112*42e22086SApple OSS Distributions #ifdef  __cplusplus
113*42e22086SApple OSS Distributions }
114*42e22086SApple OSS Distributions #endif
115*42e22086SApple OSS Distributions #endif /* PF || !KERNEL */
116*42e22086SApple OSS Distributions #endif /* _NET_IF_PFLOG_H_ */
117