154359Sroberto/* $KAME: keysock.h,v 1.8 2000/03/27 05:11:06 sumikawa Exp $ */ 254359Sroberto 3132451Sroberto/*- 4132451Sroberto * SPDX-License-Identifier: BSD-3-Clause 5132451Sroberto * 654359Sroberto * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 7285612Sdelphij * All rights reserved. 8330141Sdelphij * 9285612Sdelphij * Redistribution and use in source and binary forms, with or without 10285612Sdelphij * modification, are permitted provided that the following conditions 11330141Sdelphij * are met: 1282498Sroberto * 1. Redistributions of source code must retain the above copyright 1382498Sroberto * notice, this list of conditions and the following disclaimer. 14182007Sroberto * 2. Redistributions in binary form must reproduce the above copyright 15285612Sdelphij * notice, this list of conditions and the following disclaimer in the 16285612Sdelphij * documentation and/or other materials provided with the distribution. 17285612Sdelphij * 3. Neither the name of the project nor the names of its contributors 18285612Sdelphij * may be used to endorse or promote products derived from this software 19330141Sdelphij * without specific prior written permission. 2054359Sroberto * 2154359Sroberto * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2254359Sroberto * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2354359Sroberto * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2454359Sroberto * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2554359Sroberto * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2654359Sroberto * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2754359Sroberto * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2854359Sroberto * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2954359Sroberto * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3054359Sroberto * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31293650Sglebius * SUCH DAMAGE. 32293650Sglebius */ 33285612Sdelphij 34330141Sdelphij#ifndef _NETIPSEC_KEYSOCK_H_ 35330141Sdelphij#define _NETIPSEC_KEYSOCK_H_ 36330141Sdelphij 37285612Sdelphij/* statistics for pfkey socket */ 38285612Sdelphijstruct pfkeystat { 39285612Sdelphij /* kernel -> userland */ 40285612Sdelphij uint64_t out_total; /* # of total calls */ 4154359Sroberto uint64_t out_bytes; /* total bytecount */ 42132451Sroberto uint64_t out_msgtype[256]; /* message type histogram */ 43132451Sroberto uint64_t out_invlen; /* invalid length field */ 44285612Sdelphij uint64_t out_invver; /* invalid version field */ 45285612Sdelphij uint64_t out_invmsgtype; /* invalid message type field */ 46285612Sdelphij uint64_t out_tooshort; /* msg too short */ 47285612Sdelphij uint64_t out_nomem; /* memory allocation failure */ 48132451Sroberto uint64_t out_dupext; /* duplicate extension */ 49285612Sdelphij uint64_t out_invexttype; /* invalid extension type */ 50285612Sdelphij uint64_t out_invsatype; /* invalid sa type */ 51285612Sdelphij uint64_t out_invaddr; /* invalid address extension */ 52285612Sdelphij /* userland -> kernel */ 53285612Sdelphij uint64_t in_total; /* # of total calls */ 54285612Sdelphij uint64_t in_bytes; /* total bytecount */ 55285612Sdelphij uint64_t in_msgtype[256]; /* message type histogram */ 56285612Sdelphij uint64_t in_msgtarget[3]; /* one/all/registered */ 57285612Sdelphij uint64_t in_nomem; /* memory allocation failure */ 58285612Sdelphij /* others */ 59285612Sdelphij uint64_t sockerr; /* # of socket related errors */ 60285612Sdelphij}; 61285612Sdelphij 62285612Sdelphij#define KEY_SENDUP_ONE 0 63285612Sdelphij#define KEY_SENDUP_ALL 1 64285612Sdelphij#define KEY_SENDUP_REGISTERED 2 65285612Sdelphij 66285612Sdelphij#ifdef _KERNEL 67285612Sdelphij#include <sys/counter.h> 68285612Sdelphij 69285612SdelphijSYSCTL_DECL(_net_key); 70285612Sdelphij 71285612Sdelphijstruct keycb { 72285612Sdelphij LIST_ENTRY(keycb) kp_next; 73285612Sdelphij struct socket *kp_socket; 74285612Sdelphij int kp_promisc; /* promiscuous mode */ 75285612Sdelphij int kp_registered; /* registered socket */ 76285612Sdelphij}; 7754359Sroberto 78285612SdelphijVNET_PCPUSTAT_DECLARE(struct pfkeystat, pfkeystat); 79285612Sdelphij#define PFKEYSTAT_ADD(name, val) \ 80285612Sdelphij VNET_PCPUSTAT_ADD(struct pfkeystat, pfkeystat, name, (val)) 81285612Sdelphij#define PFKEYSTAT_INC(name) PFKEYSTAT_ADD(name, 1) 82132451Sroberto 83285612Sdelphijint key_output(struct mbuf *m, struct socket *so, ...); 84285612Sdelphijint key_sendup_mbuf(struct socket *, struct mbuf *, int); 8554359Sroberto#endif /* _KERNEL */ 86132451Sroberto 87285612Sdelphij#endif /*_NETIPSEC_KEYSOCK_H_*/ 88285612Sdelphij