]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sys/contrib/altq/altq/altq.h
MFC r287009, r287120 and r298131:
[FreeBSD/stable/10.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_FAIRQ             13      /* fairq */
67 #define ALTQT_CODEL             14      /* CoDel */
68 #define ALTQT_MAX               15      /* should be max discipline type + 1 */
69
70 #ifdef ALTQ3_COMPAT
71 struct  altqreq {
72         char    ifname[IFNAMSIZ];       /* if name, e.g. "en0" */
73         u_long  arg;                    /* request-specific argument */
74 };
75 #endif
76
77 /* simple token backet meter profile */
78 struct  tb_profile {
79         u_int   rate;   /* rate in bit-per-sec */
80         u_int   depth;  /* depth in bytes */
81 };
82
83 #ifdef ALTQ3_COMPAT
84 struct  tbrreq {
85         char    ifname[IFNAMSIZ];       /* if name, e.g. "en0" */
86         struct  tb_profile tb_prof;     /* token bucket profile */
87 };
88
89 #ifdef ALTQ3_CLFIER_COMPAT
90 /*
91  * common network flow info structure
92  */
93 struct flowinfo {
94         u_char          fi_len;         /* total length */
95         u_char          fi_family;      /* address family */
96         u_int8_t        fi_data[46];    /* actually longer; address family
97                                            specific flow info. */
98 };
99
100 /*
101  * flow info structure for internet protocol family.
102  * (currently this is the only protocol family supported)
103  */
104 struct flowinfo_in {
105         u_char          fi_len;         /* sizeof(struct flowinfo_in) */
106         u_char          fi_family;      /* AF_INET */
107         u_int8_t        fi_proto;       /* IPPROTO_XXX */
108         u_int8_t        fi_tos;         /* type-of-service */
109         struct in_addr  fi_dst;         /* dest address */
110         struct in_addr  fi_src;         /* src address */
111         u_int16_t       fi_dport;       /* dest port */
112         u_int16_t       fi_sport;       /* src port */
113         u_int32_t       fi_gpi;         /* generalized port id for ipsec */
114         u_int8_t        _pad[28];       /* make the size equal to
115                                            flowinfo_in6 */
116 };
117
118 #ifdef SIN6_LEN
119 struct flowinfo_in6 {
120         u_char          fi6_len;        /* sizeof(struct flowinfo_in6) */
121         u_char          fi6_family;     /* AF_INET6 */
122         u_int8_t        fi6_proto;      /* IPPROTO_XXX */
123         u_int8_t        fi6_tclass;     /* traffic class */
124         u_int32_t       fi6_flowlabel;  /* ipv6 flowlabel */
125         u_int16_t       fi6_dport;      /* dest port */
126         u_int16_t       fi6_sport;      /* src port */
127         u_int32_t       fi6_gpi;        /* generalized port id */
128         struct in6_addr fi6_dst;        /* dest address */
129         struct in6_addr fi6_src;        /* src address */
130 };
131 #endif /* INET6 */
132
133 /*
134  * flow filters for AF_INET and AF_INET6
135  */
136 struct flow_filter {
137         int                     ff_ruleno;
138         struct flowinfo_in      ff_flow;
139         struct {
140                 struct in_addr  mask_dst;
141                 struct in_addr  mask_src;
142                 u_int8_t        mask_tos;
143                 u_int8_t        _pad[3];
144         } ff_mask;
145         u_int8_t _pad2[24];     /* make the size equal to flow_filter6 */
146 };
147
148 #ifdef SIN6_LEN
149 struct flow_filter6 {
150         int                     ff_ruleno;
151         struct flowinfo_in6     ff_flow6;
152         struct {
153                 struct in6_addr mask6_dst;
154                 struct in6_addr mask6_src;
155                 u_int8_t        mask6_tclass;
156                 u_int8_t        _pad[3];
157         } ff_mask6;
158 };
159 #endif /* INET6 */
160 #endif /* ALTQ3_CLFIER_COMPAT */
161 #endif /* ALTQ3_COMPAT */
162
163 /*
164  * generic packet counter
165  */
166 struct pktcntr {
167         u_int64_t       packets;
168         u_int64_t       bytes;
169 };
170
171 #define PKTCNTR_ADD(cntr, len)  \
172         do { (cntr)->packets++; (cntr)->bytes += len; } while (/*CONSTCOND*/ 0)
173
174 #ifdef ALTQ3_COMPAT
175 /*
176  * altq related ioctls
177  */
178 #define ALTQGTYPE       _IOWR('q', 0, struct altqreq)   /* get queue type */
179 #if 0
180 /*
181  * these ioctls are currently discipline-specific but could be shared
182  * in the future.
183  */
184 #define ALTQATTACH      _IOW('q', 1, struct altqreq)    /* attach discipline */
185 #define ALTQDETACH      _IOW('q', 2, struct altqreq)    /* detach discipline */
186 #define ALTQENABLE      _IOW('q', 3, struct altqreq)    /* enable discipline */
187 #define ALTQDISABLE     _IOW('q', 4, struct altqreq)    /* disable discipline*/
188 #define ALTQCLEAR       _IOW('q', 5, struct altqreq)    /* (re)initialize */
189 #define ALTQCONFIG      _IOWR('q', 6, struct altqreq)   /* set config params */
190 #define ALTQADDCLASS    _IOWR('q', 7, struct altqreq)   /* add a class */
191 #define ALTQMODCLASS    _IOWR('q', 8, struct altqreq)   /* modify a class */
192 #define ALTQDELCLASS    _IOWR('q', 9, struct altqreq)   /* delete a class */
193 #define ALTQADDFILTER   _IOWR('q', 10, struct altqreq)  /* add a filter */
194 #define ALTQDELFILTER   _IOWR('q', 11, struct altqreq)  /* delete a filter */
195 #define ALTQGETSTATS    _IOWR('q', 12, struct altqreq)  /* get statistics */
196 #define ALTQGETCNTR     _IOWR('q', 13, struct altqreq)  /* get a pkt counter */
197 #endif /* 0 */
198 #define ALTQTBRSET      _IOW('q', 14, struct tbrreq)    /* set tb regulator */
199 #define ALTQTBRGET      _IOWR('q', 15, struct tbrreq)   /* get tb regulator */
200 #endif /* ALTQ3_COMPAT */
201
202 #ifdef _KERNEL
203 #include <altq/altq_var.h>
204 #endif
205
206 #endif /* _ALTQ_ALTQ_H_ */