1 /*-
2 * Copyright (c) 2004-2008 University of Zagreb
3 * Copyright (c) 2007-2008 FreeBSD Foundation
4 *
5 * This software was developed by the University of Zagreb and the
6 * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
7 * FreeBSD Foundation.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
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.
17 *
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
28 * SUCH DAMAGE.
29 *
30 * $FreeBSD$
31 */
32
33 #ifndef _NETGRAPH_PIPE_H_
34 #define _NETGRAPH_PIPE_H_
35
36 /* Node type name and magic cookie */
37 #define NG_PIPE_NODE_TYPE "pipe"
38 #define NGM_PIPE_COOKIE 200708191
39
40 /* Hook names */
41 #define NG_PIPE_HOOK_UPPER "upper"
42 #define NG_PIPE_HOOK_LOWER "lower"
43
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 */
46
47 /* Statistics structure for one hook */
48 struct ng_pipe_hookstat {
49 u_int64_t fwd_octets;
50 u_int64_t fwd_frames;
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;
55 };
56
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 }, \
65 { NULL }, \
66 }
67
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;
72 };
73
74 /* Keep this in sync with the above structure definition */
75 #define NG_PIPE_STATS_INFO(hstype) { \
76 { "downstream", (hstype) }, \
77 { "upstream", (hstype) }, \
78 { NULL }, \
79 }
80
81 /* Runtime structure for one hook */
82 struct ng_pipe_hookrun {
83 u_int32_t fifo_queues;
84 u_int32_t qin_octets;
85 u_int32_t qin_frames;
86 u_int32_t qout_octets;
87 u_int32_t qout_frames;
88 };
89
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 }, \
97 { NULL }, \
98 }
99
100 /* Runtime structure returned by NGM_PIPE_GET_RUN */
101 struct ng_pipe_run {
102 struct ng_pipe_hookrun downstream;
103 struct ng_pipe_hookrun upstream;
104 };
105
106 /* Keep this in sync with the above structure definition */
107 #define NG_PIPE_RUN_INFO(hstype) { \
108 { "downstream", (hstype) }, \
109 { "upstream", (hstype) }, \
110 { NULL }, \
111 }
112
113 /* Config structure for one hook */
114 struct ng_pipe_hookcfg {
115 u_int64_t bandwidth;
116 u_int64_t ber;
117 u_int32_t qin_size_limit;
118 u_int32_t qout_size_limit;
119 u_int32_t duplicate;
120 u_int32_t fifo;
121 u_int32_t drr;
122 u_int32_t wfq;
123 u_int32_t droptail;
124 u_int32_t drophead;
125 };
126
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 }, \
139 { NULL }, \
140 }
141
142 /* Config structure returned by NGM_PIPE_GET_CFG */
143 struct ng_pipe_cfg {
144 u_int64_t bandwidth;
145 u_int64_t delay;
146 u_int32_t header_offset;
147 u_int32_t overhead;
148 struct ng_pipe_hookcfg downstream;
149 struct ng_pipe_hookcfg upstream;
150 };
151
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) }, \
160 { NULL }, \
161 }
162
163 /* Netgraph commands */
164 enum {
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 */
171 };
172
173 #endif /* _NETGRAPH_PIPE_H_ */
Cache object: 68a02468490b1dfceed8d56549203add
|