org.pcap4j.core.PcapNetworkInterface.PromiscuousMode Java Examples
The following examples show how to use
org.pcap4j.core.PcapNetworkInterface.PromiscuousMode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CapEnv.java From NSS with Apache License 2.0 | 5 votes |
PromiscuousMode getMode(PcapNetworkInterface pi){ PromiscuousMode mode=null; String string=(pi.getDescription()+":"+pi.getName()).toLowerCase(); if(string.contains("wireless")){ mode= PromiscuousMode.NONPROMISCUOUS; }else { mode= PromiscuousMode.PROMISCUOUS; } return mode; }
Example #2
Source File: CapEnv.java From finalspeed-91yun with GNU General Public License v2.0 | 5 votes |
PromiscuousMode getMode(PcapNetworkInterface pi){ PromiscuousMode mode=null; String string=(pi.getDescription()+":"+pi.getName()).toLowerCase(); if(string.contains("wireless")){ mode=PromiscuousMode.NONPROMISCUOUS; }else { mode=PromiscuousMode.PROMISCUOUS; } return mode; }
Example #3
Source File: CapEnv.java From finalspeed with GNU General Public License v2.0 | 5 votes |
PromiscuousMode getMode(PcapNetworkInterface pi) { PromiscuousMode mode; String string = (pi.getDescription() + ":" + pi.getName()).toLowerCase(); if (string.contains("wireless")) { mode = PromiscuousMode.NONPROMISCUOUS; } else { mode = PromiscuousMode.PROMISCUOUS; } return mode; }
Example #4
Source File: Boot.java From MakeLobbiesGreatAgain with MIT License | 4 votes |
public static void main(String[] args) throws UnsupportedLookAndFeelException, AWTException, ClassNotFoundException, InterruptedException, FontFormatException, InstantiationException, IllegalAccessException, IOException, PcapNativeException, NotOpenException { System.setProperty("jna.nosys", "true"); if (!Sanity.check()) { System.exit(1); } Settings.init(); Settings.set("autoload", Settings.get("autoload", "0")); //"autoload" is an ini-only toggle for advanced users. setupTray(); getLocalAddr(); nif = Pcaps.getDevByAddress(addr); if (nif == null) { JOptionPane.showMessageDialog(null, "The device you selected doesn't seem to exist. Double-check the IP you entered.", "Error", JOptionPane.ERROR_MESSAGE); System.exit(1); } final int addrHash = addr.hashCode(); final int snapLen = 65536; final PromiscuousMode mode = PromiscuousMode.NONPROMISCUOUS; final int timeout = 0; handle = nif.openLive(snapLen, mode, timeout); handle.setFilter("udp && less 150", BpfProgram.BpfCompileMode.OPTIMIZE); ui = new Overlay(); while (running) { final Packet packet = handle.getNextPacket(); if (packet != null) { final IpV4Packet ippacket = packet.get(IpV4Packet.class); if (ippacket != null) { final UdpPacket udppack = ippacket.get(UdpPacket.class); if (udppack != null && udppack.getPayload() != null) { final int srcAddrHash = ippacket.getHeader().getSrcAddr().hashCode(); final int dstAddrHash = ippacket.getHeader().getDstAddr().hashCode(); final int payloadLen = udppack.getPayload().getRawData().length; if (active.containsKey(srcAddrHash) && srcAddrHash != addrHash) { if (active.get(srcAddrHash) != null && payloadLen == 68 //Packets are STUN related: 56 is request, 68 is response && dstAddrHash == addrHash) { ui.setPing(ippacket.getHeader().getSrcAddr(), handle.getTimestamp().getTime() - active.get(srcAddrHash).getTime()); active.put(srcAddrHash, null); //No longer expect ping } } else { if (payloadLen == 56 && srcAddrHash == addrHash) { active.put(ippacket.getHeader().getDstAddr().hashCode(), handle.getTimestamp()); } } } } } } }