I have an error from the following scenario with IGMP socket call;
fd = socket(PF_INET, SOCK_RAW, IPPROTO_IGMP) ;
setsockopt( fd, IPPROTO_IP, IP_HDRINCL, nval, sizeof(nval) );
/** Fill in the IP header and Ethernet header**/
/*** Fill, create the IGMP packet structures***/
if(sendto( fd, &buf, sizeof(buf), 0,(struct sockaddr *) &addr, sizeof(addr)) < 0) {
printf("Socket Sendto error %d : %s\n", errno, strerror(errno));
return 0;
}
the sendto call fails saying Message too long. I am using 8192 as the buffer size. So I tried using the following call to fix this error;
if(setsockopt(dlpifd, IPPROTO_IP, SO_SNDBUF, &val, sizeof(int)) < 0) {
printf("Can't set socket options:%d:%s\n", errno, strerror(errno));
return 0;`
}
setsockopt( ) call succeeds but the same error for sendto();
So i checked the SO_SNDBUF size with getsockopt( ) call and it shows 1 byte ?!
What is wrong I am doing.
Does the Linux kernel need recompile for IGMP support ? or I am missing something?