153246Sarchie/*
253246Sarchie * ng_ksocket.h
3139823Simp */
4139823Simp
5139823Simp/*-
653246Sarchie * Copyright (c) 1996-1999 Whistle Communications, Inc.
753246Sarchie * All rights reserved.
853246Sarchie *
953246Sarchie * Subject to the following obligations and disclaimer of warranty, use and
1053246Sarchie * redistribution of this software, in source or object code forms, with or
1153246Sarchie * without modifications are expressly permitted by Whistle Communications;
1253246Sarchie * provided, however, that:
1353246Sarchie * 1. Any and all reproductions of the source or object code must include the
1453246Sarchie *    copyright notice above and the following disclaimer of warranties; and
1553246Sarchie * 2. No rights are granted, in any manner or form, to use Whistle
1653246Sarchie *    Communications, Inc. trademarks, including the mark "WHISTLE
1753246Sarchie *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
1853246Sarchie *    such appears in the above copyright notice or in the software.
1953246Sarchie *
2053246Sarchie * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
2153246Sarchie * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
2253246Sarchie * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
2353246Sarchie * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
2453246Sarchie * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
2553246Sarchie * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
2653246Sarchie * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
2753246Sarchie * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
2853246Sarchie * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
2953246Sarchie * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
3053246Sarchie * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
3153246Sarchie * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
3253246Sarchie * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
3353246Sarchie * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3453246Sarchie * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3553246Sarchie * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
3653246Sarchie * OF SUCH DAMAGE.
3753246Sarchie *
3867506Sjulian * Author: Archie Cobbs <archie@freebsd.org>
3953246Sarchie *
4053246Sarchie * $FreeBSD$
4153246Sarchie * $Whistle: ng_ksocket.h,v 1.1 1999/11/16 20:04:40 archie Exp $
4253246Sarchie */
4353246Sarchie
44122481Sru#ifndef _NETGRAPH_NG_KSOCKET_H_
45122481Sru#define _NETGRAPH_NG_KSOCKET_H_
4653246Sarchie
4783186Sjulian#include <sys/socket.h>
4883186Sjulian
4953246Sarchie/* Node type name and magic cookie */
5053246Sarchie#define NG_KSOCKET_NODE_TYPE	"ksocket"
5153246Sarchie#define NGM_KSOCKET_COOKIE	942710669
5253246Sarchie
5353913Sarchie/* For NGM_KSOCKET_SETOPT and NGM_KSOCKET_GETOPT control messages */
5453913Sarchiestruct ng_ksocket_sockopt {
5564511Sarchie	int32_t		level;		/* second arg of [gs]etsockopt() */
5664511Sarchie	int32_t		name;		/* third arg of [gs]etsockopt() */
57151800Sru	u_char		value[];	/* fourth arg of [gs]etsockopt() */
5853913Sarchie};
5953913Sarchie
6053913Sarchie/* Max length socket option we can return via NGM_KSOCKET_GETOPT
6153913Sarchie   XXX This should not be necessary, we should dynamically size
6253913Sarchie   XXX the response. Until then.. */
6353913Sarchie#define NG_KSOCKET_MAX_OPTLEN	1024
6453913Sarchie
6553913Sarchie/* Keep this in sync with the above structure definition */
6653913Sarchie#define NG_KSOCKET_SOCKOPT_INFO(svtype)	{			\
6753913Sarchie	  { "level",		&ng_parse_int32_type	},	\
6853913Sarchie	  { "name",		&ng_parse_int32_type	},	\
6953913Sarchie	  { "value",		(svtype)		},	\
7097685Sarchie	  { NULL }						\
7153913Sarchie}
7253913Sarchie
7383186Sjulian/* For NGM_KSOCKET_ACCEPT control message responses */
7483186Sjulianstruct ng_ksocket_accept {
7583186Sjulian	u_int32_t	nodeid;		/* node ID of connected ksocket */
7683186Sjulian	struct sockaddr	addr;		/* peer's address (variable length) */
7783186Sjulian};
7883186Sjulian
7983186Sjulian/* Keep this in sync with the above structure definition */
8083186Sjulian#define	NGM_KSOCKET_ACCEPT_INFO {					\
8183186Sjulian	  { "nodeid",		&ng_parse_hint32_type		  },	\
8283186Sjulian	  { "addr",		&ng_ksocket_generic_sockaddr_type },	\
8383186Sjulian	  { NULL }							\
8483186Sjulian}
8583186Sjulian
8653246Sarchie/* Netgraph commands */
8753246Sarchieenum {
8853246Sarchie	NGM_KSOCKET_BIND = 1,
8953246Sarchie	NGM_KSOCKET_LISTEN,
9053246Sarchie	NGM_KSOCKET_ACCEPT,
9153246Sarchie	NGM_KSOCKET_CONNECT,
9253246Sarchie	NGM_KSOCKET_GETNAME,
9353246Sarchie	NGM_KSOCKET_GETPEERNAME,
9453246Sarchie	NGM_KSOCKET_SETOPT,
9553246Sarchie	NGM_KSOCKET_GETOPT,
9653246Sarchie};
9753246Sarchie
98131117Sjulian#ifdef _KERNEL
99131117Sjulian
100131108Sjulian/* Structure for sockaddr tag */
101131108Sjulianstruct sa_tag {
102131108Sjulian	struct m_tag	tag;
103141728Sglebius	ng_ID_t		id;
104131108Sjulian	struct sockaddr	sa;
105131108Sjulian};
10687070Sarchie
107131108Sjulian/* Tag information ID's */
108131108Sjulian#define NG_KSOCKET_TAG_SOCKADDR	1	/* data is struct sockaddr */
109131108Sjulian
110131117Sjulian#endif /* _KERNEL */
111122481Sru#endif /* _NETGRAPH_NG_KSOCKET_H_ */
112