Sync usage with man page.
[netbsd-mini2440.git] / usr.sbin / altq / libaltq / altq_qop.h
blob1ea6f37a8a5545a77efdc3169c8569a575ae3a37
1 /* $NetBSD: altq_qop.h,v 1.4 2006/11/26 11:38:07 peter Exp $ */
2 /* $KAME: altq_qop.h,v 1.5 2002/02/12 10:14:01 kjc Exp $ */
3 /*
4 * Copyright (C) 1999-2000
5 * Sony Computer Science Laboratories, Inc. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
28 #ifndef _ALTQ_QOP_H_
29 #define _ALTQ_QOP_H_
31 #include <sys/queue.h>
32 #include <altq/altq.h>
33 #include <altq/altq_red.h>
35 struct ifinfo;
36 struct classinfo;
37 struct fltrinfo;
39 /* queueing discipline specific command parsers */
40 struct qdisc_parser {
41 const char *qname;
42 int (*interface_parser)(const char *ifname, int argc, char **argv);
43 int (*class_parser)(const char *ifname, const char *clname,
44 const char *parent, int argc, char **argv);
47 /* queueing discipline specific operations */
48 struct qdisc_ops {
49 int qdisc_type; /* discipline type (e.g., ALTQT_CBQ) */
50 const char *qname; /* discipline name (e.g., cbq) */
52 /* interface operations */
53 int (*attach)(struct ifinfo *);
54 int (*detach)(struct ifinfo *);
55 int (*clear)(struct ifinfo *);
56 int (*enable)(struct ifinfo *);
57 int (*disable)(struct ifinfo *);
59 /* class operations (optional) */
60 int (*add_class)(struct classinfo *);
61 int (*modify_class)(struct classinfo *, void *);
62 int (*delete_class)(struct classinfo *);
64 /* filter operations (optional) */
65 int (*add_filter)(struct fltrinfo *);
66 int (*delete_filter)(struct fltrinfo *);
70 * interface info
72 struct ifinfo {
73 LIST_ENTRY(ifinfo) next; /* next entry on iflist */
74 char *ifname; /* interface name */
75 u_int bandwidth; /* bandwidth in bps */
76 u_int ifmtu; /* mtu of the interface */
77 u_int ifindex; /* interface index */
78 int enabled; /* hfsc on/off state */
79 LIST_HEAD(, classinfo) cllist; /* class list */
80 LIST_HEAD(, fltrinfo) fltr_rules; /* filter rule list */
82 struct classinfo *resv_class; /* special class for rsvp */
84 /* discipline info */
85 struct qdisc_ops *qdisc; /* qdisc system interface */
86 void *private; /* discipline specific data */
87 int (*enable_hook)(struct ifinfo *);
88 int (*delete_hook)(struct ifinfo *);
92 * class info
94 struct classinfo {
95 LIST_ENTRY(classinfo) next; /* next entry on cllist
96 of ifinfo */
97 u_long handle; /* class handle */
98 char *clname; /* class name */
99 struct ifinfo *ifinfo; /* back pointer to ifinfo */
100 struct classinfo *parent; /* parent class */
101 struct classinfo *sibling; /* sibling class */
102 struct classinfo *child; /* child class */
103 LIST_HEAD(, fltrinfo) fltrlist; /* filters for this class */
105 void *private; /* discipline specific data */
106 int (*delete_hook)(struct classinfo *);
110 * filter info
112 struct fltrinfo {
113 LIST_ENTRY(fltrinfo) next; /* next entry on fltrlist
114 of classinfo */
115 LIST_ENTRY(fltrinfo) nextrule; /* next entry on fltr_rules
116 of ifinfo */
117 u_long handle; /* filter handle */
118 char *flname; /* filter name, if specified */
119 struct flow_filter fltr; /* filter value */
120 struct classinfo *clinfo; /* back pointer to classinfo */
122 /* for consistency check */
123 int line_no; /* config file line number */
124 int dontwarn; /* supress warning msg */
127 int do_command(FILE *infp);
128 int qcmd_enable(const char *ifname);
129 int qcmd_disable(const char *ifname);
130 int qcmd_delete_if(const char *ifname);
131 int qcmd_clear_hierarchy(const char *ifname);
132 int qcmd_enableall(void);
133 int qcmd_disableall(void);
134 int qcmd_config(void);
135 int qcmd_init(void);
136 int qcmd_clear(const char *ifname);
137 int qcmd_destroyall(void);
138 int qcmd_restart(void);
139 int qcmd_delete_class(const char *ifname, const char *clname);
140 int qcmd_add_filter(const char *ifname, const char *clname, const char *flname,
141 const struct flow_filter *fltr);
142 int qcmd_delete_filter(const char *ifname, const char *clname,
143 const char *flname);
144 int qcmd_tbr_register(const char *ifname, u_int rate, u_int size);
145 int qop_enable(struct ifinfo *ifinfo);
146 int qop_disable(struct ifinfo *ifinfo);
147 int qop_delete_if(struct ifinfo *ifinfo);
148 int qop_clear(struct ifinfo *ifinfo);
150 int qop_add_if(struct ifinfo **rp, const char *ifname, u_int bandwidth,
151 struct qdisc_ops *qdisc_ops, void *if_private);
152 int qop_delete_if(struct ifinfo *ifinfo);
154 int qop_add_class(struct classinfo **rp, const char *clname,
155 struct ifinfo *ifinfo, struct classinfo *parent,
156 void *class_private);
157 int qop_modify_class(struct classinfo *clinfo, void *arg);
158 int qop_delete_class(struct classinfo *clinfo);
160 int qop_add_filter(struct fltrinfo **rp,
161 struct classinfo *clinfo,
162 const char *flname,
163 const struct flow_filter *fltr,
164 struct fltrinfo **conflict);
165 int qop_delete_filter(struct fltrinfo *fltr);
167 int is_q_enabled(const char *ifname);
168 struct ifinfo *ifname2ifinfo(const char *ifname);
169 struct ifinfo *input_ifname2ifinfo(const char *ifname);
170 struct classinfo *clname2clinfo(const struct ifinfo *ifinfo,
171 const char *clname);
172 struct classinfo * clhandle2clinfo(struct ifinfo *ifinfo, u_long handle);
173 struct fltrinfo *flname2flinfo(const struct classinfo *clinfo,
174 const char *flname);
175 struct fltrinfo *flhandle2fltrinfo(struct ifinfo *ifinfo, u_long handle);
176 void print_filter(const struct flow_filter *filt);
177 const char *qoperror(int qoperrno);
178 u_int get_ifindex(const char *ifname);
179 struct classinfo *get_rootclass(struct ifinfo *ifinfo);
180 struct classinfo *get_nextclass(struct classinfo *clinfo);
181 u_long atobps(const char *s);
182 u_long atobytes(const char *s);
183 int qop_red_set_defaults(int th_min, int th_max, int inv_pmax);
184 int qop_rio_set_defaults(struct redparams *params);
185 int open_module(const char *devname, int flags);
186 int client_input(FILE *fp);
188 /* misc system errors */
189 #define QOPERR_OK 0 /* no error */
190 #define QOPERR_SYSCALL 1 /* syscall err; see errno */
191 #define QOPERR_NOMEM 2 /* not enough memory */
192 #define QOPERR_INVAL 3 /* invalid parameter */
193 #define QOPERR_RANGE 4 /* out of range */
194 #define QOPERR_BADIF 5 /* bad interface name */
195 #define QOPERR_BADCLASS 6 /* bad class name */
196 #define QOPERR_BADFILTER 7 /* bad filter name */
198 /* class errors */
199 #define QOPERR_CLASS 8 /* class failure */
200 #define QOPERR_CLASS_INVAL 9 /* bad class value */
201 #define QOPERR_CLASS_PERM 10 /* class operation not permitted */
203 /* filter errors */
204 #define QOPERR_FILTER 11 /* filter failure */
205 #define QOPERR_FILTER_INVAL 12 /* bad filter value */
206 #define QOPERR_FILTER_SHADOW 13 /* shadows an existing filter */
208 /* addmission errors */
209 #define QOPERR_ADMISSION 14 /* admission control failure */
210 #define QOPERR_ADMISSION_NOBW 15 /* insufficient bandwidth */
211 #define QOPERR_ADMISSION_DELAY 16 /* cannot meet delay bound req */
212 #define QOPERR_ADMISSION_NOSVC 17 /* no service available */
214 /* policy errors */
215 #define QOPERR_POLICY 18 /* policy control failure */
217 #define QOPERR_MAX 18
219 extern int filter_dontwarn;/* supress warning for the current filter */
220 extern const char *altqconfigfile; /* config file name */
221 extern const char *qop_errlist[]; /* error string list */
222 extern struct qdisc_ops nop_qdisc;
223 extern char *cur_ifname(void);
224 extern struct qdisc_parser qdisc_parser[];
226 #ifndef RSVPD
227 /* rename LOG() to log_write() */
228 #define LOG log_write
229 void log_write(int, int, const char *, ...);
231 /* stuff defined in rsvp headers */
232 #define IsDebug(type) (l_debug >= LOG_DEBUG && (m_debug & (type)))
233 #define DEBUG_ALTQ 0x40
235 #define ntoh16(x) ((u_int16_t)ntohs((u_int16_t)(x)))
236 #define ntoh32(x) ((u_int32_t)ntohl((u_int32_t)(x)))
237 #define hton16(x) ((u_int16_t)htons((u_int16_t)(x)))
238 #define hton32(x) ((u_int32_t)htonl((u_int32_t)(x)))
240 extern int if_num; /* number of phyints */
241 extern int m_debug; /* Debug output control bits */
242 extern int l_debug; /* Logging severity level */
243 extern int line_no; /* current line number in config file */
244 extern int daemonize; /* log_write uses stderr if daemonize is 0 */
246 #endif /* !RSVPD */
248 #ifdef INET6
249 /* a macro to handle v6 address in 32-bit fields */
250 #define IN6ADDR32(a, i) (*(u_int32_t *)(&(a)->s6_addr[(i)<<2]))
251 #endif
253 #endif /* _ALTQ_QOP_H_ */