xref: /dflybsd-src/sys/netgraph7/ksocket/ng_ksocket.h (revision cbc43ac303b5f81e556596e8539e323c1e403c1d)
149191e0fSNuno Antunes /*
249191e0fSNuno Antunes  * ng_ksocket.h
349191e0fSNuno Antunes  */
449191e0fSNuno Antunes 
549191e0fSNuno Antunes /*-
649191e0fSNuno Antunes  * Copyright (c) 1996-1999 Whistle Communications, Inc.
749191e0fSNuno Antunes  * All rights reserved.
849191e0fSNuno Antunes  *
949191e0fSNuno Antunes  * Subject to the following obligations and disclaimer of warranty, use and
1049191e0fSNuno Antunes  * redistribution of this software, in source or object code forms, with or
1149191e0fSNuno Antunes  * without modifications are expressly permitted by Whistle Communications;
1249191e0fSNuno Antunes  * provided, however, that:
1349191e0fSNuno Antunes  * 1. Any and all reproductions of the source or object code must include the
1449191e0fSNuno Antunes  *    copyright notice above and the following disclaimer of warranties; and
1549191e0fSNuno Antunes  * 2. No rights are granted, in any manner or form, to use Whistle
1649191e0fSNuno Antunes  *    Communications, Inc. trademarks, including the mark "WHISTLE
1749191e0fSNuno Antunes  *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
1849191e0fSNuno Antunes  *    such appears in the above copyright notice or in the software.
1949191e0fSNuno Antunes  *
2049191e0fSNuno Antunes  * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
2149191e0fSNuno Antunes  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
2249191e0fSNuno Antunes  * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
2349191e0fSNuno Antunes  * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
2449191e0fSNuno Antunes  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
2549191e0fSNuno Antunes  * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
2649191e0fSNuno Antunes  * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
2749191e0fSNuno Antunes  * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
2849191e0fSNuno Antunes  * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
2949191e0fSNuno Antunes  * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
3049191e0fSNuno Antunes  * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
3149191e0fSNuno Antunes  * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
3249191e0fSNuno Antunes  * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
3349191e0fSNuno Antunes  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3449191e0fSNuno Antunes  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3549191e0fSNuno Antunes  * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
3649191e0fSNuno Antunes  * OF SUCH DAMAGE.
3749191e0fSNuno Antunes  *
3849191e0fSNuno Antunes  * Author: Archie Cobbs <archie@freebsd.org>
3949191e0fSNuno Antunes  *
4049191e0fSNuno Antunes  * $FreeBSD: src/sys/netgraph/ng_ksocket.h,v 1.13 2005/10/28 14:41:28 ru Exp $
4149191e0fSNuno Antunes  * $Whistle: ng_ksocket.h,v 1.1 1999/11/16 20:04:40 archie Exp $
4249191e0fSNuno Antunes  */
4349191e0fSNuno Antunes 
4449191e0fSNuno Antunes #ifndef _NETGRAPH_NG_KSOCKET_H_
4549191e0fSNuno Antunes #define _NETGRAPH_NG_KSOCKET_H_
4649191e0fSNuno Antunes 
47*cbc43ac3SSascha Wildner #include <sys/types.h>
4849191e0fSNuno Antunes #include <sys/socket.h>
4949191e0fSNuno Antunes 
5049191e0fSNuno Antunes /* Node type name and magic cookie */
5149191e0fSNuno Antunes #define NG_KSOCKET_NODE_TYPE	"ksocket"
5249191e0fSNuno Antunes #define NGM_KSOCKET_COOKIE	942710669
5349191e0fSNuno Antunes 
5449191e0fSNuno Antunes /* For NGM_KSOCKET_SETOPT and NGM_KSOCKET_GETOPT control messages */
5549191e0fSNuno Antunes struct ng_ksocket_sockopt {
5649191e0fSNuno Antunes 	int32_t		level;		/* second arg of [gs]etsockopt() */
5749191e0fSNuno Antunes 	int32_t		name;		/* third arg of [gs]etsockopt() */
5849191e0fSNuno Antunes 	u_char		value[];	/* fourth arg of [gs]etsockopt() */
5949191e0fSNuno Antunes };
6049191e0fSNuno Antunes 
6149191e0fSNuno Antunes /* Max length socket option we can return via NGM_KSOCKET_GETOPT
6249191e0fSNuno Antunes    XXX This should not be necessary, we should dynamically size
6349191e0fSNuno Antunes    XXX the response. Until then.. */
6449191e0fSNuno Antunes #define NG_KSOCKET_MAX_OPTLEN	1024
6549191e0fSNuno Antunes 
6649191e0fSNuno Antunes /* Keep this in sync with the above structure definition */
6749191e0fSNuno Antunes #define NG_KSOCKET_SOCKOPT_INFO(svtype)	{			\
6849191e0fSNuno Antunes 	  { "level",		&ng_parse_int32_type	},	\
6949191e0fSNuno Antunes 	  { "name",		&ng_parse_int32_type	},	\
7049191e0fSNuno Antunes 	  { "value",		(svtype)		},	\
7149191e0fSNuno Antunes 	  { NULL }						\
7249191e0fSNuno Antunes }
7349191e0fSNuno Antunes 
7449191e0fSNuno Antunes /* For NGM_KSOCKET_ACCEPT control message responses */
7549191e0fSNuno Antunes struct ng_ksocket_accept {
7649191e0fSNuno Antunes 	u_int32_t	nodeid;		/* node ID of connected ksocket */
7749191e0fSNuno Antunes 	struct sockaddr	addr;		/* peer's address (variable length) */
7849191e0fSNuno Antunes };
7949191e0fSNuno Antunes 
8049191e0fSNuno Antunes /* Keep this in sync with the above structure definition */
8149191e0fSNuno Antunes #define	NGM_KSOCKET_ACCEPT_INFO {					\
8249191e0fSNuno Antunes 	  { "nodeid",		&ng_parse_hint32_type		  },	\
8349191e0fSNuno Antunes 	  { "addr",		&ng_ksocket_generic_sockaddr_type },	\
8449191e0fSNuno Antunes 	  { NULL }							\
8549191e0fSNuno Antunes }
8649191e0fSNuno Antunes 
8749191e0fSNuno Antunes /* Netgraph commands */
8849191e0fSNuno Antunes enum {
8949191e0fSNuno Antunes 	NGM_KSOCKET_BIND = 1,
9049191e0fSNuno Antunes 	NGM_KSOCKET_LISTEN,
9149191e0fSNuno Antunes 	NGM_KSOCKET_ACCEPT,
9249191e0fSNuno Antunes 	NGM_KSOCKET_CONNECT,
9349191e0fSNuno Antunes 	NGM_KSOCKET_GETNAME,
9449191e0fSNuno Antunes 	NGM_KSOCKET_GETPEERNAME,
9549191e0fSNuno Antunes 	NGM_KSOCKET_SETOPT,
9649191e0fSNuno Antunes 	NGM_KSOCKET_GETOPT,
9749191e0fSNuno Antunes };
9849191e0fSNuno Antunes 
9949191e0fSNuno Antunes #ifdef _KERNEL
10049191e0fSNuno Antunes 
10149191e0fSNuno Antunes /* Structure for sockaddr tag */
10249191e0fSNuno Antunes struct sa_tag {
10349191e0fSNuno Antunes 	struct m_tag	tag;
10449191e0fSNuno Antunes 	ng_ID_t		id;
10549191e0fSNuno Antunes 	struct sockaddr	sa;
10649191e0fSNuno Antunes };
10749191e0fSNuno Antunes 
10849191e0fSNuno Antunes /* Tag information ID's */
10949191e0fSNuno Antunes #define NG_KSOCKET_TAG_SOCKADDR	1	/* data is struct sockaddr */
11049191e0fSNuno Antunes 
11149191e0fSNuno Antunes #endif /* _KERNEL */
11249191e0fSNuno Antunes #endif /* _NETGRAPH_NG_KSOCKET_H_ */
113