keysock.h revision 195727
127897Sfsmp/*	$FreeBSD: head/sys/netipsec/keysock.h 195727 2009-07-16 21:13:04Z rwatson $	*/
2208291Suqs/*	$KAME: keysock.h,v 1.8 2000/03/27 05:11:06 sumikawa Exp $	*/
327897Sfsmp
427897Sfsmp/*-
527897Sfsmp * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
627897Sfsmp * All rights reserved.
727897Sfsmp *
827897Sfsmp * Redistribution and use in source and binary forms, with or without
927897Sfsmp * modification, are permitted provided that the following conditions
1027897Sfsmp * are met:
1127897Sfsmp * 1. Redistributions of source code must retain the above copyright
1227897Sfsmp *    notice, this list of conditions and the following disclaimer.
1327897Sfsmp * 2. Redistributions in binary form must reproduce the above copyright
1427897Sfsmp *    notice, this list of conditions and the following disclaimer in the
1527897Sfsmp *    documentation and/or other materials provided with the distribution.
1627897Sfsmp * 3. Neither the name of the project nor the names of its contributors
1727897Sfsmp *    may be used to endorse or promote products derived from this software
1827897Sfsmp *    without specific prior written permission.
1927897Sfsmp *
2027897Sfsmp * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
2127897Sfsmp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2252676Sphantom * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2348795Snik * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2450476Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2548795Snik * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26191953Sivoras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2727897Sfsmp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2879538Sru * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2927897Sfsmp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3027897Sfsmp * SUCH DAMAGE.
31138999Sjkoshy */
3227897Sfsmp
33107664Srwatson#ifndef _NETIPSEC_KEYSOCK_H_
3427897Sfsmp#define _NETIPSEC_KEYSOCK_H_
3527897Sfsmp
3679727Sschweikh/* statistics for pfkey socket */
37138999Sjkoshystruct pfkeystat {
3827897Sfsmp	/* kernel -> userland */
39113820Sjhb	u_quad_t out_total;		/* # of total calls */
40107700Sru	u_quad_t out_bytes;		/* total bytecount */
41107700Sru	u_quad_t out_msgtype[256];	/* message type histogram */
42268351Smarcel	u_quad_t out_invlen;		/* invalid length field */
43107664Srwatson	u_quad_t out_invver;		/* invalid version field */
44107664Srwatson	u_quad_t out_invmsgtype;	/* invalid message type field */
45127378Sjhb	u_quad_t out_tooshort;		/* msg too short */
46127378Sjhb	u_quad_t out_nomem;		/* memory allocation failure */
47127378Sjhb	u_quad_t out_dupext;		/* duplicate extension */
48107663Srwatson	u_quad_t out_invexttype;	/* invalid extension type */
4927897Sfsmp	u_quad_t out_invsatype;		/* invalid sa type */
5027897Sfsmp	u_quad_t out_invaddr;		/* invalid address extension */
5127897Sfsmp	/* userland -> kernel */
52107664Srwatson	u_quad_t in_total;		/* # of total calls */
53107664Srwatson	u_quad_t in_bytes;		/* total bytecount */
54107664Srwatson	u_quad_t in_msgtype[256];	/* message type histogram */
55127378Sjhb	u_quad_t in_msgtarget[3];	/* one/all/registered */
56107664Srwatson	u_quad_t in_nomem;		/* memory allocation failure */
57107663Srwatson	/* others */
58107663Srwatson	u_quad_t sockerr;		/* # of socket related errors */
59113820Sjhb};
60138999Sjkoshy
61138999Sjkoshy#define KEY_SENDUP_ONE		0
62138999Sjkoshy#define KEY_SENDUP_ALL		1
63138999Sjkoshy#define KEY_SENDUP_REGISTERED	2
64113820Sjhb
65138999Sjkoshy#ifdef _KERNEL
66224528Savgstruct keycb {
67224528Savg	struct rawcb kp_raw;	/* rawcb */
68224528Savg	int kp_promisc;		/* promiscuous mode */
69224528Savg	int kp_registered;	/* registered socket */
70138999Sjkoshy};
71138999Sjkoshy
72191953SivorasVNET_DECLARE(struct pfkeystat, pfkeystat);
73191953Sivoras#define	V_pfkeystat		VNET(pfkeystat)
74191953Sivoras
75191953Sivorasextern int key_output(struct mbuf *m, struct socket *so);
76191953Sivorasextern int key_usrreq __P((struct socket *,
77191953Sivoras	int, struct mbuf *, struct mbuf *, struct mbuf *));
78191953Sivoras
79191953Sivorasextern int key_sendup __P((struct socket *, struct sadb_msg *, u_int, int));
80191953Sivorasextern int key_sendup_mbuf __P((struct socket *, struct mbuf *, int));
81191953Sivoras#endif /* _KERNEL */
82191953Sivoras
83191953Sivoras#endif /*_NETIPSEC_KEYSOCK_H_*/
84191953Sivoras