2 * Copyright (c) 2004-2008 University of Zagreb
3 * Copyright (c) 2007-2008 FreeBSD Foundation
5 * This software was developed by the University of Zagreb and the
6 * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #ifndef _NETGRAPH_PIPE_H_
34 #define _NETGRAPH_PIPE_H_
36 /* Node type name and magic cookie */
37 #define NG_PIPE_NODE_TYPE "pipe"
38 #define NGM_PIPE_COOKIE 200708191
41 #define NG_PIPE_HOOK_UPPER "upper"
42 #define NG_PIPE_HOOK_LOWER "lower"
44 #define MAX_FSIZE 16384 /* Largest supported frame size, in bytes, for BER */
45 #define MAX_OHSIZE 256 /* Largest supported dummy-framing size, in bytes */
47 /* Statistics structure for one hook */
48 struct ng_pipe_hookstat {
51 u_int64_t in_disc_octets;
52 u_int64_t in_disc_frames;
53 u_int64_t out_disc_octets;
54 u_int64_t out_disc_frames;
57 /* Keep this in sync with the above structure definition */
58 #define NG_PIPE_HOOKSTAT_INFO { \
59 { "FwdOctets", &ng_parse_uint64_type }, \
60 { "FwdFrames", &ng_parse_uint64_type }, \
61 { "queueDropOctets", &ng_parse_uint64_type }, \
62 { "queueDropFrames", &ng_parse_uint64_type }, \
63 { "delayDropOctets", &ng_parse_uint64_type }, \
64 { "delayDropFrames", &ng_parse_uint64_type }, \
68 /* Statistics structure returned by NGM_PIPE_GET_STATS */
69 struct ng_pipe_stats {
70 struct ng_pipe_hookstat downstream;
71 struct ng_pipe_hookstat upstream;
74 /* Keep this in sync with the above structure definition */
75 #define NG_PIPE_STATS_INFO(hstype) { \
76 { "downstream", (hstype) }, \
77 { "upstream", (hstype) }, \
81 /* Runtime structure for one hook */
82 struct ng_pipe_hookrun {
83 u_int32_t fifo_queues;
86 u_int32_t qout_octets;
87 u_int32_t qout_frames;
90 /* Keep this in sync with the above structure definition */
91 #define NG_PIPE_HOOKRUN_INFO { \
92 { "queues", &ng_parse_uint32_type }, \
93 { "queuedOctets", &ng_parse_uint32_type }, \
94 { "queuedFrames", &ng_parse_uint32_type }, \
95 { "delayedOctets", &ng_parse_uint32_type }, \
96 { "delayedFrames", &ng_parse_uint32_type }, \
100 /* Runtime structure returned by NGM_PIPE_GET_RUN */
102 struct ng_pipe_hookrun downstream;
103 struct ng_pipe_hookrun upstream;
106 /* Keep this in sync with the above structure definition */
107 #define NG_PIPE_RUN_INFO(hstype) { \
108 { "downstream", (hstype) }, \
109 { "upstream", (hstype) }, \
113 /* Config structure for one hook */
114 struct ng_pipe_hookcfg {
117 u_int32_t qin_size_limit;
118 u_int32_t qout_size_limit;
127 /* Keep this in sync with the above structure definition */
128 #define NG_PIPE_HOOKCFG_INFO { \
129 { "bandwidth", &ng_parse_uint64_type }, \
130 { "BER", &ng_parse_uint64_type }, \
131 { "queuelen", &ng_parse_uint32_type }, \
132 { "delaylen", &ng_parse_uint32_type }, \
133 { "duplicate", &ng_parse_uint32_type }, \
134 { "fifo", &ng_parse_uint32_type }, \
135 { "drr", &ng_parse_uint32_type }, \
136 { "wfq", &ng_parse_uint32_type }, \
137 { "droptail", &ng_parse_uint32_type }, \
138 { "drophead", &ng_parse_uint32_type }, \
142 /* Config structure returned by NGM_PIPE_GET_CFG */
146 u_int32_t header_offset;
148 struct ng_pipe_hookcfg downstream;
149 struct ng_pipe_hookcfg upstream;
152 /* Keep this in sync with the above structure definition */
153 #define NG_PIPE_CFG_INFO(hstype) { \
154 { "bandwidth", &ng_parse_uint64_type }, \
155 { "delay", &ng_parse_uint64_type }, \
156 { "header_offset", &ng_parse_uint32_type }, \
157 { "overhead", &ng_parse_uint32_type }, \
158 { "downstream", (hstype) }, \
159 { "upstream", (hstype) }, \
163 /* Netgraph commands */
165 NGM_PIPE_GET_STATS=1, /* get stats */
166 NGM_PIPE_CLR_STATS, /* clear stats */
167 NGM_PIPE_GETCLR_STATS, /* atomically get and clear stats */
168 NGM_PIPE_GET_RUN, /* get current runtime status */
169 NGM_PIPE_GET_CFG, /* get configurable parameters */
170 NGM_PIPE_SET_CFG, /* set configurable parameters */
173 #endif /* _NETGRAPH_PIPE_H_ */