/*-
* Copyright (c) 2009-2025 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This material is based upon work partially supported by The
* NetBSD Foundation under a contract with Mindaugas Rasiukevicius.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* Storage of address (both for IPv4 and IPv6) and netmask.
*/
typedef union {
uint8_t word8[16];
uint16_t word16[8];
uint32_t word32[4];
} npf_addr_t;
/*
* use a single type for both user id and group id
*/
struct r_id {
uint32_t id[2];
uint8_t op;
};
typedef struct {
/* NPF context, information flags and the nbuf. */
npf_t * npc_ctx;
uint32_t npc_info;
nbuf_t * npc_nbuf;
/*
* Pointers to the IP source and destination addresses,
* and the address length (4 for IPv4 or 16 for IPv6).
*/
npf_addr_t * npc_ips[2];
uint8_t npc_alen;
/* IP header length and L4 protocol. */
uint32_t npc_hlen;
uint16_t npc_proto;
/* IPv4, IPv6. */
union {
struct ip * v4;
struct ip6_hdr * v6;
} npc_ip;
/*
* Override the connection key, if not NULL. This affects the
* behaviour of npf_conn_lookup() and npf_conn_establish().
* Note: npc_ckey is of npf_connkey_t type.
*/
const void * npc_ckey;
} npf_cache_t;