altq.h revision 1.2.2.2 1 1.2.2.2 bouyer /* $NetBSD: altq.h,v 1.2.2.2 2001/01/05 17:39:35 bouyer Exp $ */
2 1.2.2.2 bouyer /* $KAME: altq.h,v 1.6 2000/12/14 08:12:45 thorpej Exp $ */
3 1.2.2.2 bouyer
4 1.2.2.2 bouyer /*
5 1.2.2.2 bouyer * Copyright (C) 1998-2000
6 1.2.2.2 bouyer * Sony Computer Science Laboratories Inc. All rights reserved.
7 1.2.2.2 bouyer *
8 1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
9 1.2.2.2 bouyer * modification, are permitted provided that the following conditions
10 1.2.2.2 bouyer * are met:
11 1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
12 1.2.2.2 bouyer * notice, this list of conditions and the following disclaimer.
13 1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
14 1.2.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
15 1.2.2.2 bouyer * documentation and/or other materials provided with the distribution.
16 1.2.2.2 bouyer *
17 1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
18 1.2.2.2 bouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 1.2.2.2 bouyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 1.2.2.2 bouyer * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
21 1.2.2.2 bouyer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 1.2.2.2 bouyer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 1.2.2.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 1.2.2.2 bouyer * SUCH DAMAGE.
28 1.2.2.2 bouyer */
29 1.2.2.2 bouyer #ifndef _ALTQ_ALTQ_H_
30 1.2.2.2 bouyer #define _ALTQ_ALTQ_H_
31 1.2.2.2 bouyer
32 1.2.2.2 bouyer #include <sys/param.h>
33 1.2.2.2 bouyer #include <sys/ioccom.h>
34 1.2.2.2 bouyer #include <sys/queue.h>
35 1.2.2.2 bouyer #include <netinet/in.h>
36 1.2.2.2 bouyer
37 1.2.2.2 bouyer #ifndef IFNAMSIZ
38 1.2.2.2 bouyer #define IFNAMSIZ 16
39 1.2.2.2 bouyer #endif
40 1.2.2.2 bouyer
41 1.2.2.2 bouyer /* altq discipline type */
42 1.2.2.2 bouyer #define ALTQT_NONE 0 /* reserved */
43 1.2.2.2 bouyer #define ALTQT_CBQ 1 /* cbq */
44 1.2.2.2 bouyer #define ALTQT_WFQ 2 /* wfq */
45 1.2.2.2 bouyer #define ALTQT_AFMAP 3 /* afmap */
46 1.2.2.2 bouyer #define ALTQT_FIFOQ 4 /* fifoq */
47 1.2.2.2 bouyer #define ALTQT_RED 5 /* red */
48 1.2.2.2 bouyer #define ALTQT_RIO 6 /* rio */
49 1.2.2.2 bouyer #define ALTQT_LOCALQ 7 /* local use */
50 1.2.2.2 bouyer #define ALTQT_HFSC 8 /* hfsc */
51 1.2.2.2 bouyer #define ALTQT_CDNR 9 /* traffic conditioner */
52 1.2.2.2 bouyer #define ALTQT_BLUE 10 /* blue */
53 1.2.2.2 bouyer #define ALTQT_PRIQ 11 /* priority queue */
54 1.2.2.2 bouyer #define ALTQT_MAX 12 /* should be max discipline type + 1 */
55 1.2.2.2 bouyer
56 1.2.2.2 bouyer struct altqreq {
57 1.2.2.2 bouyer char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */
58 1.2.2.2 bouyer u_long arg; /* request-specific argument */
59 1.2.2.2 bouyer };
60 1.2.2.2 bouyer
61 1.2.2.2 bouyer /* simple token backet meter profile */
62 1.2.2.2 bouyer struct tb_profile {
63 1.2.2.2 bouyer u_int rate; /* rate in bit-per-sec */
64 1.2.2.2 bouyer u_int depth; /* depth in bytes */
65 1.2.2.2 bouyer };
66 1.2.2.2 bouyer
67 1.2.2.2 bouyer struct tbrreq {
68 1.2.2.2 bouyer char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */
69 1.2.2.2 bouyer struct tb_profile tb_prof; /* token bucket profile */
70 1.2.2.2 bouyer };
71 1.2.2.2 bouyer
72 1.2.2.2 bouyer /*
73 1.2.2.2 bouyer * common network flow info structure
74 1.2.2.2 bouyer */
75 1.2.2.2 bouyer struct flowinfo {
76 1.2.2.2 bouyer u_char fi_len; /* total length */
77 1.2.2.2 bouyer u_char fi_family; /* address family */
78 1.2.2.2 bouyer u_int8_t fi_data[46]; /* actually longer; address family
79 1.2.2.2 bouyer specific flow info. */
80 1.2.2.2 bouyer };
81 1.2.2.2 bouyer
82 1.2.2.2 bouyer /*
83 1.2.2.2 bouyer * flow info structure for internet protocol family.
84 1.2.2.2 bouyer * (currently this is the only protocol family supported)
85 1.2.2.2 bouyer */
86 1.2.2.2 bouyer struct flowinfo_in {
87 1.2.2.2 bouyer u_char fi_len; /* sizeof(struct flowinfo_in) */
88 1.2.2.2 bouyer u_char fi_family; /* AF_INET */
89 1.2.2.2 bouyer u_int8_t fi_proto; /* IPPROTO_XXX */
90 1.2.2.2 bouyer u_int8_t fi_tos; /* type-of-service */
91 1.2.2.2 bouyer struct in_addr fi_dst; /* dest address */
92 1.2.2.2 bouyer struct in_addr fi_src; /* src address */
93 1.2.2.2 bouyer u_int16_t fi_dport; /* dest port */
94 1.2.2.2 bouyer u_int16_t fi_sport; /* src port */
95 1.2.2.2 bouyer u_int32_t fi_gpi; /* generalized port id for ipsec */
96 1.2.2.2 bouyer u_int8_t _pad[28]; /* make the size equal to
97 1.2.2.2 bouyer flowinfo_in6 */
98 1.2.2.2 bouyer };
99 1.2.2.2 bouyer
100 1.2.2.2 bouyer #ifdef SIN6_LEN
101 1.2.2.2 bouyer struct flowinfo_in6 {
102 1.2.2.2 bouyer u_char fi6_len; /* sizeof(struct flowinfo_in6) */
103 1.2.2.2 bouyer u_char fi6_family; /* AF_INET6 */
104 1.2.2.2 bouyer u_int8_t fi6_proto; /* IPPROTO_XXX */
105 1.2.2.2 bouyer u_int8_t fi6_tclass; /* traffic class */
106 1.2.2.2 bouyer u_int32_t fi6_flowlabel; /* ipv6 flowlabel */
107 1.2.2.2 bouyer u_int16_t fi6_dport; /* dest port */
108 1.2.2.2 bouyer u_int16_t fi6_sport; /* src port */
109 1.2.2.2 bouyer u_int32_t fi6_gpi; /* generalized port id */
110 1.2.2.2 bouyer struct in6_addr fi6_dst; /* dest address */
111 1.2.2.2 bouyer struct in6_addr fi6_src; /* src address */
112 1.2.2.2 bouyer };
113 1.2.2.2 bouyer #endif /* INET6 */
114 1.2.2.2 bouyer
115 1.2.2.2 bouyer /*
116 1.2.2.2 bouyer * flow filters for AF_INET and AF_INET6
117 1.2.2.2 bouyer */
118 1.2.2.2 bouyer struct flow_filter {
119 1.2.2.2 bouyer int ff_ruleno;
120 1.2.2.2 bouyer struct flowinfo_in ff_flow;
121 1.2.2.2 bouyer struct {
122 1.2.2.2 bouyer struct in_addr mask_dst;
123 1.2.2.2 bouyer struct in_addr mask_src;
124 1.2.2.2 bouyer u_int8_t mask_tos;
125 1.2.2.2 bouyer u_int8_t _pad[3];
126 1.2.2.2 bouyer } ff_mask;
127 1.2.2.2 bouyer u_int8_t _pad2[24]; /* make the size equal to flow_filter6 */
128 1.2.2.2 bouyer };
129 1.2.2.2 bouyer
130 1.2.2.2 bouyer #ifdef SIN6_LEN
131 1.2.2.2 bouyer struct flow_filter6 {
132 1.2.2.2 bouyer int ff_ruleno;
133 1.2.2.2 bouyer struct flowinfo_in6 ff_flow6;
134 1.2.2.2 bouyer struct {
135 1.2.2.2 bouyer struct in6_addr mask6_dst;
136 1.2.2.2 bouyer struct in6_addr mask6_src;
137 1.2.2.2 bouyer u_int8_t mask6_tclass;
138 1.2.2.2 bouyer u_int8_t _pad[3];
139 1.2.2.2 bouyer } ff_mask6;
140 1.2.2.2 bouyer };
141 1.2.2.2 bouyer #endif /* INET6 */
142 1.2.2.2 bouyer
143 1.2.2.2 bouyer /*
144 1.2.2.2 bouyer * generic packet counter
145 1.2.2.2 bouyer */
146 1.2.2.2 bouyer struct pktcntr {
147 1.2.2.2 bouyer u_int64_t packets;
148 1.2.2.2 bouyer u_int64_t bytes;
149 1.2.2.2 bouyer };
150 1.2.2.2 bouyer
151 1.2.2.2 bouyer #define PKTCNTR_ADD(cntr, len) \
152 1.2.2.2 bouyer do { (cntr)->packets++; (cntr)->bytes += len; } while (0)
153 1.2.2.2 bouyer
154 1.2.2.2 bouyer /*
155 1.2.2.2 bouyer * altq related ioctls
156 1.2.2.2 bouyer */
157 1.2.2.2 bouyer #define ALTQGTYPE _IOWR('q', 0, struct altqreq) /* get queue type */
158 1.2.2.2 bouyer #if 0
159 1.2.2.2 bouyer /*
160 1.2.2.2 bouyer * these ioctls are currently discipline-specific but could be shared
161 1.2.2.2 bouyer * in the future.
162 1.2.2.2 bouyer */
163 1.2.2.2 bouyer #define ALTQATTACH _IOW('q', 1, struct altqreq) /* attach discipline */
164 1.2.2.2 bouyer #define ALTQDETACH _IOW('q', 2, struct altqreq) /* detach discipline */
165 1.2.2.2 bouyer #define ALTQENABLE _IOW('q', 3, struct altqreq) /* enable discipline */
166 1.2.2.2 bouyer #define ALTQDISABLE _IOW('q', 4, struct altqreq) /* disable discipline*/
167 1.2.2.2 bouyer #define ALTQCLEAR _IOW('q', 5, struct altqreq) /* (re)initialize */
168 1.2.2.2 bouyer #define ALTQCONFIG _IOWR('q', 6, struct altqreq) /* set config params */
169 1.2.2.2 bouyer #define ALTQADDCLASS _IOWR('q', 7, struct altqreq) /* add a class */
170 1.2.2.2 bouyer #define ALTQMODCLASS _IOWR('q', 8, struct altqreq) /* modify a class */
171 1.2.2.2 bouyer #define ALTQDELCLASS _IOWR('q', 9, struct altqreq) /* delete a class */
172 1.2.2.2 bouyer #define ALTQADDFILTER _IOWR('q', 10, struct altqreq) /* add a filter */
173 1.2.2.2 bouyer #define ALTQDELFILTER _IOWR('q', 11, struct altqreq) /* delete a filter */
174 1.2.2.2 bouyer #define ALTQGETSTATS _IOWR('q', 12, struct altqreq) /* get statistics */
175 1.2.2.2 bouyer #define ALTQGETCNTR _IOWR('q', 13, struct altqreq) /* get a pkt counter */
176 1.2.2.2 bouyer #endif /* 0 */
177 1.2.2.2 bouyer #define ALTQTBRSET _IOW('q', 14, struct tbrreq) /* set tb regulator */
178 1.2.2.2 bouyer #define ALTQTBRGET _IOWR('q', 15, struct tbrreq) /* get tb regulator */
179 1.2.2.2 bouyer
180 1.2.2.2 bouyer /* queue macros only in FreeBSD */
181 1.2.2.2 bouyer #ifndef LIST_EMPTY
182 1.2.2.2 bouyer #define LIST_EMPTY(head) ((head)->lh_first == NULL)
183 1.2.2.2 bouyer #endif
184 1.2.2.2 bouyer #ifndef LIST_FOREACH
185 1.2.2.2 bouyer #define LIST_FOREACH(var, head, field) \
186 1.2.2.2 bouyer for((var) = (head)->lh_first; (var); (var) = (var)->field.le_next)
187 1.2.2.2 bouyer #endif
188 1.2.2.2 bouyer
189 1.2.2.2 bouyer #ifdef KERNEL
190 1.2.2.2 bouyer #ifndef _KERNEL
191 1.2.2.2 bouyer #define _KERNEL
192 1.2.2.2 bouyer #endif
193 1.2.2.2 bouyer #endif
194 1.2.2.2 bouyer
195 1.2.2.2 bouyer #ifdef _KERNEL
196 1.2.2.2 bouyer #include <altq/altq_var.h>
197 1.2.2.2 bouyer #endif
198 1.2.2.2 bouyer
199 1.2.2.2 bouyer #endif /* _ALTQ_ALTQ_H_ */
200