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,

Code:
int sockfd;
sockfd = socket(PF_PACKET,SOCK_RAW,htons(ETH_P_ALL));
After this i set the interface 'eth0' into promiscous mode,
Then i get the packet as,

Code:
n=recvfrom(sockfd,message,MAX_BUFF,0,NULL,NULL);
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)

Problem:

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.

Note:

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.

Thanks.