1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2019, Joyent, Inc.
14 */
15
16 #ifndef __IPF_CFW_H__
17 #define __IPF_CFW_H__
18
19 #include <sys/types.h>
20 #include <inet/ip6.h>
21 #include <sys/uuid.h>
22
23 /* Because ipf compiles this kernel file in userland testing... */
24 #ifndef ASSERT3U
25 #define ASSERT3U(a, b, c) ASSERT(a ## b ## c);
26 #endif /* ASSERT3U */
27
28 /*
29 * CFW Event, which is emitted to a global-zone listener. The global-zone
30 * listener solves the one-fd-per-zone problem of using each zone's ipmon.
31 *
32 * These must be 64-bit aligned. There might be reserved fields to insure it.
33 */
34 #define CFWEV_BLOCK 1
35 #define CFWEV_BEGIN 2
36 #define CFWEV_END 3
37 #define CFWDIR_IN 1
38 #define CFWDIR_OUT 2
39
40 typedef struct cfwev_s {
41 uint16_t cfwev_type; /* BEGIN, END, BLOCK */
42 uint16_t cfwev_length; /* in bytes, so capped to 65535 bytes */
43 zoneid_t cfwev_zonedid; /* Pullable from ipf_stack_t. */
44
45 uint16_t cfwev_ruleid; /* Pullable from fr_info_t. */
46 uint8_t cfwev_protocol; /* IPPROTO_* */
47 /* "direction" informs if src/dst are local/remote or remote/local. */
48 uint8_t cfwev_direction;
49 uint16_t cfwev_sport; /* Source port (network order) */
50 uint16_t cfwev_dport; /* Dest. port (network order) */
51
52 in6_addr_t cfwev_saddr; /* IPv4 addresses are V4MAPPED. */
53 in6_addr_t cfwev_daddr;
54
55 /*
56 * Because of 'struct timeval' being different between 32-bit and
57 * 64-bit ABIs, this interface is only usable by 64-bit binaries.
58 */
59 struct timeval cfwev_tstamp;
60
61 uuid_t cfwev_ruleuuid; /* Pullable from fr_info_t. */
62 } cfwev_t;
63
64
65
66 #endif /* __IPF_CFW_H__ */