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