xref: /freebsd/sys/netgraph/ng_message.h (revision 859a4d166c0fc97b248bf33c8745b7494934b0bf)
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 {
574cf49a43SJulian Elischer 		u_char		version;		/* must == NG_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 
69f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
70f8307e12SArchie Cobbs #define NG_GENERIC_NG_MESG_INFO(dtype)	{			\
71f8307e12SArchie Cobbs 	{							\
7257b57be3SArchie Cobbs 	  { "version",		&ng_parse_uint8_type	},	\
7357b57be3SArchie Cobbs 	  { "spare",		&ng_parse_uint8_type	},	\
7457b57be3SArchie Cobbs 	  { "arglen",		&ng_parse_uint16_type	},	\
7557b57be3SArchie Cobbs 	  { "flags",		&ng_parse_hint32_type	},	\
7657b57be3SArchie Cobbs 	  { "token",		&ng_parse_uint32_type	},	\
7757b57be3SArchie Cobbs 	  { "typecookie",	&ng_parse_uint32_type	},	\
7857b57be3SArchie Cobbs 	  { "cmd",		&ng_parse_uint32_type	},	\
79f8307e12SArchie Cobbs 	  { "cmdstr",		&ng_parse_cmdbuf_type	},	\
80f8307e12SArchie Cobbs 	  { "data",		(dtype)			},	\
81f8307e12SArchie Cobbs 	  { NULL },						\
82f8307e12SArchie Cobbs 	}							\
83f8307e12SArchie Cobbs }
84f8307e12SArchie Cobbs 
85f8307e12SArchie Cobbs /* Negraph type binary compatibility field */
86859a4d16SJulian Elischer #define NG_VERSION	4
87f8307e12SArchie Cobbs 
88f8307e12SArchie Cobbs /* Flags field flags */
894cf49a43SJulian Elischer #define NGF_ORIG	0x0000		/* the msg is the original request */
904cf49a43SJulian Elischer #define NGF_RESP	0x0001		/* the message is a response */
914cf49a43SJulian Elischer 
92f8307e12SArchie Cobbs /* Type of a unique node ID */
93f8307e12SArchie Cobbs #define ng_ID_t unsigned int
94f8307e12SArchie Cobbs 
954cf49a43SJulian Elischer /*
964cf49a43SJulian Elischer  * Here we describe the "generic" messages that all nodes inherently
974cf49a43SJulian Elischer  * understand. With the exception of NGM_TEXT_STATUS, these are handled
984cf49a43SJulian Elischer  * automatically by the base netgraph code.
994cf49a43SJulian Elischer  */
1004cf49a43SJulian Elischer 
1014cf49a43SJulian Elischer /* Generic message type cookie */
1024cf49a43SJulian Elischer #define NGM_GENERIC_COOKIE	851672668
1034cf49a43SJulian Elischer 
1044cf49a43SJulian Elischer /* Generic messages defined for this type cookie */
105f8307e12SArchie Cobbs #define	NGM_SHUTDOWN		1	/* shut down node */
106f8307e12SArchie Cobbs #define NGM_MKPEER		2	/* create and attach a peer node */
107f8307e12SArchie Cobbs #define NGM_CONNECT		3	/* connect two nodes */
108f8307e12SArchie Cobbs #define NGM_NAME		4	/* give a node a name */
109f8307e12SArchie Cobbs #define NGM_RMHOOK		5	/* break a connection btw. two nodes */
110f8307e12SArchie Cobbs #define	NGM_NODEINFO		6	/* get nodeinfo for the target */
111f8307e12SArchie Cobbs #define	NGM_LISTHOOKS		7	/* get list of hooks on node */
112f8307e12SArchie Cobbs #define	NGM_LISTNAMES		8	/* list all globally named nodes */
113f8307e12SArchie Cobbs #define	NGM_LISTNODES		9	/* list all nodes, named and unnamed */
114f8307e12SArchie Cobbs #define	NGM_LISTTYPES		10	/* list all installed node types */
115f8307e12SArchie Cobbs #define	NGM_TEXT_STATUS		11	/* (optional) get text status report */
116f8307e12SArchie Cobbs #define	NGM_BINARY2ASCII	12	/* convert struct ng_mesg to ascii */
117f8307e12SArchie Cobbs #define	NGM_ASCII2BINARY	13	/* convert ascii to struct ng_mesg */
1187095e097SPoul-Henning Kamp #define	NGM_TEXT_CONFIG		14	/* (optional) get/set text config */
1194cf49a43SJulian Elischer 
120859a4d16SJulian Elischer /*
121859a4d16SJulian Elischer  * Flow control and intra node control messages.
122859a4d16SJulian Elischer  * These are routed between nodes to allow flow control and to allow
123859a4d16SJulian Elischer  * events to be passed around the graph.
124859a4d16SJulian Elischer  * There will be some form of default handling for these but I
125859a4d16SJulian Elischer  * do not yet know what it is..
126859a4d16SJulian Elischer  */
127859a4d16SJulian Elischer 
128859a4d16SJulian Elischer /* Generic message type cookie */
129859a4d16SJulian Elischer #define NGM_FLOW_COOKIE	851672669 /* temp for debugging */
130859a4d16SJulian Elischer 
131859a4d16SJulian Elischer /* Upstream messages */
132859a4d16SJulian Elischer #define NGM_LINK_IS_UP		32	/* e.g. carrier found - no data */
133859a4d16SJulian Elischer #define NGM_LINK_IS_DOWN	33	/* carrier lost, includes queue state */
134859a4d16SJulian Elischer #define NGM_HIGH_WATER_PASSED	34	/* includes queue state */
135859a4d16SJulian Elischer #define NGM_LOW_WATER_PASSED	35	/* includes queue state */
136859a4d16SJulian Elischer #define NGM_SYNC_QUEUE_STATE	36	/* sync response from sending packet */
137859a4d16SJulian Elischer 
138859a4d16SJulian Elischer /* Downstream messages */
139859a4d16SJulian Elischer #define NGM_DROP_LINK		41	/* drop DTR, etc. - stay in the graph */
140859a4d16SJulian Elischer #define NGM_RAISE LINK		42	/* if you previously dropped it */
141859a4d16SJulian Elischer #define NGM_FLUSH_QUEUE		43	/* no data */
142859a4d16SJulian Elischer #define NGM_GET_BANDWIDTH	44	/* either real or measured */
143859a4d16SJulian Elischer #define NGM_SET_XMIT_Q_LIMITS	45	/* includes queue state */
144859a4d16SJulian Elischer #define NGM_GET_XMIT_Q_LIMITS	46	/* returns queue state */
145859a4d16SJulian Elischer #define NGM_MICROMANAGE		47	/* We want sync. queue state reply
146859a4d16SJulian Elischer 					   for each packet sent down */
147859a4d16SJulian Elischer #define NGM_SET_FLOW_MANAGER	48	/* send flow control here */
148f8307e12SArchie Cobbs /* Structure used for NGM_MKPEER */
1494cf49a43SJulian Elischer struct ngm_mkpeer {
1504cf49a43SJulian Elischer 	char	type[NG_TYPELEN + 1];			/* peer type */
1514cf49a43SJulian Elischer 	char	ourhook[NG_HOOKLEN + 1];		/* hook name */
1524cf49a43SJulian Elischer 	char	peerhook[NG_HOOKLEN + 1];		/* peer hook name */
1534cf49a43SJulian Elischer };
1544cf49a43SJulian Elischer 
155f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
156f8307e12SArchie Cobbs #define NG_GENERIC_MKPEER_INFO()	{			\
157f8307e12SArchie Cobbs 	{							\
158f8307e12SArchie Cobbs 	  { "type",		&ng_parse_typebuf_type	},	\
159f8307e12SArchie Cobbs 	  { "ourhook",		&ng_parse_hookbuf_type	},	\
160f8307e12SArchie Cobbs 	  { "peerhook",		&ng_parse_hookbuf_type	},	\
161f8307e12SArchie Cobbs 	  { NULL },						\
162f8307e12SArchie Cobbs 	}							\
163f8307e12SArchie Cobbs }
164f8307e12SArchie Cobbs 
165f8307e12SArchie Cobbs /* Structure used for NGM_CONNECT */
1664cf49a43SJulian Elischer struct ngm_connect {
1674cf49a43SJulian Elischer 	char	path[NG_PATHLEN + 1];			/* peer path */
1684cf49a43SJulian Elischer 	char	ourhook[NG_HOOKLEN + 1];		/* hook name */
1694cf49a43SJulian Elischer 	char	peerhook[NG_HOOKLEN + 1];		/* peer hook name */
1704cf49a43SJulian Elischer };
1714cf49a43SJulian Elischer 
172f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
173f8307e12SArchie Cobbs #define NG_GENERIC_CONNECT_INFO()	{			\
174f8307e12SArchie Cobbs 	{							\
175f8307e12SArchie Cobbs 	  { "path",		&ng_parse_pathbuf_type	},	\
176f8307e12SArchie Cobbs 	  { "ourhook",		&ng_parse_hookbuf_type	},	\
177f8307e12SArchie Cobbs 	  { "peerhook",		&ng_parse_hookbuf_type	},	\
178f8307e12SArchie Cobbs 	  { NULL },						\
179f8307e12SArchie Cobbs 	}							\
180f8307e12SArchie Cobbs }
181f8307e12SArchie Cobbs 
182f8307e12SArchie Cobbs /* Structure used for NGM_NAME */
1834cf49a43SJulian Elischer struct ngm_name {
1844cf49a43SJulian Elischer 	char	name[NG_NODELEN + 1];			/* node name */
1854cf49a43SJulian Elischer };
1864cf49a43SJulian Elischer 
187f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
188f8307e12SArchie Cobbs #define NG_GENERIC_NAME_INFO()	{				\
189f8307e12SArchie Cobbs 	{							\
190f8307e12SArchie Cobbs 	  { "name",		&ng_parse_nodebuf_type	},	\
191f8307e12SArchie Cobbs 	  { NULL },						\
192f8307e12SArchie Cobbs 	}							\
193f8307e12SArchie Cobbs }
194f8307e12SArchie Cobbs 
195f8307e12SArchie Cobbs /* Structure used for NGM_RMHOOK */
1964cf49a43SJulian Elischer struct ngm_rmhook {
1974cf49a43SJulian Elischer 	char	ourhook[NG_HOOKLEN + 1];		/* hook name */
1984cf49a43SJulian Elischer };
1994cf49a43SJulian Elischer 
200f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
201f8307e12SArchie Cobbs #define NG_GENERIC_RMHOOK_INFO()	{			\
202f8307e12SArchie Cobbs 	{							\
203f8307e12SArchie Cobbs 	  { "hook",		&ng_parse_hookbuf_type	},	\
204f8307e12SArchie Cobbs 	  { NULL },						\
205f8307e12SArchie Cobbs 	}							\
206f8307e12SArchie Cobbs }
207f8307e12SArchie Cobbs 
208f8307e12SArchie Cobbs /* Structure used for NGM_NODEINFO */
2094cf49a43SJulian Elischer struct nodeinfo {
2104cf49a43SJulian Elischer 	char		name[NG_NODELEN + 1];	/* node name (if any) */
2114cf49a43SJulian Elischer         char    	type[NG_TYPELEN + 1];   /* peer type */
212dc90cad9SJulian Elischer 	ng_ID_t		id;			/* unique identifier */
2134cf49a43SJulian Elischer 	u_int32_t	hooks;			/* number of active hooks */
2144cf49a43SJulian Elischer };
2154cf49a43SJulian Elischer 
216f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
217f8307e12SArchie Cobbs #define NG_GENERIC_NODEINFO_INFO()	{			\
218f8307e12SArchie Cobbs 	{							\
219f8307e12SArchie Cobbs 	  { "name",		&ng_parse_nodebuf_type	},	\
220f8307e12SArchie Cobbs 	  { "type",		&ng_parse_typebuf_type	},	\
22157b57be3SArchie Cobbs 	  { "id",		&ng_parse_hint32_type	},	\
22257b57be3SArchie Cobbs 	  { "hooks",		&ng_parse_uint32_type	},	\
223f8307e12SArchie Cobbs 	  { NULL },						\
224f8307e12SArchie Cobbs 	}							\
225f8307e12SArchie Cobbs }
226f8307e12SArchie Cobbs 
227f8307e12SArchie Cobbs /* Structure used for NGM_LISTHOOKS */
2284cf49a43SJulian Elischer struct linkinfo {
2294cf49a43SJulian Elischer 	char		ourhook[NG_HOOKLEN + 1];	/* hook name */
2304cf49a43SJulian Elischer 	char		peerhook[NG_HOOKLEN + 1];	/* peer hook */
2314cf49a43SJulian Elischer 	struct nodeinfo	nodeinfo;
2324cf49a43SJulian Elischer };
2334cf49a43SJulian Elischer 
234f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
235f8307e12SArchie Cobbs #define NG_GENERIC_LINKINFO_INFO(nitype)	{		\
236f8307e12SArchie Cobbs 	{							\
237f8307e12SArchie Cobbs 	  { "ourhook",		&ng_parse_hookbuf_type	},	\
238f8307e12SArchie Cobbs 	  { "peerhook",		&ng_parse_hookbuf_type	},	\
239f8307e12SArchie Cobbs 	  { "nodeinfo",		(nitype)		},	\
240f8307e12SArchie Cobbs 	  { NULL },						\
241f8307e12SArchie Cobbs 	}							\
242f8307e12SArchie Cobbs }
243f8307e12SArchie Cobbs 
2444cf49a43SJulian Elischer struct hooklist {
2454cf49a43SJulian Elischer 	struct nodeinfo nodeinfo;		/* node information */
2464cf49a43SJulian Elischer 	struct linkinfo link[0];		/* info about each hook */
2474cf49a43SJulian Elischer };
2484cf49a43SJulian Elischer 
249f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
250f8307e12SArchie Cobbs #define NG_GENERIC_HOOKLIST_INFO(nitype,litype)	{		\
251f8307e12SArchie Cobbs 	{							\
252f8307e12SArchie Cobbs 	  { "nodeinfo",		(nitype)		},	\
253f8307e12SArchie Cobbs 	  { "linkinfo",		(litype)		},	\
254f8307e12SArchie Cobbs 	  { NULL },						\
255f8307e12SArchie Cobbs 	}							\
256f8307e12SArchie Cobbs }
257f8307e12SArchie Cobbs 
258f8307e12SArchie Cobbs /* Structure used for NGM_LISTNAMES/NGM_LISTNODES */
2594cf49a43SJulian Elischer struct namelist {
2604cf49a43SJulian Elischer 	u_int32_t	numnames;
2614cf49a43SJulian Elischer 	struct nodeinfo	nodeinfo[0];
2624cf49a43SJulian Elischer };
2634cf49a43SJulian Elischer 
264f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
265f8307e12SArchie Cobbs #define NG_GENERIC_LISTNODES_INFO(niarraytype)	{		\
266f8307e12SArchie Cobbs 	{							\
26757b57be3SArchie Cobbs 	  { "numnames",		&ng_parse_uint32_type	},	\
268f8307e12SArchie Cobbs 	  { "nodeinfo",		(niarraytype)		},	\
269f8307e12SArchie Cobbs 	  { NULL },						\
270f8307e12SArchie Cobbs 	}							\
271f8307e12SArchie Cobbs }
272f8307e12SArchie Cobbs 
273f8307e12SArchie Cobbs /* Structure used for NGM_LISTTYPES */
2744cf49a43SJulian Elischer struct typeinfo {
275a096e45aSArchie Cobbs 	char		type_name[NG_TYPELEN + 1];	/* name of type */
2764cf49a43SJulian Elischer 	u_int32_t	numnodes;			/* number alive */
2774cf49a43SJulian Elischer };
2784cf49a43SJulian Elischer 
279f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
280f8307e12SArchie Cobbs #define NG_GENERIC_TYPEINFO_INFO()		{		\
281f8307e12SArchie Cobbs 	{							\
282f8307e12SArchie Cobbs 	  { "typename",		&ng_parse_typebuf_type	},	\
28357b57be3SArchie Cobbs 	  { "numnodes",		&ng_parse_uint32_type	},	\
284f8307e12SArchie Cobbs 	  { NULL },						\
285f8307e12SArchie Cobbs 	}							\
286f8307e12SArchie Cobbs }
287f8307e12SArchie Cobbs 
2884cf49a43SJulian Elischer struct typelist {
2894cf49a43SJulian Elischer 	u_int32_t	numtypes;
2904cf49a43SJulian Elischer 	struct typeinfo	typeinfo[0];
2914cf49a43SJulian Elischer };
2924cf49a43SJulian Elischer 
293f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */
294f8307e12SArchie Cobbs #define NG_GENERIC_TYPELIST_INFO(tiarraytype)	{		\
295f8307e12SArchie Cobbs 	{							\
29657b57be3SArchie Cobbs 	  { "numtypes",		&ng_parse_uint32_type	},	\
297f8307e12SArchie Cobbs 	  { "typeinfo",		(tiarraytype)		},	\
298f8307e12SArchie Cobbs 	  { NULL },						\
299f8307e12SArchie Cobbs 	}							\
300f8307e12SArchie Cobbs }
301f8307e12SArchie Cobbs 
302859a4d16SJulian Elischer struct ngm_bandwidth {
303859a4d16SJulian Elischer 	u_int64_t	nominal_in;
304859a4d16SJulian Elischer 	u_int64_t	seen_in;
305859a4d16SJulian Elischer 	u_int64_t	nominal_out;
306859a4d16SJulian Elischer 	u_int64_t	seen_out;
307859a4d16SJulian Elischer };
308859a4d16SJulian Elischer 
309859a4d16SJulian Elischer /* Keep this in sync with the above structure definition */
310859a4d16SJulian Elischer #define NG_GENERIC_BANDWIDTH_INFO()	{			\
311859a4d16SJulian Elischer 	{							\
312859a4d16SJulian Elischer 	  { "nominal_in",	&ng_parse_uint64_type	},	\
313859a4d16SJulian Elischer 	  { "seen_in",		&ng_parse_uint64_type	},	\
314859a4d16SJulian Elischer 	  { "nominal_out",	&ng_parse_uint64_type	},	\
315859a4d16SJulian Elischer 	  { "seen_out",		&ng_parse_uint64_type	},	\
316859a4d16SJulian Elischer 	  { NULL },						\
317859a4d16SJulian Elischer 	}							\
318859a4d16SJulian Elischer }
319859a4d16SJulian Elischer 
320859a4d16SJulian Elischer /*
321859a4d16SJulian Elischer  * Information about a node's 'output' queue.
322859a4d16SJulian Elischer  * This is NOT the netgraph input queueing mechanism,
323859a4d16SJulian Elischer  * but rather any queue the node may implement internally
324859a4d16SJulian Elischer  * This has to consider ALTQ if we are to work with it.
325859a4d16SJulian Elischer  * As far as I can see, ALTQ counts PACKETS, not bytes.
326859a4d16SJulian Elischer  * If ALTQ has several queues and one has passed a watermark
327859a4d16SJulian Elischer  * we should have the priority of that queue be real (and not -1)
328859a4d16SJulian Elischer  * XXX ALTQ stuff is just an idea.....
329859a4d16SJulian Elischer  */
330859a4d16SJulian Elischer struct ngm_queue_state {
331859a4d16SJulian Elischer 	u_int queue_priority; /* maybe only low-pri is full. -1 = all*/
332859a4d16SJulian Elischer 	u_int	max_queuelen_bytes;
333859a4d16SJulian Elischer 	u_int	max_queuelen_packets;
334859a4d16SJulian Elischer 	u_int	low_watermark;
335859a4d16SJulian Elischer 	u_int	high_watermark;
336859a4d16SJulian Elischer 	u_int	current;
337859a4d16SJulian Elischer };
338859a4d16SJulian Elischer 
339859a4d16SJulian Elischer /* Keep this in sync with the above structure definition */
340859a4d16SJulian Elischer #define NG_GENERIC_QUEUE_INFO()	{				\
341859a4d16SJulian Elischer 	{							\
342859a4d16SJulian Elischer 	  { "max_queuelen_bytes", &ng_parse_uint_type	},	\
343859a4d16SJulian Elischer 	  { "max_queuelen_packets", &ng_parse_uint_type	},	\
344859a4d16SJulian Elischer 	  { "high_watermark",	&ng_parse_uint_type	},	\
345859a4d16SJulian Elischer 	  { "low_watermark",	&ng_parse_uint_type	},	\
346859a4d16SJulian Elischer 	  { "current",		&ng_parse_uint_type	},	\
347859a4d16SJulian Elischer 	  { NULL },						\
348859a4d16SJulian Elischer 	}							\
349859a4d16SJulian Elischer }
350859a4d16SJulian Elischer 
351859a4d16SJulian Elischer /* Tell a node who to send async flow control info to. */
352859a4d16SJulian Elischer struct flow_manager {
353859a4d16SJulian Elischer 	ng_ID_t		id;			/* unique identifier */
354859a4d16SJulian Elischer };
355859a4d16SJulian Elischer 
356859a4d16SJulian Elischer /* Keep this in sync with the above structure definition */
357859a4d16SJulian Elischer #define NG_GENERIC_FLOW_MANAGER_INFO()	{			\
358859a4d16SJulian Elischer 	{							\
359859a4d16SJulian Elischer 	  { "id",		&ng_parse_hint32_type	},	\
360859a4d16SJulian Elischer 	  { NULL },						\
361859a4d16SJulian Elischer 	}							\
362859a4d16SJulian Elischer }
363859a4d16SJulian Elischer 
364859a4d16SJulian Elischer 
3654cf49a43SJulian Elischer /*
3664cf49a43SJulian Elischer  * For netgraph nodes that are somehow associated with file descriptors
3674cf49a43SJulian Elischer  * (e.g., a device that has a /dev entry and is also a netgraph node),
3684cf49a43SJulian Elischer  * we define a generic ioctl for requesting the corresponding nodeinfo
3694cf49a43SJulian Elischer  * structure and for assigning a name (if there isn't one already).
3704cf49a43SJulian Elischer  *
3714cf49a43SJulian Elischer  * For these to you need to also #include <sys/ioccom.h>.
3724cf49a43SJulian Elischer  */
3734cf49a43SJulian Elischer 
3744cf49a43SJulian Elischer #define NGIOCGINFO	_IOR('N', 40, struct nodeinfo)	/* get node info */
3754cf49a43SJulian Elischer #define NGIOCSETNAME	_IOW('N', 41, struct ngm_name)	/* set node name */
3764cf49a43SJulian Elischer 
377664a31e4SPeter Wemm #ifdef _KERNEL
3784cf49a43SJulian Elischer /*
3794cf49a43SJulian Elischer  * Allocate and initialize a netgraph message "msg" with "len"
3804cf49a43SJulian Elischer  * extra bytes of argument. Sets "msg" to NULL if fails.
3814cf49a43SJulian Elischer  * Does not initialize token.
3824cf49a43SJulian Elischer  */
3834cf49a43SJulian Elischer #define NG_MKMESSAGE(msg, cookie, cmdid, len, how)			\
3844cf49a43SJulian Elischer 	do {								\
3854cf49a43SJulian Elischer 	  MALLOC((msg), struct ng_mesg *, sizeof(struct ng_mesg)	\
38699cdf4ccSDavid Malone 	    + (len), M_NETGRAPH, (how) | M_ZERO);			\
3874cf49a43SJulian Elischer 	  if ((msg) == NULL)						\
3884cf49a43SJulian Elischer 	    break;							\
3894cf49a43SJulian Elischer 	  (msg)->header.version = NG_VERSION;				\
3904cf49a43SJulian Elischer 	  (msg)->header.typecookie = (cookie);				\
3914cf49a43SJulian Elischer 	  (msg)->header.cmd = (cmdid);					\
3924cf49a43SJulian Elischer 	  (msg)->header.arglen = (len);					\
3934cf49a43SJulian Elischer 	  strncpy((msg)->header.cmdstr, #cmdid,				\
3944cf49a43SJulian Elischer 	    sizeof((msg)->header.cmdstr) - 1);				\
3954cf49a43SJulian Elischer 	} while (0)
3964cf49a43SJulian Elischer 
3974cf49a43SJulian Elischer /*
3984cf49a43SJulian Elischer  * Allocate and initialize a response "rsp" to a message "msg"
3994cf49a43SJulian Elischer  * with "len" extra bytes of argument. Sets "rsp" to NULL if fails.
4004cf49a43SJulian Elischer  */
4014cf49a43SJulian Elischer #define NG_MKRESPONSE(rsp, msg, len, how)				\
4024cf49a43SJulian Elischer 	do {								\
4034cf49a43SJulian Elischer 	  MALLOC((rsp), struct ng_mesg *, sizeof(struct ng_mesg)	\
40499cdf4ccSDavid Malone 	    + (len), M_NETGRAPH, (how) | M_ZERO);			\
4054cf49a43SJulian Elischer 	  if ((rsp) == NULL)						\
4064cf49a43SJulian Elischer 	    break;							\
4074cf49a43SJulian Elischer 	  (rsp)->header.version = NG_VERSION;				\
4084cf49a43SJulian Elischer 	  (rsp)->header.arglen = (len);					\
4094cf49a43SJulian Elischer 	  (rsp)->header.token = (msg)->header.token;			\
4104cf49a43SJulian Elischer 	  (rsp)->header.typecookie = (msg)->header.typecookie;		\
4114cf49a43SJulian Elischer 	  (rsp)->header.cmd = (msg)->header.cmd;			\
4124cf49a43SJulian Elischer 	  bcopy((msg)->header.cmdstr, (rsp)->header.cmdstr,		\
4134cf49a43SJulian Elischer 	    sizeof((rsp)->header.cmdstr));				\
4144cf49a43SJulian Elischer 	  (rsp)->header.flags |= NGF_RESP;				\
4154cf49a43SJulian Elischer 	} while (0)
416664a31e4SPeter Wemm #endif /* _KERNEL */
4174cf49a43SJulian Elischer 
4184cf49a43SJulian Elischer #endif /* _NETGRAPH_NG_MESSAGE_H_ */
4194cf49a43SJulian Elischer 
420