Home | History | Annotate | Line # | Download | only in altq
altq_conf.h revision 1.1.1.1
      1 /*	$KAME: altq_conf.h,v 1.5 2000/12/14 08:12:45 thorpej Exp $	*/
      2 
      3 /*
      4  * Copyright (C) 1998-2000
      5  *	Sony Computer Science Laboratories Inc.  All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
     17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
     20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  */
     28 #ifndef _ALTQ_ALTQ_CONF_H_
     29 #define	_ALTQ_ALTQ_CONF_H_
     30 
     31 #ifdef _KERNEL
     32 
     33 #include <sys/param.h>
     34 #include <sys/conf.h>
     35 #include <sys/kernel.h>
     36 
     37 #if (__FreeBSD_version > 300000)
     38 #define	ALTQ_KLD
     39 #endif
     40 
     41 #ifdef ALTQ_KLD
     42 #include <sys/module.h>
     43 #endif
     44 
     45 #ifndef dev_decl
     46 #ifdef __STDC__
     47 #define	dev_decl(n,t)	d_ ## t ## _t n ## t
     48 #else
     49 #define	dev_decl(n,t)	d_/**/t/**/_t n/**/t
     50 #endif
     51 #endif
     52 
     53 #if defined(__NetBSD__) || defined(__OpenBSD__)
     54 typedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct proc *p));
     55 typedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct proc *p));
     56 typedef int d_ioctl_t __P((dev_t dev, u_long cmd, caddr_t data,
     57 			   int fflag, struct proc *p));
     58 
     59 #define	noopen	(dev_type_open((*))) enodev
     60 #define	noclose	(dev_type_close((*))) enodev
     61 #define	noioctl	(dev_type_ioctl((*))) enodev
     62 #endif /* __NetBSD__ || __OpenBSD__ */
     63 
     64 #if defined(__OpenBSD__)
     65 int altqopen __P((dev_t dev, int oflags, int devtype, struct proc *p));
     66 int altqclose __P((dev_t dev, int fflag, int devtype, struct proc *p));
     67 int altqioctl __P((dev_t dev, u_long cmd, caddr_t data, int fflag,
     68                            struct proc *p));
     69 #endif
     70 
     71 /*
     72  * altq queueing discipline switch structure
     73  */
     74 struct altqsw {
     75         char		*d_name;
     76 	d_open_t	*d_open;
     77 	d_close_t	*d_close;
     78 	d_ioctl_t	*d_ioctl;
     79 };
     80 
     81 #define	altqdev_decl(n) \
     82 	dev_decl(n,open); dev_decl(n,close); dev_decl(n,ioctl)
     83 
     84 #ifdef ALTQ_KLD
     85 
     86 struct altq_module_data {
     87 	int	type;		/* discipline type */
     88 	int	ref;		/* reference count */
     89 	struct	altqsw *altqsw; /* discipline functions */
     90 };
     91 
     92 #define	ALTQ_MODULE(name, type, devsw)					\
     93 static struct altq_module_data name##_moddata = { type, 0, devsw };	\
     94 									\
     95 moduledata_t name##_mod = {						\
     96     #name,								\
     97     altq_module_handler,						\
     98     &name##_moddata							\
     99 };									\
    100 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+96)
    101 
    102 void altq_module_incref __P((int));
    103 void altq_module_declref __P((int));
    104 int altq_module_handler __P((module_t, int, void *));
    105 
    106 #endif /* ALTQ_KLD */
    107 
    108 #endif /* _KERNEL */
    109 #endif /* _ALTQ_ALTQ_CONF_H_ */
    110