LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 05-15-2006, 09:08 AM   #1
shreekantsingh
LQ Newbie
 
Registered: Apr 2006
Posts: 1

Rep: Reputation: 0
Problem with Linux socket filter


Hi,
I am facing some problem while implementing the filter.
The problem is in want to receive only those packet which matches multicast mac ID or the mac ID of my nic. I am opening the RAW socket and putting it in PACKET_MR_PROMISC mode. I am receiving all the packet. I want to receive only the packerts which are matching the macID.
This is the code snippet


sdRdWr=socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP));
if(sdRdWr<0)
{
perror("socket");
exit(1);
}
memset(&ifr,0,sizeof(ifr));
strncpy(ifr.ifr_name, device,sizeof(ifr.ifr_name));
if(ioctl(sdRdWr, SIOCGIFINDEX, &ifr)<0)
{
close(sdRdWr);
perror("cant get flags");
exit(1);
}

sll.sll_family=AF_PACKET;
sll.sll_ifindex=ifr.ifr_ifindex;
sll.sll_protocol=htons(ETH_P_ALL);

if(bind(sdRdWr,(struct sockaddr*)&sll,sizeof(sll))<0)
{
perror("bind");
exit(1);
}
memset(&mr,0,sizeof(mr));
mr.mr_ifindex=ifr.ifr_ifindex;
mr.mr_type=PACKET_MR_PROMISC;
if(setsockopt(sdRdWr,SOL_PACKET,PACKET_ADD_MEMBERSHIP,&mr,sizeof(mr))<0)
{
.
.
.
.
Thanks in advance
Shree Kant
 
  


Reply

Tags
filter, socket


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what does "failed to install socket filter protocol not available " mean??? xiaohaomei Linux - Networking 0 07-15-2004 08:45 PM
problem using socket in perl for linux enviornment hitesh29 Linux - Networking 0 04-08-2004 12:11 AM
Wierd error with ping WARNING: failed to install socket filter: Protocol not availabl abefroman Linux - Networking 4 03-25-2004 05:48 PM
Warning: failed to install socket filter: Protocol not available ixion Linux - Networking 0 08-12-2003 09:25 AM
BSD socket filter problem DaveV *BSD 0 08-07-2003 02:09 AM


All times are GMT -5. The time now is 06:13 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration