Skip to contentSkip to conversation

About Raw socket, vlan + ip header

DISCUSSION Sriram Raghunathan 3 participants 3 messages Mar 3, 2015 – Mar 4, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

My name is Sriram, have a question about raw socket programming.

Writing a socket program where, I'm trying to construct a ether frame with vlan id and copying ip header there after. By using PF_PACKET family.

But when I do a sendto, the ip header is stripped off from the packet. Could you please let me know how to go about?

Having the ip header is necessary for a software here.

Thanks for the time.

Sriram

#1 lore raw
Quoted 6 lines · Sriram Raghunathan

Writing a socket program where, I'm trying to construct a ether frame with vlan id and copying ip header there after. By using PF_PACKET family.

But when I do a sendto, the ip header is stripped off from the packet. Could you please let me know how to go about?

man 7 packet

...
The socket_type is either SOCK_RAW for raw packets including the link level header or SOCK_DGRAM for cooked packets with the link level
header removed. The link level header information is available in a
common format in a sockaddr_ll. protocol is the IEEE 802.3 protocol
...

Are you opening a SOCK_RAW or a SOCK_DGRAM PF_PACKET socket?

Phil.

#2 lore raw

Hi Philippe,

Using SOCK_RAW.

Sriram

Quoted 20 lines · ext Philippe Troin
Quoted 6 lines · Sriram Raghunathan

Writing a socket program where, I'm trying to construct a ether frame with vlan id and copying ip header there after. By using PF_PACKET family.

But when I do a sendto, the ip header is stripped off from the packet. Could you please let me know how to go about?

man 7 packet

...
The socket_type is either SOCK_RAW for raw packets including the link level header or SOCK_DGRAM for cooked packets with the link level
header removed. The link level header information is available in a
common format in a sockaddr_ll. protocol is the IEEE 802.3 protocol
...

Are you opening a SOCK_RAW or a SOCK_DGRAM PF_PACKET socket?

Phil.