xref: /freebsd/sys/netgraph/ng_source.h (revision 262e143bd46171a6415a5b28af260a5efa2a3db8)
1 /*
2  * ng_source.h
3  */
4 
5 /*-
6  * Copyright 2002 Sandvine Inc.
7  * All rights reserved.
8  *
9  * Subject to the following obligations and disclaimer of warranty, use and
10  * redistribution of this software, in source or object code forms, with or
11  * without modifications are expressly permitted by Sandvine Inc.; provided,
12  * however, that:
13  * 1. Any and all reproductions of the source or object code must include the
14  *    copyright notice above and the following disclaimer of warranties; and
15  * 2. No rights are granted, in any manner or form, to use Sandvine Inc.
16  *    trademarks, including the mark "SANDVINE" on advertising, endorsements,
17  *    or otherwise except as such appears in the above copyright notice or in
18  *    the software.
19  *
20  * THIS SOFTWARE IS BEING PROVIDED BY SANDVINE "AS IS", AND TO THE MAXIMUM
21  * EXTENT PERMITTED BY LAW, SANDVINE MAKES NO REPRESENTATIONS OR WARRANTIES,
22  * EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
23  * ANY AND ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
24  * PURPOSE, OR NON-INFRINGEMENT.  SANDVINE DOES NOT WARRANT, GUARANTEE, OR
25  * MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE
26  * USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY
27  * OR OTHERWISE.  IN NO EVENT SHALL SANDVINE BE LIABLE FOR ANY DAMAGES
28  * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
29  * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30  * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
31  * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34  * THIS SOFTWARE, EVEN IF SANDVINE IS ADVISED OF THE POSSIBILITY OF SUCH
35  * DAMAGE.
36  *
37  * Author: Dave Chapeskie <dchapeskie@sandvine.com>
38  *
39  * $FreeBSD$
40  */
41 
42 #ifndef _NETGRAPH_NG_SOURCE_H_
43 #define _NETGRAPH_NG_SOURCE_H_
44 
45 /* Node type name and magic cookie */
46 #define NG_SOURCE_NODE_TYPE	"source"
47 #define NGM_SOURCE_COOKIE	1110646684
48 
49 /* Hook names */
50 #define NG_SOURCE_HOOK_INPUT	"input"
51 #define NG_SOURCE_HOOK_OUTPUT	"output"
52 
53 /* Statistics structure returned by NGM_SOURCE_GET_STATS */
54 struct ng_source_stats {
55 	u_int64_t	outOctets;
56 	u_int64_t	outFrames;
57 	u_int32_t	queueOctets;
58 	u_int32_t	queueFrames;
59 	struct timeval	startTime;
60 	struct timeval	endTime;
61 	struct timeval	elapsedTime;
62 };
63 
64 extern const struct ng_parse_type ng_source_timeval_type;
65 /* Keep this in sync with the above structure definition */
66 #define NG_SOURCE_STATS_TYPE_INFO	{			\
67 	  { "outOctets",	&ng_parse_uint64_type	},	\
68 	  { "outFrames",	&ng_parse_uint64_type	},	\
69 	  { "queueOctets",	&ng_parse_uint32_type	},	\
70 	  { "queueFrames",	&ng_parse_uint32_type	},	\
71 	  { "startTime",	&ng_source_timeval_type },	\
72 	  { "endTime",		&ng_source_timeval_type },	\
73 	  { "elapsedTime",	&ng_source_timeval_type },	\
74 	  { NULL }						\
75 }
76 
77 /* Netgraph commands */
78 enum {
79 	NGM_SOURCE_GET_STATS = 1,	/* get stats */
80 	NGM_SOURCE_CLR_STATS,		/* clear stats */
81 	NGM_SOURCE_GETCLR_STATS,	/* atomically get and clear stats */
82 	NGM_SOURCE_START,		/* start sending queued data */
83 	NGM_SOURCE_STOP,		/* stop sending queued data */
84 	NGM_SOURCE_CLR_DATA,		/* clear the queued data */
85 	NGM_SOURCE_SETIFACE,		/* configure downstream iface */
86 };
87 
88 #endif /* _NETGRAPH_NG_SOURCE_H_ */
89