From 577cd008ab71098cce35fa4648eb197c95d122f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 28 May 2024 12:51:20 +0200 Subject: [PATCH 1/7] Update bindgen script to use new argument names --- generate_bindings.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/generate_bindings.sh b/generate_bindings.sh index a342345..8b3475d 100755 --- a/generate_bindings.sh +++ b/generate_bindings.sh @@ -8,14 +8,14 @@ echo " $SDK_PATH" echo "" bindgen \ - --whitelist-type pf_status \ - --whitelist-type pfioc_rule \ - --whitelist-type pfioc_pooladdr \ - --whitelist-type pfioc_trans \ - --whitelist-type pfioc_states \ - --whitelist-type pfioc_state_kill \ - --whitelist-var PF_.* \ - --whitelist-var PFRULE_.* \ + --allowlist-type pf_status \ + --allowlist-type pfioc_rule \ + --allowlist-type pfioc_pooladdr \ + --allowlist-type pfioc_trans \ + --allowlist-type pfioc_states \ + --allowlist-type pfioc_state_kill \ + --allowlist-var PF_.* \ + --allowlist-var PFRULE_.* \ -o ./src/ffi/pfvar.rs ./ffi/pfvar.h -- \ -DPRIVATE \ -I$SDK_PATH/usr/include \ From 21f5989055962139c303446cbbced6356a4f3552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 28 May 2024 12:52:10 +0200 Subject: [PATCH 2/7] Fix shellcheck complaints on generate_bindings --- generate_bindings.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generate_bindings.sh b/generate_bindings.sh index 8b3475d..58e702b 100755 --- a/generate_bindings.sh +++ b/generate_bindings.sh @@ -2,7 +2,7 @@ # Please always have the latest version of bindgen and rustfmt installed before using this script -SDK_PATH=`xcodebuild -sdk macosx Path -version` +SDK_PATH=$(xcodebuild -sdk macosx Path -version) echo "Using macOS SDK at:" echo " $SDK_PATH" echo "" @@ -18,5 +18,5 @@ bindgen \ --allowlist-var PFRULE_.* \ -o ./src/ffi/pfvar.rs ./ffi/pfvar.h -- \ -DPRIVATE \ - -I$SDK_PATH/usr/include \ - -I$SDK_PATH/System/Library/Frameworks/Kernel.framework/Versions/A/Headers + -I"$SDK_PATH/usr/include" \ + -I"$SDK_PATH/System/Library/Frameworks/Kernel.framework/Versions/A/Headers" From 6c5c4ee168103cab63d510f86c0419e37ad8c6d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 28 May 2024 12:58:48 +0200 Subject: [PATCH 3/7] Make generate_bindings.h take pfvar.h path as argument --- README.md | 5 +++++ generate_bindings.sh | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3367d8f..1d6010f 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ let rule = pfctl::FilterRuleBuilder::default() pf.add_rule(anchor_name, &rule).unwrap(); ``` +## System bindings + +See comments in `generate_bindings.sh` for how to generate the Rust bindings to the system +libraries + [integration tests]: https://github.com/mullvad/pfctl-rs/tree/master/tests [examples]: https://github.com/mullvad/pfctl-rs/tree/master/examples diff --git a/generate_bindings.sh b/generate_bindings.sh index 58e702b..8aa04aa 100755 --- a/generate_bindings.sh +++ b/generate_bindings.sh @@ -2,6 +2,11 @@ # Please always have the latest version of bindgen and rustfmt installed before using this script +# Download the pfvar.h file to generate bindings for from: +# https://github.com/apple-oss-distributions/xnu/blob/main/bsd/net/pfvar.h + +pfvar_h_path=${1:?"Specify path to pfvar.h as first argument"} + SDK_PATH=$(xcodebuild -sdk macosx Path -version) echo "Using macOS SDK at:" echo " $SDK_PATH" @@ -16,7 +21,7 @@ bindgen \ --allowlist-type pfioc_state_kill \ --allowlist-var PF_.* \ --allowlist-var PFRULE_.* \ - -o ./src/ffi/pfvar.rs ./ffi/pfvar.h -- \ + -o ./src/ffi/pfvar.rs "$pfvar_h_path" -- \ -DPRIVATE \ -I"$SDK_PATH/usr/include" \ -I"$SDK_PATH/System/Library/Frameworks/Kernel.framework/Versions/A/Headers" From a1a2f03b3299b2891886c736246442f7593616cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 28 May 2024 13:00:18 +0200 Subject: [PATCH 4/7] Remove checked in pfvar.h file --- ffi/pfvar.h | 2446 --------------------------------------------------- 1 file changed, 2446 deletions(-) delete mode 100755 ffi/pfvar.h diff --git a/ffi/pfvar.h b/ffi/pfvar.h deleted file mode 100755 index 11e771b..0000000 --- a/ffi/pfvar.h +++ /dev/null @@ -1,2446 +0,0 @@ -/* - * Copyright (c) 2007-2015 Apple Inc. All rights reserved. - * - * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. The rights granted to you under the License - * may not be used to create, or enable the creation or redistribution of, - * unlawful or unlicensed copies of an Apple operating system, or to - * circumvent, violate, or enable the circumvention or violation of, any - * terms of an Apple operating system software license agreement. - * - * Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ - */ - -/* $apfw: git commit b6bf13f8321283cd7ee82b1795e86506084b1b95 $ */ -/* $OpenBSD: pfvar.h,v 1.259 2007/12/02 12:08:04 pascoe Exp $ */ - -/* - * Copyright (c) 2001 Daniel Hartmeier - * NAT64 - Copyright (c) 2010 Viagenie Inc. (http://www.viagenie.ca) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef _NET_PFVAR_H_ -#define _NET_PFVAR_H_ - -#ifdef PRIVATE -/* - * XXX - * XXX Private interfaces. Do not include this file; use pfctl(8) instead. - * XXX - */ -#if PF || !defined(KERNEL) - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include -#ifdef KERNEL -#include -#include -#include - -#include -#include - -#if BYTE_ORDER == BIG_ENDIAN -#define htobe64(x) (x) -#else /* LITTLE ENDIAN */ -#define htobe64(x) __DARWIN_OSSwapInt64(x) -#endif /* LITTLE_ENDIAN */ - -#define be64toh(x) htobe64(x) - -extern lck_rw_t *pf_perim_lock; -extern lck_mtx_t *pf_lock; - -struct pool { - struct zone *pool_zone; /* pointer to backend zone */ - const char *pool_name; /* name of pool */ - unsigned int pool_count; /* # of outstanding elements */ - unsigned int pool_hiwat; /* high watermark */ - unsigned int pool_limit; /* hard limit */ - unsigned int pool_fails; /* # of failed allocs due to limit */ -}; - -#define PR_NOWAIT FALSE -#define PR_WAITOK TRUE - -__private_extern__ void pool_init(struct pool *, size_t, unsigned int, - unsigned int, int, const char *, void *); -__private_extern__ void pool_destroy(struct pool *); -__private_extern__ void pool_sethiwat(struct pool *, int); -__private_extern__ void pool_sethardlimit(struct pool *, int, - const char *, int); -__private_extern__ void *pool_get(struct pool *, int); -__private_extern__ void pool_put(struct pool *, void *); -__private_extern__ u_int64_t pf_time_second(void); -__private_extern__ u_int64_t pf_calendar_time_second(void); -#endif /* KERNEL */ - -union sockaddr_union { - struct sockaddr sa; - struct sockaddr_in sin; - struct sockaddr_in6 sin6; -}; - -#define PF_TCPS_PROXY_SRC ((TCP_NSTATES)+0) -#define PF_TCPS_PROXY_DST ((TCP_NSTATES)+1) - -#define PF_MD5_DIGEST_LENGTH 16 -#ifdef MD5_DIGEST_LENGTH -#if PF_MD5_DIGEST_LENGTH != MD5_DIGEST_LENGTH -#error -#endif /* PF_MD5_DIGEST_LENGTH != MD5_DIGEST_LENGTH */ -#endif /* MD5_DIGEST_LENGTH */ - -#ifdef KERNEL -struct ip; -struct ip6_hdr; -struct tcphdr; -struct pf_grev1_hdr; -struct pf_esp_hdr; -#endif /* KERNEL */ - -#define PF_GRE_PPTP_VARIANT 0x01 - -enum { PF_INOUT, PF_IN, PF_OUT }; -enum { PF_PASS, PF_DROP, PF_SCRUB, PF_NOSCRUB, PF_NAT, PF_NONAT, - PF_BINAT, PF_NOBINAT, PF_RDR, PF_NORDR, PF_SYNPROXY_DROP, - PF_DUMMYNET, PF_NODUMMYNET, PF_NAT64, PF_NONAT64 }; -enum { PF_RULESET_SCRUB, PF_RULESET_FILTER, PF_RULESET_NAT, - PF_RULESET_BINAT, PF_RULESET_RDR, PF_RULESET_DUMMYNET, - PF_RULESET_MAX }; -enum { PF_OP_NONE, PF_OP_IRG, PF_OP_EQ, PF_OP_NE, PF_OP_LT, - PF_OP_LE, PF_OP_GT, PF_OP_GE, PF_OP_XRG, PF_OP_RRG }; -enum { PF_DEBUG_NONE, PF_DEBUG_URGENT, PF_DEBUG_MISC, PF_DEBUG_NOISY }; -enum { PF_CHANGE_NONE, PF_CHANGE_ADD_HEAD, PF_CHANGE_ADD_TAIL, - PF_CHANGE_ADD_BEFORE, PF_CHANGE_ADD_AFTER, - PF_CHANGE_REMOVE, PF_CHANGE_GET_TICKET }; -enum { PF_GET_NONE, PF_GET_CLR_CNTR }; - -/* - * Note about PFTM_*: real indices into pf_rule.timeout[] come before - * PFTM_MAX, special cases afterwards. See pf_state_expires(). - */ -enum { PFTM_TCP_FIRST_PACKET, PFTM_TCP_OPENING, PFTM_TCP_ESTABLISHED, - PFTM_TCP_CLOSING, PFTM_TCP_FIN_WAIT, PFTM_TCP_CLOSED, - PFTM_UDP_FIRST_PACKET, PFTM_UDP_SINGLE, PFTM_UDP_MULTIPLE, - PFTM_ICMP_FIRST_PACKET, PFTM_ICMP_ERROR_REPLY, - PFTM_GREv1_FIRST_PACKET, PFTM_GREv1_INITIATING, - PFTM_GREv1_ESTABLISHED, PFTM_ESP_FIRST_PACKET, PFTM_ESP_INITIATING, - PFTM_ESP_ESTABLISHED, PFTM_OTHER_FIRST_PACKET, PFTM_OTHER_SINGLE, - PFTM_OTHER_MULTIPLE, PFTM_FRAG, PFTM_INTERVAL, - PFTM_ADAPTIVE_START, PFTM_ADAPTIVE_END, PFTM_SRC_NODE, - PFTM_TS_DIFF, PFTM_MAX, PFTM_PURGE, PFTM_UNLINKED }; - -/* PFTM default values */ -#define PFTM_TCP_FIRST_PACKET_VAL 120 /* First TCP packet */ -#define PFTM_TCP_OPENING_VAL 30 /* No response yet */ -#define PFTM_TCP_ESTABLISHED_VAL (24 * 60 * 60) /* Established */ -#define PFTM_TCP_CLOSING_VAL (15 * 60) /* Half closed */ -#define PFTM_TCP_FIN_WAIT_VAL 45 /* Got both FINs */ -#define PFTM_TCP_CLOSED_VAL 90 /* Got a RST */ -#define PFTM_UDP_FIRST_PACKET_VAL 60 /* First UDP packet */ -#define PFTM_UDP_SINGLE_VAL 30 /* Unidirectional */ -#define PFTM_UDP_MULTIPLE_VAL 60 /* Bidirectional */ -#define PFTM_ICMP_FIRST_PACKET_VAL 20 /* First ICMP packet */ -#define PFTM_ICMP_ERROR_REPLY_VAL 10 /* Got error response */ -#define PFTM_GREv1_FIRST_PACKET_VAL 120 -#define PFTM_GREv1_INITIATING_VAL 30 -#define PFTM_GREv1_ESTABLISHED_VAL 1800 -#define PFTM_ESP_FIRST_PACKET_VAL 120 -#define PFTM_ESP_INITIATING_VAL 30 -#define PFTM_ESP_ESTABLISHED_VAL 900 -#define PFTM_OTHER_FIRST_PACKET_VAL 60 /* First packet */ -#define PFTM_OTHER_SINGLE_VAL 30 /* Unidirectional */ -#define PFTM_OTHER_MULTIPLE_VAL 60 /* Bidirectional */ -#define PFTM_FRAG_VAL 30 /* Fragment expire */ -#define PFTM_INTERVAL_VAL 10 /* Expire interval */ -#define PFTM_SRC_NODE_VAL 0 /* Source tracking */ -#define PFTM_TS_DIFF_VAL 30 /* Allowed TS diff */ - -enum { PF_NOPFROUTE, PF_FASTROUTE, PF_ROUTETO, PF_DUPTO, PF_REPLYTO }; -enum { PF_LIMIT_STATES, - PF_LIMIT_APP_STATES, - PF_LIMIT_SRC_NODES, PF_LIMIT_FRAGS, - PF_LIMIT_TABLES, PF_LIMIT_TABLE_ENTRIES, PF_LIMIT_MAX }; -#define PF_POOL_IDMASK 0x0f -enum { PF_POOL_NONE, PF_POOL_BITMASK, PF_POOL_RANDOM, - PF_POOL_SRCHASH, PF_POOL_ROUNDROBIN }; -enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL, - PF_ADDR_TABLE, PF_ADDR_RTLABEL, PF_ADDR_URPFFAILED, - PF_ADDR_RANGE }; -#define PF_POOL_TYPEMASK 0x0f -#define PF_POOL_STICKYADDR 0x20 -#define PF_WSCALE_FLAG 0x80 -#define PF_WSCALE_MASK 0x0f - -#define PF_LOG 0x01 -#define PF_LOG_ALL 0x02 -#define PF_LOG_SOCKET_LOOKUP 0x04 - -struct pf_addr { - union { - struct in_addr v4; - struct in6_addr v6; - u_int8_t addr8[16]; - u_int16_t addr16[8]; - u_int32_t addr32[4]; - } pfa; /* 128-bit address */ -#define v4 pfa.v4 -#define v6 pfa.v6 -#define addr8 pfa.addr8 -#define addr16 pfa.addr16 -#define addr32 pfa.addr32 -}; - -#define PF_TABLE_NAME_SIZE 32 - -#define PFI_AFLAG_NETWORK 0x01 -#define PFI_AFLAG_BROADCAST 0x02 -#define PFI_AFLAG_PEER 0x04 -#define PFI_AFLAG_MODEMASK 0x07 -#define PFI_AFLAG_NOALIAS 0x08 - -#ifndef RTLABEL_LEN -#define RTLABEL_LEN 32 -#endif - -struct pf_addr_wrap { - union { - struct { - struct pf_addr addr; - struct pf_addr mask; - } a; - char ifname[IFNAMSIZ]; - char tblname[PF_TABLE_NAME_SIZE]; - char rtlabelname[RTLABEL_LEN]; - u_int32_t rtlabel; - } v; - union { -#ifdef KERNEL - struct pfi_dynaddr *dyn __attribute__((aligned(8))); - struct pfr_ktable *tbl __attribute__((aligned(8))); -#else /* !KERNEL */ - void *dyn __attribute__((aligned(8))); - void *tbl __attribute__((aligned(8))); -#endif /* !KERNEL */ - int dyncnt __attribute__((aligned(8))); - int tblcnt __attribute__((aligned(8))); - } p __attribute__((aligned(8))); - u_int8_t type; /* PF_ADDR_* */ - u_int8_t iflags; /* PFI_AFLAG_* */ -}; - -struct pf_port_range { - u_int16_t port[2]; - u_int8_t op; -}; - -union pf_rule_xport { - struct pf_port_range range; - u_int16_t call_id; - u_int32_t spi; -}; - -#ifdef KERNEL -struct pfi_dynaddr { - TAILQ_ENTRY(pfi_dynaddr) entry; - struct pf_addr pfid_addr4; - struct pf_addr pfid_mask4; - struct pf_addr pfid_addr6; - struct pf_addr pfid_mask6; - struct pfr_ktable *pfid_kt; - struct pfi_kif *pfid_kif; - void *pfid_hook_cookie; - int pfid_net; /* mask or 128 */ - int pfid_acnt4; /* address count IPv4 */ - int pfid_acnt6; /* address count IPv6 */ - sa_family_t pfid_af; /* rule af */ - u_int8_t pfid_iflags; /* PFI_AFLAG_* */ -}; - -/* - * Address manipulation macros - */ - -#if INET -#if !INET6 -#define PF_INET_ONLY -#endif /* ! INET6 */ -#endif /* INET */ - -#if INET6 -#if !INET -#define PF_INET6_ONLY -#endif /* ! INET */ -#endif /* INET6 */ - -#if INET -#if INET6 -#define PF_INET_INET6 -#endif /* INET6 */ -#endif /* INET */ - -#else /* !KERNEL */ - -#define PF_INET_INET6 - -#endif /* !KERNEL */ - -/* Both IPv4 and IPv6 */ -#ifdef PF_INET_INET6 - -#define PF_AEQ(a, b, c) \ - ((c == AF_INET && (a)->addr32[0] == (b)->addr32[0]) || \ - ((a)->addr32[3] == (b)->addr32[3] && \ - (a)->addr32[2] == (b)->addr32[2] && \ - (a)->addr32[1] == (b)->addr32[1] && \ - (a)->addr32[0] == (b)->addr32[0])) \ - -#define PF_ANEQ(a, b, c) \ - ((c == AF_INET && (a)->addr32[0] != (b)->addr32[0]) || \ - ((a)->addr32[3] != (b)->addr32[3] || \ - (a)->addr32[2] != (b)->addr32[2] || \ - (a)->addr32[1] != (b)->addr32[1] || \ - (a)->addr32[0] != (b)->addr32[0])) \ - -#define PF_ALEQ(a, b, c) \ - ((c == AF_INET && (a)->addr32[0] <= (b)->addr32[0]) || \ - ((a)->addr32[3] <= (b)->addr32[3] && \ - (a)->addr32[2] <= (b)->addr32[2] && \ - (a)->addr32[1] <= (b)->addr32[1] && \ - (a)->addr32[0] <= (b)->addr32[0])) \ - -#define PF_AZERO(a, c) \ - ((c == AF_INET && !(a)->addr32[0]) || \ - (!(a)->addr32[0] && !(a)->addr32[1] && \ - !(a)->addr32[2] && !(a)->addr32[3])) \ - -#define PF_MATCHA(n, a, m, b, f) \ - pf_match_addr(n, a, m, b, f) - -#define PF_ACPY(a, b, f) \ - pf_addrcpy(a, b, f) - -#define PF_AINC(a, f) \ - pf_addr_inc(a, f) - -#define PF_POOLMASK(a, b, c, d, f) \ - pf_poolmask(a, b, c, d, f) - -#else - -/* Just IPv6 */ - -#ifdef PF_INET6_ONLY - -#define PF_AEQ(a, b, c) \ - ((a)->addr32[3] == (b)->addr32[3] && \ - (a)->addr32[2] == (b)->addr32[2] && \ - (a)->addr32[1] == (b)->addr32[1] && \ - (a)->addr32[0] == (b)->addr32[0]) \ - -#define PF_ANEQ(a, b, c) \ - ((a)->addr32[3] != (b)->addr32[3] || \ - (a)->addr32[2] != (b)->addr32[2] || \ - (a)->addr32[1] != (b)->addr32[1] || \ - (a)->addr32[0] != (b)->addr32[0]) \ - -#define PF_ALEQ(a, b, c) \ - ((a)->addr32[3] <= (b)->addr32[3] && \ - (a)->addr32[2] <= (b)->addr32[2] && \ - (a)->addr32[1] <= (b)->addr32[1] && \ - (a)->addr32[0] <= (b)->addr32[0]) \ - -#define PF_AZERO(a, c) \ - (!(a)->addr32[0] && \ - !(a)->addr32[1] && \ - !(a)->addr32[2] && \ - !(a)->addr32[3]) \ - -#define PF_MATCHA(n, a, m, b, f) \ - pf_match_addr(n, a, m, b, f) - -#define PF_ACPY(a, b, f) \ - pf_addrcpy(a, b, f) - -#define PF_AINC(a, f) \ - pf_addr_inc(a, f) - -#define PF_POOLMASK(a, b, c, d, f) \ - pf_poolmask(a, b, c, d, f) - -#else - -/* Just IPv4 */ -#ifdef PF_INET_ONLY - -#define PF_AEQ(a, b, c) \ - ((a)->addr32[0] == (b)->addr32[0]) - -#define PF_ANEQ(a, b, c) \ - ((a)->addr32[0] != (b)->addr32[0]) - -#define PF_ALEQ(a, b, c) \ - ((a)->addr32[0] <= (b)->addr32[0]) - -#define PF_AZERO(a, c) \ - (!(a)->addr32[0]) - -#define PF_MATCHA(n, a, m, b, f) \ - pf_match_addr(n, a, m, b, f) - -#define PF_ACPY(a, b, f) \ - (a)->v4.s_addr = (b)->v4.s_addr - -#define PF_AINC(a, f) \ - do { \ - (a)->addr32[0] = htonl(ntohl((a)->addr32[0]) + 1); \ - } while (0) - -#define PF_POOLMASK(a, b, c, d, f) \ - do { \ - (a)->addr32[0] = ((b)->addr32[0] & (c)->addr32[0]) | \ - (((c)->addr32[0] ^ 0xffffffff) & (d)->addr32[0]); \ - } while (0) - -#endif /* PF_INET_ONLY */ -#endif /* PF_INET6_ONLY */ -#endif /* PF_INET_INET6 */ - -#ifdef KERNEL -#define PF_MISMATCHAW(aw, x, af, neg, ifp) \ - ( \ - (((aw)->type == PF_ADDR_NOROUTE && \ - pf_routable((x), (af), NULL)) || \ - (((aw)->type == PF_ADDR_URPFFAILED && (ifp) != NULL && \ - pf_routable((x), (af), (ifp))) || \ - ((aw)->type == PF_ADDR_RTLABEL && \ - !pf_rtlabel_match((x), (af), (aw))) || \ - ((aw)->type == PF_ADDR_TABLE && \ - !pfr_match_addr((aw)->p.tbl, (x), (af))) || \ - ((aw)->type == PF_ADDR_DYNIFTL && \ - !pfi_match_addr((aw)->p.dyn, (x), (af))) || \ - ((aw)->type == PF_ADDR_RANGE && \ - !pf_match_addr_range(&(aw)->v.a.addr, \ - &(aw)->v.a.mask, (x), (af))) || \ - ((aw)->type == PF_ADDR_ADDRMASK && \ - !PF_AZERO(&(aw)->v.a.mask, (af)) && \ - !PF_MATCHA(0, &(aw)->v.a.addr, \ - &(aw)->v.a.mask, (x), (af))))) != \ - (neg) \ - ) -#endif /* KERNEL */ - -struct pf_rule_uid { - uid_t uid[2]; - u_int8_t op; - u_int8_t _pad[3]; -}; - -struct pf_rule_gid { - uid_t gid[2]; - u_int8_t op; - u_int8_t _pad[3]; -}; - -struct pf_rule_addr { - struct pf_addr_wrap addr; - union pf_rule_xport xport; - u_int8_t neg; -}; - -struct pf_pooladdr { - struct pf_addr_wrap addr; - TAILQ_ENTRY(pf_pooladdr) entries; -#if !defined(__LP64__) - u_int32_t _pad[2]; -#endif /* !__LP64__ */ - char ifname[IFNAMSIZ]; -#ifdef KERNEL - struct pfi_kif *kif __attribute__((aligned(8))); -#else /* !KERNEL */ - void *kif __attribute__((aligned(8))); -#endif /* !KERNEL */ -}; - -TAILQ_HEAD(pf_palist, pf_pooladdr); - -struct pf_poolhashkey { - union { - u_int8_t key8[16]; - u_int16_t key16[8]; - u_int32_t key32[4]; - } pfk; /* 128-bit hash key */ -#define key8 pfk.key8 -#define key16 pfk.key16 -#define key32 pfk.key32 -}; - -struct pf_pool { - struct pf_palist list; -#if !defined(__LP64__) - u_int32_t _pad[2]; -#endif /* !__LP64__ */ -#ifdef KERNEL - struct pf_pooladdr *cur __attribute__((aligned(8))); -#else /* !KERNEL */ - void *cur __attribute__((aligned(8))); -#endif /* !KERNEL */ - struct pf_poolhashkey key __attribute__((aligned(8))); - struct pf_addr counter; - int tblidx; - u_int16_t proxy_port[2]; - u_int8_t port_op; - u_int8_t opts; - sa_family_t af; -}; - - -/* A packed Operating System description for fingerprinting */ -typedef u_int32_t pf_osfp_t; -#define PF_OSFP_ANY ((pf_osfp_t)0) -#define PF_OSFP_UNKNOWN ((pf_osfp_t)-1) -#define PF_OSFP_NOMATCH ((pf_osfp_t)-2) - -struct pf_osfp_entry { - SLIST_ENTRY(pf_osfp_entry) fp_entry; -#if !defined(__LP64__) - u_int32_t _pad; -#endif /* !__LP64__ */ - pf_osfp_t fp_os; - int fp_enflags; -#define PF_OSFP_EXPANDED 0x001 /* expanded entry */ -#define PF_OSFP_GENERIC 0x002 /* generic signature */ -#define PF_OSFP_NODETAIL 0x004 /* no p0f details */ -#define PF_OSFP_LEN 32 - char fp_class_nm[PF_OSFP_LEN]; - char fp_version_nm[PF_OSFP_LEN]; - char fp_subtype_nm[PF_OSFP_LEN]; -}; -#define PF_OSFP_ENTRY_EQ(a, b) \ - ((a)->fp_os == (b)->fp_os && \ - memcmp((a)->fp_class_nm, (b)->fp_class_nm, PF_OSFP_LEN) == 0 && \ - memcmp((a)->fp_version_nm, (b)->fp_version_nm, PF_OSFP_LEN) == 0 && \ - memcmp((a)->fp_subtype_nm, (b)->fp_subtype_nm, PF_OSFP_LEN) == 0) - -/* handle pf_osfp_t packing */ -#define _FP_RESERVED_BIT 1 /* For the special negative #defines */ -#define _FP_UNUSED_BITS 1 -#define _FP_CLASS_BITS 10 /* OS Class (Windows, Linux) */ -#define _FP_VERSION_BITS 10 /* OS version (95, 98, NT, 2.4.54, 3.2) */ -#define _FP_SUBTYPE_BITS 10 /* patch level (NT SP4, SP3, ECN patch) */ -#define PF_OSFP_UNPACK(osfp, class, version, subtype) do { \ - (class) = ((osfp) >> (_FP_VERSION_BITS+_FP_SUBTYPE_BITS)) & \ - ((1 << _FP_CLASS_BITS) - 1); \ - (version) = ((osfp) >> _FP_SUBTYPE_BITS) & \ - ((1 << _FP_VERSION_BITS) - 1);\ - (subtype) = (osfp) & ((1 << _FP_SUBTYPE_BITS) - 1); \ -} while (0) -#define PF_OSFP_PACK(osfp, class, version, subtype) do { \ - (osfp) = ((class) & ((1 << _FP_CLASS_BITS) - 1)) << (_FP_VERSION_BITS \ - + _FP_SUBTYPE_BITS); \ - (osfp) |= ((version) & ((1 << _FP_VERSION_BITS) - 1)) << \ - _FP_SUBTYPE_BITS; \ - (osfp) |= (subtype) & ((1 << _FP_SUBTYPE_BITS) - 1); \ -} while (0) - -/* the fingerprint of an OSes TCP SYN packet */ -typedef u_int64_t pf_tcpopts_t; -struct pf_os_fingerprint { - SLIST_HEAD(pf_osfp_enlist, pf_osfp_entry) fp_oses; /* list of matches */ - pf_tcpopts_t fp_tcpopts; /* packed TCP options */ - u_int16_t fp_wsize; /* TCP window size */ - u_int16_t fp_psize; /* ip->ip_len */ - u_int16_t fp_mss; /* TCP MSS */ - u_int16_t fp_flags; -#define PF_OSFP_WSIZE_MOD 0x0001 /* Window modulus */ -#define PF_OSFP_WSIZE_DC 0x0002 /* Window don't care */ -#define PF_OSFP_WSIZE_MSS 0x0004 /* Window multiple of MSS */ -#define PF_OSFP_WSIZE_MTU 0x0008 /* Window multiple of MTU */ -#define PF_OSFP_PSIZE_MOD 0x0010 /* packet size modulus */ -#define PF_OSFP_PSIZE_DC 0x0020 /* packet size don't care */ -#define PF_OSFP_WSCALE 0x0040 /* TCP window scaling */ -#define PF_OSFP_WSCALE_MOD 0x0080 /* TCP window scale modulus */ -#define PF_OSFP_WSCALE_DC 0x0100 /* TCP window scale dont-care */ -#define PF_OSFP_MSS 0x0200 /* TCP MSS */ -#define PF_OSFP_MSS_MOD 0x0400 /* TCP MSS modulus */ -#define PF_OSFP_MSS_DC 0x0800 /* TCP MSS dont-care */ -#define PF_OSFP_DF 0x1000 /* IPv4 don't fragment bit */ -#define PF_OSFP_TS0 0x2000 /* Zero timestamp */ -#define PF_OSFP_INET6 0x4000 /* IPv6 */ - u_int8_t fp_optcnt; /* TCP option count */ - u_int8_t fp_wscale; /* TCP window scaling */ - u_int8_t fp_ttl; /* IPv4 TTL */ -#define PF_OSFP_MAXTTL_OFFSET 40 -/* TCP options packing */ -#define PF_OSFP_TCPOPT_NOP 0x0 /* TCP NOP option */ -#define PF_OSFP_TCPOPT_WSCALE 0x1 /* TCP window scaling option */ -#define PF_OSFP_TCPOPT_MSS 0x2 /* TCP max segment size opt */ -#define PF_OSFP_TCPOPT_SACK 0x3 /* TCP SACK OK option */ -#define PF_OSFP_TCPOPT_TS 0x4 /* TCP timestamp option */ -#define PF_OSFP_TCPOPT_BITS 3 /* bits used by each option */ -#define PF_OSFP_MAX_OPTS \ - (sizeof(((struct pf_os_fingerprint *)0)->fp_tcpopts) * 8) \ - / PF_OSFP_TCPOPT_BITS - - SLIST_ENTRY(pf_os_fingerprint) fp_next; -}; - -struct pf_osfp_ioctl { - struct pf_osfp_entry fp_os; - pf_tcpopts_t fp_tcpopts; /* packed TCP options */ - u_int16_t fp_wsize; /* TCP window size */ - u_int16_t fp_psize; /* ip->ip_len */ - u_int16_t fp_mss; /* TCP MSS */ - u_int16_t fp_flags; - u_int8_t fp_optcnt; /* TCP option count */ - u_int8_t fp_wscale; /* TCP window scaling */ - u_int8_t fp_ttl; /* IPv4 TTL */ - - int fp_getnum; /* DIOCOSFPGET number */ -}; - - -union pf_rule_ptr { - struct pf_rule *ptr __attribute__((aligned(8))); - u_int32_t nr __attribute__((aligned(8))); -} __attribute__((aligned(8))); - -#define PF_ANCHOR_NAME_SIZE 64 - -struct pf_rule { - struct pf_rule_addr src; - struct pf_rule_addr dst; -#define PF_SKIP_IFP 0 -#define PF_SKIP_DIR 1 -#define PF_SKIP_AF 2 -#define PF_SKIP_PROTO 3 -#define PF_SKIP_SRC_ADDR 4 -#define PF_SKIP_SRC_PORT 5 -#define PF_SKIP_DST_ADDR 6 -#define PF_SKIP_DST_PORT 7 -#define PF_SKIP_COUNT 8 - union pf_rule_ptr skip[PF_SKIP_COUNT]; -#define PF_RULE_LABEL_SIZE 64 - char label[PF_RULE_LABEL_SIZE]; -#define PF_QNAME_SIZE 64 - char ifname[IFNAMSIZ]; - char qname[PF_QNAME_SIZE]; - char pqname[PF_QNAME_SIZE]; -#define PF_TAG_NAME_SIZE 64 - char tagname[PF_TAG_NAME_SIZE]; - char match_tagname[PF_TAG_NAME_SIZE]; - - char overload_tblname[PF_TABLE_NAME_SIZE]; - - TAILQ_ENTRY(pf_rule) entries; -#if !defined(__LP64__) - u_int32_t _pad[2]; -#endif /* !__LP64__ */ - struct pf_pool rpool; - - u_int64_t evaluations; - u_int64_t packets[2]; - u_int64_t bytes[2]; - - u_int64_t ticket; -#define PF_OWNER_NAME_SIZE 64 - char owner[PF_OWNER_NAME_SIZE]; - u_int32_t priority; - -#ifdef KERNEL - struct pfi_kif *kif __attribute__((aligned(8))); -#else /* !KERNEL */ - void *kif __attribute__((aligned(8))); -#endif /* !KERNEL */ - struct pf_anchor *anchor __attribute__((aligned(8))); -#ifdef KERNEL - struct pfr_ktable *overload_tbl __attribute__((aligned(8))); -#else /* !KERNEL */ - void *overload_tbl __attribute__((aligned(8))); -#endif /* !KERNEL */ - - pf_osfp_t os_fingerprint __attribute__((aligned(8))); - - unsigned int rtableid; - u_int32_t timeout[PFTM_MAX]; - u_int32_t states; - u_int32_t max_states; - u_int32_t src_nodes; - u_int32_t max_src_nodes; - u_int32_t max_src_states; - u_int32_t max_src_conn; - struct { - u_int32_t limit; - u_int32_t seconds; - } max_src_conn_rate; - u_int32_t qid; - u_int32_t pqid; - u_int32_t rt_listid; - u_int32_t nr; - u_int32_t prob; - uid_t cuid; - pid_t cpid; - - u_int16_t return_icmp; - u_int16_t return_icmp6; - u_int16_t max_mss; - u_int16_t tag; - u_int16_t match_tag; - - struct pf_rule_uid uid; - struct pf_rule_gid gid; - - u_int32_t rule_flag; - u_int8_t action; - u_int8_t direction; - u_int8_t log; - u_int8_t logif; - u_int8_t quick; - u_int8_t ifnot; - u_int8_t match_tag_not; - u_int8_t natpass; - -#define PF_STATE_NORMAL 0x1 -#define PF_STATE_MODULATE 0x2 -#define PF_STATE_SYNPROXY 0x3 - u_int8_t keep_state; - sa_family_t af; - u_int8_t proto; - u_int8_t type; - u_int8_t code; - u_int8_t flags; - u_int8_t flagset; - u_int8_t min_ttl; - u_int8_t allow_opts; - u_int8_t rt; - u_int8_t return_ttl; - -/* service class categories */ -#define SCIDX_MASK 0x0f -#define SC_BE 0x10 -#define SC_BK_SYS 0x11 -#define SC_BK 0x12 -#define SC_RD 0x13 -#define SC_OAM 0x14 -#define SC_AV 0x15 -#define SC_RV 0x16 -#define SC_VI 0x17 -#define SC_VO 0x18 -#define SC_CTL 0x19 - -/* diffserve code points */ -#define DSCP_MASK 0xfc -#define DSCP_CUMASK 0x03 -#define DSCP_EF 0xb8 -#define DSCP_AF11 0x28 -#define DSCP_AF12 0x30 -#define DSCP_AF13 0x38 -#define DSCP_AF21 0x48 -#define DSCP_AF22 0x50 -#define DSCP_AF23 0x58 -#define DSCP_AF31 0x68 -#define DSCP_AF32 0x70 -#define DSCP_AF33 0x78 -#define DSCP_AF41 0x88 -#define DSCP_AF42 0x90 -#define DSCP_AF43 0x98 -#define AF_CLASSMASK 0xe0 -#define AF_DROPPRECMASK 0x18 - u_int8_t tos; - u_int8_t anchor_relative; - u_int8_t anchor_wildcard; - -#define PF_FLUSH 0x01 -#define PF_FLUSH_GLOBAL 0x02 - u_int8_t flush; - - u_int8_t proto_variant; - u_int8_t extfilter; /* Filter mode [PF_EXTFILTER_xxx] */ - u_int8_t extmap; /* Mapping mode [PF_EXTMAP_xxx] */ - u_int32_t dnpipe; - u_int32_t dntype; -}; - -/* pf device identifiers */ -#define PFDEV_PF 0 -#define PFDEV_PFM 1 -#define PFDEV_MAX 2 - -/* rule flags */ -#define PFRULE_DROP 0x0000 -#define PFRULE_RETURNRST 0x0001 -#define PFRULE_FRAGMENT 0x0002 -#define PFRULE_RETURNICMP 0x0004 -#define PFRULE_RETURN 0x0008 -#define PFRULE_NOSYNC 0x0010 -#define PFRULE_SRCTRACK 0x0020 /* track source states */ -#define PFRULE_RULESRCTRACK 0x0040 /* per rule */ - -/* scrub flags */ -#define PFRULE_NODF 0x0100 -#define PFRULE_FRAGCROP 0x0200 /* non-buffering frag cache */ -#define PFRULE_FRAGDROP 0x0400 /* drop funny fragments */ -#define PFRULE_RANDOMID 0x0800 -#define PFRULE_REASSEMBLE_TCP 0x1000 - -/* rule flags for TOS/DSCP/service class differentiation */ -#define PFRULE_TOS 0x2000 -#define PFRULE_DSCP 0x4000 -#define PFRULE_SC 0x8000 - -/* rule flags again */ -#define PFRULE_IFBOUND 0x00010000 /* if-bound */ -#define PFRULE_PFM 0x00020000 /* created by pfm device */ - -#define PFSTATE_HIWAT 10000 /* default state table size */ -#define PFSTATE_ADAPT_START 6000 /* default adaptive timeout start */ -#define PFSTATE_ADAPT_END 12000 /* default adaptive timeout end */ - -#define PFAPPSTATE_HIWAT 10000 /* default same as state table */ - -enum pf_extmap { - PF_EXTMAP_APD = 1, /* Address-port-dependent mapping */ - PF_EXTMAP_AD, /* Address-dependent mapping */ - PF_EXTMAP_EI /* Endpoint-independent mapping */ -}; - -enum pf_extfilter { - PF_EXTFILTER_APD = 1, /* Address-port-dependent filtering */ - PF_EXTFILTER_AD, /* Address-dependent filtering */ - PF_EXTFILTER_EI /* Endpoint-independent filtering */ -}; - -struct pf_threshold { - u_int32_t limit; -#define PF_THRESHOLD_MULT 1000 -#define PF_THRESHOLD_MAX 0xffffffff / PF_THRESHOLD_MULT - u_int32_t seconds; - u_int32_t count; - u_int32_t last; -}; - -struct pf_src_node { - RB_ENTRY(pf_src_node) entry; - struct pf_addr addr; - struct pf_addr raddr; - union pf_rule_ptr rule; -#ifdef KERNEL - struct pfi_kif *kif; -#else /* !KERNEL */ - void *kif; -#endif /* !KERNEL */ - u_int64_t bytes[2]; - u_int64_t packets[2]; - u_int32_t states; - u_int32_t conn; - struct pf_threshold conn_rate; - u_int64_t creation; - u_int64_t expire; - sa_family_t af; - u_int8_t ruletype; -}; - -#define PFSNODE_HIWAT 10000 /* default source node table size */ - -#ifdef KERNEL -struct pf_state_scrub { - struct timeval pfss_last; /* time received last packet */ - u_int32_t pfss_tsecr; /* last echoed timestamp */ - u_int32_t pfss_tsval; /* largest timestamp */ - u_int32_t pfss_tsval0; /* original timestamp */ - u_int16_t pfss_flags; -#define PFSS_TIMESTAMP 0x0001 /* modulate timestamp */ -#define PFSS_PAWS 0x0010 /* stricter PAWS checks */ -#define PFSS_PAWS_IDLED 0x0020 /* was idle too long. no PAWS */ -#define PFSS_DATA_TS 0x0040 /* timestamp on data packets */ -#define PFSS_DATA_NOTS 0x0080 /* no timestamp on data packets */ - u_int8_t pfss_ttl; /* stashed TTL */ - u_int8_t pad; - u_int32_t pfss_ts_mod; /* timestamp modulation */ -}; -#endif /* KERNEL */ - -union pf_state_xport { - u_int16_t port; - u_int16_t call_id; - u_int32_t spi; -}; - -struct pf_state_host { - struct pf_addr addr; - union pf_state_xport xport; -}; - -#ifdef KERNEL -struct pf_state_peer { - u_int32_t seqlo; /* Max sequence number sent */ - u_int32_t seqhi; /* Max the other end ACKd + win */ - u_int32_t seqdiff; /* Sequence number modulator */ - u_int16_t max_win; /* largest window (pre scaling) */ - u_int8_t state; /* active state level */ - u_int8_t wscale; /* window scaling factor */ - u_int16_t mss; /* Maximum segment size option */ - u_int8_t tcp_est; /* Did we reach TCPS_ESTABLISHED */ - struct pf_state_scrub *scrub; /* state is scrubbed */ - u_int8_t pad[3]; -}; - -TAILQ_HEAD(pf_state_queue, pf_state); - -struct pf_state; -struct pf_pdesc; -struct pf_app_state; - -typedef void (*pf_app_handler)(struct pf_state *, int, int, struct pf_pdesc *, - struct pfi_kif *); - -typedef int (*pf_app_compare)(struct pf_app_state *, struct pf_app_state *); - -struct pf_pptp_state { - struct pf_state *grev1_state; -}; - -struct pf_grev1_state { - struct pf_state *pptp_state; -}; - -struct pf_ike_state { - u_int64_t cookie; -}; - -struct pf_app_state { - pf_app_handler handler; - pf_app_compare compare_lan_ext; - pf_app_compare compare_ext_gwy; - union { - struct pf_pptp_state pptp; - struct pf_grev1_state grev1; - struct pf_ike_state ike; - } u; -}; - -/* keep synced with struct pf_state, used in RB_FIND */ -struct pf_state_key_cmp { - struct pf_state_host lan; - struct pf_state_host gwy; - struct pf_state_host ext_lan; - struct pf_state_host ext_gwy; - sa_family_t af_lan; - sa_family_t af_gwy; - u_int8_t proto; - u_int8_t direction; - u_int8_t proto_variant; - struct pf_app_state *app_state; -}; - -TAILQ_HEAD(pf_statelist, pf_state); - -struct pf_state_key { - struct pf_state_host lan; - struct pf_state_host gwy; - struct pf_state_host ext_lan; - struct pf_state_host ext_gwy; - sa_family_t af_lan; - sa_family_t af_gwy; - u_int8_t proto; - u_int8_t direction; - u_int8_t proto_variant; - struct pf_app_state *app_state; - u_int32_t flowsrc; - u_int32_t flowhash; - - RB_ENTRY(pf_state_key) entry_lan_ext; - RB_ENTRY(pf_state_key) entry_ext_gwy; - struct pf_statelist states; - u_int32_t refcnt; -}; - - -/* keep synced with struct pf_state, used in RB_FIND */ -struct pf_state_cmp { - u_int64_t id; - u_int32_t creatorid; - u_int32_t pad; -}; - -/* flowhash key (12-bytes multiple for performance) */ -struct pf_flowhash_key { - struct pf_state_host ap1; /* address+port blob 1 */ - struct pf_state_host ap2; /* address+port blob 2 */ - u_int32_t af; - u_int32_t proto; -}; -#endif /* KERNEL */ - -struct hook_desc; -TAILQ_HEAD(hook_desc_head, hook_desc); - -#ifdef KERNEL -struct pf_state { - u_int64_t id; - u_int32_t creatorid; - u_int32_t pad; - - TAILQ_ENTRY(pf_state) entry_list; - TAILQ_ENTRY(pf_state) next; - RB_ENTRY(pf_state) entry_id; - struct pf_state_peer src; - struct pf_state_peer dst; - union pf_rule_ptr rule; - union pf_rule_ptr anchor; - union pf_rule_ptr nat_rule; - struct pf_addr rt_addr; - struct hook_desc_head unlink_hooks; - struct pf_state_key *state_key; - struct pfi_kif *kif; - struct pfi_kif *rt_kif; - struct pf_src_node *src_node; - struct pf_src_node *nat_src_node; - u_int64_t packets[2]; - u_int64_t bytes[2]; - u_int64_t creation; - u_int64_t expire; - u_int64_t pfsync_time; - u_int16_t tag; - u_int8_t log; - u_int8_t allow_opts; - u_int8_t timeout; - u_int8_t sync_flags; -}; -#endif /* KERNEL */ - -#define PFSTATE_NOSYNC 0x01 -#define PFSTATE_FROMSYNC 0x02 -#define PFSTATE_STALE 0x04 - -#define __packed __attribute__((__packed__)) - -/* - * Unified state structures for pulling states out of the kernel - * used by pfsync(4) and the pf(4) ioctl. - */ -struct pfsync_state_scrub { - u_int16_t pfss_flags; - u_int8_t pfss_ttl; /* stashed TTL */ -#define PFSYNC_SCRUB_FLAG_VALID 0x01 - u_int8_t scrub_flag; - u_int32_t pfss_ts_mod; /* timestamp modulation */ -} __packed; - -struct pfsync_state_host { - struct pf_addr addr; - union pf_state_xport xport; - u_int16_t pad[2]; -} __packed; - -struct pfsync_state_peer { - struct pfsync_state_scrub scrub; /* state is scrubbed */ - u_int32_t seqlo; /* Max sequence number sent */ - u_int32_t seqhi; /* Max the other end ACKd + win */ - u_int32_t seqdiff; /* Sequence number modulator */ - u_int16_t max_win; /* largest window (pre scaling) */ - u_int16_t mss; /* Maximum segment size option */ - u_int8_t state; /* active state level */ - u_int8_t wscale; /* window scaling factor */ - u_int8_t pad[6]; -} __packed; - -struct pfsync_state { - u_int32_t id[2]; - char ifname[IFNAMSIZ]; - struct pfsync_state_host lan; - struct pfsync_state_host gwy; - struct pfsync_state_host ext_lan; - struct pfsync_state_host ext_gwy; - struct pfsync_state_peer src; - struct pfsync_state_peer dst; - struct pf_addr rt_addr; - struct hook_desc_head unlink_hooks; -#if !defined(__LP64__) - u_int32_t _pad[2]; -#endif /* !__LP64__ */ - u_int32_t rule; - u_int32_t anchor; - u_int32_t nat_rule; - u_int64_t creation; - u_int64_t expire; - u_int32_t packets[2][2]; - u_int32_t bytes[2][2]; - u_int32_t creatorid; - u_int16_t tag; - sa_family_t af_lan; - sa_family_t af_gwy; - u_int8_t proto; - u_int8_t direction; - u_int8_t log; - u_int8_t allow_opts; - u_int8_t timeout; - u_int8_t sync_flags; - u_int8_t updates; - u_int8_t proto_variant; - u_int8_t __pad; - u_int32_t flowhash; -} __packed; - -#define PFSYNC_FLAG_COMPRESS 0x01 -#define PFSYNC_FLAG_STALE 0x02 -#define PFSYNC_FLAG_SRCNODE 0x04 -#define PFSYNC_FLAG_NATSRCNODE 0x08 - -#ifdef KERNEL -/* for copies to/from userland via pf_ioctl() */ -#define pf_state_peer_to_pfsync(s, d) do { \ - (d)->seqlo = (s)->seqlo; \ - (d)->seqhi = (s)->seqhi; \ - (d)->seqdiff = (s)->seqdiff; \ - (d)->max_win = (s)->max_win; \ - (d)->mss = (s)->mss; \ - (d)->state = (s)->state; \ - (d)->wscale = (s)->wscale; \ - if ((s)->scrub) { \ - (d)->scrub.pfss_flags = \ - (s)->scrub->pfss_flags & PFSS_TIMESTAMP; \ - (d)->scrub.pfss_ttl = (s)->scrub->pfss_ttl; \ - (d)->scrub.pfss_ts_mod = (s)->scrub->pfss_ts_mod; \ - (d)->scrub.scrub_flag = PFSYNC_SCRUB_FLAG_VALID; \ - } \ -} while (0) - -#define pf_state_peer_from_pfsync(s, d) do { \ - (d)->seqlo = (s)->seqlo; \ - (d)->seqhi = (s)->seqhi; \ - (d)->seqdiff = (s)->seqdiff; \ - (d)->max_win = (s)->max_win; \ - (d)->mss = ntohs((s)->mss); \ - (d)->state = (s)->state; \ - (d)->wscale = (s)->wscale; \ - if ((s)->scrub.scrub_flag == PFSYNC_SCRUB_FLAG_VALID && \ - (d)->scrub != NULL) { \ - (d)->scrub->pfss_flags = \ - ntohs((s)->scrub.pfss_flags) & PFSS_TIMESTAMP; \ - (d)->scrub->pfss_ttl = (s)->scrub.pfss_ttl; \ - (d)->scrub->pfss_ts_mod = (s)->scrub.pfss_ts_mod; \ - } \ -} while (0) -#endif /* KERNEL */ - -#define pf_state_counter_to_pfsync(s, d) do { \ - d[0] = (s>>32)&0xffffffff; \ - d[1] = s&0xffffffff; \ -} while (0) - -#define pf_state_counter_from_pfsync(s) \ - (((u_int64_t)(s[0])<<32) | (u_int64_t)(s[1])) - - - -TAILQ_HEAD(pf_rulequeue, pf_rule); - -struct pf_anchor; - -struct pf_ruleset { - struct { - struct pf_rulequeue queues[2]; - struct { - struct pf_rulequeue *ptr; - struct pf_rule **ptr_array; - u_int32_t rcount; - u_int32_t ticket; - int open; - } active, inactive; - } rules[PF_RULESET_MAX]; - struct pf_anchor *anchor; - u_int32_t tticket; - int tables; - int topen; -}; - -RB_HEAD(pf_anchor_global, pf_anchor); -RB_HEAD(pf_anchor_node, pf_anchor); -struct pf_anchor { - RB_ENTRY(pf_anchor) entry_global; - RB_ENTRY(pf_anchor) entry_node; - struct pf_anchor *parent; - struct pf_anchor_node children; - char name[PF_ANCHOR_NAME_SIZE]; - char path[MAXPATHLEN]; - struct pf_ruleset ruleset; - int refcnt; /* anchor rules */ - int match; - char owner[PF_OWNER_NAME_SIZE]; -}; -#ifdef KERNEL -RB_PROTOTYPE_SC(__private_extern__, pf_anchor_global, pf_anchor, entry_global, - pf_anchor_compare); -RB_PROTOTYPE_SC(__private_extern__, pf_anchor_node, pf_anchor, entry_node, - pf_anchor_compare); -#else /* !KERNEL */ -RB_PROTOTYPE(pf_anchor_global, pf_anchor, entry_global, pf_anchor_compare); -RB_PROTOTYPE(pf_anchor_node, pf_anchor, entry_node, pf_anchor_compare); -#endif /* !KERNEL */ - -#define PF_RESERVED_ANCHOR "_pf" - -#define PFR_TFLAG_PERSIST 0x00000001 -#define PFR_TFLAG_CONST 0x00000002 -#define PFR_TFLAG_ACTIVE 0x00000004 -#define PFR_TFLAG_INACTIVE 0x00000008 -#define PFR_TFLAG_REFERENCED 0x00000010 -#define PFR_TFLAG_REFDANCHOR 0x00000020 -#define PFR_TFLAG_USRMASK 0x00000003 -#define PFR_TFLAG_SETMASK 0x0000003C -#define PFR_TFLAG_ALLMASK 0x0000003F - -struct pfr_table { - char pfrt_anchor[MAXPATHLEN]; - char pfrt_name[PF_TABLE_NAME_SIZE]; - u_int32_t pfrt_flags; - u_int8_t pfrt_fback; -}; - -enum { PFR_FB_NONE, PFR_FB_MATCH, PFR_FB_ADDED, PFR_FB_DELETED, - PFR_FB_CHANGED, PFR_FB_CLEARED, PFR_FB_DUPLICATE, - PFR_FB_NOTMATCH, PFR_FB_CONFLICT, PFR_FB_MAX }; - -struct pfr_addr { - union { - struct in_addr _pfra_ip4addr; - struct in6_addr _pfra_ip6addr; - } pfra_u; - u_int8_t pfra_af; - u_int8_t pfra_net; - u_int8_t pfra_not; - u_int8_t pfra_fback; -}; -#define pfra_ip4addr pfra_u._pfra_ip4addr -#define pfra_ip6addr pfra_u._pfra_ip6addr - -enum { PFR_DIR_IN, PFR_DIR_OUT, PFR_DIR_MAX }; -enum { PFR_OP_BLOCK, PFR_OP_PASS, PFR_OP_ADDR_MAX, PFR_OP_TABLE_MAX }; -#define PFR_OP_XPASS PFR_OP_ADDR_MAX - -struct pfr_astats { - struct pfr_addr pfras_a; -#if !defined(__LP64__) - u_int32_t _pad; -#endif /* !__LP64__ */ - u_int64_t pfras_packets[PFR_DIR_MAX][PFR_OP_ADDR_MAX]; - u_int64_t pfras_bytes[PFR_DIR_MAX][PFR_OP_ADDR_MAX]; - u_int64_t pfras_tzero; -}; - -enum { PFR_REFCNT_RULE, PFR_REFCNT_ANCHOR, PFR_REFCNT_MAX }; - -struct pfr_tstats { - struct pfr_table pfrts_t; - u_int64_t pfrts_packets[PFR_DIR_MAX][PFR_OP_TABLE_MAX]; - u_int64_t pfrts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX]; - u_int64_t pfrts_match; - u_int64_t pfrts_nomatch; - u_int64_t pfrts_tzero; - int pfrts_cnt; - int pfrts_refcnt[PFR_REFCNT_MAX]; -#if !defined(__LP64__) - u_int32_t _pad; -#endif /* !__LP64__ */ -}; -#define pfrts_name pfrts_t.pfrt_name -#define pfrts_flags pfrts_t.pfrt_flags - -#ifdef KERNEL -SLIST_HEAD(pfr_kentryworkq, pfr_kentry); -struct pfr_kentry { - struct radix_node pfrke_node[2]; - union sockaddr_union pfrke_sa; - u_int64_t pfrke_packets[PFR_DIR_MAX][PFR_OP_ADDR_MAX]; - u_int64_t pfrke_bytes[PFR_DIR_MAX][PFR_OP_ADDR_MAX]; - SLIST_ENTRY(pfr_kentry) pfrke_workq; - u_int64_t pfrke_tzero; - u_int8_t pfrke_af; - u_int8_t pfrke_net; - u_int8_t pfrke_not; - u_int8_t pfrke_mark; - u_int8_t pfrke_intrpool; -}; - -SLIST_HEAD(pfr_ktableworkq, pfr_ktable); -RB_HEAD(pfr_ktablehead, pfr_ktable); -struct pfr_ktable { - struct pfr_tstats pfrkt_ts; - RB_ENTRY(pfr_ktable) pfrkt_tree; - SLIST_ENTRY(pfr_ktable) pfrkt_workq; - struct radix_node_head *pfrkt_ip4; - struct radix_node_head *pfrkt_ip6; - struct pfr_ktable *pfrkt_shadow; - struct pfr_ktable *pfrkt_root; - struct pf_ruleset *pfrkt_rs; - u_int64_t pfrkt_larg; - u_int32_t pfrkt_nflags; -}; -#define pfrkt_t pfrkt_ts.pfrts_t -#define pfrkt_name pfrkt_t.pfrt_name -#define pfrkt_anchor pfrkt_t.pfrt_anchor -#define pfrkt_ruleset pfrkt_t.pfrt_ruleset -#define pfrkt_flags pfrkt_t.pfrt_flags -#define pfrkt_cnt pfrkt_ts.pfrts_cnt -#define pfrkt_refcnt pfrkt_ts.pfrts_refcnt -#define pfrkt_packets pfrkt_ts.pfrts_packets -#define pfrkt_bytes pfrkt_ts.pfrts_bytes -#define pfrkt_match pfrkt_ts.pfrts_match -#define pfrkt_nomatch pfrkt_ts.pfrts_nomatch -#define pfrkt_tzero pfrkt_ts.pfrts_tzero - -RB_HEAD(pf_state_tree_lan_ext, pf_state_key); -RB_PROTOTYPE_SC(__private_extern__, pf_state_tree_lan_ext, pf_state_key, - entry_lan_ext, pf_state_compare_lan_ext); - -RB_HEAD(pf_state_tree_ext_gwy, pf_state_key); -RB_PROTOTYPE_SC(__private_extern__, pf_state_tree_ext_gwy, pf_state_key, - entry_ext_gwy, pf_state_compare_ext_gwy); - -RB_HEAD(pfi_ifhead, pfi_kif); - -/* state tables */ -extern struct pf_state_tree_lan_ext pf_statetbl_lan_ext; -extern struct pf_state_tree_ext_gwy pf_statetbl_ext_gwy; - -/* keep synced with pfi_kif, used in RB_FIND */ -struct pfi_kif_cmp { - char pfik_name[IFNAMSIZ]; -}; - -struct pfi_kif { - char pfik_name[IFNAMSIZ]; - RB_ENTRY(pfi_kif) pfik_tree; - u_int64_t pfik_packets[2][2][2]; - u_int64_t pfik_bytes[2][2][2]; - u_int64_t pfik_tzero; - int pfik_flags; - void *pfik_ah_cookie; - struct ifnet *pfik_ifp; - int pfik_states; - int pfik_rules; - TAILQ_HEAD(, pfi_dynaddr) pfik_dynaddrs; -}; - -enum pfi_kif_refs { - PFI_KIF_REF_NONE, - PFI_KIF_REF_STATE, - PFI_KIF_REF_RULE -}; - -struct pfi_uif { -#else /* !KERNEL */ -struct pfi_kif { -#endif /* !KERNEL */ - char pfik_name[IFNAMSIZ]; - u_int64_t pfik_packets[2][2][2]; - u_int64_t pfik_bytes[2][2][2]; - u_int64_t pfik_tzero; - int pfik_flags; - int pfik_states; - int pfik_rules; -#if !defined(__LP64__) - u_int32_t _pad; -#endif /* !__LP64__ */ -}; - -#define PFI_IFLAG_SKIP 0x0100 /* skip filtering on interface */ - -#ifdef KERNEL -struct pf_pdesc { - struct { - int done; - uid_t uid; - gid_t gid; - pid_t pid; - } lookup; - u_int64_t tot_len; /* Make Mickey money */ - union { - struct tcphdr *tcp; - struct udphdr *udp; - struct icmp *icmp; -#if INET6 - struct icmp6_hdr *icmp6; -#endif /* INET6 */ - struct pf_grev1_hdr *grev1; - struct pf_esp_hdr *esp; - void *any; - } hdr; - - /* XXX TODO: Change baddr and naddr to *saddr */ - struct pf_addr baddr; /* src address before translation */ - struct pf_addr bdaddr; /* dst address before translation */ - struct pf_addr naddr; /* src address after translation */ - struct pf_addr ndaddr; /* dst address after translation */ - struct pf_rule *nat_rule; /* nat/rdr rule applied to packet */ - struct pf_addr *src; - struct pf_addr *dst; - struct ether_header - *eh; - struct mbuf *mp; - int lmw; /* lazy writable offset */ - struct pf_mtag *pf_mtag; - u_int16_t *ip_sum; - u_int32_t off; /* protocol header offset */ - u_int32_t hdrlen; /* protocol header length */ - u_int32_t p_len; /* total length of payload */ - u_int16_t flags; /* Let SCRUB trigger behavior in */ - /* state code. Easier than tags */ -#define PFDESC_TCP_NORM 0x0001 /* TCP shall be statefully scrubbed */ -#define PFDESC_IP_REAS 0x0002 /* IP frags would've been reassembled */ -#define PFDESC_IP_FRAG 0x0004 /* This is a fragment */ - sa_family_t af; - sa_family_t naf; /* address family after translation */ - u_int8_t proto; - u_int8_t tos; - u_int8_t ttl; - u_int8_t proto_variant; - mbuf_svc_class_t sc; /* mbuf service class (MBUF_SVC) */ - u_int32_t pktflags; /* mbuf packet flags (PKTF) */ - u_int32_t flowsrc; /* flow source (FLOWSRC) */ - u_int32_t flowhash; /* flow hash to identify the sender */ -}; -#endif /* KERNEL */ - -/* flags for RDR options */ -#define PF_DPORT_RANGE 0x01 /* Dest port uses range */ -#define PF_RPORT_RANGE 0x02 /* RDR'ed port uses range */ - -/* Reasons code for passing/dropping a packet */ -#define PFRES_MATCH 0 /* Explicit match of a rule */ -#define PFRES_BADOFF 1 /* Bad offset for pull_hdr */ -#define PFRES_FRAG 2 /* Dropping following fragment */ -#define PFRES_SHORT 3 /* Dropping short packet */ -#define PFRES_NORM 4 /* Dropping by normalizer */ -#define PFRES_MEMORY 5 /* Dropped due to lacking mem */ -#define PFRES_TS 6 /* Bad TCP Timestamp (RFC1323) */ -#define PFRES_CONGEST 7 /* Congestion (of ipintrq) */ -#define PFRES_IPOPTIONS 8 /* IP option */ -#define PFRES_PROTCKSUM 9 /* Protocol checksum invalid */ -#define PFRES_BADSTATE 10 /* State mismatch */ -#define PFRES_STATEINS 11 /* State insertion failure */ -#define PFRES_MAXSTATES 12 /* State limit */ -#define PFRES_SRCLIMIT 13 /* Source node/conn limit */ -#define PFRES_SYNPROXY 14 /* SYN proxy */ -#define PFRES_DUMMYNET 15 /* Dummynet */ -#define PFRES_MAX 16 /* total+1 */ - -#define PFRES_NAMES { \ - "match", \ - "bad-offset", \ - "fragment", \ - "short", \ - "normalize", \ - "memory", \ - "bad-timestamp", \ - "congestion", \ - "ip-option", \ - "proto-cksum", \ - "state-mismatch", \ - "state-insert", \ - "state-limit", \ - "src-limit", \ - "synproxy", \ - "dummynet", \ - NULL \ -} - -/* Counters for other things we want to keep track of */ -#define LCNT_STATES 0 /* states */ -#define LCNT_SRCSTATES 1 /* max-src-states */ -#define LCNT_SRCNODES 2 /* max-src-nodes */ -#define LCNT_SRCCONN 3 /* max-src-conn */ -#define LCNT_SRCCONNRATE 4 /* max-src-conn-rate */ -#define LCNT_OVERLOAD_TABLE 5 /* entry added to overload table */ -#define LCNT_OVERLOAD_FLUSH 6 /* state entries flushed */ -#define LCNT_MAX 7 /* total+1 */ - -#define LCNT_NAMES { \ - "max states per rule", \ - "max-src-states", \ - "max-src-nodes", \ - "max-src-conn", \ - "max-src-conn-rate", \ - "overload table insertion", \ - "overload flush states", \ - NULL \ -} - -/* UDP state enumeration */ -#define PFUDPS_NO_TRAFFIC 0 -#define PFUDPS_SINGLE 1 -#define PFUDPS_MULTIPLE 2 - -#define PFUDPS_NSTATES 3 /* number of state levels */ - -#define PFUDPS_NAMES { \ - "NO_TRAFFIC", \ - "SINGLE", \ - "MULTIPLE", \ - NULL \ -} - -/* GREv1 protocol state enumeration */ -#define PFGRE1S_NO_TRAFFIC 0 -#define PFGRE1S_INITIATING 1 -#define PFGRE1S_ESTABLISHED 2 - -#define PFGRE1S_NSTATES 3 /* number of state levels */ - -#define PFGRE1S_NAMES { \ - "NO_TRAFFIC", \ - "INITIATING", \ - "ESTABLISHED", \ - NULL \ -} - -#define PFESPS_NO_TRAFFIC 0 -#define PFESPS_INITIATING 1 -#define PFESPS_ESTABLISHED 2 - -#define PFESPS_NSTATES 3 /* number of state levels */ - -#define PFESPS_NAMES { "NO_TRAFFIC", "INITIATING", "ESTABLISHED", NULL } - -/* Other protocol state enumeration */ -#define PFOTHERS_NO_TRAFFIC 0 -#define PFOTHERS_SINGLE 1 -#define PFOTHERS_MULTIPLE 2 - -#define PFOTHERS_NSTATES 3 /* number of state levels */ - -#define PFOTHERS_NAMES { \ - "NO_TRAFFIC", \ - "SINGLE", \ - "MULTIPLE", \ - NULL \ -} - -#define FCNT_STATE_SEARCH 0 -#define FCNT_STATE_INSERT 1 -#define FCNT_STATE_REMOVALS 2 -#define FCNT_MAX 3 - -#define SCNT_SRC_NODE_SEARCH 0 -#define SCNT_SRC_NODE_INSERT 1 -#define SCNT_SRC_NODE_REMOVALS 2 -#define SCNT_MAX 3 - -#ifdef KERNEL -#define ACTION_SET(a, x) \ - do { \ - if ((a) != NULL) \ - *(a) = (x); \ - } while (0) - -#define REASON_SET(a, x) \ - do { \ - if ((a) != NULL) \ - *(a) = (x); \ - if (x < PFRES_MAX) \ - pf_status.counters[x]++; \ - } while (0) -#endif /* KERNEL */ - -struct pf_status { - u_int64_t counters[PFRES_MAX]; - u_int64_t lcounters[LCNT_MAX]; /* limit counters */ - u_int64_t fcounters[FCNT_MAX]; - u_int64_t scounters[SCNT_MAX]; - u_int64_t pcounters[2][2][3]; - u_int64_t bcounters[2][2]; - u_int64_t stateid; - u_int32_t running; - u_int32_t states; - u_int32_t src_nodes; - u_int64_t since __attribute__((aligned(8))); - u_int32_t debug; - u_int32_t hostid; - char ifname[IFNAMSIZ]; - u_int8_t pf_chksum[PF_MD5_DIGEST_LENGTH]; -}; - -struct cbq_opts { - u_int32_t minburst; - u_int32_t maxburst; - u_int32_t pktsize; - u_int32_t maxpktsize; - u_int32_t ns_per_byte; - u_int32_t maxidle; - int32_t minidle; - u_int32_t offtime; - u_int32_t flags; -}; - -struct priq_opts { - u_int32_t flags; -}; - -struct qfq_opts { - u_int32_t flags; - u_int32_t lmax; -}; - -struct hfsc_opts { - /* real-time service curve */ - u_int64_t rtsc_m1; /* slope of the 1st segment in bps */ - u_int64_t rtsc_d; /* the x-projection of m1 in msec */ - u_int64_t rtsc_m2; /* slope of the 2nd segment in bps */ - u_int32_t rtsc_fl; /* service curve flags */ -#if !defined(__LP64__) - u_int32_t _pad; -#endif /* !__LP64__ */ - /* link-sharing service curve */ - u_int64_t lssc_m1; - u_int64_t lssc_d; - u_int64_t lssc_m2; - u_int32_t lssc_fl; -#if !defined(__LP64__) - u_int32_t __pad; -#endif /* !__LP64__ */ - /* upper-limit service curve */ - u_int64_t ulsc_m1; - u_int64_t ulsc_d; - u_int64_t ulsc_m2; - u_int32_t ulsc_fl; - u_int32_t flags; /* scheduler flags */ -}; - -struct fairq_opts { - u_int32_t nbuckets; /* hash buckets */ - u_int32_t flags; - u_int64_t hogs_m1; /* hog detection bandwidth */ - - /* link-sharing service curve */ - u_int64_t lssc_m1; - u_int64_t lssc_d; - u_int64_t lssc_m2; -}; - -/* bandwidth types */ -#define PF_ALTQ_BW_ABSOLUTE 1 /* bw in absolute value (bps) */ -#define PF_ALTQ_BW_PERCENT 2 /* bandwidth in percentage */ - -/* ALTQ rule flags */ -#define PF_ALTQF_TBR 0x1 /* enable Token Bucket Regulator */ - -/* queue rule flags */ -#define PF_ALTQ_QRF_WEIGHT 0x1 /* weight instead of priority */ - -struct pf_altq { - char ifname[IFNAMSIZ]; - - /* discipline-specific state */ - void *altq_disc __attribute__((aligned(8))); - TAILQ_ENTRY(pf_altq) entries __attribute__((aligned(8))); -#if !defined(__LP64__) - u_int32_t _pad[2]; -#endif /* !__LP64__ */ - - u_int32_t aflags; /* ALTQ rule flags */ - u_int32_t bwtype; /* bandwidth type */ - - /* scheduler spec */ - u_int32_t scheduler; /* scheduler type */ - u_int32_t tbrsize; /* tokenbucket regulator size */ - u_int64_t ifbandwidth; /* interface bandwidth */ - - /* queue spec */ - char qname[PF_QNAME_SIZE]; /* queue name */ - char parent[PF_QNAME_SIZE]; /* parent name */ - u_int32_t parent_qid; /* parent queue id */ - u_int32_t qrflags; /* queue rule flags */ - union { - u_int32_t priority; /* priority */ - u_int32_t weight; /* weight */ - }; - u_int32_t qlimit; /* queue size limit */ - u_int32_t flags; /* misc flags */ -#if !defined(__LP64__) - u_int32_t __pad; -#endif /* !__LP64__ */ - u_int64_t bandwidth; /* queue bandwidth */ - union { - struct cbq_opts cbq_opts; - struct priq_opts priq_opts; - struct hfsc_opts hfsc_opts; - struct fairq_opts fairq_opts; - struct qfq_opts qfq_opts; - } pq_u; - - u_int32_t qid; /* return value */ -}; - -struct pf_tagname { - TAILQ_ENTRY(pf_tagname) entries; - char name[PF_TAG_NAME_SIZE]; - u_int16_t tag; - int ref; -}; - -#define PFFRAG_FRENT_HIWAT 5000 /* Number of fragment entries */ -#define PFFRAG_FRAG_HIWAT 1000 /* Number of fragmented packets */ -#define PFFRAG_FRCENT_HIWAT 50000 /* Number of fragment cache entries */ -#define PFFRAG_FRCACHE_HIWAT 10000 /* Number of fragment descriptors */ - -#define PFR_KTABLE_HIWAT 1000 /* Number of tables */ -#define PFR_KENTRY_HIWAT 200000 /* Number of table entries */ -#define PFR_KENTRY_HIWAT_SMALL 100000 /* Number of table entries (tiny hosts) */ - -/* - * ioctl parameter structures - */ - -struct pfioc_pooladdr { - u_int32_t action; - u_int32_t ticket; - u_int32_t nr; - u_int32_t r_num; - u_int8_t r_action; - u_int8_t r_last; - u_int8_t af; - char anchor[MAXPATHLEN]; - struct pf_pooladdr addr; -}; - -struct pfioc_rule { - u_int32_t action; - u_int32_t ticket; - u_int32_t pool_ticket; - u_int32_t nr; - char anchor[MAXPATHLEN]; - char anchor_call[MAXPATHLEN]; - struct pf_rule rule; -}; - -struct pfioc_natlook { - struct pf_addr saddr; - struct pf_addr daddr; - struct pf_addr rsaddr; - struct pf_addr rdaddr; - union pf_state_xport sxport; - union pf_state_xport dxport; - union pf_state_xport rsxport; - union pf_state_xport rdxport; - sa_family_t af; - u_int8_t proto; - u_int8_t proto_variant; - u_int8_t direction; -}; - -struct pfioc_state { - struct pfsync_state state; -}; - -struct pfioc_src_node_kill { - /* XXX returns the number of src nodes killed in psnk_af */ - sa_family_t psnk_af; - struct pf_rule_addr psnk_src; - struct pf_rule_addr psnk_dst; -}; - -struct pfioc_state_addr_kill { - struct pf_addr_wrap addr; - u_int8_t reserved_[3]; - u_int8_t neg; - union pf_rule_xport xport; -}; - -struct pfioc_state_kill { - /* XXX returns the number of states killed in psk_af */ - sa_family_t psk_af; - u_int8_t psk_proto; - u_int8_t psk_proto_variant; - u_int8_t _pad; - struct pfioc_state_addr_kill psk_src; - struct pfioc_state_addr_kill psk_dst; - char psk_ifname[IFNAMSIZ]; - char psk_ownername[PF_OWNER_NAME_SIZE]; -}; - -struct pfioc_states { - int ps_len; - union { - caddr_t psu_buf; - struct pfsync_state *psu_states; - } ps_u __attribute__((aligned(8))); -#define ps_buf ps_u.psu_buf -#define ps_states ps_u.psu_states -}; - -#ifdef KERNEL -struct pfioc_states_32 { - int ps_len; - union { - user32_addr_t psu_buf; - user32_addr_t psu_states; - } ps_u __attribute__((aligned(8))); -}; - -struct pfioc_states_64 { - int ps_len; - union { - user64_addr_t psu_buf; - user64_addr_t psu_states; - } ps_u __attribute__((aligned(8))); -}; -#endif /* KERNEL */ - -#define PFTOK_PROCNAME_LEN 64 -#pragma pack(1) -struct pfioc_token { - u_int64_t token_value; - u_int64_t timestamp; - pid_t pid; - char proc_name[PFTOK_PROCNAME_LEN]; -}; -#pragma pack() - -struct pfioc_kernel_token { - SLIST_ENTRY(pfioc_kernel_token) next; - struct pfioc_token token; -}; - -struct pfioc_remove_token { - u_int64_t token_value; - u_int64_t refcount; -}; - -struct pfioc_tokens { - int size; - union { - caddr_t pgtu_buf; - struct pfioc_token *pgtu_tokens; - } pgt_u __attribute__((aligned(8))); -#define pgt_buf pgt_u.pgtu_buf -#define pgt_tokens pgt_u.pgtu_tokens -}; - -#ifdef KERNEL -struct pfioc_tokens_32 { - int size; - union { - user32_addr_t pgtu_buf; - user32_addr_t pgtu_tokens; - } pgt_u __attribute__((aligned(8))); -}; - -struct pfioc_tokens_64 { - int size; - union { - user64_addr_t pgtu_buf; - user64_addr_t pgtu_tokens; - } pgt_u __attribute__((aligned(8))); -}; -#endif /* KERNEL */ - - -struct pfioc_src_nodes { - int psn_len; - union { - caddr_t psu_buf; - struct pf_src_node *psu_src_nodes; - } psn_u __attribute__((aligned(8))); -#define psn_buf psn_u.psu_buf -#define psn_src_nodes psn_u.psu_src_nodes -}; - -#ifdef KERNEL -struct pfioc_src_nodes_32 { - int psn_len; - union { - user32_addr_t psu_buf; - user32_addr_t psu_src_nodes; - } psn_u __attribute__((aligned(8))); -}; - -struct pfioc_src_nodes_64 { - int psn_len; - union { - user64_addr_t psu_buf; - user64_addr_t psu_src_nodes; - } psn_u __attribute__((aligned(8))); -}; -#endif /* KERNEL */ - -struct pfioc_if { - char ifname[IFNAMSIZ]; -}; - -struct pfioc_tm { - int timeout; - int seconds; -}; - -struct pfioc_limit { - int index; - unsigned limit; -}; - -struct pfioc_altq { - u_int32_t action; - u_int32_t ticket; - u_int32_t nr; - struct pf_altq altq __attribute__((aligned(8))); -}; - -struct pfioc_qstats { - u_int32_t ticket; - u_int32_t nr; - void *buf __attribute__((aligned(8))); - int nbytes __attribute__((aligned(8))); - u_int8_t scheduler; -}; - -struct pfioc_ruleset { - u_int32_t nr; - char path[MAXPATHLEN]; - char name[PF_ANCHOR_NAME_SIZE]; -}; - -#define PF_RULESET_ALTQ (PF_RULESET_MAX) -#define PF_RULESET_TABLE (PF_RULESET_MAX+1) -struct pfioc_trans { - int size; /* number of elements */ - int esize; /* size of each element in bytes */ - struct pfioc_trans_e { - int rs_num; - char anchor[MAXPATHLEN]; - u_int32_t ticket; - } *array __attribute__((aligned(8))); -}; - -#ifdef KERNEL -struct pfioc_trans_32 { - int size; /* number of elements */ - int esize; /* size of each element in bytes */ - user32_addr_t array __attribute__((aligned(8))); -}; - -struct pfioc_trans_64 { - int size; /* number of elements */ - int esize; /* size of each element in bytes */ - user64_addr_t array __attribute__((aligned(8))); -}; -#endif /* KERNEL */ - - -#define PFR_FLAG_ATOMIC 0x00000001 -#define PFR_FLAG_DUMMY 0x00000002 -#define PFR_FLAG_FEEDBACK 0x00000004 -#define PFR_FLAG_CLSTATS 0x00000008 -#define PFR_FLAG_ADDRSTOO 0x00000010 -#define PFR_FLAG_REPLACE 0x00000020 -#define PFR_FLAG_ALLRSETS 0x00000040 -#define PFR_FLAG_ALLMASK 0x0000007F -#ifdef KERNEL -#define PFR_FLAG_USERIOCTL 0x10000000 -#endif /* KERNEL */ - -struct pfioc_table { - struct pfr_table pfrio_table; - void *pfrio_buffer __attribute__((aligned(8))); - int pfrio_esize __attribute__((aligned(8))); - int pfrio_size; - int pfrio_size2; - int pfrio_nadd; - int pfrio_ndel; - int pfrio_nchange; - int pfrio_flags; - u_int32_t pfrio_ticket; -}; -#define pfrio_exists pfrio_nadd -#define pfrio_nzero pfrio_nadd -#define pfrio_nmatch pfrio_nadd -#define pfrio_naddr pfrio_size2 -#define pfrio_setflag pfrio_size2 -#define pfrio_clrflag pfrio_nadd - -#ifdef KERNEL -struct pfioc_table_32 { - struct pfr_table pfrio_table; - user32_addr_t pfrio_buffer __attribute__((aligned(8))); - int pfrio_esize __attribute__((aligned(8))); - int pfrio_size; - int pfrio_size2; - int pfrio_nadd; - int pfrio_ndel; - int pfrio_nchange; - int pfrio_flags; - u_int32_t pfrio_ticket; -}; - -struct pfioc_table_64 { - struct pfr_table pfrio_table; - user64_addr_t pfrio_buffer __attribute__((aligned(8))); - int pfrio_esize __attribute__((aligned(8))); - int pfrio_size; - int pfrio_size2; - int pfrio_nadd; - int pfrio_ndel; - int pfrio_nchange; - int pfrio_flags; - u_int32_t pfrio_ticket; -}; -#endif /* KERNEL */ - -struct pfioc_iface { - char pfiio_name[IFNAMSIZ]; - void *pfiio_buffer __attribute__((aligned(8))); - int pfiio_esize __attribute__((aligned(8))); - int pfiio_size; - int pfiio_nzero; - int pfiio_flags; -}; - -#ifdef KERNEL -struct pfioc_iface_32 { - char pfiio_name[IFNAMSIZ]; - user32_addr_t pfiio_buffer __attribute__((aligned(8))); - int pfiio_esize __attribute__((aligned(8))); - int pfiio_size; - int pfiio_nzero; - int pfiio_flags; -}; - -struct pfioc_iface_64 { - char pfiio_name[IFNAMSIZ]; - user64_addr_t pfiio_buffer __attribute__((aligned(8))); - int pfiio_esize __attribute__((aligned(8))); - int pfiio_size; - int pfiio_nzero; - int pfiio_flags; -}; -#endif /* KERNEL */ - -struct pf_ifspeed { - char ifname[IFNAMSIZ]; - u_int64_t baudrate; -}; - -/* - * ioctl operations - */ - -#define DIOCSTART _IO ('D', 1) -#define DIOCSTOP _IO ('D', 2) -#define DIOCADDRULE _IOWR('D', 4, struct pfioc_rule) -#define DIOCGETSTARTERS _IOWR('D', 5, struct pfioc_tokens) -#define DIOCGETRULES _IOWR('D', 6, struct pfioc_rule) -#define DIOCGETRULE _IOWR('D', 7, struct pfioc_rule) -#define DIOCSTARTREF _IOR ('D', 8, u_int64_t) -#define DIOCSTOPREF _IOWR('D', 9, struct pfioc_remove_token) -/* XXX cut 10 - 17 */ -#define DIOCCLRSTATES _IOWR('D', 18, struct pfioc_state_kill) -#define DIOCGETSTATE _IOWR('D', 19, struct pfioc_state) -#define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if) -#define DIOCGETSTATUS _IOWR('D', 21, struct pf_status) -#define DIOCCLRSTATUS _IO ('D', 22) -#define DIOCNATLOOK _IOWR('D', 23, struct pfioc_natlook) -#define DIOCSETDEBUG _IOWR('D', 24, u_int32_t) -#define DIOCGETSTATES _IOWR('D', 25, struct pfioc_states) -#define DIOCCHANGERULE _IOWR('D', 26, struct pfioc_rule) -#define DIOCINSERTRULE _IOWR('D', 27, struct pfioc_rule) -#define DIOCDELETERULE _IOWR('D', 28, struct pfioc_rule) -#define DIOCSETTIMEOUT _IOWR('D', 29, struct pfioc_tm) -#define DIOCGETTIMEOUT _IOWR('D', 30, struct pfioc_tm) -#define DIOCADDSTATE _IOWR('D', 37, struct pfioc_state) -#define DIOCCLRRULECTRS _IO ('D', 38) -#define DIOCGETLIMIT _IOWR('D', 39, struct pfioc_limit) -#define DIOCSETLIMIT _IOWR('D', 40, struct pfioc_limit) -#define DIOCKILLSTATES _IOWR('D', 41, struct pfioc_state_kill) -#define DIOCSTARTALTQ _IO ('D', 42) -#define DIOCSTOPALTQ _IO ('D', 43) -#define DIOCADDALTQ _IOWR('D', 45, struct pfioc_altq) -#define DIOCGETALTQS _IOWR('D', 47, struct pfioc_altq) -#define DIOCGETALTQ _IOWR('D', 48, struct pfioc_altq) -#define DIOCCHANGEALTQ _IOWR('D', 49, struct pfioc_altq) -#define DIOCGETQSTATS _IOWR('D', 50, struct pfioc_qstats) -#define DIOCBEGINADDRS _IOWR('D', 51, struct pfioc_pooladdr) -#define DIOCADDADDR _IOWR('D', 52, struct pfioc_pooladdr) -#define DIOCGETADDRS _IOWR('D', 53, struct pfioc_pooladdr) -#define DIOCGETADDR _IOWR('D', 54, struct pfioc_pooladdr) -#define DIOCCHANGEADDR _IOWR('D', 55, struct pfioc_pooladdr) -/* XXX cut 55 - 57 */ -#define DIOCGETRULESETS _IOWR('D', 58, struct pfioc_ruleset) -#define DIOCGETRULESET _IOWR('D', 59, struct pfioc_ruleset) -#define DIOCRCLRTABLES _IOWR('D', 60, struct pfioc_table) -#define DIOCRADDTABLES _IOWR('D', 61, struct pfioc_table) -#define DIOCRDELTABLES _IOWR('D', 62, struct pfioc_table) -#define DIOCRGETTABLES _IOWR('D', 63, struct pfioc_table) -#define DIOCRGETTSTATS _IOWR('D', 64, struct pfioc_table) -#define DIOCRCLRTSTATS _IOWR('D', 65, struct pfioc_table) -#define DIOCRCLRADDRS _IOWR('D', 66, struct pfioc_table) -#define DIOCRADDADDRS _IOWR('D', 67, struct pfioc_table) -#define DIOCRDELADDRS _IOWR('D', 68, struct pfioc_table) -#define DIOCRSETADDRS _IOWR('D', 69, struct pfioc_table) -#define DIOCRGETADDRS _IOWR('D', 70, struct pfioc_table) -#define DIOCRGETASTATS _IOWR('D', 71, struct pfioc_table) -#define DIOCRCLRASTATS _IOWR('D', 72, struct pfioc_table) -#define DIOCRTSTADDRS _IOWR('D', 73, struct pfioc_table) -#define DIOCRSETTFLAGS _IOWR('D', 74, struct pfioc_table) -#define DIOCRINADEFINE _IOWR('D', 77, struct pfioc_table) -#define DIOCOSFPFLUSH _IO('D', 78) -#define DIOCOSFPADD _IOWR('D', 79, struct pf_osfp_ioctl) -#define DIOCOSFPGET _IOWR('D', 80, struct pf_osfp_ioctl) -#define DIOCXBEGIN _IOWR('D', 81, struct pfioc_trans) -#define DIOCXCOMMIT _IOWR('D', 82, struct pfioc_trans) -#define DIOCXROLLBACK _IOWR('D', 83, struct pfioc_trans) -#define DIOCGETSRCNODES _IOWR('D', 84, struct pfioc_src_nodes) -#define DIOCCLRSRCNODES _IO('D', 85) -#define DIOCSETHOSTID _IOWR('D', 86, u_int32_t) -#define DIOCIGETIFACES _IOWR('D', 87, struct pfioc_iface) -#define DIOCSETIFFLAG _IOWR('D', 89, struct pfioc_iface) -#define DIOCCLRIFFLAG _IOWR('D', 90, struct pfioc_iface) -#define DIOCKILLSRCNODES _IOWR('D', 91, struct pfioc_src_node_kill) -#define DIOCGIFSPEED _IOWR('D', 92, struct pf_ifspeed) - -#ifdef KERNEL -RB_HEAD(pf_src_tree, pf_src_node); -RB_PROTOTYPE_SC(__private_extern__, pf_src_tree, pf_src_node, entry, - pf_src_compare); -extern struct pf_src_tree tree_src_tracking; - -RB_HEAD(pf_state_tree_id, pf_state); -RB_PROTOTYPE_SC(__private_extern__, pf_state_tree_id, pf_state, - entry_id, pf_state_compare_id); -extern struct pf_state_tree_id tree_id; -extern struct pf_state_queue state_list; - -TAILQ_HEAD(pf_poolqueue, pf_pool); -extern struct pf_poolqueue pf_pools[2]; -extern struct pf_palist pf_pabuf; -extern u_int32_t ticket_pabuf; -#if PF_ALTQ -TAILQ_HEAD(pf_altqqueue, pf_altq); -extern struct pf_altqqueue pf_altqs[2]; -extern u_int32_t ticket_altqs_active; -extern u_int32_t ticket_altqs_inactive; -extern int altqs_inactive_open; -extern struct pf_altqqueue *pf_altqs_active; -extern struct pf_altqqueue *pf_altqs_inactive; -#endif /* PF_ALTQ */ -extern struct pf_poolqueue *pf_pools_active; -extern struct pf_poolqueue *pf_pools_inactive; - -__private_extern__ int pf_tbladdr_setup(struct pf_ruleset *, - struct pf_addr_wrap *); -__private_extern__ void pf_tbladdr_remove(struct pf_addr_wrap *); -__private_extern__ void pf_tbladdr_copyout(struct pf_addr_wrap *); -__private_extern__ void pf_calc_skip_steps(struct pf_rulequeue *); -__private_extern__ u_int32_t pf_calc_state_key_flowhash(struct pf_state_key *); - -extern struct pool pf_src_tree_pl, pf_rule_pl; -extern struct pool pf_state_pl, pf_state_key_pl, pf_pooladdr_pl; -extern struct pool pf_state_scrub_pl; -#if PF_ALTQ -extern struct pool pf_altq_pl; -#endif /* PF_ALTQ */ -extern struct pool pf_app_state_pl; - -extern struct thread *pf_purge_thread; - -__private_extern__ void pfinit(void); -__private_extern__ void pf_purge_thread_fn(void *, wait_result_t); -__private_extern__ void pf_purge_expired_src_nodes(void); -__private_extern__ void pf_purge_expired_states(u_int32_t); -__private_extern__ void pf_unlink_state(struct pf_state *); -__private_extern__ void pf_free_state(struct pf_state *); -__private_extern__ int pf_insert_state(struct pfi_kif *, struct pf_state *); -__private_extern__ int pf_insert_src_node(struct pf_src_node **, - struct pf_rule *, struct pf_addr *, sa_family_t); -__private_extern__ void pf_src_tree_remove_state(struct pf_state *); -__private_extern__ struct pf_state *pf_find_state_byid(struct pf_state_cmp *); -__private_extern__ struct pf_state *pf_find_state_all(struct pf_state_key_cmp *, - u_int, int *); -__private_extern__ void pf_print_state(struct pf_state *); -__private_extern__ void pf_print_flags(u_int8_t); -__private_extern__ u_int16_t pf_cksum_fixup(u_int16_t, u_int16_t, u_int16_t, - u_int8_t); - -extern struct ifnet *sync_ifp; -extern struct pf_rule pf_default_rule; -__private_extern__ void pf_addrcpy(struct pf_addr *, struct pf_addr *, - u_int8_t); -__private_extern__ void pf_rm_rule(struct pf_rulequeue *, struct pf_rule *); - -struct ip_fw_args; -#if INET -__private_extern__ int pf_test(int, struct ifnet *, struct mbuf **, - struct ether_header *, struct ip_fw_args *); -#endif /* INET */ - -#if INET6 -__private_extern__ int pf_test6(int, struct ifnet *, struct mbuf **, - struct ether_header *, struct ip_fw_args *); -__private_extern__ void pf_poolmask(struct pf_addr *, struct pf_addr *, - struct pf_addr *, struct pf_addr *, u_int8_t); -__private_extern__ void pf_addr_inc(struct pf_addr *, sa_family_t); -#endif /* INET6 */ - -__private_extern__ struct mbuf *pf_lazy_makewritable(struct pf_pdesc *, - struct mbuf *, int); -__private_extern__ void *pf_pull_hdr(struct mbuf *, int, void *, int, - u_short *, u_short *, sa_family_t); -__private_extern__ void pf_change_a(void *, u_int16_t *, u_int32_t, u_int8_t); -__private_extern__ int pflog_packet(struct pfi_kif *, struct mbuf *, - sa_family_t, u_int8_t, u_int8_t, struct pf_rule *, struct pf_rule *, - struct pf_ruleset *, struct pf_pdesc *); -__private_extern__ int pf_match_addr(u_int8_t, struct pf_addr *, - struct pf_addr *, struct pf_addr *, sa_family_t); -__private_extern__ int pf_match_addr_range(struct pf_addr *, struct pf_addr *, - struct pf_addr *, sa_family_t); -__private_extern__ int pf_match(u_int8_t, u_int32_t, u_int32_t, u_int32_t); -__private_extern__ int pf_match_port(u_int8_t, u_int16_t, u_int16_t, u_int16_t); -__private_extern__ int pf_match_xport(u_int8_t, u_int8_t, union pf_rule_xport *, - union pf_state_xport *); -__private_extern__ int pf_match_uid(u_int8_t, uid_t, uid_t, uid_t); -__private_extern__ int pf_match_gid(u_int8_t, gid_t, gid_t, gid_t); - -__private_extern__ void pf_normalize_init(void); -__private_extern__ int pf_normalize_isempty(void); -__private_extern__ int pf_normalize_ip(struct mbuf **, int, struct pfi_kif *, - u_short *, struct pf_pdesc *); -__private_extern__ int pf_normalize_ip6(struct mbuf **, int, struct pfi_kif *, - u_short *, struct pf_pdesc *); -__private_extern__ int pf_normalize_tcp(int, struct pfi_kif *, struct mbuf *, - int, int, void *, struct pf_pdesc *); -__private_extern__ void pf_normalize_tcp_cleanup(struct pf_state *); -__private_extern__ int pf_normalize_tcp_init(struct mbuf *, int, - struct pf_pdesc *, struct tcphdr *, struct pf_state_peer *, - struct pf_state_peer *); -__private_extern__ int pf_normalize_tcp_stateful(struct mbuf *, int, - struct pf_pdesc *, u_short *, struct tcphdr *, struct pf_state *, - struct pf_state_peer *, struct pf_state_peer *, int *); -__private_extern__ u_int64_t pf_state_expires(const struct pf_state *); -__private_extern__ void pf_purge_expired_fragments(void); -__private_extern__ int pf_routable(struct pf_addr *addr, sa_family_t af, - struct pfi_kif *); -__private_extern__ int pf_rtlabel_match(struct pf_addr *, sa_family_t, - struct pf_addr_wrap *); -__private_extern__ int pf_socket_lookup(int, struct pf_pdesc *); -__private_extern__ struct pf_state_key *pf_alloc_state_key(struct pf_state *, - struct pf_state_key *); -__private_extern__ void pfr_initialize(void); -__private_extern__ int pfr_match_addr(struct pfr_ktable *, struct pf_addr *, - sa_family_t); -__private_extern__ void pfr_update_stats(struct pfr_ktable *, struct pf_addr *, - sa_family_t, u_int64_t, int, int, int); -__private_extern__ int pfr_pool_get(struct pfr_ktable *, int *, - struct pf_addr *, struct pf_addr **, struct pf_addr **, sa_family_t); -__private_extern__ void pfr_dynaddr_update(struct pfr_ktable *, - struct pfi_dynaddr *); -__private_extern__ void pfr_table_copyin_cleanup(struct pfr_table *); -__private_extern__ struct pfr_ktable *pfr_attach_table(struct pf_ruleset *, - char *); -__private_extern__ void pfr_detach_table(struct pfr_ktable *); -__private_extern__ int pfr_clr_tables(struct pfr_table *, int *, int); -__private_extern__ int pfr_add_tables(user_addr_t, int, int *, int); -__private_extern__ int pfr_del_tables(user_addr_t, int, int *, int); -__private_extern__ int pfr_get_tables(struct pfr_table *, user_addr_t, - int *, int); -__private_extern__ int pfr_get_tstats(struct pfr_table *, user_addr_t, - int *, int); -__private_extern__ int pfr_clr_tstats(user_addr_t, int, int *, int); -__private_extern__ int pfr_set_tflags(user_addr_t, int, int, int, int *, - int *, int); -__private_extern__ int pfr_clr_addrs(struct pfr_table *, int *, int); -__private_extern__ int pfr_insert_kentry(struct pfr_ktable *, struct pfr_addr *, - u_int64_t); -__private_extern__ int pfr_add_addrs(struct pfr_table *, user_addr_t, - int, int *, int); -__private_extern__ int pfr_del_addrs(struct pfr_table *, user_addr_t, - int, int *, int); -__private_extern__ int pfr_set_addrs(struct pfr_table *, user_addr_t, - int, int *, int *, int *, int *, int, u_int32_t); -__private_extern__ int pfr_get_addrs(struct pfr_table *, user_addr_t, - int *, int); -__private_extern__ int pfr_get_astats(struct pfr_table *, user_addr_t, - int *, int); -__private_extern__ int pfr_clr_astats(struct pfr_table *, user_addr_t, - int, int *, int); -__private_extern__ int pfr_tst_addrs(struct pfr_table *, user_addr_t, - int, int *, int); -__private_extern__ int pfr_ina_begin(struct pfr_table *, u_int32_t *, int *, - int); -__private_extern__ int pfr_ina_rollback(struct pfr_table *, u_int32_t, int *, - int); -__private_extern__ int pfr_ina_commit(struct pfr_table *, u_int32_t, int *, - int *, int); -__private_extern__ int pfr_ina_define(struct pfr_table *, user_addr_t, - int, int *, int *, u_int32_t, int); - -extern struct pfi_kif *pfi_all; - -__private_extern__ void pfi_initialize(void); -__private_extern__ struct pfi_kif *pfi_kif_get(const char *); -__private_extern__ void pfi_kif_ref(struct pfi_kif *, enum pfi_kif_refs); -__private_extern__ void pfi_kif_unref(struct pfi_kif *, enum pfi_kif_refs); -__private_extern__ int pfi_kif_match(struct pfi_kif *, struct pfi_kif *); -__private_extern__ void pfi_attach_ifnet(struct ifnet *); -__private_extern__ void pfi_detach_ifnet(struct ifnet *); -__private_extern__ int pfi_match_addr(struct pfi_dynaddr *, struct pf_addr *, - sa_family_t); -__private_extern__ int pfi_dynaddr_setup(struct pf_addr_wrap *, sa_family_t); -__private_extern__ void pfi_dynaddr_remove(struct pf_addr_wrap *); -__private_extern__ void pfi_dynaddr_copyout(struct pf_addr_wrap *); -__private_extern__ void pfi_update_status(const char *, struct pf_status *); -__private_extern__ int pfi_get_ifaces(const char *, user_addr_t, int *); -__private_extern__ int pfi_set_flags(const char *, int); -__private_extern__ int pfi_clear_flags(const char *, int); - -__private_extern__ u_int16_t pf_tagname2tag(char *); -__private_extern__ void pf_tag2tagname(u_int16_t, char *); -__private_extern__ void pf_tag_ref(u_int16_t); -__private_extern__ void pf_tag_unref(u_int16_t); -__private_extern__ int pf_tag_packet(struct mbuf *, struct pf_mtag *, - int, unsigned int, struct pf_pdesc *); -__private_extern__ void pf_step_into_anchor(int *, struct pf_ruleset **, int, - struct pf_rule **, struct pf_rule **, int *); -__private_extern__ int pf_step_out_of_anchor(int *, struct pf_ruleset **, int, - struct pf_rule **, struct pf_rule **, int *); -__private_extern__ u_int32_t pf_qname2qid(char *); -__private_extern__ void pf_qid2qname(u_int32_t, char *); -__private_extern__ void pf_qid_unref(u_int32_t); - -extern struct pf_status pf_status; -extern struct pool pf_frent_pl, pf_frag_pl; - -struct pf_pool_limit { - void *pp; - unsigned limit; -}; -extern struct pf_pool_limit pf_pool_limits[PF_LIMIT_MAX]; - -__private_extern__ int pf_af_hook(struct ifnet *, struct mbuf **, - struct mbuf **, unsigned int, int, struct ip_fw_args *); -__private_extern__ int pf_ifaddr_hook(struct ifnet *); -__private_extern__ void pf_ifnet_hook(struct ifnet *, int); - -/* - * The following are defined with "private extern" storage class for - * kernel, and "extern" for user-space. - */ -extern struct pf_anchor_global pf_anchors; -extern struct pf_anchor pf_main_anchor; -#define pf_main_ruleset pf_main_anchor.ruleset - -extern int pf_is_enabled; -extern int16_t pf_nat64_configured; -#define PF_IS_ENABLED (pf_is_enabled != 0) -extern u_int32_t pf_hash_seed; - -#if PF_ALTQ -extern u_int32_t altq_allowed; -#endif /* PF_ALTQ */ - -/* these ruleset functions can be linked into userland programs (pfctl) */ -__private_extern__ int pf_get_ruleset_number(u_int8_t); -__private_extern__ void pf_init_ruleset(struct pf_ruleset *); -__private_extern__ int pf_anchor_setup(struct pf_rule *, - const struct pf_ruleset *, const char *); -__private_extern__ int pf_anchor_copyout(const struct pf_ruleset *, - const struct pf_rule *, struct pfioc_rule *); -__private_extern__ void pf_anchor_remove(struct pf_rule *); -__private_extern__ void pf_remove_if_empty_ruleset(struct pf_ruleset *); -__private_extern__ struct pf_anchor *pf_find_anchor(const char *); -__private_extern__ struct pf_ruleset *pf_find_ruleset(const char *); -__private_extern__ struct pf_ruleset *pf_find_ruleset_with_owner(const char *, - const char *, int, int *); -__private_extern__ struct pf_ruleset *pf_find_or_create_ruleset(const char *); -__private_extern__ void pf_rs_initialize(void); - -__private_extern__ int pf_osfp_add(struct pf_osfp_ioctl *); -__private_extern__ struct pf_osfp_enlist *pf_osfp_fingerprint(struct pf_pdesc *, - struct mbuf *, int, const struct tcphdr *); -__private_extern__ struct pf_osfp_enlist *pf_osfp_fingerprint_hdr( - const struct ip *, const struct ip6_hdr *, const struct tcphdr *); -__private_extern__ void pf_osfp_flush(void); -__private_extern__ int pf_osfp_get(struct pf_osfp_ioctl *); -__private_extern__ void pf_osfp_initialize(void); -__private_extern__ int pf_osfp_match(struct pf_osfp_enlist *, pf_osfp_t); -__private_extern__ struct pf_os_fingerprint *pf_osfp_validate(void); -__private_extern__ struct pf_mtag *pf_find_mtag(struct mbuf *); -__private_extern__ struct pf_mtag *pf_get_mtag(struct mbuf *); -#else /* !KERNEL */ -extern struct pf_anchor_global pf_anchors; -extern struct pf_anchor pf_main_anchor; -#define pf_main_ruleset pf_main_anchor.ruleset - -/* these ruleset functions can be linked into userland programs (pfctl) */ -extern int pf_get_ruleset_number(u_int8_t); -extern void pf_init_ruleset(struct pf_ruleset *); -extern int pf_anchor_setup(struct pf_rule *, const struct pf_ruleset *, - const char *); -extern int pf_anchor_copyout(const struct pf_ruleset *, const struct pf_rule *, - struct pfioc_rule *); -extern void pf_anchor_remove(struct pf_rule *); -extern void pf_remove_if_empty_ruleset(struct pf_ruleset *); -extern struct pf_anchor *pf_find_anchor(const char *); -extern struct pf_ruleset *pf_find_ruleset(const char *); -extern struct pf_ruleset *pf_find_ruleset_with_owner(const char *, - const char *, int, int *); -extern struct pf_ruleset *pf_find_or_create_ruleset(const char *); -extern void pf_rs_initialize(void); -#endif /* !KERNEL */ - -#ifdef __cplusplus -} -#endif -#endif /* PF || !KERNEL */ -#endif /* PRIVATE */ -#endif /* _NET_PFVAR_H_ */ From 77438e48b9701ddfb7ac5a0e65b5257087a46609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 28 May 2024 15:09:40 +0200 Subject: [PATCH 5/7] Use Rust style enums by default --- generate_bindings.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/generate_bindings.sh b/generate_bindings.sh index 8aa04aa..029e6d3 100755 --- a/generate_bindings.sh +++ b/generate_bindings.sh @@ -21,6 +21,7 @@ bindgen \ --allowlist-type pfioc_state_kill \ --allowlist-var PF_.* \ --allowlist-var PFRULE_.* \ + --default-enum-style rust \ -o ./src/ffi/pfvar.rs "$pfvar_h_path" -- \ -DPRIVATE \ -I"$SDK_PATH/usr/include" \ From 74b094754985d3d7f37aba305d7897b2405b17f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 28 May 2024 15:11:16 +0200 Subject: [PATCH 6/7] Generate bindings for newer pfvar.h with newer bindgen bindgen: 0.69.4 pfvar.h: https://raw.githubusercontent.com/apple-oss-distributions/xnu/1031c584a5e37aff177559b9f69dbd3c8c3fd30a/bsd/net/pfvar.h --- src/ffi/pfvar.rs | 1105 ++++++++++++++++++++++++++-------------------- 1 file changed, 624 insertions(+), 481 deletions(-) diff --git a/src/ffi/pfvar.rs b/src/ffi/pfvar.rs index ce66d38..f7737bc 100644 --- a/src/ffi/pfvar.rs +++ b/src/ffi/pfvar.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen */ +/* automatically generated by rust-bindgen 0.69.4 */ pub const PF_UNSPEC: u32 = 0; pub const PF_LOCAL: u32 = 1; @@ -38,7 +38,8 @@ pub const PF_NETBIOS: u32 = 33; pub const PF_PPP: u32 = 34; pub const PF_RESERVED_36: u32 = 36; pub const PF_UTUN: u32 = 38; -pub const PF_MAX: u32 = 40; +pub const PF_VSOCK: u32 = 40; +pub const PF_MAX: u32 = 41; pub const PF_MD5_DIGEST_LENGTH: u32 = 16; pub const PF_GRE_PPTP_VARIANT: u32 = 1; pub const PF_POOL_IDMASK: u32 = 15; @@ -113,9 +114,11 @@ pub const PFRULE_DSCP: u32 = 16384; pub const PFRULE_SC: u32 = 32768; pub const PFRULE_IFBOUND: u32 = 65536; pub const PFRULE_PFM: u32 = 131072; +pub const PF_TAG_NAME_SYSTEM_SERVICE: &[u8; 32] = b"com.apple.pf.system_service_tag\0"; +pub const PF_TAG_NAME_STACK_DROP: &[u8; 28] = b"com.apple.pf.stack_drop_tag\0"; pub const PF_THRESHOLD_MULT: u32 = 1000; pub const PF_THRESHOLD_MAX: u32 = 4294967; -pub const PF_RESERVED_ANCHOR: &'static [u8; 4usize] = b"_pf\0"; +pub const PF_RESERVED_ANCHOR: &[u8; 4] = b"_pf\0"; pub const PF_DPORT_RANGE: u32 = 1; pub const PF_RPORT_RANGE: u32 = 2; pub const PF_ALTQ_BW_ABSOLUTE: u32 = 1; @@ -144,6 +147,8 @@ pub struct in_addr { } #[test] fn bindgen_test_layout_in_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 4usize, @@ -155,7 +160,7 @@ fn bindgen_test_layout_in_addr() { concat!("Alignment of ", stringify!(in_addr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).s_addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).s_addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -176,10 +181,12 @@ pub union in6_addr__bindgen_ty_1 { pub __u6_addr8: [__uint8_t; 16usize], pub __u6_addr16: [__uint16_t; 8usize], pub __u6_addr32: [__uint32_t; 4usize], - _bindgen_union_align: [u32; 4usize], } #[test] fn bindgen_test_layout_in6_addr__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -191,9 +198,7 @@ fn bindgen_test_layout_in6_addr__bindgen_ty_1() { concat!("Alignment of ", stringify!(in6_addr__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).__u6_addr8 as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).__u6_addr8) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -203,9 +208,7 @@ fn bindgen_test_layout_in6_addr__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).__u6_addr16 as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).__u6_addr16) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -215,9 +218,7 @@ fn bindgen_test_layout_in6_addr__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).__u6_addr32 as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).__u6_addr32) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -229,6 +230,8 @@ fn bindgen_test_layout_in6_addr__bindgen_ty_1() { } #[test] fn bindgen_test_layout_in6_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -240,7 +243,7 @@ fn bindgen_test_layout_in6_addr() { concat!("Alignment of ", stringify!(in6_addr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).__u6_addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).__u6_addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -250,89 +253,194 @@ fn bindgen_test_layout_in6_addr() { ) ); } -pub const PF_INOUT: _bindgen_ty_5 = 0; -pub const PF_IN: _bindgen_ty_5 = 1; -pub const PF_OUT: _bindgen_ty_5 = 2; -pub type _bindgen_ty_5 = u32; -pub const PF_PASS: _bindgen_ty_6 = 0; -pub const PF_DROP: _bindgen_ty_6 = 1; -pub const PF_SCRUB: _bindgen_ty_6 = 2; -pub const PF_NOSCRUB: _bindgen_ty_6 = 3; -pub const PF_NAT: _bindgen_ty_6 = 4; -pub const PF_NONAT: _bindgen_ty_6 = 5; -pub const PF_BINAT: _bindgen_ty_6 = 6; -pub const PF_NOBINAT: _bindgen_ty_6 = 7; -pub const PF_RDR: _bindgen_ty_6 = 8; -pub const PF_NORDR: _bindgen_ty_6 = 9; -pub const PF_SYNPROXY_DROP: _bindgen_ty_6 = 10; -pub const PF_DUMMYNET: _bindgen_ty_6 = 11; -pub const PF_NODUMMYNET: _bindgen_ty_6 = 12; -pub const PF_NAT64: _bindgen_ty_6 = 13; -pub const PF_NONAT64: _bindgen_ty_6 = 14; -pub type _bindgen_ty_6 = u32; -pub const PF_RULESET_SCRUB: _bindgen_ty_7 = 0; -pub const PF_RULESET_FILTER: _bindgen_ty_7 = 1; -pub const PF_RULESET_NAT: _bindgen_ty_7 = 2; -pub const PF_RULESET_BINAT: _bindgen_ty_7 = 3; -pub const PF_RULESET_RDR: _bindgen_ty_7 = 4; -pub const PF_RULESET_DUMMYNET: _bindgen_ty_7 = 5; -pub const PF_RULESET_MAX: _bindgen_ty_7 = 6; -pub type _bindgen_ty_7 = u32; -pub const PF_OP_NONE: _bindgen_ty_8 = 0; -pub const PF_OP_IRG: _bindgen_ty_8 = 1; -pub const PF_OP_EQ: _bindgen_ty_8 = 2; -pub const PF_OP_NE: _bindgen_ty_8 = 3; -pub const PF_OP_LT: _bindgen_ty_8 = 4; -pub const PF_OP_LE: _bindgen_ty_8 = 5; -pub const PF_OP_GT: _bindgen_ty_8 = 6; -pub const PF_OP_GE: _bindgen_ty_8 = 7; -pub const PF_OP_XRG: _bindgen_ty_8 = 8; -pub const PF_OP_RRG: _bindgen_ty_8 = 9; -pub type _bindgen_ty_8 = u32; -pub const PF_DEBUG_NONE: _bindgen_ty_9 = 0; -pub const PF_DEBUG_URGENT: _bindgen_ty_9 = 1; -pub const PF_DEBUG_MISC: _bindgen_ty_9 = 2; -pub const PF_DEBUG_NOISY: _bindgen_ty_9 = 3; -pub type _bindgen_ty_9 = u32; -pub const PF_CHANGE_NONE: _bindgen_ty_10 = 0; -pub const PF_CHANGE_ADD_HEAD: _bindgen_ty_10 = 1; -pub const PF_CHANGE_ADD_TAIL: _bindgen_ty_10 = 2; -pub const PF_CHANGE_ADD_BEFORE: _bindgen_ty_10 = 3; -pub const PF_CHANGE_ADD_AFTER: _bindgen_ty_10 = 4; -pub const PF_CHANGE_REMOVE: _bindgen_ty_10 = 5; -pub const PF_CHANGE_GET_TICKET: _bindgen_ty_10 = 6; -pub type _bindgen_ty_10 = u32; -pub const PF_GET_NONE: _bindgen_ty_11 = 0; -pub const PF_GET_CLR_CNTR: _bindgen_ty_11 = 1; -pub type _bindgen_ty_11 = u32; -pub const PF_NOPFROUTE: _bindgen_ty_13 = 0; -pub const PF_FASTROUTE: _bindgen_ty_13 = 1; -pub const PF_ROUTETO: _bindgen_ty_13 = 2; -pub const PF_DUPTO: _bindgen_ty_13 = 3; -pub const PF_REPLYTO: _bindgen_ty_13 = 4; -pub type _bindgen_ty_13 = u32; -pub const PF_LIMIT_STATES: _bindgen_ty_14 = 0; -pub const PF_LIMIT_APP_STATES: _bindgen_ty_14 = 1; -pub const PF_LIMIT_SRC_NODES: _bindgen_ty_14 = 2; -pub const PF_LIMIT_FRAGS: _bindgen_ty_14 = 3; -pub const PF_LIMIT_TABLES: _bindgen_ty_14 = 4; -pub const PF_LIMIT_TABLE_ENTRIES: _bindgen_ty_14 = 5; -pub const PF_LIMIT_MAX: _bindgen_ty_14 = 6; -pub type _bindgen_ty_14 = u32; -pub const PF_POOL_NONE: _bindgen_ty_15 = 0; -pub const PF_POOL_BITMASK: _bindgen_ty_15 = 1; -pub const PF_POOL_RANDOM: _bindgen_ty_15 = 2; -pub const PF_POOL_SRCHASH: _bindgen_ty_15 = 3; -pub const PF_POOL_ROUNDROBIN: _bindgen_ty_15 = 4; -pub type _bindgen_ty_15 = u32; -pub const PF_ADDR_ADDRMASK: _bindgen_ty_16 = 0; -pub const PF_ADDR_NOROUTE: _bindgen_ty_16 = 1; -pub const PF_ADDR_DYNIFTL: _bindgen_ty_16 = 2; -pub const PF_ADDR_TABLE: _bindgen_ty_16 = 3; -pub const PF_ADDR_RTLABEL: _bindgen_ty_16 = 4; -pub const PF_ADDR_URPFFAILED: _bindgen_ty_16 = 5; -pub const PF_ADDR_RANGE: _bindgen_ty_16 = 6; -pub type _bindgen_ty_16 = u32; +pub const PF_INOUT: _bindgen_ty_6 = _bindgen_ty_6::PF_INOUT; +pub const PF_IN: _bindgen_ty_6 = _bindgen_ty_6::PF_IN; +pub const PF_OUT: _bindgen_ty_6 = _bindgen_ty_6::PF_OUT; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum _bindgen_ty_6 { + PF_INOUT = 0, + PF_IN = 1, + PF_OUT = 2, +} +pub const PF_PASS: _bindgen_ty_7 = _bindgen_ty_7::PF_PASS; +pub const PF_DROP: _bindgen_ty_7 = _bindgen_ty_7::PF_DROP; +pub const PF_SCRUB: _bindgen_ty_7 = _bindgen_ty_7::PF_SCRUB; +pub const PF_NOSCRUB: _bindgen_ty_7 = _bindgen_ty_7::PF_NOSCRUB; +pub const PF_NAT: _bindgen_ty_7 = _bindgen_ty_7::PF_NAT; +pub const PF_NONAT: _bindgen_ty_7 = _bindgen_ty_7::PF_NONAT; +pub const PF_BINAT: _bindgen_ty_7 = _bindgen_ty_7::PF_BINAT; +pub const PF_NOBINAT: _bindgen_ty_7 = _bindgen_ty_7::PF_NOBINAT; +pub const PF_RDR: _bindgen_ty_7 = _bindgen_ty_7::PF_RDR; +pub const PF_NORDR: _bindgen_ty_7 = _bindgen_ty_7::PF_NORDR; +pub const PF_SYNPROXY_DROP: _bindgen_ty_7 = _bindgen_ty_7::PF_SYNPROXY_DROP; +pub const PF_DUMMYNET: _bindgen_ty_7 = _bindgen_ty_7::PF_DUMMYNET; +pub const PF_NODUMMYNET: _bindgen_ty_7 = _bindgen_ty_7::PF_NODUMMYNET; +pub const PF_NAT64: _bindgen_ty_7 = _bindgen_ty_7::PF_NAT64; +pub const PF_NONAT64: _bindgen_ty_7 = _bindgen_ty_7::PF_NONAT64; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum _bindgen_ty_7 { + PF_PASS = 0, + PF_DROP = 1, + PF_SCRUB = 2, + PF_NOSCRUB = 3, + PF_NAT = 4, + PF_NONAT = 5, + PF_BINAT = 6, + PF_NOBINAT = 7, + PF_RDR = 8, + PF_NORDR = 9, + PF_SYNPROXY_DROP = 10, + PF_DUMMYNET = 11, + PF_NODUMMYNET = 12, + PF_NAT64 = 13, + PF_NONAT64 = 14, +} +pub const PF_RULESET_SCRUB: _bindgen_ty_8 = _bindgen_ty_8::PF_RULESET_SCRUB; +pub const PF_RULESET_FILTER: _bindgen_ty_8 = _bindgen_ty_8::PF_RULESET_FILTER; +pub const PF_RULESET_NAT: _bindgen_ty_8 = _bindgen_ty_8::PF_RULESET_NAT; +pub const PF_RULESET_BINAT: _bindgen_ty_8 = _bindgen_ty_8::PF_RULESET_BINAT; +pub const PF_RULESET_RDR: _bindgen_ty_8 = _bindgen_ty_8::PF_RULESET_RDR; +pub const PF_RULESET_DUMMYNET: _bindgen_ty_8 = _bindgen_ty_8::PF_RULESET_DUMMYNET; +pub const PF_RULESET_MAX: _bindgen_ty_8 = _bindgen_ty_8::PF_RULESET_MAX; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum _bindgen_ty_8 { + PF_RULESET_SCRUB = 0, + PF_RULESET_FILTER = 1, + PF_RULESET_NAT = 2, + PF_RULESET_BINAT = 3, + PF_RULESET_RDR = 4, + PF_RULESET_DUMMYNET = 5, + PF_RULESET_MAX = 6, +} +pub const PF_OP_NONE: _bindgen_ty_9 = _bindgen_ty_9::PF_OP_NONE; +pub const PF_OP_IRG: _bindgen_ty_9 = _bindgen_ty_9::PF_OP_IRG; +pub const PF_OP_EQ: _bindgen_ty_9 = _bindgen_ty_9::PF_OP_EQ; +pub const PF_OP_NE: _bindgen_ty_9 = _bindgen_ty_9::PF_OP_NE; +pub const PF_OP_LT: _bindgen_ty_9 = _bindgen_ty_9::PF_OP_LT; +pub const PF_OP_LE: _bindgen_ty_9 = _bindgen_ty_9::PF_OP_LE; +pub const PF_OP_GT: _bindgen_ty_9 = _bindgen_ty_9::PF_OP_GT; +pub const PF_OP_GE: _bindgen_ty_9 = _bindgen_ty_9::PF_OP_GE; +pub const PF_OP_XRG: _bindgen_ty_9 = _bindgen_ty_9::PF_OP_XRG; +pub const PF_OP_RRG: _bindgen_ty_9 = _bindgen_ty_9::PF_OP_RRG; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum _bindgen_ty_9 { + PF_OP_NONE = 0, + PF_OP_IRG = 1, + PF_OP_EQ = 2, + PF_OP_NE = 3, + PF_OP_LT = 4, + PF_OP_LE = 5, + PF_OP_GT = 6, + PF_OP_GE = 7, + PF_OP_XRG = 8, + PF_OP_RRG = 9, +} +pub const PF_DEBUG_NONE: _bindgen_ty_10 = _bindgen_ty_10::PF_DEBUG_NONE; +pub const PF_DEBUG_URGENT: _bindgen_ty_10 = _bindgen_ty_10::PF_DEBUG_URGENT; +pub const PF_DEBUG_MISC: _bindgen_ty_10 = _bindgen_ty_10::PF_DEBUG_MISC; +pub const PF_DEBUG_NOISY: _bindgen_ty_10 = _bindgen_ty_10::PF_DEBUG_NOISY; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum _bindgen_ty_10 { + PF_DEBUG_NONE = 0, + PF_DEBUG_URGENT = 1, + PF_DEBUG_MISC = 2, + PF_DEBUG_NOISY = 3, +} +pub const PF_CHANGE_NONE: _bindgen_ty_11 = _bindgen_ty_11::PF_CHANGE_NONE; +pub const PF_CHANGE_ADD_HEAD: _bindgen_ty_11 = _bindgen_ty_11::PF_CHANGE_ADD_HEAD; +pub const PF_CHANGE_ADD_TAIL: _bindgen_ty_11 = _bindgen_ty_11::PF_CHANGE_ADD_TAIL; +pub const PF_CHANGE_ADD_BEFORE: _bindgen_ty_11 = _bindgen_ty_11::PF_CHANGE_ADD_BEFORE; +pub const PF_CHANGE_ADD_AFTER: _bindgen_ty_11 = _bindgen_ty_11::PF_CHANGE_ADD_AFTER; +pub const PF_CHANGE_REMOVE: _bindgen_ty_11 = _bindgen_ty_11::PF_CHANGE_REMOVE; +pub const PF_CHANGE_GET_TICKET: _bindgen_ty_11 = _bindgen_ty_11::PF_CHANGE_GET_TICKET; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum _bindgen_ty_11 { + PF_CHANGE_NONE = 0, + PF_CHANGE_ADD_HEAD = 1, + PF_CHANGE_ADD_TAIL = 2, + PF_CHANGE_ADD_BEFORE = 3, + PF_CHANGE_ADD_AFTER = 4, + PF_CHANGE_REMOVE = 5, + PF_CHANGE_GET_TICKET = 6, +} +pub const PF_GET_NONE: _bindgen_ty_12 = _bindgen_ty_12::PF_GET_NONE; +pub const PF_GET_CLR_CNTR: _bindgen_ty_12 = _bindgen_ty_12::PF_GET_CLR_CNTR; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum _bindgen_ty_12 { + PF_GET_NONE = 0, + PF_GET_CLR_CNTR = 1, +} +pub const PF_NOPFROUTE: _bindgen_ty_14 = _bindgen_ty_14::PF_NOPFROUTE; +pub const PF_FASTROUTE: _bindgen_ty_14 = _bindgen_ty_14::PF_FASTROUTE; +pub const PF_ROUTETO: _bindgen_ty_14 = _bindgen_ty_14::PF_ROUTETO; +pub const PF_DUPTO: _bindgen_ty_14 = _bindgen_ty_14::PF_DUPTO; +pub const PF_REPLYTO: _bindgen_ty_14 = _bindgen_ty_14::PF_REPLYTO; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum _bindgen_ty_14 { + PF_NOPFROUTE = 0, + PF_FASTROUTE = 1, + PF_ROUTETO = 2, + PF_DUPTO = 3, + PF_REPLYTO = 4, +} +pub const PF_LIMIT_STATES: _bindgen_ty_15 = _bindgen_ty_15::PF_LIMIT_STATES; +pub const PF_LIMIT_APP_STATES: _bindgen_ty_15 = _bindgen_ty_15::PF_LIMIT_APP_STATES; +pub const PF_LIMIT_SRC_NODES: _bindgen_ty_15 = _bindgen_ty_15::PF_LIMIT_SRC_NODES; +pub const PF_LIMIT_FRAGS: _bindgen_ty_15 = _bindgen_ty_15::PF_LIMIT_FRAGS; +pub const PF_LIMIT_TABLES: _bindgen_ty_15 = _bindgen_ty_15::PF_LIMIT_TABLES; +pub const PF_LIMIT_TABLE_ENTRIES: _bindgen_ty_15 = _bindgen_ty_15::PF_LIMIT_TABLE_ENTRIES; +pub const PF_LIMIT_MAX: _bindgen_ty_15 = _bindgen_ty_15::PF_LIMIT_MAX; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum _bindgen_ty_15 { + PF_LIMIT_STATES = 0, + PF_LIMIT_APP_STATES = 1, + PF_LIMIT_SRC_NODES = 2, + PF_LIMIT_FRAGS = 3, + PF_LIMIT_TABLES = 4, + PF_LIMIT_TABLE_ENTRIES = 5, + PF_LIMIT_MAX = 6, +} +pub const PF_POOL_NONE: _bindgen_ty_16 = _bindgen_ty_16::PF_POOL_NONE; +pub const PF_POOL_BITMASK: _bindgen_ty_16 = _bindgen_ty_16::PF_POOL_BITMASK; +pub const PF_POOL_RANDOM: _bindgen_ty_16 = _bindgen_ty_16::PF_POOL_RANDOM; +pub const PF_POOL_SRCHASH: _bindgen_ty_16 = _bindgen_ty_16::PF_POOL_SRCHASH; +pub const PF_POOL_ROUNDROBIN: _bindgen_ty_16 = _bindgen_ty_16::PF_POOL_ROUNDROBIN; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum _bindgen_ty_16 { + PF_POOL_NONE = 0, + PF_POOL_BITMASK = 1, + PF_POOL_RANDOM = 2, + PF_POOL_SRCHASH = 3, + PF_POOL_ROUNDROBIN = 4, +} +pub const PF_ADDR_ADDRMASK: _bindgen_ty_17 = _bindgen_ty_17::PF_ADDR_ADDRMASK; +pub const PF_ADDR_NOROUTE: _bindgen_ty_17 = _bindgen_ty_17::PF_ADDR_NOROUTE; +pub const PF_ADDR_DYNIFTL: _bindgen_ty_17 = _bindgen_ty_17::PF_ADDR_DYNIFTL; +pub const PF_ADDR_TABLE: _bindgen_ty_17 = _bindgen_ty_17::PF_ADDR_TABLE; +pub const PF_ADDR_RTLABEL: _bindgen_ty_17 = _bindgen_ty_17::PF_ADDR_RTLABEL; +pub const PF_ADDR_URPFFAILED: _bindgen_ty_17 = _bindgen_ty_17::PF_ADDR_URPFFAILED; +pub const PF_ADDR_RANGE: _bindgen_ty_17 = _bindgen_ty_17::PF_ADDR_RANGE; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum _bindgen_ty_17 { + PF_ADDR_ADDRMASK = 0, + PF_ADDR_NOROUTE = 1, + PF_ADDR_DYNIFTL = 2, + PF_ADDR_TABLE = 3, + PF_ADDR_RTLABEL = 4, + PF_ADDR_URPFFAILED = 5, + PF_ADDR_RANGE = 6, +} #[repr(C)] #[derive(Copy, Clone)] pub struct pf_addr { @@ -341,15 +449,17 @@ pub struct pf_addr { #[repr(C)] #[derive(Copy, Clone)] pub union pf_addr__bindgen_ty_1 { - pub v4: in_addr, - pub v6: in6_addr, - pub addr8: [u_int8_t; 16usize], - pub addr16: [u_int16_t; 8usize], - pub addr32: [u_int32_t; 4usize], - _bindgen_union_align: [u32; 4usize], + pub _v4addr: in_addr, + pub _v6addr: in6_addr, + pub _addr8: [u_int8_t; 16usize], + pub _addr16: [u_int16_t; 8usize], + pub _addr32: [u_int32_t; 4usize], } #[test] fn bindgen_test_layout_pf_addr__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -361,58 +471,60 @@ fn bindgen_test_layout_pf_addr__bindgen_ty_1() { concat!("Alignment of ", stringify!(pf_addr__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._v4addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(pf_addr__bindgen_ty_1), "::", - stringify!(v4) + stringify!(_v4addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).v6 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._v6addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(pf_addr__bindgen_ty_1), "::", - stringify!(v6) + stringify!(_v6addr) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr8 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._addr8) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(pf_addr__bindgen_ty_1), "::", - stringify!(addr8) + stringify!(_addr8) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr16 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._addr16) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(pf_addr__bindgen_ty_1), "::", - stringify!(addr16) + stringify!(_addr16) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr32 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._addr32) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(pf_addr__bindgen_ty_1), "::", - stringify!(addr32) + stringify!(_addr32) ) ); } #[test] fn bindgen_test_layout_pf_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -424,7 +536,7 @@ fn bindgen_test_layout_pf_addr() { concat!("Alignment of ", stringify!(pf_addr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pfa as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pfa) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -450,7 +562,6 @@ pub union pf_addr_wrap__bindgen_ty_1 { pub tblname: [::std::os::raw::c_char; 32usize], pub rtlabelname: [::std::os::raw::c_char; 32usize], pub rtlabel: u_int32_t, - _bindgen_union_align: [u32; 8usize], } #[repr(C)] #[derive(Copy, Clone)] @@ -460,6 +571,9 @@ pub struct pf_addr_wrap__bindgen_ty_1__bindgen_ty_1 { } #[test] fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -477,10 +591,7 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).addr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -490,10 +601,7 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mask as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -505,6 +613,9 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1__bindgen_ty_1() { } #[test] fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -516,7 +627,7 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1() { concat!("Alignment of ", stringify!(pf_addr_wrap__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).a as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -526,9 +637,7 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ifname as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -538,9 +647,7 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tblname as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).tblname) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -550,9 +657,7 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rtlabelname as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rtlabelname) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -562,9 +667,7 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rtlabel as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rtlabel) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -577,14 +680,16 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1() { #[repr(C)] #[derive(Copy, Clone)] pub union pf_addr_wrap__bindgen_ty_2 { - pub r#dyn: *mut ::std::os::raw::c_void, + pub dyn_: *mut ::std::os::raw::c_void, pub tbl: *mut ::std::os::raw::c_void, pub dyncnt: ::std::os::raw::c_int, pub tblcnt: ::std::os::raw::c_int, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -596,19 +701,17 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_2() { concat!("Alignment of ", stringify!(pf_addr_wrap__bindgen_ty_2)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).r#dyn as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).dyn_) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", stringify!(pf_addr_wrap__bindgen_ty_2), "::", - stringify!(r#dyn) + stringify!(dyn_) ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tbl as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tbl) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -618,9 +721,7 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dyncnt as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).dyncnt) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -630,9 +731,7 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tblcnt as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).tblcnt) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -644,6 +743,8 @@ fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_2() { } #[test] fn bindgen_test_layout_pf_addr_wrap() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 48usize, @@ -655,7 +756,7 @@ fn bindgen_test_layout_pf_addr_wrap() { concat!("Alignment of ", stringify!(pf_addr_wrap)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).v as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).v) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -665,7 +766,7 @@ fn bindgen_test_layout_pf_addr_wrap() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).p as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).p) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -675,7 +776,7 @@ fn bindgen_test_layout_pf_addr_wrap() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 40usize, concat!( "Offset of field: ", @@ -685,7 +786,7 @@ fn bindgen_test_layout_pf_addr_wrap() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).iflags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).iflags) as usize - ptr as usize }, 41usize, concat!( "Offset of field: ", @@ -703,6 +804,8 @@ pub struct pf_port_range { } #[test] fn bindgen_test_layout_pf_port_range() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 6usize, @@ -714,7 +817,7 @@ fn bindgen_test_layout_pf_port_range() { concat!("Alignment of ", stringify!(pf_port_range)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).port as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -724,7 +827,7 @@ fn bindgen_test_layout_pf_port_range() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).op as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).op) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -740,10 +843,11 @@ pub union pf_rule_xport { pub range: pf_port_range, pub call_id: u_int16_t, pub spi: u_int32_t, - _bindgen_union_align: [u32; 2usize], } #[test] fn bindgen_test_layout_pf_rule_xport() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -755,7 +859,7 @@ fn bindgen_test_layout_pf_rule_xport() { concat!("Alignment of ", stringify!(pf_rule_xport)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).range as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).range) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -765,7 +869,7 @@ fn bindgen_test_layout_pf_rule_xport() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).call_id as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).call_id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -775,7 +879,7 @@ fn bindgen_test_layout_pf_rule_xport() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).spi as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).spi) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -794,6 +898,8 @@ pub struct pf_rule_uid { } #[test] fn bindgen_test_layout_pf_rule_uid() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 12usize, @@ -805,7 +911,7 @@ fn bindgen_test_layout_pf_rule_uid() { concat!("Alignment of ", stringify!(pf_rule_uid)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).uid as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).uid) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -815,7 +921,7 @@ fn bindgen_test_layout_pf_rule_uid() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).op as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).op) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -825,7 +931,7 @@ fn bindgen_test_layout_pf_rule_uid() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._pad) as usize - ptr as usize }, 9usize, concat!( "Offset of field: ", @@ -844,6 +950,8 @@ pub struct pf_rule_gid { } #[test] fn bindgen_test_layout_pf_rule_gid() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 12usize, @@ -855,7 +963,7 @@ fn bindgen_test_layout_pf_rule_gid() { concat!("Alignment of ", stringify!(pf_rule_gid)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gid as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).gid) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -865,7 +973,7 @@ fn bindgen_test_layout_pf_rule_gid() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).op as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).op) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -875,7 +983,7 @@ fn bindgen_test_layout_pf_rule_gid() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._pad) as usize - ptr as usize }, 9usize, concat!( "Offset of field: ", @@ -894,6 +1002,8 @@ pub struct pf_rule_addr { } #[test] fn bindgen_test_layout_pf_rule_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 64usize, @@ -905,7 +1015,7 @@ fn bindgen_test_layout_pf_rule_addr() { concat!("Alignment of ", stringify!(pf_rule_addr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -915,7 +1025,7 @@ fn bindgen_test_layout_pf_rule_addr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).xport as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).xport) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -925,7 +1035,7 @@ fn bindgen_test_layout_pf_rule_addr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).neg as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).neg) as usize - ptr as usize }, 56usize, concat!( "Offset of field: ", @@ -951,6 +1061,9 @@ pub struct pf_pooladdr__bindgen_ty_1 { } #[test] fn bindgen_test_layout_pf_pooladdr__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -962,9 +1075,7 @@ fn bindgen_test_layout_pf_pooladdr__bindgen_ty_1() { concat!("Alignment of ", stringify!(pf_pooladdr__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tqe_next as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).tqe_next) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -974,9 +1085,7 @@ fn bindgen_test_layout_pf_pooladdr__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).tqe_prev as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).tqe_prev) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -988,6 +1097,8 @@ fn bindgen_test_layout_pf_pooladdr__bindgen_ty_1() { } #[test] fn bindgen_test_layout_pf_pooladdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 88usize, @@ -999,7 +1110,7 @@ fn bindgen_test_layout_pf_pooladdr() { concat!("Alignment of ", stringify!(pf_pooladdr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1009,7 +1120,7 @@ fn bindgen_test_layout_pf_pooladdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entries as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -1019,7 +1130,7 @@ fn bindgen_test_layout_pf_pooladdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ifname as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, 64usize, concat!( "Offset of field: ", @@ -1029,7 +1140,7 @@ fn bindgen_test_layout_pf_pooladdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).kif as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).kif) as usize - ptr as usize }, 80usize, concat!( "Offset of field: ", @@ -1047,6 +1158,8 @@ pub struct pf_palist { } #[test] fn bindgen_test_layout_pf_palist() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1058,7 +1171,7 @@ fn bindgen_test_layout_pf_palist() { concat!("Alignment of ", stringify!(pf_palist)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqh_first as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tqh_first) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1068,7 +1181,7 @@ fn bindgen_test_layout_pf_palist() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqh_last as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tqh_last) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1089,10 +1202,12 @@ pub union pf_poolhashkey__bindgen_ty_1 { pub key8: [u_int8_t; 16usize], pub key16: [u_int16_t; 8usize], pub key32: [u_int32_t; 4usize], - _bindgen_union_align: [u32; 4usize], } #[test] fn bindgen_test_layout_pf_poolhashkey__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1104,9 +1219,7 @@ fn bindgen_test_layout_pf_poolhashkey__bindgen_ty_1() { concat!("Alignment of ", stringify!(pf_poolhashkey__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).key8 as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).key8) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1116,9 +1229,7 @@ fn bindgen_test_layout_pf_poolhashkey__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).key16 as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).key16) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1128,9 +1239,7 @@ fn bindgen_test_layout_pf_poolhashkey__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).key32 as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).key32) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1142,6 +1251,8 @@ fn bindgen_test_layout_pf_poolhashkey__bindgen_ty_1() { } #[test] fn bindgen_test_layout_pf_poolhashkey() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1153,7 +1264,7 @@ fn bindgen_test_layout_pf_poolhashkey() { concat!("Alignment of ", stringify!(pf_poolhashkey)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pfk as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pfk) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1178,6 +1289,8 @@ pub struct pf_pool { } #[test] fn bindgen_test_layout_pf_pool() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 72usize, @@ -1189,7 +1302,7 @@ fn bindgen_test_layout_pf_pool() { concat!("Alignment of ", stringify!(pf_pool)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).list as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).list) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1199,7 +1312,7 @@ fn bindgen_test_layout_pf_pool() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cur as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cur) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -1209,7 +1322,7 @@ fn bindgen_test_layout_pf_pool() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).key as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).key) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -1219,7 +1332,7 @@ fn bindgen_test_layout_pf_pool() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).counter as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).counter) as usize - ptr as usize }, 40usize, concat!( "Offset of field: ", @@ -1229,7 +1342,7 @@ fn bindgen_test_layout_pf_pool() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tblidx as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tblidx) as usize - ptr as usize }, 56usize, concat!( "Offset of field: ", @@ -1239,7 +1352,7 @@ fn bindgen_test_layout_pf_pool() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).proxy_port as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).proxy_port) as usize - ptr as usize }, 60usize, concat!( "Offset of field: ", @@ -1249,7 +1362,7 @@ fn bindgen_test_layout_pf_pool() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).port_op as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).port_op) as usize - ptr as usize }, 64usize, concat!( "Offset of field: ", @@ -1259,7 +1372,7 @@ fn bindgen_test_layout_pf_pool() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).opts as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).opts) as usize - ptr as usize }, 65usize, concat!( "Offset of field: ", @@ -1269,7 +1382,7 @@ fn bindgen_test_layout_pf_pool() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).af as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).af) as usize - ptr as usize }, 66usize, concat!( "Offset of field: ", @@ -1285,10 +1398,11 @@ pub type pf_osfp_t = u_int32_t; pub union pf_rule_ptr { pub ptr: *mut pf_rule, pub nr: u_int32_t, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_pf_rule_ptr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -1300,7 +1414,7 @@ fn bindgen_test_layout_pf_rule_ptr() { concat!("Alignment of ", stringify!(pf_rule_ptr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ptr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ptr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1310,7 +1424,7 @@ fn bindgen_test_layout_pf_rule_ptr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1406,6 +1520,9 @@ pub struct pf_rule__bindgen_ty_1 { } #[test] fn bindgen_test_layout_pf_rule__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -1417,7 +1534,7 @@ fn bindgen_test_layout_pf_rule__bindgen_ty_1() { concat!("Alignment of ", stringify!(pf_rule__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqe_next as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tqe_next) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1427,7 +1544,7 @@ fn bindgen_test_layout_pf_rule__bindgen_ty_1() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqe_prev as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tqe_prev) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -1445,6 +1562,9 @@ pub struct pf_rule__bindgen_ty_2 { } #[test] fn bindgen_test_layout_pf_rule__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -1456,7 +1576,7 @@ fn bindgen_test_layout_pf_rule__bindgen_ty_2() { concat!("Alignment of ", stringify!(pf_rule__bindgen_ty_2)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).limit as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).limit) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1466,7 +1586,7 @@ fn bindgen_test_layout_pf_rule__bindgen_ty_2() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).seconds as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).seconds) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -1478,6 +1598,8 @@ fn bindgen_test_layout_pf_rule__bindgen_ty_2() { } #[test] fn bindgen_test_layout_pf_rule() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 1040usize, @@ -1489,7 +1611,7 @@ fn bindgen_test_layout_pf_rule() { concat!("Alignment of ", stringify!(pf_rule)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).src as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).src) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -1499,7 +1621,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dst) as usize - ptr as usize }, 64usize, concat!( "Offset of field: ", @@ -1509,7 +1631,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).skip as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).skip) as usize - ptr as usize }, 128usize, concat!( "Offset of field: ", @@ -1519,7 +1641,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).label as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).label) as usize - ptr as usize }, 192usize, concat!( "Offset of field: ", @@ -1529,7 +1651,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ifname as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, 256usize, concat!( "Offset of field: ", @@ -1539,7 +1661,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).qname as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).qname) as usize - ptr as usize }, 272usize, concat!( "Offset of field: ", @@ -1549,7 +1671,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pqname as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pqname) as usize - ptr as usize }, 336usize, concat!( "Offset of field: ", @@ -1559,7 +1681,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tagname as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tagname) as usize - ptr as usize }, 400usize, concat!( "Offset of field: ", @@ -1569,7 +1691,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).match_tagname as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).match_tagname) as usize - ptr as usize }, 464usize, concat!( "Offset of field: ", @@ -1579,7 +1701,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).overload_tblname as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).overload_tblname) as usize - ptr as usize }, 528usize, concat!( "Offset of field: ", @@ -1589,7 +1711,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entries as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, 560usize, concat!( "Offset of field: ", @@ -1599,7 +1721,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rpool as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rpool) as usize - ptr as usize }, 576usize, concat!( "Offset of field: ", @@ -1609,7 +1731,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).evaluations as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).evaluations) as usize - ptr as usize }, 648usize, concat!( "Offset of field: ", @@ -1619,7 +1741,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).packets as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).packets) as usize - ptr as usize }, 656usize, concat!( "Offset of field: ", @@ -1629,7 +1751,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).bytes as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).bytes) as usize - ptr as usize }, 672usize, concat!( "Offset of field: ", @@ -1639,7 +1761,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ticket as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ticket) as usize - ptr as usize }, 688usize, concat!( "Offset of field: ", @@ -1649,7 +1771,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).owner as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).owner) as usize - ptr as usize }, 696usize, concat!( "Offset of field: ", @@ -1659,7 +1781,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).priority as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).priority) as usize - ptr as usize }, 760usize, concat!( "Offset of field: ", @@ -1669,7 +1791,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).kif as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).kif) as usize - ptr as usize }, 768usize, concat!( "Offset of field: ", @@ -1679,7 +1801,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).anchor as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).anchor) as usize - ptr as usize }, 776usize, concat!( "Offset of field: ", @@ -1689,7 +1811,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).overload_tbl as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).overload_tbl) as usize - ptr as usize }, 784usize, concat!( "Offset of field: ", @@ -1699,7 +1821,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).os_fingerprint as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).os_fingerprint) as usize - ptr as usize }, 792usize, concat!( "Offset of field: ", @@ -1709,7 +1831,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rtableid as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rtableid) as usize - ptr as usize }, 796usize, concat!( "Offset of field: ", @@ -1719,7 +1841,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).timeout as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).timeout) as usize - ptr as usize }, 800usize, concat!( "Offset of field: ", @@ -1729,7 +1851,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).states as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).states) as usize - ptr as usize }, 904usize, concat!( "Offset of field: ", @@ -1739,7 +1861,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_states as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).max_states) as usize - ptr as usize }, 908usize, concat!( "Offset of field: ", @@ -1749,7 +1871,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_nodes as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).src_nodes) as usize - ptr as usize }, 912usize, concat!( "Offset of field: ", @@ -1759,7 +1881,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_src_nodes as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).max_src_nodes) as usize - ptr as usize }, 916usize, concat!( "Offset of field: ", @@ -1769,7 +1891,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_src_states as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).max_src_states) as usize - ptr as usize }, 920usize, concat!( "Offset of field: ", @@ -1779,7 +1901,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_src_conn as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).max_src_conn) as usize - ptr as usize }, 924usize, concat!( "Offset of field: ", @@ -1789,7 +1911,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_src_conn_rate as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).max_src_conn_rate) as usize - ptr as usize }, 928usize, concat!( "Offset of field: ", @@ -1799,7 +1921,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).qid as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).qid) as usize - ptr as usize }, 936usize, concat!( "Offset of field: ", @@ -1809,7 +1931,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pqid as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pqid) as usize - ptr as usize }, 940usize, concat!( "Offset of field: ", @@ -1819,7 +1941,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rt_listid as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rt_listid) as usize - ptr as usize }, 944usize, concat!( "Offset of field: ", @@ -1829,7 +1951,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, 948usize, concat!( "Offset of field: ", @@ -1839,7 +1961,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).prob as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).prob) as usize - ptr as usize }, 952usize, concat!( "Offset of field: ", @@ -1849,7 +1971,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cuid as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cuid) as usize - ptr as usize }, 956usize, concat!( "Offset of field: ", @@ -1859,7 +1981,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).cpid as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).cpid) as usize - ptr as usize }, 960usize, concat!( "Offset of field: ", @@ -1869,7 +1991,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).return_icmp as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).return_icmp) as usize - ptr as usize }, 964usize, concat!( "Offset of field: ", @@ -1879,7 +2001,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).return_icmp6 as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).return_icmp6) as usize - ptr as usize }, 966usize, concat!( "Offset of field: ", @@ -1889,7 +2011,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_mss as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).max_mss) as usize - ptr as usize }, 968usize, concat!( "Offset of field: ", @@ -1899,7 +2021,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tag as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tag) as usize - ptr as usize }, 970usize, concat!( "Offset of field: ", @@ -1909,7 +2031,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).match_tag as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).match_tag) as usize - ptr as usize }, 972usize, concat!( "Offset of field: ", @@ -1919,7 +2041,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).uid as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).uid) as usize - ptr as usize }, 976usize, concat!( "Offset of field: ", @@ -1929,7 +2051,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gid as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).gid) as usize - ptr as usize }, 988usize, concat!( "Offset of field: ", @@ -1939,7 +2061,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rule_flag as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rule_flag) as usize - ptr as usize }, 1000usize, concat!( "Offset of field: ", @@ -1949,7 +2071,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).action as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).action) as usize - ptr as usize }, 1004usize, concat!( "Offset of field: ", @@ -1959,7 +2081,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).direction as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).direction) as usize - ptr as usize }, 1005usize, concat!( "Offset of field: ", @@ -1969,7 +2091,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).log as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).log) as usize - ptr as usize }, 1006usize, concat!( "Offset of field: ", @@ -1979,7 +2101,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).logif as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).logif) as usize - ptr as usize }, 1007usize, concat!( "Offset of field: ", @@ -1989,7 +2111,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).quick as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).quick) as usize - ptr as usize }, 1008usize, concat!( "Offset of field: ", @@ -1999,7 +2121,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ifnot as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ifnot) as usize - ptr as usize }, 1009usize, concat!( "Offset of field: ", @@ -2009,7 +2131,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).match_tag_not as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).match_tag_not) as usize - ptr as usize }, 1010usize, concat!( "Offset of field: ", @@ -2019,7 +2141,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).natpass as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).natpass) as usize - ptr as usize }, 1011usize, concat!( "Offset of field: ", @@ -2029,7 +2151,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).keep_state as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).keep_state) as usize - ptr as usize }, 1012usize, concat!( "Offset of field: ", @@ -2039,7 +2161,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).af as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).af) as usize - ptr as usize }, 1013usize, concat!( "Offset of field: ", @@ -2049,7 +2171,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).proto as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize }, 1014usize, concat!( "Offset of field: ", @@ -2059,7 +2181,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, 1015usize, concat!( "Offset of field: ", @@ -2069,7 +2191,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).code) as usize - ptr as usize }, 1016usize, concat!( "Offset of field: ", @@ -2079,7 +2201,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, 1017usize, concat!( "Offset of field: ", @@ -2089,7 +2211,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flagset as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flagset) as usize - ptr as usize }, 1018usize, concat!( "Offset of field: ", @@ -2099,7 +2221,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).min_ttl as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).min_ttl) as usize - ptr as usize }, 1019usize, concat!( "Offset of field: ", @@ -2109,7 +2231,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).allow_opts as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).allow_opts) as usize - ptr as usize }, 1020usize, concat!( "Offset of field: ", @@ -2119,7 +2241,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rt as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rt) as usize - ptr as usize }, 1021usize, concat!( "Offset of field: ", @@ -2129,7 +2251,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).return_ttl as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).return_ttl) as usize - ptr as usize }, 1022usize, concat!( "Offset of field: ", @@ -2139,7 +2261,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tos as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tos) as usize - ptr as usize }, 1023usize, concat!( "Offset of field: ", @@ -2149,7 +2271,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).anchor_relative as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).anchor_relative) as usize - ptr as usize }, 1024usize, concat!( "Offset of field: ", @@ -2159,7 +2281,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).anchor_wildcard as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).anchor_wildcard) as usize - ptr as usize }, 1025usize, concat!( "Offset of field: ", @@ -2169,7 +2291,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flush as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flush) as usize - ptr as usize }, 1026usize, concat!( "Offset of field: ", @@ -2179,7 +2301,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).proto_variant as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).proto_variant) as usize - ptr as usize }, 1027usize, concat!( "Offset of field: ", @@ -2189,7 +2311,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).extfilter as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).extfilter) as usize - ptr as usize }, 1028usize, concat!( "Offset of field: ", @@ -2199,7 +2321,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).extmap as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).extmap) as usize - ptr as usize }, 1029usize, concat!( "Offset of field: ", @@ -2209,7 +2331,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dnpipe as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dnpipe) as usize - ptr as usize }, 1032usize, concat!( "Offset of field: ", @@ -2219,7 +2341,7 @@ fn bindgen_test_layout_pf_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dntype as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dntype) as usize - ptr as usize }, 1036usize, concat!( "Offset of field: ", @@ -2235,10 +2357,11 @@ pub union pf_state_xport { pub port: u_int16_t, pub call_id: u_int16_t, pub spi: u_int32_t, - _bindgen_union_align: u32, } #[test] fn bindgen_test_layout_pf_state_xport() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 4usize, @@ -2250,7 +2373,7 @@ fn bindgen_test_layout_pf_state_xport() { concat!("Alignment of ", stringify!(pf_state_xport)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).port as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2260,7 +2383,7 @@ fn bindgen_test_layout_pf_state_xport() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).call_id as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).call_id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2270,7 +2393,7 @@ fn bindgen_test_layout_pf_state_xport() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).spi as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).spi) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2293,6 +2416,8 @@ pub struct hook_desc_head { } #[test] fn bindgen_test_layout_hook_desc_head() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -2304,7 +2429,7 @@ fn bindgen_test_layout_hook_desc_head() { concat!("Alignment of ", stringify!(hook_desc_head)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqh_first as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tqh_first) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2314,7 +2439,7 @@ fn bindgen_test_layout_hook_desc_head() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqh_last as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tqh_last) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2334,6 +2459,8 @@ pub struct pfsync_state_scrub { } #[test] fn bindgen_test_layout_pfsync_state_scrub() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -2345,7 +2472,7 @@ fn bindgen_test_layout_pfsync_state_scrub() { concat!("Alignment of ", stringify!(pfsync_state_scrub)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pfss_flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pfss_flags) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2355,7 +2482,7 @@ fn bindgen_test_layout_pfsync_state_scrub() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pfss_ttl as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pfss_ttl) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -2365,7 +2492,7 @@ fn bindgen_test_layout_pfsync_state_scrub() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).scrub_flag as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).scrub_flag) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -2375,7 +2502,7 @@ fn bindgen_test_layout_pfsync_state_scrub() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pfss_ts_mod as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pfss_ts_mod) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -2394,6 +2521,8 @@ pub struct pfsync_state_host { } #[test] fn bindgen_test_layout_pfsync_state_host() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 24usize, @@ -2405,7 +2534,7 @@ fn bindgen_test_layout_pfsync_state_host() { concat!("Alignment of ", stringify!(pfsync_state_host)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2415,7 +2544,7 @@ fn bindgen_test_layout_pfsync_state_host() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).xport as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).xport) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2425,7 +2554,7 @@ fn bindgen_test_layout_pfsync_state_host() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -2450,6 +2579,8 @@ pub struct pfsync_state_peer { } #[test] fn bindgen_test_layout_pfsync_state_peer() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -2461,7 +2592,7 @@ fn bindgen_test_layout_pfsync_state_peer() { concat!("Alignment of ", stringify!(pfsync_state_peer)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).scrub as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).scrub) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2471,7 +2602,7 @@ fn bindgen_test_layout_pfsync_state_peer() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).seqlo as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).seqlo) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2481,7 +2612,7 @@ fn bindgen_test_layout_pfsync_state_peer() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).seqhi as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).seqhi) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -2491,7 +2622,7 @@ fn bindgen_test_layout_pfsync_state_peer() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).seqdiff as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).seqdiff) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -2501,7 +2632,7 @@ fn bindgen_test_layout_pfsync_state_peer() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).max_win as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).max_win) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", @@ -2511,7 +2642,7 @@ fn bindgen_test_layout_pfsync_state_peer() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).mss as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).mss) as usize - ptr as usize }, 22usize, concat!( "Offset of field: ", @@ -2521,7 +2652,7 @@ fn bindgen_test_layout_pfsync_state_peer() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).state as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -2531,7 +2662,7 @@ fn bindgen_test_layout_pfsync_state_peer() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).wscale as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).wscale) as usize - ptr as usize }, 25usize, concat!( "Offset of field: ", @@ -2541,7 +2672,7 @@ fn bindgen_test_layout_pfsync_state_peer() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, 26usize, concat!( "Offset of field: ", @@ -2588,6 +2719,8 @@ pub struct pfsync_state { } #[test] fn bindgen_test_layout_pfsync_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 297usize, @@ -2599,7 +2732,7 @@ fn bindgen_test_layout_pfsync_state() { concat!("Alignment of ", stringify!(pfsync_state)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).id as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2609,7 +2742,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ifname as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2619,7 +2752,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).lan as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).lan) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -2629,7 +2762,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).gwy as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).gwy) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -2639,7 +2772,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_lan as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ext_lan) as usize - ptr as usize }, 72usize, concat!( "Offset of field: ", @@ -2649,7 +2782,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_gwy as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ext_gwy) as usize - ptr as usize }, 96usize, concat!( "Offset of field: ", @@ -2659,7 +2792,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).src as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).src) as usize - ptr as usize }, 120usize, concat!( "Offset of field: ", @@ -2669,7 +2802,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).dst as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).dst) as usize - ptr as usize }, 152usize, concat!( "Offset of field: ", @@ -2679,7 +2812,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rt_addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rt_addr) as usize - ptr as usize }, 184usize, concat!( "Offset of field: ", @@ -2689,7 +2822,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).unlink_hooks as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).unlink_hooks) as usize - ptr as usize }, 200usize, concat!( "Offset of field: ", @@ -2699,7 +2832,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rule as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rule) as usize - ptr as usize }, 216usize, concat!( "Offset of field: ", @@ -2709,7 +2842,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).anchor as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).anchor) as usize - ptr as usize }, 220usize, concat!( "Offset of field: ", @@ -2719,7 +2852,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nat_rule as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nat_rule) as usize - ptr as usize }, 224usize, concat!( "Offset of field: ", @@ -2729,7 +2862,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).creation as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).creation) as usize - ptr as usize }, 228usize, concat!( "Offset of field: ", @@ -2739,7 +2872,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).expire as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).expire) as usize - ptr as usize }, 236usize, concat!( "Offset of field: ", @@ -2749,7 +2882,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).packets as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).packets) as usize - ptr as usize }, 244usize, concat!( "Offset of field: ", @@ -2759,7 +2892,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).bytes as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).bytes) as usize - ptr as usize }, 260usize, concat!( "Offset of field: ", @@ -2769,7 +2902,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).creatorid as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).creatorid) as usize - ptr as usize }, 276usize, concat!( "Offset of field: ", @@ -2779,7 +2912,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tag as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tag) as usize - ptr as usize }, 280usize, concat!( "Offset of field: ", @@ -2789,7 +2922,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).af_lan as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).af_lan) as usize - ptr as usize }, 282usize, concat!( "Offset of field: ", @@ -2799,7 +2932,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).af_gwy as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).af_gwy) as usize - ptr as usize }, 283usize, concat!( "Offset of field: ", @@ -2809,7 +2942,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).proto as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize }, 284usize, concat!( "Offset of field: ", @@ -2819,7 +2952,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).direction as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).direction) as usize - ptr as usize }, 285usize, concat!( "Offset of field: ", @@ -2829,7 +2962,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).log as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).log) as usize - ptr as usize }, 286usize, concat!( "Offset of field: ", @@ -2839,7 +2972,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).allow_opts as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).allow_opts) as usize - ptr as usize }, 287usize, concat!( "Offset of field: ", @@ -2849,7 +2982,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).timeout as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).timeout) as usize - ptr as usize }, 288usize, concat!( "Offset of field: ", @@ -2859,7 +2992,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).sync_flags as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).sync_flags) as usize - ptr as usize }, 289usize, concat!( "Offset of field: ", @@ -2869,7 +3002,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).updates as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).updates) as usize - ptr as usize }, 290usize, concat!( "Offset of field: ", @@ -2879,7 +3012,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).proto_variant as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).proto_variant) as usize - ptr as usize }, 291usize, concat!( "Offset of field: ", @@ -2889,7 +3022,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).__pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).__pad) as usize - ptr as usize }, 292usize, concat!( "Offset of field: ", @@ -2899,7 +3032,7 @@ fn bindgen_test_layout_pfsync_state() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).flowhash as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).flowhash) as usize - ptr as usize }, 293usize, concat!( "Offset of field: ", @@ -2917,6 +3050,8 @@ pub struct pf_rulequeue { } #[test] fn bindgen_test_layout_pf_rulequeue() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -2928,7 +3063,7 @@ fn bindgen_test_layout_pf_rulequeue() { concat!("Alignment of ", stringify!(pf_rulequeue)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqh_first as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tqh_first) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -2938,7 +3073,7 @@ fn bindgen_test_layout_pf_rulequeue() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tqh_last as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tqh_last) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -2970,11 +3105,15 @@ pub struct pf_ruleset__bindgen_ty_1__bindgen_ty_1 { pub ptr: *mut pf_rulequeue, pub ptr_array: *mut *mut pf_rule, pub rcount: u_int32_t, + pub rsize: u_int32_t, pub ticket: u_int32_t, pub open: ::std::os::raw::c_int, } #[test] fn bindgen_test_layout_pf_ruleset__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 32usize, @@ -2992,10 +3131,7 @@ fn bindgen_test_layout_pf_ruleset__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ptr as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ptr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3005,10 +3141,7 @@ fn bindgen_test_layout_pf_ruleset__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ptr_array as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ptr_array) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3018,10 +3151,7 @@ fn bindgen_test_layout_pf_ruleset__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rcount as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rcount) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -3031,24 +3161,28 @@ fn bindgen_test_layout_pf_ruleset__bindgen_ty_1__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ticket as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rsize) as usize - ptr as usize }, 20usize, concat!( "Offset of field: ", stringify!(pf_ruleset__bindgen_ty_1__bindgen_ty_1), "::", - stringify!(ticket) + stringify!(rsize) ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).open as *const _ - as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ticket) as usize - ptr as usize }, 24usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(ticket) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).open) as usize - ptr as usize }, + 28usize, concat!( "Offset of field: ", stringify!(pf_ruleset__bindgen_ty_1__bindgen_ty_1), @@ -3059,6 +3193,9 @@ fn bindgen_test_layout_pf_ruleset__bindgen_ty_1__bindgen_ty_1() { } #[test] fn bindgen_test_layout_pf_ruleset__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 96usize, @@ -3070,7 +3207,7 @@ fn bindgen_test_layout_pf_ruleset__bindgen_ty_1() { concat!("Alignment of ", stringify!(pf_ruleset__bindgen_ty_1)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).queues as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).queues) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3080,7 +3217,7 @@ fn bindgen_test_layout_pf_ruleset__bindgen_ty_1() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).active as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).active) as usize - ptr as usize }, 32usize, concat!( "Offset of field: ", @@ -3090,9 +3227,7 @@ fn bindgen_test_layout_pf_ruleset__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).inactive as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).inactive) as usize - ptr as usize }, 64usize, concat!( "Offset of field: ", @@ -3104,6 +3239,8 @@ fn bindgen_test_layout_pf_ruleset__bindgen_ty_1() { } #[test] fn bindgen_test_layout_pf_ruleset() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 600usize, @@ -3115,7 +3252,7 @@ fn bindgen_test_layout_pf_ruleset() { concat!("Alignment of ", stringify!(pf_ruleset)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rules as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rules) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3125,7 +3262,7 @@ fn bindgen_test_layout_pf_ruleset() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).anchor as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).anchor) as usize - ptr as usize }, 576usize, concat!( "Offset of field: ", @@ -3135,7 +3272,7 @@ fn bindgen_test_layout_pf_ruleset() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tticket as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tticket) as usize - ptr as usize }, 584usize, concat!( "Offset of field: ", @@ -3145,7 +3282,7 @@ fn bindgen_test_layout_pf_ruleset() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).tables as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).tables) as usize - ptr as usize }, 588usize, concat!( "Offset of field: ", @@ -3155,7 +3292,7 @@ fn bindgen_test_layout_pf_ruleset() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).topen as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).topen) as usize - ptr as usize }, 592usize, concat!( "Offset of field: ", @@ -3172,6 +3309,8 @@ pub struct pf_anchor_node { } #[test] fn bindgen_test_layout_pf_anchor_node() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -3183,7 +3322,7 @@ fn bindgen_test_layout_pf_anchor_node() { concat!("Alignment of ", stringify!(pf_anchor_node)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rbh_root as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rbh_root) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3194,7 +3333,7 @@ fn bindgen_test_layout_pf_anchor_node() { ); } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub struct pf_anchor { pub entry_global: pf_anchor__bindgen_ty_1, pub entry_node: pf_anchor__bindgen_ty_2, @@ -3216,6 +3355,9 @@ pub struct pf_anchor__bindgen_ty_1 { } #[test] fn bindgen_test_layout_pf_anchor__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 24usize, @@ -3227,9 +3369,7 @@ fn bindgen_test_layout_pf_anchor__bindgen_ty_1() { concat!("Alignment of ", stringify!(pf_anchor__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rbe_left as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rbe_left) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3239,9 +3379,7 @@ fn bindgen_test_layout_pf_anchor__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rbe_right as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rbe_right) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3251,9 +3389,7 @@ fn bindgen_test_layout_pf_anchor__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rbe_parent as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rbe_parent) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -3272,6 +3408,9 @@ pub struct pf_anchor__bindgen_ty_2 { } #[test] fn bindgen_test_layout_pf_anchor__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 24usize, @@ -3283,9 +3422,7 @@ fn bindgen_test_layout_pf_anchor__bindgen_ty_2() { concat!("Alignment of ", stringify!(pf_anchor__bindgen_ty_2)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rbe_left as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rbe_left) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3295,9 +3432,7 @@ fn bindgen_test_layout_pf_anchor__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rbe_right as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rbe_right) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3307,9 +3442,7 @@ fn bindgen_test_layout_pf_anchor__bindgen_ty_2() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rbe_parent as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rbe_parent) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -3321,6 +3454,8 @@ fn bindgen_test_layout_pf_anchor__bindgen_ty_2() { } #[test] fn bindgen_test_layout_pf_anchor() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 1824usize, @@ -3332,7 +3467,7 @@ fn bindgen_test_layout_pf_anchor() { concat!("Alignment of ", stringify!(pf_anchor)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entry_global as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).entry_global) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3342,7 +3477,7 @@ fn bindgen_test_layout_pf_anchor() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).entry_node as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).entry_node) as usize - ptr as usize }, 24usize, concat!( "Offset of field: ", @@ -3352,7 +3487,7 @@ fn bindgen_test_layout_pf_anchor() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).parent as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).parent) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -3362,7 +3497,7 @@ fn bindgen_test_layout_pf_anchor() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).children as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).children) as usize - ptr as usize }, 56usize, concat!( "Offset of field: ", @@ -3372,7 +3507,7 @@ fn bindgen_test_layout_pf_anchor() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize }, 64usize, concat!( "Offset of field: ", @@ -3382,7 +3517,7 @@ fn bindgen_test_layout_pf_anchor() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).path as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).path) as usize - ptr as usize }, 128usize, concat!( "Offset of field: ", @@ -3392,7 +3527,7 @@ fn bindgen_test_layout_pf_anchor() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ruleset as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ruleset) as usize - ptr as usize }, 1152usize, concat!( "Offset of field: ", @@ -3402,7 +3537,7 @@ fn bindgen_test_layout_pf_anchor() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).refcnt as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).refcnt) as usize - ptr as usize }, 1752usize, concat!( "Offset of field: ", @@ -3412,7 +3547,7 @@ fn bindgen_test_layout_pf_anchor() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).match_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).match_) as usize - ptr as usize }, 1756usize, concat!( "Offset of field: ", @@ -3422,7 +3557,7 @@ fn bindgen_test_layout_pf_anchor() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).owner as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).owner) as usize - ptr as usize }, 1760usize, concat!( "Offset of field: ", @@ -3435,7 +3570,7 @@ fn bindgen_test_layout_pf_anchor() { #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct pf_status { - pub counters: [u_int64_t; 16usize], + pub counters: [u_int64_t; 17usize], pub lcounters: [u_int64_t; 7usize], pub fcounters: [u_int64_t; 3usize], pub scounters: [u_int64_t; 3usize], @@ -3453,9 +3588,11 @@ pub struct pf_status { } #[test] fn bindgen_test_layout_pf_status() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), - 432usize, + 440usize, concat!("Size of: ", stringify!(pf_status)) ); assert_eq!( @@ -3464,7 +3601,7 @@ fn bindgen_test_layout_pf_status() { concat!("Alignment of ", stringify!(pf_status)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).counters as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).counters) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3474,8 +3611,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).lcounters as *const _ as usize }, - 128usize, + unsafe { ::std::ptr::addr_of!((*ptr).lcounters) as usize - ptr as usize }, + 136usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3484,8 +3621,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).fcounters as *const _ as usize }, - 184usize, + unsafe { ::std::ptr::addr_of!((*ptr).fcounters) as usize - ptr as usize }, + 192usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3494,8 +3631,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).scounters as *const _ as usize }, - 208usize, + unsafe { ::std::ptr::addr_of!((*ptr).scounters) as usize - ptr as usize }, + 216usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3504,8 +3641,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pcounters as *const _ as usize }, - 232usize, + unsafe { ::std::ptr::addr_of!((*ptr).pcounters) as usize - ptr as usize }, + 240usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3514,8 +3651,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).bcounters as *const _ as usize }, - 328usize, + unsafe { ::std::ptr::addr_of!((*ptr).bcounters) as usize - ptr as usize }, + 336usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3524,8 +3661,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).stateid as *const _ as usize }, - 360usize, + unsafe { ::std::ptr::addr_of!((*ptr).stateid) as usize - ptr as usize }, + 368usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3534,8 +3671,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).running as *const _ as usize }, - 368usize, + unsafe { ::std::ptr::addr_of!((*ptr).running) as usize - ptr as usize }, + 376usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3544,8 +3681,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).states as *const _ as usize }, - 372usize, + unsafe { ::std::ptr::addr_of!((*ptr).states) as usize - ptr as usize }, + 380usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3554,8 +3691,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).src_nodes as *const _ as usize }, - 376usize, + unsafe { ::std::ptr::addr_of!((*ptr).src_nodes) as usize - ptr as usize }, + 384usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3564,8 +3701,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).since as *const _ as usize }, - 384usize, + unsafe { ::std::ptr::addr_of!((*ptr).since) as usize - ptr as usize }, + 392usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3574,8 +3711,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).debug as *const _ as usize }, - 392usize, + unsafe { ::std::ptr::addr_of!((*ptr).debug) as usize - ptr as usize }, + 400usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3584,8 +3721,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).hostid as *const _ as usize }, - 396usize, + unsafe { ::std::ptr::addr_of!((*ptr).hostid) as usize - ptr as usize }, + 404usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3594,8 +3731,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ifname as *const _ as usize }, - 400usize, + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, + 408usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3604,8 +3741,8 @@ fn bindgen_test_layout_pf_status() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pf_chksum as *const _ as usize }, - 416usize, + unsafe { ::std::ptr::addr_of!((*ptr).pf_chksum) as usize - ptr as usize }, + 424usize, concat!( "Offset of field: ", stringify!(pf_status), @@ -3629,6 +3766,8 @@ pub struct pfioc_pooladdr { } #[test] fn bindgen_test_layout_pfioc_pooladdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 1136usize, @@ -3640,7 +3779,7 @@ fn bindgen_test_layout_pfioc_pooladdr() { concat!("Alignment of ", stringify!(pfioc_pooladdr)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).action as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).action) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3650,7 +3789,7 @@ fn bindgen_test_layout_pfioc_pooladdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ticket as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ticket) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -3660,7 +3799,7 @@ fn bindgen_test_layout_pfioc_pooladdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3670,7 +3809,7 @@ fn bindgen_test_layout_pfioc_pooladdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).r_num as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).r_num) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -3680,7 +3819,7 @@ fn bindgen_test_layout_pfioc_pooladdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).r_action as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).r_action) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -3690,7 +3829,7 @@ fn bindgen_test_layout_pfioc_pooladdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).r_last as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).r_last) as usize - ptr as usize }, 17usize, concat!( "Offset of field: ", @@ -3700,7 +3839,7 @@ fn bindgen_test_layout_pfioc_pooladdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).af as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).af) as usize - ptr as usize }, 18usize, concat!( "Offset of field: ", @@ -3710,7 +3849,7 @@ fn bindgen_test_layout_pfioc_pooladdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).anchor as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).anchor) as usize - ptr as usize }, 19usize, concat!( "Offset of field: ", @@ -3720,7 +3859,7 @@ fn bindgen_test_layout_pfioc_pooladdr() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 1048usize, concat!( "Offset of field: ", @@ -3743,6 +3882,8 @@ pub struct pfioc_rule { } #[test] fn bindgen_test_layout_pfioc_rule() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 3104usize, @@ -3754,7 +3895,7 @@ fn bindgen_test_layout_pfioc_rule() { concat!("Alignment of ", stringify!(pfioc_rule)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).action as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).action) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3764,7 +3905,7 @@ fn bindgen_test_layout_pfioc_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ticket as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ticket) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -3774,7 +3915,7 @@ fn bindgen_test_layout_pfioc_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).pool_ticket as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).pool_ticket) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3784,7 +3925,7 @@ fn bindgen_test_layout_pfioc_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).nr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, 12usize, concat!( "Offset of field: ", @@ -3794,7 +3935,7 @@ fn bindgen_test_layout_pfioc_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).anchor as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).anchor) as usize - ptr as usize }, 16usize, concat!( "Offset of field: ", @@ -3804,7 +3945,7 @@ fn bindgen_test_layout_pfioc_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).anchor_call as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).anchor_call) as usize - ptr as usize }, 1040usize, concat!( "Offset of field: ", @@ -3814,7 +3955,7 @@ fn bindgen_test_layout_pfioc_rule() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).rule as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).rule) as usize - ptr as usize }, 2064usize, concat!( "Offset of field: ", @@ -3834,6 +3975,9 @@ pub struct pfioc_state_addr_kill { } #[test] fn bindgen_test_layout_pfioc_state_addr_kill() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 64usize, @@ -3845,7 +3989,7 @@ fn bindgen_test_layout_pfioc_state_addr_kill() { concat!("Alignment of ", stringify!(pfioc_state_addr_kill)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).addr as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3855,7 +3999,7 @@ fn bindgen_test_layout_pfioc_state_addr_kill() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).reserved_ as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).reserved_) as usize - ptr as usize }, 48usize, concat!( "Offset of field: ", @@ -3865,7 +4009,7 @@ fn bindgen_test_layout_pfioc_state_addr_kill() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).neg as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).neg) as usize - ptr as usize }, 51usize, concat!( "Offset of field: ", @@ -3875,7 +4019,7 @@ fn bindgen_test_layout_pfioc_state_addr_kill() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).xport as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).xport) as usize - ptr as usize }, 52usize, concat!( "Offset of field: ", @@ -3899,6 +4043,8 @@ pub struct pfioc_state_kill { } #[test] fn bindgen_test_layout_pfioc_state_kill() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 216usize, @@ -3910,7 +4056,7 @@ fn bindgen_test_layout_pfioc_state_kill() { concat!("Alignment of ", stringify!(pfioc_state_kill)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).psk_af as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).psk_af) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -3920,7 +4066,7 @@ fn bindgen_test_layout_pfioc_state_kill() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).psk_proto as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).psk_proto) as usize - ptr as usize }, 1usize, concat!( "Offset of field: ", @@ -3930,9 +4076,7 @@ fn bindgen_test_layout_pfioc_state_kill() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).psk_proto_variant as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).psk_proto_variant) as usize - ptr as usize }, 2usize, concat!( "Offset of field: ", @@ -3942,7 +4086,7 @@ fn bindgen_test_layout_pfioc_state_kill() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::()))._pad as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr)._pad) as usize - ptr as usize }, 3usize, concat!( "Offset of field: ", @@ -3952,7 +4096,7 @@ fn bindgen_test_layout_pfioc_state_kill() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).psk_src as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).psk_src) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -3962,7 +4106,7 @@ fn bindgen_test_layout_pfioc_state_kill() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).psk_dst as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).psk_dst) as usize - ptr as usize }, 72usize, concat!( "Offset of field: ", @@ -3972,7 +4116,7 @@ fn bindgen_test_layout_pfioc_state_kill() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).psk_ifname as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).psk_ifname) as usize - ptr as usize }, 136usize, concat!( "Offset of field: ", @@ -3982,7 +4126,7 @@ fn bindgen_test_layout_pfioc_state_kill() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).psk_ownername as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).psk_ownername) as usize - ptr as usize }, 152usize, concat!( "Offset of field: ", @@ -4003,10 +4147,12 @@ pub struct pfioc_states { pub union pfioc_states__bindgen_ty_1 { pub psu_buf: caddr_t, pub psu_states: *mut pfsync_state, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_pfioc_states__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 8usize, @@ -4018,9 +4164,7 @@ fn bindgen_test_layout_pfioc_states__bindgen_ty_1() { concat!("Alignment of ", stringify!(pfioc_states__bindgen_ty_1)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).psu_buf as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).psu_buf) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4030,9 +4174,7 @@ fn bindgen_test_layout_pfioc_states__bindgen_ty_1() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).psu_states as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).psu_states) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4044,6 +4186,8 @@ fn bindgen_test_layout_pfioc_states__bindgen_ty_1() { } #[test] fn bindgen_test_layout_pfioc_states() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -4055,7 +4199,7 @@ fn bindgen_test_layout_pfioc_states() { concat!("Alignment of ", stringify!(pfioc_states)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ps_len as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ps_len) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4065,7 +4209,7 @@ fn bindgen_test_layout_pfioc_states() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).ps_u as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).ps_u) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", @@ -4083,7 +4227,7 @@ pub struct pfioc_trans { pub array: *mut pfioc_trans_pfioc_trans_e, } #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub struct pfioc_trans_pfioc_trans_e { pub rs_num: ::std::os::raw::c_int, pub anchor: [::std::os::raw::c_char; 1024usize], @@ -4091,6 +4235,9 @@ pub struct pfioc_trans_pfioc_trans_e { } #[test] fn bindgen_test_layout_pfioc_trans_pfioc_trans_e() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 1032usize, @@ -4102,9 +4249,7 @@ fn bindgen_test_layout_pfioc_trans_pfioc_trans_e() { concat!("Alignment of ", stringify!(pfioc_trans_pfioc_trans_e)) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).rs_num as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).rs_num) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4114,9 +4259,7 @@ fn bindgen_test_layout_pfioc_trans_pfioc_trans_e() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).anchor as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).anchor) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -4126,9 +4269,7 @@ fn bindgen_test_layout_pfioc_trans_pfioc_trans_e() { ) ); assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ticket as *const _ as usize - }, + unsafe { ::std::ptr::addr_of!((*ptr).ticket) as usize - ptr as usize }, 1028usize, concat!( "Offset of field: ", @@ -4140,6 +4281,8 @@ fn bindgen_test_layout_pfioc_trans_pfioc_trans_e() { } #[test] fn bindgen_test_layout_pfioc_trans() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::(), 16usize, @@ -4151,7 +4294,7 @@ fn bindgen_test_layout_pfioc_trans() { concat!("Alignment of ", stringify!(pfioc_trans)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).size as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", @@ -4161,7 +4304,7 @@ fn bindgen_test_layout_pfioc_trans() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).esize as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).esize) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", @@ -4171,7 +4314,7 @@ fn bindgen_test_layout_pfioc_trans() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).array as *const _ as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).array) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", From bc0c3429cae34f199703b52840639239cdc8e2da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Tue, 28 May 2024 15:13:16 +0200 Subject: [PATCH 7/7] Update rust code for new field names --- src/rule/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rule/mod.rs b/src/rule/mod.rs index bd541b5..9682fc6 100644 --- a/src/rule/mod.rs +++ b/src/rule/mod.rs @@ -457,8 +457,8 @@ impl CopyTo for IpNetwork { impl CopyTo for IpAddr { fn copy_to(&self, pf_addr: &mut ffi::pfvar::pf_addr) { match *self { - IpAddr::V4(ip) => ip.copy_to(unsafe { &mut pf_addr.pfa.v4 }), - IpAddr::V6(ip) => ip.copy_to(unsafe { &mut pf_addr.pfa.v6 }), + IpAddr::V4(ip) => ip.copy_to(unsafe { &mut pf_addr.pfa._v4addr }), + IpAddr::V6(ip) => ip.copy_to(unsafe { &mut pf_addr.pfa._v6addr }), } } }