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