net/igmp: add MULTICAST_TTL support

Change-Id: Ic8c9a4f4f9b1ebf9858fa5368c6c75e949de6800
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an
2020-12-02 13:41:22 +08:00
committed by chao an
parent 4802a011d6
commit af1da5e047
+27 -5
View File
@@ -51,6 +51,7 @@
#include "netdev/netdev.h"
#include "igmp/igmp.h"
#include "inet/inet.h"
#include "udp/udp.h"
#ifdef CONFIG_NET_IPv4
@@ -187,19 +188,40 @@ 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 */
case IP_MULTICAST_LOOP: /* Set/read boolean that determines
* whether sent multicast packets
* should be looped back to local
* sockets. */
{
ret = OK;
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_LOOP: /* Set/read boolean that determines
* whether sent multicast packets
* should be looped back to local
* sockets. */
case IP_MULTICAST_IF: /* Set local device for a multicast
* socket */
case IP_UNBLOCK_SOURCE: /* Unblock previously blocked multicast