I setup a raw Packet socket using the following:
sockFd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL) );
Then I am trying to set the socket option IP_HDRINCL using:
int one = 1;
if (setsockopt (sockFd, IPPROTO_IP, IP_HDRINCL, &one, sizeof(one)) < 0)
LogPrint(LOG_UNKNOWN,"Warning: Cannot set HDRINCL!\n");
But I am unable to set this option (I get an error with errno 92 and message “Protocol not available”. If I change PF_PACKET to PF_INET then the options is set but I have to use PF_PACKET. So is there a way to set this option with the socket created above?
Thanks a bunch.
PF_PACKETsockets don’t have any option that I asked in the question to be set. That option is only available onPF_INETorPF_INET6sockets with typeSOCK_RAW.If one wants the IP headers to be added by the kernel, the one must use the
PF_INETsocket.