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