keysock.h revision 253081
1109864Sjeff/*	$FreeBSD: head/sys/netipsec/keysock.h 253081 2013-07-09 09:32:06Z ae $	*/
2165762Sjeff/*	$KAME: keysock.h,v 1.8 2000/03/27 05:11:06 sumikawa Exp $	*/
3109864Sjeff
4109864Sjeff/*-
5109864Sjeff * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6109864Sjeff * All rights reserved.
7109864Sjeff *
8109864Sjeff * Redistribution and use in source and binary forms, with or without
9109864Sjeff * modification, are permitted provided that the following conditions
10109864Sjeff * are met:
11109864Sjeff * 1. Redistributions of source code must retain the above copyright
12109864Sjeff *    notice, this list of conditions and the following disclaimer.
13109864Sjeff * 2. Redistributions in binary form must reproduce the above copyright
14109864Sjeff *    notice, this list of conditions and the following disclaimer in the
15109864Sjeff *    documentation and/or other materials provided with the distribution.
16109864Sjeff * 3. Neither the name of the project nor the names of its contributors
17109864Sjeff *    may be used to endorse or promote products derived from this software
18109864Sjeff *    without specific prior written permission.
19109864Sjeff *
20109864Sjeff * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21109864Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22109864Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23109864Sjeff * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24109864Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25109864Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26109864Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27171482Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28171482Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29171482Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30171482Sjeff * SUCH DAMAGE.
31171482Sjeff */
32171482Sjeff
33172293Sjeff#ifndef _NETIPSEC_KEYSOCK_H_
34171482Sjeff#define _NETIPSEC_KEYSOCK_H_
35171482Sjeff
36171482Sjeff/* statistics for pfkey socket */
37171482Sjeffstruct pfkeystat {
38116182Sobrien	/* kernel -> userland */
39191645Sjeff	uint64_t out_total;		/* # of total calls */
40116182Sobrien	uint64_t out_bytes;		/* total bytecount */
41147565Speter	uint64_t out_msgtype[256];	/* message type histogram */
42179297Sjb	uint64_t out_invlen;		/* invalid length field */
43147565Speter	uint64_t out_invver;		/* invalid version field */
44134649Sscottl	uint64_t out_invmsgtype;	/* invalid message type field */
45109864Sjeff	uint64_t out_tooshort;		/* msg too short */
46109864Sjeff	uint64_t out_nomem;		/* memory allocation failure */
47131929Smarcel	uint64_t out_dupext;		/* duplicate extension */
48109864Sjeff	uint64_t out_invexttype;	/* invalid extension type */
49109864Sjeff	uint64_t out_invsatype;		/* invalid sa type */
50109864Sjeff	uint64_t out_invaddr;		/* invalid address extension */
51109864Sjeff	/* userland -> kernel */
52109864Sjeff	uint64_t in_total;		/* # of total calls */
53112966Sjeff	uint64_t in_bytes;		/* total bytecount */
54122038Sjeff	uint64_t in_msgtype[256];	/* message type histogram */
55109864Sjeff	uint64_t in_msgtarget[3];	/* one/all/registered */
56235459Srstone	uint64_t in_nomem;		/* memory allocation failure */
57109864Sjeff	/* others */
58109864Sjeff	uint64_t sockerr;		/* # of socket related errors */
59109864Sjeff};
60109864Sjeff
61139453Sjhb#define KEY_SENDUP_ONE		0
62161599Sdavidxu#define KEY_SENDUP_ALL		1
63109864Sjeff#define KEY_SENDUP_REGISTERED	2
64176735Sjeff
65184439Sivoras#ifdef _KERNEL
66109864Sjeffstruct keycb {
67145256Sjkoshy	struct rawcb kp_raw;	/* rawcb */
68145256Sjkoshy	int kp_promisc;		/* promiscuous mode */
69145256Sjkoshy	int kp_registered;	/* registered socket */
70145256Sjkoshy};
71179297Sjb
72179297SjbVNET_DECLARE(struct pfkeystat, pfkeystat);
73179297Sjb#define	PFKEYSTAT_ADD(name, val)	V_pfkeystat.name += (val)
74179297Sjb#define	PFKEYSTAT_INC(name)		PFKEYSTAT_ADD(name, 1)
75179297Sjb#define	V_pfkeystat		VNET(pfkeystat)
76179297Sjb
77109864Sjeffextern int key_output(struct mbuf *m, struct socket *so);
78121790Sjeffextern int key_usrreq __P((struct socket *,
79109864Sjeff	int, struct mbuf *, struct mbuf *, struct mbuf *));
80236141Sraj
81172345Sjeffextern int key_sendup __P((struct socket *, struct sadb_msg *, u_int, int));
82166190Sjeffextern int key_sendup_mbuf __P((struct socket *, struct mbuf *, int));
83166190Sjeff#endif /* _KERNEL */
84171482Sjeff
85166137Sjeff#endif /*_NETIPSEC_KEYSOCK_H_*/
86187679Sjeff