0

I'm trying to parse a datagram obtained with recvmsg on a raw socket, but I'm not sure about its format. Since according to man raw, "A raw socket receives or sends the raw datagram not including link level headers", I was expecting that it would start directly with the ip header. But reading this other question sockets: right way to access IP and UDP headers on raw socket buffer, in which the ip header is obtained with

  struct iphdr *ip = (struct iphdr *)(pkt + 14);

it looks like there are 14 bytes before it. What are those bytes reserved for? Can I assume I will always get the ip header on a raw sockets' datagram at that position?

I created the socket in this way

    int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);

sent an icmp request using sendto with a struct icmphdr (with ICMP_TYPE, internet checksum ,etc) and received 28 bytes from recvmsg (passing MSG_WAITALL flag) I would like to parse.

Pedro
  • 11
  • 3

0 Answers0