mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
net/igmp: add MULTICAST_TTL support
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
@@ -51,6 +51,7 @@
|
|||||||
#include "netdev/netdev.h"
|
#include "netdev/netdev.h"
|
||||||
#include "igmp/igmp.h"
|
#include "igmp/igmp.h"
|
||||||
#include "inet/inet.h"
|
#include "inet/inet.h"
|
||||||
|
#include "udp/udp.h"
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
|
||||||
@@ -184,12 +185,37 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
|
|||||||
}
|
}
|
||||||
break;
|
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 */
|
/* The following IPv4 socket options are defined, but not implemented */
|
||||||
|
|
||||||
case IP_MULTICAST_IF: /* Set local device for a multicast
|
case IP_MULTICAST_IF: /* Set local device for a multicast
|
||||||
* socket */
|
* 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
|
case IP_MULTICAST_LOOP: /* Set/read boolean that determines
|
||||||
* whether sent multicast packets
|
* whether sent multicast packets
|
||||||
* should be looped back to local
|
* should be looped back to local
|
||||||
|
|||||||
Reference in New Issue
Block a user