开发者

using IP_ADD_SOURCE_MEMBERSHIP unable to add more then 10 source address for a RAW socket

开发者 https://www.devze.com 2023-02-04 09:59 出处:网络
HI, I use set socket option IP_ADD_SOURCE_MEMBERSHIP to add more then 10 source address. But after 10 source address I am unable to add further. Can anyone tell me how can add more then 10 address pe

HI,

I use set socket option IP_ADD_SOURCE_MEMBERSHIP to add more then 10 source address. But after 10 source address I am unable to add further. Can anyone tell me how can add more then 10 address per socket. My code is as follows,

sock = socket (AF_INET, SOCK_RAW, IPPROTO_UDP);

/* The below code repeted for more then 10 times */

struct ip_mreq_source  mc_req;

mc_req.imr_multiaddr.s_addr   = grpaddr;
mc_req.imr_interface.s_addr   = ifaddr;
mc_req.imr_sourceaddr.s_addr  = srcaddr;

if ((setsockopt (sock, IPPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP,
                 (void*) &mc_req,
        开发者_JAVA技巧         sizeof (mc_req))) < 0)
{
    printf ("Can't set  IP_ADD_SOURCE_MEMBERSHIP!\n");
    exit (1);
}

After adding 10 source address Error comes as Can't set IP_ADD_SOURCE_MEMBERSHIP!.

Thanks in advance

Debjyoti


That looks like you're hitting a kernel limit.

Check the value configured in:

/proc/sys/net/ipv4/igmp_max_msf

and adjust it as needed. For example:

echo 20 > /proc/sys/net/ipv4/igmp_max_msf
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号