This patch implements user configurable
categories/ports for traffic tracking.
The patch is against the 1.2.0b version. To apply it
the following sequence of commands can be used:
$ tar xzf bandwidthd-1.2.0b.tgz
$ cd bandwidthd-1.2.0b
$ zcat ../configurable-ports-v2.patch.gz | patch -p1
The main changes are:
- Now the etc/bandwidthd.conf has a new "item" (could be
replaced by something more meaningfull) option that
describes a class of traffic to be monitored. I
the syntax is straightfoward.
- The management of these configuration data is done
using a couple of linked lists and a hash table
implemented at the new tables.h and tables.c files.
- The htdocs/legend.gif file is replaced by a
htdocs/legend.png one rebuilt at runtime based on the
given configuration. A new function named drawLegend()
in bandwidthd.c does the magic.
- The Statistics and IPData structS where changed to
support the new design.
- The GraphData() function suffered some major changes.
- The CDF file format now depends on the number of
configured itens and should be erased on configuration
The default configuration file more or less reproduces
the old behavior, but old data files need to be
converted to the new format. It shouldn't be difficult
to write a simple script to do that conversion.
My first intention was to make the configuration
completely dynamic, but the IPC structures made this a
difficult task. So, the number of items is limited by
the MAX_ITENS configuration option in bandwidthd.h.
The hash table size is configurable by simultaneously
modifying the HASH_TABLE_SIZE and HASH_TABLE_MASK
options in tables.h. The hash function (if it can be
called so) is only a simple bitmask. A more
sophisticated one could be used, but I saw no obvious
reason for it.