1 /* $NetBSD: altq.h,v 1.2 2000/12/14 08:49:49 thorpej Exp $ */ 2 /* $KAME: altq.h,v 1.6 2000/12/14 08:12:45 thorpej Exp $ */ 3 4 /* 5 * Copyright (C) 1998-2000 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 #include <sys/param.h> 33 #include <sys/ioccom.h> 34 #include <sys/queue.h> 35 #include <netinet/in.h> 36 37 #ifndef IFNAMSIZ 38 #define IFNAMSIZ 16 39 #endif 40 41 /* altq discipline type */ 42 #define ALTQT_NONE 0 /* reserved */ 43 #define ALTQT_CBQ 1 /* cbq */ 44 #define ALTQT_WFQ 2 /* wfq */ 45 #define ALTQT_AFMAP 3 /* afmap */ 46 #define ALTQT_FIFOQ 4 /* fifoq */ 47 #define ALTQT_RED 5 /* red */ 48 #define ALTQT_RIO 6 /* rio */ 49 #define ALTQT_LOCALQ 7 /* local use */ 50 #define ALTQT_HFSC 8 /* hfsc */ 51 #define ALTQT_CDNR 9 /* traffic conditioner */ 52 #define ALTQT_BLUE 10 /* blue */ 53 #define ALTQT_PRIQ 11 /* priority queue */ 54 #define ALTQT_MAX 12 /* should be max discipline type + 1 */ 55 56 struct altqreq { 57 char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ 58 u_long arg; /* request-specific argument */ 59 }; 60 61 /* simple token backet meter profile */ 62 struct tb_profile { 63 u_int rate; /* rate in bit-per-sec */ 64 u_int depth; /* depth in bytes */ 65 }; 66 67 struct tbrreq { 68 char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ 69 struct tb_profile tb_prof; /* token bucket profile */ 70 }; 71 72 /* 73 * common network flow info structure 74 */ 75 struct flowinfo { 76 u_char fi_len; /* total length */ 77 u_char fi_family; /* address family */ 78 u_int8_t fi_data[46]; /* actually longer; address family 79 specific flow info. */ 80 }; 81 82 /* 83 * flow info structure for internet protocol family. 84 * (currently this is the only protocol family supported) 85 */ 86 struct flowinfo_in { 87 u_char fi_len; /* sizeof(struct flowinfo_in) */ 88 u_char fi_family; /* AF_INET */ 89 u_int8_t fi_proto; /* IPPROTO_XXX */ 90 u_int8_t fi_tos; /* type-of-service */ 91 struct in_addr fi_dst; /* dest address */ 92 struct in_addr fi_src; /* src address */ 93 u_int16_t fi_dport; /* dest port */ 94 u_int16_t fi_sport; /* src port */ 95 u_int32_t fi_gpi; /* generalized port id for ipsec */ 96 u_int8_t _pad[28]; /* make the size equal to 97 flowinfo_in6 */ 98 }; 99 100 #ifdef SIN6_LEN 101 struct flowinfo_in6 { 102 u_char fi6_len; /* sizeof(struct flowinfo_in6) */ 103 u_char fi6_family; /* AF_INET6 */ 104 u_int8_t fi6_proto; /* IPPROTO_XXX */ 105 u_int8_t fi6_tclass; /* traffic class */ 106 u_int32_t fi6_flowlabel; /* ipv6 flowlabel */ 107 u_int16_t fi6_dport; /* dest port */ 108 u_int16_t fi6_sport; /* src port */ 109 u_int32_t fi6_gpi; /* generalized port id */ 110 struct in6_addr fi6_dst; /* dest address */ 111 struct in6_addr fi6_src; /* src address */ 112 }; 113 #endif /* INET6 */ 114 115 /* 116 * flow filters for AF_INET and AF_INET6 117 */ 118 struct flow_filter { 119 int ff_ruleno; 120 struct flowinfo_in ff_flow; 121 struct { 122 struct in_addr mask_dst; 123 struct in_addr mask_src; 124 u_int8_t mask_tos; 125 u_int8_t _pad[3]; 126 } ff_mask; 127 u_int8_t _pad2[24]; /* make the size equal to flow_filter6 */ 128 }; 129 130 #ifdef SIN6_LEN 131 struct flow_filter6 { 132 int ff_ruleno; 133 struct flowinfo_in6 ff_flow6; 134 struct { 135 struct in6_addr mask6_dst; 136 struct in6_addr mask6_src; 137 u_int8_t mask6_tclass; 138 u_int8_t _pad[3]; 139 } ff_mask6; 140 }; 141 #endif /* INET6 */ 142 143 /* 144 * generic packet counter 145 */ 146 struct pktcntr { 147 u_int64_t packets; 148 u_int64_t bytes; 149 }; 150 151 #define PKTCNTR_ADD(cntr, len) \ 152 do { (cntr)->packets++; (cntr)->bytes += len; } while (0) 153 154 /* 155 * altq related ioctls 156 */ 157 #define ALTQGTYPE _IOWR('q', 0, struct altqreq) /* get queue type */ 158 #if 0 159 /* 160 * these ioctls are currently discipline-specific but could be shared 161 * in the future. 162 */ 163 #define ALTQATTACH _IOW('q', 1, struct altqreq) /* attach discipline */ 164 #define ALTQDETACH _IOW('q', 2, struct altqreq) /* detach discipline */ 165 #define ALTQENABLE _IOW('q', 3, struct altqreq) /* enable discipline */ 166 #define ALTQDISABLE _IOW('q', 4, struct altqreq) /* disable discipline*/ 167 #define ALTQCLEAR _IOW('q', 5, struct altqreq) /* (re)initialize */ 168 #define ALTQCONFIG _IOWR('q', 6, struct altqreq) /* set config params */ 169 #define ALTQADDCLASS _IOWR('q', 7, struct altqreq) /* add a class */ 170 #define ALTQMODCLASS _IOWR('q', 8, struct altqreq) /* modify a class */ 171 #define ALTQDELCLASS _IOWR('q', 9, struct altqreq) /* delete a class */ 172 #define ALTQADDFILTER _IOWR('q', 10, struct altqreq) /* add a filter */ 173 #define ALTQDELFILTER _IOWR('q', 11, struct altqreq) /* delete a filter */ 174 #define ALTQGETSTATS _IOWR('q', 12, struct altqreq) /* get statistics */ 175 #define ALTQGETCNTR _IOWR('q', 13, struct altqreq) /* get a pkt counter */ 176 #endif /* 0 */ 177 #define ALTQTBRSET _IOW('q', 14, struct tbrreq) /* set tb regulator */ 178 #define ALTQTBRGET _IOWR('q', 15, struct tbrreq) /* get tb regulator */ 179 180 /* queue macros only in FreeBSD */ 181 #ifndef LIST_EMPTY 182 #define LIST_EMPTY(head) ((head)->lh_first == NULL) 183 #endif 184 #ifndef LIST_FOREACH 185 #define LIST_FOREACH(var, head, field) \ 186 for((var) = (head)->lh_first; (var); (var) = (var)->field.le_next) 187 #endif 188 189 #ifdef KERNEL 190 #ifndef _KERNEL 191 #define _KERNEL 192 #endif 193 #endif 194 195 #ifdef _KERNEL 196 #include <altq/altq_var.h> 197 #endif 198 199 #endif /* _ALTQ_ALTQ_H_ */ 200