xref: /freebsd/sys/netipsec/keysock.h (revision f6a3b357e9be4c6423c85eff9a847163a0d307c8)
1 /*	$FreeBSD$	*/
2 /*	$KAME: keysock.h,v 1.8 2000/03/27 05:11:06 sumikawa Exp $	*/
3 
4 /*-
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of the project nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  */
34 
35 #ifndef _NETIPSEC_KEYSOCK_H_
36 #define _NETIPSEC_KEYSOCK_H_
37 
38 /* statistics for pfkey socket */
39 struct pfkeystat {
40 	/* kernel -> userland */
41 	uint64_t out_total;		/* # of total calls */
42 	uint64_t out_bytes;		/* total bytecount */
43 	uint64_t out_msgtype[256];	/* message type histogram */
44 	uint64_t out_invlen;		/* invalid length field */
45 	uint64_t out_invver;		/* invalid version field */
46 	uint64_t out_invmsgtype;	/* invalid message type field */
47 	uint64_t out_tooshort;		/* msg too short */
48 	uint64_t out_nomem;		/* memory allocation failure */
49 	uint64_t out_dupext;		/* duplicate extension */
50 	uint64_t out_invexttype;	/* invalid extension type */
51 	uint64_t out_invsatype;		/* invalid sa type */
52 	uint64_t out_invaddr;		/* invalid address extension */
53 	/* userland -> kernel */
54 	uint64_t in_total;		/* # of total calls */
55 	uint64_t in_bytes;		/* total bytecount */
56 	uint64_t in_msgtype[256];	/* message type histogram */
57 	uint64_t in_msgtarget[3];	/* one/all/registered */
58 	uint64_t in_nomem;		/* memory allocation failure */
59 	/* others */
60 	uint64_t sockerr;		/* # of socket related errors */
61 };
62 
63 #define KEY_SENDUP_ONE		0
64 #define KEY_SENDUP_ALL		1
65 #define KEY_SENDUP_REGISTERED	2
66 
67 #ifdef _KERNEL
68 #include <sys/counter.h>
69 
70 struct keycb {
71 	struct rawcb kp_raw;	/* rawcb */
72 	int kp_promisc;		/* promiscuous mode */
73 	int kp_registered;	/* registered socket */
74 };
75 
76 VNET_PCPUSTAT_DECLARE(struct pfkeystat, pfkeystat);
77 #define	PFKEYSTAT_ADD(name, val)	\
78     VNET_PCPUSTAT_ADD(struct pfkeystat, pfkeystat, name, (val))
79 #define	PFKEYSTAT_INC(name)		PFKEYSTAT_ADD(name, 1)
80 
81 int key_output(struct mbuf *m, struct socket *so, ...);
82 int key_sendup_mbuf(struct socket *, struct mbuf *, int);
83 #endif /* _KERNEL */
84 
85 #endif /*_NETIPSEC_KEYSOCK_H_*/
86