LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-04-2012, 06:19 AM   #1
petar
LQ Newbie
 
Registered: Jun 2008
Posts: 3

Rep: Reputation: 0
802.1q tag, raw socket


Hello,

I am writing program that need to accept double TAG traffic. I am using raw socket for that.
And in general my program run OK, except that for some reason received packet do not have 2 VLAN tags, but only one. I see in wireshark that packet indeed have 2 VLAN tags in it.
Can you please help? Funny part is that sending of double tagged package is working fine.

if ((rx_socket = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0)
{
perror("Error creating socket");
exit(0);
}
struct ifreq if_mac_rec1;
memset(&if_mac_rec1, 0, sizeof(struct ifreq));
strncpy(if_mac_rec1.ifr_name, "eth0", IFNAMSIZ);
if (ioctl(rx_socket, SIOCGIFINDEX, &if_mac_rec1) < 0)
{
perror("SIOCGIFINDEX");
exit(1);
}

struct packet_mreq mr_rx;
memset (&mr_rx, 0, sizeof (mr_rx));
mr_rx.mr_ifindex = if_mac_rec1.ifr_ifindex;
mr_rx.mr_type = PACKET_MR_PROMISC;
setsockopt (rx_socket, SOL_PACKET,PACKET_ADD_MEMBERSHIP, &mr_rx, sizeof (mr_rx));

if (recvfrom(rx_socket, (unsigned char *)&recv_msg, 800, 0,0,0) <= 0)
perror("packet receive error:Rx-> Receive all messages");
 
Old 05-07-2012, 03:31 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 1,413

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
Most likely this means you are capturing on the VLAN interface (like eth1.101) instead of on the raw interface (like eth1). See here.
 
  


Reply


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
Socket RAW ethernet scarabee Programming 1 02-23-2012 06:00 PM
Raw socket - max frame length supported by sendto call for tag frames muruga86 Linux - Networking 0 06-17-2010 06:45 AM
raw sockets in wireless network (802.11) pratyushvb Programming 2 05-27-2010 08:15 AM
Socket Raw linuxanswer Programming 1 04-01-2004 09:43 PM
ping without raw socket linuxnw Linux - Networking 3 12-09-2003 11:57 PM


All times are GMT -5. The time now is 09:31 PM.

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