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) ...@@ -14,7 +14,7 @@ void track_dns(void)
} }
else else
{ {
dns.fd = mapi_create_flow("eth0"); dns.fd = mapi_create_flow(DEVICE);
} }
dns.filter = mapi_apply_function(dns.fd, "BPF_FILTER", "port 53"); dns.filter = mapi_apply_function(dns.fd, "BPF_FILTER", "port 53");
...@@ -29,7 +29,7 @@ void track_dns(void) ...@@ -29,7 +29,7 @@ void track_dns(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -38,7 +38,7 @@ void track_dns(void) ...@@ -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) if(res)
......
...@@ -15,7 +15,7 @@ void track_eigrp(void) ...@@ -15,7 +15,7 @@ void track_eigrp(void)
} }
else 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"); eigrp.filter = mapi_apply_function(eigrp.fd, "BPF_FILTER", "proto eigrp");//"ip[18] & 88 == 0");
...@@ -32,7 +32,7 @@ void track_eigrp(void) ...@@ -32,7 +32,7 @@ void track_eigrp(void)
sleep(2); 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) if(res)
...@@ -42,7 +42,7 @@ void track_eigrp(void) ...@@ -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) if(res)
......
...@@ -15,7 +15,7 @@ void track_ip(void) ...@@ -15,7 +15,7 @@ void track_ip(void)
} }
else else
{ {
ip.fd = mapi_create_flow("eth0"); ip.fd = mapi_create_flow(DEVICE);
} }
ip.filter = mapi_apply_function(ip.fd, "BPF_FILTER", "ip"); ip.filter = mapi_apply_function(ip.fd, "BPF_FILTER", "ip");
...@@ -30,7 +30,7 @@ void track_ip(void) ...@@ -30,7 +30,7 @@ void track_ip(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -38,7 +38,7 @@ void track_ip(void) ...@@ -38,7 +38,7 @@ void track_ip(void)
res = NULL; 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) if(res)
{ {
...@@ -70,7 +70,7 @@ void track_ip6(void) ...@@ -70,7 +70,7 @@ void track_ip6(void)
} }
else else
{ {
ip6.fd = mapi_create_flow("eth0"); ip6.fd = mapi_create_flow(DEVICE);
} }
ip6.filter = mapi_apply_function(ip6.fd, "BPF_FILTER", "ip6"); ip6.filter = mapi_apply_function(ip6.fd, "BPF_FILTER", "ip6");
...@@ -85,7 +85,7 @@ void track_ip6(void) ...@@ -85,7 +85,7 @@ void track_ip6(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -93,7 +93,7 @@ void track_ip6(void) ...@@ -93,7 +93,7 @@ void track_ip6(void)
res = NULL; 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) if(res)
{ {
...@@ -124,7 +124,7 @@ void track_arp(void) ...@@ -124,7 +124,7 @@ void track_arp(void)
} }
else else
{ {
arp.fd = mapi_create_flow("eth0"); arp.fd = mapi_create_flow(DEVICE);
} }
arp.filter = mapi_apply_function(arp.fd, "BPF_FILTER", "arp"); arp.filter = mapi_apply_function(arp.fd, "BPF_FILTER", "arp");
...@@ -139,7 +139,7 @@ void track_arp(void) ...@@ -139,7 +139,7 @@ void track_arp(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -147,7 +147,7 @@ void track_arp(void) ...@@ -147,7 +147,7 @@ void track_arp(void)
res = NULL; 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) if(res)
{ {
...@@ -178,7 +178,7 @@ void track_rarp(void) ...@@ -178,7 +178,7 @@ void track_rarp(void)
} }
else else
{ {
rarp.fd = mapi_create_flow("eth0"); rarp.fd = mapi_create_flow(DEVICE);
} }
rarp.filter = mapi_apply_function(rarp.fd, "BPF_FILTER", "rarp"); rarp.filter = mapi_apply_function(rarp.fd, "BPF_FILTER", "rarp");
...@@ -193,7 +193,7 @@ void track_rarp(void) ...@@ -193,7 +193,7 @@ void track_rarp(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -201,7 +201,7 @@ void track_rarp(void) ...@@ -201,7 +201,7 @@ void track_rarp(void)
res = NULL; 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) if(res)
{ {
...@@ -232,7 +232,7 @@ void track_atalk(void) ...@@ -232,7 +232,7 @@ void track_atalk(void)
} }
else else
{ {
atalk.fd = mapi_create_flow("eth0"); atalk.fd = mapi_create_flow(DEVICE);
} }
atalk.filter = mapi_apply_function(atalk.fd, "BPF_FILTER", "atalk"); atalk.filter = mapi_apply_function(atalk.fd, "BPF_FILTER", "atalk");
...@@ -247,7 +247,7 @@ void track_atalk(void) ...@@ -247,7 +247,7 @@ void track_atalk(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -255,7 +255,7 @@ void track_atalk(void) ...@@ -255,7 +255,7 @@ void track_atalk(void)
res = NULL; 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) if(res)
{ {
...@@ -286,7 +286,7 @@ void track_aarp(void) ...@@ -286,7 +286,7 @@ void track_aarp(void)
} }
else else
{ {
aarp.fd = mapi_create_flow("eth0"); aarp.fd = mapi_create_flow(DEVICE);
} }
aarp.filter = mapi_apply_function(aarp.fd, "BPF_FILTER", "aarp"); aarp.filter = mapi_apply_function(aarp.fd, "BPF_FILTER", "aarp");
...@@ -301,7 +301,7 @@ void track_aarp(void) ...@@ -301,7 +301,7 @@ void track_aarp(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -309,7 +309,7 @@ void track_aarp(void) ...@@ -309,7 +309,7 @@ void track_aarp(void)
res = NULL; 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) if(res)
{ {
...@@ -340,7 +340,7 @@ void track_decnet(void) ...@@ -340,7 +340,7 @@ void track_decnet(void)
} }
else else
{ {
decnet.fd = mapi_create_flow("eth0"); decnet.fd = mapi_create_flow(DEVICE);
} }
decnet.filter = mapi_apply_function(decnet.fd, "BPF_FILTER", "decnet"); decnet.filter = mapi_apply_function(decnet.fd, "BPF_FILTER", "decnet");
...@@ -355,7 +355,7 @@ void track_decnet(void) ...@@ -355,7 +355,7 @@ void track_decnet(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -363,7 +363,7 @@ void track_decnet(void) ...@@ -363,7 +363,7 @@ void track_decnet(void)
res = NULL; 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) if(res)
{ {
...@@ -394,7 +394,7 @@ void track_iso(void) ...@@ -394,7 +394,7 @@ void track_iso(void)
} }
else else
{ {
iso.fd = mapi_create_flow("eth0"); iso.fd = mapi_create_flow(DEVICE);
} }
iso.filter = mapi_apply_function(iso.fd, "BPF_FILTER", "iso"); iso.filter = mapi_apply_function(iso.fd, "BPF_FILTER", "iso");
...@@ -409,7 +409,7 @@ void track_iso(void) ...@@ -409,7 +409,7 @@ void track_iso(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -417,7 +417,7 @@ void track_iso(void) ...@@ -417,7 +417,7 @@ void track_iso(void)
res = NULL; 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) if(res)
{ {
...@@ -448,7 +448,7 @@ void track_stp(void) ...@@ -448,7 +448,7 @@ void track_stp(void)
} }
else else
{ {
stp.fd = mapi_create_flow("eth0"); stp.fd = mapi_create_flow(DEVICE);
} }
stp.filter = mapi_apply_function(stp.fd, "BPF_FILTER", "stp"); stp.filter = mapi_apply_function(stp.fd, "BPF_FILTER", "stp");
...@@ -463,7 +463,7 @@ void track_stp(void) ...@@ -463,7 +463,7 @@ void track_stp(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -471,7 +471,7 @@ void track_stp(void) ...@@ -471,7 +471,7 @@ void track_stp(void)
res = NULL; 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) if(res)
{ {
...@@ -502,7 +502,7 @@ void track_ipx(void) ...@@ -502,7 +502,7 @@ void track_ipx(void)
} }
else else
{ {
ipx.fd = mapi_create_flow("eth0"); ipx.fd = mapi_create_flow(DEVICE);
} }
ipx.filter = mapi_apply_function(ipx.fd, "BPF_FILTER", "ipx"); ipx.filter = mapi_apply_function(ipx.fd, "BPF_FILTER", "ipx");
...@@ -517,7 +517,7 @@ void track_ipx(void) ...@@ -517,7 +517,7 @@ void track_ipx(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -525,7 +525,7 @@ void track_ipx(void) ...@@ -525,7 +525,7 @@ void track_ipx(void)
res = NULL; 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) if(res)
{ {
...@@ -556,7 +556,7 @@ void track_sca(void) ...@@ -556,7 +556,7 @@ void track_sca(void)
} }
else else
{ {
sca.fd = mapi_create_flow("eth0"); sca.fd = mapi_create_flow(DEVICE);
} }
sca.filter = mapi_apply_function(sca.fd, "BPF_FILTER", "sca"); sca.filter = mapi_apply_function(sca.fd, "BPF_FILTER", "sca");
...@@ -571,7 +571,7 @@ void track_sca(void) ...@@ -571,7 +571,7 @@ void track_sca(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -579,7 +579,7 @@ void track_sca(void) ...@@ -579,7 +579,7 @@ void track_sca(void)
res = NULL; 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) if(res)
{ {
...@@ -610,7 +610,7 @@ void track_lat(void) ...@@ -610,7 +610,7 @@ void track_lat(void)
} }
else else
{ {
lat.fd = mapi_create_flow("eth0"); lat.fd = mapi_create_flow(DEVICE);
} }
lat.filter = mapi_apply_function(lat.fd, "BPF_FILTER", "lat"); lat.filter = mapi_apply_function(lat.fd, "BPF_FILTER", "lat");
...@@ -625,7 +625,7 @@ void track_lat(void) ...@@ -625,7 +625,7 @@ void track_lat(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -633,7 +633,7 @@ void track_lat(void) ...@@ -633,7 +633,7 @@ void track_lat(void)
res = NULL; 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) if(res)
{ {
...@@ -664,7 +664,7 @@ void track_mopdl(void) ...@@ -664,7 +664,7 @@ void track_mopdl(void)
} }
else else
{ {
mopdl.fd = mapi_create_flow("eth0"); mopdl.fd = mapi_create_flow(DEVICE);
} }
mopdl.filter = mapi_apply_function(mopdl.fd, "BPF_FILTER", "mopdl"); mopdl.filter = mapi_apply_function(mopdl.fd, "BPF_FILTER", "mopdl");
...@@ -679,7 +679,7 @@ void track_mopdl(void) ...@@ -679,7 +679,7 @@ void track_mopdl(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -687,7 +687,7 @@ void track_mopdl(void) ...@@ -687,7 +687,7 @@ void track_mopdl(void)
res = NULL; 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) if(res)
{ {
...@@ -718,7 +718,7 @@ void track_moprc(void) ...@@ -718,7 +718,7 @@ void track_moprc(void)
} }
else else
{ {
moprc.fd = mapi_create_flow("eth0"); moprc.fd = mapi_create_flow(DEVICE);
} }
moprc.filter = mapi_apply_function(moprc.fd, "BPF_FILTER", "moprc"); moprc.filter = mapi_apply_function(moprc.fd, "BPF_FILTER", "moprc");
...@@ -733,7 +733,7 @@ void track_moprc(void) ...@@ -733,7 +733,7 @@ void track_moprc(void)
{ {
sleep(2); 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) if(res)
{ {
...@@ -741,7 +741,7 @@ void track_moprc(void) ...@@ -741,7 +741,7 @@ void track_moprc(void)
res = NULL; res = NULL;
}