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