*** ../kame/freebsd4/lib/libaltq/Makefile	Mon Feb  3 15:25:29 2003
--- ./freebsd4/lib/libaltq/Makefile	Thu Feb 27 15:17:54 2003
***************
*** 1,9 ****
  LIB=	altq
  SRCS=	parser.c qop.c qop_blue.c qop_cbq.c qop_cdnr.c \
  	qop_conf.c qop_dummy.c qop_errlist.c qop_fifoq.c qop_hfsc.c \
! 	qop_jobs.c qop_priq.c qop_red.c qop_rio.c qop_wfq.c quip_server.c
  CFLAGS+=-DALTQ -DINET6
  
  .PATH:	${.CURDIR}/../../kame/libaltq
  
  .include <bsd.lib.mk>
--- 1,10 ----
  LIB=	altq
  SRCS=	parser.c qop.c qop_blue.c qop_cbq.c qop_cdnr.c \
  	qop_conf.c qop_dummy.c qop_errlist.c qop_fifoq.c qop_hfsc.c \
! 	qop_jobs.c qop_priq.c qop_red.c qop_rio.c qop_wfq.c qop_pbs.c \
! 	quip_server.c
  CFLAGS+=-DALTQ -DINET6
  
  .PATH:	${.CURDIR}/../../kame/libaltq
  
  .include <bsd.lib.mk>
*** ../kame/freebsd4/sys/conf/files	Sun Oct 27 05:21:10 2002
--- ./freebsd4/sys/conf/files	Thu Feb 27 15:17:54 2003
***************
*** 69,78 ****
--- 69,79 ----
  altq/altq_red.c		optional altq
  altq/altq_rio.c		optional altq
  altq/altq_rmclass.c	optional altq
  altq/altq_subr.c	optional altq
  altq/altq_wfq.c		optional altq
+ altq/altq_pbs.c		optional altq
  coda/coda_namecache.c	optional vcoda
  coda/coda_fbsd.c	optional vcoda
  coda/coda_psdev.c	optional vcoda
  coda/coda_subr.c	optional vcoda
  coda/coda_venus.c	optional vcoda
*** ../kame/freebsd4/sys/conf/options	Mon Feb  3 10:54:47 2003
--- ./freebsd4/sys/conf/options	Thu Feb 27 15:17:54 2003
***************
*** 260,269 ****
--- 260,270 ----
  ALTQ_CDNR		opt_altq.h
  ALTQ_BLUE		opt_altq.h
  ALTQ_PRIQ		opt_altq.h
  ALTQ_NOPCC		opt_altq.h
  ALTQ_DEBUG		opt_altq.h
+ ALTQ_PBS		opt_altq.h
   
  ACCEPT_FILTER_DATA
  ACCEPT_FILTER_HTTP
  BOOTP			opt_bootp.h
  BOOTP_COMPAT		opt_bootp.h
*** ../kame/freebsd4/sys/i386/conf/GENERIC.KAME	Wed Feb 19 11:15:58 2003
--- ./freebsd4/sys/i386/conf/GENERIC.KAME	Thu Feb 27 15:17:54 2003
***************
*** 314,323 ****
--- 314,324 ----
  #options 	ALTQ_JOBS	#joint buffer management and scheduling
  #options 	ALTQ_IPSEC	#check ipsec in IPv4
  #options 	ALTQ_CDNR	#diffserv traffic conditioner
  #options 	ALTQ_BLUE	#blue by wu-chang feng
  #options 	ALTQ_PRIQ	#priority queue
+ #options	ALTQ_PBS	#Partial Buffer Sharing
  #options 	ALTQ_NOPCC	#don't use processor cycle counter
  #options 	ALTQ_DEBUG	#for debugging
  # you might want to set kernel timer to 1kHz if you use CBQ,
  # especially with 100baseT
  #options 	HZ=1000
*** ../kame/freebsd4/usr.bin/altqstat/Makefile	Sat Oct 26 09:00:51 2002
--- ./freebsd4/usr.bin/altqstat/Makefile	Thu Feb 27 15:17:54 2003
***************
*** 1,9 ****
  PROG=	altqstat
  SRCS=	altqstat.c qdisc_blue.c qdisc_cbq.c qdisc_cdnr.c qdisc_conf.c \
  	qdisc_fifoq.c qdisc_hfsc.c qdisc_jobs.c qdisc_priq.c qdisc_red.c \
! 	qdisc_rio.c qdisc_wfq.c quip_client.c
  
  MAN1=	altqstat.1
  
  CFLAGS+=-DALTQ -DINET6 -Wall -I${.CURDIR}/../../kame/libaltq
  
--- 1,9 ----
  PROG=	altqstat
  SRCS=	altqstat.c qdisc_blue.c qdisc_cbq.c qdisc_cdnr.c qdisc_conf.c \
  	qdisc_fifoq.c qdisc_hfsc.c qdisc_jobs.c qdisc_priq.c qdisc_red.c \
! 	qdisc_rio.c qdisc_wfq.c quip_client.c qdisc_pbs.c
  
  MAN1=	altqstat.1
  
  CFLAGS+=-DALTQ -DINET6 -Wall -I${.CURDIR}/../../kame/libaltq
  
*** ../kame/kame/kame/altqstat/Makefile	Sat Oct 26 08:59:54 2002
--- ./kame/kame/altqstat/Makefile	Thu Feb 27 15:17:53 2003
***************
*** 3,13 ****
  SYS_DEFINES?=	-DINET6
  
  PROG=		altqstat
  OBJS= 		altqstat.o quip_client.o qdisc_conf.o \
  		qdisc_cbq.o qdisc_hfsc.o qdisc_cdnr.o \
! 		qdisc_wfq.o qdisc_fifoq.o \
  		qdisc_red.o qdisc_rio.o qdisc_blue.o qdisc_priq.o qdisc_jobs.o
  MAN1=		altqstat.1
  
  CFLAGS=		-g -Wall
  CFLAGS+=	-W -Wpointer-arith -Wcast-qual -Wmissing-prototypes -ansi
--- 3,13 ----
  SYS_DEFINES?=	-DINET6
  
  PROG=		altqstat
  OBJS= 		altqstat.o quip_client.o qdisc_conf.o \
  		qdisc_cbq.o qdisc_hfsc.o qdisc_cdnr.o \
! 		qdisc_wfq.o qdisc_fifoq.o qdisc_pbs.o\
  		qdisc_red.o qdisc_rio.o qdisc_blue.o qdisc_priq.o qdisc_jobs.o
  MAN1=		altqstat.1
  
  CFLAGS=		-g -Wall
  CFLAGS+=	-W -Wpointer-arith -Wcast-qual -Wmissing-prototypes -ansi
*** ../kame/kame/kame/altqstat/altqstat.h	Sat Oct 26 08:59:54 2002
--- ./kame/kame/altqstat/altqstat.h	Thu Feb 27 15:17:53 2003
***************
*** 48,57 ****
--- 48,58 ----
  stat_loop_t red_stat_loop;
  stat_loop_t rio_stat_loop;
  stat_loop_t blue_stat_loop;
  stat_loop_t priq_stat_loop;
  stat_loop_t jobs_stat_loop;
+ stat_loop_t pbs_stat_loop;
  
  struct redstats;
  
  void chandle2name(const char *, u_long, char *, size_t);
  stat_loop_t *qdisc2stat_loop(const char *);
*** ../kame/kame/kame/altqstat/qdisc_conf.c	Sat Oct 26 08:59:54 2002
--- ./kame/kame/altqstat/qdisc_conf.c	Thu Feb 27 15:17:53 2003
***************
*** 54,63 ****
--- 54,64 ----
  	{"red",		ALTQT_RED,	red_stat_loop},
  	{"rio",		ALTQT_RIO,	rio_stat_loop},
  	{"blue",	ALTQT_BLUE,	blue_stat_loop},
  	{"priq",	ALTQT_PRIQ,	priq_stat_loop},
  	{"jobs",	ALTQT_JOBS,	jobs_stat_loop},
+ 	{"pbs",		ALTQT_PBS,	pbs_stat_loop},
  	{NULL, 		0,		NULL}
  };
  
  stat_loop_t *
  qdisc2stat_loop(const char *qdisc_name)
*** ../kame/kame/kame/altqstat/qdisc_pbs.c	Thu Jan  1 01:00:00 1970
--- ./kame/kame/altqstat/qdisc_pbs.c	Thu Feb 27 15:17:53 2003
***************
*** 0 ****
--- 1,92 ----
+ /*	$KAME$	*/
+ /*
+  * Copyright (C) 1999-2000
+  *	Sony Computer Science Laboratories, Inc.  All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  *
+  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  */
+ 
+ #include <sys/param.h>
+ #include <sys/ioctl.h>
+ #include <sys/time.h>
+ #include <sys/socket.h>
+ #include <net/if.h>
+ #include <netinet/in.h>
+ #include <altq/altq.h>
+ #include <altq/altq_pbs.h>
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <string.h>
+ #include <signal.h>
+ #include <errno.h>
+ #include <err.h>
+ 
+ #include "altqstat.h"
+ 
+ void
+ pbs_stat_loop(int fd, const char *ifname, int count, int interval)
+ {
+ 	struct pbs_getstats get_stats;
+ 	struct timeval cur_time, last_time;
+ 	u_int64_t last_bytes;
+ 	double sec;
+ 	int cnt = count;
+ 	sigset_t		omask;
+ 
+ 	strlcpy(get_stats.iface.pbs_ifname, ifname,
+ 		sizeof(get_stats.iface.pbs_ifname));
+ 
+ 	gettimeofday(&last_time, NULL);
+ 	last_time.tv_sec -= interval;
+ 	last_bytes = 0;
+ 
+ 	while (count == 0 || cnt-- > 0) {
+ 	
+ 		if (ioctl(fd, PBS_GETSTATS, &get_stats) < 0)
+ 			err(1, "ioctl PBS_GETSTATS");
+ 
+ 		gettimeofday(&cur_time, NULL);
+ 		sec = calc_interval(&cur_time, &last_time);
+ 
+ 		printf(" len: %d\tlimit: %d\tweight: %d\tperiod: %u\n",
+ 		       get_stats.q_len, get_stats.q_limit, get_stats.q_weight, get_stats.period);
+ 		printf(" xmit: %llu pkts (%llu bytes)\tout_drop: %llu pkts (%llu bytes)  drop: %llu pkts (%llu bytes)\n",
+ 		       (ull)get_stats.xmit_cnt.packets,
+ 		       (ull)get_stats.xmit_cnt.bytes,
+ 		       (ull)get_stats.outdrop_cnt.packets,
+ 		       (ull)get_stats.outdrop_cnt.bytes,
+ 		       (ull)get_stats.drop_cnt.packets,
+ 		       (ull)get_stats.drop_cnt.bytes);
+ 		printf(" throughput: %sbps\n",
+ 		       rate2str(calc_rate(get_stats.xmit_cnt.bytes,
+ 					  last_bytes, sec)));
+ 		
+ 		last_bytes = get_stats.xmit_cnt.bytes;
+ 		last_time = cur_time;
+ 
+ 		/* wait for alarm signal */
+ 		if (sigprocmask(SIG_BLOCK, NULL, &omask) == 0)
+ 			sigsuspend(&omask);
+ 	}
+ }
*** ../kame/kame/kame/etc/MAKEDEV.altq	Fri Oct 25 08:01:37 2002
--- ./kame/kame/etc/MAKEDEV.altq	Thu Feb 27 15:17:53 2003
***************
*** 96,105 ****
--- 96,106 ----
  	sh MAKEDEV.altq hfsc
  	sh MAKEDEV.altq cdnr
  	sh MAKEDEV.altq blue
  	sh MAKEDEV.altq priq
  	sh MAKEDEV.altq jobs
+ 	sh MAKEDEV.altq pbs
  	;;
  
  altq)
  	rm -f ${devpath}/altq/altq
  	mknod ${devpath}/altq/altq c $altqchr 0
***************
*** 199,208 ****
--- 200,217 ----
  	rm -f ${devpath}/jobs
  	rm -f ${devpath}/altq/jobs
  	mknod ${devpath}/altq/jobs c $altqchr 12
  	chown root:wheel ${devpath}/altq/jobs
  	chmod 644 ${devpath}/altq/jobs
+ 	;;
+ 
+ pbs)
+ 	rm -f ${devpath}/pbs
+ 	rm -f ${devpath}/altq/pbs
+ 	mknod ${devpath}/altq/pbs c $altqchr 13
+ 	chown root:wheel ${devpath}/altq/pbs
+ 	chmod 644 ${devpath}/altq/pbs
  	;;
  
  *)
  	echo 'MAKEDEV.altq: no such device!'
  	;;
*** ../kame/kame/kame/libaltq/Makefile	Sat Oct 26 08:59:53 2002
--- ./kame/kame/libaltq/Makefile	Thu Feb 27 15:17:54 2003
***************
*** 5,15 ****
  LIB=	libaltq.a
  
  OBJS= 	qop.o parser.o quip_server.o qop_cdnr.o qop_errlist.o \
  	qop_conf.o qop_dummy.o qop_cbq.o qop_hfsc.o qop_priq.o \
  	qop_red.o qop_rio.o qop_blue.o qop_wfq.o qop_fifoq.o \
! 	qop_priq.o qop_jobs
  
  CFLAGS=		-g -Wall
  CFLAGS+=	-Wpointer-arith -Wcast-qual -Wmissing-prototypes -ansi
  DEFINES=	-DALTQ $(SYS_DEFINES)
  INCLUDES=	-I. $(SYS_INCLUDES)
--- 5,15 ----
  LIB=	libaltq.a
  
  OBJS= 	qop.o parser.o quip_server.o qop_cdnr.o qop_errlist.o \
  	qop_conf.o qop_dummy.o qop_cbq.o qop_hfsc.o qop_priq.o \
  	qop_red.o qop_rio.o qop_blue.o qop_wfq.o qop_fifoq.o \
! 	qop_priq.o qop_jobs qop_pbs.o
  
  CFLAGS=		-g -Wall
  CFLAGS+=	-Wpointer-arith -Wcast-qual -Wmissing-prototypes -ansi
  DEFINES=	-DALTQ $(SYS_DEFINES)
  INCLUDES=	-I. $(SYS_INCLUDES)
*** ../kame/kame/kame/libaltq/qop_conf.c	Sat Oct 26 08:59:53 2002
--- ./kame/kame/libaltq/qop_conf.c	Thu Feb 27 15:17:54 2003
***************
*** 50,59 ****
--- 50,60 ----
  extern interface_parser_t	fifoq_interface_parser;
  extern interface_parser_t	priq_interface_parser;
  extern class_parser_t		priq_class_parser;
  extern interface_parser_t	jobs_interface_parser;
  extern class_parser_t		jobs_class_parser;
+ extern interface_parser_t	pbs_interface_parser;
  
  struct qdisc_parser qdisc_parser[] = {
  	{"null",	null_interface_parser,	null_class_parser},
  	{"cbq",		cbq_interface_parser,	cbq_class_parser},
  	{"hfsc",	hfsc_interface_parser,	hfsc_class_parser},
***************
*** 62,69 ****
--- 63,71 ----
  	{"blue",	blue_interface_parser,	NULL},
  	{"wfq",		wfq_interface_parser,	NULL},
  	{"fifoq",	fifoq_interface_parser,	NULL},
  	{"priq",	priq_interface_parser,	priq_class_parser},
  	{"jobs",	jobs_interface_parser,	jobs_class_parser},
+ 	{"pbs",		pbs_interface_parser,	NULL},
  	{NULL, NULL, NULL}
  };
  
*** ../kame/kame/kame/libaltq/qop_pbs.c	Thu Jan  1 01:00:00 1970
--- ./kame/kame/libaltq/qop_pbs.c	Thu Feb 27 15:17:54 2003
***************
*** 0 ****
--- 1,256 ----
+ /*	$KAME$	*/
+ /*
+  * Copyright (C) 1999-2000
+  *	Sony Computer Science Laboratories, Inc.  All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  *
+  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  */
+ 
+ #include <sys/param.h>
+ #include <sys/socket.h>
+ #include <sys/sockio.h>
+ #include <sys/ioctl.h>
+ #include <sys/fcntl.h>
+ #include <net/if.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <stddef.h>
+ #include <string.h>
+ #include <ctype.h>
+ #include <errno.h>
+ #include <syslog.h>
+ #include <netdb.h>
+ 
+ #include <altq/altq.h>
+ #include <altq/altq_pbs.h>
+ #include "altq_qop.h"
+ #include "qop_pbs.h"
+ 
+ static int pbs_attach(struct ifinfo *);
+ static int pbs_detach(struct ifinfo *);
+ static int pbs_enable(struct ifinfo *);
+ static int pbs_disable(struct ifinfo *);
+ 
+ #define PBS_DEVICE	"/dev/altq/pbs"
+ 
+ static int pbs_fd = -1;
+ static int pbs_refcount = 0;
+ 
+ static struct qdisc_ops pbs_qdisc = {
+ 	ALTQT_PBS,
+ 	"pbs",
+ 	pbs_attach,
+ 	pbs_detach,
+ 	NULL,			/* clear */
+ 	pbs_enable,
+ 	pbs_disable,
+ 	NULL,			/* add class */
+ 	NULL,			/* modify class */
+ 	NULL,			/* delete class */
+ 	NULL,			/* add filter */
+ 	NULL			/* delete filter */
+ };
+ 
+ /*
+  * parser interface
+  */
+ #define EQUAL(s1, s2)	(strcmp((s1), (s2)) == 0)
+ 
+ int
+ pbs_interface_parser(const char *ifname, int argc, char **argv)
+ {
+ 	u_int  	bandwidth = 100000000;	/* 100Mbps */
+ 	u_int	tbrsize = 0;
+ 	int	qlimit = 50;
+ 	int	qweight = 25;
+ 
+ 	/*
+ 	 * process options
+ 	 */
+ 	while (argc > 0) {
+ 		if (EQUAL(*argv, "bandwidth")) {
+ 			argc--; argv++;
+ 			if (argc > 0)
+ 				bandwidth = atobps(*argv);
+ 		} else if (EQUAL(*argv, "tbrsize")) {
+ 			argc--; argv++;
+ 			if (argc > 0)
+ 				tbrsize = atobytes(*argv);
+ 		} else if (EQUAL(*argv, "qlimit")) {
+ 			argc--; argv++;
+ 			if (argc > 0)
+ 				qlimit = (int)strtol(*argv, NULL, 0);
+ 		} else if (EQUAL(*argv, "qweight")) {
+ 			argc--; argv++;
+ 			if (argc > 0)
+ 				qweight = (int)strtol(*argv, NULL, 0);
+ 		} else if (EQUAL(*argv, "pbs")) {
+ 			/* just skip */
+ 		} else {
+ 			LOG(LOG_ERR, 0, "Unknown keyword '%s'", *argv);
+ 			return (0);
+ 		}
+ 		argc--; argv++;
+ 	}
+ 
+ 	if (qcmd_tbr_register(ifname, bandwidth, tbrsize) != 0)
+ 		return (0);
+ 
+ 	if (qcmd_pbs_add_if(ifname, bandwidth, qlimit, qweight) != 0)
+ 		return (0);
+ 	return (1);
+ }
+ 
+ /*
+  * qcmd api
+  */
+ int
+ qcmd_pbs_add_if(const char *ifname, u_int bandwidth, int qlimit, int qweight)
+ {
+ 	int error;
+ 	
+ 	error = qop_pbs_add_if(NULL, ifname, bandwidth, qlimit, qweight);
+ 	if (error != 0)
+ 		LOG(LOG_ERR, errno, "%s: can't add pbs on interface '%s'",
+ 		    qoperror(error), ifname);
+ 	return (error);
+ }
+ 
+ /*
+  * qop api
+  */
+ int 
+ qop_pbs_add_if(struct ifinfo **rp, const char *ifname,
+ 		 u_int bandwidth, int qlimit, int qweight)
+ {
+ 	struct ifinfo *ifinfo = NULL;
+ 	struct pbs_ifinfo *pbs_ifinfo;
+ 	int error;
+ 
+ 	if ((pbs_ifinfo = calloc(1, sizeof(*pbs_ifinfo))) == NULL)
+ 		return (QOPERR_NOMEM);
+ 	pbs_ifinfo->qlimit   = qlimit;
+ 	pbs_ifinfo->qweight   = qweight;
+ 
+ 	error = qop_add_if(&ifinfo, ifname, bandwidth,
+ 			   &pbs_qdisc, pbs_ifinfo);
+ 	if (error != 0) {
+ 		free(pbs_ifinfo);
+ 		return (error);
+ 	}
+ 
+ 	if (rp != NULL)
+ 		*rp = ifinfo;
+ 	return (0);
+ }
+ 
+ /*
+  *  system call interfaces for qdisc_ops
+  */
+ static int
+ pbs_attach(struct ifinfo *ifinfo)
+ {
+ 	struct pbs_interface iface;
+ 	struct pbs_ifinfo *pbs_ifinfo;
+ 	struct pbs_conf conf;
+ 
+ 	if (pbs_fd < 0 &&
+ 	    (pbs_fd = open(PBS_DEVICE, O_RDWR)) < 0 &&
+ 	    (pbs_fd = open_module(PBS_DEVICE, O_RDWR)) < 0) {
+ 		LOG(LOG_ERR, errno, "PBS open");
+ 		return (QOPERR_SYSCALL);
+ 	}
+ 
+ 	pbs_refcount++;
+ 	memset(&iface, 0, sizeof(iface));
+ 	strncpy(iface.pbs_ifname, ifinfo->ifname, IFNAMSIZ);
+ 
+ 	if (ioctl(pbs_fd, PBS_IF_ATTACH, &iface) < 0)
+ 		return (QOPERR_SYSCALL);
+ 
+ 	pbs_ifinfo = (struct pbs_ifinfo *)ifinfo->private;
+ 
+ 	/* set partial size to limit */
+ 	if(pbs_ifinfo->qweight > pbs_ifinfo->qlimit) pbs_ifinfo->qweight = pbs_ifinfo->qlimit;
+ 
+ 	/* set pbs parameters */
+ 	if (pbs_ifinfo->qlimit > 0) {
+ 		memset(&conf, 0, sizeof(conf));
+ 		strncpy(conf.iface.pbs_ifname, ifinfo->ifname, IFNAMSIZ);
+ 		conf.pbs_limit = pbs_ifinfo->qlimit;
+ 		conf.pbs_weight = pbs_ifinfo->qweight;
+ 		if (ioctl(pbs_fd, PBS_CONFIG, &conf) < 0)
+ 			return (QOPERR_SYSCALL);
+ 	}
+ #if 1
+ 	LOG(LOG_INFO, 0, "pbs attached to %s", iface.pbs_ifname);
+ #endif
+ 	return (0);
+ }
+ 
+ static int
+ pbs_detach(struct ifinfo *ifinfo)
+ {
+ 	struct pbs_interface iface;
+ 	
+ 	memset(&iface, 0, sizeof(iface));
+ 	strncpy(iface.pbs_ifname, ifinfo->ifname, IFNAMSIZ);
+ 
+ 	if (ioctl(pbs_fd, PBS_IF_DETACH, &iface) < 0)
+ 		return (QOPERR_SYSCALL);
+ 
+ 	if (--pbs_refcount == 0) {
+ 		close(pbs_fd);
+ 		pbs_fd = -1;
+ 	}
+ 	return (0);
+ }
+ 
+ static int
+ pbs_enable(struct ifinfo *ifinfo)
+ {
+ 	struct pbs_interface iface;
+ 
+ 	memset(&iface, 0, sizeof(iface));
+ 	strncpy(iface.pbs_ifname, ifinfo->ifname, IFNAMSIZ);
+ 
+ 	if (ioctl(pbs_fd, PBS_ENABLE, &iface) < 0)
+ 		return (QOPERR_SYSCALL);
+ 	return (0);
+ }
+ 
+ static int
+ pbs_disable(struct ifinfo *ifinfo)
+ {
+ 	struct pbs_interface iface;
+ 
+ 	memset(&iface, 0, sizeof(iface));
+ 	strncpy(iface.pbs_ifname, ifinfo->ifname, IFNAMSIZ);
+ 
+ 	if (ioctl(pbs_fd, PBS_DISABLE, &iface) < 0)
+ 		return (QOPERR_SYSCALL);
+ 	return (0);
+ }
*** ../kame/kame/kame/libaltq/qop_pbs.h	Thu Jan  1 01:00:00 1970
--- ./kame/kame/libaltq/qop_pbs.h	Thu Feb 27 15:17:54 2003
***************
*** 0 ****
--- 1,39 ----
+ /*	$KAME$	*/
+ /*
+  * Copyright (C) 1999-2000
+  *	Sony Computer Science Laboratories, Inc.  All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  *
+  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  */
+ 
+ /*
+  * pbs private ifinfo structure
+  */
+ struct pbs_ifinfo {
+ 	int qlimit;		/* max queue length */
+ 	int qweight;		/* partial buffer length */
+ };
+ 
+ int pbs_interface_parser(const char *ifname, int argc, char **argv);
+ int qcmd_pbs_add_if(const char *ifname, u_int bandwidth, int qlimit, int qweight);
+ int qop_pbs_add_if(struct ifinfo **rp, const char *ifname, 
+ 		     u_int bandwidth, int qlimit, int qweight);
*** ../kame/kame/sys/altq/altq.h.orig	Tue Jul 22 15:58:21 2003
--- ./kame/sys/altq/altq.h	Tue Jul 22 16:07:42 2003
***************
*** 60,70 ****
  #define	ALTQT_HFSC		8	/* hfsc */
  #define	ALTQT_CDNR		9	/* traffic conditioner */
  #define	ALTQT_BLUE		10	/* blue */
  #define	ALTQT_PRIQ		11	/* priority queue */
  #define	ALTQT_JOBS		12	/* JoBS */
! #define	ALTQT_MAX		13	/* should be max discipline type + 1 */
  
  #ifdef ALTQ3_COMPAT
  struct	altqreq {
  	char	ifname[IFNAMSIZ];	/* if name, e.g. "en0" */
  	u_long	arg;			/* request-specific argument */
--- 60,71 ----
  #define	ALTQT_HFSC		8	/* hfsc */
  #define	ALTQT_CDNR		9	/* traffic conditioner */
  #define	ALTQT_BLUE		10	/* blue */
  #define	ALTQT_PRIQ		11	/* priority queue */
  #define	ALTQT_JOBS		12	/* JoBS */
! #define	ALTQT_PBS		13	/* PBS */
! #define	ALTQT_MAX		14	/* should be max discipline type + 1 */
  
  #ifdef ALTQ3_COMPAT
  struct	altqreq {
  	char	ifname[IFNAMSIZ];	/* if name, e.g. "en0" */
  	u_long	arg;			/* request-specific argument */
*** ../kame/kame/sys/altq/altq_conf.c	Sat Feb  8 19:24:16 2003
--- ./kame/sys/altq/altq_conf.c	Thu Feb 27 15:17:54 2003
***************
*** 87,96 ****
--- 87,99 ----
  altqdev_decl(priq);
  #endif
  #ifdef ALTQ_JOBS
  altqdev_decl(jobs);
  #endif
+ #ifdef ALTQ_PBS
+ altqdev_decl(pbs);
+ #endif
  
  /*
   * altq minor device (discipline) table
   */
  static struct altqsw altqsw[] = {				/* minor */
***************
*** 152,161 ****
--- 155,169 ----
  #endif
  #ifdef ALTQ_JOBS
  	{"jobs",jobsopen,	jobsclose,	jobsioctl},	/* 12 */
  #else
  	{"noq", noopen,		noclose,	noioctl},	/* 12 */
+ #endif
+ #ifdef ALTQ_PBS
+ 	{"pbs",pbsopen,	pbsclose,	pbsioctl},	/* 13 */
+ #else
+ 	{"noq", noopen,		noclose,	noioctl},	/* 13 */
  #endif
  };
  
  /*
   * altq major device support
*** ../kame/kame/sys/altq/altq_pbs.c	Thu Jan  1 01:00:00 1970
--- ./kame/sys/altq/altq_pbs.c	Thu Feb 27 15:17:54 2003
***************
*** 0 ****
--- 1,454 ----
+ /*	$KAME$	*/
+ 
+ /*
+  * Copyright (C) 1997-2002
+  *	Sony Computer Science Laboratories Inc.  All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  *
+  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  */
+ 
+ #if defined(__FreeBSD__) || defined(__NetBSD__)
+ #include "opt_altq.h"
+ #endif /* __FreeBSD__ || __NetBSD__ */
+ #ifdef ALTQ_PBS  /* pbs is enabled by ALTQ_PBS option in opt_altq.h */
+ 
+ /*
+  * Partial Buffer Sharing for altq
+  * Based on fifoq.
+  */
+ 
+ #include <sys/param.h>
+ #include <sys/malloc.h>
+ #include <sys/mbuf.h>
+ #include <sys/socket.h>
+ #include <sys/sockio.h>
+ #include <sys/systm.h>
+ #include <sys/proc.h>
+ #include <sys/errno.h>
+ #include <sys/kernel.h>
+ 
+ #include <net/if.h>
+ #include <net/if_types.h>
+ #include <netinet/in.h>
+ 
+ #include <altq/altq.h>
+ #include <altq/altq_conf.h>
+ #include <altq/altq_pbs.h>
+ 
+ #define	PBS_STATS	/* collect statistics */
+ 
+ /* pbs_list keeps all pbs_state_t's allocated. */
+ static pbs_state_t *pbs_list = NULL;
+ 
+ /* internal function prototypes */
+ static int		pbs_enqueue(struct ifaltq *, struct mbuf *,
+ 				      struct altq_pktattr *);
+ static struct mbuf 	*pbs_dequeue(struct ifaltq *, int);
+ static int 		pbs_detach(pbs_state_t *);
+ static int		pbs_request(struct ifaltq *, int, void *);
+ static void 		pbs_purge(pbs_state_t *);
+ 
+ /*
+  * pbs device interface
+  */
+ altqdev_decl(pbs);
+ 
+ int
+ pbsopen(dev, flag, fmt, p)
+ 	dev_t dev;
+ 	int flag, fmt;
+ #if (__FreeBSD_version > 500000)
+ 	struct thread *p;
+ #else
+ 	struct proc *p;
+ #endif
+ {
+ 	/* everything will be done when the queueing scheme is attached. */
+ 	return 0;
+ }
+ 
+ /*
+  * there are 2 ways to act on close.
+  *   detach-all-on-close:
+  *	use for the daemon style approach.  if the daemon dies, all the
+  *	resource will be released.
+  *   no-action-on-close:
+  *	use for the command style approach.  (e.g.  pbs on/off)
+  *
+  * note: close is called not on every close but when the last reference
+  *       is removed (only once with multiple simultaneous references.)
+  */
+ int
+ pbsclose(dev, flag, fmt, p)
+ 	dev_t dev;
+ 	int flag, fmt;
+ #if (__FreeBSD_version > 500000)
+ 	struct thread *p;
+ #else
+ 	struct proc *p;
+ #endif
+ {
+ 	pbs_state_t *q;
+ 	int err, error = 0;
+ 
+ 	while ((q = pbs_list) != NULL) {
+ 		/* destroy all */
+ 		err = pbs_detach(q);
+ 		if (err != 0 && error == 0)
+ 			error = err;
+ 	}
+ 
+ 	return error;
+ }
+ 
+ int
+ pbsioctl(dev, cmd, addr, flag, p)
+ 	dev_t dev;
+ 	ioctlcmd_t cmd;
+ 	caddr_t addr;
+ 	int flag;
+ #if (__FreeBSD_version > 500000)
+ 	struct thread *p;
+ #else
+ 	struct proc *p;
+ #endif
+ {
+ 	pbs_state_t *q;
+ 	struct pbs_interface *ifacep;
+ 	struct ifnet *ifp;
+ 	int	error = 0;
+ 
+ 	/* check super-user privilege */
+ 	switch (cmd) {
+ 	case PBS_GETSTATS:
+ 		break;
+ 	default:
+ #if (__FreeBSD_version > 400000)
+ 		if ((error = suser(p)) != 0)
+ 			return (error);
+ #else
+ 		if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
+ 			return (error);
+ #endif
+ 		break;
+ 	}
+ 
+ 	switch (cmd) {
+ 	case PBS_ENABLE:
+ 		ifacep = (struct pbs_interface *)addr;
+ 		if ((q = altq_lookup(ifacep->pbs_ifname, ALTQT_PBS))
+ 		    == NULL) {
+ 			error = EBADF;
+ 			break;
+ 		}
+ 		error = altq_enable(q->q_ifq);
+ 		break;
+ 
+ 	case PBS_DISABLE:
+ 		ifacep = (struct pbs_interface *)addr;
+ 		if ((q = altq_lookup(ifacep->pbs_ifname, ALTQT_PBS))
+ 		    == NULL) {
+ 			error = EBADF;
+ 			break;
+ 		}
+ 		error = altq_disable(q->q_ifq);
+ 		break;
+ 
+ 	case PBS_IF_ATTACH:
+ 		ifp = ifunit(((struct pbs_interface *)addr)->pbs_ifname);
+ 		if (ifp == NULL) {
+ 			error = ENXIO;
+ 			break;
+ 		}
+ 
+ 		/* allocate and initialize pbs_state_t */
+ 		MALLOC(q, pbs_state_t *, sizeof(pbs_state_t),
+ 		       M_DEVBUF, M_WAITOK);
+ 		if (q == NULL) {
+ 			error = ENOMEM;
+ 			break;
+ 		}
+ 		bzero(q, sizeof(pbs_state_t));
+ 
+ 		q->q_ifq = &ifp->if_snd;
+ 		q->q_head = q->q_tail = NULL;
+ 		q->q_len = 0;
+ 		q->q_limit = PBS_LIMIT;
+ 		q->q_weight = PBS_WEIGHT;
+ 
+ 		/*
+ 		 * set PBS to this ifnet structure.
+ 		 */
+ 		error = altq_attach(q->q_ifq, ALTQT_PBS, q,
+ 				    pbs_enqueue, pbs_dequeue, pbs_request,
+ 				    NULL, NULL);
+ 		if (error) {
+ 			FREE(q, M_DEVBUF);
+ 			break;
+ 		}
+ 
+ 		/* add this state to the pbs list */
+ 		q->q_next = pbs_list;
+ 		pbs_list = q;
+ 		break;
+ 
+ 	case PBS_IF_DETACH:
+ 		ifacep = (struct pbs_interface *)addr;
+ 		if ((q = altq_lookup(ifacep->pbs_ifname, ALTQT_PBS))
+ 		    == NULL) {
+ 			error = EBADF;
+ 			break;
+ 		}
+ 		error = pbs_detach(q);
+ 		break;
+ 
+ 	case PBS_GETSTATS:
+ 		do {
+ 			struct pbs_getstats *q_stats;
+ 
+ 			q_stats = (struct pbs_getstats *)addr;
+ 			if ((q = altq_lookup(q_stats->iface.pbs_ifname,
+ 					     ALTQT_PBS)) == NULL) {
+ 				error = EBADF;
+ 				break;
+ 			}
+ 
+ 			q_stats->q_len		= q->q_len;
+ 			q_stats->q_limit 	= q->q_limit;
+ 			q_stats->q_weight 		= q->q_weight;
+ 			q_stats->xmit_cnt	= q->q_stats.xmit_cnt;
+ 			q_stats->drop_cnt 	= q->q_stats.drop_cnt;
+ 			q_stats->outdrop_cnt 	= q->q_stats.outdrop_cnt;
+ 			q_stats->period   	= q->q_stats.period;
+ 		} while (/*CONSTCOND*/ 0);
+ 		break;
+ 
+ 	case PBS_CONFIG:
+ 		do {
+ 			struct pbs_conf *fc;
+ 			int limit;
+ 			int weight;
+ 
+ 			fc = (struct pbs_conf *)addr;
+ 			if ((q = altq_lookup(fc->iface.pbs_ifname,
+ 					     ALTQT_PBS)) == NULL) {
+ 				error = EBADF;
+ 				break;
+ 			}
+ 			limit = fc->pbs_limit;
+ 			weight = fc->pbs_weight;
+ 			if (limit < 0)
+ 				limit = 0;
+ 			if(weight > limit)
+ 				weight = limit;
+ 			q->q_limit = limit;
+ 			fc->pbs_limit = limit;
+ 			q->q_weight = weight;
+ 			fc->pbs_weight = weight;
+ 		} while (/*CONSTCOND*/ 0);
+ 		break;
+ 
+ 	default:
+ 		error = EINVAL;
+ 		break;
+ 	}
+ 	return error;
+ }
+ 
+ /*
+  * pbs support routines
+  */
+ 
+ /* enqueue routine:
+  *
+  *	returns: 0 when successfully queued.
+  *		 ENOBUFS when drop occurs.
+  */
+ static int
+ pbs_enqueue(ifq, m, pktattr)
+ 	struct ifaltq *ifq;
+ 	struct mbuf *m;
+ 	struct altq_pktattr *pktattr;
+ {
+ 	pbs_state_t *q = (pbs_state_t *)ifq->altq_disc;
+ 	int class = 0;
+ 	
+ 	if(q->q_len >= q->q_weight) {
+ 		if (q->q_len >= q->q_limit) {
+ #ifdef PBS_STATS
+ 			PKTCNTR_ADD(&q->q_stats.drop_cnt, m_pktlen(m));
+ #endif
+ 			m_freem(m);
+ 			return (ENOBUFS);
+ 		}
+ 		class = read_dsfield(m, pktattr);
+ 
+ 		if(class == 0x28) {
+ 			m->m_nextpkt = NULL;
+ 			if (q->q_tail == NULL)
+ 				q->q_head = m;
+ 			else
+ 				q->q_tail->m_nextpkt = m;
+ 			q->q_tail = m;
+ 			q->q_len++;
+ 			ifq->ifq_len++;
+ 			return 0;
+ 		} else {
+ #ifdef PBS_STATS
+ 			PKTCNTR_ADD(&q->q_stats.outdrop_cnt, m_pktlen(m));
+ #endif
+ 			m_freem(m);
+ 			return (ENOBUFS);
+ 		}
+ 	}
+ 
+ 	/* else enqueue the packet at the taile of the queue */
+ 	m->m_nextpkt = NULL;
+ 	if (q->q_tail == NULL)
+ 		q->q_head = m;
+ 	else
+ 		q->q_tail->m_nextpkt = m;
+ 	q->q_tail = m;
+ 	q->q_len++;
+ 	ifq->ifq_len++;
+ 
+ 	return 0;
+ }
+ 
+ /*
+  * dequeue routine:
+  *	must be called in splimp.
+  *
+  *	returns: mbuf dequeued.
+  *		 NULL when no packet is available in the queue.
+  */
+ /*
+  * ALTDQ_PEEK is provided for drivers which need to know the next packet
+  * to send in advance.
+  * when ALTDQ_PEEK is specified, the next packet to be dequeued is
+  * returned without dequeueing the packet.
+  * when ALTDQ_DEQUEUE is called *immediately after* an ALTDQ_PEEK
+  * operation, the same packet should be returned.
+  */
+ static struct mbuf *
+ pbs_dequeue(ifq, op)
+ 	struct ifaltq *ifq;
+ 	int op;
+ {
+ 	pbs_state_t *q = (pbs_state_t *)ifq->altq_disc;
+ 	struct mbuf *m = NULL;
+ 
+ 	if (op == ALTDQ_POLL)
+ 		return (q->q_head);
+ 
+ 	if ((m = q->q_head) == NULL)
+ 		return (NULL);
+ 
+ 	if ((q->q_head = m->m_nextpkt) == NULL)
+ 		q->q_tail = NULL;
+ 	m->m_nextpkt = NULL;
+ 	q->q_len--;
+ 	ifq->ifq_len--;
+ #ifdef PBS_STATS
+ 	PKTCNTR_ADD(&q->q_stats.xmit_cnt, m_pktlen(m));
+ 	if (q->q_len == 0)
+ 		q->q_stats.period++;
+ #endif
+ 	return (m);
+ }
+ 
+ static int
+ pbs_request(ifq, req, arg)
+ 	struct ifaltq *ifq;
+ 	int req;
+ 	void *arg;
+ {
+ 	pbs_state_t *q = (pbs_state_t *)ifq->altq_disc;
+ 
+ 	switch (req) {
+ 	case ALTRQ_PURGE:
+ 		pbs_purge(q);
+ 		break;
+ 	}
+ 	return (0);
+ }
+ 
+ 
+ static int pbs_detach(q)
+ 	pbs_state_t *q;
+ {
+ 	pbs_state_t *tmp;
+ 	int error = 0;
+ 
+ 	if (ALTQ_IS_ENABLED(q->q_ifq))
+ 		altq_disable(q->q_ifq);
+ 
+ 	pbs_purge(q);
+ 
+ 	if ((error = altq_detach(q->q_ifq)))
+ 		return (error);
+ 
+ 	if (pbs_list == q)
+ 		pbs_list = q->q_next;
+ 	else {
+ 		for (tmp = pbs_list; tmp != NULL; tmp = tmp->q_next)
+ 			if (tmp->q_next == q) {
+ 				tmp->q_next = q->q_next;
+ 				break;
+ 			}
+ 		if (tmp == NULL)
+ 			printf("pbs_detach: no state in pbs_list!\n");
+ 	}
+ 
+ 	FREE(q, M_DEVBUF);
+ 	return (error);
+ }
+ 
+ /*
+  * pbs_purge
+  * should be called in splimp or after disabling the pbs.
+  */
+ static void pbs_purge(q)
+ 	pbs_state_t *q;
+ {
+ 	struct mbuf *m;
+ 
+ 	while ((m = q->q_head) != NULL) {
+ 		q->q_head = m->m_nextpkt;
+ 		m_freem(m);
+ 	}
+ 	q->q_tail = NULL;
+ 	q->q_len = 0;
+ 	if (ALTQ_IS_ENABLED(q->q_ifq))
+ 		q->q_ifq->ifq_len = 0;
+ }
+ 
+ #ifdef KLD_MODULE
+ 
+ static struct altqsw pbs_sw =
+ 	{"pbs", pbsopen, pbsclose, pbsioctl};
+ 
+ ALTQ_MODULE(altq_pbs, ALTQT_PBS, &pbs_sw);
+ 
+ #endif /* KLD_MODULE */
+ 
+ #endif /* ALTQ_PBS */
*** ../kame/kame/sys/altq/altq_pbs.h	Thu Jan  1 01:00:00 1970
--- ./kame/sys/altq/altq_pbs.h	Thu Feb 27 15:17:54 2003
***************
*** 0 ****
--- 1,57 ----
+ #ifndef _ALTQ_ALTQ_PBS_H_
+ #define	_ALTQ_ALTQ_PBS_H_
+ 
+ typedef struct pbs_state {
+ 	struct pbs_state *q_next;	/* next pbs_state in the list */
+ 	struct ifaltq *q_ifq;		/* backpointer to ifaltq */
+ 
+ 	struct mbuf *q_head;		/* head of queue */
+ 	struct mbuf *q_tail;		/* tail of queue */
+ 	int	q_len;			/* queue length */
+ 	int	q_limit;		/* max queue length */
+ 	int	q_weight;		/* seuil a ne pas depasser pour packet IN */
+ 
+ 	/* statistics */
+ 	struct {
+ 		struct pktcntr	xmit_cnt;
+ 		struct pktcntr	drop_cnt;
+ 		struct pktcntr	outdrop_cnt;
+ 		u_int		period;
+ 	} q_stats;
+ } pbs_state_t;
+ 
+ struct pbs_interface {
+ 	char	pbs_ifname[IFNAMSIZ];
+ };
+ 
+ struct pbs_getstats {
+ 	struct pbs_interface iface;
+ 	int		q_len;
+ 	int		q_limit;
+ 	int		q_weight;
+ 	struct pktcntr	xmit_cnt;
+ 	struct pktcntr	outdrop_cnt;
+ 	struct pktcntr	drop_cnt;
+ 	u_int		period;
+ };
+ 
+ struct pbs_conf {
+ 	struct pbs_interface iface;
+ 	int pbs_limit;
+ 	int pbs_weight;
+ };
+ 
+ #define	PBS_LIMIT	50	/* default max queue lenght */
+ #define	PBS_WEIGHT	25	/* default buffer queue lenght */
+ 
+ /*
+  * IOCTLs for PBS
+  */
+ #define	PBS_IF_ATTACH		_IOW('Q', 1, struct pbs_interface)
+ #define	PBS_IF_DETACH		_IOW('Q', 2, struct pbs_interface)
+ #define	PBS_ENABLE		_IOW('Q', 3, struct pbs_interface)
+ #define	PBS_DISABLE		_IOW('Q', 4, struct pbs_interface)
+ #define	PBS_CONFIG		_IOWR('Q', 6, struct pbs_conf)
+ #define	PBS_GETSTATS		_IOWR('Q', 12, struct pbs_getstats)
+ 
+ #endif /* _ALTQ_ALTQ_PBS_H_ */

