xref: /f-stack/tools/compat/include/netgraph/ng_etf.h (revision 3b2bd0f6)
1*3b2bd0f6Slogwang /*-
2*3b2bd0f6Slogwang  * ng_etf.h
3*3b2bd0f6Slogwang  */
4*3b2bd0f6Slogwang 
5*3b2bd0f6Slogwang /*-
6*3b2bd0f6Slogwang  * Copyright (c) 2001, FreeBSD Incorporated
7*3b2bd0f6Slogwang  * All rights reserved.
8*3b2bd0f6Slogwang  *
9*3b2bd0f6Slogwang  * Redistribution and use in source and binary forms, with or without
10*3b2bd0f6Slogwang  * modification, are permitted provided that the following conditions
11*3b2bd0f6Slogwang  * are met:
12*3b2bd0f6Slogwang  * 1. Redistributions of source code must retain the above copyright
13*3b2bd0f6Slogwang  *    notice unmodified, this list of conditions, and the following
14*3b2bd0f6Slogwang  *    disclaimer.
15*3b2bd0f6Slogwang  * 2. Redistributions in binary form must reproduce the above copyright
16*3b2bd0f6Slogwang  *    notice, this list of conditions and the following disclaimer in the
17*3b2bd0f6Slogwang  *    documentation and/or other materials provided with the distribution.
18*3b2bd0f6Slogwang  *
19*3b2bd0f6Slogwang  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20*3b2bd0f6Slogwang  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21*3b2bd0f6Slogwang  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22*3b2bd0f6Slogwang  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23*3b2bd0f6Slogwang  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24*3b2bd0f6Slogwang  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25*3b2bd0f6Slogwang  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26*3b2bd0f6Slogwang  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27*3b2bd0f6Slogwang  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28*3b2bd0f6Slogwang  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29*3b2bd0f6Slogwang  * SUCH DAMAGE.
30*3b2bd0f6Slogwang  *
31*3b2bd0f6Slogwang  * Author: Julian Elischer <[email protected]>
32*3b2bd0f6Slogwang  *
33*3b2bd0f6Slogwang  * $FreeBSD$
34*3b2bd0f6Slogwang  */
35*3b2bd0f6Slogwang 
36*3b2bd0f6Slogwang #ifndef _NETGRAPH_NG_ETF_H_
37*3b2bd0f6Slogwang #define _NETGRAPH_NG_ETF_H_
38*3b2bd0f6Slogwang 
39*3b2bd0f6Slogwang /* Node type name. This should be unique among all netgraph node types */
40*3b2bd0f6Slogwang #define NG_ETF_NODE_TYPE	"etf"
41*3b2bd0f6Slogwang 
42*3b2bd0f6Slogwang /* Node type cookie. Should also be unique. This value MUST change whenever
43*3b2bd0f6Slogwang    an incompatible change is made to this header file, to insure consistency.
44*3b2bd0f6Slogwang    The de facto method for generating cookies is to take the output of the
45*3b2bd0f6Slogwang    date command: date -u +'%s' */
46*3b2bd0f6Slogwang #define NGM_ETF_COOKIE		983084516
47*3b2bd0f6Slogwang 
48*3b2bd0f6Slogwang /* Hook names */
49*3b2bd0f6Slogwang #define NG_ETF_HOOK_DOWNSTREAM	"downstream"
50*3b2bd0f6Slogwang #define NG_ETF_HOOK_NOMATCH	"nomatch"
51*3b2bd0f6Slogwang 
52*3b2bd0f6Slogwang /* Netgraph commands understood by this node type */
53*3b2bd0f6Slogwang enum {
54*3b2bd0f6Slogwang 	NGM_ETF_SET_FLAG = 1,
55*3b2bd0f6Slogwang 	NGM_ETF_GET_STATUS,
56*3b2bd0f6Slogwang 	NGM_ETF_SET_FILTER,
57*3b2bd0f6Slogwang 
58*3b2bd0f6Slogwang };
59*3b2bd0f6Slogwang 
60*3b2bd0f6Slogwang /* This structure is returned by the NGM_ETF_GET_STATUS command */
61*3b2bd0f6Slogwang struct ng_etfstat {
62*3b2bd0f6Slogwang 	u_int32_t   packets_in;		/* packets in from downstream */
63*3b2bd0f6Slogwang 	u_int32_t   packets_out;	/* packets out towards downstream */
64*3b2bd0f6Slogwang };
65*3b2bd0f6Slogwang 
66*3b2bd0f6Slogwang /*
67*3b2bd0f6Slogwang  * This needs to be kept in sync with the above structure definition
68*3b2bd0f6Slogwang  */
69*3b2bd0f6Slogwang #define NG_ETF_STATS_TYPE_INFO	{				\
70*3b2bd0f6Slogwang 	  { "packets_in",	&ng_parse_uint32_type	},	\
71*3b2bd0f6Slogwang 	  { "packets_out",	&ng_parse_uint32_type	},	\
72*3b2bd0f6Slogwang 	  { NULL }						\
73*3b2bd0f6Slogwang }
74*3b2bd0f6Slogwang 
75*3b2bd0f6Slogwang /* This structure is returned by the NGM_ETF_GET_STATUS command */
76*3b2bd0f6Slogwang struct ng_etffilter {
77*3b2bd0f6Slogwang 	char		matchhook[NG_HOOKSIZ]; /* hook name */
78*3b2bd0f6Slogwang 	u_int16_t	ethertype;	/* this ethertype to this hook */
79*3b2bd0f6Slogwang };
80*3b2bd0f6Slogwang 
81*3b2bd0f6Slogwang /*
82*3b2bd0f6Slogwang  * This needs to be kept in sync with the above structure definition
83*3b2bd0f6Slogwang  */
84*3b2bd0f6Slogwang #define NG_ETF_FILTER_TYPE_INFO	{				\
85*3b2bd0f6Slogwang           { "matchhook",	&ng_parse_hookbuf_type  },	\
86*3b2bd0f6Slogwang 	  { "ethertype",	&ng_parse_uint16_type   },	\
87*3b2bd0f6Slogwang 	  { NULL }						\
88*3b2bd0f6Slogwang }
89*3b2bd0f6Slogwang 
90*3b2bd0f6Slogwang #endif /* _NETGRAPH_NG_ETF_H_ */
91