aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2002-06-17 16:29:46 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2002-06-17 16:29:46 +0000
commit62176f9106865ca4bd1baf0627dc8b5f6b14fa65 (patch)
treec229a37cec373f39e4c4aa541df822b1ae757a0e /src
parent5573851a1130e1f4dfbce8ccce752878b413ac99 (diff)
downloadipacct-62176f9106865ca4bd1baf0627dc8b5f6b14fa65.tar.gz
ipacct-62176f9106865ca4bd1baf0627dc8b5f6b14fa65.tar.bz2
Added verbose diagnostics printing.
(_account_check_stream): Bugfix.
Diffstat (limited to 'src')
-rw-r--r--src/account.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/account.c b/src/account.c
index 511d356..206dd57 100644
--- a/src/account.c
+++ b/src/account.c
@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* $Id: account.c,v 1.3 2002/06/16 23:11:33 gray Exp $ */
+/* $Id: account.c,v 1.4 2002/06/17 16:29:46 gray Exp $ */
#if defined(HAVE_CONFIG_H)
# include <config.h>
#endif
@@ -99,11 +99,21 @@ _network_match(networkp, ipdatap)
{
network_t *np = (network_t*)networkp;
struct ipdata *ipd = (struct ipdata*)ipdatap;
-
+
+ if (verbose > 1) {
+ char buf1[16], buf2[16];
+ printf("# comparing %s/%s",
+ ipaddr2str(buf1, np->addr),
+ ipaddr2str(buf2, np->netmask));
+ }
if (np->addr == (ipd->addr[ipd->dir] & np->netmask)) {
+ if (verbose > 1)
+ printf(" OK\n");
ipd->match++;
return 1;
}
+ if (verbose > 1)
+ printf(" no\n");
return 0;
}
@@ -113,10 +123,16 @@ lookup_address(flow, ipd)
struct ipdata *ipd;
{
ipd->match = 0;
+ if (verbose > 1)
+ printf("# trying source flow:\n");
ipd->dir = DIR_SRC;
list_iterate(flow->src, _network_match, ipd);
+ if (verbose > 1)
+ printf("# trying dest flow:\n");
ipd->dir = DIR_DST;
list_iterate(flow->dst, _network_match, ipd);
+ if (verbose > 1)
+ printf("# %d matches\n", ipd->match);
return ipd->match == 2;
}
@@ -136,7 +152,7 @@ _account_check_stream(streamp, ipp)
if (lookup_address(&stream->direct, ipd)
&& !lookup_address(&stream->except, ipd)) {
/*FIXME: bytes shoud be ctr[2] */
- if (ipd->dir == DIR_SRC)
+ if (stream->dir == DIR_SRC)
ipd->stat->bytes.out += ipd->length;
else
ipd->stat->bytes.in += ipd->length;
@@ -155,6 +171,8 @@ _account_check_stat(statp, ipp)
struct ipdata *ipd = (struct ipdata *)ipp;
ipd->stat = statp;
+ if (verbose > 1)
+ printf("# stat %s\n", ipd->stat->name);
list_iterate(ipd->stat->streams, _account_check_stream, ipd);
return 0;
}
@@ -167,6 +185,12 @@ account(ip)
ipd.ip = ip;
ipd.length = ntohs(ip->ip_len);
+ if (verbose > 1) {
+ char buf1[16], buf2[16];
+ printf("# from %s to %s\n",
+ ipaddr2str(buf1, ip->ip_src.s_addr),
+ ipaddr2str(buf2, ip->ip_dst.s_addr));
+ }
list_iterate(targets, _account_check_stat, &ipd);
}
@@ -318,6 +342,7 @@ test_shell()
continue;
case '?':
printf("p SRC DEST [LEN]\n");
+ printf("v {NUM|?}\n");
printf("q\n");
break;
case 'p':
@@ -332,6 +357,12 @@ test_shell()
ip.ip_len = htons(ip.ip_len);
account(&ip);
break;
+ case 'v':
+ if (tok[0] == '?')
+ printf("verbose is %d\n", verbose);
+ else
+ verbose = atoi(tok);
+ break;
case 'q':
return 0;
default:

Return to:

Send suggestions and report system problems to the System administrator.