I am trying to filter the packet and discard if expression matches the situation. I mean to say that If packet is coming from 192.168.1.100, It should not get deliver to the destination(which is 192.168.1.119).
<pre>PcapBpfProgram program = new PcapBpfProgram();
String expression = "host 192.168.1.100";
int optimize = 0;
int netmask = 0xFFFFFF00;
if (pcap.compile(program, expression, optimize, netmask) != Pcap.OK
{
System.err.println(pcap.getErr());
return;
}
if (pcap.setFilter(program) != Pcap.OK)
{
System.err.println(pcap.getErr());
return;
}</pre>
In my CASE the host is 192.168.1.100 so Pcap.OK is returning true. But packet is still transmitting to the destination. How can I stop that packet from transmission???
TIA
I recently built a packet sniffer that redirected particular RTP packets to a different detination, I guess it is exactly what you need to do. You can get the whole code from my GitHub repository, under the "Lizardous" folder:
https://github.com/Longhitano/main_projects/blob/master/Lizardous/src/j1/lizardous.java