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