mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-12 09:52:27 +00:00
lib: futher simplification of setsockopt_ipv4_multicast()
* sockopt.c (setsockopt_ipv4_multicast): check for wrong optname with assert(), rather than return an error.
This commit is contained in:
parent
e0afa6f44a
commit
ee7e75d38b
@ -214,10 +214,7 @@ setsockopt_ipv4_multicast(int sock,
|
||||
struct ip_mreqn mreqn;
|
||||
int ret;
|
||||
|
||||
switch (optname)
|
||||
{
|
||||
case IP_ADD_MEMBERSHIP:
|
||||
case IP_DROP_MEMBERSHIP:
|
||||
assert(optname == IP_ADD_MEMBERSHIP || optname == IP_DROP_MEMBERSHIP);
|
||||
memset (&mreqn, 0, sizeof(mreqn));
|
||||
|
||||
if (mcast_addr)
|
||||
@ -242,14 +239,6 @@ setsockopt_ipv4_multicast(int sock,
|
||||
(void *)&mreqn, sizeof(mreqn));
|
||||
}
|
||||
return ret;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Can out and give an understandable error */
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Example defines for another OS, boilerplate off other code in this
|
||||
function, AND handle optname as per other sections for consistency !! */
|
||||
@ -263,12 +252,10 @@ setsockopt_ipv4_multicast(int sock,
|
||||
struct ip_mreq mreq;
|
||||
int ret;
|
||||
|
||||
assert(optname == IP_ADD_MEMBERSHIP || optname == IP_DROP_MEMBERSHIP);
|
||||
|
||||
m.s_addr = htonl(ifindex);
|
||||
|
||||
switch (optname)
|
||||
{
|
||||
case IP_ADD_MEMBERSHIP:
|
||||
case IP_DROP_MEMBERSHIP:
|
||||
memset (&mreq, 0, sizeof(mreq));
|
||||
mreq.imr_multiaddr.s_addr = mcast_addr;
|
||||
mreq.imr_interface = m;
|
||||
@ -289,14 +276,7 @@ setsockopt_ipv4_multicast(int sock,
|
||||
(void *)&mreq, sizeof(mreq));
|
||||
}
|
||||
return ret;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Can out and give an understandable error */
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
#error "Unsupported multicast API"
|
||||
#endif /* #if OS_TYPE */
|
||||
|
Loading…
Reference in New Issue
Block a user