/*-
* Copyright (c) 2009-2020 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.
*/
/*
* The main connection tracking structure.
*/
struct npf_conn {
/*
* Protocol, address length, the interface ID (if zero,
* then the state is global) and connection flags.
*/
uint16_t c_proto;
uint16_t c_alen;
unsigned c_ifid;
unsigned c_flags;
/*
* Entry in the connection database/list. The entry is
* protected by npf_t::conn_lock.
*/
union {
npf_conn_t * c_next;
LIST_ENTRY(npf_conn) c_entry;
};
/*
* The Reference count and the last activity time (used to
* calculate expiration time). Note: *unsigned* 32-bit integer
* as a timestamp is sufficient for us.
*/
unsigned c_refcnt;
uint32_t c_atime;
/* The protocol state and lock. */
kmutex_t c_lock;
npf_state_t c_state;
/*
* Connection "forwards" and "backwards" keys. They are accessed
* as npf_connkey_t, see below and npf_conn_getkey().
*/
uint32_t c_keys[];
};
typedef struct {
int connkey_interface;
int connkey_direction;
} npf_conn_params_t;
#endif
/*
* Connection key interface.
*
* See the key layout description in the npf_connkey.c source file.
*/