bwm-tools-devel Mailing List for Bandwidth Management Tools (Page 3)
Brought to you by:
nkukard
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(11) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(52) |
Feb
|
Mar
|
Apr
(6) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
(3) |
Mar
(9) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: SVN C. <sv...@li...> - 2005-01-12 18:38:14
|
Author: nkukard Date: 2005-01-12 20:38:02 +0200 (Wed, 12 Jan 2005) New Revision: 40 Added: branch/bwm_monitor-treeview/ Modified: branch/bwm_monitor-treeview/bwm_monitor/bwm_monitor.c branch/bwm_monitor-treeview/bwmd/flowControl.c branch/bwm_monitor-treeview/include/flowControl.h Log: * Created branch to develop bwm_monitor treeview Copied: branch/bwm_monitor-treeview (from rev 39, trunk) Modified: branch/bwm_monitor-treeview/bwm_monitor/bwm_monitor.c =================================================================== --- trunk/bwm_monitor/bwm_monitor.c 2005-01-12 18:05:22 UTC (rev 39) +++ branch/bwm_monitor-treeview/bwm_monitor/bwm_monitor.c 2005-01-12 18:38:02 UTC (rev 40) @@ -43,8 +43,35 @@ #define PORT 9034 +#define NODE_STYLE 0x01 +#define NODE_EXPAND 0x02 +typedef struct node_t { + char *name; + char flags; + // relation fields + struct node_t *prio; + struct node_t *next; + struct node_t *parent; + struct node_t *childs; +} node_t; +#define NODE struct node_t +typedef struct tree_t { + WINDOW *window; + NODE *nodes; + NODE *topnode; + NODE *selnode; + short x,y,c,l; +} tree_t; +#define TREE struct tree_t +TREE *new_tree(int l, int c, int y, int x); +NODE *new_node(TREE *tree, char *name, char *parent, char flag); +void draw_tree(TREE *tree, NODE *start); +NODE *last_node(NODE *node); +//void dump_tree(NODE *start, char level); + + static void finish(int sig); @@ -86,7 +113,7 @@ read_fds = master_fds; - result = select(fdmax + 1, &read_fds, NULL, NULL, &timeout); + result = select(fdmax + 1, &read_fds, NULL, NULL, &timeout); // Check select() result if (result > 0) @@ -211,7 +238,9 @@ MENU *m_main; WINDOW *w_menu = NULL; ITEM **menu_items; - int mrows, mcols; + TREE *flowTree; + NODE *flowNode; + int mrows, mcols, line=1; int c; char *menuItem; int done = 0; @@ -219,7 +248,7 @@ int mySock; struct sockaddr_in serverAddr; // Server address struct ipc_packet_t myPacket; - int nbytes; + int nbytes,x,y; signal(SIGINT, finish); @@ -312,11 +341,9 @@ // Set our main screen wbkgdset(w_main, COLOR_PAIR(2) | ' '); fill_window(w_main); - windowTitle(w_main,3,2,0,2,"BWM Monitor v"PACKAGE_VERSION" - Copyright (c) 2003-2005 Linux Based Systems Design"); + windowTitle(w_main,3,2,0,2,"BWM Monitor v"PACKAGE_VERSION" - Copyright (c) 2003-2004 Linux Based Systems Design"); refresh(); - - - + // Send a LIST packet away to get a flow list myPacket.pktType = IPC_PACKET_LIST_FLOWS; @@ -325,10 +352,15 @@ fprintf(stderr,"bwm_monitor: Failed to write to socket: %s\n",strerror(errno)); exit(1); } - - c = 0; + + getmaxyx(w_main, y, x); + flowTree = new_tree(y-2, x/2, 1, x/4); +// if (flowTree && flowTree->window) +// keypad(flowTree->window,TRUE); + +// c = 0; // Allocate memory for menu items - menu_items = (ITEM **) malloc((numFlows + 1) * sizeof(ITEM *)); +// menu_items = (ITEM **) malloc((numFlows + 1) * sizeof(ITEM *)); do { // Grab pavket @@ -338,13 +370,78 @@ if (myPacket.pktType == IPC_PACKET_LIST_ITEM) { // And add memory item - menu_items[c] = new_item(strdup(myPacket.u.statusData.flowName),""); - c++; +// menu_items[c] = new_item(strdup(myPacket.u.statusData.flowName),""); +// c++; + flowNode = new_node(flowTree, myPacket.u.statusData.flowName, + myPacket.u.statusData.parentName, NODE_EXPAND); + if (flowNode != NULL) + flowTree->selnode = flowNode; } } } while (myPacket.pktType == IPC_PACKET_LIST_ITEM); + flowTree->selnode = flowTree->nodes; + draw_tree(flowTree, flowTree->selnode); +// wrefresh(flowTree->window); +// dump_tree(flowTree->nodes, 0); + while (!done) + { +// if (flowTree->window) +// keypad(flowTree->window,TRUE); + switch (getch()) + { + case 'q': + done = 1; + break; + case KEY_UP: + if (flowTree->selnode->prio) + { + flowTree->selnode = flowTree->selnode->prio; + while (flowTree->selnode->flags&NODE_EXPAND && + flowTree->selnode->childs) + flowTree->selnode = last_node(flowTree->selnode->childs); + } + else if (flowTree->selnode->parent) + { + flowTree->selnode = flowTree->selnode->parent; + } + draw_tree(flowTree, flowTree->selnode); + /* we dont need colorful, do we? */ + /* + wmove(flowTree->window, 0, 1); + waddch(flowTree->window, '('); + waddch(flowTree->window, ACS_UARROW); + waddch(flowTree->window, ')'); + wrefresh(flowTree->window); + */ + break; + case KEY_DOWN: + if (flowTree->selnode->flags&NODE_EXPAND && + flowTree->selnode->childs) + flowTree->selnode = flowTree->selnode->childs; + else if (flowTree->selnode->next) + flowTree->selnode = flowTree->selnode->next; + else if (flowTree->selnode->parent) + { + NODE *p = flowTree->selnode->parent; + while (p && !p->next) + p = p->parent; + if (p) flowTree->selnode = p->next; + } + draw_tree(flowTree, flowTree->selnode); + /* + wmove(flowTree->window, 0, 1); + waddch(flowTree->window, '('); + waddch(flowTree->window, ACS_DARROW); + waddch(flowTree->window, ')'); + wrefresh(flowTree->window); + */ + break; + } + refresh(); + } +/* // Don't forget our quit item menu_items[numFlows] = new_item(strdup("Quit"),""); @@ -397,7 +494,7 @@ free_item(menu_items[c]); // free(menu_items); free_menu(m_main); - +*/ shutdown(mySock,SHUT_RDWR); close(mySock); @@ -414,3 +511,184 @@ exit(0); } + +/******************************************************************************/ +// create new tree +TREE *new_tree(int l, int c, int y, int x) +{ + TREE *tree = (TREE *) malloc (sizeof(TREE)); + if (tree != NULL) + { + tree->nodes = NULL; + tree->x = x; + tree->y = y; + tree->c = c; + tree->l = l; + if (has_colors()) + wbkgdset(tree->window, COLOR_PAIR(5) | ' '); + else + wbkgdset(tree->window, A_BOLD | ' '); + tree->window = newwin(tree->l, tree->c, tree->y, tree->x); + } + return tree; +} + +NODE *search_node(NODE *node, const char *name) +{ + if (node == NULL) + return NULL; + while (node && strcasecmp(node->name, name)!=0) + { + NODE *pnode = search_node(node->childs, name); + if ( pnode != NULL ) + return pnode; + node = node->next; + } + if (node && strcasecmp(node->name, name)==0) + return node; + return NULL; +} + +NODE *last_node(NODE *node) +{ + if (node == NULL) + return NULL; + while (node->next != NULL) + node = node->next; + return node; +} + +// create new tree node +NODE *new_node(TREE *tree, char *name, char *parent, char flag) +{ + NODE *node, *lnode=NULL, *pnode = NULL; + + if (!name || !strlen(name)) + return NULL; + + node = (NODE *) malloc(sizeof(NODE)); + if ( node != NULL ) + { + node->name = strdup(name); + if (!node->name) + { + free(node); + node = NULL; + } + else + { + if (parent && strlen(parent)) + { + NODE *p = tree->selnode ? tree->selnode : NULL; + while (p && strcasecmp(p->name, parent)!=0) + p = p->parent; + pnode = p ? p : search_node(tree->nodes, parent); + } + if (pnode!=NULL) + if (!pnode->childs) + pnode->childs = node; + else + lnode = last_node(pnode->childs); + else + lnode = last_node(tree->nodes); + node->next = NULL; + node->prio = lnode; + node->parent = pnode; + node->childs = NULL; + node->flags = flag; + if (lnode) + lnode->next = node; + if (!tree->nodes) + tree->nodes = node; + tree->selnode = node; + } + } + return node; +} + +void draw_tree(TREE *tree, NODE *start) +{ + int y, x, l, i, level=0; + NODE *p = start->parent; + + if (!tree->window) return; + setTextAttr(tree->window,WA_BOLD); + //wbkgdset(tree->window, COLOR_PAIR(5) | ' '); + fill_window(tree->window); + box(tree->window, 0, 0); + + // get start node level + while (p) { level++; p = p->parent; } + + getmaxyx(tree->window, y, x); + for (i=1; i<y-1 && start; i++) + { + wmove(tree->window, i, level*3 + 1); + if (start->parent) + { + NODE *p = start->parent; + l = level; + while (p && l>0) + { + if (p->next) + { + wmove(tree->window, i, (l-1)*3 + 1); + waddch(tree->window, ACS_VLINE); + } + p = p->parent; l--; + } + wmove(tree->window, i, level*3 + 1); + + if (!start->next) + waddch(tree->window, ACS_LLCORNER); + else + waddch(tree->window, ACS_LTEE); + } + else if (!start->next) + waddch(tree->window, ACS_LLCORNER); + else if (!start->prio) + waddch(tree->window, ACS_ULCORNER); + else + waddch(tree->window, ACS_LTEE); + waddch(tree->window, ACS_HLINE); + mvwprintw(tree->window, i, level*3 + 4, "%s", start->name); + if (start->flags&NODE_EXPAND && start->childs) + { + start = start->childs; level++; + } + else if (start->next) + start = start->next; + else if (start->parent) + { + while (start && !start->next) + { + start = start->parent; level--; + } + if (start && start->next) + start = start->next; + } + else start = NULL; + } + wrefresh(tree->window); +} + +#if 0 +void dump_tree(NODE *start, char level) +{ + while (start) + { + char i = 0; + FILE *debug = fopen("debug.txt", "a+"); + if (debug) + { + for (i = 0; i<level; i++) + fprintf(debug, "\t"); + fprintf(debug, "%s\n", start->name); + fclose(debug); + } + dump_tree(start->childs, level+1); + start = start->next; + } +} +#endif + Modified: branch/bwm_monitor-treeview/bwmd/flowControl.c =================================================================== --- trunk/bwmd/flowControl.c 2005-01-12 18:05:22 UTC (rev 39) +++ branch/bwm_monitor-treeview/bwmd/flowControl.c 2005-01-12 18:38:02 UTC (rev 40) @@ -207,6 +207,13 @@ // Construct the status packet and send it away strncpy(statusPacket.flowName,tmpFlow->flowName,MAX_REFLEN); + // If we have a parent, get its name + if (tmpFlow->parent) + strncpy(statusPacket.parentName, + tmpFlow->parent->flowName,MAX_REFLEN); + else // If not, strlen == 0 + memset(statusPacket.parentName,'\0',MAX_REFLEN); + // Setup all our counters statusPacket.maxQueueSize = tmpFlow->maxQueueSize; statusPacket.maxQueueLen = tmpFlow->maxQueueLen; statusPacket.maxRate = tmpFlow->maxRate; @@ -250,6 +257,8 @@ // Construct the status packet and send it away strncpy(statusPacket.flowName,tmpGroup->groupName,MAX_REFLEN); + // Groups don't have parents + memset(statusPacket.parentName,'\0',MAX_REFLEN); statusPacket.maxQueueSize = -1; statusPacket.maxQueueLen = -1; statusPacket.maxRate = -1; @@ -425,6 +434,12 @@ myPacket.pktType = IPC_PACKET_LIST_ITEM; strcpy(myPacket.u.statusData.flowName,tmpFlow->flowName); + // If we have a parent, get its name + if (tmpFlow->parent) + strncpy(myPacket.u.statusData.parentName, + tmpFlow->parent->flowName,MAX_REFLEN); + else // If not, strlen == 0 + memset(myPacket.u.statusData.parentName,'\0',MAX_REFLEN); sendall(tmpClient->fd, &myPacket, sizeof(struct ipc_packet_t)); flowItem = g_list_next(flowItem); } @@ -437,6 +452,8 @@ myPacket.pktType = IPC_PACKET_LIST_ITEM; strcpy(myPacket.u.statusData.flowName,tmpGroup->groupName); + // Groups don't have parents + memset(myPacket.u.statusData.parentName,'\0',MAX_REFLEN); sendall(tmpClient->fd, &myPacket, sizeof(struct ipc_packet_t)); groupItem = g_list_next(groupItem); } Modified: branch/bwm_monitor-treeview/include/flowControl.h =================================================================== --- trunk/include/flowControl.h 2005-01-12 18:05:22 UTC (rev 39) +++ branch/bwm_monitor-treeview/include/flowControl.h 2005-01-12 18:38:02 UTC (rev 40) @@ -71,6 +71,7 @@ struct status_packet_t { char flowName[MAX_REFLEN]; + char parentName[MAX_REFLEN]; long int maxQueueSize; long int maxQueueLen; long int maxRate; |
From: SVN C. <sv...@li...> - 2005-01-12 18:05:55
|
Author: nkukard Date: 2005-01-12 20:05:22 +0200 (Wed, 12 Jan 2005) New Revision: 39 Modified: trunk/CREDITS trunk/Makefile.am trunk/Makefile.in trunk/TODO trunk/bwm_firewall/Makefile.in trunk/bwm_graph/Makefile.am trunk/bwm_graph/Makefile.in trunk/bwm_graph/graph.c trunk/bwm_graph/graph.h trunk/bwm_monitor/Makefile.am trunk/bwm_monitor/Makefile.in trunk/bwm_monitor/bwm_monitor.c trunk/bwm_monitor/display.c trunk/bwm_monitor/display.h trunk/bwmd/Makefile.am trunk/bwmd/Makefile.in trunk/bwmd/autoclass.c trunk/bwmd/flow.c trunk/bwmd/flowControl.c trunk/bwmd/ipq.c trunk/bwmd/logging.c trunk/bwmd/report.c trunk/configure trunk/configure.ac trunk/doc/Makefile.in trunk/include/autoclass.h trunk/include/common.h trunk/include/flow.h trunk/include/flowControl.h trunk/include/ipq.h trunk/include/misc.h trunk/include/report.h trunk/include/xmlConf.h trunk/lib/Makefile.am trunk/lib/Makefile.in trunk/lib/misc.c trunk/lib/xmlConf.c Log: * Updated copyright dates to 2005 * Added configure option --with-rrdtool-source, this option will build rrdtool and link BWM Tools statically * Fixed glib detection bug in configure * Fixed libxml detection bug in configure * Fixed multiple entries in CREDITS file * Updated TODO file Modified: trunk/CREDITS =================================================================== --- trunk/CREDITS 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/CREDITS 2005-01-12 18:05:22 UTC (rev 39) @@ -1,3 +1,6 @@ +Giang Hu <fre...@gm...> + - Various fixes and ideas + - Added --load command to bwm_firewall Bruno Rodrigues <bdr...@st...> - Requirements for Debian Stable 3.0 @@ -2,14 +5,2 @@ -Bruno Rodrigues <bdr...@st...> - - Requirements for Debian Stable 3.0 - -Bruno Rodrigues <bdr...@st...> - - Requirements for Debian Stable 3.0 - -Bruno Rodrigues <bdr...@st...> - - Requirements for Debian Stable 3.0 - -Bruno Rodrigues <bdr...@st...> - - Requirements for Debian Stable 3.0 - Patrick Ancillotti <pa...@xs...> Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/Makefile.am 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ # # makefile.am - Makefile for BWM Tools -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 @@ -17,7 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -SUBDIRS=lib bwm_firewall bwm_graph bwmd bwm_monitor doc +SUBDIRS=$(subdirs) lib bwm_firewall bwm_graph bwmd bwm_monitor doc EXTRA_DIST=include/autoclass.h include/common.h include/flow.h include/flowControl.h include/ipq.h EXTRA_DIST+=include/libipq.h include/misc.h include/report.h include/xmlConf.h Modified: trunk/Makefile.in =================================================================== --- trunk/Makefile.in 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/Makefile.in 2005-01-12 18:05:22 UTC (rev 39) @@ -16,7 +16,7 @@ # # makefile.am - Makefile for BWM Tools -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 @@ -196,9 +196,10 @@ program_transform_name = @program_transform_name@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ -SUBDIRS = lib bwm_firewall bwm_graph bwmd bwm_monitor doc +SUBDIRS = $(subdirs) lib bwm_firewall bwm_graph bwmd bwm_monitor doc EXTRA_DIST = include/autoclass.h include/common.h include/flow.h \ include/flowControl.h include/ipq.h include/libipq.h \ include/misc.h include/report.h include/xmlConf.h Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/TODO 2005-01-12 18:05:22 UTC (rev 39) @@ -15,7 +15,5 @@ * Add menu to bwm_monitor to which IP it wants to connect to, authentication aswell and default to localhost * bwm_firewall to generate automatic MARK values for flows -* fix parseDateTime, this is the messiest function! * fix findFlowByName & findGroupByName, these 2 functions are similar and i'm sure can be merged * have the location of iptables-restore automatically discovered using ./configure, with override options -* make bwm_firewall able to reload the firewall into kernel using iptables-restore Modified: trunk/bwm_firewall/Makefile.in =================================================================== --- trunk/bwm_firewall/Makefile.in 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwm_firewall/Makefile.in 2005-01-12 18:05:22 UTC (rev 39) @@ -194,6 +194,7 @@ program_transform_name = @program_transform_name@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ EXTRA_DIST = bwm_firewall.h Modified: trunk/bwm_graph/Makefile.am =================================================================== --- trunk/bwm_graph/Makefile.am 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwm_graph/Makefile.am 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ # # makefile.am - Makefile for BWM Graph -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 Modified: trunk/bwm_graph/Makefile.in =================================================================== --- trunk/bwm_graph/Makefile.in 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwm_graph/Makefile.in 2005-01-12 18:05:22 UTC (rev 39) @@ -16,7 +16,7 @@ # # makefile.am - Makefile for BWM Graph -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 @@ -195,6 +195,7 @@ program_transform_name = @program_transform_name@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ EXTRA_DIST = graph.h Modified: trunk/bwm_graph/graph.c =================================================================== --- trunk/bwm_graph/graph.c 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwm_graph/graph.c 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * graph.c - BWM Graph functions - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/bwm_graph/graph.h =================================================================== --- trunk/bwm_graph/graph.h 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwm_graph/graph.h 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * graph.c - BWM Graph functions header file - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/bwm_monitor/Makefile.am =================================================================== --- trunk/bwm_monitor/Makefile.am 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwm_monitor/Makefile.am 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ # # makefile.am - Makefile for BWM Monitor -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 Modified: trunk/bwm_monitor/Makefile.in =================================================================== --- trunk/bwm_monitor/Makefile.in 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwm_monitor/Makefile.in 2005-01-12 18:05:22 UTC (rev 39) @@ -16,7 +16,7 @@ # # makefile.am - Makefile for BWM Monitor -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 @@ -195,6 +195,7 @@ program_transform_name = @program_transform_name@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ EXTRA_DIST = display.h Modified: trunk/bwm_monitor/bwm_monitor.c =================================================================== --- trunk/bwm_monitor/bwm_monitor.c 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwm_monitor/bwm_monitor.c 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * bwm_monitor.c - BWM Monitor - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 @@ -312,7 +312,7 @@ // Set our main screen wbkgdset(w_main, COLOR_PAIR(2) | ' '); fill_window(w_main); - windowTitle(w_main,3,2,0,2,"BWM Monitor v"PACKAGE_VERSION" - Copyright (c) 2003-2004 Linux Based Systems Design"); + windowTitle(w_main,3,2,0,2,"BWM Monitor v"PACKAGE_VERSION" - Copyright (c) 2003-2005 Linux Based Systems Design"); refresh(); Modified: trunk/bwm_monitor/display.c =================================================================== --- trunk/bwm_monitor/display.c 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwm_monitor/display.c 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * display.c - Curses stuff for BWM Monitor - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/bwm_monitor/display.h =================================================================== --- trunk/bwm_monitor/display.h 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwm_monitor/display.h 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * display.h - Curses stuff for BWM Monitor header file - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/bwmd/Makefile.am =================================================================== --- trunk/bwmd/Makefile.am 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwmd/Makefile.am 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ # # makefile.am - Makefile for BWM Daemon -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 Modified: trunk/bwmd/Makefile.in =================================================================== --- trunk/bwmd/Makefile.in 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwmd/Makefile.in 2005-01-12 18:05:22 UTC (rev 39) @@ -16,7 +16,7 @@ # # makefile.am - Makefile for BWM Daemon -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 @@ -197,6 +197,7 @@ program_transform_name = @program_transform_name@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ CONFIG_DIR = /etc/bwm_tools Modified: trunk/bwmd/autoclass.c =================================================================== --- trunk/bwmd/autoclass.c 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwmd/autoclass.c 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * autoclass.c - Automatic packet priority classification - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/bwmd/flow.c =================================================================== --- trunk/bwmd/flow.c 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwmd/flow.c 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * flow.c - Flow handling for bwmd - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/bwmd/flowControl.c =================================================================== --- trunk/bwmd/flowControl.c 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwmd/flowControl.c 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * flowControl.c - Backend <-> Frontend control - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/bwmd/ipq.c =================================================================== --- trunk/bwmd/ipq.c 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwmd/ipq.c 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * ipq.c - IPQ handling for bwmd - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/bwmd/logging.c =================================================================== --- trunk/bwmd/logging.c 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwmd/logging.c 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * logging.c - Logging support for bwmd - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/bwmd/report.c =================================================================== --- trunk/bwmd/report.c 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/bwmd/report.c 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * flowControl.c - BWM Daemon reporting stuff - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/configure =================================================================== --- trunk/configure 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/configure 2005-01-12 18:05:22 UTC (rev 39) @@ -463,7 +463,8 @@ # include <unistd.h> #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL RRDTOOL_LIBS AL! LOCA LIBOBJS PKG_CONFIG GLIB_CFLAGS GLIB_LIBS GLIB_GENMARSHAL GOBJECT_QUERY GLIB_MKENUMS XML2_CONFIG XML_CPPFLAGS XML_LIBS XML_CFLAGS LTLIBOBJS' +ac_subdirs_all="$ac_subdirs_all rrdtool" +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL subdirs RRDTOOL! _LIBS ALLOCA LIBOBJS PKG_CONFIG GLIB_CFLAGS GLIB_LIBS GLIB_GENMARSHAL GOBJECT_QUERY GLIB_MKENUMS XML2_CONFIG XML_CPPFLAGS XML_LIBS XML_CFLAGS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -1045,6 +1046,7 @@ both] --with-tags[=TAGS] include additional configurations [automatic] + --with-rrdtool-source Specify directory where rrdtool sources are --with-xml-prefix=PFX Prefix where libxml is installed (optional) --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional) @@ -3752,7 +3754,7 @@ ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 3755 "configure"' > conftest.$ac_ext + echo '#line 3757 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -5324,7 +5326,7 @@ # Provide some information about the compiler. -echo "$as_me:5327:" \ +echo "$as_me:5329:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5 @@ -6358,11 +6360,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6361: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6363: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6365: \$? = $ac_status" >&5 + echo "$as_me:6367: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -6591,11 +6593,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6594: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6596: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6598: \$? = $ac_status" >&5 + echo "$as_me:6600: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -6651,11 +6653,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6654: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6656: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:6658: \$? = $ac_status" >&5 + echo "$as_me:6660: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8835,7 +8837,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 8838 "configure" +#line 8840 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -8933,7 +8935,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 8936 "configure" +#line 8938 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11112,11 +11114,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:11115: $lt_compile\"" >&5) + (eval echo "\"\$as_me:11117: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:11119: \$? = $ac_status" >&5 + echo "$as_me:11121: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -11172,11 +11174,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:11175: $lt_compile\"" >&5) + (eval echo "\"\$as_me:11177: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:11179: \$? = $ac_status" >&5 + echo "$as_me:11181: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -12533,7 +12535,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 12536 "configure" +#line 12538 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12631,7 +12633,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 12634 "configure" +#line 12636 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13458,11 +13460,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13461: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13463: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13465: \$? = $ac_status" >&5 + echo "$as_me:13467: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -13518,11 +13520,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13521: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13523: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13525: \$? = $ac_status" >&5 + echo "$as_me:13527: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15552,11 +15554,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15555: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15557: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15559: \$? = $ac_status" >&5 + echo "$as_me:15561: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -15785,11 +15787,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15788: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15790: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15792: \$? = $ac_status" >&5 + echo "$as_me:15794: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -15845,11 +15847,11 @@ -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15848: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15850: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15852: \$? = $ac_status" >&5 + echo "$as_me:15854: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -18029,7 +18031,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 18032 "configure" +#line 18034 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18127,7 +18129,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 18130 "configure" +#line 18132 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19486,13 +19488,26 @@ fi -echo "$as_me:$LINENO: checking for rrd_create in -lrrd" >&5 + +# Check whether --with-rrdtool-source or --without-rrdtool-source was given. +if test "${with_rrdtool_source+set}" = set; then + withval="$with_rrdtool_source" + + + +subdirs="$subdirs rrdtool" + + RRDTOOL_LIBS="$top_builddir/rrdtool/src/.libs/librrdtool.a" + +else + + echo "$as_me:$LINENO: checking for rrd_create in -lrrd" >&5 echo $ECHO_N "checking for rrd_create in -lrrd... $ECHO_C" >&6 if test "${ac_cv_lib_rrd_rrd_create+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lrrd $LIBS" +LIBS="-lrrd "-lm" $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -19554,90 +19569,25 @@ have_librrd=yes fi -if test x"$have_librrd" = x -then - echo "$as_me:$LINENO: checking for rrd_update in -lrrd" >&5 -echo $ECHO_N "checking for rrd_update in -lrrd... $ECHO_C" >&6 -if test "${ac_cv_lib_rrd_rrd_update+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lrrd "-lm" $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char rrd_update (); -int -main () -{ -rrd_update (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_rrd_rrd_update=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_rrd_rrd_update=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_rrd_rrd_update" >&5 -echo "${ECHO_T}$ac_cv_lib_rrd_rrd_update" >&6 -if test $ac_cv_lib_rrd_rrd_update = yes; then - have_librrd=yes -fi - if test x"$have_librrd" = x then echo + echo "* - ERROR -" echo "* You need the development libraries and headers" echo "* for rrdtool. Normally you can download a" echo "* package called rrdtool-devel for your" echo "* distribution, install it and everything should" echo "* be fine" + echo "*" + echo "* Alternatively, follow these instructions..." + echo "* 1. Download, uncompress and extract rrdtool to the top BWM Tools directory" + echo "* 2. Symlink it, like this -> ln -s rrdtool-x.x.x rrdtool" + echo "* 3. Re-run ./configure with -> --with-rrdtool-source" exit 1 fi - RRDTOOL_LIBS="-lm" -fi -RRDTOOL_LIBS="$RRDTOOL_LIBS -lrrd" + RRDTOOL_LIBS="-lm -lrrd" +fi; # Checks for header files. @@ -22803,7 +22753,7 @@ done -# Custom +# Check for glib 2.4.0 # Check whether --enable-glibtest or --disable-glibtest was given. if test "${enable_glibtest+set}" = set; then enableval="$enable_glibtest" @@ -23123,8 +23073,17 @@ rm -f conf.glibtest +if test x"$have_glib" = x"no" +then + echo + echo "* - ERROR -" + echo "* glib >= 2.4.0 required, this includes the development libraries and headers" + exit 1 +fi +# Check for libxml 2.6.0 + # Check whether --with-xml-prefix or --without-xml-prefix was given. if test "${with_xml_prefix+set}" = set; then withval="$with_xml_prefix" @@ -23427,9 +23386,18 @@ rm -f conf.xmltest +if test x"$have_xml" = x"no" +then + echo + echo "* - ERROR -" + echo "* libxml >= 2.6.0 required, this includes the development libraries and headers" + exit 1 +fi + XML_CFLAGS=$XML_CPPFLAGS + ac_config_files="$ac_config_files Makefile lib/Makefile bwm_firewall/Makefile bwm_graph/Makefile bwmd/Makefile bwm_monitor/Makefile doc/Makefile" cat >confcache <<\_ACEOF @@ -24147,6 +24115,7 @@ s,@FFLAGS@,$FFLAGS,;t t s,@ac_ct_F77@,$ac_ct_F77,;t t s,@LIBTOOL@,$LIBTOOL,;t t +s,@subdirs@,$subdirs,;t t s,@RRDTOOL_LIBS@,$RRDTOOL_LIBS,;t t s,@ALLOCA@,$ALLOCA,;t t s,@LIBOBJS@,$LIBOBJS,;t t @@ -24876,3 +24845,180 @@ $ac_cs_success || { (exit 1); exit 1; } fi +# +# CONFIG_SUBDIRS section. +# +if test "$no_recursion" != yes; then + + # Remove --cache-file and --srcdir arguments so they do not pile up. + ac_sub_configure_args= + ac_prev= + for ac_arg in $ac_configure_args; do + if test -n "$ac_prev"; then + ac_prev= + continue + fi + case $ac_arg in + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \ + | --c=*) + ;; + --config-cache | -C) + ;; + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + ;; + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + ;; + *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;; + esac + done + + # Always prepend --prefix to ensure using the same prefix + # in subdir configurations. + ac_sub_configure_args="--prefix=$prefix $ac_sub_configure_args" + + ac_popdir=`pwd` + for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue + + # Do not complain, so a configure script can configure whichever + # parts of a large source tree are present. + test -d $srcdir/$ac_dir || continue + + { echo "$as_me:$LINENO: configuring in $ac_dir" >&5 +echo "$as_me: configuring in $ac_dir" >&6;} + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + cd $ac_dir + + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + ac_sub_configure="$SHELL '$ac_srcdir/configure.gnu'" + elif test -f $ac_srcdir/configure; then + ac_sub_configure="$SHELL '$ac_srcdir/configure'" + elif test -f $ac_srcdir/configure.in; then + ac_sub_configure=$ac_configure + else + { echo "$as_me:$LINENO: WARNING: no configuration information is in $ac_dir" >&5 +echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;} + ac_sub_configure= + fi + + # The recursion is here. + if test -n "$ac_sub_configure"; then + # Make the cache file name correct relative to the subdirectory. + case $cache_file in + [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;; + *) # Relative path. + ac_sub_cache_file=$ac_top_builddir$cache_file ;; + esac + + { echo "$as_me:$LINENO: running $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5 +echo "$as_me: running $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;} + # The eval makes quoting arguments work. + eval $ac_sub_configure $ac_sub_configure_args \ + --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir || + { { echo "$as_me:$LINENO: error: $ac_sub_configure failed for $ac_dir" >&5 +echo "$as_me: error: $ac_sub_configure failed for $ac_dir" >&2;} + { (exit 1); exit 1; }; } + fi + + cd $ac_popdir + done +fi + Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/configure.ac 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * configure.ac - Configure macro file for BWM Tools - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 @@ -42,26 +42,34 @@ AC_CHECK_LIB([ncurses], [curses_version]) AC_CHECK_LIB([panel], [panel_window]) -AC_CHECK_LIB([rrd], [rrd_create],have_librrd=yes) -if test x"$have_librrd" = x -then - AC_CHECK_LIB([rrd], [rrd_update],have_librrd=yes,,"-lm") +AC_ARG_WITH([rrdtool-source], + [ --with-rrdtool-source Specify directory where rrdtool sources are], + [ + AC_CONFIG_SUBDIRS(rrdtool) + RRDTOOL_LIBS="$top_builddir/rrdtool/src/.libs/librrdtool.a" + ], + [ + AC_CHECK_LIB([rrd], [rrd_create],have_librrd=yes,,"-lm") if test x"$have_librrd" = x then echo + echo "* - ERROR -" echo "* You need the development libraries and headers" echo "* for rrdtool. Normally you can download a" echo "* package called rrdtool-devel for your" echo "* distribution, install it and everything should" echo "* be fine" + echo "*" + echo "* Alternatively, follow these instructions..." + echo "* 1. Download, uncompress and extract rrdtool to the top BWM Tools directory" + echo "* 2. Symlink it, like this -> ln -s rrdtool-x.x.x rrdtool" + echo "* 3. Re-run ./configure with -> --with-rrdtool-source" exit 1 fi - RRDTOOL_LIBS="-lm" -fi -RRDTOOL_LIBS="$RRDTOOL_LIBS -lrrd" + RRDTOOL_LIBS="-lm -lrrd" + ]) AC_SUBST(RRDTOOL_LIBS) - # Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT @@ -87,12 +95,30 @@ AC_FUNC_VPRINTF AC_CHECK_FUNCS([gettimeofday inet_ntoa memset select socket strcasecmp strchr strdup strerror strncasecmp strndup]) -# Custom +# Check for glib 2.4.0 AM_PATH_GLIB_2_0(2.4.0,have_glib=yes,have_glib=no,gthread) +if test x"$have_glib" = x"no" +then + echo + echo "* - ERROR -" + echo "* glib >= 2.4.0 required, this includes the development libraries and headers" + exit 1 +fi + +# Check for libxml 2.6.0 AM_PATH_XML2(2.6.0,have_xml=yes,have_xml=no) +if test x"$have_xml" = x"no" +then + echo + echo "* - ERROR -" + echo "* libxml >= 2.6.0 required, this includes the development libraries and headers" + exit 1 +fi + XML_CFLAGS=$XML_CPPFLAGS AC_SUBST(XML_CFLAGS) + AC_CONFIG_FILES([ Makefile lib/Makefile Modified: trunk/doc/Makefile.in =================================================================== --- trunk/doc/Makefile.in 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/doc/Makefile.in 2005-01-12 18:05:22 UTC (rev 39) @@ -186,6 +186,7 @@ program_transform_name = @program_transform_name@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ EXTRA_DIST = Configuration Install example.xml fdl.texi Modified: trunk/include/autoclass.h =================================================================== --- trunk/include/autoclass.h 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/include/autoclass.h 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * autoclass.h - Automatic packet priority classification header file - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/include/common.h =================================================================== --- trunk/include/common.h 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/include/common.h 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * common.h - Header stuff commonly used by more than 1 .c file - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/include/flow.h =================================================================== --- trunk/include/flow.h 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/include/flow.h 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * flow.h - Headerfile for bwmd - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/include/flowControl.h =================================================================== --- trunk/include/flowControl.h 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/include/flowControl.h 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * flowControl.h - Control interface stuff - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/include/ipq.h =================================================================== --- trunk/include/ipq.h 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/include/ipq.h 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * ipq.h - IPQ header file for bwmd - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/include/misc.h =================================================================== --- trunk/include/misc.h 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/include/misc.h 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * misc.h - Misc functions header file - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/include/report.h =================================================================== --- trunk/include/report.h 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/include/report.h 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * report.h - Reporting header file for bwmd - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/include/xmlConf.h =================================================================== --- trunk/include/xmlConf.h 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/include/xmlConf.h 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * xmlConf.h - Header stuff for our xml config library - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/lib/Makefile.am =================================================================== --- trunk/lib/Makefile.am 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/lib/Makefile.am 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ # # makefile.am - Makefile for the BWM library -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 Modified: trunk/lib/Makefile.in =================================================================== --- trunk/lib/Makefile.in 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/lib/Makefile.in 2005-01-12 18:05:22 UTC (rev 39) @@ -16,7 +16,7 @@ # # makefile.am - Makefile for the BWM library -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 @@ -199,6 +199,7 @@ program_transform_name = @program_transform_name@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ lib_LTLIBRARIES = libbwm.la Modified: trunk/lib/misc.c =================================================================== --- trunk/lib/misc.c 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/lib/misc.c 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * misc.c - Misc functions we can use - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 Modified: trunk/lib/xmlConf.c =================================================================== --- trunk/lib/xmlConf.c 2005-01-10 17:00:29 UTC (rev 38) +++ trunk/lib/xmlConf.c 2005-01-12 18:05:22 UTC (rev 39) @@ -1,6 +1,6 @@ /* * xmlConf.c - XML config file stuff - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 |
From: SVN C. <sv...@li...> - 2005-01-10 17:00:47
|
Author: nkukard Date: 2005-01-10 19:00:29 +0200 (Mon, 10 Jan 2005) New Revision: 38 Modified: trunk/doc/Makefile.am trunk/doc/Makefile.in Log: * Remove bwmtools.info if we do make clean as this file is generated Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2005-01-10 15:33:52 UTC (rev 37) +++ trunk/doc/Makefile.am 2005-01-10 17:00:29 UTC (rev 38) @@ -19,6 +19,7 @@ EXTRA_DIST = Configuration Install example.xml fdl.texi +CLEANFILES = bwmtools.info info_TEXINFOS = bwmtools.texi Modified: trunk/doc/Makefile.in =================================================================== --- trunk/doc/Makefile.in 2005-01-10 15:33:52 UTC (rev 37) +++ trunk/doc/Makefile.in 2005-01-10 17:00:29 UTC (rev 38) @@ -66,7 +66,7 @@ CONFIG_CLEAN_FILES = SOURCES = DIST_SOURCES = -INFO_DEPS = $(srcdir)/bwmtools.info +INFO_DEPS = bwmtools.info am__TEXINFO_TEX_DIR = $(srcdir) DVIS = bwmtools.dvi PDFS = bwmtools.pdf @@ -189,11 +189,12 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ EXTRA_DIST = Configuration Install example.xml fdl.texi +CLEANFILES = bwmtools.info info_TEXINFOS = bwmtools.texi all: all-am .SUFFIXES: -.SUFFIXES: .dvi .html .info .pdf .ps .texi +.SUFFIXES: .dvi .ps $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -233,40 +234,36 @@ distclean-libtool: -rm -f libtool -.texi.info: +bwmtools.info: bwmtools.texi $(srcdir)/version.texi restore=: && backupdir="$(am__leading_dot)am$$$$" && \ - am__cwd=`pwd` && cd $(srcdir) && \ rm -rf $$backupdir && mkdir $$backupdir && \ for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \ if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \ done; \ - cd "$$am__cwd"; \ if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ - -o $@ $<; \ + -o $@ `test -f 'bwmtools.texi' || echo '$(srcdir)/'`bwmtools.texi; \ then \ rc=0; \ - cd $(srcdir); \ else \ rc=$$?; \ - cd $(srcdir) && \ $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \ fi; \ rm -rf $$backupdir; exit $$rc -.texi.dvi: +bwmtools.dvi: bwmtools.texi $(srcdir)/version.texi TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ - $(TEXI2DVI) $< + $(TEXI2DVI) -o $@ `test -f 'bwmtools.texi' || echo '$(srcdir)/'`bwmtools.texi -.texi.pdf: +bwmtools.pdf: bwmtools.texi $(srcdir)/version.texi TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ - $(TEXI2PDF) $< + $(TEXI2PDF) -o $@ `test -f 'bwmtools.texi' || echo '$(srcdir)/'`bwmtools.texi -.texi.html: +bwmtools.html: bwmtools.texi $(srcdir)/version.texi rm -rf $(@:.html=.htp) if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ - -o $(@:.html=.htp) $<; \ + -o $(@:.html=.htp) `test -f 'bwmtools.texi' || echo '$(srcdir)/'`bwmtools.texi; \ then \ rm -rf $@; \ if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ @@ -276,10 +273,6 @@ rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \ exit 1; \ fi -$(srcdir)/bwmtools.info: bwmtools.texi $(srcdir)/version.texi -bwmtools.dvi: bwmtools.texi $(srcdir)/version.texi -bwmtools.pdf: bwmtools.texi $(srcdir)/version.texi -bwmtools.html: bwmtools.texi $(srcdir)/version.texi $(srcdir)/version.texi: $(srcdir)/stamp-vti $(srcdir)/stamp-vti: bwmtools.texi $(top_srcdir)/configure @(dir=.; test -f ./bwmtools.texi || dir=$(srcdir); \ @@ -413,6 +406,7 @@ mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) |
From: SVN C. <sv...@li...> - 2005-01-10 15:34:09
|
Author: nkukard Date: 2005-01-10 17:33:52 +0200 (Mon, 10 Jan 2005) New Revision: 37 Modified: trunk/doc/Makefile.am trunk/doc/Makefile.in Log: * Added fdl.texi to distribution Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2005-01-10 12:56:05 UTC (rev 36) +++ trunk/doc/Makefile.am 2005-01-10 15:33:52 UTC (rev 37) @@ -18,7 +18,7 @@ -EXTRA_DIST = Configuration Install example.xml +EXTRA_DIST = Configuration Install example.xml fdl.texi info_TEXINFOS = bwmtools.texi Modified: trunk/doc/Makefile.in =================================================================== --- trunk/doc/Makefile.in 2005-01-10 12:56:05 UTC (rev 36) +++ trunk/doc/Makefile.in 2005-01-10 15:33:52 UTC (rev 37) @@ -188,7 +188,7 @@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ -EXTRA_DIST = Configuration Install example.xml +EXTRA_DIST = Configuration Install example.xml fdl.texi info_TEXINFOS = bwmtools.texi all: all-am |
From: SVN C. <sv...@li...> - 2005-01-10 12:56:24
|
Author: nkukard Date: 2005-01-10 14:56:05 +0200 (Mon, 10 Jan 2005) New Revision: 36 Removed: trunk/doc/bwmtools.info Log: * Remove bwmtools.info, this is built when compiling Deleted: trunk/doc/bwmtools.info =================================================================== --- trunk/doc/bwmtools.info 2005-01-10 12:02:47 UTC (rev 35) +++ trunk/doc/bwmtools.info 2005-01-10 12:56:05 UTC (rev 36) @@ -1,852 +0,0 @@ -This is bwmtools.info, produced by makeinfo version 4.7 from -bwmtools.texi. - - This manual is for BWM Tools (version devel, 7 January 2005) - - Copyright (C) 2005 Linux Based Systems Design. - - Permission is granted to copy, distribute and/or modify this - document under the terms of the GNU Free Documentation License, - Version 1.2 or any later version published by the Free Software - Foundation; with no Invariant Sections, no Front-Cover Texts, and - no Back-Cover Texts. A copy of the license is included in the - section entitled "GNU Free Documentation License". - -INFO-DIR-SECTION Network applications -START-INFO-DIR-ENTRY -* BWM Tools: Managing bandwidth with BWM Tools -END-INFO-DIR-ENTRY - - -File: bwmtools.info, Node: Top, Next: Introduction, Up: (dir) - -Bandwidth Management Tools -************************** - -* Menu: - -* Introduction::The purpose of BWM Tools -* Installation::Building and installing the package -* Configuration::Configuring BWM Tools -* Graphing::Generating graphs -* Examples::Configuration examples -* Advanced::Advanced issues -* Copying This Manual:: -* Index:: - - -File: bwmtools.info, Node: Introduction, Next: Installation, Prev: Top, Up: Top - -1 Introduction -************** - -Bandwidth Management Tools was designed to provide a full suite of -bandwidth management applications, able to shape, log and graph traffic. - - Seeing as BWM Tools uses iptables for matching traffic, the -complexity of traffic control is limitless. - - BWM Tools is a set of userspace utilities, no kernel patches are -required. As long as your iptables supports the `-j QUEUE' target, -traffic shaping will work. - - -File: bwmtools.info, Node: Installation, Next: Configuration, Prev: Introduction, Up: Top - -2 Installation -************** - -Before you can use BWM Tools, you must make sure you have all the -dependencies installed... - - * glib2 >= 2.4.0 - - * libxml2 >= 2.6.0 - - * rrdtool >= 1.0.49 (only required for graphing) - - Next you need to download BWM Tools, compile it and install it. - - Here is step-by-step instructions on how to do this... - - 1. Download the latest version of BWM Tools, the latest version can be - found on the project homepage: `http://bwm-tools.lbsd.net' - - 2. Uncompress the archive using either `tar jxvf <archive - name>.tar.bz2' or `tar zxvf <archive name>.tar.gz' depending - weather its a .tar.bz2 or .tar.gz respectively. - - 3. Run `./configure' in the source directory. Optionally a - `--prefix=...' parameter can be passed which will determine where - BWM Tools will be installed. - - 4. Once the configure process is complete, issue a `make' command, - this will compile BWM Tools. - - 5. When BWM Tools has finished compiling, type `make install'. This - will by default install BWM Tools into /usr/local, unless of course - if you specified a `--prefix=...' above. - - -File: bwmtools.info, Node: Configuration, Next: Graphing, Prev: Installation, Up: Top - -3 Configuration -*************** - -Configuration of BWM Tools is done via an XML configuration file, this -file is normally located in /etc/bwm_tools/firewall.xml - - The layout of the file is pretty simple and is split up into various -sections, these are detailed below... - -* Menu: - -* Global:: -* ACL:: -* NAT:: -* Traffic:: - - -File: bwmtools.info, Node: Global, Next: ACL, Up: Configuration - -3.1 The `<global>' section -========================== - -This section contains global directives pertaining to either the -operation of BWM Tools or definitions used in other sections. These -directives are detailed below... - - * Module management in the `<modules>' section - This section is used to load modules when bwmd starts. The syntax - to load a module is as follows... - <load name="kernel_module_name" /> - - The `<load />' tag takes the following parameters... - * `name="..."' - This is the name of the module to load - - * `params="..."' - Parameters to load module with - - Here is how it can be used to load the ip_queue kernel module - required by bwmd for shaping. Including ftp connection tracking to - allow users to ftp through a tightly secured firewall. - <firewall> - <global> - <modules> - <load name="ip_queue"/> - <load name="ip_nat_ftp"/> - <load name="ip_conntrack_ftp"/> - </modules> - </global> - . - . - . - </firewall> - - * Class definition in the `<class>' section - This section is used to define classes used in both firewalling - and network address translation. The basic syntax is as follows... - <class name="traffic_from_support"> - <address name="pete_in" src="192.168.0.100" /> - </class> - - The `<class>' tag has got no other options apart from name. - - The `<address />' tag on the other hand has the following - options... - - * `name="..."' - This is a descriptive name for the address, - isn't really used anywhere - - * `cmd-line="..."' - Optional command line arguments for - iptables, for example `cmd-line="-m helper --helper <string>"' - - * `dst="..."' - Optional destination IP address - - * `dst-iface="..."' - Optional destination interface - - * `dst-port="..."' - Optional destination port - - * `proto="..."' - Optional protocol specification, any valid - protocol in `/etc/protocols' - - * `src="..."' - Optional source IP address - - * `src-iface="..."' - Optional source interface - - * `src-port="..."' - Optional source port - - Here is an example how it can be used to match connections over a - specific number... - <firewall> - <global> - . - . - . - <class name="excess_connections_to_webserver"> - <address name="excess_to_server1" dst="192.168.0.100" proto="tcp" dst-port="80" cmd-line="-m connlimit --connlimit-above 10"/> - </class> - </global> - . - . - . - </firewall> - - -File: bwmtools.info, Node: ACL, Next: NAT, Prev: Global, Up: Configuration - -3.2 The `<acl>' section -======================= - -This is basically the firewall section, you can add all your firewall -rules here or just leave it blank to use your current firewall. - - The syntax for this section is a little more complex and is as -follows... - <acl> - <table name="filter"> - <chain name="INPUT" defualt="ACCEPT"> - <rule name="excess_connections" target="DROP"> - excess_connections_to_webserver - </rule> - </chain> - </table> - </acl> - - Explaining the above example, this will add 1 rule to the `INPUT' -chain under the `filter' table which will drop all new packets that -arrive if the concurrent connections on port 80 is higher than 10. - - It is the equivalent to... -`iptables -t filter -A INPUT -d 192.168.0.10 -p tcp -dport 80 -m -connlimit --connlimit-above 10 -j DROP' - - The following tags and parameters are available... - * Specify the table with `<table> ... </table>' - The `<table>' tag is used to enclose the directives you plan to - use with a specific table. Examples of tables are... `filter', - `nat', `mangle' - - The `<table>' tag takes the following parameters... - * `name="..."' - This is the name of the table we will be - working with - - * Specify a chain with `<chain> ... </chain>' - The `<chain>' tag is used to specify what chain the rules defined - between the starting and ending tags apply to. Examples of already - defined chains are `INPUT', `OUTPUT' and `FORWARD'. - - The `<chain>' tag takes the following parameters... - * `name="..."' - This is the name of the chain we will be - working with - - * `default="..."' - This specifies the default target for the - chain - - * Specify a rule with `<rule> ... </rule>' - The `<rule>' tag is used to specify what classes apply to what - rule, and are in order inserted into the actual iptables chains as - iptables rules. - - The `<rule>' tag takes the following parameters... - * `name="..."' - Optional name of rule - - * `cmd-line="..."' - Optional extra command line parameters to - pass to iptables - - * `target="..."' - This is the target for the rule, used as the - `-j <target>' parameter when generating iptables rules. - - Between the opening and closing tags, classes defined in the - `<global>' section are listed, these classify which traffic - applies to which rule. - - Multiple classes can be listed, one per line. - -Using the above, here is an example of a simple firewall which allows -http and ssh traffic, assuming your IP address is 10.0.0.2 of course... - <firewall> - # Global configuration and access classes - <global> - <class name="http_traffic"> - <address dst="10.0.0.2" proto="tcp" dst-port="80"/> - </class> - <class name="ssh_traffic"> - <address dst="10.0.0.2" proto="tcp" dst-port="22"/> - </class> - </global> - - # Access control lists - <acl> - <table name="filter"> - <chain name="INPUT" default="DROP"> - <rule name="allowed_traffic" target="ACCEPT"> - http_traffic - ssh_traffic - </rule> - </chain> - <chain name="FORWARD" default="DROP"> - </chain> - <chain name="OUTPUT" default="ACCEPT"> - </chain> - </table> - </acl> - - </firewall> - - -File: bwmtools.info, Node: NAT, Next: Traffic, Prev: ACL, Up: Configuration - -3.3 The `<nat>' section -======================= - -The NAT section is used to define network address translation rules, -these rules allow one to translate the source or destination IP address -within packets. A common use for this is when a webserver is behind a -firewall, requests are made to a globally routable IP address and -translated to the internal IP address of the webserver and visa versa. - - This section has the following syntax... - <nat> - <snat> - <rule name="traf_from_webserver" to-src="<globally routable IP here>"> - traffic_from_webserver - </rule> - </snat> - <dnat> - <rule name="traf_to_webserver" to-dst="192.168.1.100"> - traffic_to_webserver - </rule> - </dnat> - </nat> - - There are 2 tags available, `<snat>' and `<dnat>', these two tags -are used for soure network address translation and destination address -translation respectively. - - Valid options for these 2 directives are as follows... - * Source network address translation using `<snat>' - SNAT is used for source network address translation, an example of - which is again a webserver behind a firewall. Where SNAT comes in - handy is when the webserver makes a query through the firewall, - instead of the traffic on the internet comming from the webservers - internal IP 192.168.1.100 which is not going to work, the firewall - translates 192.168.1.100 to a globally routable IP address. - - There are no parameters for this directive, although the following - tags and parameters are available... - * Specify a rule with `<rule> ... </rule>' - The `<rule>' tag is used to specify what classes apply to - what rule, and are in order inserted into the actual iptables - chains as iptables rules. - - The `<rule>' tag takes the following parameters... - * `name="..."' - Optional name of rule - - * `to-src"..."' - Translate all traffic matched in the - class specification to this IP address. - - Between the opening and closing tags, classes defined in the - `<global>' section are listed, these classify which traffic - applies to which rule. - - Multiple classes can be listed, one per line. - - - -File: bwmtools.info, Node: Traffic, Prev: NAT, Up: Configuration - -3.4 The `<traffic>' section -=========================== - - -File: bwmtools.info, Node: Graphing, Next: Examples, Prev: Configuration, Up: Top - -4 Graphing -********** - - -File: bwmtools.info, Node: Examples, Next: Advanced, Prev: Graphing, Up: Top - -5 Examples -********** - - -File: bwmtools.info, Node: Advanced, Next: Copying This Manual, Prev: Examples, Up: Top - -6 Advanced -********** - - -File: bwmtools.info, Node: Copying This Manual, Next: Index, Prev: Advanced, Up: Top - -Appendix A Copying This Manual -****************************** - -* Menu: - -* GNU Free Documentation License:: License for copying this manual. - - -File: bwmtools.info, Node: GNU Free Documentation License, Up: Copying This Manual - -A.1 GNU Free Documentation License -================================== - - Version 1.2, November 2002 - - Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA - - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - 0. PREAMBLE - - The purpose of this License is to make a manual, textbook, or other - functional and useful document "free" in the sense of freedom: to - assure everyone the effective freedom to copy and redistribute it, - with or without modifying it, either commercially or - noncommercially. Secondarily, this License preserves for the - author and publisher a way to get credit for their work, while not - being considered responsible for modifications made by others. - - This License is a kind of "copyleft", which means that derivative - works of the document must themselves be free in the same sense. - It complements the GNU General Public License, which is a copyleft - license designed for free software. - - We have designed this License in order to use it for manuals for - free software, because free software needs free documentation: a - free program should come with manuals providing the same freedoms - that the software does. But this License is not limited to - software manuals; it can be used for any textual work, regardless - of subject matter or whether it is published as a printed book. - We recommend this License principally for works whose purpose is - instruction or reference. - - 1. APPLICABILITY AND DEFINITIONS - - This License applies to any manual or other work, in any medium, - that contains a notice placed by the copyright holder saying it - can be distributed under the terms of this License. Such a notice - grants a world-wide, royalty-free license, unlimited in duration, - to use that work under the conditions stated herein. The - "Document", below, refers to any such manual or work. Any member - of the public is a licensee, and is addressed as "you". You - accept the license if you copy, modify or distribute the work in a - way requiring permission under copyright law. - - A "Modified Version" of the Document means any work containing the - Document or a portion of it, either copied verbatim, or with - modifications and/or translated into another language. - - A "Secondary Section" is a named appendix or a front-matter section - of the Document that deals exclusively with the relationship of the - publishers or authors of the Document to the Document's overall - subject (or to related matters) and contains nothing that could - fall directly within that overall subject. (Thus, if the Document - is in part a textbook of mathematics, a Secondary Section may not - explain any mathematics.) The relationship could be a matter of - historical connection with the subject or with related matters, or - of legal, commercial, philosophical, ethical or political position - regarding them. - - The "Invariant Sections" are certain Secondary Sections whose - titles are designated, as being those of Invariant Sections, in - the notice that says that the Document is released under this - License. If a section does not fit the above definition of - Secondary then it is not allowed to be designated as Invariant. - The Document may contain zero Invariant Sections. If the Document - does not identify any Invariant Sections then there are none. - - The "Cover Texts" are certain short passages of text that are - listed, as Front-Cover Texts or Back-Cover Texts, in the notice - that says that the Document is released under this License. A - Front-Cover Text may be at most 5 words, and a Back-Cover Text may - be at most 25 words. - - A "Transparent" copy of the Document means a machine-readable copy, - represented in a format whose specification is available to the - general public, that is suitable for revising the document - straightforwardly with generic text editors or (for images - composed of pixels) generic paint programs or (for drawings) some - widely available drawing editor, and that is suitable for input to - text formatters or for automatic translation to a variety of - formats suitable for input to text formatters. A copy made in an - otherwise Transparent file format whose markup, or absence of - markup, has been arranged to thwart or discourage subsequent - modification by readers is not Transparent. An image format is - not Transparent if used for any substantial amount of text. A - copy that is not "Transparent" is called "Opaque". - - Examples of suitable formats for Transparent copies include plain - ASCII without markup, Texinfo input format, LaTeX input format, - SGML or XML using a publicly available DTD, and - standard-conforming simple HTML, PostScript or PDF designed for - human modification. Examples of transparent image formats include - PNG, XCF and JPG. Opaque formats include proprietary formats that - can be read and edited only by proprietary word processors, SGML or - XML for which the DTD and/or processing tools are not generally - available, and the machine-generated HTML, PostScript or PDF - produced by some word processors for output purposes only. - - The "Title Page" means, for a printed book, the title page itself, - plus such following pages as are needed to hold, legibly, the - material this License requires to appear in the title page. For - works in formats which do not have any title page as such, "Title - Page" means the text near the most prominent appearance of the - work's title, preceding the beginning of the body of the text. - - A section "Entitled XYZ" means a named subunit of the Document - whose title either is precisely XYZ or contains XYZ in parentheses - following text that translates XYZ in another language. (Here XYZ - stands for a specific section name mentioned below, such as - "Acknowledgements", "Dedications", "Endorsements", or "History".) - To "Preserve the Title" of such a section when you modify the - Document means that it remains a section "Entitled XYZ" according - to this definition. - - The Document may include Warranty Disclaimers next to the notice - which states that this License applies to the Document. These - Warranty Disclaimers are considered to be included by reference in - this License, but only as regards disclaiming warranties: any other - implication that these Warranty Disclaimers may have is void and - has no effect on the meaning of this License. - - 2. VERBATIM COPYING - - You may copy and distribute the Document in any medium, either - commercially or noncommercially, provided that this License, the - copyright notices, and the license notice saying this License - applies to the Document are reproduced in all copies, and that you - add no other conditions whatsoever to those of this License. You - may not use technical measures to obstruct or control the reading - or further copying of the copies you make or distribute. However, - you may accept compensation in exchange for copies. If you - distribute a large enough number of copies you must also follow - the conditions in section 3. - - You may also lend copies, under the same conditions stated above, - and you may publicly display copies. - - 3. COPYING IN QUANTITY - - If you publish printed copies (or copies in media that commonly - have printed covers) of the Document, numbering more than 100, and - the Document's license notice requires Cover Texts, you must - enclose the copies in covers that carry, clearly and legibly, all - these Cover Texts: Front-Cover Texts on the front cover, and - Back-Cover Texts on the back cover. Both covers must also clearly - and legibly identify you as the publisher of these copies. The - front cover must present the full title with all words of the - title equally prominent and visible. You may add other material - on the covers in addition. Copying with changes limited to the - covers, as long as they preserve the title of the Document and - satisfy these conditions, can be treated as verbatim copying in - other respects. - - If the required texts for either cover are too voluminous to fit - legibly, you should put the first ones listed (as many as fit - reasonably) on the actual cover, and continue the rest onto - adjacent pages. - - If you publish or distribute Opaque copies of the Document - numbering more than 100, you must either include a - machine-readable Transparent copy along with each Opaque copy, or - state in or with each Opaque copy a computer-network location from - which the general network-using public has access to download - using public-standard network protocols a complete Transparent - copy of the Document, free of added material. If you use the - latter option, you must take reasonably prudent steps, when you - begin distribution of Opaque copies in quantity, to ensure that - this Transparent copy will remain thus accessible at the stated - location until at least one year after the last time you - distribute an Opaque copy (directly or through your agents or - retailers) of that edition to the public. - - It is requested, but not required, that you contact the authors of - the Document well before redistributing any large number of - copies, to give them a chance to provide you with an updated - version of the Document. - - 4. MODIFICATIONS - - You may copy and distribute a Modified Version of the Document - under the conditions of sections 2 and 3 above, provided that you - release the Modified Version under precisely this License, with - the Modified Version filling the role of the Document, thus - licensing distribution and modification of the Modified Version to - whoever possesses a copy of it. In addition, you must do these - things in the Modified Version: - - A. Use in the Title Page (and on the covers, if any) a title - distinct from that of the Document, and from those of - previous versions (which should, if there were any, be listed - in the History section of the Document). You may use the - same title as a previous version if the original publisher of - that version gives permission. - - B. List on the Title Page, as authors, one or more persons or - entities responsible for authorship of the modifications in - the Modified Version, together with at least five of the - principal authors of the Document (all of its principal - authors, if it has fewer than five), unless they release you - from this requirement. - - C. State on the Title page the name of the publisher of the - Modified Version, as the publisher. - - D. Preserve all the copyright notices of the Document. - - E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices. - - F. Include, immediately after the copyright notices, a license - notice giving the public permission to use the Modified - Version under the terms of this License, in the form shown in - the Addendum below. - - G. Preserve in that license notice the full lists of Invariant - Sections and required Cover Texts given in the Document's - license notice. - - H. Include an unaltered copy of this License. - - I. Preserve the section Entitled "History", Preserve its Title, - and add to it an item stating at least the title, year, new - authors, and publisher of the Modified Version as given on - the Title Page. If there is no section Entitled "History" in - the Document, create one stating the title, year, authors, - and publisher of the Document as given on its Title Page, - then add an item describing the Modified Version as stated in - the previous sentence. - - J. Preserve the network location, if any, given in the Document - for public access to a Transparent copy of the Document, and - likewise the network locations given in the Document for - previous versions it was based on. These may be placed in - the "History" section. You may omit a network location for a - work that was published at least four years before the - Document itself, or if the original publisher of the version - it refers to gives permission. - - K. For any section Entitled "Acknowledgements" or "Dedications", - Preserve the Title of the section, and preserve in the - section all the substance and tone of each of the contributor - acknowledgements and/or dedications given therein. - - L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section - titles. - - M. Delete any section Entitled "Endorsements". Such a section - may not be included in the Modified Version. - - N. Do not retitle any existing section to be Entitled - "Endorsements" or to conflict in title with any Invariant - Section. - - O. Preserve any Warranty Disclaimers. - - If the Modified Version includes new front-matter sections or - appendices that qualify as Secondary Sections and contain no - material copied from the Document, you may at your option - designate some or all of these sections as invariant. To do this, - add their titles to the list of Invariant Sections in the Modified - Version's license notice. These titles must be distinct from any - other section titles. - - You may add a section Entitled "Endorsements", provided it contains - nothing but endorsements of your Modified Version by various - parties--for example, statements of peer review or that the text - has been approved by an organization as the authoritative - definition of a standard. - - You may add a passage of up to five words as a Front-Cover Text, - and a passage of up to 25 words as a Back-Cover Text, to the end - of the list of Cover Texts in the Modified Version. Only one - passage of Front-Cover Text and one of Back-Cover Text may be - added by (or through arrangements made by) any one entity. If the - Document already includes a cover text for the same cover, - previously added by you or by arrangement made by the same entity - you are acting on behalf of, you may not add another; but you may - replace the old one, on explicit permission from the previous - publisher that added the old one. - - The author(s) and publisher(s) of the Document do not by this - License give permission to use their names for publicity for or to - assert or imply endorsement of any Modified Version. - - 5. COMBINING DOCUMENTS - - You may combine the Document with other documents released under - this License, under the terms defined in section 4 above for - modified versions, provided that you include in the combination - all of the Invariant Sections of all of the original documents, - unmodified, and list them all as Invariant Sections of your - combined work in its license notice, and that you preserve all - their Warranty Disclaimers. - - The combined work need only contain one copy of this License, and - multiple identical Invariant Sections may be replaced with a single - copy. If there are multiple Invariant Sections with the same name - but different contents, make the title of each such section unique - by adding at the end of it, in parentheses, the name of the - original author or publisher of that section if known, or else a - unique number. Make the same adjustment to the section titles in - the list of Invariant Sections in the license notice of the - combined work. - - In the combination, you must combine any sections Entitled - "History" in the various original documents, forming one section - Entitled "History"; likewise combine any sections Entitled - "Acknowledgements", and any sections Entitled "Dedications". You - must delete all sections Entitled "Endorsements." - - 6. COLLECTIONS OF DOCUMENTS - - You may make a collection consisting of the Document and other - documents released under this License, and replace the individual - copies of this License in the various documents with a single copy - that is included in the collection, provided that you follow the - rules of this License for verbatim copying of each of the - documents in all other respects. - - You may extract a single document from such a collection, and - distribute it individually under this License, provided you insert - a copy of this License into the extracted document, and follow - this License in all other respects regarding verbatim copying of - that document. - - 7. AGGREGATION WITH INDEPENDENT WORKS - - A compilation of the Document or its derivatives with other - separate and independent documents or works, in or on a volume of - a storage or distribution medium, is called an "aggregate" if the - copyright resulting from the compilation is not used to limit the - legal rights of the compilation's users beyond what the individual - works permit. When the Document is included in an aggregate, this - License does not apply to the other works in the aggregate which - are not themselves derivative works of the Document. - - If the Cover Text requirement of section 3 is applicable to these - copies of the Document, then if the Document is less than one half - of the entire aggregate, the Document's Cover Texts may be placed - on covers that bracket the Document within the aggregate, or the - electronic equivalent of covers if the Document is in electronic - form. Otherwise they must appear on printed covers that bracket - the whole aggregate. - - 8. TRANSLATION - - Translation is considered a kind of modification, so you may - distribute translations of the Document under the terms of section - 4. Replacing Invariant Sections with translations requires special - permission from their copyright holders, but you may include - translations of some or all Invariant Sections in addition to the - original versions of these Invariant Sections. You may include a - translation of this License, and all the license notices in the - Document, and any Warranty Disclaimers, provided that you also - include the original English version of this License and the - original versions of those notices and disclaimers. In case of a - disagreement between the translation and the original version of - this License or a notice or disclaimer, the original version will - prevail. - - If a section in the Document is Entitled "Acknowledgements", - "Dedications", or "History", the requirement (section 4) to - Preserve its Title (section 1) will typically require changing the - actual title. - - 9. TERMINATION - - You may not copy, modify, sublicense, or distribute the Document - except as expressly provided for under this License. Any other - attempt to copy, modify, sublicense or distribute the Document is - void, and will automatically terminate your rights under this - License. However, parties who have received copies, or rights, - from you under this License will not have their licenses - terminated so long as such parties remain in full compliance. - - 10. FUTURE REVISIONS OF THIS LICENSE - - The Free Software Foundation may publish new, revised versions of - the GNU Free Documentation License from time to time. Such new - versions will be similar in spirit to the present version, but may - differ in detail to address new problems or concerns. See - `http://www.gnu.org/copyleft/'. - - Each version of the License is given a distinguishing version - number. If the Document specifies that a particular numbered - version of this License "or any later version" applies to it, you - have the option of following the terms and conditions either of - that specified version or of any later version that has been - published (not as a draft) by the Free Software Foundation. If - the Document does not specify a version number of this License, - you may choose any version ever published (not as a draft) by the - Free Software Foundation. - -A.1.1 ADDENDUM: How to use this License for your documents ----------------------------------------------------------- - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and license -notices just after the title page: - - Copyright (C) YEAR YOUR NAME. - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.2 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover - Texts. A copy of the license is included in the section entitled ``GNU - Free Documentation License''. - - If you have Invariant Sections, Front-Cover Texts and Back-Cover -Texts, replace the "with...Texts." line with this: - - with the Invariant Sections being LIST THEIR TITLES, with - the Front-Cover Texts being LIST, and with the Back-Cover Texts - being LIST. - - If you have Invariant Sections without Cover Texts, or some other -combination of the three, merge those two alternatives to suit the -situation. - - If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, to -permit their use in free software. - - -File: bwmtools.info, Node: Index, Prev: Copying This Manual, Up: Top - -Index -***** - - -* Menu: - -* FDL, GNU Free Documentation License: GNU Free Documentation License. - (line 6) -* introduction: Introduction. (line 6) - - - -Tag Table: -Node: Top719 -Node: Introduction1111 -Node: Installation1642 -Node: Configuration2868 -Node: Global3282 -Node: ACL6078 -Node: NAT9550 -Node: Traffic11910 -Node: Graphing12038 -Node: Examples12150 -Node: Advanced12257 -Node: Copying This Manual12375 -Node: GNU Free Documentation License12609 -Node: Index35020 - -End Tag Table |
From: SVN C. <sv...@li...> - 2005-01-10 12:03:20
|
Author: nkukard Date: 2005-01-10 14:02:47 +0200 (Mon, 10 Jan 2005) New Revision: 35 Modified: trunk/Makefile.am trunk/Makefile.in trunk/bwm_firewall/bwm_firewall.c trunk/bwm_graph/bwm_graph.c trunk/bwm_graph/graph.c trunk/bwmd/bwmd.c trunk/configure trunk/configure.ac Log: * Fixed unused option in bwm_graph * Fixed small typo in bwm_firewall * Added doc directory to that being built Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2005-01-10 12:00:08 UTC (rev 34) +++ trunk/Makefile.am 2005-01-10 12:02:47 UTC (rev 35) @@ -17,9 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -SUBDIRS=lib bwm_firewall bwm_graph bwmd bwm_monitor +SUBDIRS=lib bwm_firewall bwm_graph bwmd bwm_monitor doc EXTRA_DIST=include/autoclass.h include/common.h include/flow.h include/flowControl.h include/ipq.h EXTRA_DIST+=include/libipq.h include/misc.h include/report.h include/xmlConf.h -EXTRA_DIST+=doc/Configuration doc/Install doc/example.xml - Modified: trunk/Makefile.in =================================================================== --- trunk/Makefile.in 2005-01-10 12:00:08 UTC (rev 34) +++ trunk/Makefile.in 2005-01-10 12:02:47 UTC (rev 35) @@ -198,11 +198,10 @@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ -SUBDIRS = lib bwm_firewall bwm_graph bwmd bwm_monitor +SUBDIRS = lib bwm_firewall bwm_graph bwmd bwm_monitor doc EXTRA_DIST = include/autoclass.h include/common.h include/flow.h \ include/flowControl.h include/ipq.h include/libipq.h \ - include/misc.h include/report.h include/xmlConf.h \ - doc/Configuration doc/Install doc/example.xml + include/misc.h include/report.h include/xmlConf.h all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -391,7 +390,7 @@ distdir: $(DISTFILES) $(am__remove_distdir) mkdir $(distdir) - $(mkdir_p) $(distdir)/doc $(distdir)/include + $(mkdir_p) $(distdir)/include @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ Modified: trunk/bwm_firewall/bwm_firewall.c =================================================================== --- trunk/bwm_firewall/bwm_firewall.c 2005-01-10 12:00:08 UTC (rev 34) +++ trunk/bwm_firewall/bwm_firewall.c 2005-01-10 12:02:47 UTC (rev 35) @@ -130,7 +130,7 @@ // COMPAT: Do not genrate nodes for formatting spaces - LIBXML_TEST_VERSION + LIBXML_TEST_VERSION xmlKeepBlanksDefault(0); // FIXME - check if file exists Modified: trunk/bwm_graph/bwm_graph.c =================================================================== --- trunk/bwm_graph/bwm_graph.c 2005-01-10 12:00:08 UTC (rev 34) +++ trunk/bwm_graph/bwm_graph.c 2005-01-10 12:02:47 UTC (rev 35) @@ -54,7 +54,7 @@ printf(" --graph-date Add date information under graph\n"); printf(" --graph-title=<graph_title> Title of graph\n"); printf(" --graph-total Add totals per flow at bottom of graph\n"); - printf(" --graph-maxRate Specify your own maxRate value\n"); +// printf(" --graph-maxRate Specify your own maxRate value\n"); printf(" --graph-vert-title=<graph_title>\n"); printf(" Vertical title of graph\n"); printf("\n"); @@ -73,12 +73,12 @@ {"start",1,0,'s'}, {"end",1,0,'e'}, {"help",0,0,'h'}, - {"graph-filename",0,0,1}, + {"graph-filename",1,0,1}, {"graph-avg",0,0,2}, {"graph-date",0,0,3}, {"graph-title",1,0,4}, {"graph-total",0,0,5}, - {"graph-maxRate",0,0,6}, +// {"graph-maxRate",1,0,6}, {"graph-vert-title",1,0,7}, {0,0,0,0} }; @@ -163,9 +163,11 @@ case 5: options->graph_total = 1; break; +/* case 6: options->graph_maxRate = 1; break; +*/ case 7: options->verticalTitle = strndup(optarg,BUFFER_SIZE); break; Modified: trunk/bwm_graph/graph.c =================================================================== --- trunk/bwm_graph/graph.c 2005-01-10 12:00:08 UTC (rev 34) +++ trunk/bwm_graph/graph.c 2005-01-10 12:02:47 UTC (rev 35) @@ -622,7 +622,7 @@ // Check if we must display our cute little line if (hasOptions) ADD_SINGLE_PARAM(params,numParams,"COMMENT:%s\\c","- * - * -"); - ADD_SINGLE_PARAM(params,numParams,"COMMENT:%s\\c","Graph generated by bwm_tools v"PACKAGE_VERSION" (http://bwmtools.lbsd.net)"); + ADD_SINGLE_PARAM(params,numParams,"COMMENT:%s\\c","Graph generated by bwm_tools v"PACKAGE_VERSION" (http://bwm-tools.lbsd.net)"); // Call rrd tool optind = 0; opterr = 0; Modified: trunk/bwmd/bwmd.c =================================================================== --- trunk/bwmd/bwmd.c 2005-01-10 12:00:08 UTC (rev 34) +++ trunk/bwmd/bwmd.c 2005-01-10 12:02:47 UTC (rev 35) @@ -1,6 +1,6 @@ /* * bwmd.c - BWM Daemon - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 @@ -105,7 +105,7 @@ }; - printf("BWM Daemon v%s - Copyright (c) 2003-2004 Linux Based Systems Design\n\n",PACKAGE_VERSION); + printf("BWM Daemon v%s - Copyright (c) 2003-2005 Linux Based Systems Design\n\n",PACKAGE_VERSION); // Loop with options while (1) Modified: trunk/configure =================================================================== --- trunk/configure 2005-01-10 12:00:08 UTC (rev 34) +++ trunk/configure 2005-01-10 12:02:47 UTC (rev 35) @@ -23430,7 +23430,7 @@ XML_CFLAGS=$XML_CPPFLAGS - ac_config_files="$ac_config_files Makefile lib/Makefile bwm_firewall/Makefile bwm_graph/Makefile bwmd/Makefile bwm_monitor/Makefile" + ac_config_files="$ac_config_files Makefile lib/Makefile bwm_firewall/Makefile bwm_graph/Makefile bwmd/Makefile bwm_monitor/Makefile doc/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -23994,6 +23994,7 @@ "bwm_graph/Makefile" ) CONFIG_FILES="$CONFIG_FILES bwm_graph/Makefile" ;; "bwmd/Makefile" ) CONFIG_FILES="$CONFIG_FILES bwmd/Makefile" ;; "bwm_monitor/Makefile" ) CONFIG_FILES="$CONFIG_FILES bwm_monitor/Makefile" ;; + "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2005-01-10 12:00:08 UTC (rev 34) +++ trunk/configure.ac 2005-01-10 12:02:47 UTC (rev 35) @@ -100,5 +100,6 @@ bwm_graph/Makefile bwmd/Makefile bwm_monitor/Makefile + doc/Makefile ]) AC_OUTPUT |
From: SVN C. <sv...@li...> - 2005-01-10 12:01:12
|
Author: nkukard Date: 2005-01-10 14:00:08 +0200 (Mon, 10 Jan 2005) New Revision: 34 Added: trunk/doc/Makefile.am trunk/doc/Makefile.in trunk/doc/bwmtools.info trunk/doc/bwmtools.texi trunk/doc/fdl.texi trunk/doc/mdate-sh trunk/doc/stamp-vti trunk/doc/texinfo.tex trunk/doc/version.texi Modified: trunk/doc/example.xml Log: * Fixed bug in example.xml * Added bwmtools texinfo manual Added: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2005-01-09 16:23:48 UTC (rev 33) +++ trunk/doc/Makefile.am 2005-01-10 12:00:08 UTC (rev 34) @@ -0,0 +1,24 @@ +# +# makefile.am - Makefile for documentation +# Copyright (C) 2003-2005, 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 + + + +EXTRA_DIST = Configuration Install example.xml + +info_TEXINFOS = bwmtools.texi + Added: trunk/doc/Makefile.in =================================================================== --- trunk/doc/Makefile.in 2005-01-09 16:23:48 UTC (rev 33) +++ trunk/doc/Makefile.in 2005-01-10 12:00:08 UTC (rev 34) @@ -0,0 +1,517 @@ +# Makefile.in generated by automake 1.9.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# +# makefile.am - Makefile for documentation +# Copyright (C) 2003-2005, 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 +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = doc +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/stamp-vti $(srcdir)/version.texi mdate-sh \ + texinfo.tex +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +INFO_DEPS = $(srcdir)/bwmtools.info +am__TEXINFO_TEX_DIR = $(srcdir) +DVIS = bwmtools.dvi +PDFS = bwmtools.pdf +PSS = bwmtools.ps +HTMLS = bwmtools.html +TEXINFOS = bwmtools.texi +TEXI2DVI = texi2dvi +TEXI2PDF = $(TEXI2DVI) --pdf --batch +MAKEINFOHTML = $(MAKEINFO) --html +AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS) +DVIPS = dvips +am__installdirs = "$(DESTDIR)$(infodir)" +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GOBJECT_QUERY = @GOBJECT_QUERY@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RRDTOOL_LIBS = @RRDTOOL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XML2_CONFIG = @XML2_CONFIG@ +XML_CFLAGS = @XML_CFLAGS@ +XML_CPPFLAGS = @XML_CPPFLAGS@ +XML_LIBS = @XML_LIBS@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +EXTRA_DIST = Configuration Install example.xml +info_TEXINFOS = bwmtools.texi +all: all-am + +.SUFFIXES: +.SUFFIXES: .dvi .html .info .pdf .ps .texi +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu doc/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool + +.texi.info: + restore=: && backupdir="$(am__leading_dot)am$$$$" && \ + am__cwd=`pwd` && cd $(srcdir) && \ + rm -rf $$backupdir && mkdir $$backupdir && \ + for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \ + if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \ + done; \ + cd "$$am__cwd"; \ + if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ + -o $@ $<; \ + then \ + rc=0; \ + cd $(srcdir); \ + else \ + rc=$$?; \ + cd $(srcdir) && \ + $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \ + fi; \ + rm -rf $$backupdir; exit $$rc + +.texi.dvi: + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ + $(TEXI2DVI) $< + +.texi.pdf: + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ + $(TEXI2PDF) $< + +.texi.html: + rm -rf $(@:.html=.htp) + if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ + -o $(@:.html=.htp) $<; \ + then \ + rm -rf $@; \ + if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ + mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \ + else \ + if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ + rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \ + exit 1; \ + fi +$(srcdir)/bwmtools.info: bwmtools.texi $(srcdir)/version.texi +bwmtools.dvi: bwmtools.texi $(srcdir)/version.texi +bwmtools.pdf: bwmtools.texi $(srcdir)/version.texi +bwmtools.html: bwmtools.texi $(srcdir)/version.texi +$(srcdir)/version.texi: $(srcdir)/stamp-vti +$(srcdir)/stamp-vti: bwmtools.texi $(top_srcdir)/configure + @(dir=.; test -f ./bwmtools.texi || dir=$(srcdir); \ + set `$(SHELL) $(srcdir)/mdate-sh $$dir/bwmtools.texi`; \ + echo "@set UPDATED $$1 $$2 $$3"; \ + echo "@set UPDATED-MONTH $$2 $$3"; \ + echo "@set EDITION $(VERSION)"; \ + echo "@set VERSION $(VERSION)") > vti.tmp + @cmp -s vti.tmp $(srcdir)/version.texi \ + || (echo "Updating $(srcdir)/version.texi"; \ + cp vti.tmp $(srcdir)/version.texi) + -@rm -f vti.tmp + @cp $(srcdir)/version.texi $@ + +mostlyclean-vti: + -rm -f vti.tmp + +maintainer-clean-vti: + -rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi +.dvi.ps: + $(DVIPS) -o $@ $< + +uninstall-info-am: + $(PRE_UNINSTALL) + @if (install-info --version && \ + install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ + list='$(INFO_DEPS)'; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \ + install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \ + done; \ + else :; fi + @$(NORMAL_UNINSTALL) + @list='$(INFO_DEPS)'; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \ + (if cd "$(DESTDIR)$(infodir)"; then \ + echo " rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9])"; \ + rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \ + else :; fi); \ + done + +dist-info: $(INFO_DEPS) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + list='$(INFO_DEPS)'; \ + for base in $$list; do \ + case $$base in \ + $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \ + esac; \ + if test -f $$base; then d=.; else d=$(srcdir); fi; \ + for file in $$d/$$base*; do \ + relfile=`expr "$$file" : "$$d/\(.*\)"`; \ + test -f $(distdir)/$$relfile || \ + cp -p $$file $(distdir)/$$relfile; \ + done; \ + done + +mostlyclean-aminfo: + -rm -rf bwmtools.aux bwmtools.cp bwmtools.cps bwmtools.fn bwmtools.fns \ + bwmtools.ky bwmtools.kys bwmtools.log bwmtools.pg \ + bwmtools.tmp bwmtools.toc bwmtools.tp bwmtools.tps \ + bwmtools.vr bwmtools.vrs bwmtools.dvi bwmtools.pdf \ + bwmtools.ps bwmtools.html + +maintainer-clean-aminfo: + @list='$(INFO_DEPS)'; for i in $$list; do \ + i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \ + echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \ + rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-info +check-am: all-am +check: check-am +all-am: Makefile $(INFO_DEPS) +installdirs: + for dir in "$(DESTDIR)$(infodir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-libtool + +dvi: dvi-am + +dvi-am: $(DVIS) + +html: html-am + +html-am: $(HTMLS) + +info: info-am + +info-am: $(INFO_DEPS) + +install-data-am: install-info-am + +install-exec-am: + +install-info: install-info-am + +install-info-am: $(INFO_DEPS) + @$(NORMAL_INSTALL) + test -z "$(infodir)" || $(mkdir_p) "$(DESTDIR)$(infodir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + list='$(INFO_DEPS)'; \ + for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + esac; \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \ + for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \ + $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \ + if test -f $$ifile; then \ + relfile=`echo "$$ifile" | sed 's|^.*/||'`; \ + echo " $(INSTALL_DATA) '$$ifile' '$(DESTDIR)$(infodir)/$$relfile'"; \ + $(INSTALL_DATA) "$$ifile" "$(DESTDIR)$(infodir)/$$relfile"; \ + else : ; fi; \ + done; \ + done + @$(POST_INSTALL) + @if (install-info --version && \ + install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ + list='$(INFO_DEPS)'; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\ + install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\ + done; \ + else : ; fi +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-aminfo \ + maintainer-clean-generic maintainer-clean-vti + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-aminfo mostlyclean-generic \ + mostlyclean-libtool mostlyclean-vti + +pdf: pdf-am + +pdf-am: $(PDFS) + +ps: ps-am + +ps-am: $(PSS) + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + dist-info distclean distclean-generic distclean-libtool \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-aminfo \ + maintainer-clean-generic maintainer-clean-vti mostlyclean \ + mostlyclean-aminfo mostlyclean-generic mostlyclean-libtool \ + mostlyclean-vti pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: Added: trunk/doc/bwmtools.info =================================================================== --- trunk/doc/bwmtools.info 2005-01-09 16:23:48 UTC (rev 33) +++ trunk/doc/bwmtools.info 2005-01-10 12:00:08 UTC (rev 34) @@ -0,0 +1,852 @@ +This is bwmtools.info, produced by makeinfo version 4.7 from +bwmtools.texi. + + This manual is for BWM Tools (version devel, 7 January 2005) + + Copyright (C) 2005 Linux Based Systems Design. + + Permission is granted to copy, distribute and/or modify this + document under the terms of the GNU Free Documentation License, + Version 1.2 or any later version published by the Free Software + Foundation; with no Invariant Sections, no Front-Cover Texts, and + no Back-Cover Texts. A copy of the license is included in the + section entitled "GNU Free Documentation License". + +INFO-DIR-SECTION Network applications +START-INFO-DIR-ENTRY +* BWM Tools: Managing bandwidth with BWM Tools +END-INFO-DIR-ENTRY + + +File: bwmtools.info, Node: Top, Next: Introduction, Up: (dir) + +Bandwidth Management Tools +************************** + +* Menu: + +* Introduction::The purpose of BWM Tools +* Installation::Building and installing the package +* Configuration::Configuring BWM Tools +* Graphing::Generating graphs +* Examples::Configuration examples +* Advanced::Advanced issues +* Copying This Manual:: +* Index:: + + +File: bwmtools.info, Node: Introduction, Next: Installation, Prev: Top, Up: Top + +1 Introduction +************** + +Bandwidth Management Tools was designed to provide a full suite of +bandwidth management applications, able to shape, log and graph traffic. + + Seeing as BWM Tools uses iptables for matching traffic, the +complexity of traffic control is limitless. + + BWM Tools is a set of userspace utilities, no kernel patches are +required. As long as your iptables supports the `-j QUEUE' target, +traffic shaping will work. + + +File: bwmtools.info, Node: Installation, Next: Configuration, Prev: Introduction, Up: Top + +2 Installation +************** + +Before you can use BWM Tools, you must make sure you have all the +dependencies installed... + + * glib2 >= 2.4.0 + + * libxml2 >= 2.6.0 + + * rrdtool >= 1.0.49 (only required for graphing) + + Next you need to download BWM Tools, compile it and install it. + + Here is step-by-step instructions on how to do this... + + 1. Download the latest version of BWM Tools, the latest version can be + found on the project homepage: `http://bwm-tools.lbsd.net' + + 2. Uncompress the archive using either `tar jxvf <archive + name>.tar.bz2' or `tar zxvf <archive name>.tar.gz' depending + weather its a .tar.bz2 or .tar.gz respectively. + + 3. Run `./configure' in the source directory. Optionally a + `--prefix=...' parameter can be passed which will determine where + BWM Tools will be installed. + + 4. Once the configure process is complete, issue a `make' command, + this will compile BWM Tools. + + 5. When BWM Tools has finished compiling, type `make install'. This + will by default install BWM Tools into /usr/local, unless of course + if you specified a `--prefix=...' above. + + +File: bwmtools.info, Node: Configuration, Next: Graphing, Prev: Installation, Up: Top + +3 Configuration +*************** + +Configuration of BWM Tools is done via an XML configuration file, this +file is normally located in /etc/bwm_tools/firewall.xml + + The layout of the file is pretty simple and is split up into various +sections, these are detailed below... + +* Menu: + +* Global:: +* ACL:: +* NAT:: +* Traffic:: + + +File: bwmtools.info, Node: Global, Next: ACL, Up: Configuration + +3.1 The `<global>' section +========================== + +This section contains global directives pertaining to either the +operation of BWM Tools or definitions used in other sections. These +directives are detailed below... + + * Module management in the `<modules>' section + This section is used to load modules when bwmd starts. The syntax + to load a module is as follows... + <load name="kernel_module_name" /> + + The `<load />' tag takes the following parameters... + * `name="..."' - This is the name of the module to load + + * `params="..."' - Parameters to load module with + + Here is how it can be used to load the ip_queue kernel module + required by bwmd for shaping. Including ftp connection tracking to + allow users to ftp through a tightly secured firewall. + <firewall> + <global> + <modules> + <load name="ip_queue"/> + <load name="ip_nat_ftp"/> + <load name="ip_conntrack_ftp"/> + </modules> + </global> + . + . + . + </firewall> + + * Class definition in the `<class>' section + This section is used to define classes used in both firewalling + and network address translation. The basic syntax is as follows... + <class name="traffic_from_support"> + <address name="pete_in" src="192.168.0.100" /> + </class> + + The `<class>' tag has got no other options apart from name. + + The `<address />' tag on the other hand has the following + options... + + * `name="..."' - This is a descriptive name for the address, + isn't really used anywhere + + * `cmd-line="..."' - Optional command line arguments for + iptables, for example `cmd-line="-m helper --helper <string>"' + + * `dst="..."' - Optional destination IP address + + * `dst-iface="..."' - Optional destination interface + + * `dst-port="..."' - Optional destination port + + * `proto="..."' - Optional protocol specification, any valid + protocol in `/etc/protocols' + + * `src="..."' - Optional source IP address + + * `src-iface="..."' - Optional source interface + + * `src-port="..."' - Optional source port + + Here is an example how it can be used to match connections over a + specific number... + <firewall> + <global> + . + . + . + <class name="excess_connections_to_webserver"> + <address name="excess_to_server1" dst="192.168.0.100" proto="tcp" dst-port="80" cmd-line="-m connlimit --connlimit-above 10"/> + </class> + </global> + . + . + . + </firewall> + + +File: bwmtools.info, Node: ACL, Next: NAT, Prev: Global, Up: Configuration + +3.2 The `<acl>' section +======================= + +This is basically the firewall section, you can add all your firewall +rules here or just leave it blank to use your current firewall. + + The syntax for this section is a little more complex and is as +follows... + <acl> + <table name="filter"> + <chain name="INPUT" defualt="ACCEPT"> + <rule name="excess_connections" target="DROP"> + excess_connections_to_webserver + </rule> + </chain> + </table> + </acl> + + Explaining the above example, this will add 1 rule to the `INPUT' +chain under the `filter' table which will drop all new packets that +arrive if the concurrent connections on port 80 is higher than 10. + + It is the equivalent to... +`iptables -t filter -A INPUT -d 192.168.0.10 -p tcp -dport 80 -m +connlimit --connlimit-above 10 -j DROP' + + The following tags and parameters are available... + * Specify the table with `<table> ... </table>' + The `<table>' tag is used to enclose the directives you plan to + use with a specific table. Examples of tables are... `filter', + `nat', `mangle' + + The `<table>' tag takes the following parameters... + * `name="..."' - This is the name of the table we will be + working with + + * Specify a chain with `<chain> ... </chain>' + The `<chain>' tag is used to specify what chain the rules defined + between the starting and ending tags apply to. Examples of already + defined chains are `INPUT', `OUTPUT' and `FORWARD'. + + The `<chain>' tag takes the following parameters... + * `name="..."' - This is the name of the chain we will be + working with + + * `default="..."' - This specifies the default target for the + chain + + * Specify a rule with `<rule> ... </rule>' + The `<rule>' tag is used to specify what classes apply to what + rule, and are in order inserted into the actual iptables chains as + iptables rules. + + The `<rule>' tag takes the following parameters... + * `name="..."' - Optional name of rule + + * `cmd-line="..."' - Optional extra command line parameters to + pass to iptables + + * `target="..."' - This is the target for the rule, used as the + `-j <target>' parameter when generating iptables rules. + + Between the opening and closing tags, classes defined in the + `<global>' section are listed, these classify which traffic + applies to which rule. + + Multiple classes can be listed, one per line. + +Using the above, here is an example of a simple firewall which allows +http and ssh traffic, assuming your IP address is 10.0.0.2 of course... + <firewall> + # Global configuration and access classes + <global> + <class name="http_traffic"> + <address dst="10.0.0.2" proto="tcp" dst-port="80"/> + </class> + <class name="ssh_traffic"> + <address dst="10.0.0.2" proto="tcp" dst-port="22"/> + </class> + </global> + + # Access control lists + <acl> + <table name="filter"> + <chain name="INPUT" default="DROP"> + <rule name="allowed_traffic" target="ACCEPT"> + http_traffic + ssh_traffic + </rule> + </chain> + <chain name="FORWARD" default="DROP"> + </chain> + <chain name="OUTPUT" default="ACCEPT"> + </chain> + </table> + </acl> + + </firewall> + + +File: bwmtools.info, Node: NAT, Next: Traffic, Prev: ACL, Up: Configuration + +3.3 The `<nat>' section +======================= + +The NAT section is used to define network address translation rules, +these rules allow one to translate the source or destination IP address +within packets. A common use for this is when a webserver is behind a +firewall, requests are made to a globally routable IP address and +translated to the internal IP address of the webserver and visa versa. + + This section has the following syntax... + <nat> + <snat> + <rule name="traf_from_webserver" to-src="<globally routable IP here>"> + traffic_from_webserver + </rule> + </snat> + <dnat> + <rule name="traf_to_webserver" to-dst="192.168.1.100"> + traffic_to_webserver + </rule> + </dnat> + </nat> + + There are 2 tags available, `<snat>' and `<dnat>', these two tags +are used for soure network address translation and destination address +translation respectively. + + Valid options for these 2 directives are as follows... + * Source network address translation using `<snat>' + SNAT is used for source network address translation, an example of + which is again a webserver behind a firewall. Where SNAT comes in + handy is when the webserver makes a query through the firewall, + instead of the traffic on the internet comming from the webservers + internal IP 192.168.1.100 which is not going to work, the firewall + translates 192.168.1.100 to a globally routable IP address. + + There are no parameters for this directive, although the following + tags and parameters are available... + * Specify a rule with `<rule> ... </rule>' + The `<rule>' tag is used to specify what classes apply to + what rule, and are in order inserted into the actual iptables + chains as iptables rules. + + The `<rule>' tag takes the following parameters... + * `name="..."' - Optional name of rule + + * `to-src"..."' - Translate all traffic matched in the + class specification to this IP address. + + Between the opening and closing tags, classes defined in the + `<global>' section are listed, these classify which traffic + applies to which rule. + + Multiple classes can be listed, one per line. + + + +File: bwmtools.info, Node: Traffic, Prev: NAT, Up: Configuration + +3.4 The `<traffic>' section +=========================== + + +File: bwmtools.info, Node: Graphing, Next: Examples, Prev: Configuration, Up: Top + +4 Graphing +********** + + +File: bwmtools.info, Node: Examples, Next: Advanced, Prev: Graphing, Up: Top + +5 Examples +********** + + +File: bwmtools.info, Node: Advanced, Next: Copying This Manual, Prev: Examples, Up: Top + +6 Advanced +********** + + +File: bwmtools.info, Node: Copying This Manual, Next: Index, Prev: Advanced, Up: Top + +Appendix A Copying This Manual +****************************** + +* Menu: + +* GNU Free Documentation License:: License for copying this manual. + + +File: bwmtools.info, Node: GNU Free Documentation License, Up: Copying This Manual + +A.1 GNU Free Documentation License +================================== + + Version 1.2, November 2002 + + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + 0. PREAMBLE + + The purpose of this License is to make a manual, textbook, or other + functional and useful document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by others. + + This License is a kind of "copyleft", which means that derivative + works of the document must themselves be free in the same sense. + It complements the GNU General Public License, which is a copyleft + license designed for free software. + + We have designed this License in order to use it for manuals for + free software, because free software needs free documentation: a + free program should come with manuals providing the same freedoms + that the software does. But this License is not limited to + software manuals; it can be used for any textual work, regardless + of subject matter or whether it is published as a printed book. + We recommend this License principally for works whose purpose is + instruction or reference. + + 1. APPLICABILITY AND DEFINITIONS + + This License applies to any manual or other work, in any medium, + that contains a notice placed by the copyright holder saying it + can be distributed under the terms of this License. Such a notice + grants a world-wide, royalty-free license, unlimited in duration, + to use that work under the conditions stated herein. The + "Document", below, refers to any such manual or work. Any member + of the public is a licensee, and is addressed as "you". You + accept the license if you copy, modify or distribute the work in a + way requiring permission under copyright law. + + A "Modified Version" of the Document means any work containing the + Document or a portion of it, either copied verbatim, or with + modifications and/or translated into another language. + + A "Secondary Section" is a named appendix or a front-matter section + of the Document that deals exclusively with the relationship of the + publishers or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that could + fall directly within that overall subject. (Thus, if the Document + is in part a textbook of mathematics, a Secondary Section may not + explain any mathematics.) The relationship could be a matter of + historical connection with the subject or with related matters, or + of legal, commercial, philosophical, ethical or political position + regarding them. + + The "Invariant Sections" are certain Secondary Sections whose + titles are designated, as being those of Invariant Sections, in + the notice that says that the Document is released under this + License. If a section does not fit the above definition of + Secondary then it is not allowed to be designated as Invariant. + The Document may contain zero Invariant Sections. If the Document + does not identify any Invariant Sections then there are none. + + The "Cover Texts" are certain short passages of text that are + listed, as Front-Cover Texts or Back-Cover Texts, in the notice + that says that the Document is released under this License. A + Front-Cover Text may be at most 5 words, and a Back-Cover Text may + be at most 25 words. + + A "Transparent" copy of the Document means a machine-readable copy, + represented in a format whose specification is available to the + general public, that is suitable for revising the document + straightforwardly with generic text editors or (for images + composed of pixels) generic paint programs or (for drawings) some + widely available drawing editor, and that is suitable for input to + text formatters or for automatic translation to a variety of + formats suitable for input to text formatters. A copy made in an + otherwise Transparent file format whose markup, or absence of + markup, has been arranged to thwart or discourage subsequent + modification by readers is not Transparent. An image format is + not Transparent if used for any substantial amount of text. A + copy that is not "Transparent" is called "Opaque". + + Examples of suitable formats for Transparent copies include plain + ASCII without markup, Texinfo input format, LaTeX input format, + SGML or XML using a publicly available DTD, and + standard-conforming simple HTML, PostScript or PDF designed for + human modification. Examples of transparent image formats include + PNG, XCF and JPG. Opaque formats include proprietary formats that + can be read and edited only by proprietary word processors, SGML or + XML for which the DTD and/or processing tools are not generally + available, and the machine-generated HTML, PostScript or PDF + produced by some word processors for output purposes only. + + The "Title Page" means, for a printed book, the title page itself, + plus such following pages as are needed to hold, legibly, the + material this License requires to appear in the title page. For + works in formats which do not have any title page as such, "Title + Page" means the text near the most prominent appearance of the + work's title, preceding the beginning of the body of the text. + + A section "Entitled XYZ" means a named subunit of the Document + whose title either is precisely XYZ or contains XYZ in parentheses + following text that translates XYZ in another language. (Here XYZ + stands for a specific section name mentioned below, such as + "Acknowledgements", "Dedications", "Endorsements", or "History".) + To "Preserve the Title" of such a section when you modify the + Document means that it remains a section "Entitled XYZ" according + to this definition. + + The Document may include Warranty Disclaimers next to the notice + which states that this License applies to the Document. These + Warranty Disclaimers are considered to be included by reference in + this License, but only as regards disclaiming warranties: any other + implication that these Warranty Disclaimers may have is void and + has no effect on the meaning of this License. + + 2. VERBATIM COPYING + + You may copy and distribute the Document in any medium, either + commercially or noncommercially, provided that this License, the + copyright notices, and the license notice saying this License + applies to the Document are reproduced in all copies, and that you + add no other conditions whatsoever to those of this License. You + may not use technical measures to obstruct or control the reading + or further copying of the copies you make or distribute. However, + you may accept compensation in exchange for copies. If you + distribute a large enough number of copies you must also follow + the conditions in section 3. + + You may also lend copies, under the same conditions stated above, + and you may publicly display copies. + + 3. COPYING IN QUANTITY + + If you publish printed copies (or copies in media that commonly + have printed covers) of the Document, numbering more than 100, and + the Document's license notice requires Cover Texts, you must + enclose the copies in covers that carry, clearly and legibly, all + these Cover Texts: Front-Cover Texts on the front cover, and + Back-Cover Texts on the back cover. Both covers must also clearly + and legibly identify you as the publisher of these copies. The + front cover must present the full title with all words of the + title equally prominent and visible. You may add other material + on the covers in addition. Copying with changes limited to the + covers, as long as they preserve the title of the Document and + satisfy these conditions, can be treated as verbatim copying in + other respects. + + If the required texts for either cover are too voluminous to fit + legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, or + state in or with each Opaque copy a computer-network location from + which the general network-using public has access to download + using public-standard network protocols a complete Transparent + copy of the Document, free of added material. If you use the + latter option, you must take reasonably prudent steps, when you + begin distribution of Opaque copies in quantity, to ensure that + this Transparent copy will remain thus accessible at the stated + location until at least one year after the last time you + distribute an Opaque copy (directly or through your agents or + retailers) of that edition to the public. + + It is requested, but not required, that you contact the authors of + the Document well before redistributing any large number of + copies, to give them a chance to provide you with an updated + version of the Document. + + 4. MODIFICATIONS + + You may copy and distribute a Modified Version of the Document + under the conditions of sections 2 and 3 above, provided that you + release the Modified Version under precisely this License, with + the Modified Version filling the role of the Document, thus + licensing distribution and modification of the Modified Version to + whoever possesses a copy of it. In addition, you must do these + things in the Modified Version: + + A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of + previous versions (which should, if there were any, be listed + in the History section of the Document). You may use the + same title as a previous version if the original publisher of + that version gives permission. + + B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in + the Modified Version, together with at least five of the + principal authors of the Document (all of its principal + authors, if it has fewer than five), unless they release you + from this requirement. + + C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + + D. Preserve all the copyright notices of the Document. + + E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + + F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified + Version under the terms of this License, in the form shown in + the Addendum below. + + G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. + + H. Include an unaltered copy of this License. + + I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on + the Title Page. If there is no section Entitled "History" in + the Document, create one stating the title, year, authors, + and publisher of the Document as given on its Title Page, + then add an item describing the Modified Version as stated in + the previous sentence. + + J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for + previous versions it was based on. These may be placed in + the "History" section. You may omit a network location for a + work that was published at least four years before the + Document itself, or if the original publisher of the version + it refers to gives permission. + + K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the + section all the substance and tone of each of the contributor + acknowledgements and/or dedications given therein. + + L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section + titles. + + M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + + N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant + Section. + + O. Preserve any Warranty Disclaimers. + + If the Modified Version includes new front-matter sections or + appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do this, + add their titles to the list of Invariant Sections in the Modified + Version's license notice. These titles must be distinct from any + other section titles. + + You may add a section Entitled "Endorsements", provided it contains + nothing but endorsements of your Modified Version by various + parties--for example, statements of peer review or that the text + has been approved by an organization as the authoritative + definition of a standard. + + You may add a passage of up to five words as a Front-Cover Text, + and a passage of up to 25 words as a Back-Cover Text, to the end + of the list of Cover Texts in the Modified Version. Only one + passage of Front-Cover Text and one of Back-Cover Text may be + added by (or through arrangements made by) any one entity. If the + Document already includes a cover text for the same cover, + previously added by you or by arrangement made by the same entity + you are acting on behalf of, you may not add another; but you may + replace the old one, on explicit permission from the previous + publisher that added the old one. + + The author(s) and publisher(s) of the Document do not by this + License give permission to use their names for publicity for or to + assert or imply endorsement of any Modified Version. + + 5. COMBINING DOCUMENTS + + You may combine the Document with other documents released under + this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination + all of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + + The combined work need only contain one copy of this License, and + multiple identical Invariant Sections may be replaced with a single + copy. If there are multiple Invariant Sections with the same name + but different contents, make the title of each such section unique + by adding at the end of it, in parentheses, the name of the + original author or publisher of that section if known, or else a + unique number. Make the same adjustment to the section titles in + the list of Invariant Sections in the license notice of the + combined work. + + In the combination, you must combine any sections Entitled + "History" in the various original documents, forming one section + Entitled "History"; likewise combine any sections Entitled + "Acknowledgements", and any sections Entitled "Dedications". You + must delete all sections Entitled "Endorsements." + + 6. COLLECTIONS OF DOCUMENTS + + You may make a collection consisting of the Document and other + documents released under this License, and replace the individual + copies of this License in the various documents with a single copy + that is included in the collection, provided that you follow the + rules of this License for verbatim copying of each of the + documents in all other respects. + + You may extract a single document from such a collection, and + distribute it individually under this License, provided you insert + a copy of this License into the extracted document, and follow + this License in all other respects regarding verbatim copying of + that document. + + 7. AGGREGATION WITH INDEPENDENT WORKS + + A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of + a storage or distribution medium, is called an "aggregate" if the + copyright resulting from the compilation is not used to limit the + legal rights of the compilation's users beyond what the individual + works permit. When the Document is included in an aggregate, this + License does not apply to the other works in the aggregate which + are not themselves derivative works of the Document. + + If the Cover Text requirement of section 3 is applicable to these + copies of the Document, then if the Document is less than one half + of the entire aggregate, the Document's Cover Texts may be placed + on covers that bracket the Document within the aggregate, or the + electronic equivalent of covers if the Document is in electronic + form. Otherwise they must appear on printed covers that bracket + the whole aggregate. + + 8. TRANSLATION + + Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires special + permission from their copyright holders, but you may include + translations of some or all Invariant Sections in addition to the + original versions of these Invariant Sections. You may include a + translation of this License, and all the license notices in the + Document, and any Warranty Disclaimers, provided that you also + include the original English version of this License and the + original versions of those notices and disclaimers. In case of a + disagreement between the translation and the original version of + this License or a notice or disclaimer, the original version will + prevail. + + If a section in the Document is Entitled "Acknowledgements", + "Dedications", or "History", the requirement (section 4) to + Preserve its Title (section 1) will typically require changing the + actual title. + + 9. TERMINATION + + You may not copy, modify, sublicense, or distribute the Document + except as expressly provided for under this License. Any other + attempt to copy, modify, sublicense or distribute the Document is + void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 10. FUTURE REVISIONS OF THIS LICENSE + + The Free Software Foundation may publish new, revised versions of + the GNU Free Documentation License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. See + `http://www.gnu.org/copyleft/'. + + Each version of the License is given a distinguishing version + number. If the Document specifies that a particular numbered + version of this License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that specified version or of any later version that has been + published (not as a draft) by the Free Software Foundation. If + the Document does not specify a version number of this License, + you may choose any version ever published (not as a draft) by the + Free Software Foundation. + +A.1.1 ADDENDUM: How to use this License for your documents +---------------------------------------------------------- + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and license +notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + + If you have Invariant Sections, Front-Cover Texts and Back-Cover +Texts, replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover Texts + being LIST. + + If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + + If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, to +permit their use in free software. + + +File: bwmtools.info, Node: Index, Prev: Copying This Manual, Up: Top + +Index +***** + + +* Menu: + +* FDL, GNU Free Documentation License: GNU Free Documentation License. + (line 6) +* introduction: Introduction. (line 6) + + + +Tag Table: +Node: Top719 +Node: Introduction1111 +Node: Installation1642 +Node: Configuration2868 +Node: Global3282 +Node: ACL6078 +Node: NAT9550 +Node: Traffic11910 +Node: Graphing12038 +Node: Examples12150 +Node: Advanced12257 +Node: Copying This Manual12375 +Node: GNU Free Documentation License12609 +Node: Index35020 + +End Tag Table Added: trunk/doc/bwmtools.texi =================================================================== --- trunk/doc/bwmtools.texi 2005-01-09 16:23:48 UTC (rev 33) +++ trunk/doc/bwmtools.texi 2005-01-10 12:00:08 UTC (rev 34) @@ -0,0 +1,1647 @@ +\input texinfo @c -*-texinfo-*- +@comment %**start of header +@setfilename bwmtools.info +@include version.texi +@settitle bwmtools +@setchapternewpage on +@setcontentsaftertitlepage +@firstparagraphindent none +@syncodeindex pg cp +@comment %**end of header + + +@copying +This manual is for BWM Tools +(version @value{VERSION}, @value{UPDATED}) + +Copyright @copyright{} 2005 Linux Based Systems Design. + +@quotation +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.2 +or any later version published by the Free Software Foundation; +with no Invariant Sections, no Front-Cover Texts, and no Back-Cover +Texts. A copy of the license is included in the section entitled ``GNU +Free Documentation License''. +@end quotation +@end copying + + +@dircategory Network applications +@direntry +* BWM Tools: Managing bandwidth with BWM Tools +@end direntry + + + +@titlepage +@title Bandwidth Management Tools +@subtitle for version @value{VERSION}, @value{UPDATED} +@author Written by: Nigel Kukard <@email{nkukard@@lbsd.net}> +@page +@vskip 0pt plus 1filll +@insertcopying +@end titlepage + +@ifnottex +@node Top +@top Bandwidth Management Tools +@end ifnottex + +@menu +* Introduction::The purpose of BWM Tools +* Installation::Building and installing the package +* Configuration::Configuring BWM Tools +* Integration::Integrating BWM Tools with your system +* Graphing::Generating graphs +* Examples::Configuration examples +* Copying This Manual:: +* Index:: +@end menu + + + + + + + + +@node Introduction +@chapter Introduction to BWM Tools +Bandwidth Management Tools was designed to provide a full suite of bandwidth +management applications, able to shape, log and graph traffic. +@*@* +Seeing as BWM Tools uses iptables for matching traffic, the complexity of +traffic control is limitless. +@*@* +BWM Tools is a set of userspace utilities, no kernel patches are required. +As long as your iptables supports the @option{-j QUEUE} target, traffic +shaping will work. + + + + + + + +@node Installation +@chapter Installing BWM Tools + +Before you can use BWM Tools, you must make sure you have all the +dependencies installed@dots{} +@* +@itemize +@item +glib2 >= 2.4.0 +@item +libxml2 >= 2.6.0 +@item +rrdtool >= 1.0.49 (only required for graphing) +@end itemize +@* +Next you need to download BWM Tools, compile it and install +it. +@*@* +Here is step-by-step instructions on how to do this@dots{} +@* +@enumerate +@item +Download the latest version of BWM Tools, the latest version can be +found on the project homepage: @url{http://bwm-tools.lbsd.net} +@* +@item +Uncompress the archive using either @code{tar jxvf <archive name>.tar.bz2} +or @code{tar zxvf <archive name>.tar.gz} depending weather its a .tar.bz2 +or .tar.gz respectively. +@* +@item +Run @command{./configure} in the source directory. Optionally a +@option{--prefix=@dots{}} parameter can be passed which will determine where +BWM Tools will be installed. +@* +@item +Once the configure process is complete, issue a @command{make} command, +this will compile BWM Tools. +@* +@item +When BWM Tools has finished compiling, type @code{make install}. This +will by default install BWM Tools into /usr/local, unless of course +if you specified a @option{--prefix=@dots{}} above. +@end enumerate + + + + + + + + + + +@node Configuration +@chapter Configuring BWM Tools + +Configuration of BWM Tools is done via an XML configuration file, this file +is normally located in /etc/bwm_tools/firewall.xml +@*@* +The layout of the file is pretty simple and is split up into various sections, +these are detailed in the following sections@dots{} + + +@menu +* Global::Global options and class definitions +* ACL::Access control lists / firewalling +* NAT::Network Address Translation +* Traffic::Traffic shaping +@end menu + + + + + + +@node Global +@section The @code{<global>} section +@cindex global +This section contains global tags pertaining to either the operation of BWM +Tools or definitions used in other sections. These tags are detailed +below@dots{} +@* +@itemize +@item +@cindex modules +Module management in the @code{<modules>} section +@*@* +This section is used to load modules when bwmd starts. The syntax to load +a module is as follows@dots{} +@* +@smallexample + <load name="kernel_module_name" /> +@end smallexample +@* +The @code{<load />} tag takes the following parameters@dots{} +@* +@cindex load +@itemize +@item +@code{name="@dots{}"} - This is the name of the module to load +@item +@code{params="@dots{}"} - Parameters to load module with +@end itemize +@* +Here is how it can be used to load the ip_queue kernel module required +by bwmd for shaping. Including ftp connection tracking to allow users to +ftp through a tightly secured firewall. +@* +@smallexample +<firewall> + <global> + <modules> + <load name="ip_queue"/> + <load name="ip_nat_ftp"/> + <load name="ip_conntrack_ftp"/> + </modules> + </global> +. +. +. +</firewall> +@end smallexample + +@* +@item +@cindex class +Class definition in the @code{<class>} section +@*@* +This section is used to define classes used in both firewalling and network +address translation. The basic syntax is as follows@dots{} +@* +@smallexample + <class name="traffic_f... [truncated message content] |
From: SVN C. <sv...@li...> - 2005-01-09 16:24:09
|
Author: nkukard Date: 2005-01-09 18:23:48 +0200 (Sun, 09 Jan 2005) New Revision: 33 Modified: trunk/bwm_graph/bwm_graph.c trunk/lib/misc.c Log: * Fixed up displaying of usage information * Fixed bug when invalid options were specified but no error given * If no graph output file is specified, no graph will be generated * Added "hidden" options to available options to specify * -o option changed to --graph-filename * -t option changed to --graph-title * Changed date format to YYYY/MM/DD HH:MM:SS Modified: trunk/bwm_graph/bwm_graph.c =================================================================== --- trunk/bwm_graph/bwm_graph.c 2005-01-09 11:27:01 UTC (rev 32) +++ trunk/bwm_graph/bwm_graph.c 2005-01-09 16:23:48 UTC (rev 33) @@ -1,6 +1,6 @@ /* * bwm_graph.c - BWM Graph - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 @@ -37,25 +37,27 @@ // Function to print out our usage void printUsage(char **argv) { - printf("Usage: %s [-h|--help] [options]\n\n\n",argv[0]); - printf("Options...\n\n"); - printf("--flows=<flow1>[(counter)][:<rrd_line_type>[#rrbbgg]][,<flow2>[...]]\n"); - printf(" Flow(s) to generate report on\n\n"); - printf("--start=<start_date>\n"); - printf(" Date/Time of report start\n\n"); - printf("--end=<end_date>\n"); - printf(" Date/Time or report end\n\n"); - printf("--output=<filename>\n"); - printf(" Output filename\n\n"); - printf("--title=<graph_title>\n"); - printf(" Title of graph\n\n\n"); - printf("Graph Options...\n\n"); - printf("--graph-avg\n"); - printf(" Add averages per flow at bottom of graph\n\n"); - printf("--graph-date\n"); - printf(" Add date information under graph\n\n"); - printf("--graph-total\n"); - printf(" Add totals per flow at bottom of graph\n\n"); + printf("Usage: %s <options>\n",argv[0]); + printf("\n"); + printf("Options:\n"); + printf(" -f, --flows=<flow1>[(counter)][:<rrd_line_type>[#rrbbgg]][,<flow2>[...]]\n"); + printf(" Flow(s) to generate report on\n\n"); + printf(" -s, --start=\"YYYY/MM/DD HH:MM:SS\"\n"); + printf(" Date/Time of report start\n"); + printf(" -e, --end=\"YYYY/MM/DD HH:MM:SS\"\n"); + printf(" Date/Time of report end\n"); + printf(" -h, --help Display this page\n"); + printf("\n"); + printf("Graph Options:\n"); + printf(" --graph-filename=<filename> Output image filename\n"); + printf(" --graph-avg Add averages per flow at bottom of graph\n"); + printf(" --graph-date Add date information under graph\n"); + printf(" --graph-title=<graph_title> Title of graph\n"); + printf(" --graph-total Add totals per flow at bottom of graph\n"); + printf(" --graph-maxRate Specify your own maxRate value\n"); + printf(" --graph-vert-title=<graph_title>\n"); + printf(" Vertical title of graph\n"); + printf("\n"); } @@ -67,21 +69,20 @@ // Our options struct option long_options[] = { + {"flows",1,0,'f'}, + {"start",1,0,'s'}, {"end",1,0,'e'}, - {"flows",1,0,'f'}, {"help",0,0,'h'}, - {"output",1,0,'o'}, - {"start",1,0,'s'}, - {"title",1,0,'t'}, - {"vertical-title",1,0,'v'}, - {"graph-avg",0,0,1}, - {"graph-total",0,0,2}, - {"graph-maxRate",0,0,3}, - {"graph-date",0,0,4}, + {"graph-filename",0,0,1}, + {"graph-avg",0,0,2}, + {"graph-date",0,0,3}, + {"graph-title",1,0,4}, + {"graph-total",0,0,5}, + {"graph-maxRate",0,0,6}, + {"graph-vert-title",1,0,7}, {0,0,0,0} }; char **flowArray = NULL; - char *outputFile = "image.png"; int result = 0; char *aFlow; struct graphSource_t *gFlow; @@ -90,10 +91,14 @@ options = (struct graphOptions_t*) malloc0(sizeof(struct graphOptions_t)); - // FIXME - error check + if (!options) + { + fprintf(stderr,"ERROR: Failed to allocate memory options\n"); + return 1; + } + + printf("BWM Graph v%s - Copyright (c) 2003-2005 Linux Based Systems Design\n\n",PACKAGE_VERSION); - printf("BWM Graph v%s - Copyright (c) 2003-2004 Linux Based Systems Design\n\n",PACKAGE_VERSION); - // Print out help if (argc == 1) { @@ -107,21 +112,14 @@ int option_index = 0; // Process - c = getopt_long(argc,argv,"e:f:hs:t:v:",long_options,&option_index); + c = getopt_long(argc,argv,"f:s:e:h",long_options,&option_index); if (c == -1) break; // Check... switch (c) { - case 'e': - options->end = parseDateTime(optarg); - if (options->end < 0) - { - fprintf(stderr,"ERROR: Error in end time specified\n"); - return(1); - } - break; + // Normal options case 'f': // Grab the flows... flows = strndup(optarg,BUFFER_SIZE); @@ -129,12 +127,6 @@ flowArray = g_strsplit(flows,",",0); free(flows); break; - case 'h': - printUsage(argv); - return(0); - case 'o': - outputFile = strndup(optarg,BUFFER_SIZE); - break; case 's': options->start = parseDateTime(optarg); if (options->start < 0) @@ -143,52 +135,72 @@ return(1); } break; - case 't': - options->title = strndup(optarg,BUFFER_SIZE); + case 'e': + options->end = parseDateTime(optarg); + if (options->end < 0) + { + fprintf(stderr,"ERROR: Error in end time specified\n"); + return(1); + } break; - case 'v': - options->verticalTitle = strndup(optarg,BUFFER_SIZE); - break; + case 'h': + printUsage(argv); + return 0; + // Graphing options case 1: - options->graph_avg = 1; + options->outputFile = strndup(optarg,BUFFER_SIZE); break; case 2: - options->graph_total = 1; + options->graph_avg = 1; break; case 3: - options->graph_maxRate = 1; + options->graph_date = 1; break; case 4: - options->graph_date = 1; + options->title = strndup(optarg,BUFFER_SIZE); break; + case 5: + options->graph_total = 1; + break; + case 6: + options->graph_maxRate = 1; + break; + case 7: + options->verticalTitle = strndup(optarg,BUFFER_SIZE); + break; + + default: + printUsage(argv); + return 1; } } - // Let us know about ahy unknown options + // Let us know about any unknown options if (optind < argc) { while (optind < argc) - fprintf(stderr,"%s: invalid option -- %s\n",argv[0],argv[optind++]); - return(1); + fprintf(stderr,"ERROR: Invalid option -- %s\n",argv[optind++]); + printUsage(argv); + return 1; } // Check everything is ok... if (options->start <= 0) { fprintf(stderr,"ERROR: Report start date must be specified\n"); - return(1); + return 1; } if (options->end <= 0) { fprintf(stderr,"ERROR: Report end date must be specified\n"); - return(1); + return 1; } if (flowArray == 0) { fprintf(stderr,"ERROR: No flows specified for reporting\n"); - return(1); + return 1; } @@ -208,9 +220,6 @@ } free(flowArray); - // Create our graph options... - options->outputFile = outputFile; - // Create the files we need... printf("Creating RRD files...\n"); result = createRRDFiles(graphSources,options); @@ -222,13 +231,13 @@ result = writeRRDFile(graphSources,options); } // Graph... - if (result == 0) + if (result == 0 && options->outputFile) { printf("Graphing flows..."); result = writeGraphs(graphSources,options); } - return(result); + return result; } Modified: trunk/lib/misc.c =================================================================== --- trunk/lib/misc.c 2005-01-09 11:27:01 UTC (rev 32) +++ trunk/lib/misc.c 2005-01-09 16:23:48 UTC (rev 33) @@ -57,7 +57,7 @@ // Scan datetime provided and get our variables - ret = sscanf(dateTime, "%d/%d/%d %d:%d:%d", &day, &month, &year, &hour, + ret = sscanf(dateTime, "%d/%d/%d %d:%d:%d", &year, &month, &day, &hour, &minute, &second); // Check if we have an acceptable number of variables scanned |
From: SVN C. <sv...@li...> - 2005-01-09 11:27:24
|
Author: nkukard Date: 2005-01-09 13:27:01 +0200 (Sun, 09 Jan 2005) New Revision: 32 Modified: trunk/bwmd/bwmd.c Log: * Added printUsage() function * Display usage in more readable format Modified: trunk/bwmd/bwmd.c =================================================================== --- trunk/bwmd/bwmd.c 2005-01-05 13:08:18 UTC (rev 31) +++ trunk/bwmd/bwmd.c 2005-01-09 11:27:01 UTC (rev 32) @@ -67,6 +67,19 @@ } +// Print out our usage +void printUsage(char **argv) +{ + printf("Usage: %s <options>\n",argv[0]); + printf("\n"); + printf("Options:\n"); + printf(" -c, --config=<config_file> Specify non-default BWM Tools config file\n"); + printf(" -f, --foreground Run in foreground and print debugging info to screen\n"); + printf(" -h, --help Display this page\n"); + printf("\n"); +} + + // Main processig stuff... int main(int argc, char **argv) { @@ -114,11 +127,10 @@ daemonize = 0; break; case 'h': - // FIXME - version from CVS - printf("Usage: %s [-h|--help] [--config=<config_file>] [--foreground]\n",argv[0]); + printUsage(argv); return 0; default: - printf("Usage: %s [-h|--help] [--config=<config_file>] [--foreground]\n",argv[0]); + printUsage(argv); return 1; } |
From: SVN C. <sv...@li...> - 2005-01-05 13:08:40
|
Author: nkukard Date: 2005-01-05 15:08:18 +0200 (Wed, 05 Jan 2005) New Revision: 31 Modified: trunk/bwm_firewall/bwm_firewall.c Log: * Giang Hu <fre...@gm...> - Added preliminary support for direct piping of iptables firewall into iptables-restore Modified: trunk/bwm_firewall/bwm_firewall.c =================================================================== --- trunk/bwm_firewall/bwm_firewall.c 2005-01-05 09:45:08 UTC (rev 30) +++ trunk/bwm_firewall/bwm_firewall.c 2005-01-05 13:08:18 UTC (rev 31) @@ -211,30 +211,43 @@ // Function to write firewall to file -static int writeFirewall(GList *ruleList, char *filename) +static int writeFirewall(GList *ruleList, char *filename, char load) { int fd; int fuct = 0; char *buffer, datetime[32]; + FILE *piptables_restore = NULL; + - - // Write rule by rule to file + // Process rule by rule & write to file and/or pipe to iptables directly void writeRule(gpointer data, gpointer user_data) { int res; + if (!fuct) { + // Write to file... res = write(fd,data,strlen(data)); if (res < 0) { fprintf(stderr,"Failed to write to file: %s\n",strerror(errno)); fuct = 1; } + // Check if we piping to iptables aswell + if (piptables_restore) + { + fprintf(piptables_restore, "%s", data); + // Check for IO error + if (ferror(piptables_restore)) + { + fprintf(stderr,"Failed to write to file: %s\n",strerror(errno)); + piptables_restore = NULL; + } + } } } - // Open firewall file fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY,S_IREAD|S_IWRITE); if (fd < 0) @@ -243,6 +256,15 @@ return(-1); } + // Check if we piping direct to iptables aswell + if (load) + { + // iptables-restore should be in path + piptables_restore = popen("iptables-restore", "w"); + if (!piptables_restore) + fprintf(stderr, "ERROR: Can not find iptables-restore in $PATH, skipping load\n"); + } + buffer = (char *) malloc0(BUFFER_SIZE); // Write out comment to say what version & at what datetime we generated the firewall snprintf(buffer,BUFFER_SIZE,"# Generated using BWM Firewall v%s: %s\n",PACKAGE_VERSION, @@ -255,6 +277,10 @@ // Finally close file descriptor close(fd); + // If we opened iptables-restore close + if (piptables_restore) + fclose(piptables_restore); + return(fuct); } @@ -267,7 +293,7 @@ printf("Options:\n"); printf(" -c, --config=<config_file> Specify non-default BWM Tools config file\n"); printf(" -f, --file[=<output_file>] Generate iptables-restore file from BWM Tools firewall\n"); -// printf(" -l, --load Load BWM Tools firewall directly into kernel\n"); + printf(" -l, --load Load BWM Tools firewall directly into kernel\n"); printf(" -h, --help Display this page\n"); printf(" -r, --reset-counters Reset iptables counters, usable with \"iptables-restore -c\"\n"); printf("\n"); @@ -292,7 +318,7 @@ { {"config",required_argument,0,'c'}, {"file",optional_argument,0,'f'}, -// {"load",no_argument,0,'l'}, + {"load",no_argument,0,'l'}, {"help",no_argument,0,'h'}, {"reset-counters",no_argument,0,'r'}, {0,0,0,0} @@ -314,8 +340,7 @@ int option_index = 0; // Process -// c = getopt_long(argc,argv,"c=f:lhr",long_options,&option_index); - c = getopt_long(argc,argv,"c:f::hr",long_options,&option_index); + c = getopt_long(argc,argv,"c:f::lhr",long_options,&option_index); if (c == -1) break; @@ -372,7 +397,7 @@ if (fw) { printf("Writing IPTables configuration to \"%s\"...\n",outputFile); - res = writeFirewall(fw,outputFile); + res = writeFirewall(fw,outputFile,loadFirewall); } // Return result code |
From: SVN C. <sv...@li...> - 2005-01-05 09:45:34
|
Author: nkukard Date: 2005-01-05 11:45:08 +0200 (Wed, 05 Jan 2005) New Revision: 30 Modified: trunk/bwm_firewall/Makefile.in Log: * One last change to bwm_firewall, added 2005 in copyright Modified: trunk/bwm_firewall/Makefile.in =================================================================== --- trunk/bwm_firewall/Makefile.in 2005-01-05 08:59:28 UTC (rev 29) +++ trunk/bwm_firewall/Makefile.in 2005-01-05 09:45:08 UTC (rev 30) @@ -16,7 +16,7 @@ # # makefile.am - Makefile for BWM Firewall -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 |
From: SVN C. <sv...@li...> - 2005-01-05 08:59:46
|
Author: nkukard Date: 2005-01-05 10:59:28 +0200 (Wed, 05 Jan 2005) New Revision: 29 Modified: trunk/bwm_firewall/Makefile.am trunk/bwm_firewall/bwm_firewall.c trunk/bwm_firewall/bwm_firewall.h Log: * Added optional resetting of counters * Modified options to the following... -c, --config=<config_file> Specify non-default BWM Tools config file -f, --file[=<output_file>] Generate iptables-restore file from BWM Tools firewall -h, --help Display this page -r, --reset-counters Reset iptables counters, usable with "iptables-restore -c" Modified: trunk/bwm_firewall/Makefile.am =================================================================== --- trunk/bwm_firewall/Makefile.am 2005-01-04 13:41:55 UTC (rev 28) +++ trunk/bwm_firewall/Makefile.am 2005-01-05 08:59:28 UTC (rev 29) @@ -1,6 +1,6 @@ # # makefile.am - Makefile for BWM Firewall -# Copyright (C) 2003-2004, Linux Based Systems Design +# Copyright (C) 2003-2005, 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 Modified: trunk/bwm_firewall/bwm_firewall.c =================================================================== --- trunk/bwm_firewall/bwm_firewall.c 2005-01-04 13:41:55 UTC (rev 28) +++ trunk/bwm_firewall/bwm_firewall.c 2005-01-05 08:59:28 UTC (rev 29) @@ -1,6 +1,6 @@ /* * bwm_firewall.c - BWM Firewall - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 @@ -51,7 +51,7 @@ // Function to build a list of rules which iptables-restore takes -static GList *createFirewallRules(char *filename) +static GList *createFirewallRules(char *filename, char resetCounters) { xmlDocPtr doc; xmlNodePtr cur; @@ -63,6 +63,7 @@ char *tableList[] = {"filter","mangle",NULL}; char *tableName; int i; + char counters[7] = ""; // Loop with a table @@ -77,14 +78,16 @@ void processChains(gpointer p1_key, gpointer p1_value, gpointer p1_user_data) { struct confACLChain_t *chain = (struct confACLChain_t*) p1_value; - + aRule = (char *) malloc0(BUFFER_SIZE); - // Check if we have a default target for the chain or not + + // Check if we have a default target for the chain or not if (chain->defaultTarget) - snprintf(aRule,BUFFER_SIZE,":%s %s\n",chain->name,chain->defaultTarget); + snprintf(aRule,BUFFER_SIZE,":%s %s%s\n",chain->name,chain->defaultTarget,counters); else - snprintf(aRule,BUFFER_SIZE,":%s -\n",chain->name); + snprintf(aRule,BUFFER_SIZE,":%s -%s\n",chain->name,counters); + result = g_list_append(result,aRule); } @@ -127,7 +130,7 @@ // COMPAT: Do not genrate nodes for formatting spaces - LIBXML_TEST_VERSION + LIBXML_TEST_VERSION xmlKeepBlanksDefault(0); // FIXME - check if file exists @@ -196,6 +199,10 @@ // Clean up everything else before quitting. xmlCleanupParser(); + /* Check if we appending zero counters */ + if (resetCounters) + sprintf(counters,"%s"," [0:0]"); + // Build rule list g_hash_table_foreach(fwHash,processTable,NULL); @@ -238,7 +245,8 @@ buffer = (char *) malloc0(BUFFER_SIZE); // Write out comment to say what version & at what datetime we generated the firewall - snprintf(buffer,BUFFER_SIZE,"# Generated using BWM Firewall v%s: %s\n",PACKAGE_VERSION, date2str((char *) &datetime)); + snprintf(buffer,BUFFER_SIZE,"# Generated using BWM Firewall v%s: %s\n",PACKAGE_VERSION, + date2str((char *) &datetime)); write(fd,buffer,strlen(buffer)); // Loop with all rules @@ -254,7 +262,15 @@ // Print out our usage void printUsage(char **argv) { - printf("Usage: %s [-h|--help] [-f|--force] [-c|--config=<config_file>] [-o|--output=<output_file>]\n",argv[0]); + printf("Usage: %s <options>\n",argv[0]); + printf("\n"); + printf("Options:\n"); + printf(" -c, --config=<config_file> Specify non-default BWM Tools config file\n"); + printf(" -f, --file[=<output_file>] Generate iptables-restore file from BWM Tools firewall\n"); +// printf(" -l, --load Load BWM Tools firewall directly into kernel\n"); + printf(" -h, --help Display this page\n"); + printf(" -r, --reset-counters Reset iptables counters, usable with \"iptables-restore -c\"\n"); + printf("\n"); } @@ -265,22 +281,25 @@ int c; char *configFile = CONFIG_FILE; char *outputFile = IPTABLES_FILE; - int force = 0; + char resetCounters = 0; int res = 1; // signal we return error status + char writeFile = 0; + char loadFirewall = 0; // Our options struct option long_options[] = { - {"config",1,0,'c'}, - {"force",0,0,'f'}, - {"help",0,0,'h'}, - {"output",1,0,'o'}, + {"config",required_argument,0,'c'}, + {"file",optional_argument,0,'f'}, +// {"load",no_argument,0,'l'}, + {"help",no_argument,0,'h'}, + {"reset-counters",no_argument,0,'r'}, {0,0,0,0} }; - printf("BWM Firewall v%s - Copyright (c) 2003-2004 Linux Based Systems Design\n\n",PACKAGE_VERSION); + printf("BWM Firewall v%s - Copyright (c) 2003-2005 Linux Based Systems Design\n\n",PACKAGE_VERSION); // Check if we have no args if (argc == 1) @@ -295,7 +314,8 @@ int option_index = 0; // Process - c = getopt_long(argc,argv,"c:hfo:",long_options,&option_index); +// c = getopt_long(argc,argv,"c=f:lhr",long_options,&option_index); + c = getopt_long(argc,argv,"c:f::hr",long_options,&option_index); if (c == -1) break; @@ -305,30 +325,48 @@ case 'c': configFile = strdup(optarg); break; + case 'f': - force = 1; - break; + // If we have an option, save it + if (optarg) + outputFile = strdup(optarg); + writeFile = 1; + break; + + case 'l': + loadFirewall = 1; + break; + case 'h': printUsage(argv); return(0); - case 'o': - outputFile = strdup(optarg); + + case 'r': + resetCounters = 1; break; } } - + // Let us know about ahy unknown options if (optind < argc) { while (optind < argc) fprintf(stderr,"%s: invalid option -- %s\n",argv[0],argv[optind++]); - return(1); + return 1; } + // Check if we actually going to do anything + if (!writeFile && !loadFirewall) + { + printf("ERROR: No action to take\n"); + printUsage(argv); + return 1; + } + // Load configuration printf("Loading configuration from \"%s\"...\n",configFile); - fw = createFirewallRules(configFile); + fw = createFirewallRules(configFile,resetCounters); // Write out firewall if (fw) Modified: trunk/bwm_firewall/bwm_firewall.h =================================================================== --- trunk/bwm_firewall/bwm_firewall.h 2005-01-04 13:41:55 UTC (rev 28) +++ trunk/bwm_firewall/bwm_firewall.h 2005-01-05 08:59:28 UTC (rev 29) @@ -1,6 +1,6 @@ /* * bwm_firewall.h - BWM Firewall headers - * Copyright (C) 2003-2004, Linux Based Systems Design + * Copyright (C) 2003-2005, 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 |
From: SVN C. <sv...@li...> - 2005-01-04 13:42:26
|
Author: nkukard Date: 2005-01-04 15:41:55 +0200 (Tue, 04 Jan 2005) New Revision: 28 Modified: trunk/README trunk/configure trunk/configure.ac Log: * Fixed README to include only 1 copy of debian requirements * Added more exact version to configure with regards to glib & libxml Modified: trunk/README =================================================================== --- trunk/README 2005-01-03 16:54:45 UTC (rev 27) +++ trunk/README 2005-01-04 13:41:55 UTC (rev 28) @@ -18,8 +18,8 @@ Requirements ------------ -GLib >= 2.0.0 -libxml >= 2.0.0 +GLib >= 2.4.0 +libxml >= 2.6.0 RRDTool (preferbly the latest) @@ -34,51 +34,3 @@ libxml2-dev librrd0-dev - -Requirements for Debian Stable 3.0 ----------------------------------- -libglib2.0-0 -libglib2.0-dev -libglib2.0-dbg -libgd2-dev -cgilib -libpng-dev -libxml2-dev -librrd0-dev - - -Requirements for Debian Stable 3.0 ----------------------------------- -libglib2.0-0 -libglib2.0-dev -libglib2.0-dbg -libgd2-dev -cgilib -libpng-dev -libxml2-dev -librrd0-dev - - -Requirements for Debian Stable 3.0 ----------------------------------- -libglib2.0-0 -libglib2.0-dev -libglib2.0-dbg -libgd2-dev -cgilib -libpng-dev -libxml2-dev -librrd0-dev - - -Requirements for Debian Stable 3.0 ----------------------------------- -libglib2.0-0 -libglib2.0-dev -libglib2.0-dbg -libgd2-dev -cgilib -libpng-dev -libxml2-dev -librrd0-dev - Modified: trunk/configure =================================================================== --- trunk/configure 2005-01-03 16:54:45 UTC (rev 27) +++ trunk/configure 2005-01-04 13:41:55 UTC (rev 28) @@ -22883,7 +22883,7 @@ no_glib=yes fi - min_glib_version=2.0.0 + min_glib_version=2.4.0 echo "$as_me:$LINENO: checking for GLIB - version >= $min_glib_version" >&5 echo $ECHO_N "checking for GLIB - version >= $min_glib_version... $ECHO_C" >&6 @@ -23201,7 +23201,7 @@ echo "${ECHO_T}no" >&6 fi - min_xml_version=2.0.0 + min_xml_version=2.6.0 echo "$as_me:$LINENO: checking for libxml - version >= $min_xml_version" >&5 echo $ECHO_N "checking for libxml - version >= $min_xml_version... $ECHO_C" >&6 no_xml="" Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2005-01-03 16:54:45 UTC (rev 27) +++ trunk/configure.ac 2005-01-04 13:41:55 UTC (rev 28) @@ -88,8 +88,8 @@ AC_CHECK_FUNCS([gettimeofday inet_ntoa memset select socket strcasecmp strchr strdup strerror strncasecmp strndup]) # Custom -AM_PATH_GLIB_2_0(2.0.0,have_glib=yes,have_glib=no,gthread) -AM_PATH_XML2(2.0.0,have_xml=yes,have_xml=no) +AM_PATH_GLIB_2_0(2.4.0,have_glib=yes,have_glib=no,gthread) +AM_PATH_XML2(2.6.0,have_xml=yes,have_xml=no) XML_CFLAGS=$XML_CPPFLAGS AC_SUBST(XML_CFLAGS) |
From: SVN C. <sv...@li...> - 2005-01-03 16:55:04
|
Author: nkukard Date: 2005-01-03 18:54:45 +0200 (Mon, 03 Jan 2005) New Revision: 27 Modified: trunk/lib/misc.c Log: * Forgot to add ret = to grab return value Modified: trunk/lib/misc.c =================================================================== --- trunk/lib/misc.c 2005-01-03 14:49:04 UTC (rev 26) +++ trunk/lib/misc.c 2005-01-03 16:54:45 UTC (rev 27) @@ -57,7 +57,7 @@ // Scan datetime provided and get our variables - sscanf(dateTime, "%d/%d/%d %d:%d:%d", &day, &month, &year, &hour, + ret = sscanf(dateTime, "%d/%d/%d %d:%d:%d", &day, &month, &year, &hour, &minute, &second); // Check if we have an acceptable number of variables scanned |
From: SVN C. <sv...@li...> - 2005-01-03 14:49:20
|
Author: nkukard Date: 2005-01-03 16:49:04 +0200 (Mon, 03 Jan 2005) New Revision: 26 Modified: trunk/bwmd/bwmd.c trunk/bwmd/flow.c trunk/bwmd/flowControl.c trunk/bwmd/ipq.c trunk/bwmd/report.c trunk/include/flow.h Log: * Giang Hu <fre...@gm...> - Added logging support to bwmd Modified: trunk/bwmd/bwmd.c =================================================================== --- trunk/bwmd/bwmd.c 2005-01-03 14:48:14 UTC (rev 25) +++ trunk/bwmd/bwmd.c 2005-01-03 14:49:04 UTC (rev 26) @@ -206,8 +206,10 @@ // Check if we must become a daemon if (daemonize) + { + initSyslog("BWM", LOG_DEBUG); daemon(0,0); - + } // Create our threads to run IPQRunnerThread = g_thread_create(IPQRunner, (void *) runnerData, TRUE, NULL); flowRunnerThread = g_thread_create(flowRunner, (void *) runnerData, TRUE, NULL); Modified: trunk/bwmd/flow.c =================================================================== --- trunk/bwmd/flow.c 2005-01-03 14:48:14 UTC (rev 25) +++ trunk/bwmd/flow.c 2005-01-03 14:49:04 UTC (rev 26) @@ -32,9 +32,6 @@ #include "ipq.h" - - - // Function to update all our flow groups void updateGroups(struct flow_t *flow, int pktCount, int pktSize, int pktDropped, int pktBursted) { @@ -351,8 +348,7 @@ g_mutex_unlock(runnerData->IPQLock); if (status < 0) { - // FIXME - send error to log - fprintf(stderr,"Failed to ACCEPT packet\n"); + logMessage(LOG_ERR, "Failed to ACCEPT packet\n"); break; } @@ -466,9 +462,7 @@ for (i = 0; i < NUM_PRIO_BANDS; i++) queueChangeList[i] = NULL; - - if (!runnerData->daemon) - printf("Flow runner started...\n"); + logMessage(LOG_DEBUG, "Flow runner started...\n"); // Loop when we get a signal while (1) Modified: trunk/bwmd/flowControl.c =================================================================== --- trunk/bwmd/flowControl.c 2005-01-03 14:48:14 UTC (rev 25) +++ trunk/bwmd/flowControl.c 2005-01-03 14:49:04 UTC (rev 26) @@ -113,21 +113,21 @@ // Get us a socket if ((serverSock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - fprintf(stderr,"flowControl: Error getting socket: %s\n",strerror(errno)); + logMessage(LOG_ERR, "flowControl: Error getting socket: %s\n",strerror(errno)); return(NULL); } // Lose the pesky "address already in use" error message if (setsockopt(serverSock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) { - fprintf(stderr,"flowControl: Error setting socket options: %s\n",strerror(errno)); + logMessage(LOG_ERR, "flowControl: Error setting socket options: %s\n",strerror(errno)); return(NULL); } // Set us up as non blocking if (fcntl(serverSock,F_SETFL,O_NONBLOCK)) { - fprintf(stderr,"flowControl: Error setting socket to non-blocking: %s\n",strerror(errno)); + logMessage(LOG_ERR, "flowControl: Error setting socket to non-blocking: %s\n",strerror(errno)); return(NULL); } @@ -139,14 +139,14 @@ // and bind to it if (bind(serverSock, (struct sockaddr *) &listenAddr, sizeof(struct sockaddr)) == -1) { - fprintf(stderr,"flowControl: Error binding to socket: %s\n",strerror(errno)); + logMessage(LOG_ERR, "flowControl: Error binding to socket: %s\n",strerror(errno)); return(NULL); } // And listen on the socket if (listen(serverSock, 10) == -1) { - fprintf(stderr,"flowControl: Failed to listen on socket: %s\n",strerror(errno)); + logMessage(LOG_ERR, "flowControl: Failed to listen on socket: %s\n",strerror(errno)); return(NULL); } @@ -156,10 +156,8 @@ // Keep track of the biggest file descriptor fdmax = serverSock; // so far, it's this one + logMessage(LOG_DEBUG, "Stat thread started...\n"); - if (!runnerData->daemon) - printf("Stat thread started...\n"); - // Init everything to NOW gettimeofday(&now,NULL); lastSend = lastFree = lastReset = now; @@ -183,7 +181,7 @@ if (result == -1) { - fprintf(stderr,"flowControl: Failed to call select(): %s\n",strerror(errno)); + logMessage(LOG_ERR, "flowControl: Failed to call select(): %s\n",strerror(errno)); return(NULL); } @@ -235,9 +233,7 @@ myPacket.u.statusData = statusPacket; // And send it away if (sendall(tmpClient->fd, &myPacket, sizeof(struct ipc_packet_t)) == -1) - { - fprintf(stderr,"flowControl: Failed to write to client: %s\n",strerror(errno)); - } + logMessage(LOG_DEBUG, "flowControl: Failed to write to client: %s\n",strerror(errno)); statusItem = g_list_next(statusItem); } @@ -272,9 +268,7 @@ myPacket.u.statusData = statusPacket; // And send it away if (sendall(tmpClient->fd, &myPacket, sizeof(struct ipc_packet_t)) == -1) - { - fprintf(stderr,"flowControl: Failed to write to client: %s\n",strerror(errno)); - } + logMessage(LOG_DEBUG, "flowControl: Failed to write to client: %s\n",strerror(errno)); statusItem = g_list_next(statusItem); } @@ -298,7 +292,7 @@ // Accept the connection if ((newfd = accept(serverSock, (struct sockaddr *) &remoteAddr, &addrlen)) == -1) - fprintf(stderr,"flowControl: Failed to accept connection: %s\n",strerror(errno)); + logMessage(LOG_DEBUG, "flowControl: Failed to accept connection: %s\n",strerror(errno)); else { tmpClient = (struct ipc_client_t*) malloc(sizeof(struct ipc_client_t)); @@ -314,7 +308,7 @@ // Keep track of max fd's if (newfd > fdmax) fdmax = newfd; - printf("flowControl: New connection from %s on socket %d\n", inet_ntoa(remoteAddr.sin_addr), newfd); + logMessage(LOG_DEBUG, "flowControl: New connection from %s on socket %d\n", inet_ntoa(remoteAddr.sin_addr), newfd); } } @@ -336,9 +330,9 @@ // Got error or connection closed by client if (nbytes == 0) // Connection closed - printf("flowControl: Socket %d hung up\n", tmpClient->fd); + logMessage(LOG_DEBUG, "flowControl: Socket %d hung up\n", tmpClient->fd); else - fprintf(stderr,"flowControl: Error reading data: %s\n", strerror(errno)); + logMessage(LOG_DEBUG, "flowControl: Error reading data: %s\n", strerror(errno)); // Close and remove from master set close(tmpClient->fd); FD_CLR(tmpClient->fd, &master_fds); @@ -361,7 +355,7 @@ sendall(tmpClient->fd, &myPacket, sizeof(struct ipc_packet_t)); break; case IPC_PACKET_PONG: - printf("Received a PONG from %i\n",i); + logMessage(LOG_DEBUG, "Received a PONG from %i\n",i); break; case IPC_PACKET_ADD: i = 0; @@ -370,7 +364,7 @@ tmpFlow = findFlowByName(runnerData->flows,myPacket.u.statusData.flowName); if (tmpFlow) { - printf("Adding flow \"%s\" to update run\n",myPacket.u.statusData.flowName); + logMessage(LOG_DEBUG, "Adding flow \"%s\" to update run\n",myPacket.u.statusData.flowName); if (!g_list_find(tmpClient->flowStatusList,tmpFlow)) tmpClient->flowStatusList = g_list_append(tmpClient->flowStatusList,tmpFlow); i = 1; @@ -381,7 +375,7 @@ tmpGroup = findGroupByName(runnerData->groups,myPacket.u.statusData.flowName); if (tmpGroup) { - printf("Adding group \"%s\" to update run\n",myPacket.u.statusData.flowName); + logMessage(LOG_DEBUG, "Adding group \"%s\" to update run\n",myPacket.u.statusData.flowName); if (!g_list_find(tmpClient->groupStatusList,tmpGroup)) tmpClient->groupStatusList = g_list_append(tmpClient->groupStatusList, tmpGroup); @@ -390,7 +384,7 @@ } if (!i) - printf("Failed to find flow or group: %s\n",myPacket.u.statusData.flowName); + logMessage(LOG_DEBUG, "Failed to find flow or group: %s\n",myPacket.u.statusData.flowName); break; case IPC_PACKET_DEL: @@ -400,9 +394,8 @@ tmpFlow = findFlowByName(runnerData->flows,myPacket.u.statusData.flowName); if (tmpFlow) { - printf("Deleting flow \"%s\" from update run\n",myPacket.u.statusData.flowName); - //if (!g_list_find(tmpClient->flowStatusList,tmpFlow)) - tmpClient->flowStatusList = g_list_remove(tmpClient->flowStatusList,tmpFlow); + logMessage(LOG_DEBUG, "Deleting flow \"%s\" from update run\n",myPacket.u.statusData.flowName); + tmpClient->flowStatusList = g_list_remove(tmpClient->flowStatusList,tmpFlow); i = 1; } @@ -411,21 +404,20 @@ tmpGroup = findGroupByName(runnerData->groups,myPacket.u.statusData.flowName); if (tmpGroup) { - printf("Deleting group \"%s\" from update run\n", + logMessage(LOG_DEBUG, "Deleting group \"%s\" from update run\n", myPacket.u.statusData.flowName); - // if (!g_list_find(tmpClient->groupStatusList,tmpGroup)) - tmpClient->groupStatusList = g_list_remove(tmpClient->groupStatusList, - tmpGroup); + tmpClient->groupStatusList = g_list_remove(tmpClient->groupStatusList, + tmpGroup); i = 1; } } if (!i) - printf("Failed to find flow: %s\n",myPacket.u.statusData.flowName); + logMessage(LOG_DEBUG, "Failed to find flow: %s\n",myPacket.u.statusData.flowName); break; case IPC_PACKET_LIST_FLOWS: // Send flow list to the client - printf("Sending flow list\n"); + logMessage(LOG_DEBUG, "Sending flow list\n"); flowItem = g_list_first(runnerData->flows); while (flowItem) { @@ -436,7 +428,7 @@ sendall(tmpClient->fd, &myPacket, sizeof(struct ipc_packet_t)); flowItem = g_list_next(flowItem); } - printf("Sending group list\n"); + logMessage(LOG_DEBUG, "Sending group list\n"); // Send groups aswell, but fake it so it looks like flows groupItem = g_list_first(runnerData->groups); while (groupItem) @@ -451,7 +443,7 @@ // And an end packet myPacket.pktType = IPC_PACKET_LIST_END; sendall(tmpClient->fd, &myPacket, sizeof(struct ipc_packet_t)); - printf("List ended\n"); + logMessage(LOG_DEBUG, "List ended\n"); break; case IPC_PACKET_GET_NUM_FLOWS: // Reply with number of flows @@ -460,7 +452,7 @@ sendall(tmpClient->fd, &myPacket, sizeof(struct ipc_packet_t)); break; default: - printf("Received unknown packet type %i\n",myPacket.pktType); + logMessage(LOG_DEBUG, "Received unknown packet type %i\n",myPacket.pktType); break; } clientItem = g_list_next(clientItem); Modified: trunk/bwmd/ipq.c =================================================================== --- trunk/bwmd/ipq.c 2005-01-03 14:48:14 UTC (rev 25) +++ trunk/bwmd/ipq.c 2005-01-03 14:49:04 UTC (rev 26) @@ -288,15 +288,14 @@ unsigned int pkt_len = 0; GList *listItem; + + logMessage(LOG_INFO, "IPQ runner started...\n"); - 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"); + logMessage(LOG_ERR, "Failed to get IPQ handle\n"); return(NULL); } @@ -313,7 +312,7 @@ // Fail if error if (status < 0) { - fprintf(stderr,"Failed to get packet from IPQ: %s\n",ipq_errstr()); + logMessage(LOG_WARNING, "Failed to get packet from IPQ: %s\n",ipq_errstr()); // Lock, we dead... accept it! destroyIPQHandle(runnerData->IPQHandle); return(NULL); @@ -323,7 +322,7 @@ switch (ipq_message_type(buf)) { case NLMSG_ERROR: - fprintf(stderr, "Received error message: IPQ = %s, SYSTEM = %s\n",ipq_errstr(),strerror(errno)); + logMessage(LOG_WARNING, "Received error message: IPQ = %s, SYSTEM = %s\n",ipq_errstr(),strerror(errno)); break; case IPQM_PACKET: @@ -356,19 +355,18 @@ // Queue the packet... status = queuePacket(runnerData,packet->payload->mark,packet); if (status < 0) - fprintf(stderr,"Failed to queue packet\n"); - + logMessage(LOG_WARNING, "Failed to queue packet\n"); break; default: - fprintf(stderr, "Unknown message type!\n"); + logMessage(LOG_WARNING, "Unknown message type!\n"); break; } } closeIPQHandle(runnerData->IPQHandle); - printf("Exiting IPQ runner thread\n"); + logMessage(LOG_INFO, "Exiting IPQ runner thread\n"); } Modified: trunk/bwmd/report.c =================================================================== --- trunk/bwmd/report.c 2005-01-03 14:48:14 UTC (rev 25) +++ trunk/bwmd/report.c 2005-01-03 14:49:04 UTC (rev 26) @@ -66,7 +66,7 @@ opRes = read(fd,&fileHeader,sizeof(struct aLogFileHeader_t)); if (opRes != sizeof(struct aLogFileHeader_t)) { - fprintf(stderr,"Error reading header from \"%s\": %s\n",filename,strerror(errno)); + logMessage(LOG_DEBUG, "Error reading header from \"%s\": %s\n",filename,strerror(errno)); err = 1; } // If no errors seek... @@ -76,7 +76,7 @@ opRes = lseek(fd,0,SEEK_END); if (opRes < 0) { - fprintf(stderr,"Error seeking end of file \"%s\": %s\n",filename,strerror(errno)); + logMessage(LOG_DEBUG, "Error seeking end of file \"%s\": %s\n",filename,strerror(errno)); err = 1; } } @@ -87,7 +87,7 @@ opRes = write(fd,&reportData->entry,sizeof(struct aLogFileEntry_t)); if (opRes != sizeof(struct aLogFileEntry_t)) { - fprintf(stderr,"Error writing record to file \"%s\": %s\n",filename,strerror(errno)); + logMessage(LOG_DEBUG, "Error writing record to file \"%s\": %s\n",filename,strerror(errno)); err = 1; } else @@ -107,7 +107,7 @@ opRes = lseek(fd,0,SEEK_SET); if (opRes < 0) { - fprintf(stderr,"Error seeking beginning of file \"%s\": %s\n",filename,strerror(errno)); + logMessage(LOG_DEBUG, "Error seeking beginning of file \"%s\": %s\n",filename,strerror(errno)); err = 1; } } @@ -118,7 +118,7 @@ opRes = write(fd,&fileHeader,sizeof(struct aLogFileHeader_t)); if (opRes != sizeof(struct aLogFileHeader_t)) { - fprintf(stderr,"Error writing header to file \"%s\": %s\n",filename,strerror(errno)); + logMessage(LOG_DEBUG, "Error writing header to file \"%s\": %s\n",filename,strerror(errno)); err = 1; } } @@ -132,7 +132,7 @@ // Check if file doesn't exist if (errno == ENOENT) { - printf("Creating report file %s\n",filename); + logMessage(LOG_DEBUG, "Creating report file %s\n",filename); // If not create it fd = open(filename,O_CREAT|O_RDWR,S_IREAD|S_IWRITE); if (fd > 0) @@ -148,7 +148,7 @@ opRes = write(fd,&fileHeader,sizeof(struct aLogFileHeader_t)); if (opRes != sizeof(struct aLogFileHeader_t)) { - fprintf(stderr,"Error writing header to \"%s\": %s\n",filename,strerror(errno)); + logMessage(LOG_DEBUG, "Error writing header to \"%s\": %s\n",filename,strerror(errno)); err = 1; } // If no errors write more... @@ -157,17 +157,17 @@ opRes = write(fd,&reportData->entry,sizeof(struct aLogFileEntry_t)); if (opRes != sizeof(struct aLogFileEntry_t)) { - fprintf(stderr,"Error writing record to \"%s\": %s\n",filename,strerror(errno)); + logMessage(LOG_DEBUG, "Error writing record to \"%s\": %s\n",filename,strerror(errno)); err = 1; } } close(fd); } else - fprintf(stderr,"Stat error on \"%s\": %s\n",filename,strerror(errno)); + logMessage(LOG_DEBUG, "Stat error on \"%s\": %s\n",filename,strerror(errno)); } else - fprintf(stderr,"Failed to open file \"%s\": %s\n",filename,strerror(errno)); + logMessage(LOG_DEBUG, "Failed to open file \"%s\": %s\n",filename,strerror(errno)); } return(NULL); @@ -181,9 +181,8 @@ struct runnerData_t *runnerData = (struct runnerData_t*) data; GList *flowItem, *groupItem; - - if (!runnerData->daemon) - printf("Report runner started...\n"); + + logMessage(LOG_DEBUG, "Report runner started...\n"); // Loop every 1s and reset everything while (1) { Modified: trunk/include/flow.h =================================================================== --- trunk/include/flow.h 2005-01-03 14:48:14 UTC (rev 25) +++ trunk/include/flow.h 2005-01-03 14:49:04 UTC (rev 26) @@ -29,6 +29,7 @@ #include <glib.h> #include <linux/netfilter.h> #include <sys/time.h> +#include <syslog.h> #include "common.h" #include "ipq.h" #include "libipq.h" @@ -183,7 +184,7 @@ (flow->curQueueSize + pktSize >= flow->maxQueueSize && flow->maxQueueSize != 0)); } +extern void logMessage(int priority, const char *fmt, ...); - #endif |
From: SVN C. <sv...@li...> - 2005-01-03 14:48:32
|
Author: nkukard Date: 2005-01-03 16:48:14 +0200 (Mon, 03 Jan 2005) New Revision: 25 Modified: trunk/bwm_monitor/bwm_monitor.c Log: * Giang Hu <fre...@gm...> - Fixed select() error check Modified: trunk/bwm_monitor/bwm_monitor.c =================================================================== --- trunk/bwm_monitor/bwm_monitor.c 2005-01-03 13:40:41 UTC (rev 24) +++ trunk/bwm_monitor/bwm_monitor.c 2005-01-03 14:48:14 UTC (rev 25) @@ -127,9 +127,9 @@ wrefresh(win); } - else - { // socket has been closed or error occured - // FIXME - set error message + else if (result < 0) + { // error occured + // FIXME - set error message break; } |
From: SVN C. <sv...@li...> - 2005-01-03 13:40:58
|
Author: nkukard Date: 2005-01-03 15:40:41 +0200 (Mon, 03 Jan 2005) New Revision: 24 Modified: trunk/include/flow.h trunk/include/xmlConf.h Log: * Change 4/4: Depletion of lib Modified: trunk/include/flow.h =================================================================== --- trunk/include/flow.h 2005-01-03 13:40:24 UTC (rev 23) +++ trunk/include/flow.h 2005-01-03 13:40:41 UTC (rev 24) @@ -161,28 +161,6 @@ struct pktStat_t getFlowTotalStats(struct pktStat_t *pktStats, long int pktStatsLen); -// Create a flow -struct flow_t* createFlow( - char *flowName, - struct flow_t *parentFlow, - long int statsLen, - long int maxQueueSize, - long int maxQueueLen, - long int maxRate, - long int burstRate, - long int nfmark, - float parent_th, - int reportTimeout); - - -// Create group -struct group_t *createGroup( - char *groupName, - long int statsLen, - int reportTimeout, - GList *flowList); - - // Function to update all our flow groups void updateGroups( struct flow_t *flow, @@ -192,13 +170,6 @@ int pktBursted); -// Create a packet queue -struct pktQueue_t *createPktQueue( - long int prio, - long int nfmark, - struct flow_t *parentFlow); - - // Flow runner thread void *flowRunner(void *data); Modified: trunk/include/xmlConf.h =================================================================== --- trunk/include/xmlConf.h 2005-01-03 13:40:24 UTC (rev 23) +++ trunk/include/xmlConf.h 2005-01-03 13:40:41 UTC (rev 24) @@ -26,6 +26,7 @@ #define _XMLCONF_H #include <glib.h> +#include <libxml/parser.h> // An address declaration with all its lil params @@ -70,8 +71,30 @@ }; + +// Function to get a chain if it exists or to create it +struct confACLChain_t *lookupChain(GHashTable *chains, char *chainName); + +// Function to get a table if it exists or to create it +struct confACLTable_t *lookupTable(GHashTable *tables, char *tableName); + +// Parse the GLOBAL section to get modules we must load GHashTable *getModuleLoadHash(char *filename); -GList *createFirewallRules(char *filename); + +// Parse the TRAFFIC section and create flows + queues struct flowData_t createFlowData(char *filename); +// Parse the NAT section +void parseNAT(xmlDocPtr doc, xmlNodePtr cur, GHashTable *fwHash, GHashTable *classHash); + +// Parse the TRAFFIC section +void parseTraffic(xmlDocPtr doc, xmlNodePtr cur, GHashTable *fwHash, GHashTable *classHash); + +// Parse the GLOBAL section +GHashTable *parseGlobal(xmlDocPtr doc, xmlNodePtr cur); + +// Parse the ACL section +GHashTable *parseACL(xmlDocPtr doc, xmlNodePtr cur, GHashTable *fwHash, GHashTable *classHash); + + #endif |
From: SVN C. <sv...@li...> - 2005-01-03 13:40:43
|
Author: nkukard Date: 2005-01-03 15:40:24 +0200 (Mon, 03 Jan 2005) New Revision: 23 Removed: trunk/lib/autoclass.c trunk/lib/flow.c trunk/lib/ipq.c trunk/lib/libipq.c Modified: trunk/lib/Makefile.am trunk/lib/Makefile.in trunk/lib/xmlConf.c Log: * Change 3/4: Depletion of lib Modified: trunk/lib/Makefile.am =================================================================== --- trunk/lib/Makefile.am 2005-01-03 13:39:48 UTC (rev 22) +++ trunk/lib/Makefile.am 2005-01-03 13:40:24 UTC (rev 23) @@ -25,7 +25,7 @@ lib_LTLIBRARIES = libbwm.la -libbwm_la_SOURCES = flow.c ipq.c libipq.c xmlConf.c autoclass.c misc.c +libbwm_la_SOURCES = xmlConf.c misc.c libbwm_la_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(XML_CFLAGS) $(GMIME_CFLAGS) $(AM_CFLAGS) libbwm_la_LDFLAGS = $(GLIB_LIBS) $(XML_LIBS) $(GMIME_LIBS) -version-info 1:0:0 Modified: trunk/lib/Makefile.in =================================================================== --- trunk/lib/Makefile.in 2005-01-03 13:39:48 UTC (rev 22) +++ trunk/lib/Makefile.in 2005-01-03 13:40:24 UTC (rev 23) @@ -75,9 +75,7 @@ libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libbwm_la_LIBADD = -am_libbwm_la_OBJECTS = libbwm_la-flow.lo libbwm_la-ipq.lo \ - libbwm_la-libipq.lo libbwm_la-xmlConf.lo \ - libbwm_la-autoclass.lo libbwm_la-misc.lo +am_libbwm_la_OBJECTS = libbwm_la-xmlConf.lo libbwm_la-misc.lo libbwm_la_OBJECTS = $(am_libbwm_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -204,7 +202,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ lib_LTLIBRARIES = libbwm.la -libbwm_la_SOURCES = flow.c ipq.c libipq.c xmlConf.c autoclass.c misc.c +libbwm_la_SOURCES = xmlConf.c misc.c libbwm_la_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) $(XML_CFLAGS) $(GMIME_CFLAGS) $(AM_CFLAGS) libbwm_la_LDFLAGS = $(GLIB_LIBS) $(XML_LIBS) $(GMIME_LIBS) -version-info 1:0:0 all: all-am @@ -276,10 +274,6 @@ distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbwm_la-autoclass.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbwm_la-flow.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbwm_la-ipq.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbwm_la-libipq.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbwm_la-misc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbwm_la-xmlConf.Plo@am__quote@ @@ -304,27 +298,6 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< -libbwm_la-flow.lo: flow.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbwm_la_CFLAGS) $(CFLAGS) -MT libbwm_la-flow.lo -MD -MP -MF "$(DEPDIR)/libbwm_la-flow.Tpo" -c -o libbwm_la-flow.lo `test -f 'flow.c' || echo '$(srcdir)/'`flow.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libbwm_la-flow.Tpo" "$(DEPDIR)/libbwm_la-flow.Plo"; else rm -f "$(DEPDIR)/libbwm_la-flow.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='flow.c' object='libbwm_la-flow.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbwm_la_CFLAGS) $(CFLAGS) -c -o libbwm_la-flow.lo `test -f 'flow.c' || echo '$(srcdir)/'`flow.c - -libbwm_la-ipq.lo: ipq.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbwm_la_CFLAGS) $(CFLAGS) -MT libbwm_la-ipq.lo -MD -MP -MF "$(DEPDIR)/libbwm_la-ipq.Tpo" -c -o libbwm_la-ipq.lo `test -f 'ipq.c' || echo '$(srcdir)/'`ipq.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libbwm_la-ipq.Tpo" "$(DEPDIR)/libbwm_la-ipq.Plo"; else rm -f "$(DEPDIR)/libbwm_la-ipq.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ipq.c' object='libbwm_la-ipq.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbwm_la_CFLAGS) $(CFLAGS) -c -o libbwm_la-ipq.lo `test -f 'ipq.c' || echo '$(srcdir)/'`ipq.c - -libbwm_la-libipq.lo: libipq.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbwm_la_CFLAGS) $(CFLAGS) -MT libbwm_la-libipq.lo -MD -MP -MF "$(DEPDIR)/libbwm_la-libipq.Tpo" -c -o libbwm_la-libipq.lo `test -f 'libipq.c' || echo '$(srcdir)/'`libipq.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libbwm_la-libipq.Tpo" "$(DEPDIR)/libbwm_la-libipq.Plo"; else rm -f "$(DEPDIR)/libbwm_la-libipq.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libipq.c' object='libbwm_la-libipq.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbwm_la_CFLAGS) $(CFLAGS) -c -o libbwm_la-libipq.lo `test -f 'libipq.c' || echo '$(srcdir)/'`libipq.c - libbwm_la-xmlConf.lo: xmlConf.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbwm_la_CFLAGS) $(CFLAGS) -MT libbwm_la-xmlConf.lo -MD -MP -MF "$(DEPDIR)/libbwm_la-xmlConf.Tpo" -c -o libbwm_la-xmlConf.lo `test -f 'xmlConf.c' || echo '$(srcdir)/'`xmlConf.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libbwm_la-xmlConf.Tpo" "$(DEPDIR)/libbwm_la-xmlConf.Plo"; else rm -f "$(DEPDIR)/libbwm_la-xmlConf.Tpo"; exit 1; fi @@ -332,13 +305,6 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbwm_la_CFLAGS) $(CFLAGS) -c -o libbwm_la-xmlConf.lo `test -f 'xmlConf.c' || echo '$(srcdir)/'`xmlConf.c -libbwm_la-autoclass.lo: autoclass.c -@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbwm_la_CFLAGS) $(CFLAGS) -MT libbwm_la-autoclass.lo -MD -MP -MF "$(DEPDIR)/libbwm_la-autoclass.Tpo" -c -o libbwm_la-autoclass.lo `test -f 'autoclass.c' || echo '$(srcdir)/'`autoclass.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libbwm_la-autoclass.Tpo" "$(DEPDIR)/libbwm_la-autoclass.Plo"; else rm -f "$(DEPDIR)/libbwm_la-autoclass.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='autoclass.c' object='libbwm_la-autoclass.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbwm_la_CFLAGS) $(CFLAGS) -c -o libbwm_la-autoclass.lo `test -f 'autoclass.c' || echo '$(srcdir)/'`autoclass.c - libbwm_la-misc.lo: misc.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbwm_la_CFLAGS) $(CFLAGS) -MT libbwm_la-misc.lo -MD -MP -MF "$(DEPDIR)/libbwm_la-misc.Tpo" -c -o libbwm_la-misc.lo `test -f 'misc.c' || echo '$(srcdir)/'`misc.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libbwm_la-misc.Tpo" "$(DEPDIR)/libbwm_la-misc.Plo"; else rm -f "$(DEPDIR)/libbwm_la-misc.Tpo"; exit 1; fi Deleted: trunk/lib/autoclass.c =================================================================== --- trunk/lib/autoclass.c 2005-01-03 13:39:48 UTC (rev 22) +++ trunk/lib/autoclass.c 2005-01-03 13:40:24 UTC (rev 23) @@ -1,107 +0,0 @@ -/* - * 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; -} - Deleted: trunk/lib/flow.c =================================================================== --- trunk/lib/flow.c 2005-01-03 13:39:48 UTC (rev 22) +++ trunk/lib/flow.c 2005-01-03 13:40:24 UTC (rev 23) @@ -1,768 +0,0 @@ -/* - * 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" - - - - - -// Create a flow -struct flow_t* createFlow( - char *flowName, - struct flow_t *parentFlow, - long int statsLen, - long int maxQueueSize, - long int maxQueueLen, - long int maxRate, - long int burstRate, - long int nfmark, - float parent_th, - int reportTimeout) -{ - int i; - struct flow_t *flow = (struct flow_t*) malloc(sizeof(struct flow_t)); - - - // Check if its ok... - if (!flow) - { - // FIXME - log error - fprintf(stderr,"Failed to allocate memory for flow\n"); - return NULL; - } - - // Lock entire flow - flow->lock = g_mutex_new(); - - strncpy(flow->flowName,flowName,MAX_REFLEN); // copy string - - flow->statsLen = statsLen; - flow->statsPos = 0; - - flow->parent = parentFlow; - - flow->maxQueueSize = maxQueueSize; - flow->maxQueueLen = maxQueueLen; - flow->maxRate = maxRate; - flow->burstRate = burstRate; - flow->nfmark = nfmark; - - flow->parent_th = parent_th; - - flow->counterTimeout = reportTimeout; - flow->counterRemaining = reportTimeout; - - flow->curQueueSize = 0; - flow->curQueueLen = 0; - - // Lock for our counters only - flow->counterLock = g_mutex_new(); - flow->counter.pktCount = 0; - flow->counter.pktSize = 0; - flow->counter.pktDropped = 0; - flow->counter.pktBursted = 0; - - flow->groups = NULL; - - flow->lastDumpTimestamp = time(NULL); - // Check if we can set our credit - if (flow->maxRate > 0) - { - flow->usCredit = flow->maxRate / 1000000.0; // For micro (millionths) of seconds silly - flow->curCredit = 0; - } - else - { - flow->usCredit = 0; - flow->curCredit = 0; - } - - if (flow->burstRate > 0) - { - flow->usBurstCredit = flow->burstRate / 1000000.0; - flow->curBurstCredit = 0; - } - else - { - flow->usBurstCredit = 0; - flow->curBurstCredit = 0; - } - // Setup throughput stuff... - gettimeofday(&flow->lastThroughputUpdate,NULL); - flow->curThroughputAge = 0; - flow->curThroughput = 0; - // Set last time we calculated credit and the rest... - flow->accumMs = 0; - gettimeofday(&flow->lastCreditCalc,NULL); - // Clear our running counters - flow->running.pktCount = 0; - flow->running.pktSize = 0; - flow->running.pktDropped = 0; - flow->running.pktBursted = 0; - - // Verify everything is ok... - if (flow->statsLen == 0) - flow->statsLen = 10; - - // Create stuff... - flow->pktStats = (struct pktStat_t*) malloc0(sizeof(struct pktStat_t) * flow->statsLen); - if (!flow->pktStats) - { - // FIXME - log error - fprintf(stderr,"Failed to allocate memory for flow->pktStats\n"); - return NULL; - } - - // Calculate the queue length ... etc - if (flow->maxQueueLen == -1) - { - if (flow->maxRate != 0) - flow->maxQueueLen = 5; // Seems an OK value for normal use? - else - flow->maxQueueLen = 0; - } - if (flow->maxQueueSize == -1) - { - if (flow->maxRate != 0) - flow->maxQueueSize = 4096; // Let us queue at least 2 big packets and some small ones - else - flow->maxQueueSize = 0; - } - - // Calculate our thresholds - //flow->min_th = (flow->maxRate / 750); - //flow->max_th = (flow->maxRate / 750) * 4; - - // Blank all queues - for (i = 0; i < NUM_PRIO_BANDS; i++) - { - struct pktQueue_t *pktQueue = flow->pktQueues[i] = (struct pktQueue_t*) malloc(sizeof(struct pktQueue_t)); - - pktQueue->lock = g_mutex_new(); - pktQueue->prio = i; - pktQueue->parentFlow = flow; - pktQueue->nfmark = -1; - pktQueue->curSize = 0; - pktQueue->curLen = 0; - pktQueue->maxSize = 0; - pktQueue->maxLen = 0; - pktQueue->packets = NULL; - } - -// printf("Flow added...\n"); -// printf(" flowName - %s\n",flowName); -// printf(" parent - %p\n",parentFlow); -// printf(" nfmark - %li\n",nfmark); -// printf(" statsLen - %li\n",flow->statsLen); -// printf(" maxQueueSize - %li\n",flow->maxQueueSize); -// printf(" maxQueueLen - %li\n",flow->maxQueueLen); -// printf(" maxRate - %li\n",flow->maxRate); -// printf(" usCredit - %.6f\n",flow->usCredit); -// printf(" curCredit - %u\n",flow->curCredit); -// printf(" usBurstCredit - %.6f\n",flow->usBurstCredit); -// printf(" curBurstCredit - %u\n",flow->curBurstCredit); -// printf(" burstRate - %li\n",flow->burstRate); -// printf("Queue Stuff:\n"); -// printf(" min_th - %li\n",flow->min_th); -// printf(" max_th - %li\n",flow->max_th); - - return flow; -} - - -// Create group -struct group_t *createGroup( - char *groupName, - long int statsLen, - int reportTimeout, - GList *flowList) -{ - struct group_t *group = (struct group_t *) malloc(sizeof(struct group_t)); - - - // Lock entire flow - group->lock = g_mutex_new(); - - strncpy(group->groupName,groupName,MAX_REFLEN); // copy string - - // Stats stuff - group->statsLen = statsLen; - group->statsPos = 0; - - // Clear our running counters - group->running.pktCount = 0; - group->running.pktSize = 0; - group->running.pktDropped = 0; - group->running.pktBursted = 0; - - group->counterLock = g_mutex_new(); - group->counter.pktCount = 0; - group->counter.pktSize = 0; - group->counter.pktDropped = 0; - group->counter.pktBursted = 0; - - // Set dump time - group->lastDumpTimestamp = time(NULL); - - // Report stuff - group->counterTimeout = reportTimeout; - group->counterRemaining = reportTimeout; - - // Our list of flows - group->flowList = flowList; - - // Verify everything is ok... - if (group->statsLen == 0) - group->statsLen = 10; - - group->pktStats = (struct pktStat_t*) malloc0(sizeof(struct pktStat_t) * group->statsLen); - if (!group->pktStats) - { - // FIXME - log error - fprintf(stderr,"Failed to allocate memory for group->pktStats\n"); - return NULL; - } - return group; -} - - -// Create a packet queue for the flow -struct pktQueue_t *createPktQueue( - long int prio, - long int nfmark, - struct flow_t *parentFlow) -{ - struct pktQueue_t *pktQueue = parentFlow->pktQueues[prio]; - - - // Make sure we valid - if (prio >= NUM_PRIO_BANDS || prio < 0) - { - fprintf(stderr,"ERROR: Queue priority must be between 0 and 99\n"); - return NULL; - } - - pktQueue->nfmark = nfmark; -/* - printf(" Queue added...\n"); - printf(" prio - %li\n",prio); - printf(" nfmark - %li\n",nfmark); -*/ - return pktQueue; -} - - -// 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); -} - - Deleted: trunk/lib/ipq.c =================================================================== --- trunk/lib/ipq.c 2005-01-03 13:39:48 UTC (rev 22) +++ trunk/lib/ipq.c 2005-01-03 13:40:24 UTC (rev 23) @@ -1,374 +0,0 @@ -/* - * 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"); -} - - Deleted: trunk/lib/libipq.c =================================================================== --- trunk/lib/libipq.c 2005-01-03 13:39:48 UTC (rev 22) +++ trunk/lib/libipq.c 2005-01-03 13:40:24 UTC (rev 23) @@ -1,385 +0,0 @@ -/* - * 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); -} Modified: trunk/lib/xmlConf.c =================================================================== --- trunk/lib/xmlConf.c 2005-01-03 13:39:48 UTC (rev 22) +++ trunk/lib/xmlConf.c 2005-01-03 13:40:24 UTC (rev 23) @@ -26,6 +26,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <time.h> #include <libxml/xmlmemory.h> #include <libxml/parser.h> #include "common.h" @@ -34,54 +35,6 @@ -/* general functions - static struct confACLChain_t *lookupChain(GHashChain *tables, char *tableName) {{{ */ -// Function to get a chain if it exists or to create it -static struct confACLChain_t *lookupChain(GHashTable *chains, char *chainName) -{ - struct confACLChain_t *tmpChain; - - // See if we have a table by this name - tmpChain = g_hash_table_lookup(chains,chainName); - if (tmpChain == NULL) - { - // If not... create everything - tmpChain = (struct confACLChain_t*) malloc(sizeof(struct confACLChain_t)); - tmpChain->name = strdup(chainName); - tmpChain->defaultTarget = NULL; - // If not... start creating everything... - tmpChain->ruleList = NULL; - tmpChain->ruleset = NULL; - g_hash_table_insert(chains,chainName,tmpChain); - } - - // Return chain - return(tmpChain); -} -/* }}} */ - -/* general functions - static struct confACLTable_t *lookupTable(GHashTable *tables, char *tableName) {{{ */ -// Function to get a table if it exists or to create it -static struct confACLTable_t *lookupTable(GHashTable *tables, char *tableName) -{ - struct confACLTable_t *tmpTable; - - // See if we have a table by this name - tmpTable = g_hash_table_lookup(tables,tableName); - if (tmpTable == NULL) - { - // If not... create everything - tmpTable = (struct confACLTable_t*) malloc(sizeof(struct confACLTable_t)); - tmpTable->name = strdup(tableName); - tmpTable->chains = g_hash_table_new(g_str_hash,g_str_equal); - g_hash_table_insert(tables,tableName,tmpTable); - } - - // Return table - return(tmpTable); -} -/* }}} */ - -/* general functions - static GList *splitContents(xmlNodePtr node) {{{ */ // Function to split out the contents of an xml content into a linked list static GList *splitContents(xmlNodePtr node) { @@ -134,9 +87,8 @@ return(result); } -/* }}} */ -/* general functions - static GHashTable *getProperties(xmlNodePtr node) {{{ */ + // Function to get the properties in a hash table of a node static GHashTable *getProperties(xmlNodePtr node) { @@ -163,9 +115,8 @@ // Return our hash return(attribHash); } -/* }}} */ -/* ruleset functions - static GList *createRuleset(GHashTable *classHash, GList *classList, char *chainName, char *target, char *cmd_line1, char *cmd_line2) {{{ */ + // Function to build a ruleset out of a number of classes and an extra char* at the end static GList *createRuleset(GHashTable *classHash, GList *classList, char *chainName, char *target, char *cmd_line1, char *cmd_line2) { @@ -262,9 +213,8 @@ return(result); } -/* }}} */ -/* ruleset functions - static GList *createClassRuleset(struct confClass_t *confClass) {{{ */ + // Create a classes ruleset static GList *createClassRuleset(struct confClass_t *confClass) { @@ -381,9 +331,7 @@ // Returning the rule list return result; } -/* }}} */ -/* ruleset functions - static char *createNATRuleset(GHashTable *properties) {{{ */ // Function which creates our "special" nat extra cmd_line options static char *createNATRuleset(GHashTable *properties) { @@ -437,9 +385,8 @@ // Return the string FIXME - free mem in parent? return buffer; } -/* }}} */ -/* ruleset functions - static char *createTrafficRuleset(GHashTable *properties) {{{ */ + // Function which creates our "special" traffic extra cmd_line options static char *createTrafficRuleset(GHashTable *properties) { @@ -505,9 +452,53 @@ // Return the string FIXME - free mem in parent? return buffer; } -/* }}} */ -/* parsing functions - static GHashTable *moduleLoadList(char *filename) {{{ */ + +// Function to get a chain if it exists or to create it +struct confACLChain_t *lookupChain(GHashTable *chains, char *chainName) +{ + struct confACLChain_t *tmpChain; + + // See if we have a table by this name + tmpChain = g_hash_table_lookup(chains,chainName); + if (tmpChain == NULL) + { + // If not... create everything + tmpChain = (struct confACLChain_t*) malloc(sizeof(struct confACLChain_t)); + tmpChain->name = strdup(chainName); + tmpChain->defaultTarget = NULL; + // If not... start creating everything... + tmpChain->ruleList = NULL; + tmpChain->ruleset = NULL; + g_hash_table_insert(chains,chainName,tmpChain); + } + + // Return chain + return(tmpChain); +} + + +// Function to get a table if it exists or to create it +struct confACLTable_t *lookupTable(GHashTable *tables, char *tableName) +{ + struct confACLTable_t *tmpTable; + + // See if we have a table by this name + tmpTable = g_hash_table_lookup(tables,tableName); + if (tmpTable == NULL) + { + // If not... create everything + tmpTable = (struct confACLTable_t*) malloc(sizeof(struct confACLTable_t)); + tmpTable->name = strdup(tableName); + tmpTable->chains = g_hash_table_new(g_str_hash,g_str_equal); + g_hash_table_insert(tables,tableName,tmpTable); + } + + // Return table + return(tmpTable); +} + + // Parse the GLOBAL section to get modules we must load GHashTable *getModuleLoadHash(char *filename) { @@ -642,611 +633,254 @@ return(moduleHash); } -/* }}} */ -/* parsing functions - static GHashTable *parseGlobal(xmlDocPtr doc, xmlNodePtr cur) {{{ */ -// Parse the GLOBAL section -static GHashTable *parseGlobal(xmlDocPtr doc, xmlNodePtr cur) + +// Create a flow +static struct flow_t* createFlow( + char *flowName, + struct flow_t *parentFlow, + long int statsLen, + long int maxQueueSize, + long int maxQueueLen, + long int maxRate, + long int burstRate, + long int nfmark, + float parent_th, + int reportTimeout) { - char *className; - xmlNodePtr classNode; - GHashTable *classHash; - struct confClass_t *tempClass; - struct confClassAddress_t *tempClassAddress; - + int i; + struct flow_t *flow = (struct flow_t*) malloc(sizeof(struct flow_t)); - classHash = g_hash_table_new(g_str_hash,g_str_equal); - // We don't care what the top level element name is... - cur = cur->xmlChildrenNode; - while (cur) + // Check if its ok... + if (!flow) { - int validTag = 0; + // FIXME - log error + fprintf(stderr,"Failed to allocate memory for flow\n"); + return NULL; + } + // Lock entire flow + flow->lock = g_mutex_new(); + + strncpy(flow->flowName,flowName,MAX_REFLEN); // copy string + + flow->statsLen = statsLen; + flow->statsPos = 0; - // Check if we found a class - if (!xmlStrcmp(cur->name, (const xmlChar *) "class")) - { - className = xmlGetProp(cur, (const xmlChar *) "name"); - // We have found a class!! - if (className) - { - if (g_hash_table_lookup(classHash,className) == NULL) - { - // Allocate our class - tempClass = (struct confClass_t*) malloc(sizeof(struct confClass_t)); - tempClass->name = className; - tempClass->addresses = NULL; - - // Loop with class contents - classNode = cur->xmlChildrenNode; - while (classNode) - { + flow->parent = parentFlow; - // Check if we are infact doing an address - if (!xmlStrcmp(classNode->name, (const xmlChar *) "address")) - { - // Allocate a new address structure - tempClassAddress = (struct confClassAddress_t*) malloc(sizeof(struct confClassAddress_t)); - tempClassAddress->params = getProperties(classNode); - // FIXME - get this things name from the hash above - tempClassAddress->name = NULL; - // FIXME - we should parse the attribs here?? - - tempClass->addresses = g_list_append(tempClass->addresses,tempClassAddress); - } - // Advance "address" - classNode = classNode->next; - } - - // Create our ruleset - tempClass->ruleset = createClassRuleset(tempClass); - - // Add our class to the major list... - g_hash_table_insert(classHash,className,tempClass); - } - else - fprintf(stderr,"ERROR: Duplicate class found: %s\n",className); - } - else - fprintf(stderr,"ERROR: We found a class without a name\n"); - validTag = 1; - } + flow->maxQueueSize = maxQueueSize; + flow->maxQueueLen = maxQueueLen; + flow->maxRate = maxRate; + flow->burstRate = burstRate; + flow->nfmark = nfmark; - // Check if we found modules to load - if (!xmlStrcmp(cur->name, (const xmlChar *) "modules")) - validTag = 1; + flow->parent_th = parent_th; + + flow->counterTimeout = reportTimeout; + flow->counterRemaining = reportTimeout; - // And a plain text tag... - if (!xmlStrcmp(cur->name, (const xmlChar *) "text")) - validTag = 1; + flow->curQueueSize = 0; + flow->curQueueLen = 0; - // Check if we knew what the tag was - if (!validTag) - fprintf(stderr,"WARNING: Unknown tag %s in GLOBAL section\n",cur->name); - - // Advance "class" - cur = cur->next; - } + // Lock for our counters only + flow->counterLock = g_mutex_new(); + flow->counter.pktCount = 0; + flow->counter.pktSize = 0; + flow->counter.pktDropped = 0; + flow->counter.pktBursted = 0; - return(classHash); -} -/* }}} */ - -/* parsing functions - static GHashTab... [truncated message content] |
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); +} |
From: SVN C. <sv...@li...> - 2005-01-03 13:39:51
|
Author: nkukard Date: 2005-01-03 15:39:32 +0200 (Mon, 03 Jan 2005) New Revision: 21 Modified: trunk/bwm_firewall/bwm_firewall.c Log: * Change 1/4: Depletion of lib Modified: trunk/bwm_firewall/bwm_firewall.c =================================================================== --- trunk/bwm_firewall/bwm_firewall.c 2005-01-03 08:11:13 UTC (rev 20) +++ trunk/bwm_firewall/bwm_firewall.c 2005-01-03 13:39:32 UTC (rev 21) @@ -26,16 +26,20 @@ #include <glib.h> #include <errno.h> #include <fcntl.h> +#include <libxml/parser.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> +#include <time.h> #include <unistd.h> #include "../config.h" #include "common.h" #include "xmlConf.h" + + // return current date string like // Sun Jan 2 21:52:25 2005 static char *date2str(char *buffer) @@ -45,6 +49,160 @@ return buffer; } + +// Function to build a list of rules which iptables-restore takes +static GList *createFirewallRules(char *filename) +{ + xmlDocPtr doc; + xmlNodePtr cur; + GHashTable *classHash = NULL; + GHashTable *fwHash = NULL; + GList *result = NULL; + struct confACLTable_t *tmpTable; + struct confACLChain_t *aChain; + char *tableList[] = {"filter","mangle",NULL}; + char *tableName; + int i; + + + // Loop with a table + void processTable(gpointer p_key, gpointer p_value, gpointer p_user_data) + { + char *aRule; + char *tableName = (char *) p_key; + struct confACLTable_t *table = (struct confACLTable_t*) p_value; + + + // Create chains... + void processChains(gpointer p1_key, gpointer p1_value, gpointer p1_user_data) + { + struct confACLChain_t *chain = (struct confACLChain_t*) p1_value; + + + aRule = (char *) malloc0(BUFFER_SIZE); + // Check if we have a default target for the chain or not + if (chain->defaultTarget) + snprintf(aRule,BUFFER_SIZE,":%s %s\n",chain->name,chain->defaultTarget); + else + snprintf(aRule,BUFFER_SIZE,":%s -\n",chain->name); + result = g_list_append(result,aRule); + } + + // Print out rules + void processRules(gpointer p1_key, gpointer p1_value, gpointer p1_user_data) + { + struct confACLChain_t *chain = (struct confACLChain_t*) p1_value; + + + // And each item therein + void processRuleset(gpointer data, gpointer user_data) + { + char *rule = (char *) data; + + + aRule = (char *) malloc0(BUFFER_SIZE); + snprintf(aRule,BUFFER_SIZE,"%s\n",rule); + result = g_list_append(result,aRule); + } + + // Loop with all the ruleset items + g_list_foreach(chain->ruleset,processRuleset,NULL); + } + + + aRule = (char *) malloc0(BUFFER_SIZE); + snprintf(aRule,BUFFER_SIZE,"*%s\n",tableName); + result = g_list_append(result,aRule); + + // First generate chain names + g_hash_table_foreach(table->chains,processChains,NULL); + // Then the rules for the chains + g_hash_table_foreach(table->chains,processRules,NULL); + + aRule = (char *) malloc0(BUFFER_SIZE); + snprintf(aRule,BUFFER_SIZE,"COMMIT\n"); + result = g_list_append(result,aRule); + } + + + + // COMPAT: Do not genrate nodes for formatting spaces + LIBXML_TEST_VERSION + xmlKeepBlanksDefault(0); + + // FIXME - check if file exists + // Build an XML tree from a the file + doc = xmlParseFile(filename); + if (doc == NULL) + return(NULL); + + // Check the document is of the right kind + cur = xmlDocGetRootElement(doc); + if (cur == NULL) + { + fprintf(stderr,"ERROR: Empty document\n"); + xmlFreeDoc(doc); + return(NULL); + } + + // Check if we have the right root element & block + if (xmlStrcmp(cur->name, (const xmlChar *) "firewall")) + { + fprintf(stderr,"ERROR: Document of the wrong type, root node != firewall"); + xmlFreeDoc(doc); + return(NULL); + } + + + // Init everything... + fwHash = g_hash_table_new(g_str_hash,g_str_equal); + i = 0; + tableName = tableList[i]; + while (tableName) + { + // See if we have a table by this name + tmpTable = lookupTable(fwHash,tableName); + // Check if we already did the chain or not + aChain = lookupChain(tmpTable->chains,"INPUT"); + aChain->defaultTarget = "ACCEPT"; + aChain = lookupChain(tmpTable->chains,"FORWARD"); + aChain->defaultTarget = "ACCEPT"; + aChain = lookupChain(tmpTable->chains,"OUTPUT"); + aChain->defaultTarget = "ACCEPT"; + // Advance... + i++; + tableName = tableList[i]; + } + + // Walk the tree. + cur = cur->xmlChildrenNode; + while (cur) + { + // Try find sections + if (!xmlStrcmp(cur->name, (const xmlChar *) "global")) + classHash = parseGlobal(doc,cur); + if (!xmlStrcmp(cur->name, (const xmlChar *) "acl")) + parseACL(doc,cur,fwHash,classHash); + if (!xmlStrcmp(cur->name, (const xmlChar *) "nat")) + parseNAT(doc,cur,fwHash,classHash); + if (!xmlStrcmp(cur->name, (const xmlChar *) "traffic")) + parseTraffic(doc,cur,fwHash,classHash); + + // Next plz!! + cur = cur->next; + } + + + // Clean up everything else before quitting. + xmlCleanupParser(); + + // Build rule list + g_hash_table_foreach(fwHash,processTable,NULL); + + return(result); +} + + // Function to write firewall to file static int writeFirewall(GList *ruleList, char *filename) { @@ -80,7 +238,7 @@ buffer = (char *) malloc0(BUFFER_SIZE); // Write out comment to say what version & at what datetime we generated the firewall - snprintf(buffer,BUFFER_SIZE,"# Generated using BWM Firewall v%s: %s\n",PACKAGE_VERSION, date2str(&datetime)); + snprintf(buffer,BUFFER_SIZE,"# Generated using BWM Firewall v%s: %s\n",PACKAGE_VERSION, date2str((char *) &datetime)); write(fd,buffer,strlen(buffer)); // Loop with all rules |
From: SVN C. <sv...@li...> - 2005-01-03 08:11:45
|
Author: nkukard Date: 2005-01-03 10:11:13 +0200 (Mon, 03 Jan 2005) New Revision: 20 Added: trunk/bwmd/logging.c Modified: trunk/bwmd/Makefile.am trunk/bwmd/Makefile.in trunk/config.h.in trunk/configure trunk/configure.ac Log: * Giang Hu <fre...@gm...> - Added logging API to bwmd * Updated configure scripts to reflect header requirements Modified: trunk/bwmd/Makefile.am =================================================================== --- trunk/bwmd/Makefile.am 2005-01-03 06:29:39 UTC (rev 19) +++ trunk/bwmd/Makefile.am 2005-01-03 08:11:13 UTC (rev 20) @@ -28,7 +28,7 @@ LOG_DIR=/var/bwm_tools bin_PROGRAMS = bwmd -bwmd_SOURCES = report.c flowControl.c bwmd.c +bwmd_SOURCES = report.c flowControl.c bwmd.c logging.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 06:29:39 UTC (rev 19) +++ trunk/bwmd/Makefile.in 2005-01-03 08:11:13 UTC (rev 20) @@ -70,7 +70,7 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_bwmd_OBJECTS = bwmd-report.$(OBJEXT) bwmd-flowControl.$(OBJEXT) \ - bwmd-bwmd.$(OBJEXT) + bwmd-bwmd.$(OBJEXT) bwmd-logging.$(OBJEXT) bwmd_OBJECTS = $(am_bwmd_OBJECTS) bwmd_DEPENDENCIES = $(top_builddir)/lib/libbwm.la DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) @@ -200,7 +200,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 +bwmd_SOURCES = report.c flowControl.c bwmd.c logging.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) @@ -277,6 +277,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bwmd-bwmd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bwmd-flowControl.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@ .c.o: @@ -342,6 +343,20 @@ @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/logging.c =================================================================== --- trunk/bwmd/logging.c 2005-01-03 06:29:39 UTC (rev 19) +++ trunk/bwmd/logging.c 2005-01-03 08:11:13 UTC (rev 20) @@ -0,0 +1,64 @@ +/* + * logging.c - Logging support 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 + * + * 03/01/2005 - Giang Hu <fre...@gm...> + * * Initial design +*/ + +#include <stdarg.h> +#include <stdio.h> +#include <syslog.h> + + + +char using_syslog = 0; + + +// Initialize syslog +void initSyslog(const char *ident, int prioMask) +{ + if (!using_syslog) + { + openlog(ident, LOG_CONS, LOG_DAEMON); + setlogmask(LOG_UPTO(prioMask)); + using_syslog = 1; + } +} + + +// Log message +void logMessage(int priority, const char *fmt, ...) +{ + va_list args; + + + va_start(args, fmt); + + // Check if we using syslog... + if (using_syslog) + vsyslog(priority, fmt, args); + // If not and priority is low.. stdout + else if (priority == 0) + vfprintf(stdout, fmt, args); + // If priority is high, stderr + else + vfprintf(stderr, fmt, args); + + va_end(args); +} + Modified: trunk/config.h.in =================================================================== --- trunk/config.h.in 2005-01-03 06:29:39 UTC (rev 19) +++ trunk/config.h.in 2005-01-03 08:11:13 UTC (rev 20) @@ -24,6 +24,9 @@ /* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + /* Define to 1 if you have the <fcntl.h> header file. */ #undef HAVE_FCNTL_H @@ -108,6 +111,9 @@ /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP +/* Define to 1 if you have the <syslog.h> header file. */ +#undef HAVE_SYSLOG_H + /* Define to 1 if you have the <sys/select.h> header file. */ #undef HAVE_SYS_SELECT_H @@ -129,6 +135,9 @@ /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL @@ -180,6 +189,9 @@ /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ #undef TIME_WITH_SYS_TIME +/* Define to 1 if your <sys/time.h> declares `struct tm'. */ +#undef TM_IN_SYS_TIME + /* Version number of package */ #undef VERSION @@ -191,6 +203,12 @@ /* Define to empty if `const' does not conform to ANSI C. */ #undef const +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc Modified: trunk/configure =================================================================== --- trunk/configure 2005-01-03 06:29:39 UTC (rev 19) +++ trunk/configure 2005-01-03 08:11:13 UTC (rev 20) @@ -19886,7 +19886,8 @@ -for ac_header in arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h + +for ac_header in arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h syslog.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then @@ -20302,6 +20303,77 @@ fi +echo "$as_me:$LINENO: checking for inline" >&5 +echo $ECHO_N "checking for inline... $ECHO_C" >&6 +if test "${ac_cv_c_inline+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_inline=$ac_kw; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 +echo "${ECHO_T}$ac_cv_c_inline" >&6 + + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + echo "$as_me:$LINENO: checking for size_t" >&5 echo $ECHO_N "checking for size_t... $ECHO_C" >&6 if test "${ac_cv_type_size_t+set}" = set; then @@ -20433,7 +20505,70 @@ fi +echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5 +echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6 +if test "${ac_cv_struct_tm+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +#include <time.h> +int +main () +{ +struct tm *tp; tp->tm_sec; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_struct_tm=time.h +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_struct_tm=sys/time.h +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5 +echo "${ECHO_T}$ac_cv_struct_tm" >&6 +if test $ac_cv_struct_tm = sys/time.h; then + +cat >>confdefs.h <<\_ACEOF +#define TM_IN_SYS_TIME 1 +_ACEOF + +fi + + # Checks for library functions. # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! @@ -22355,16 +22490,217 @@ done +for ac_func in vprintf +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif +#undef $ac_func +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF +echo "$as_me:$LINENO: checking for _doprnt" >&5 +echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6 +if test "${ac_cv_func__doprnt+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define _doprnt to an innocuous variant, in case <limits.h> declares _doprnt. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define _doprnt innocuous__doprnt +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char _doprnt (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif +#undef _doprnt + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char _doprnt (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub__doprnt) || defined (__stub____doprnt) +choke me +#else +char (*f) () = _doprnt; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != _doprnt; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func__doprnt=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func__doprnt=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 +echo "${ECHO_T}$ac_cv_func__doprnt" >&6 +if test $ac_cv_func__doprnt = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DOPRNT 1 +_ACEOF + +fi + +fi +done + + + + + + + + + + + + + for ac_func in gettimeofday inet_ntoa memset select socket strcasecmp strchr strdup strerror strncasecmp strndup do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2005-01-03 06:29:39 UTC (rev 19) +++ trunk/configure.ac 2005-01-03 08:11:13 UTC (rev 20) @@ -65,13 +65,15 @@ # Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h]) +AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h syslog.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST +AC_C_INLINE AC_TYPE_SIZE_T AC_HEADER_TIME +AC_STRUCT_TM # Checks for library functions. AC_FUNC_ALLOCA @@ -82,6 +84,7 @@ AC_TYPE_SIGNAL AC_FUNC_STAT AC_FUNC_STRFTIME +AC_FUNC_VPRINTF AC_CHECK_FUNCS([gettimeofday inet_ntoa memset select socket strcasecmp strchr strdup strerror strncasecmp strndup]) # Custom |
From: SVN C. <sv...@li...> - 2005-01-03 06:30:12
|
Author: nkukard Date: 2005-01-03 08:29:39 +0200 (Mon, 03 Jan 2005) New Revision: 19 Modified: trunk/bwm_monitor/bwm_monitor.c Log: * Giang Hu <fre...@gm...> - Fixed timeout to 250ms, added break out of select if we fail Modified: trunk/bwm_monitor/bwm_monitor.c =================================================================== --- trunk/bwm_monitor/bwm_monitor.c 2005-01-02 15:45:54 UTC (rev 18) +++ trunk/bwm_monitor/bwm_monitor.c 2005-01-03 06:29:39 UTC (rev 19) @@ -82,7 +82,7 @@ // Set our timeout to half a second timeout.tv_sec = 0; - timeout.tv_usec = 500; + timeout.tv_usec = 250000; read_fds = master_fds; @@ -127,6 +127,11 @@ wrefresh(win); } + else + { // socket has been closed or error occured + // FIXME - set error message + break; + } // Check if we got a keypress if (wgetch(win) != ERR) |
From: SVN C. <sv...@li...> - 2005-01-02 15:46:08
|
Author: nkukard Date: 2005-01-02 17:45:54 +0200 (Sun, 02 Jan 2005) New Revision: 18 Modified: trunk/lib/misc.c Log: * Giang Hu <fre...@gm...> - Reworked parseDateTime function, the old one was a bit insane Modified: trunk/lib/misc.c =================================================================== --- trunk/lib/misc.c 2005-01-02 15:32:38 UTC (rev 17) +++ trunk/lib/misc.c 2005-01-02 15:45:54 UTC (rev 18) @@ -51,121 +51,34 @@ // Convert datetime format into unix time format int parseDateTime(char *dateTime) { - char *sday, *smonth, *syear, *shour, *sminute, *ssecond; int day = 0, month = 0, year = 0, hour = 0, minute = 0, second = 0; struct tm time_p; int ret; - - - // Convert all values we need - sday = dateTime; - if (!sday) - { - fprintf(stderr,"ERROR: Failed to find \"day\" in date specified - %s",dateTime); - return -1; - } - - smonth = strchr(sday,'/'); - if (!smonth) - { - fprintf(stderr,"ERROR: Failed to find \"month\" in date specified - %s",dateTime); - return -1; - } - smonth++; + - // Now we have the next marker, we can process the prev variable - day = aptrtoi(sday,smonth); - - syear = strchr(smonth,'/'); - if (!syear) - { - fprintf(stderr,"ERROR: Failed to find \"year\" in date specified - %s",dateTime); - return -1; - } - syear++; + // Scan datetime provided and get our variables + sscanf(dateTime, "%d/%d/%d %d:%d:%d", &day, &month, &year, &hour, + &minute, &second); - // And so forth - month = aptrtoi(smonth,syear); - - // Here we have a shorter version, we don't really need hour/min/sec - shour = strchr(syear,' '); - if (shour) - shour++; - - year = aptrtoi(syear,shour); - - - // Check if we have an hour - if (shour) + // Check if we have an acceptable number of variables scanned + if ( ret == 3 || ret == 5 || ret == 6 ) { - // Same for minutes - sminute = strchr(shour,':'); - if (sminute) - sminute++; - hour = aptrtoi(shour,sminute); - - // And seconds - if (sminute) - { - ssecond = strchr(sminute,':'); - if (ssecond) - ssecond++; - - minute = aptrtoi(sminute,ssecond); - - second = aptrtoi(ssecond,NULL); - } + time_p.tm_mday = day; + time_p.tm_mon = month - 1; // Months since Jan + time_p.tm_year = year - 1900; // Years since 1900 + time_p.tm_hour = hour; + time_p.tm_min = minute; + time_p.tm_sec = second; + ret = mktime(&time_p); } + else + ret = -1; - - // Check all is ok... - if (day <= 0 || day > 31) - { - fprintf(stderr,"Failed to get DAY: %i\n",day); - return -1; - } + // If we encountered an error.. complain + if (ret == -1) + fprintf(stderr,"ERROR: Failed to convert %s to date time",dateTime); - if (month <= 0 || month > 12) - { - fprintf(stderr,"Failed to get MONTH: %i\n",month); - return -1; - } - - if (year <= 0) - { - fprintf(stderr,"Failed to get YEAR: %i\n",year); - return -1; - } - - if (hour < 0 || hour > 23) - { - fprintf(stderr,"Failed to get HOUR: %i\n",hour); - return -1; - } - - if (minute < 0 || minute > 59) - { - fprintf(stderr,"Failed to get MINUTE: %i\n",minute); - return -1; - } - - if (second < 0 || second > 59) - { - fprintf(stderr,"Failed to get SECOND: %i\n",second); - return -1; - } - - // Setup our struct - time_p.tm_mday = day; - time_p.tm_mon = month - 1; // Months since Jan - time_p.tm_year = year - 1900; // Years since 1900 - time_p.tm_hour = hour; - time_p.tm_min = minute; - time_p.tm_sec = second; - - // Return our time construction - ret = mktime(&time_p); - return(ret); + return ret; } |
From: SVN C. <sv...@li...> - 2005-01-02 15:33:06
|
Author: nkukard Date: 2005-01-02 17:32:38 +0200 (Sun, 02 Jan 2005) New Revision: 17 Modified: trunk/bwm_firewall/bwm_firewall.c Log: * Giang Hu <fre...@gm...> - Added datetime stamp to generated iptables firewall Modified: trunk/bwm_firewall/bwm_firewall.c =================================================================== --- trunk/bwm_firewall/bwm_firewall.c 2005-01-01 06:56:51 UTC (rev 16) +++ trunk/bwm_firewall/bwm_firewall.c 2005-01-02 15:32:38 UTC (rev 17) @@ -36,14 +36,21 @@ #include "common.h" #include "xmlConf.h" +// return current date string like +// Sun Jan 2 21:52:25 2005 +static char *date2str(char *buffer) +{ + time_t t = time(NULL); + sprintf(buffer, "%s", ctime(&t)); + return buffer; +} - // Function to write firewall to file static int writeFirewall(GList *ruleList, char *filename) { int fd; int fuct = 0; - char *buffer; + char *buffer, datetime[32]; // Write rule by rule to file @@ -72,8 +79,8 @@ } buffer = (char *) malloc0(BUFFER_SIZE); - // FIXME - add date - snprintf(buffer,BUFFER_SIZE,"# Generated using BWM Firewall v%s: %s\n",PACKAGE_VERSION,"DATE"); + // Write out comment to say what version & at what datetime we generated the firewall + snprintf(buffer,BUFFER_SIZE,"# Generated using BWM Firewall v%s: %s\n",PACKAGE_VERSION, date2str(&datetime)); write(fd,buffer,strlen(buffer)); // Loop with all rules |
From: SVN C. <sv...@li...> - 2005-01-01 07:40:45
|
Author: nkukard Date: 2005-01-01 08:56:51 +0200 (Sat, 01 Jan 2005) New Revision: 16 Modified: trunk/TODO trunk/bwmd/report.c Log: * After speaking to Giang Hu <fre...@gm...> I've updated the TODO list to reflect our discussions * Committed patch from Giang Hu <fre...@gm...> which fixes typo in bwmd/report.c * Made bwmd/report.c more verbose with its error messages Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-01-01 06:54:26 UTC (rev 15) +++ trunk/TODO 2005-01-01 06:56:51 UTC (rev 16) @@ -12,3 +12,10 @@ netlink syn, not async * Add maxRate graphing to graph.c * Add shared mem resizing to stats.c +* Add menu to bwm_monitor to which IP it wants to connect to, authentication aswell and default + to localhost +* bwm_firewall to generate automatic MARK values for flows +* fix parseDateTime, this is the messiest function! +* fix findFlowByName & findGroupByName, these 2 functions are similar and i'm sure can be merged +* have the location of iptables-restore automatically discovered using ./configure, with override options +* make bwm_firewall able to reload the firewall into kernel using iptables-restore Modified: trunk/bwmd/report.c =================================================================== --- trunk/bwmd/report.c 2005-01-01 06:54:26 UTC (rev 15) +++ trunk/bwmd/report.c 2005-01-01 06:56:51 UTC (rev 16) @@ -66,7 +66,7 @@ opRes = read(fd,&fileHeader,sizeof(struct aLogFileHeader_t)); if (opRes != sizeof(struct aLogFileHeader_t)) { - fprintf(stderr,"Error reading header: %s\n",strerror(errno)); + fprintf(stderr,"Error reading header from \"%s\": %s\n",filename,strerror(errno)); err = 1; } // If no errors seek... @@ -76,7 +76,7 @@ opRes = lseek(fd,0,SEEK_END); if (opRes < 0) { - fprintf(stderr,"Error seeking end %s\n",strerror(errno)); + fprintf(stderr,"Error seeking end of file \"%s\": %s\n",filename,strerror(errno)); err = 1; } } @@ -87,7 +87,7 @@ opRes = write(fd,&reportData->entry,sizeof(struct aLogFileEntry_t)); if (opRes != sizeof(struct aLogFileEntry_t)) { - fprintf(stderr,"Error writing record: %s\n",strerror(errno)); + fprintf(stderr,"Error writing record to file \"%s\": %s\n",filename,strerror(errno)); err = 1; } else @@ -107,7 +107,7 @@ opRes = lseek(fd,0,SEEK_SET); if (opRes < 0) { - fprintf(stderr,"Error seeking end %s\n",strerror(errno)); + fprintf(stderr,"Error seeking beginning of file \"%s\": %s\n",filename,strerror(errno)); err = 1; } } @@ -118,14 +118,14 @@ opRes = write(fd,&fileHeader,sizeof(struct aLogFileHeader_t)); if (opRes != sizeof(struct aLogFileHeader_t)) { - fprintf(stderr,"Error writing header: %s\n",strerror(errno)); + fprintf(stderr,"Error writing header to file \"%s\": %s\n",filename,strerror(errno)); err = 1; } } close(fd); } else - fprintf(stderr,"Stat error: %s\n",strerror(errno)); + fprintf(stderr,"Stat error on \"%s\": %s\n",filename,strerror(errno)); } else { @@ -148,7 +148,7 @@ opRes = write(fd,&fileHeader,sizeof(struct aLogFileHeader_t)); if (opRes != sizeof(struct aLogFileHeader_t)) { - fprintf(stderr,"Error writing header: %s\n",strerror(errno)); + fprintf(stderr,"Error writing header to \"%s\": %s\n",filename,strerror(errno)); err = 1; } // If no errors write more... @@ -157,17 +157,17 @@ opRes = write(fd,&reportData->entry,sizeof(struct aLogFileEntry_t)); if (opRes != sizeof(struct aLogFileEntry_t)) { - fprintf(stderr,"Error writing record: %s\n",strerror(errno)); + fprintf(stderr,"Error writing record to \"%s\": %s\n",filename,strerror(errno)); err = 1; } } close(fd); } else - fprintf(stderr,"Stat error: %s\n",strerror(errno)); + fprintf(stderr,"Stat error on \"%s\": %s\n",filename,strerror(errno)); } else - fprintf(stderr,"Open failed: %s\n",strerror(errno)); + fprintf(stderr,"Failed to open file \"%s\": %s\n",filename,strerror(errno)); } return(NULL); |