802.1q tag, raw socket
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");
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)
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");