xref: /freebsd/sys/netgraph/ng_message.h (revision b57a79658b78d76a39aab4ac895c6e8585eb744f)
14cf49a43SJulian Elischer 
24cf49a43SJulian Elischer /*
34cf49a43SJulian Elischer  * ng_message.h
44cf49a43SJulian Elischer  *
54cf49a43SJulian Elischer  * Copyright (c) 1996-1999 Whistle Communications, Inc.
64cf49a43SJulian Elischer  * All rights reserved.
74cf49a43SJulian Elischer  *
84cf49a43SJulian Elischer  * Subject to the following obligations and disclaimer of warranty, use and
94cf49a43SJulian Elischer  * redistribution of this software, in source or object code forms, with or
104cf49a43SJulian Elischer  * without modifications are expressly permitted by Whistle Communications;
114cf49a43SJulian Elischer  * provided, however, that:
124cf49a43SJulian Elischer  * 1. Any and all reproductions of the source or object code must include the
134cf49a43SJulian Elischer  *    copyright notice above and the following disclaimer of warranties; and
144cf49a43SJulian Elischer  * 2. No rights are granted, in any manner or form, to use Whistle
154cf49a43SJulian Elischer  *    Communications, Inc. trademarks, including the mark "WHISTLE
164cf49a43SJulian Elischer  *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
174cf49a43SJulian Elischer  *    such appears in the above copyright notice or in the software.
184cf49a43SJulian Elischer  *
194cf49a43SJulian Elischer  * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
204cf49a43SJulian Elischer  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
214cf49a43SJulian Elischer  * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
224cf49a43SJulian Elischer  * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
234cf49a43SJulian Elischer  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
244cf49a43SJulian Elischer  * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
254cf49a43SJulian Elischer  * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
264cf49a43SJulian Elischer  * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
274cf49a43SJulian Elischer  * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
284cf49a43SJulian Elischer  * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
294cf49a43SJulian Elischer  * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
304cf49a43SJulian Elischer  * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
314cf49a43SJulian Elischer  * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
324cf49a43SJulian Elischer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
334cf49a43SJulian Elischer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
344cf49a43SJulian Elischer  * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
354cf49a43SJulian Elischer  * OF SUCH DAMAGE.
364cf49a43SJulian Elischer  *
37cc3bbd68SJulian Elischer  * Author: Julian Elischer <julian@freebsd.org>
384cf49a43SJulian Elischer  *
394cf49a43SJulian Elischer  * $FreeBSD$
404cf49a43SJulian Elischer  * $Whistle: ng_message.h,v 1.12 1999/01/25 01:17:44 archie Exp $
414cf49a43SJulian Elischer  */
424cf49a43SJulian Elischer 
434cf49a43SJulian Elischer #ifndef _NETGRAPH_NG_MESSAGE_H_
444cf49a43SJulian Elischer #define _NETGRAPH_NG_MESSAGE_H_ 1
454cf49a43SJulian Elischer 
464cf49a43SJulian Elischer /* ASCII string size limits */
474cf49a43SJulian Elischer #define NG_TYPELEN	15	/* max type name len (16 with null) */
484cf49a43SJulian Elischer #define NG_HOOKLEN	15	/* max hook name len (16 with null) */
494cf49a43SJulian Elischer #define NG_NODELEN	15	/* max node name len (16 with null) */
504cf49a43SJulian Elischer #define NG_PATHLEN	511	/* max path len     (512 with null) */
514cf49a43SJulian Elischer #define NG_CMDSTRLEN	15	/* max command string (16 with null) */
524cf49a43SJulian Elischer #define NG_TEXTRESPONSE 1024	/* allow this length for a text response */
534cf49a43SJulian Elischer 
544cf49a43SJulian Elischer /* A netgraph message */
554cf49a43SJulian Elischer struct ng_mesg {
564cf49a43SJulian Elischer 	struct	ng_msghdr {
57589f6ed8SJulian Elischer 		u_char		version;		/*  == NGM_VERSION */
584cf49a43SJulian Elischer 		u_char		spare;			/* pad to 2 bytes */
594cf49a43SJulian Elischer 		u_int16_t	arglen;			/* length of data */
604cf49a43SJulian Elischer 		u_int32_t	flags;			/* message status */
614cf49a43SJulian Elischer 		u_int32_t	token;			/* match with reply */
624cf49a43SJulian Elischer 		u_int32_t	typecookie;		/* node's type cookie */
634cf49a43SJulian Elischer 		u_int32_t	cmd;			/* command identifier */
644cf49a43SJulian Elischer 		u_char		cmdstr[NG_CMDSTRLEN+1];	/* cmd string + \0 */
654cf49a43SJulian Elischer 	} header;
664cf49a43SJulian Elischer 	char	data[0];		/* placeholder for actual data */
674cf49a43SJulian Elischer };
68f8307e12SArchie Cobbs 
69069154d5SJulian Elischer /* this command is guaranteed to not alter data or'd into the command */
70069154d5SJulian Elischer #define NGM_READONLY	0x10000000
71589f6ed8SJulian Elischer 
72f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
73f8307e12SArchie Cobbs #define NG_GENERIC_NG_MESG_INFO(dtype)	{			\
74f8307e12SArchie Cobbs 	{							\
7557b57be3SArchie Cobbs 	  { "version",		&ng_parse_uint8_type	},	\
7657b57be3SArchie Cobbs 	  { "spare",		&ng_parse_uint8_type	},	\
7757b57be3SArchie Cobbs 	  { "arglen",		&ng_parse_uint16_type	},	\
7857b57be3SArchie Cobbs 	  { "flags",		&ng_parse_hint32_type	},	\
7957b57be3SArchie Cobbs 	  { "token",		&ng_parse_uint32_type	},	\
8057b57be3SArchie Cobbs 	  { "typecookie",	&ng_parse_uint32_type	},	\
8157b57be3SArchie Cobbs 	  { "cmd",		&ng_parse_uint32_type	},	\
82f8307e12SArchie Cobbs 	  { "cmdstr",		&ng_parse_cmdbuf_type	},	\
83f8307e12SArchie Cobbs 	  { "data",		(dtype)			},	\
84f8307e12SArchie Cobbs 	  { NULL },						\
85f8307e12SArchie Cobbs 	}							\
86f8307e12SArchie Cobbs }
87f8307e12SArchie Cobbs 
88589f6ed8SJulian Elischer /*
89589f6ed8SJulian Elischer  * Netgraph message header compatibility field
90589f6ed8SJulian Elischer  * Interfaces within the kernel are defined by a different
91589f6ed8SJulian Elischer  * value (see NG_ABI_VERSION in netgraph.g)
92589f6ed8SJulian Elischer  */
93069154d5SJulian Elischer #define NG_VERSION	5
94f8307e12SArchie Cobbs 
95f8307e12SArchie Cobbs /* Flags field flags */
96069154d5SJulian Elischer #define NGF_ORIG	0x00000000	/* the msg is the original request */
97069154d5SJulian Elischer #define NGF_RESP	0x00000001	/* the message is a response */
981acb27c6SJulian Elischer 
99f8307e12SArchie Cobbs /* Type of a unique node ID */
100f8307e12SArchie Cobbs #define ng_ID_t unsigned int
101f8307e12SArchie Cobbs 
1024cf49a43SJulian Elischer /*
1034cf49a43SJulian Elischer  * Here we describe the "generic" messages that all nodes inherently
1044cf49a43SJulian Elischer  * understand. With the exception of NGM_TEXT_STATUS, these are handled
1054cf49a43SJulian Elischer  * automatically by the base netgraph code.
1064cf49a43SJulian Elischer  */
1074cf49a43SJulian Elischer 
1084cf49a43SJulian Elischer /* Generic message type cookie */
109069154d5SJulian Elischer #define NGM_GENERIC_COOKIE	977674408
1104cf49a43SJulian Elischer 
1114cf49a43SJulian Elischer /* Generic messages defined for this type cookie */
112f8307e12SArchie Cobbs #define	NGM_SHUTDOWN		1	/* shut down node */
113f8307e12SArchie Cobbs #define NGM_MKPEER		2	/* create and attach a peer node */
114f8307e12SArchie Cobbs #define NGM_CONNECT		3	/* connect two nodes */
115f8307e12SArchie Cobbs #define NGM_NAME		4	/* give a node a name */
116f8307e12SArchie Cobbs #define NGM_RMHOOK		5	/* break a connection btw. two nodes */
117069154d5SJulian Elischer #define	NGM_NODEINFO		(6|NGM_READONLY)/* get nodeinfo for target */
118069154d5SJulian Elischer #define	NGM_LISTHOOKS		(7|NGM_READONLY)/* get list of hooks on node */
119069154d5SJulian Elischer #define	NGM_LISTNAMES		(8|NGM_READONLY)/* list globally named nodes */
120069154d5SJulian Elischer #define	NGM_LISTNODES		(9|NGM_READONLY)/* list nodes, named & not */
121069154d5SJulian Elischer #define	NGM_LISTTYPES		(10|NGM_READONLY)/* list installed node types */
122069154d5SJulian Elischer #define	NGM_TEXT_STATUS		(11|NGM_READONLY)/* (optional) get txt status */
123069154d5SJulian Elischer #define	NGM_BINARY2ASCII	(12|NGM_READONLY)/* convert ng_mesg to ascii */
124069154d5SJulian Elischer #define	NGM_ASCII2BINARY	(13|NGM_READONLY)/* convert ascii to ng_mesg */
1257095e097SPoul-Henning Kamp #define	NGM_TEXT_CONFIG		14	/* (optional) get/set text config */
1264cf49a43SJulian Elischer 
127859a4d16SJulian Elischer /*
128859a4d16SJulian Elischer  * Flow control and intra node control messages.
129859a4d16SJulian Elischer  * These are routed between nodes to allow flow control and to allow
130859a4d16SJulian Elischer  * events to be passed around the graph.
131859a4d16SJulian Elischer  * There will be some form of default handling for these but I
132859a4d16SJulian Elischer  * do not yet know what it is..
133859a4d16SJulian Elischer  */
134859a4d16SJulian Elischer 
135859a4d16SJulian Elischer /* Generic message type cookie */
136859a4d16SJulian Elischer #define NGM_FLOW_COOKIE	851672669 /* temp for debugging */
137859a4d16SJulian Elischer 
138859a4d16SJulian Elischer /* Upstream messages */
139859a4d16SJulian Elischer #define NGM_LINK_IS_UP		32	/* e.g. carrier found - no data */
140859a4d16SJulian Elischer #define NGM_LINK_IS_DOWN	33	/* carrier lost, includes queue state */
141859a4d16SJulian Elischer #define NGM_HIGH_WATER_PASSED	34	/* includes queue state */
142859a4d16SJulian Elischer #define NGM_LOW_WATER_PASSED	35	/* includes queue state */
143859a4d16SJulian Elischer #define NGM_SYNC_QUEUE_STATE	36	/* sync response from sending packet */
144859a4d16SJulian Elischer 
145859a4d16SJulian Elischer /* Downstream messages */
146859a4d16SJulian Elischer #define NGM_DROP_LINK		41	/* drop DTR, etc. - stay in the graph */
147b57a7965SJulian Elischer #define NGM_RAISE_LINK		42	/* if you previously dropped it */
148859a4d16SJulian Elischer #define NGM_FLUSH_QUEUE		43	/* no data */
149069154d5SJulian Elischer #define NGM_GET_BANDWIDTH	(44|NGM_READONLY)	/* either real or measured */
150859a4d16SJulian Elischer #define NGM_SET_XMIT_Q_LIMITS	45	/* includes queue state */
151069154d5SJulian Elischer #define NGM_GET_XMIT_Q_LIMITS	(46|NGM_READONLY)	/* returns queue state */
152069154d5SJulian Elischer #define NGM_MICROMANAGE		47	/* We want sync. queue state
153069154d5SJulian Elischer 						reply for each packet sent */
154859a4d16SJulian Elischer #define NGM_SET_FLOW_MANAGER	48	/* send flow control here */
155f8307e12SArchie Cobbs /* Structure used for NGM_MKPEER */
1564cf49a43SJulian Elischer struct ngm_mkpeer {
1574cf49a43SJulian Elischer 	char	type[NG_TYPELEN + 1];			/* peer type */
1584cf49a43SJulian Elischer 	char	ourhook[NG_HOOKLEN + 1];		/* hook name */
1594cf49a43SJulian Elischer 	char	peerhook[NG_HOOKLEN + 1];		/* peer hook name */
1604cf49a43SJulian Elischer };
1614cf49a43SJulian Elischer 
162f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
163f8307e12SArchie Cobbs #define NG_GENERIC_MKPEER_INFO()	{			\
164f8307e12SArchie Cobbs 	{							\
165f8307e12SArchie Cobbs 	  { "type",		&ng_parse_typebuf_type	},	\
166f8307e12SArchie Cobbs 	  { "ourhook",		&ng_parse_hookbuf_type	},	\
167f8307e12SArchie Cobbs 	  { "peerhook",		&ng_parse_hookbuf_type	},	\
168f8307e12SArchie Cobbs 	  { NULL },						\
169f8307e12SArchie Cobbs 	}							\
170f8307e12SArchie Cobbs }
171f8307e12SArchie Cobbs 
172f8307e12SArchie Cobbs /* Structure used for NGM_CONNECT */
1734cf49a43SJulian Elischer struct ngm_connect {
1744cf49a43SJulian Elischer 	char	path[NG_PATHLEN + 1];			/* peer path */
1754cf49a43SJulian Elischer 	char	ourhook[NG_HOOKLEN + 1];		/* hook name */
1764cf49a43SJulian Elischer 	char	peerhook[NG_HOOKLEN + 1];		/* peer hook name */
1774cf49a43SJulian Elischer };
1784cf49a43SJulian Elischer 
179f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
180f8307e12SArchie Cobbs #define NG_GENERIC_CONNECT_INFO()	{			\
181f8307e12SArchie Cobbs 	{							\
182f8307e12SArchie Cobbs 	  { "path",		&ng_parse_pathbuf_type	},	\
183f8307e12SArchie Cobbs 	  { "ourhook",		&ng_parse_hookbuf_type	},	\
184f8307e12SArchie Cobbs 	  { "peerhook",		&ng_parse_hookbuf_type	},	\
185f8307e12SArchie Cobbs 	  { NULL },						\
186f8307e12SArchie Cobbs 	}							\
187f8307e12SArchie Cobbs }
188f8307e12SArchie Cobbs 
189f8307e12SArchie Cobbs /* Structure used for NGM_NAME */
1904cf49a43SJulian Elischer struct ngm_name {
1914cf49a43SJulian Elischer 	char	name[NG_NODELEN + 1];			/* node name */
1924cf49a43SJulian Elischer };
1934cf49a43SJulian Elischer 
194f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
195f8307e12SArchie Cobbs #define NG_GENERIC_NAME_INFO()	{				\
196f8307e12SArchie Cobbs 	{							\
197f8307e12SArchie Cobbs 	  { "name",		&ng_parse_nodebuf_type	},	\
198f8307e12SArchie Cobbs 	  { NULL },						\
199f8307e12SArchie Cobbs 	}							\
200f8307e12SArchie Cobbs }
201f8307e12SArchie Cobbs 
202f8307e12SArchie Cobbs /* Structure used for NGM_RMHOOK */
2034cf49a43SJulian Elischer struct ngm_rmhook {
2044cf49a43SJulian Elischer 	char	ourhook[NG_HOOKLEN + 1];		/* hook name */
2054cf49a43SJulian Elischer };
2064cf49a43SJulian Elischer 
207f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
208f8307e12SArchie Cobbs #define NG_GENERIC_RMHOOK_INFO()	{			\
209f8307e12SArchie Cobbs 	{							\
210f8307e12SArchie Cobbs 	  { "hook",		&ng_parse_hookbuf_type	},	\
211f8307e12SArchie Cobbs 	  { NULL },						\
212f8307e12SArchie Cobbs 	}							\
213f8307e12SArchie Cobbs }
214f8307e12SArchie Cobbs 
215f8307e12SArchie Cobbs /* Structure used for NGM_NODEINFO */
2164cf49a43SJulian Elischer struct nodeinfo {
2174cf49a43SJulian Elischer 	char		name[NG_NODELEN + 1];	/* node name (if any) */
2184cf49a43SJulian Elischer         char    	type[NG_TYPELEN + 1];   /* peer type */
219dc90cad9SJulian Elischer 	ng_ID_t		id;			/* unique identifier */
2204cf49a43SJulian Elischer 	u_int32_t	hooks;			/* number of active hooks */
2214cf49a43SJulian Elischer };
2224cf49a43SJulian Elischer 
223f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
224f8307e12SArchie Cobbs #define NG_GENERIC_NODEINFO_INFO()	{			\
225f8307e12SArchie Cobbs 	{							\
226f8307e12SArchie Cobbs 	  { "name",		&ng_parse_nodebuf_type	},	\
227f8307e12SArchie Cobbs 	  { "type",		&ng_parse_typebuf_type	},	\
22857b57be3SArchie Cobbs 	  { "id",		&ng_parse_hint32_type	},	\
22957b57be3SArchie Cobbs 	  { "hooks",		&ng_parse_uint32_type	},	\
230f8307e12SArchie Cobbs 	  { NULL },						\
231f8307e12SArchie Cobbs 	}							\
232f8307e12SArchie Cobbs }
233f8307e12SArchie Cobbs 
234f8307e12SArchie Cobbs /* Structure used for NGM_LISTHOOKS */
2354cf49a43SJulian Elischer struct linkinfo {
2364cf49a43SJulian Elischer 	char		ourhook[NG_HOOKLEN + 1];	/* hook name */
2374cf49a43SJulian Elischer 	char		peerhook[NG_HOOKLEN + 1];	/* peer hook */
2384cf49a43SJulian Elischer 	struct nodeinfo	nodeinfo;
2394cf49a43SJulian Elischer };
2404cf49a43SJulian Elischer 
241f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
242f8307e12SArchie Cobbs #define NG_GENERIC_LINKINFO_INFO(nitype)	{		\
243f8307e12SArchie Cobbs 	{							\
244f8307e12SArchie Cobbs 	  { "ourhook",		&ng_parse_hookbuf_type	},	\
245f8307e12SArchie Cobbs 	  { "peerhook",		&ng_parse_hookbuf_type	},	\
246f8307e12SArchie Cobbs 	  { "nodeinfo",		(nitype)		},	\
247f8307e12SArchie Cobbs 	  { NULL },						\
248f8307e12SArchie Cobbs 	}							\
249f8307e12SArchie Cobbs }
250f8307e12SArchie Cobbs 
2514cf49a43SJulian Elischer struct hooklist {
2524cf49a43SJulian Elischer 	struct nodeinfo nodeinfo;		/* node information */
2534cf49a43SJulian Elischer 	struct linkinfo link[0];		/* info about each hook */
2544cf49a43SJulian Elischer };
2554cf49a43SJulian Elischer 
256f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
257f8307e12SArchie Cobbs #define NG_GENERIC_HOOKLIST_INFO(nitype,litype)	{		\
258f8307e12SArchie Cobbs 	{							\
259f8307e12SArchie Cobbs 	  { "nodeinfo",		(nitype)		},	\
260f8307e12SArchie Cobbs 	  { "linkinfo",		(litype)		},	\
261f8307e12SArchie Cobbs 	  { NULL },						\
262f8307e12SArchie Cobbs 	}							\
263f8307e12SArchie Cobbs }
264f8307e12SArchie Cobbs 
265f8307e12SArchie Cobbs /* Structure used for NGM_LISTNAMES/NGM_LISTNODES */
2664cf49a43SJulian Elischer struct namelist {
2674cf49a43SJulian Elischer 	u_int32_t	numnames;
2684cf49a43SJulian Elischer 	struct nodeinfo	nodeinfo[0];
2694cf49a43SJulian Elischer };
2704cf49a43SJulian Elischer 
271f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
272f8307e12SArchie Cobbs #define NG_GENERIC_LISTNODES_INFO(niarraytype)	{		\
273f8307e12SArchie Cobbs 	{							\
27457b57be3SArchie Cobbs 	  { "numnames",		&ng_parse_uint32_type	},	\
275f8307e12SArchie Cobbs 	  { "nodeinfo",		(niarraytype)		},	\
276f8307e12SArchie Cobbs 	  { NULL },						\
277f8307e12SArchie Cobbs 	}							\
278f8307e12SArchie Cobbs }
279f8307e12SArchie Cobbs 
280f8307e12SArchie Cobbs /* Structure used for NGM_LISTTYPES */
2814cf49a43SJulian Elischer struct typeinfo {
282a096e45aSArchie Cobbs 	char		type_name[NG_TYPELEN + 1];	/* name of type */
2834cf49a43SJulian Elischer 	u_int32_t	numnodes;			/* number alive */
2844cf49a43SJulian Elischer };
2854cf49a43SJulian Elischer 
286f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
287f8307e12SArchie Cobbs #define NG_GENERIC_TYPEINFO_INFO()		{		\
288f8307e12SArchie Cobbs 	{							\
289f8307e12SArchie Cobbs 	  { "typename",		&ng_parse_typebuf_type	},	\
29057b57be3SArchie Cobbs 	  { "numnodes",		&ng_parse_uint32_type	},	\
291f8307e12SArchie Cobbs 	  { NULL },						\
292f8307e12SArchie Cobbs 	}							\
293f8307e12SArchie Cobbs }
294f8307e12SArchie Cobbs 
2954cf49a43SJulian Elischer struct typelist {
2964cf49a43SJulian Elischer 	u_int32_t	numtypes;
2974cf49a43SJulian Elischer 	struct typeinfo	typeinfo[0];
2984cf49a43SJulian Elischer };
2994cf49a43SJulian Elischer 
300f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
301f8307e12SArchie Cobbs #define NG_GENERIC_TYPELIST_INFO(tiarraytype)	{		\
302f8307e12SArchie Cobbs 	{							\
30357b57be3SArchie Cobbs 	  { "numtypes",		&ng_parse_uint32_type	},	\
304f8307e12SArchie Cobbs 	  { "typeinfo",		(tiarraytype)		},	\
305f8307e12SArchie Cobbs 	  { NULL },						\
306f8307e12SArchie Cobbs 	}							\
307f8307e12SArchie Cobbs }
308f8307e12SArchie Cobbs 
309859a4d16SJulian Elischer struct ngm_bandwidth {
310859a4d16SJulian Elischer 	u_int64_t	nominal_in;
311859a4d16SJulian Elischer 	u_int64_t	seen_in;
312859a4d16SJulian Elischer 	u_int64_t	nominal_out;
313859a4d16SJulian Elischer 	u_int64_t	seen_out;
314859a4d16SJulian Elischer };
315859a4d16SJulian Elischer 
316859a4d16SJulian Elischer /* Keep this in sync with the above structure definition */
317859a4d16SJulian Elischer #define NG_GENERIC_BANDWIDTH_INFO()	{			\
318859a4d16SJulian Elischer 	{							\
319859a4d16SJulian Elischer 	  { "nominal_in",	&ng_parse_uint64_type	},	\
320859a4d16SJulian Elischer 	  { "seen_in",		&ng_parse_uint64_type	},	\
321859a4d16SJulian Elischer 	  { "nominal_out",	&ng_parse_uint64_type	},	\
322859a4d16SJulian Elischer 	  { "seen_out",		&ng_parse_uint64_type	},	\
323859a4d16SJulian Elischer 	  { NULL },						\
324859a4d16SJulian Elischer 	}							\
325859a4d16SJulian Elischer }
326859a4d16SJulian Elischer 
327859a4d16SJulian Elischer /*
328859a4d16SJulian Elischer  * Information about a node's 'output' queue.
329859a4d16SJulian Elischer  * This is NOT the netgraph input queueing mechanism,
330859a4d16SJulian Elischer  * but rather any queue the node may implement internally
331859a4d16SJulian Elischer  * This has to consider ALTQ if we are to work with it.
332859a4d16SJulian Elischer  * As far as I can see, ALTQ counts PACKETS, not bytes.
333859a4d16SJulian Elischer  * If ALTQ has several queues and one has passed a watermark
334859a4d16SJulian Elischer  * we should have the priority of that queue be real (and not -1)
335859a4d16SJulian Elischer  * XXX ALTQ stuff is just an idea.....
336859a4d16SJulian Elischer  */
337859a4d16SJulian Elischer struct ngm_queue_state {
338859a4d16SJulian Elischer 	u_int queue_priority; /* maybe only low-pri is full. -1 = all*/
339859a4d16SJulian Elischer 	u_int	max_queuelen_bytes;
340859a4d16SJulian Elischer 	u_int	max_queuelen_packets;
341859a4d16SJulian Elischer 	u_int	low_watermark;
342859a4d16SJulian Elischer 	u_int	high_watermark;
343859a4d16SJulian Elischer 	u_int	current;
344859a4d16SJulian Elischer };
345859a4d16SJulian Elischer 
346859a4d16SJulian Elischer /* Keep this in sync with the above structure definition */
347859a4d16SJulian Elischer #define NG_GENERIC_QUEUE_INFO()	{				\
348859a4d16SJulian Elischer 	{							\
349859a4d16SJulian Elischer 	  { "max_queuelen_bytes", &ng_parse_uint_type	},	\
350859a4d16SJulian Elischer 	  { "max_queuelen_packets", &ng_parse_uint_type	},	\
351859a4d16SJulian Elischer 	  { "high_watermark",	&ng_parse_uint_type	},	\
352859a4d16SJulian Elischer 	  { "low_watermark",	&ng_parse_uint_type	},	\
353859a4d16SJulian Elischer 	  { "current",		&ng_parse_uint_type	},	\
354859a4d16SJulian Elischer 	  { NULL },						\
355859a4d16SJulian Elischer 	}							\
356859a4d16SJulian Elischer }
357859a4d16SJulian Elischer 
358859a4d16SJulian Elischer /* Tell a node who to send async flow control info to. */
359859a4d16SJulian Elischer struct flow_manager {
360859a4d16SJulian Elischer 	ng_ID_t		id;			/* unique identifier */
361859a4d16SJulian Elischer };
362859a4d16SJulian Elischer 
363859a4d16SJulian Elischer /* Keep this in sync with the above structure definition */
364859a4d16SJulian Elischer #define NG_GENERIC_FLOW_MANAGER_INFO()	{			\
365859a4d16SJulian Elischer 	{							\
366859a4d16SJulian Elischer 	  { "id",		&ng_parse_hint32_type	},	\
367859a4d16SJulian Elischer 	  { NULL },						\
368859a4d16SJulian Elischer 	}							\
369859a4d16SJulian Elischer }
370859a4d16SJulian Elischer 
371859a4d16SJulian Elischer 
3724cf49a43SJulian Elischer /*
3734cf49a43SJulian Elischer  * For netgraph nodes that are somehow associated with file descriptors
3744cf49a43SJulian Elischer  * (e.g., a device that has a /dev entry and is also a netgraph node),
3754cf49a43SJulian Elischer  * we define a generic ioctl for requesting the corresponding nodeinfo
3764cf49a43SJulian Elischer  * structure and for assigning a name (if there isn't one already).
3774cf49a43SJulian Elischer  *
3784cf49a43SJulian Elischer  * For these to you need to also #include <sys/ioccom.h>.
3794cf49a43SJulian Elischer  */
3804cf49a43SJulian Elischer 
3814cf49a43SJulian Elischer #define NGIOCGINFO	_IOR('N', 40, struct nodeinfo)	/* get node info */
3824cf49a43SJulian Elischer #define NGIOCSETNAME	_IOW('N', 41, struct ngm_name)	/* set node name */
3834cf49a43SJulian Elischer 
384664a31e4SPeter Wemm #ifdef _KERNEL
3854cf49a43SJulian Elischer /*
3864cf49a43SJulian Elischer  * Allocate and initialize a netgraph message "msg" with "len"
3874cf49a43SJulian Elischer  * extra bytes of argument. Sets "msg" to NULL if fails.
3884cf49a43SJulian Elischer  * Does not initialize token.
3894cf49a43SJulian Elischer  */
3904cf49a43SJulian Elischer #define NG_MKMESSAGE(msg, cookie, cmdid, len, how)			\
3914cf49a43SJulian Elischer 	do {								\
3924cf49a43SJulian Elischer 	  MALLOC((msg), struct ng_mesg *, sizeof(struct ng_mesg)	\
393069154d5SJulian Elischer 	    + (len), M_NETGRAPH_MSG, (how) | M_ZERO);			\
3944cf49a43SJulian Elischer 	  if ((msg) == NULL)						\
3954cf49a43SJulian Elischer 	    break;							\
3964cf49a43SJulian Elischer 	  (msg)->header.version = NG_VERSION;				\
3974cf49a43SJulian Elischer 	  (msg)->header.typecookie = (cookie);				\
3984cf49a43SJulian Elischer 	  (msg)->header.cmd = (cmdid);					\
3994cf49a43SJulian Elischer 	  (msg)->header.arglen = (len);					\
4004cf49a43SJulian Elischer 	  strncpy((msg)->header.cmdstr, #cmdid,				\
4014cf49a43SJulian Elischer 	    sizeof((msg)->header.cmdstr) - 1);				\
4024cf49a43SJulian Elischer 	} while (0)
4034cf49a43SJulian Elischer 
4044cf49a43SJulian Elischer /*
4054cf49a43SJulian Elischer  * Allocate and initialize a response "rsp" to a message "msg"
4064cf49a43SJulian Elischer  * with "len" extra bytes of argument. Sets "rsp" to NULL if fails.
4074cf49a43SJulian Elischer  */
4084cf49a43SJulian Elischer #define NG_MKRESPONSE(rsp, msg, len, how)				\
4094cf49a43SJulian Elischer 	do {								\
4104cf49a43SJulian Elischer 	  MALLOC((rsp), struct ng_mesg *, sizeof(struct ng_mesg)	\
411069154d5SJulian Elischer 	    + (len), M_NETGRAPH_MSG, (how) | M_ZERO);			\
4124cf49a43SJulian Elischer 	  if ((rsp) == NULL)						\
4134cf49a43SJulian Elischer 	    break;							\
4144cf49a43SJulian Elischer 	  (rsp)->header.version = NG_VERSION;				\
4154cf49a43SJulian Elischer 	  (rsp)->header.arglen = (len);					\
4164cf49a43SJulian Elischer 	  (rsp)->header.token = (msg)->header.token;			\
4174cf49a43SJulian Elischer 	  (rsp)->header.typecookie = (msg)->header.typecookie;		\
4184cf49a43SJulian Elischer 	  (rsp)->header.cmd = (msg)->header.cmd;			\
4194cf49a43SJulian Elischer 	  bcopy((msg)->header.cmdstr, (rsp)->header.cmdstr,		\
4204cf49a43SJulian Elischer 	    sizeof((rsp)->header.cmdstr));				\
4214cf49a43SJulian Elischer 	  (rsp)->header.flags |= NGF_RESP;				\
4224cf49a43SJulian Elischer 	} while (0)
423664a31e4SPeter Wemm #endif /* _KERNEL */
4244cf49a43SJulian Elischer 
4254cf49a43SJulian Elischer #endif /* _NETGRAPH_NG_MESSAGE_H_ */
4264cf49a43SJulian Elischer 
427