Commit 398105ef authored by garciay's avatar garciay
Browse files

Bugs fixed reported by Dinnyq

parent f276c950
Loading
Loading
Loading
Loading
+3 −17
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ public class PcapMultiplexer implements Runnable {
            
                              
            int r = Pcap.findAllDevs(alldevs, errbuf);  
            if (r != Pcap.OK || alldevs.isEmpty()) {  
            if (r == Pcap.NOT_OK || alldevs.isEmpty()) {  
              TERFactory.getInstance().logError("Can't read list of devices, error is %s" + errbuf.toString());  
              return;  
            }  
@@ -102,22 +102,8 @@ public class PcapMultiplexer implements Runnable {
                int flags = Pcap.MODE_PROMISCUOUS;  // capture all packets  
                int timeout = 10;                   // 10 millis  
                pcap = Pcap.openLive(device.getName(), snaplen, flags, timeout, errbuf);
                if (pcap == null) { // Check result
                    TERFactory.getInstance().logError("Error while opening device for capture: " + errbuf.toString());  
                    return;  
                }  
                captureThread = new Thread(this);
                captureThread.start();
                filter = "";
            } else { // Open file
                pcap = Pcap.openOffline(file, errbuf);
                if (pcap == null) { // Check result
                    TERFactory.getInstance().logError("Error while opening device for capture: " + errbuf.toString());  
                    return;  
                }
                captureThread = new Thread(this);
                captureThread.start();
                filter = "";
            }
            if (pcap == null) { // Check result
                TERFactory.getInstance().logError("Error while opening device for capture: " + errbuf.toString());  
@@ -267,11 +253,11 @@ public class PcapMultiplexer implements Runnable {
        int optimize = 0; // 1 means true, 0 means false
        int netmask = 0;            
        int r = pcap.compile(bpfFilter, filter, optimize, netmask);
        if (r != Pcap.OK) {
        if (r == Pcap.NOT_OK) {
            TERFactory.getInstance().logError("Filter error: " + pcap.getErr());
        } else {
            r = pcap. setFilter(bpfFilter);
            if (r != Pcap.OK) {
            if (r == Pcap.NOT_OK) {
                TERFactory.getInstance().logError("Filter error: " + pcap.getErr());
            }
        }