1130368Smlaier/* $FreeBSD$ */ 2130365Smlaier/* $KAME: altq.h,v 1.10 2003/07/10 12:07:47 kjc Exp $ */ 3130365Smlaier 4130365Smlaier/* 5130365Smlaier * Copyright (C) 1998-2003 6130365Smlaier * Sony Computer Science Laboratories Inc. All rights reserved. 7130365Smlaier * 8130365Smlaier * Redistribution and use in source and binary forms, with or without 9130365Smlaier * modification, are permitted provided that the following conditions 10130365Smlaier * are met: 11130365Smlaier * 1. Redistributions of source code must retain the above copyright 12130365Smlaier * notice, this list of conditions and the following disclaimer. 13130365Smlaier * 2. Redistributions in binary form must reproduce the above copyright 14130365Smlaier * notice, this list of conditions and the following disclaimer in the 15130365Smlaier * documentation and/or other materials provided with the distribution. 16130365Smlaier * 17130365Smlaier * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND 18130365Smlaier * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19130365Smlaier * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20130365Smlaier * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE 21130365Smlaier * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22130365Smlaier * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23130365Smlaier * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24130365Smlaier * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25130365Smlaier * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26130365Smlaier * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27130365Smlaier * SUCH DAMAGE. 28130365Smlaier */ 29130365Smlaier#ifndef _ALTQ_ALTQ_H_ 30130365Smlaier#define _ALTQ_ALTQ_H_ 31130365Smlaier 32130368Smlaier#if 0 33130365Smlaier/* 34130365Smlaier * allow altq-3 (altqd(8) and /dev/altq) to coexist with the new pf-based altq. 35130365Smlaier * altq3 is mainly for research experiments. pf-based altq is for daily use. 36130365Smlaier */ 37130365Smlaier#define ALTQ3_COMPAT /* for compatibility with altq-3 */ 38130365Smlaier#define ALTQ3_CLFIER_COMPAT /* for compatibility with altq-3 classifier */ 39130365Smlaier#endif 40130365Smlaier 41130365Smlaier#ifdef ALTQ3_COMPAT 42130365Smlaier#include <sys/param.h> 43130365Smlaier#include <sys/ioccom.h> 44130365Smlaier#include <sys/queue.h> 45130365Smlaier#include <netinet/in.h> 46130365Smlaier 47130365Smlaier#ifndef IFNAMSIZ 48130365Smlaier#define IFNAMSIZ 16 49130365Smlaier#endif 50130365Smlaier#endif /* ALTQ3_COMPAT */ 51130365Smlaier 52130365Smlaier/* altq discipline type */ 53130365Smlaier#define ALTQT_NONE 0 /* reserved */ 54130365Smlaier#define ALTQT_CBQ 1 /* cbq */ 55130365Smlaier#define ALTQT_WFQ 2 /* wfq */ 56130365Smlaier#define ALTQT_AFMAP 3 /* afmap */ 57130365Smlaier#define ALTQT_FIFOQ 4 /* fifoq */ 58130365Smlaier#define ALTQT_RED 5 /* red */ 59130365Smlaier#define ALTQT_RIO 6 /* rio */ 60130365Smlaier#define ALTQT_LOCALQ 7 /* local use */ 61130365Smlaier#define ALTQT_HFSC 8 /* hfsc */ 62130365Smlaier#define ALTQT_CDNR 9 /* traffic conditioner */ 63130365Smlaier#define ALTQT_BLUE 10 /* blue */ 64130365Smlaier#define ALTQT_PRIQ 11 /* priority queue */ 65130365Smlaier#define ALTQT_JOBS 12 /* JoBS */ 66130365Smlaier#define ALTQT_MAX 13 /* should be max discipline type + 1 */ 67130365Smlaier 68130365Smlaier#ifdef ALTQ3_COMPAT 69130365Smlaierstruct altqreq { 70130365Smlaier char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ 71130365Smlaier u_long arg; /* request-specific argument */ 72130365Smlaier}; 73130365Smlaier#endif 74130365Smlaier 75130365Smlaier/* simple token backet meter profile */ 76130365Smlaierstruct tb_profile { 77130365Smlaier u_int rate; /* rate in bit-per-sec */ 78130365Smlaier u_int depth; /* depth in bytes */ 79130365Smlaier}; 80130365Smlaier 81130365Smlaier#ifdef ALTQ3_COMPAT 82130365Smlaierstruct tbrreq { 83130365Smlaier char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */ 84130365Smlaier struct tb_profile tb_prof; /* token bucket profile */ 85130365Smlaier}; 86130365Smlaier 87130365Smlaier#ifdef ALTQ3_CLFIER_COMPAT 88130365Smlaier/* 89130365Smlaier * common network flow info structure 90130365Smlaier */ 91130365Smlaierstruct flowinfo { 92130365Smlaier u_char fi_len; /* total length */ 93130365Smlaier u_char fi_family; /* address family */ 94130365Smlaier u_int8_t fi_data[46]; /* actually longer; address family 95130365Smlaier specific flow info. */ 96130365Smlaier}; 97130365Smlaier 98130365Smlaier/* 99130365Smlaier * flow info structure for internet protocol family. 100130365Smlaier * (currently this is the only protocol family supported) 101130365Smlaier */ 102130365Smlaierstruct flowinfo_in { 103130365Smlaier u_char fi_len; /* sizeof(struct flowinfo_in) */ 104130365Smlaier u_char fi_family; /* AF_INET */ 105130365Smlaier u_int8_t fi_proto; /* IPPROTO_XXX */ 106130365Smlaier u_int8_t fi_tos; /* type-of-service */ 107130365Smlaier struct in_addr fi_dst; /* dest address */ 108130365Smlaier struct in_addr fi_src; /* src address */ 109130365Smlaier u_int16_t fi_dport; /* dest port */ 110130365Smlaier u_int16_t fi_sport; /* src port */ 111130365Smlaier u_int32_t fi_gpi; /* generalized port id for ipsec */ 112130365Smlaier u_int8_t _pad[28]; /* make the size equal to 113130365Smlaier flowinfo_in6 */ 114130365Smlaier}; 115130365Smlaier 116130365Smlaier#ifdef SIN6_LEN 117130365Smlaierstruct flowinfo_in6 { 118130365Smlaier u_char fi6_len; /* sizeof(struct flowinfo_in6) */ 119130365Smlaier u_char fi6_family; /* AF_INET6 */ 120130365Smlaier u_int8_t fi6_proto; /* IPPROTO_XXX */ 121130365Smlaier u_int8_t fi6_tclass; /* traffic class */ 122130365Smlaier u_int32_t fi6_flowlabel; /* ipv6 flowlabel */ 123130365Smlaier u_int16_t fi6_dport; /* dest port */ 124130365Smlaier u_int16_t fi6_sport; /* src port */ 125130365Smlaier u_int32_t fi6_gpi; /* generalized port id */ 126130365Smlaier struct in6_addr fi6_dst; /* dest address */ 127130365Smlaier struct in6_addr fi6_src; /* src address */ 128130365Smlaier}; 129130365Smlaier#endif /* INET6 */ 130130365Smlaier 131130365Smlaier/* 132130365Smlaier * flow filters for AF_INET and AF_INET6 133130365Smlaier */ 134130365Smlaierstruct flow_filter { 135130365Smlaier int ff_ruleno; 136130365Smlaier struct flowinfo_in ff_flow; 137130365Smlaier struct { 138130365Smlaier struct in_addr mask_dst; 139130365Smlaier struct in_addr mask_src; 140130365Smlaier u_int8_t mask_tos; 141130365Smlaier u_int8_t _pad[3]; 142130365Smlaier } ff_mask; 143130365Smlaier u_int8_t _pad2[24]; /* make the size equal to flow_filter6 */ 144130365Smlaier}; 145130365Smlaier 146130365Smlaier#ifdef SIN6_LEN 147130365Smlaierstruct flow_filter6 { 148130365Smlaier int ff_ruleno; 149130365Smlaier struct flowinfo_in6 ff_flow6; 150130365Smlaier struct { 151130365Smlaier struct in6_addr mask6_dst; 152130365Smlaier struct in6_addr mask6_src; 153130365Smlaier u_int8_t mask6_tclass; 154130365Smlaier u_int8_t _pad[3]; 155130365Smlaier } ff_mask6; 156130365Smlaier}; 157130365Smlaier#endif /* INET6 */ 158130365Smlaier#endif /* ALTQ3_CLFIER_COMPAT */ 159130365Smlaier#endif /* ALTQ3_COMPAT */ 160130365Smlaier 161130365Smlaier/* 162130365Smlaier * generic packet counter 163130365Smlaier */ 164130365Smlaierstruct pktcntr { 165130365Smlaier u_int64_t packets; 166130365Smlaier u_int64_t bytes; 167130365Smlaier}; 168130365Smlaier 169130365Smlaier#define PKTCNTR_ADD(cntr, len) \ 170130365Smlaier do { (cntr)->packets++; (cntr)->bytes += len; } while (/*CONSTCOND*/ 0) 171130365Smlaier 172130365Smlaier#ifdef ALTQ3_COMPAT 173130365Smlaier/* 174130365Smlaier * altq related ioctls 175130365Smlaier */ 176130365Smlaier#define ALTQGTYPE _IOWR('q', 0, struct altqreq) /* get queue type */ 177130365Smlaier#if 0 178130365Smlaier/* 179130365Smlaier * these ioctls are currently discipline-specific but could be shared 180130365Smlaier * in the future. 181130365Smlaier */ 182130365Smlaier#define ALTQATTACH _IOW('q', 1, struct altqreq) /* attach discipline */ 183130365Smlaier#define ALTQDETACH _IOW('q', 2, struct altqreq) /* detach discipline */ 184130365Smlaier#define ALTQENABLE _IOW('q', 3, struct altqreq) /* enable discipline */ 185130365Smlaier#define ALTQDISABLE _IOW('q', 4, struct altqreq) /* disable discipline*/ 186130365Smlaier#define ALTQCLEAR _IOW('q', 5, struct altqreq) /* (re)initialize */ 187130365Smlaier#define ALTQCONFIG _IOWR('q', 6, struct altqreq) /* set config params */ 188130365Smlaier#define ALTQADDCLASS _IOWR('q', 7, struct altqreq) /* add a class */ 189130365Smlaier#define ALTQMODCLASS _IOWR('q', 8, struct altqreq) /* modify a class */ 190130365Smlaier#define ALTQDELCLASS _IOWR('q', 9, struct altqreq) /* delete a class */ 191130365Smlaier#define ALTQADDFILTER _IOWR('q', 10, struct altqreq) /* add a filter */ 192130365Smlaier#define ALTQDELFILTER _IOWR('q', 11, struct altqreq) /* delete a filter */ 193130365Smlaier#define ALTQGETSTATS _IOWR('q', 12, struct altqreq) /* get statistics */ 194130365Smlaier#define ALTQGETCNTR _IOWR('q', 13, struct altqreq) /* get a pkt counter */ 195130365Smlaier#endif /* 0 */ 196130365Smlaier#define ALTQTBRSET _IOW('q', 14, struct tbrreq) /* set tb regulator */ 197130365Smlaier#define ALTQTBRGET _IOWR('q', 15, struct tbrreq) /* get tb regulator */ 198130365Smlaier#endif /* ALTQ3_COMPAT */ 199130365Smlaier 200130365Smlaier#ifdef _KERNEL 201130365Smlaier#include <altq/altq_var.h> 202130365Smlaier#endif 203130365Smlaier 204130365Smlaier#endif /* _ALTQ_ALTQ_H_ */ 205