net/igmp: add MULTICAST_TTL support
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
bce576c0bd
commit
4af687b8c2
@ -51,6 +51,7 @@
|
||||
#include "netdev/netdev.h"
|
||||
#include "igmp/igmp.h"
|
||||
#include "inet/inet.h"
|
||||
#include "udp/udp.h"
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
|
||||
@ -184,12 +185,37 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
|
||||
}
|
||||
break;
|
||||
|
||||
case IP_MULTICAST_TTL: /* Set/read the time-to-live value of
|
||||
* outgoing multicast packets */
|
||||
{
|
||||
if (psock->s_type != SOCK_DGRAM ||
|
||||
value_len != sizeof(int))
|
||||
{
|
||||
ret = -EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
FAR struct udp_conn_s *conn;
|
||||
int ttl = *(FAR int *)value;
|
||||
|
||||
if (ttl <= 0 || ttl > 255)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
conn = (FAR struct udp_conn_s *)psock->s_conn;
|
||||
conn->ttl = ttl;
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* The following IPv4 socket options are defined, but not implemented */
|
||||
|
||||
case IP_MULTICAST_IF: /* Set local device for a multicast
|
||||
* socket */
|
||||
case IP_MULTICAST_TTL: /* Set/read the time-to-live value of
|
||||
* outgoing multicast packets */
|
||||
case IP_MULTICAST_LOOP: /* Set/read boolean that determines
|
||||
* whether sent multicast packets
|
||||
* should be looped back to local
|
||||
|
Loading…
Reference in New Issue
Block a user