@Test public void testOpenLive() throws Exception { PcapHandle ph = Pcaps.openOffline("src/test/resources/org/pcap4j/core/udp_tcp_icmp.pcap"); BpfProgram prog = ph.compileFilter("icmp", BpfCompileMode.OPTIMIZE, PcapHandle.PCAP_NETMASK_UNKNOWN); Packet udp = ph.getNextPacket(); assertFalse(prog.applyFilter(udp)); Packet tcp = ph.getNextPacket(); assertFalse(prog.applyFilter(tcp.getRawData())); byte[] icmp = ph.getNextPacket().getRawData(); byte[] icmpArr = new byte[icmp.length + 20]; System.arraycopy(icmp, 0, icmpArr, 0, icmp.length); assertTrue(prog.applyFilter(icmpArr, icmp.length, icmp.length)); }
public boolean applyFilter(Packet packet) { return applyFilter(packet.getRawData()); }
BpfProgram { public boolean applyFilter(Packet packet) { return applyFilter(packet.getRawData()); } }
BpfProgram { public boolean applyFilter(Packet packet) { return applyFilter(packet.getRawData()); } BpfProgram(bpf_program program, String expression); }
BpfProgram { public boolean applyFilter(Packet packet) { return applyFilter(packet.getRawData()); } BpfProgram(bpf_program program, String expression); String getExpression(); boolean applyFilter(Packet packet); boolean applyFilter(byte[] packet); boolean applyFilter(byte[] packet, int orgPacketLen, int packetLen); boolean isFreed(); void free(); }
BpfProgram { public boolean applyFilter(Packet packet) { return applyFilter(packet.getRawData()); } BpfProgram(bpf_program program, String expression); String getExpression(); boolean applyFilter(Packet packet); boolean applyFilter(byte[] packet); boolean applyFilter(byte[] packet, int orgPacketLen, int packetLen); boolean isFreed(); void free();  }