[bwm-tools-devel] COMMIT - r22 - trunk/bwmd
Brought to you by:
nkukard
From: SVN C. <sv...@li...> - 2005-01-03 13:40:03
|
Author: nkukard Date: 2005-01-03 15:39:48 +0200 (Mon, 03 Jan 2005) New Revision: 22 Added: trunk/bwmd/autoclass.c trunk/bwmd/flow.c trunk/bwmd/ipq.c trunk/bwmd/libipq.c Modified: trunk/bwmd/Makefile.am trunk/bwmd/Makefile.in Log: * Change 2/4: Depletion of lib Modified: trunk/bwmd/Makefile.am =================================================================== --- trunk/bwmd/Makefile.am 2005-01-03 13:39:32 UTC (rev 21) +++ trunk/bwmd/Makefile.am 2005-01-03 13:39:48 UTC (rev 22) @@ -28,7 +28,7 @@ LOG_DIR=/var/bwm_tools bin_PROGRAMS = bwmd -bwmd_SOURCES = report.c flowControl.c bwmd.c logging.c +bwmd_SOURCES = report.c flowControl.c logging.c ipq.c flow.c libipq.c autoclass.c bwmd.c bwmd_LDADD = $(top_builddir)/lib/libbwm.la bwmd_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(XML_CFLAGS) -DCONFIG_FILE=\"$(CONFIG_FILE)\" -DLOG_DIR=\"$(LOG_DIR)\" $(AM_CFLAGS) bwmd_LDFLAGS = $(GLIB_LIBS) $(XML_LIBS) Modified: trunk/bwmd/Makefile.in =================================================================== --- trunk/bwmd/Makefile.in 2005-01-03 13:39:32 UTC (rev 21) +++ trunk/bwmd/Makefile.in 2005-01-03 13:39:48 UTC (rev 22) @@ -70,7 +70,9 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_bwmd_OBJECTS = bwmd-report.$(OBJEXT) bwmd-flowControl.$(OBJEXT) \ - bwmd-bwmd.$(OBJEXT) bwmd-logging.$(OBJEXT) + bwmd-logging.$(OBJEXT) bwmd-ipq.$(OBJEXT) bwmd-flow.$(OBJEXT) \ + bwmd-libipq.$(OBJEXT) bwmd-autoclass.$(OBJEXT) \ + bwmd-bwmd.$(OBJEXT) bwmd_OBJECTS = $(am_bwmd_OBJECTS) bwmd_DEPENDENCIES = $(top_builddir)/lib/libbwm.la DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) @@ -200,7 +202,7 @@ CONFIG_DIR = /etc/bwm_tools CONFIG_FILE = $(CONFIG_DIR)/firewall.xml LOG_DIR = /var/bwm_tools -bwmd_SOURCES = report.c flowControl.c bwmd.c logging.c +bwmd_SOURCES = report.c flowControl.c logging.c ipq.c flow.c libipq.c autoclass.c bwmd.c bwmd_LDADD = $(top_builddir)/lib/libbwm.la bwmd_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(XML_CFLAGS) -DCONFIG_FILE=\"$(CONFIG_FILE)\" -DLOG_DIR=\"$(LOG_DIR)\" $(AM_CFLAGS) bwmd_LDFLAGS = $(GLIB_LIBS) $(XML_LIBS) @@ -275,8 +277,12 @@ distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bwmd-autoclass.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bwmd-bwmd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bwmd-flow.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bwmd-flowControl.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bwmd-ipq.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bwmd-libipq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bwmd-logging.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bwmd-report.Po@am__quote@ @@ -329,6 +335,76 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-flowControl.obj `if test -f 'flowControl.c'; then $(CYGPATH_W) 'flowControl.c'; else $(CYGPATH_W) '$(srcdir)/flowControl.c'; fi` +bwmd-logging.o: logging.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-logging.o -MD -MP -MF "$(DEPDIR)/bwmd-logging.Tpo" -c -o bwmd-logging.o `test -f 'logging.c' || echo '$(srcdir)/'`logging.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-logging.Tpo" "$(DEPDIR)/bwmd-logging.Po"; else rm -f "$(DEPDIR)/bwmd-logging.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='logging.c' object='bwmd-logging.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-logging.o `test -f 'logging.c' || echo '$(srcdir)/'`logging.c + +bwmd-logging.obj: logging.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-logging.obj -MD -MP -MF "$(DEPDIR)/bwmd-logging.Tpo" -c -o bwmd-logging.obj `if test -f 'logging.c'; then $(CYGPATH_W) 'logging.c'; else $(CYGPATH_W) '$(srcdir)/logging.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-logging.Tpo" "$(DEPDIR)/bwmd-logging.Po"; else rm -f "$(DEPDIR)/bwmd-logging.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='logging.c' object='bwmd-logging.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-logging.obj `if test -f 'logging.c'; then $(CYGPATH_W) 'logging.c'; else $(CYGPATH_W) '$(srcdir)/logging.c'; fi` + +bwmd-ipq.o: ipq.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-ipq.o -MD -MP -MF "$(DEPDIR)/bwmd-ipq.Tpo" -c -o bwmd-ipq.o `test -f 'ipq.c' || echo '$(srcdir)/'`ipq.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-ipq.Tpo" "$(DEPDIR)/bwmd-ipq.Po"; else rm -f "$(DEPDIR)/bwmd-ipq.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ipq.c' object='bwmd-ipq.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-ipq.o `test -f 'ipq.c' || echo '$(srcdir)/'`ipq.c + +bwmd-ipq.obj: ipq.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-ipq.obj -MD -MP -MF "$(DEPDIR)/bwmd-ipq.Tpo" -c -o bwmd-ipq.obj `if test -f 'ipq.c'; then $(CYGPATH_W) 'ipq.c'; else $(CYGPATH_W) '$(srcdir)/ipq.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-ipq.Tpo" "$(DEPDIR)/bwmd-ipq.Po"; else rm -f "$(DEPDIR)/bwmd-ipq.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ipq.c' object='bwmd-ipq.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-ipq.obj `if test -f 'ipq.c'; then $(CYGPATH_W) 'ipq.c'; else $(CYGPATH_W) '$(srcdir)/ipq.c'; fi` + +bwmd-flow.o: flow.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-flow.o -MD -MP -MF "$(DEPDIR)/bwmd-flow.Tpo" -c -o bwmd-flow.o `test -f 'flow.c' || echo '$(srcdir)/'`flow.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-flow.Tpo" "$(DEPDIR)/bwmd-flow.Po"; else rm -f "$(DEPDIR)/bwmd-flow.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='flow.c' object='bwmd-flow.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-flow.o `test -f 'flow.c' || echo '$(srcdir)/'`flow.c + +bwmd-flow.obj: flow.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-flow.obj -MD -MP -MF "$(DEPDIR)/bwmd-flow.Tpo" -c -o bwmd-flow.obj `if test -f 'flow.c'; then $(CYGPATH_W) 'flow.c'; else $(CYGPATH_W) '$(srcdir)/flow.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-flow.Tpo" "$(DEPDIR)/bwmd-flow.Po"; else rm -f "$(DEPDIR)/bwmd-flow.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='flow.c' object='bwmd-flow.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-flow.obj `if test -f 'flow.c'; then $(CYGPATH_W) 'flow.c'; else $(CYGPATH_W) '$(srcdir)/flow.c'; fi` + +bwmd-libipq.o: libipq.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-libipq.o -MD -MP -MF "$(DEPDIR)/bwmd-libipq.Tpo" -c -o bwmd-libipq.o `test -f 'libipq.c' || echo '$(srcdir)/'`libipq.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-libipq.Tpo" "$(DEPDIR)/bwmd-libipq.Po"; else rm -f "$(DEPDIR)/bwmd-libipq.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libipq.c' object='bwmd-libipq.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-libipq.o `test -f 'libipq.c' || echo '$(srcdir)/'`libipq.c + +bwmd-libipq.obj: libipq.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-libipq.obj -MD -MP -MF "$(DEPDIR)/bwmd-libipq.Tpo" -c -o bwmd-libipq.obj `if test -f 'libipq.c'; then $(CYGPATH_W) 'libipq.c'; else $(CYGPATH_W) '$(srcdir)/libipq.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-libipq.Tpo" "$(DEPDIR)/bwmd-libipq.Po"; else rm -f "$(DEPDIR)/bwmd-libipq.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libipq.c' object='bwmd-libipq.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-libipq.obj `if test -f 'libipq.c'; then $(CYGPATH_W) 'libipq.c'; else $(CYGPATH_W) '$(srcdir)/libipq.c'; fi` + +bwmd-autoclass.o: autoclass.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-autoclass.o -MD -MP -MF "$(DEPDIR)/bwmd-autoclass.Tpo" -c -o bwmd-autoclass.o `test -f 'autoclass.c' || echo '$(srcdir)/'`autoclass.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-autoclass.Tpo" "$(DEPDIR)/bwmd-autoclass.Po"; else rm -f "$(DEPDIR)/bwmd-autoclass.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='autoclass.c' object='bwmd-autoclass.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-autoclass.o `test -f 'autoclass.c' || echo '$(srcdir)/'`autoclass.c + +bwmd-autoclass.obj: autoclass.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-autoclass.obj -MD -MP -MF "$(DEPDIR)/bwmd-autoclass.Tpo" -c -o bwmd-autoclass.obj `if test -f 'autoclass.c'; then $(CYGPATH_W) 'autoclass.c'; else $(CYGPATH_W) '$(srcdir)/autoclass.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-autoclass.Tpo" "$(DEPDIR)/bwmd-autoclass.Po"; else rm -f "$(DEPDIR)/bwmd-autoclass.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='autoclass.c' object='bwmd-autoclass.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-autoclass.obj `if test -f 'autoclass.c'; then $(CYGPATH_W) 'autoclass.c'; else $(CYGPATH_W) '$(srcdir)/autoclass.c'; fi` + bwmd-bwmd.o: bwmd.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-bwmd.o -MD -MP -MF "$(DEPDIR)/bwmd-bwmd.Tpo" -c -o bwmd-bwmd.o `test -f 'bwmd.c' || echo '$(srcdir)/'`bwmd.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-bwmd.Tpo" "$(DEPDIR)/bwmd-bwmd.Po"; else rm -f "$(DEPDIR)/bwmd-bwmd.Tpo"; exit 1; fi @@ -343,20 +419,6 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-bwmd.obj `if test -f 'bwmd.c'; then $(CYGPATH_W) 'bwmd.c'; else $(CYGPATH_W) '$(srcdir)/bwmd.c'; fi` -bwmd-logging.o: logging.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-logging.o -MD -MP -MF "$(DEPDIR)/bwmd-logging.Tpo" -c -o bwmd-logging.o `test -f 'logging.c' || echo '$(srcdir)/'`logging.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-logging.Tpo" "$(DEPDIR)/bwmd-logging.Po"; else rm -f "$(DEPDIR)/bwmd-logging.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='logging.c' object='bwmd-logging.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-logging.o `test -f 'logging.c' || echo '$(srcdir)/'`logging.c - -bwmd-logging.obj: logging.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -MT bwmd-logging.obj -MD -MP -MF "$(DEPDIR)/bwmd-logging.Tpo" -c -o bwmd-logging.obj `if test -f 'logging.c'; then $(CYGPATH_W) 'logging.c'; else $(CYGPATH_W) '$(srcdir)/logging.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bwmd-logging.Tpo" "$(DEPDIR)/bwmd-logging.Po"; else rm -f "$(DEPDIR)/bwmd-logging.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='logging.c' object='bwmd-logging.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bwmd_CFLAGS) $(CFLAGS) -c -o bwmd-logging.obj `if test -f 'logging.c'; then $(CYGPATH_W) 'logging.c'; else $(CYGPATH_W) '$(srcdir)/logging.c'; fi` - mostlyclean-libtool: -rm -f *.lo Added: trunk/bwmd/autoclass.c =================================================================== --- trunk/bwmd/autoclass.c 2005-01-03 13:39:32 UTC (rev 21) +++ trunk/bwmd/autoclass.c 2005-01-03 13:39:48 UTC (rev 22) @@ -0,0 +1,107 @@ +/* + * autoclass.c - Automatic packet priority classification + * Copyright (C) 2003-2004, Linux Based Systems Design + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * 29/08/2003 - Nigel Kukard <nk...@lb...> + * * Initial design +*/ + +#include "autoclass.h" + + +// Band calculation functions, tcp +long int tcpPortToBand(long int bandNum, u_int16_t port) +{ + long int ret = bandNum; + + + // Decide band to pump packet into + switch (port) + { + // AUTH + case 113: + ret = 20; + break; + // SSH + case 22: + // TELNET + case 23: + ret = 25; + break; + // HTTP + case 80: + // PROXY? + case 8080: + case 3128: + case 3130: + // HTTPS + case 443: + ret = 65; + break; + // CVS + case 2401: + ret = 70; + break; + // POP3 + case 110: + // IMAP + case 143: + ret = 75; + break; + // FTP + case 20: + case 21: + ret = 80; + break; + }; + + return ret; +} + +// Band calculation functions, udp +long int udpPortToBand(long int bandNum, u_int16_t port) +{ + long int ret = bandNum; + + + // Decide band to pump packet into + switch (port) + { + // DNS + case 53: + ret = 10; + break; + // NTP + case 123: + ret = 15; + break; + // RADIUS + case 1645: + case 1646: + case 1812: + case 1813: + ret = 30; + break; + }; + + if (port >= 33434 && port <= 33465) + ret = 5; + + return ret; +} + Added: trunk/bwmd/flow.c =================================================================== --- trunk/bwmd/flow.c 2005-01-03 13:39:32 UTC (rev 21) +++ trunk/bwmd/flow.c 2005-01-03 13:39:48 UTC (rev 22) @@ -0,0 +1,521 @@ +/* + * flow.c - Flow handling for bwmd + * Copyright (C) 2003-2004, Linux Based Systems Design + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * 15/04/2003 - Nigel Kukard <nk...@lb...> + * * Initial design +*/ + + +#include <glib.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include "common.h" +#include "flow.h" +#include "ipq.h" + + + + + +// Function to update all our flow groups +void updateGroups(struct flow_t *flow, int pktCount, int pktSize, int pktDropped, int pktBursted) +{ + GList *groupItem = g_list_first(flow->groups); + + + // Loop while we have summin + while (groupItem) + { + struct group_t *tmpGroup = groupItem->data; + + + // Lock and load! + g_mutex_lock(tmpGroup->lock); + + // Do our stuff + if (pktCount == -1) + tmpGroup->running.pktCount = 0; + else + tmpGroup->running.pktCount += pktCount; + + if (pktSize == -1) + tmpGroup->running.pktSize = 0; + else + tmpGroup->running.pktSize += pktSize; + + if (pktDropped == -1) + tmpGroup->running.pktDropped = 0; + else + tmpGroup->running.pktDropped += pktDropped; + + if (pktBursted == -1) + tmpGroup->running.pktBursted = 0; + else + tmpGroup->running.pktBursted += pktBursted; + + g_mutex_unlock(tmpGroup->lock); + + // Next one plz + groupItem = g_list_next(groupItem); + } +} + + +// Get average stats len, make sure you lock the flow!!! +struct pktStat_t getFlowTotalStats(struct pktStat_t *pktStats, long int pktStatsLen) +{ + struct pktStat_t returnStats; + long int curStat = 0; + + + // Reset return values + returnStats.pktCount = 0; + returnStats.pktSize = 0; + returnStats.pktDropped = 0; + returnStats.pktBursted = 0; + // Gather stats + for (curStat = 0; curStat < pktStatsLen; curStat++) + { + returnStats.pktCount += pktStats[curStat].pktCount; + returnStats.pktSize += pktStats[curStat].pktSize; + returnStats.pktDropped += pktStats[curStat].pktDropped; + returnStats.pktBursted += pktStats[curStat].pktBursted; + } + + // And return + return returnStats; +} + + +/* Set current credit & burst credit */ +static inline void calculate_flow_credit(struct flow_t *flow, unsigned int pktSize) +{ + // Check if we limited by rate + if (flow->maxRate > 0) + { + struct timeval curTime; + + // Grab exact time now + gettimeofday(&curTime,NULL); + + // Calculate credit + if (curTime.tv_sec - flow->lastCreditCalc.tv_sec > 0) + { + flow->curCredit = pktSize; + // If we must keep track of burst credit, do the same + if (flow->burstRate > 0) + flow->curBurstCredit = pktSize; + gettimeofday(&flow->lastCreditCalc,NULL); + } + else + { + unsigned int accumCredit; + + + // Add up accumulated time + flow->accumMs = curTime.tv_usec - flow->lastCreditCalc.tv_usec; + // See if we have at lease 1 byte to add + if ((accumCredit = flow->accumMs * flow->usCredit) > 1) + { + // If so add it to max of maxRate + flow->curCredit += accumCredit; + + // Add on burst credit, if we can + if (flow->burstRate > 0) + flow->curBurstCredit += (flow->accumMs * flow->usBurstCredit); + + // Remove the number of microseconds we used + flow->accumMs -= (accumCredit / flow->usCredit); + + // If we exceeded our max's, bring them back down a bit + if (flow->curCredit > flow->maxRate) + { + flow->curCredit = flow->maxRate; + flow->accumMs = 0; + } + if (flow->curBurstCredit > flow->burstRate) + flow->curBurstCredit = flow->burstRate; + + // Set this as the last time we calculated credit + gettimeofday(&flow->lastCreditCalc,NULL); + } + } + } +} + + +// Check if we will exceed our credit +static inline int credit_will_exceed(struct flow_t *flow, unsigned int pktSize) +{ + // Without the typecasts we always get a result of 0 .... *shrug* + return (flow->maxRate > 0 && (long int) flow->curCredit - (long int) pktSize < 0); +} + + +// Check if we will exceed our credit +static inline int burst_credit_will_exceed(struct flow_t *flow, unsigned int pktSize) +{ + // If burstRate == 0, it means we can burst to infinity (limited by parent) + return (flow->burstRate != 0 && (long int) flow->curBurstCredit - (long int) pktSize < 0); +} + + + +// Function to process a flow queue, returns number of packets accepted +static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *pktQueue) +{ + int status; + GList *packets; + int exceeded = 0; + int i; + // Differences in queue when we done + int acceptLen = 0, queuedLen = 0; + int acceptSize = 0, queuedSize = 0; + + + // Lock, hijack packets, unlock + g_mutex_lock(pktQueue->lock); + packets = pktQueue->packets; + pktQueue->packets = NULL; + g_mutex_unlock(pktQueue->lock); + + // Check that we within our boundaries + while (!exceeded) + { + struct packet_t *packet; + GList *pktQueueItem; + int ok = 1; + struct flow_t *flow; + struct flow_t *childFlow = NULL; + + + // Get head of the queue + pktQueueItem = g_list_first(packets); + // Last item + if (!pktQueueItem) + break; + // We got summin + packet = pktQueueItem->data; + + + childFlow = flow = pktQueue->parentFlow; + // Loop to root + while (flow && ok) + { + int bursted = 0; + + + // Set new credits + calculate_flow_credit(flow,PKT_SIZE(packet)); + + // Check if we have exceeded stuff we shouldn't + if ((i = credit_will_exceed(flow,PKT_SIZE(packet)))) + { + + // If we can burst.... see if exceed anything + if (flow->burstRate != -1) + { + int i; + + /* Check if we will exceed our burst credit */ + if ((i = burst_credit_will_exceed(flow,PKT_SIZE(packet)))) + ok = 0; + else + // Guess we didn't, we bursted + bursted = 1; + } + else + ok = 0; + } + + // If we have a parent, if we do... do a few tests + if (ok && flow->parent) + { + // Check if we havn't exceeded our parent queues + if (will_exceed_flow_queue(flow->parent,PKT_SIZE(packet))) + ok = 0; + + /* + * if (....) - if we here because of bursting, check if we have a + * willing parent to burst to. + * 1. We cannot burst over our burst-threshold to the parent + * 2. We cannot burst to a parent who is bogged + */ + if (ok && bursted) + { + // Calculate parent credits + calculate_flow_credit(flow->parent,PKT_SIZE(packet)); + + // Check if we exceeded + if (credit_will_exceed(flow->parent,PKT_SIZE(packet)) && + burst_credit_will_exceed(flow->parent,PKT_SIZE(packet))) + ok = 0; + else + { + // Parent threshold stuff, if we havn't exceeded the threshold we can burst + // First check if we can use the parent_th against the burst rate + if (flow->parent->burstRate > 0) + { + if (flow->parent_th > 0 && flow->parent_th < (flow->parent->curThroughput / + (double) flow->parent->burstRate) * 100.0) + ok = 0; + } + // If not, against the maxRate + else if (flow->parent->maxRate > 0) + { + if (flow->parent_th > 0 && flow->parent_th < (flow->parent->curThroughput / + (double) flow->parent->maxRate) * 100.0) + ok = 0; + } + } + } + } + + // If packet is still ok to pass through, do our stuff + if (ok) + { + struct timeval curTime; + + + g_mutex_lock(flow->lock); + + flow->running.pktCount++; + flow->running.pktSize += PKT_SIZE(packet); + flow->curCredit -= PKT_SIZE(packet); + flow->curThroughput += PKT_SIZE(packet); + + // If we can burst ... + if (flow->burstRate > 0) + flow->curBurstCredit -= PKT_SIZE(packet); + + // We bursted + if (bursted) + flow->running.pktBursted++; + + // Grab exact time now + gettimeofday(&curTime,NULL); + + // Add up accumulated time + if (curTime.tv_sec - flow->lastThroughputUpdate.tv_sec > 0) + flow->curThroughputAge += (curTime.tv_sec - flow->lastThroughputUpdate.tv_sec) * 1000000; + else + flow->curThroughputAge += curTime.tv_usec - flow->lastThroughputUpdate.tv_usec; + + // 2 seconds + if (flow->curThroughputAge >= 2000000) + { + flow->curThroughputAge -= 2000000; + flow->curThroughput = flow->curThroughputAge / 1000000.0 * flow->curThroughput; + } + + // Set this as the last time we updated our throughput + gettimeofday(&flow->lastThroughputUpdate,NULL); + + + g_mutex_unlock(flow->lock); + + // Time to update our groups + updateGroups(flow,1,PKT_SIZE(packet),0,0); + + // This flow is inbetween, we accepting traffic through, counters must be updated below + childFlow = flow; + flow = flow->parent; + } + } + + + // Can we accept the packet + if (ok) + { + // Re-inject packet for processing, check if it was ok... + g_mutex_lock(runnerData->IPQLock); + status = ipq_set_verdict(runnerData->IPQHandle, PKT_ID(packet), NF_ACCEPT, 0, NULL); + g_mutex_unlock(runnerData->IPQLock); + if (status < 0) + { + // FIXME - send error to log + fprintf(stderr,"Failed to ACCEPT packet\n"); + break; + } + + // Add to our flow counters, remove from queue and free + acceptSize += PKT_SIZE(packet); + acceptLen++; + packets = g_list_remove(packets,packet); + // Save the size + i = PKT_SIZE(packet); + // "Free" the packet + g_mutex_lock(runnerData->pmem.lock); + runnerData->pmem.freeList = g_list_append(runnerData->pmem.freeList,packet); + g_mutex_unlock(runnerData->pmem.lock); + } + else + { + // We got no where + if (flow == childFlow) + exceeded = 1; + else + { + struct pktQueue_t *nextPktQueue = flow->pktQueues[pktQueue->prio]; + + + // We can do this before locking + queuedLen++; + queuedSize += PKT_SIZE(packet); + packets = g_list_remove(packets,packet); + + // Lock everything + g_mutex_lock(nextPktQueue->lock); + g_mutex_lock(flow->lock); + // Add packet to parent queue & remove from child + nextPktQueue->packets = g_list_append(nextPktQueue->packets,packet); + // Update next queue stats + nextPktQueue->curLen++; + nextPktQueue->curSize += PKT_SIZE(packet); + // Update next flow stats + flow->curQueueLen++; + flow->curQueueSize += PKT_SIZE(packet); + // Finally unlock + g_mutex_unlock(flow->lock); + g_mutex_unlock(nextPktQueue->lock); + + // Signal that we just added to the queue + g_mutex_lock(runnerData->bandSignalLock); + // Check if we havn't already gotten the queue listed + // FIXME: check if we can't just add, high flow queue + if (!g_list_find(runnerData->queueChangeList[nextPktQueue->prio],nextPktQueue)) + runnerData->queueChangeList[nextPktQueue->prio] = + g_list_append(runnerData->queueChangeList[nextPktQueue->prio],nextPktQueue); + g_cond_signal(runnerData->bandSignalCond); + g_mutex_unlock(runnerData->bandSignalLock); + } + + } + } + + // Lock our data and change it, insert left over packets aswell + g_mutex_lock(P_FLOW(pktQueue,lock)); + P_FLOW(pktQueue,curQueueLen) -= (acceptLen + queuedLen); + P_FLOW(pktQueue,curQueueSize) -= (acceptSize + queuedSize); + g_mutex_unlock(P_FLOW(pktQueue,lock)); + + // Update queue aswell + g_mutex_lock(pktQueue->lock); + if (packets) + { + pktQueue->packets = g_list_concat(packets,pktQueue->packets); + // Signal that we just added to the queue + g_mutex_lock(runnerData->bandSignalLock); + // Check if we havn't already gotten the queue listed + // FIXME: check if we can't just add, high flow queue + if (!g_list_find(runnerData->queueChangeList[pktQueue->prio],pktQueue)) + runnerData->queueChangeList[pktQueue->prio] = g_list_append(runnerData->queueChangeList[pktQueue->prio],pktQueue); + g_cond_signal(runnerData->bandSignalCond); + g_mutex_unlock(runnerData->bandSignalLock); + } + pktQueue->curLen -= (acceptLen + queuedLen); + pktQueue->curSize -= (acceptSize + queuedLen); + + g_mutex_unlock(pktQueue->lock); + + return(acceptLen); +} + + + +// Main IPQ->QUEUE thread +void *flowRunner(void *data) +{ + struct runnerData_t *runnerData = (struct runnerData_t*) data; + GList *queueChangeList[NUM_PRIO_BANDS]; + int i, pktsProcessed = 0; + GTimeVal mytime; + + + // Our processing function + void processQueue(void *data, void *user_data) + { + struct pktQueue_t *pktQueue = (struct pktQueue_t*) data; + struct runnerData_t *aRunnerData = (struct runnerData_t*) user_data; + + + // Check if we found a flow with a queue + pktsProcessed += processPktQueue(aRunnerData,pktQueue); + } + + + // Allocate queue change list + for (i = 0; i < NUM_PRIO_BANDS; i++) + queueChangeList[i] = NULL; + + + if (!runnerData->daemon) + printf("Flow runner started...\n"); + + // Loop when we get a signal + while (1) + { + g_mutex_lock(runnerData->bandSignalLock); + + // If the queue has changed proceed + if (runnerData->queueChanged == 0) + { + g_get_current_time(&mytime); + g_time_val_add(&mytime,10000); + g_cond_timed_wait(runnerData->bandSignalCond,runnerData->bandSignalLock,&mytime); + } + + + // Hijack the queue change list items + for (i = 0; i < NUM_PRIO_BANDS; i++) + { + // Copy list item over + queueChangeList[i] = runnerData->queueChangeList[i]; + // Zero runner data if it is non-NULL + if (runnerData->queueChangeList[i]) + { + runnerData->queueChangeList[i] = NULL; + } + else + queueChangeList[i] = NULL; + } + + runnerData->queueChanged = 0; + + g_mutex_unlock(runnerData->bandSignalLock); + + + // Process all list + for (i = 0; i < NUM_PRIO_BANDS; i++) + { + // Process list if it is non-NULL + if (queueChangeList[i]) + { + g_list_foreach(queueChangeList[i],processQueue,runnerData); + g_list_free(queueChangeList[i]); + } + } + } + + return(NULL); +} + + Added: trunk/bwmd/ipq.c =================================================================== --- trunk/bwmd/ipq.c 2005-01-03 13:39:32 UTC (rev 21) +++ trunk/bwmd/ipq.c 2005-01-03 13:39:48 UTC (rev 22) @@ -0,0 +1,374 @@ +/* + * ipq.c - IPQ handling for bwmd + * Copyright (C) 2003-2004, Linux Based Systems Design + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * 15/04/2003 - Nigel Kukard <nk...@lb...> + * * Initial design +*/ + + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "autoclass.h" +#include "flow.h" +#include "ipq.h" +#include "libipq.h" + + + +// Destroy the ipq handle +static void destroyIPQHandle(struct ipq_handle *h) +{ + ipq_perror("passer"); + ipq_destroy_handle(h); +} + + +// Return the ipq handle +static struct ipq_handle *getIPQHandle() +{ + struct ipq_handle* h; + int result; + + // Create our ipq socket + h = ipq_create_handle(0, PF_INET, 1048576); + if (!h) + { + fprintf(stderr,"Failed to create IPQ handle\n"); + destroyIPQHandle(h); + return NULL; + } + + // Set mode... + result = ipq_set_mode(h, IPQ_COPY_PACKET, IPQ_BUFSIZE); + if (result < 0) + { + fprintf(stderr,"Failed to set IPQ mode\n"); + destroyIPQHandle(h); + return NULL; + } + + return(h); +} + + +// Close the ipq handle +static void closeIPQHandle(struct ipq_handle *h) +{ + ipq_destroy_handle(h); +} + + +// Check if we will exceed our queue +static inline int will_exceed_pkt_queue(struct pktQueue_t *pktQueue, unsigned int pktSize) +{ + return ((pktQueue->curLen >= pktQueue->maxLen && pktQueue->maxLen != 0) || + (pktQueue->curSize + pktSize >= pktQueue->maxSize && pktQueue->maxSize != 0)); +} + + +// Queue a packet +static int queuePacket(struct runnerData_t *runnerData, long int nfmark, struct packet_t *packet) +{ + struct pktQueue_t *foundQueue = NULL; + struct flow_t *foundFlow = NULL; + int status; + int result; + int drop = 0; + + + // Our find functions + void findQueue(void *data, void *user_data) + { + struct pktQueue_t *pktQueue = (struct pktQueue_t*) data; + + + if (foundQueue) return; + + // Check if we found it + if (pktQueue->nfmark == nfmark) + foundQueue = pktQueue; + } + + void findFlow(void *data, void *user_data) + { + struct flow_t *flow = (struct flow_t*) data; + + + if (foundFlow) return; + + // Check if we found it + if (flow->nfmark == nfmark) + foundFlow = flow; + } + + + // Loop to see what we find... we have to have queues if we going to loop with them + if (runnerData->pktQueues) + g_list_foreach(runnerData->pktQueues,findQueue,NULL); + // Now check if we found a flow?? + if (!foundQueue) + g_list_foreach(runnerData->flows,findFlow,NULL); + + // Check if we have something + if (!foundQueue && !foundFlow) + { + fprintf(stderr,"Queue or flow not found in processFlow() for %li\n", nfmark); + return(-1); + } + + // Now lets see if we don't have a queue... this means AUTO! + if (!foundQueue) + { + struct ip_packet_t *ip_packet = (struct ip_packet_t *) packet->payload->payload; + long int bandNum = -1; + +/* + fprintf(stderr,"auto packet queue -> protocol = %i, src = %i.%i.%i.%i, dest = %i.%i.%i.%i, tos = 0x%x\n", ip_packet->protocol, + ip_packet->u_saddr.addr.a, ip_packet->u_saddr.addr.b, ip_packet->u_saddr.addr.c, ip_packet->u_saddr.addr.d, + ip_packet->u_daddr.addr.a, ip_packet->u_daddr.addr.b, ip_packet->u_daddr.addr.c, ip_packet->u_daddr.addr.d, + IPTOS_PREC(ip_packet->tos)); +*/ + // Process a TCP packet + if (ip_packet->protocol == IPPROTO_TCP) + { + struct tcphdr *tcph = (struct tcphdr *) (packet->payload->payload + (ip_packet->ihl * 4)); +/* + fprintf(stderr," tcp -> sport = %i, dport = %i, prec = 0x%x\n", ntohs(tcph->source), + ntohs(tcph->dest), IPTOS_PREC(ip_packet->tos)); +*/ + bandNum = tcpPortToBand(bandNum,ntohs(tcph->dest)); + if (bandNum == -1) + bandNum = tcpPortToBand(bandNum,ntohs(tcph->source)); + + } + + // Process a ICMP packet + if (ip_packet->protocol == IPPROTO_ICMP) + { +/* + struct icmphdr *icmph = (struct icmphdr *) (packet->payload->payload + (ip_packet->ihl * 4)); + + fprintf(stderr,"something: icmp = %i, type = %i\n", icmph->code, icmph->type); +*/ + bandNum = 5; + } + + // Process a UDP packet + if (ip_packet->protocol == IPPROTO_UDP) + { + struct udphdr *udph = (struct udphdr *) (packet->payload->payload + (ip_packet->ihl * 4)); +/* + fprintf(stderr," udp -> sport = %i, dport = %i\n", ntohs(udph->source), + ntohs(udph->dest)); +*/ + bandNum = udpPortToBand(bandNum,ntohs(udph->dest)); + if (bandNum == -1) + bandNum = udpPortToBand(bandNum,ntohs(udph->source)); + } + + // If we didn't get anything set band number to 50, 50/50 + if (bandNum == -1) + bandNum = 50; + + foundQueue = foundFlow->pktQueues[bandNum]; + } + + + // Lock flow before we fuck with it + g_mutex_lock(foundQueue->lock); + g_mutex_lock(P_FLOW(foundQueue,lock)); + + // Check first of all if we fucked over our one of our queue limits + if (will_exceed_pkt_queue(foundQueue,PKT_SIZE(packet)) || + will_exceed_flow_queue(foundQueue->parentFlow,PKT_SIZE(packet))) + drop = 1; + + +#if 0 + // Check second of all if we fucked our min threshold over + else if (TH_EXCEEDED(foundQueue,min_th)) + { + int j = 1 + (int) (10.0 * rand() / (RAND_MAX + 1.0)); + + if (TH_EXCEEDED(foundQueue,max_th)) + { + if (j > 5) + drop = 1; + } + else + { + if (j < 3) + drop = 1; + } + } +#endif + + // Check if we must pass the packet + if (!drop) + { + // Lock, queue... adjust stats + foundQueue->packets = g_list_append(foundQueue->packets,packet); + foundQueue->curSize += PKT_SIZE(packet); + P_FLOW(foundQueue,curQueueSize) += PKT_SIZE(packet); + foundQueue->curLen++; + P_FLOW(foundQueue,curQueueLen)++; + result = 1; // Packet queued + } + else + { + // Tell kernel to drop packet + g_mutex_lock(runnerData->IPQLock); + status = ipq_set_verdict(runnerData->IPQHandle, PKT_ID(packet), NF_DROP, 0, NULL); + g_mutex_unlock(runnerData->IPQLock); + if (status < 0) + { + fprintf(stderr,"Failed to DROP packet\n"); + result = -1; + } + else + { + g_mutex_lock(P_FLOW(foundQueue,counterLock)); + P_FLOW(foundQueue,running).pktDropped++; + g_mutex_unlock(P_FLOW(foundQueue,counterLock)); + result = 2; // Packet dropped + } + // Conserve memory + g_mutex_lock(runnerData->pmem.lock); + runnerData->pmem.freeList = g_list_append(runnerData->pmem.freeList,packet); + g_mutex_unlock(runnerData->pmem.lock); + } + + // Unlock flow + g_mutex_unlock(P_FLOW(foundQueue,lock)); + g_mutex_unlock(foundQueue->lock); + + // If we have queued, signal a runner + if (result == 1) + { + // Signal that we just added to the queue + g_mutex_lock(runnerData->bandSignalLock); + // Check if we havn't already gotten the queue listed + // FIXME: check if we can't just add, high flow queue + if (!g_list_find(runnerData->queueChangeList[foundQueue->prio],foundQueue)) + runnerData->queueChangeList[foundQueue->prio] = g_list_append(runnerData->queueChangeList[foundQueue->prio],foundQueue); + runnerData->queueChanged = 1; // This basically signals immediate attention by the flow runner + g_cond_signal(runnerData->bandSignalCond); + g_mutex_unlock(runnerData->bandSignalLock); + } + + return(result); +} + + +// Main IPQ->QUEUE thread +void *IPQRunner(void *data) +{ + unsigned char buf[IPQ_BUFSIZE]; + int status; + struct runnerData_t *runnerData = (struct runnerData_t*) data; + ipq_packet_msg_t *m; + struct packet_t *packet; + unsigned int pkt_len = 0; + GList *listItem; + + + if (!runnerData->daemon) + printf("IPQ runner started...\n"); + + // Get IPQ handle + runnerData->IPQHandle = getIPQHandle(); + if (!runnerData->IPQHandle) + { + fprintf(stderr,"Failed to get IPQ handle\n"); + return(NULL); + } + + // And loop + while (1) + { + // Only loop when we have a packet + status = ipq_read(runnerData->IPQHandle, buf, IPQ_BUFSIZE, 0); + + // Loop if timeout + if (status == 0) + continue; + + // Fail if error + if (status < 0) + { + fprintf(stderr,"Failed to get packet from IPQ: %s\n",ipq_errstr()); + // Lock, we dead... accept it! + destroyIPQHandle(runnerData->IPQHandle); + return(NULL); + } + + // We must have a packet... check + switch (ipq_message_type(buf)) + { + case NLMSG_ERROR: + fprintf(stderr, "Received error message: IPQ = %s, SYSTEM = %s\n",ipq_errstr(),strerror(errno)); + break; + + case IPQM_PACKET: + + // Get packet details... + g_mutex_lock(runnerData->IPQLock); + m = ipq_get_packet(buf); + g_mutex_unlock(runnerData->IPQLock); + pkt_len = sizeof(ipq_packet_msg_t) + m->data_len; + + // Get a packet or alloc it + g_mutex_lock(runnerData->pmem.lock); + listItem = g_list_first(runnerData->pmem.freeList); + if (listItem == NULL) + { + + packet = (struct packet_t*) malloc(sizeof(struct packet_t)); + packet->payload = (ipq_packet_msg_t*) malloc(IPQ_BUFSIZE); + } + else + { + packet = listItem->data; + runnerData->pmem.freeList = g_list_remove(runnerData->pmem.freeList,packet); + } + g_mutex_unlock(runnerData->pmem.lock); + + // Copy packet + memcpy(packet->payload,m,pkt_len); + + // Queue the packet... + status = queuePacket(runnerData,packet->payload->mark,packet); + if (status < 0) + fprintf(stderr,"Failed to queue packet\n"); + + break; + + default: + fprintf(stderr, "Unknown message type!\n"); + break; + } + } + + closeIPQHandle(runnerData->IPQHandle); + + printf("Exiting IPQ runner thread\n"); +} + + Added: trunk/bwmd/libipq.c =================================================================== --- trunk/bwmd/libipq.c 2005-01-03 13:39:32 UTC (rev 21) +++ trunk/bwmd/libipq.c 2005-01-03 13:39:48 UTC (rev 22) @@ -0,0 +1,385 @@ +/* + * libipq.c + * + * IPQ userspace library. + * + * Please note that this library is still developmental, and there may + * be some API changes. + * + * Author: James Morris <jm...@in...> + * + * 07-11-2001 Modified by Fernando Anton to add support for IPv6. + * 21-04-2003 Modified by Nigel Kukard adjusted a few things. + * + * Copyright (c) 2000-2001 Netfilter Core Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <sys/time.h> +#include <sys/types.h> + +#include "libipq.h" + +/**************************************************************************** + * + * Private interface + * + ****************************************************************************/ + +enum { + IPQ_ERR_NONE = 0, + IPQ_ERR_IMPL, + IPQ_ERR_HANDLE, + IPQ_ERR_SOCKET, + IPQ_ERR_BIND, + IPQ_ERR_BUFFER, + IPQ_ERR_RECV, + IPQ_ERR_NLEOF, + IPQ_ERR_ADDRLEN, + IPQ_ERR_STRUNC, + IPQ_ERR_RTRUNC, + IPQ_ERR_NLRECV, + IPQ_ERR_SEND, + IPQ_ERR_SUPP, + IPQ_ERR_RECVBUF, + IPQ_ERR_TIMEOUT, + IPQ_ERR_PROTOCOL, + IPQ_ERR_SETSOCKET +}; +#define IPQ_MAXERR IPQ_ERR_PROTOCOL + +struct ipq_errmap_t { + int errcode; + char *message; +} ipq_errmap[] = { + { IPQ_ERR_NONE, "Unknown error" }, + { IPQ_ERR_IMPL, "Implementation error" }, + { IPQ_ERR_HANDLE, "Unable to create netlink handle" }, + { IPQ_ERR_SOCKET, "Unable to create netlink socket" }, + { IPQ_ERR_BIND, "Unable to bind netlink socket" }, + { IPQ_ERR_BUFFER, "Unable to allocate buffer" }, + { IPQ_ERR_RECV, "Failed to receive netlink message" }, + { IPQ_ERR_NLEOF, "Received EOF on netlink socket" }, + { IPQ_ERR_ADDRLEN, "Invalid peer address length" }, + { IPQ_ERR_STRUNC, "Sent message truncated" }, + { IPQ_ERR_RTRUNC, "Received message truncated" }, + { IPQ_ERR_NLRECV, "Received error from netlink" }, + { IPQ_ERR_SEND, "Failed to send netlink message" }, + { IPQ_ERR_SUPP, "Operation not supported" }, + { IPQ_ERR_RECVBUF, "Receive buffer size invalid" }, + { IPQ_ERR_TIMEOUT, "Timeout"}, + { IPQ_ERR_PROTOCOL, "Invalid protocol specified" }, + { IPQ_ERR_SETSOCKET, "Failed to set socket options" } +}; + +static int ipq_errno = IPQ_ERR_NONE; + +static ssize_t ipq_netlink_sendto(const struct ipq_handle *h, + const void *msg, size_t len); + +static ssize_t ipq_netlink_recvfrom(const struct ipq_handle *h, + unsigned char *buf, size_t len, + int timeout); + +static ssize_t ipq_netlink_sendmsg(const struct ipq_handle *h, + const struct msghdr *msg, + unsigned int flags); + +static char *ipq_strerror(int errcode); + +static ssize_t ipq_netlink_sendto(const struct ipq_handle *h, + const void *msg, size_t len) +{ + int status = sendto(h->fd, msg, len, 0, + (struct sockaddr *)&h->peer, sizeof(h->peer)); + if (status < 0) + ipq_errno = IPQ_ERR_SEND; + return status; +} + +static ssize_t ipq_netlink_sendmsg(const struct ipq_handle *h, + const struct msghdr *msg, + unsigned int flags) +{ + int status = sendmsg(h->fd, msg, flags); + if (status < 0) + ipq_errno = IPQ_ERR_SEND; + return status; +} + +static ssize_t ipq_netlink_recvfrom(const struct ipq_handle *h, + unsigned char *buf, size_t len, + int timeout) +{ + int addrlen, status; + struct nlmsghdr *nlh; + + if (len < sizeof(struct nlmsgerr)) { + ipq_errno = IPQ_ERR_RECVBUF; + return -1; + } + addrlen = sizeof(h->peer); + + if (timeout != 0) { + int ret; + struct timeval tv; + fd_set read_fds; + + if (timeout < 0) { + /* non-block non-timeout */ + tv.tv_sec = 0; + tv.tv_usec = 0; + } else { + tv.tv_sec = timeout / 1000000; + tv.tv_usec = timeout % 1000000; + } + + FD_ZERO(&read_fds); + FD_SET(h->fd, &read_fds); + ret = select(h->fd+1, &read_fds, NULL, NULL, &tv); + if (ret < 0) { + if (errno == EINTR) { + return 0; + } else { + ipq_errno = IPQ_ERR_RECV; + return -1; + } + } + if (!FD_ISSET(h->fd, &read_fds)) { + ipq_errno = IPQ_ERR_TIMEOUT; + return 0; + } + } + status = recvfrom(h->fd, buf, len, 0, + (struct sockaddr *)&h->peer, &addrlen); + if (status < 0) { + ipq_errno = IPQ_ERR_RECV; + return status; + } + if (addrlen != sizeof(h->peer)) { + ipq_errno = IPQ_ERR_RECV; + return -1; + } + if (status == 0) { + ipq_errno = IPQ_ERR_NLEOF; + return -1; + } + nlh = (struct nlmsghdr *)buf; + if (nlh->nlmsg_flags & MSG_TRUNC || nlh->nlmsg_len > status) { + ipq_errno = IPQ_ERR_RTRUNC; + return -1; + } + return status; +} + +static char *ipq_strerror(int errcode) +{ + if (errcode < 0 || errcode > IPQ_MAXERR) + errcode = IPQ_ERR_IMPL; + return ipq_errmap[errcode].message; +} + +/**************************************************************************** + * + * Public interface + * + ****************************************************************************/ + +/* + * Create and initialise an ipq handle. + */ +struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol, int recv_buf_size) +{ + int status; + struct ipq_handle *h; + + h = (struct ipq_handle *)malloc(sizeof(struct ipq_handle)); + if (h == NULL) { + ipq_errno = IPQ_ERR_HANDLE; + return NULL; + } + + memset(h, 0, sizeof(struct ipq_handle)); + + if (protocol == PF_INET) + h->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_FIREWALL); + else if (protocol == PF_INET6) + h->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_IP6_FW); + else { + ipq_errno = IPQ_ERR_PROTOCOL; + free(h); + return NULL; + } + + if (h->fd == -1) { + ipq_errno = IPQ_ERR_SOCKET; + close(h->fd); + free(h); + return NULL; + } + + status = setsockopt(h->fd,SOL_SOCKET,SO_RCVBUF,&recv_buf_size,sizeof(int)); + if (status == -1) { + ipq_errno = IPQ_ERR_SETSOCKET; + close(h->fd); + free(h); + return NULL; + } + + memset(&h->local, 0, sizeof(struct sockaddr_nl)); + h->local.nl_family = AF_NETLINK; + h->local.nl_pid = getpid(); + h->local.nl_groups = 0; + status = bind(h->fd, (struct sockaddr *)&h->local, sizeof(h->local)); + if (status == -1) { + ipq_errno = IPQ_ERR_BIND; + close(h->fd); + free(h); + return NULL; + } + memset(&h->peer, 0, sizeof(struct sockaddr_nl)); + h->peer.nl_family = AF_NETLINK; + h->peer.nl_pid = 0; + h->peer.nl_groups = 0; + return h; +} + +/* + * No error condition is checked here at this stage, but it may happen + * if/when reliable messaging is implemented. + */ +int ipq_destroy_handle(struct ipq_handle *h) +{ + if (h) { + close(h->fd); + free(h); + } + return 0; +} + +int ipq_set_mode(const struct ipq_handle *h, + u_int8_t mode, size_t range) +{ + struct { + struct nlmsghdr nlh; + ipq_peer_msg_t pm; + } req; + + memset(&req, 0, sizeof(req)); + req.nlh.nlmsg_len = NLMSG_LENGTH(sizeof(req)); + req.nlh.nlmsg_flags = NLM_F_REQUEST; + req.nlh.nlmsg_type = IPQM_MODE; + req.nlh.nlmsg_pid = h->local.nl_pid; + req.pm.msg.mode.value = mode; + req.pm.msg.mode.range = range; + return ipq_netlink_sendto(h, (void *)&req, req.nlh.nlmsg_len); +} + +/* + * timeout is in microseconds (1 second is 1000000 (1 million) microseconds) + * + */ +ssize_t ipq_read(const struct ipq_handle *h, + unsigned char *buf, size_t len, int timeout) +{ + return ipq_netlink_recvfrom(h, buf, len, timeout); +} + +int ipq_message_type(const unsigned char *buf) +{ + return ((struct nlmsghdr*)buf)->nlmsg_type; +} + +int ipq_get_msgerr(const unsigned char *buf) +{ + struct nlmsghdr *h = (struct nlmsghdr *)buf; + struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); + return -err->error; +} + +ipq_packet_msg_t *ipq_get_packet(const unsigned char *buf) +{ + return NLMSG_DATA((struct nlmsghdr *)(buf)); +} + +int ipq_set_verdict(const struct ipq_handle *h, + ipq_id_t id, + unsigned int verdict, + size_t data_len, + unsigned char *buf) +{ + unsigned char nvecs; + size_t tlen; + struct nlmsghdr nlh; + ipq_peer_msg_t pm; + struct iovec iov[3]; + struct msghdr msg; + + memset(&nlh, 0, sizeof(nlh)); + nlh.nlmsg_flags = NLM_F_REQUEST; + nlh.nlmsg_type = IPQM_VERDICT; + nlh.nlmsg_pid = h->local.nl_pid; + memset(&pm, 0, sizeof(pm)); + pm.msg.verdict.value = verdict; + pm.msg.verdict.id = id; + pm.msg.verdict.data_len = data_len; + iov[0].iov_base = &nlh; + iov[0].iov_len = sizeof(nlh); + iov[1].iov_base = ± + iov[1].iov_len = sizeof(pm); + tlen = sizeof(nlh) + sizeof(pm); + nvecs = 2; + if (data_len && buf) { + iov[2].iov_base = buf; + iov[2].iov_len = data_len; + tlen += data_len; + nvecs++; + } + msg.msg_name = (void *)&h->peer; + msg.msg_namelen = sizeof(h->peer); + msg.msg_iov = iov; + msg.msg_iovlen = nvecs; + msg.msg_control = NULL; + msg.msg_controllen = 0; + msg.msg_flags = 0; + nlh.nlmsg_len = tlen; + return ipq_netlink_sendmsg(h, &msg, 0); +} + +/* Not implemented yet */ +int ipq_ctl(const struct ipq_handle *h, int request, ...) +{ + return 1; +} + +char *ipq_errstr(void) +{ + return ipq_strerror(ipq_errno); +} + +void ipq_perror(const char *s) +{ + if (s) + fputs(s, stderr); + else + fputs("ERROR", stderr); + if (ipq_errno) + fprintf(stderr, ": %s", ipq_errstr()); + if (errno) + fprintf(stderr, ": %s", strerror(errno)); + fputc('\n', stderr); +} |