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