xref: /freebsd/sys/netipsec/keysock.h (revision ea7be1293b48385f27b97c5f112e4cad93cbd33b)
188768458SSam Leffler /*	$FreeBSD$	*/
288768458SSam Leffler /*	$KAME: keysock.h,v 1.8 2000/03/27 05:11:06 sumikawa Exp $	*/
388768458SSam Leffler 
4c398230bSWarner Losh /*-
551369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
651369649SPedro F. Giffuni  *
788768458SSam Leffler  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
888768458SSam Leffler  * All rights reserved.
988768458SSam Leffler  *
1088768458SSam Leffler  * Redistribution and use in source and binary forms, with or without
1188768458SSam Leffler  * modification, are permitted provided that the following conditions
1288768458SSam Leffler  * are met:
1388768458SSam Leffler  * 1. Redistributions of source code must retain the above copyright
1488768458SSam Leffler  *    notice, this list of conditions and the following disclaimer.
1588768458SSam Leffler  * 2. Redistributions in binary form must reproduce the above copyright
1688768458SSam Leffler  *    notice, this list of conditions and the following disclaimer in the
1788768458SSam Leffler  *    documentation and/or other materials provided with the distribution.
1888768458SSam Leffler  * 3. Neither the name of the project nor the names of its contributors
1988768458SSam Leffler  *    may be used to endorse or promote products derived from this software
2088768458SSam Leffler  *    without specific prior written permission.
2188768458SSam Leffler  *
2288768458SSam Leffler  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
2388768458SSam Leffler  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2488768458SSam Leffler  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2588768458SSam Leffler  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2688768458SSam Leffler  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2788768458SSam Leffler  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2888768458SSam Leffler  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2988768458SSam Leffler  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3088768458SSam Leffler  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3188768458SSam Leffler  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3288768458SSam Leffler  * SUCH DAMAGE.
3388768458SSam Leffler  */
3488768458SSam Leffler 
3588768458SSam Leffler #ifndef _NETIPSEC_KEYSOCK_H_
3688768458SSam Leffler #define _NETIPSEC_KEYSOCK_H_
3788768458SSam Leffler 
3888768458SSam Leffler /* statistics for pfkey socket */
3988768458SSam Leffler struct pfkeystat {
4088768458SSam Leffler 	/* kernel -> userland */
41c80211e3SAndrey V. Elsukov 	uint64_t out_total;		/* # of total calls */
42c80211e3SAndrey V. Elsukov 	uint64_t out_bytes;		/* total bytecount */
43c80211e3SAndrey V. Elsukov 	uint64_t out_msgtype[256];	/* message type histogram */
44c80211e3SAndrey V. Elsukov 	uint64_t out_invlen;		/* invalid length field */
45c80211e3SAndrey V. Elsukov 	uint64_t out_invver;		/* invalid version field */
46c80211e3SAndrey V. Elsukov 	uint64_t out_invmsgtype;	/* invalid message type field */
47c80211e3SAndrey V. Elsukov 	uint64_t out_tooshort;		/* msg too short */
48c80211e3SAndrey V. Elsukov 	uint64_t out_nomem;		/* memory allocation failure */
49c80211e3SAndrey V. Elsukov 	uint64_t out_dupext;		/* duplicate extension */
50c80211e3SAndrey V. Elsukov 	uint64_t out_invexttype;	/* invalid extension type */
51c80211e3SAndrey V. Elsukov 	uint64_t out_invsatype;		/* invalid sa type */
52c80211e3SAndrey V. Elsukov 	uint64_t out_invaddr;		/* invalid address extension */
5388768458SSam Leffler 	/* userland -> kernel */
54c80211e3SAndrey V. Elsukov 	uint64_t in_total;		/* # of total calls */
55c80211e3SAndrey V. Elsukov 	uint64_t in_bytes;		/* total bytecount */
56c80211e3SAndrey V. Elsukov 	uint64_t in_msgtype[256];	/* message type histogram */
57c80211e3SAndrey V. Elsukov 	uint64_t in_msgtarget[3];	/* one/all/registered */
58c80211e3SAndrey V. Elsukov 	uint64_t in_nomem;		/* memory allocation failure */
5988768458SSam Leffler 	/* others */
60c80211e3SAndrey V. Elsukov 	uint64_t sockerr;		/* # of socket related errors */
6188768458SSam Leffler };
6288768458SSam Leffler 
6388768458SSam Leffler #define KEY_SENDUP_ONE		0
6488768458SSam Leffler #define KEY_SENDUP_ALL		1
6588768458SSam Leffler #define KEY_SENDUP_REGISTERED	2
6688768458SSam Leffler 
6788768458SSam Leffler #ifdef _KERNEL
68db8c0879SAndrey V. Elsukov #include <sys/counter.h>
69db8c0879SAndrey V. Elsukov 
70*ea7be129SGleb Smirnoff SYSCTL_DECL(_net_key);
71*ea7be129SGleb Smirnoff 
7288768458SSam Leffler struct keycb {
73*ea7be129SGleb Smirnoff 	LIST_ENTRY(keycb) kp_next;
74*ea7be129SGleb Smirnoff 	struct socket *kp_socket;
7588768458SSam Leffler 	int kp_promisc;		/* promiscuous mode */
7688768458SSam Leffler 	int kp_registered;	/* registered socket */
7788768458SSam Leffler };
7888768458SSam Leffler 
79db8c0879SAndrey V. Elsukov VNET_PCPUSTAT_DECLARE(struct pfkeystat, pfkeystat);
80db8c0879SAndrey V. Elsukov #define	PFKEYSTAT_ADD(name, val)	\
81db8c0879SAndrey V. Elsukov     VNET_PCPUSTAT_ADD(struct pfkeystat, pfkeystat, name, (val))
82a04d64d8SAndrey V. Elsukov #define	PFKEYSTAT_INC(name)		PFKEYSTAT_ADD(name, 1)
8388768458SSam Leffler 
8426cb1e1dSAndrey V. Elsukov int key_output(struct mbuf *m, struct socket *so, ...);
8526cb1e1dSAndrey V. Elsukov int key_sendup_mbuf(struct socket *, struct mbuf *, int);
8688768458SSam Leffler #endif /* _KERNEL */
8788768458SSam Leffler 
8888768458SSam Leffler #endif /*_NETIPSEC_KEYSOCK_H_*/
89