summaryrefslogtreecommitdiff
path: root/util/tap
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2003-11-02 02:13:04 -0500
committerNathan Binkert <binkertn@umich.edu>2003-11-02 02:13:04 -0500
commit03ef1a0c0938c596ea5dc48e11c111d2c5c78903 (patch)
treecf46f0e1145a4b5357b92738ee6bfa0d6ec360c7 /util/tap
parentc7d6745b073982782eb05ca523b53e1c7fe784da (diff)
downloadgem5-03ef1a0c0938c596ea5dc48e11c111d2c5c78903.tar.xz
If a filter isn't specified, don't try to do any filtering
If pcap_lookupnet fails, just assume the netmask is 0xffffff00 that's all we really wanted from it anyway. --HG-- extra : convert_revision : ac0a390ddb7a6b0a4e4c6d2885bfa7bd059faf36
Diffstat (limited to 'util/tap')
-rw-r--r--util/tap/tap.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/util/tap/tap.cc b/util/tap/tap.cc
index 7121ebcbb..2932cec35 100644
--- a/util/tap/tap.cc
+++ b/util/tap/tap.cc
@@ -200,7 +200,7 @@ main(int argc, char *argv[])
int bufsize = 2000;
bool listening = false;
char *device = NULL;
- char *filter = "";
+ char *filter = NULL;
char c;
int daemon = false;
string host;
@@ -274,16 +274,20 @@ main(int argc, char *argv[])
if (pcap == NULL)
panic("pcap_open_live failed: %s\n", errbuf);
- bpf_program program;
- bpf_u_int32 localnet, netmask;
- if (pcap_lookupnet(device, &localnet, &netmask, errbuf) == -1)
- panic("pcap_lookupnet failed: %s\n", errbuf);
+ if (filter) {
+ bpf_program program;
+ bpf_u_int32 localnet, netmask;
+ if (pcap_lookupnet(device, &localnet, &netmask, errbuf) == -1) {
+ DPRINTF("pcap_lookupnet failed: %s\n", errbuf);
+ netmask = 0xffffff00;
+ }
- if (pcap_compile(pcap, &program, filter, 1, netmask) == -1)
- panic("pcap_compile failed, invalid filter:\n%s\n", filter);
+ if (pcap_compile(pcap, &program, filter, 1, netmask) == -1)
+ panic("pcap_compile failed, invalid filter:\n%s\n", filter);
- if (pcap_setfilter(pcap, &program) == -1)
- panic("pcap_setfilter failed\n");
+ if (pcap_setfilter(pcap, &program) == -1)
+ panic("pcap_setfilter failed\n");
+ }
eth_t *ethernet = eth_open(device);
if (!ethernet)