Commit 974b8e0c authored by Arne Øslebø's avatar Arne Øslebø
Browse files

added support for selecting which interface to use

git-svn-id: file:///home/svn/mapi/trunk@351 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent f6db428a
......@@ -14,7 +14,7 @@ void track_dns(void)
}
else
{
dns.fd = mapi_create_flow("eth0");
dns.fd = mapi_create_flow(DEVICE);
}
dns.filter = mapi_apply_function(dns.fd, "BPF_FILTER", "port 53");
......@@ -29,7 +29,7 @@ void track_dns(void)
{
sleep(2);
res = (int *)mapi_read_results(dns.fd, dns.pkt_counter, 1);
res = (int *)mapi_read_results(dns.fd, dns.pkt_counter);
if(res)
{
......@@ -38,7 +38,7 @@ void track_dns(void)
}
res = (int *)mapi_read_results(dns.fd, dns.byte_counter, 1);
res = (int *)mapi_read_results(dns.fd, dns.byte_counter);
if(res)
......
......@@ -15,7 +15,7 @@ void track_eigrp(void)
}
else
{
eigrp.fd = mapi_create_flow("eth0");
eigrp.fd = mapi_create_flow(DEVICE);
}
eigrp.filter = mapi_apply_function(eigrp.fd, "BPF_FILTER", "proto eigrp");//"ip[18] & 88 == 0");
......@@ -32,7 +32,7 @@ void track_eigrp(void)
sleep(2);
res = (int *)mapi_read_results(eigrp.fd, eigrp.pkt_counter, 1);
res = (int *)mapi_read_results(eigrp.fd, eigrp.pkt_counter);
if(res)
......@@ -42,7 +42,7 @@ void track_eigrp(void)
}
res = (int *)mapi_read_results(eigrp.fd, eigrp.byte_counter, 1);
res = (int *)mapi_read_results(eigrp.fd, eigrp.byte_counter);
if(res)
......
......@@ -15,7 +15,7 @@ void track_ip(void)
}
else
{
ip.fd = mapi_create_flow("eth0");
ip.fd = mapi_create_flow(DEVICE);
}
ip.filter = mapi_apply_function(ip.fd, "BPF_FILTER", "ip");
......@@ -30,7 +30,7 @@ void track_ip(void)
{
sleep(2);
res = (int *)mapi_read_results(ip.fd, ip.pkt_counter, 1);
res = (int *)mapi_read_results(ip.fd, ip.pkt_counter);
if(res)
{
......@@ -38,7 +38,7 @@ void track_ip(void)
res = NULL;
}
res = (int *)mapi_read_results(ip.fd, ip.byte_counter, 1);
res = (int *)mapi_read_results(ip.fd, ip.byte_counter);
if(res)
{
......@@ -70,7 +70,7 @@ void track_ip6(void)
}
else
{
ip6.fd = mapi_create_flow("eth0");
ip6.fd = mapi_create_flow(DEVICE);
}
ip6.filter = mapi_apply_function(ip6.fd, "BPF_FILTER", "ip6");
......@@ -85,7 +85,7 @@ void track_ip6(void)
{
sleep(2);
res = (int *)mapi_read_results(ip6.fd, ip6.pkt_counter, 1);
res = (int *)mapi_read_results(ip6.fd, ip6.pkt_counter);
if(res)
{
......@@ -93,7 +93,7 @@ void track_ip6(void)
res = NULL;
}
res = (int *)mapi_read_results(ip6.fd, ip6.byte_counter, 1);
res = (int *)mapi_read_results(ip6.fd, ip6.byte_counter);
if(res)
{
......@@ -124,7 +124,7 @@ void track_arp(void)
}
else
{
arp.fd = mapi_create_flow("eth0");
arp.fd = mapi_create_flow(DEVICE);
}
arp.filter = mapi_apply_function(arp.fd, "BPF_FILTER", "arp");
......@@ -139,7 +139,7 @@ void track_arp(void)
{
sleep(2);
res = (int *)mapi_read_results(arp.fd, arp.pkt_counter, 1);
res = (int *)mapi_read_results(arp.fd, arp.pkt_counter);
if(res)
{
......@@ -147,7 +147,7 @@ void track_arp(void)
res = NULL;
}
res = (int *)mapi_read_results(arp.fd, arp.byte_counter, 1);
res = (int *)mapi_read_results(arp.fd, arp.byte_counter);
if(res)
{
......@@ -178,7 +178,7 @@ void track_rarp(void)
}
else
{
rarp.fd = mapi_create_flow("eth0");
rarp.fd = mapi_create_flow(DEVICE);
}
rarp.filter = mapi_apply_function(rarp.fd, "BPF_FILTER", "rarp");
......@@ -193,7 +193,7 @@ void track_rarp(void)
{
sleep(2);
res = (int *)mapi_read_results(rarp.fd, rarp.pkt_counter, 1);
res = (int *)mapi_read_results(rarp.fd, rarp.pkt_counter);
if(res)
{
......@@ -201,7 +201,7 @@ void track_rarp(void)
res = NULL;
}
res = (int *)mapi_read_results(rarp.fd, rarp.byte_counter, 1);
res = (int *)mapi_read_results(rarp.fd, rarp.byte_counter);
if(res)
{
......@@ -232,7 +232,7 @@ void track_atalk(void)
}
else
{
atalk.fd = mapi_create_flow("eth0");
atalk.fd = mapi_create_flow(DEVICE);
}
atalk.filter = mapi_apply_function(atalk.fd, "BPF_FILTER", "atalk");
......@@ -247,7 +247,7 @@ void track_atalk(void)
{
sleep(2);
res = (int *)mapi_read_results(atalk.fd, atalk.pkt_counter, 1);
res = (int *)mapi_read_results(atalk.fd, atalk.pkt_counter);
if(res)
{
......@@ -255,7 +255,7 @@ void track_atalk(void)
res = NULL;
}
res = (int *)mapi_read_results(atalk.fd, atalk.byte_counter, 1);
res = (int *)mapi_read_results(atalk.fd, atalk.byte_counter);
if(res)
{
......@@ -286,7 +286,7 @@ void track_aarp(void)
}
else
{
aarp.fd = mapi_create_flow("eth0");
aarp.fd = mapi_create_flow(DEVICE);
}
aarp.filter = mapi_apply_function(aarp.fd, "BPF_FILTER", "aarp");
......@@ -301,7 +301,7 @@ void track_aarp(void)
{
sleep(2);
res = (int *)mapi_read_results(aarp.fd, aarp.pkt_counter, 1);
res = (int *)mapi_read_results(aarp.fd, aarp.pkt_counter);
if(res)
{
......@@ -309,7 +309,7 @@ void track_aarp(void)
res = NULL;
}
res = (int *)mapi_read_results(aarp.fd, aarp.byte_counter, 1);
res = (int *)mapi_read_results(aarp.fd, aarp.byte_counter);
if(res)
{
......@@ -340,7 +340,7 @@ void track_decnet(void)
}
else
{
decnet.fd = mapi_create_flow("eth0");
decnet.fd = mapi_create_flow(DEVICE);
}
decnet.filter = mapi_apply_function(decnet.fd, "BPF_FILTER", "decnet");
......@@ -355,7 +355,7 @@ void track_decnet(void)
{
sleep(2);
res = (int *)mapi_read_results(decnet.fd, decnet.pkt_counter, 1);
res = (int *)mapi_read_results(decnet.fd, decnet.pkt_counter);
if(res)
{
......@@ -363,7 +363,7 @@ void track_decnet(void)
res = NULL;
}
res = (int *)mapi_read_results(decnet.fd, decnet.byte_counter, 1);
res = (int *)mapi_read_results(decnet.fd, decnet.byte_counter);
if(res)
{
......@@ -394,7 +394,7 @@ void track_iso(void)
}
else
{
iso.fd = mapi_create_flow("eth0");
iso.fd = mapi_create_flow(DEVICE);
}
iso.filter = mapi_apply_function(iso.fd, "BPF_FILTER", "iso");
......@@ -409,7 +409,7 @@ void track_iso(void)
{
sleep(2);
res = (int *)mapi_read_results(iso.fd, iso.pkt_counter, 1);
res = (int *)mapi_read_results(iso.fd, iso.pkt_counter);
if(res)
{
......@@ -417,7 +417,7 @@ void track_iso(void)
res = NULL;
}
res = (int *)mapi_read_results(iso.fd, iso.byte_counter, 1);
res = (int *)mapi_read_results(iso.fd, iso.byte_counter);
if(res)
{
......@@ -448,7 +448,7 @@ void track_stp(void)
}
else
{
stp.fd = mapi_create_flow("eth0");
stp.fd = mapi_create_flow(DEVICE);
}
stp.filter = mapi_apply_function(stp.fd, "BPF_FILTER", "stp");
......@@ -463,7 +463,7 @@ void track_stp(void)
{
sleep(2);
res = (int *)mapi_read_results(stp.fd, stp.pkt_counter, 1);
res = (int *)mapi_read_results(stp.fd, stp.pkt_counter);
if(res)
{
......@@ -471,7 +471,7 @@ void track_stp(void)
res = NULL;
}
res = (int *)mapi_read_results(stp.fd, stp.byte_counter, 1);
res = (int *)mapi_read_results(stp.fd, stp.byte_counter);
if(res)
{
......@@ -502,7 +502,7 @@ void track_ipx(void)
}
else
{
ipx.fd = mapi_create_flow("eth0");
ipx.fd = mapi_create_flow(DEVICE);
}
ipx.filter = mapi_apply_function(ipx.fd, "BPF_FILTER", "ipx");
......@@ -517,7 +517,7 @@ void track_ipx(void)
{
sleep(2);
res = (int *)mapi_read_results(ipx.fd, ipx.pkt_counter, 1);
res = (int *)mapi_read_results(ipx.fd, ipx.pkt_counter);
if(res)
{
......@@ -525,7 +525,7 @@ void track_ipx(void)
res = NULL;
}
res = (int *)mapi_read_results(ipx.fd, ipx.byte_counter, 1);
res = (int *)mapi_read_results(ipx.fd, ipx.byte_counter);
if(res)
{
......@@ -556,7 +556,7 @@ void track_sca(void)
}
else
{
sca.fd = mapi_create_flow("eth0");
sca.fd = mapi_create_flow(DEVICE);
}
sca.filter = mapi_apply_function(sca.fd, "BPF_FILTER", "sca");
......@@ -571,7 +571,7 @@ void track_sca(void)
{
sleep(2);
res = (int *)mapi_read_results(sca.fd, sca.pkt_counter, 1);
res = (int *)mapi_read_results(sca.fd, sca.pkt_counter);
if(res)
{
......@@ -579,7 +579,7 @@ void track_sca(void)
res = NULL;
}
res = (int *)mapi_read_results(sca.fd, sca.byte_counter, 1);
res = (int *)mapi_read_results(sca.fd, sca.byte_counter);
if(res)
{
......@@ -610,7 +610,7 @@ void track_lat(void)
}
else
{
lat.fd = mapi_create_flow("eth0");
lat.fd = mapi_create_flow(DEVICE);
}
lat.filter = mapi_apply_function(lat.fd, "BPF_FILTER", "lat");
......@@ -625,7 +625,7 @@ void track_lat(void)
{
sleep(2);
res = (int *)mapi_read_results(lat.fd, lat.pkt_counter, 1);
res = (int *)mapi_read_results(lat.fd, lat.pkt_counter);
if(res)
{
......@@ -633,7 +633,7 @@ void track_lat(void)
res = NULL;
}
res = (int *)mapi_read_results(lat.fd, lat.byte_counter, 1);
res = (int *)mapi_read_results(lat.fd, lat.byte_counter);
if(res)
{
......@@ -664,7 +664,7 @@ void track_mopdl(void)
}
else
{
mopdl.fd = mapi_create_flow("eth0");
mopdl.fd = mapi_create_flow(DEVICE);
}
mopdl.filter = mapi_apply_function(mopdl.fd, "BPF_FILTER", "mopdl");
......@@ -679,7 +679,7 @@ void track_mopdl(void)
{
sleep(2);
res = (int *)mapi_read_results(mopdl.fd, mopdl.pkt_counter, 1);
res = (int *)mapi_read_results(mopdl.fd, mopdl.pkt_counter);
if(res)
{
......@@ -687,7 +687,7 @@ void track_mopdl(void)
res = NULL;
}
res = (int *)mapi_read_results(mopdl.fd, mopdl.byte_counter, 1);
res = (int *)mapi_read_results(mopdl.fd, mopdl.byte_counter);
if(res)
{
......@@ -718,7 +718,7 @@ void track_moprc(void)
}
else
{
moprc.fd = mapi_create_flow("eth0");
moprc.fd = mapi_create_flow(DEVICE);
}
moprc.filter = mapi_apply_function(moprc.fd, "BPF_FILTER", "moprc");
......@@ -733,7 +733,7 @@ void track_moprc(void)
{
sleep(2);
res = (int *)mapi_read_results(moprc.fd, moprc.pkt_counter, 1);
res = (int *)mapi_read_results(moprc.fd, moprc.pkt_counter);
if(res)
{
......@@ -741,7 +741,7 @@ void track_moprc(void)
res = NULL;
}
res = (int *)mapi_read_results(moprc.fd, moprc.byte_counter, 1);
res = (int *)mapi_read_results(moprc.fd, moprc.byte_counter);
if(res)
{
......@@ -772,7 +772,7 @@ void track_netbeui(void)
}
else
{
netbeui.fd = mapi_create_flow("eth0");
netbeui.fd = mapi_create_flow(DEVICE);
}
netbeui.filter = mapi_apply_function(netbeui.fd, "BPF_FILTER", "netbeui");
......@@ -787,7 +787,7 @@ void track_netbeui(void)
{
sleep(2);
res = (int *)mapi_read_results(netbeui.fd, netbeui.pkt_counter, 1);
res = (int *)mapi_read_results(netbeui.fd, netbeui.pkt_counter);
if(res)
{
......@@ -795,7 +795,7 @@ void track_netbeui(void)
res = NULL;
}
res = (int *)mapi_read_results(netbeui.fd, netbeui.byte_counter, 1);
res = (int *)mapi_read_results(netbeui.fd, netbeui.byte_counter);
{
bytes = *res;
......
......@@ -33,7 +33,7 @@ void get_filter(int pipe[2])
}
else
{
kazfd = mapi_create_flow("eth0");
kazfd = mapi_create_flow(DEVICE);
}
if(kazfd < 0)
......@@ -41,7 +41,7 @@ void get_filter(int pipe[2])
char err_buffer[1024];
int err_no;
mapi_read_error(kazfd,&err_no,err_buffer);
printf("track_kazaa:Error: %d - %s\n", err_no, err_buffer);
printf("track_kazaa:Error1: %d - %s\n", err_no, err_buffer);
}
if(mapi_apply_function(kazfd, "STR_SEARCH", "KazaaClient", 0, 1500) < 0)
......@@ -49,7 +49,7 @@ void get_filter(int pipe[2])
char err_buffer[1024];
int err_no;
mapi_read_error(kazfd, &err_no,err_buffer);
printf("track_kazaa:Error: %d - %s\n", err_no, err_buffer);
printf("track_kazaa:Error2: %d - %s\n", err_no, err_buffer);
}
bufferid = mapi_apply_function(kazfd, "TO_BUFFER");
......@@ -59,7 +59,7 @@ void get_filter(int pipe[2])
char err_buffer[1024];
int err_no;
mapi_read_error(kazfd,&err_no,err_buffer);
printf("track_kazaa:Error: %d - %s\n", err_no, err_buffer);
printf("track_kazaa:Error3: %d - %s\n", err_no, err_buffer);
}
if(mapi_connect(kazfd) < 0)
......@@ -67,7 +67,7 @@ void get_filter(int pipe[2])
char err_buffer[1024];
int err_no;
mapi_read_error(kazfd,&err_no,err_buffer);
printf("track_kazaa:Error: %d - %s\n", err_no, err_buffer);
printf("track_kazaa:Error4: %d - %s\n", err_no, err_buffer);
}
......@@ -476,7 +476,7 @@ void track_kazza(int fd[2])
}
else
{
kazfd = mapi_create_flow("eth0");
kazfd = mapi_create_flow(DEVICE);
}
if(kazfd < 0)
......@@ -484,7 +484,7 @@ void track_kazza(int fd[2])
char err_buffer[1024];
int err_no;
mapi_read_error(kazfd,&err_no,err_buffer);
printf("track_kazaa:Error: %d - %s\n", err_no, err_buffer);
printf("track_kazaa:Error5: %d - %s\n", err_no, err_buffer);
}
if(mapi_apply_function(kazfd, "STR_SEARCH", "KazaaClient", 0, 1500) < 0)
......@@ -492,7 +492,7 @@ void track_kazza(int fd[2])
char err_buffer[1024];
int err_no;
mapi_read_error(kazfd,&err_no,err_buffer);
printf("track_kazaa:Error: %d - %s\n", err_no, err_buffer);
printf("track_kazaa:Error6: %d - %s\n", err_no, err_buffer);
}
kazzapktf = mapi_apply_function(kazfd, "PKT_COUNTER");
......@@ -502,7 +502,7 @@ void track_kazza(int fd[2])
char err_buffer[1024];
int err_no;
mapi_read_error(kazfd,&err_no,err_buffer);
printf("track_kazaa:Error: %d - %s\n", err_no, err_buffer);
printf("track_kazaa:Error7: %d - %s\n", err_no, err_buffer);
}
kazzabytesf = mapi_apply_function(kazfd, "BYTE_COUNTER");
......@@ -512,7 +512,7 @@ void track_kazza(int fd[2])
char err_buffer[1024];
int err_no;
mapi_read_error(kazfd,&err_no,err_buffer);
printf("track_kazaa:Error: %d - %s\n", err_no, err_buffer);
printf("track_kazaa:Error8: %d - %s\n", err_no, err_buffer);
}
if(mapi_connect(kazfd) < 0)
......@@ -520,7 +520,7 @@ void track_kazza(int fd[2])
char err_buffer[1024];
int err_no;
mapi_read_error(kazfd,&err_no,err_buffer);
printf("track_kazaa:Error: %d - %s\n", err_no, err_buffer);
printf("track_kazaa:Error9: %d - %s\n", err_no, err_buffer);
}
// Adding support for joltid P2P provider in port 3531
......@@ -535,7 +535,7 @@ void track_kazza(int fd[2])
}
else
{
temp->fd = mapi_create_flow("eth0");
temp->fd = mapi_create_flow(DEVICE);
}
if(temp->fd < 0)
......@@ -543,7 +543,7 @@ void track_kazza(int fd[2])
char err_buffer[1024];
int err_no;
mapi_read_error(temp->fd,&err_no,err_buffer);
printf("track_kazaa:Error: %d - %s\n", err_no, err_buffer);
printf("track_kazaa:Error10: %d - %s\n", err_no, err_buffer);
}
if(mapi_apply_function(temp->fd, "BPF_FILTER", temp->filt) < 0)
......@@ -551,7 +551,7 @@ void track_kazza(int fd[2])
char err_buffer[1024];
int err_no;
mapi_read_error(temp->fd,&err_no,err_buffer);
printf("track_kazaa:Error: %d - %s\n", err_no, err_buffer);
printf("track_kazaa:Error11: %d - %s\n", err_no, err_buffer);
}
temp->pkt_counter = mapi_apply_function(temp->fd, "PKT_COUNTER");
......@@ -605,7 +605,7 @@ void track_kazza(int fd[2])
}
else
{
temp->fd = mapi_create_flow("eth0");
temp->fd = mapi_create_flow(DEVICE);
}
if(temp->fd < 0)
......@@ -668,7 +668,7 @@ void track_kazza(int fd[2])
}
else
{
temp->fd = mapi_create_flow("eth0");
temp->fd = mapi_create_flow(DEVICE);
}
if(temp->fd < 0)
......@@ -724,7 +724,7 @@ void track_kazza(int fd[2])
{
if(temp->open == 1)
{
res = (int *)mapi_read_results(temp->fd, temp->pkt_counter, 1);
res = (int *)mapi_read_results(temp->fd, temp->pkt_counter);
if(res)
{
......@@ -733,7 +733,7 @@ void track_kazza(int fd[2])
res = NULL;
}
res = (int *)mapi_read_results(temp->fd, temp->byte_counter, 1);
res = (int *)mapi_read_results(temp->fd, temp->byte_counter);
if(res)
{
......@@ -745,7 +745,7 @@ void track_kazza(int fd[2])
kazzapktc += temp->pkts;
kazzabytesc += temp->bytes;
res = (int *)mapi_read_results(temp->fd, temp->filterc, 1);
res = (int *)mapi_read_results(temp->fd, temp->filterc);
if(res)
{
......@@ -772,7 +772,7 @@ void track_kazza(int fd[2])
}// for
}// if(head)
res = (int *)mapi_read_results(kazfd, kazzapktf, 1);
res = (int *)mapi_read_results(kazfd, kazzapktf);
if(res)
{
......@@ -781,7 +781,7 @@ void track_kazza(int fd[2])
res = NULL;
}
res = (int *)mapi_read_results(kazfd, kazzabytesf, 1);
res = (int *)mapi_read_results(kazfd, kazzabytesf);
if(res)
{
......
......@@ -77,7 +77,7 @@ void track_ftp_port(int my_pipefd[2])
}
else
{
fd = mapi_create_flow("eth0");
fd = mapi_create_flow(DEVICE);
}
if(fd < 0)
......@@ -185,7 +185,7 @@ void track_ftp(int pipef[2])
}