Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/altq/libaltq Import the altq library.



details:   https://anonhg.NetBSD.org/src/rev/4bed169312cf
branches:  trunk
changeset: 500683:4bed169312cf
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Dec 16 17:38:07 2000 +0000

description:
Import the altq library.

diffstat:

 usr.sbin/altq/libaltq/Makefile       |    38 +
 usr.sbin/altq/libaltq/altq_qop.h     |   254 ++++++
 usr.sbin/altq/libaltq/if_nameindex.c |   130 +++
 usr.sbin/altq/libaltq/if_nameindex.h |    17 +
 usr.sbin/altq/libaltq/parser.c       |  1341 +++++++++++++++++++++++++++++++
 usr.sbin/altq/libaltq/qop.c          |  1437 ++++++++++++++++++++++++++++++++++
 usr.sbin/altq/libaltq/qop_blue.c     |   277 ++++++
 usr.sbin/altq/libaltq/qop_blue.h     |    44 +
 usr.sbin/altq/libaltq/qop_cbq.c      |  1081 +++++++++++++++++++++++++
 usr.sbin/altq/libaltq/qop_cbq.h      |   101 ++
 usr.sbin/altq/libaltq/qop_cdnr.c     |   932 ++++++++++++++++++++++
 usr.sbin/altq/libaltq/qop_cdnr.h     |   118 ++
 usr.sbin/altq/libaltq/qop_conf.c     |    66 +
 usr.sbin/altq/libaltq/qop_dummy.c    |   186 ++++
 usr.sbin/altq/libaltq/qop_errlist.c  |    48 +
 usr.sbin/altq/libaltq/qop_fifoq.c    |   245 +++++
 usr.sbin/altq/libaltq/qop_fifoq.h    |    38 +
 usr.sbin/altq/libaltq/qop_hfsc.c     |  1096 +++++++++++++++++++++++++
 usr.sbin/altq/libaltq/qop_hfsc.h     |    78 +
 usr.sbin/altq/libaltq/qop_priq.c     |   523 ++++++++++++
 usr.sbin/altq/libaltq/qop_priq.h     |    61 +
 usr.sbin/altq/libaltq/qop_red.c      |   307 +++++++
 usr.sbin/altq/libaltq/qop_red.h      |    47 +
 usr.sbin/altq/libaltq/qop_rio.c      |   351 ++++++++
 usr.sbin/altq/libaltq/qop_rio.h      |    47 +
 usr.sbin/altq/libaltq/qop_wfq.c      |   282 ++++++
 usr.sbin/altq/libaltq/qop_wfq.h      |    41 +
 usr.sbin/altq/libaltq/quip_server.c  |   482 +++++++++++
 usr.sbin/altq/libaltq/quip_server.h  |    36 +
 29 files changed, 9704 insertions(+), 0 deletions(-)

diffs (truncated from 9820 to 300 lines):

diff -r ddd313767e97 -r 4bed169312cf usr.sbin/altq/libaltq/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/altq/libaltq/Makefile    Sat Dec 16 17:38:07 2000 +0000
@@ -0,0 +1,38 @@
+PREFIX?=       /usr/local
+SYS_INCLUDES?= -I/usr/src/sys-altq
+
+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
+
+CFLAGS=                -g -Wall
+CFLAGS+=       -Wpointer-arith -Wcast-qual -Wmissing-prototypes -ansi
+DEFINES=       -DALTQ $(SYS_DEFINES)
+INCLUDES=      -I. $(SYS_INCLUDES)
+
+all: $(LIB)
+
+install: $(LIB)
+       $(INSTALL) $(COPY) -m 0444 $(LIB) $(PREFIX)/lib
+
+libaltq.a: libaltq.a($(OBJS))
+       rm -f $@
+       ar cq $@ `lorder $(OBJS) | tsort -q`
+       ranlib $@
+
+.c.o: 
+       $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -c $*.c
+
+clean:;                -rm -f $(LIB) *.a *.o core *.core *.bak ,* *~ "#"*
+
+
+
+
+
+
+
+
+
diff -r ddd313767e97 -r 4bed169312cf usr.sbin/altq/libaltq/altq_qop.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/altq/libaltq/altq_qop.h  Sat Dec 16 17:38:07 2000 +0000
@@ -0,0 +1,254 @@
+/*     $KAME: altq_qop.h,v 1.4 2000/10/18 09:15:18 kjc Exp $   */
+/*
+ * 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.
+ */
+#ifndef _ALTQ_QOP_H_
+#define _ALTQ_QOP_H_
+
+#include <sys/queue.h>
+#include <altq/altq.h>
+#include <altq/altq_red.h>
+
+struct ifinfo;
+struct classinfo;
+struct fltrinfo;
+
+/* queueing discipline specific command parsers */
+struct qdisc_parser {
+       char    *qname;
+       int     (*interface_parser)(const char *ifname, int argc, char **argv);
+       int     (*class_parser)(const char *ifname, const char *clname,
+                               const char *parent, int argc, char **argv);
+};
+
+/* queueing discipline specific operations */
+struct qdisc_ops {
+       int     qdisc_type;     /* discipline type (e.g., ALTQT_CBQ) */
+       char    *qname;         /* discipline name (e.g., cbq) */
+
+       /* interface operations */
+       int     (*attach)(struct ifinfo *);
+       int     (*detach)(struct ifinfo *);
+       int     (*clear)(struct ifinfo *);
+       int     (*enable)(struct ifinfo *);
+       int     (*disable)(struct ifinfo *);
+
+       /* class operations (optional) */
+       int     (*add_class)(struct classinfo *);
+       int     (*modify_class)(struct classinfo *, void *);
+       int     (*delete_class)(struct classinfo *);
+
+       /* filter operations (optional) */
+       int     (*add_filter)(struct fltrinfo *);
+       int     (*delete_filter)(struct fltrinfo *);
+};
+
+/*
+ * interface info
+ */
+struct ifinfo {
+       LIST_ENTRY(ifinfo)      next;           /* next entry on iflist */
+       char                    *ifname;        /* interface name */
+       u_int                   bandwidth;      /* bandwidth in bps */
+       u_int                   ifmtu;          /* mtu of the interface */
+       u_int                   ifindex;        /* interface index */
+       int                     enabled;        /* hfsc on/off state */
+       LIST_HEAD(, classinfo)  cllist;         /* class list */
+       LIST_HEAD(, fltrinfo)   fltr_rules;     /* filter rule list */
+
+       struct classinfo        *resv_class;    /* special class for rsvp */
+
+       /* discipline info */
+       struct qdisc_ops        *qdisc;         /* qdisc system interface */
+       void                    *private;       /* discipline specific data */
+       int     (*enable_hook)(struct ifinfo *);
+       int     (*delete_hook)(struct ifinfo *);
+};
+
+/*
+ * class info
+ */
+struct classinfo {
+       LIST_ENTRY(classinfo)   next;           /* next entry on cllist
+                                                  of ifinfo */
+       u_long                  handle;         /* class handle */
+       char                    *clname;        /* class name */
+       struct ifinfo           *ifinfo;        /* back pointer to ifinfo */
+       struct classinfo        *parent;        /* parent class */
+       struct classinfo        *sibling;       /* sibling class */
+       struct classinfo        *child;         /* child class */
+       LIST_HEAD(, fltrinfo)   fltrlist;       /* filters for this class */
+
+       void                    *private;       /* discipline specific data */
+       int     (*delete_hook)(struct classinfo *);
+};
+
+/*
+ * filter info
+ */
+struct fltrinfo {
+       LIST_ENTRY(fltrinfo)    next;           /* next entry on fltrlist
+                                                  of classinfo */
+       LIST_ENTRY(fltrinfo)    nextrule;       /* next entry on fltr_rules
+                                                  of ifinfo */
+       u_long                  handle;         /* filter handle */
+       char                    *flname;        /* filter name, if specified */
+       struct flow_filter      fltr;           /* filter value */
+       struct classinfo        *clinfo;        /* back pointer to classinfo */
+
+       /* for consistency check */
+       int                     line_no;        /* config file line number */
+       int                     dontwarn;       /* supress warning msg */
+};
+
+int DoCommand(char *infile, FILE *infp);
+
+int qcmd_enable(const char *ifname);
+int qcmd_disable(const char *ifname);
+int qcmd_delete_if(const char *ifname);
+int qcmd_clear_hierarchy(const char *ifname);
+int qcmd_enableall(void);
+int qcmd_disableall(void);
+int qcmd_config(void);
+int qcmd_init(void);
+int qcmd_clear(const char *ifname);
+int qcmd_destroyall(void);
+int qcmd_restart(void);
+int qcmd_delete_class(const char *ifname, const char *clname);
+int qcmd_add_filter(const char *ifname, const char *clname, const char *flname,
+                   const struct flow_filter *fltr);
+int qcmd_delete_filter(const char *ifname, const char *clname,
+                      const char *flname);
+int qcmd_tbr_register(const char *ifname, u_int rate, u_int size);
+int qop_enable(struct ifinfo *ifinfo);
+int qop_disable(struct ifinfo *ifinfo);
+int qop_delete_if(struct ifinfo *ifinfo);
+int qop_clear(struct ifinfo *ifinfo);
+
+int qop_add_if(struct ifinfo **rp, const char *ifname, u_int bandwidth,
+              struct qdisc_ops *qdisc_ops, void *if_private);
+int qop_delete_if(struct ifinfo *ifinfo);
+
+int qop_add_class(struct classinfo **rp, const char *clname,
+                 struct ifinfo *ifinfo, struct classinfo *parent,
+                 void *class_private);
+int qop_modify_class(struct classinfo *clinfo, void *arg);
+int qop_delete_class(struct classinfo *clinfo);
+
+int qop_add_filter(struct fltrinfo **rp,
+                  struct classinfo *clinfo,
+                  const char *flname,
+                  const struct flow_filter *fltr,
+                  struct fltrinfo **conflict);
+int qop_delete_filter(struct fltrinfo *fltr);
+
+int is_q_enabled(const char *ifname);
+struct ifinfo *ifname2ifinfo(const char *ifname);
+struct ifinfo *input_ifname2ifinfo(const char *ifname);
+struct classinfo *clname2clinfo(const struct ifinfo *ifinfo,
+                               const char *clname);
+struct classinfo * clhandle2clinfo(struct ifinfo *ifinfo, u_long handle);
+struct fltrinfo *flname2flinfo(const struct classinfo *clinfo,
+                              const char *flname);
+struct fltrinfo *flhandle2fltrinfo(struct ifinfo *ifinfo, u_long handle);
+void print_filter(const struct flow_filter *filt);
+const char *qoperror(int qoperrno);
+u_int get_ifindex(const char *ifname);
+struct classinfo *get_rootclass(struct ifinfo *ifinfo);
+struct classinfo *get_nextclass(struct classinfo *clinfo);
+u_long atobps(const char *s);
+u_long atobytes(const char *s);
+int qop_red_set_defaults(int th_min, int th_max, int inv_pmax);
+int qop_rio_set_defaults(struct redparams *params);
+int open_module(const char *devname, int flags);
+int client_input(FILE *fp);
+
+/* misc system errors */
+#define QOPERR_OK              0       /* no error */
+#define QOPERR_SYSCALL         1       /* syscall err; see errno */
+#define QOPERR_NOMEM           2       /* not enough memory */
+#define QOPERR_INVAL           3       /* invalid parameter */
+#define QOPERR_RANGE           4       /* out of range */
+#define QOPERR_BADIF           5       /* bad interface name */
+#define QOPERR_BADCLASS                6       /* bad class name */
+#define QOPERR_BADFILTER       7       /* bad filter name */
+
+/* class errors */
+#define QOPERR_CLASS           8       /* class failure */
+#define QOPERR_CLASS_INVAL     9       /* bad class value */
+#define QOPERR_CLASS_PERM      10      /* class operation not permitted */
+
+/* filter errors */
+#define QOPERR_FILTER          11      /* filter failure */
+#define QOPERR_FILTER_INVAL    12      /* bad filter value */
+#define QOPERR_FILTER_SHADOW   13      /* shadows an existing filter */
+
+/* addmission errors */
+#define QOPERR_ADMISSION       14      /* admission control failure */
+#define QOPERR_ADMISSION_NOBW  15      /* insufficient bandwidth */
+#define QOPERR_ADMISSION_DELAY 16      /* cannot meet delay bound req */
+#define QOPERR_ADMISSION_NOSVC 17      /* no service available */
+
+/* policy errors */
+#define QOPERR_POLICY          18      /* policy control failure */
+
+#define QOPERR_MAX             18
+
+extern int     filter_dontwarn;/* supress warning for the current filter */
+extern char    *altqconfigfile;        /* config file name */
+extern const char *qop_errlist[];      /* error string list */
+extern struct qdisc_ops nop_qdisc;
+extern char *cur_ifname(void);
+extern struct qdisc_parser qdisc_parser[];
+extern int     Debug_mode;
+
+#ifndef RSVPD
+/* rename LOG() to log_write() */
+#define LOG    log_write
+void log_write(int, int, const char *, ...);
+
+/* stuff defined in rsvp headers */
+#define IsDebug(type)  (l_debug >= LOG_DEBUG && (m_debug & (type)))
+#define DEBUG_ALTQ     0x40
+
+#define ntoh16(x)      ((u_int16_t)ntohs((u_int16_t)(x)))
+#define ntoh32(x)      ((u_int32_t)ntohl((u_int32_t)(x)))
+#define hton16(x)      ((u_int16_t)htons((u_int16_t)(x)))
+#define hton32(x)      ((u_int32_t)htonl((u_int32_t)(x)))
+
+extern int     if_num;         /* number of phyints */
+extern int     m_debug;        /* Debug output control bits */
+extern int     l_debug;        /* Logging severity level */
+extern int     line_no;        /* current line number in config file */
+extern int     daemonize;      /* log_write uses stderr if daemonize is 0 */
+
+#endif /* !RSVPD */
+
+#ifdef INET6
+/* a macro to handle v6 address in 32-bit fields */
+#define IN6ADDR32(a, i)        (*(u_int32_t *)(&(a)->s6_addr[(i)<<2]))
+#endif
+
+#endif /* _ALTQ_QOP_H_ */



Home | Main Index | Thread Index | Old Index