As a part of my project i have to use UNIX socket programming to discard IP packets coming from a particular IP address.
So what i did was, I created a socket as follows,
After this i set the interface 'eth0' into promiscous mode,
sockfd = socket(PF_PACKET,SOCK_RAW,htons(ETH_P_ALL));
Then i get the packet as,
the packets received by the above call are not sent to the upper layers unless a 'sendto' call is used to send to a loopback IP address. (I don't know whether this is correct or wrong)
The packets received goes to the above layers too. Only a copy is sent to my program and not the original packet. So I am not able to discard the IP packets.
Somebody who had the same problem please help.
I am not creating the socket using SOCK_PACKET since it is outdated. Anyway, even if i am able to do the above using this it is ok.