2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2004-2008 University of Zagreb
5 * Copyright (c) 2007-2008 FreeBSD Foundation
7 * This software was developed by the University of Zagreb and the
8 * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #ifndef _NETGRAPH_PIPE_H_
36 #define _NETGRAPH_PIPE_H_
38 /* Node type name and magic cookie */
39 #define NG_PIPE_NODE_TYPE "pipe"
40 #define NGM_PIPE_COOKIE 200708191
43 #define NG_PIPE_HOOK_UPPER "upper"
44 #define NG_PIPE_HOOK_LOWER "lower"
46 #define MAX_FSIZE 65536 /* Largest supported frame size, in bytes, for BER */
47 #define MAX_OHSIZE 256 /* Largest supported dummy-framing size, in bytes */
49 /* Statistics structure for one hook */
50 struct ng_pipe_hookstat {
53 u_int64_t in_disc_octets;
54 u_int64_t in_disc_frames;
55 u_int64_t out_disc_octets;
56 u_int64_t out_disc_frames;
59 /* Keep this in sync with the above structure definition */
60 #define NG_PIPE_HOOKSTAT_INFO { \
61 { "FwdOctets", &ng_parse_uint64_type }, \
62 { "FwdFrames", &ng_parse_uint64_type }, \
63 { "queueDropOctets", &ng_parse_uint64_type }, \
64 { "queueDropFrames", &ng_parse_uint64_type }, \
65 { "delayDropOctets", &ng_parse_uint64_type }, \
66 { "delayDropFrames", &ng_parse_uint64_type }, \
70 /* Statistics structure returned by NGM_PIPE_GET_STATS */
71 struct ng_pipe_stats {
72 struct ng_pipe_hookstat downstream;
73 struct ng_pipe_hookstat upstream;
76 /* Keep this in sync with the above structure definition */
77 #define NG_PIPE_STATS_INFO(hstype) { \
78 { "downstream", (hstype) }, \
79 { "upstream", (hstype) }, \
83 /* Runtime structure for one hook */
84 struct ng_pipe_hookrun {
85 u_int32_t fifo_queues;
88 u_int32_t qout_octets;
89 u_int32_t qout_frames;
92 /* Keep this in sync with the above structure definition */
93 #define NG_PIPE_HOOKRUN_INFO { \
94 { "queues", &ng_parse_uint32_type }, \
95 { "queuedOctets", &ng_parse_uint32_type }, \
96 { "queuedFrames", &ng_parse_uint32_type }, \
97 { "delayedOctets", &ng_parse_uint32_type }, \
98 { "delayedFrames", &ng_parse_uint32_type }, \
102 /* Runtime structure returned by NGM_PIPE_GET_RUN */
104 struct ng_pipe_hookrun downstream;
105 struct ng_pipe_hookrun upstream;
108 /* Keep this in sync with the above structure definition */
109 #define NG_PIPE_RUN_INFO(hstype) { \
110 { "downstream", (hstype) }, \
111 { "upstream", (hstype) }, \
115 /* Config structure for one hook */
116 struct ng_pipe_hookcfg {
119 u_int32_t qin_size_limit;
120 u_int32_t qout_size_limit;
129 /* Keep this in sync with the above structure definition */
130 #define NG_PIPE_HOOKCFG_INFO { \
131 { "bandwidth", &ng_parse_uint64_type }, \
132 { "BER", &ng_parse_uint64_type }, \
133 { "queuelen", &ng_parse_uint32_type }, \
134 { "delaylen", &ng_parse_uint32_type }, \
135 { "duplicate", &ng_parse_uint32_type }, \
136 { "fifo", &ng_parse_uint32_type }, \
137 { "drr", &ng_parse_uint32_type }, \
138 { "wfq", &ng_parse_uint32_type }, \
139 { "droptail", &ng_parse_uint32_type }, \
140 { "drophead", &ng_parse_uint32_type }, \
144 /* Config structure returned by NGM_PIPE_GET_CFG */
148 u_int32_t header_offset;
150 struct ng_pipe_hookcfg downstream;
151 struct ng_pipe_hookcfg upstream;
154 /* Keep this in sync with the above structure definition */
155 #define NG_PIPE_CFG_INFO(hstype) { \
156 { "bandwidth", &ng_parse_uint64_type }, \
157 { "delay", &ng_parse_uint64_type }, \
158 { "header_offset", &ng_parse_uint32_type }, \
159 { "overhead", &ng_parse_uint32_type }, \
160 { "downstream", (hstype) }, \
161 { "upstream", (hstype) }, \
165 /* Netgraph commands */
167 NGM_PIPE_GET_STATS=1, /* get stats */
168 NGM_PIPE_CLR_STATS, /* clear stats */
169 NGM_PIPE_GETCLR_STATS, /* atomically get and clear stats */
170 NGM_PIPE_GET_RUN, /* get current runtime status */
171 NGM_PIPE_GET_CFG, /* get configurable parameters */
172 NGM_PIPE_SET_CFG, /* set configurable parameters */
175 #endif /* _NETGRAPH_PIPE_H_ */