I am having a problem to understand VLAN tagging. I have already done changes in the /etc/network/interface file using this link(
http://myhomelab.blogspot.de/2014/01...-in-linux.html). I am using socket programming on Raspbian (Raspberry pi) using C language.
I tried 2 methods:
1. The socket in C is
s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
When i send a ethernet packet from the raspberry pi using the above socket i only see the outgoing "arp" messages on the bus.
2. s = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL))
But this creates an error "sendto failed: Invalid argument" or "sendto failed: Network down" during sending the packet, the code to send packet is:
struct sockaddr_in sin;
sin.sin_family = AF_PACKET;
sin.sin_port = htons(30490);
sin.sin_addr.s_addr = inet_addr(destination ip address);
if(sendto(socket, data, iph->tot_len, 0, (struct sockaddr *)&sin, sizeof(sin)) < 0)
{ perror("Sendto failed"); }
else { printf("Packet send"); }
Could anyone help me with the information on how to attach a VLAN tag with every packet that is being send ? Or what i am doing wrong in above code ?
Is there a code which is already implemented for sending packets with VLAN?
(In my setup i am not using any router or switch)