mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
net/setsockopt/IP_MULTICAST_TTL: add handles of different prototypes
Reference here: https://github.com/torvalds/linux/blob/b3298500b23f0b53a8d81e0d5ad98a29db71f4f0/net/ipv4/ip_sockglue.c#L923-L932 Change-Id: Iad67c756eb549d969bd7a8ffe965d9b1dcc56988 Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
+18
-16
@@ -192,38 +192,40 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
|
||||
case IP_MULTICAST_TTL: /* Set/read the time-to-live value of
|
||||
* outgoing multicast packets */
|
||||
{
|
||||
FAR struct udp_conn_s *conn;
|
||||
int ttl;
|
||||
|
||||
if (psock->s_type != SOCK_DGRAM ||
|
||||
value_len != sizeof(int))
|
||||
value == NULL || value_len == 0)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
ttl = (value_len >= sizeof(int)) ?
|
||||
*(FAR int *)value : (int)*(FAR unsigned char *)value;
|
||||
|
||||
if (ttl <= 0 || ttl > 255)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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_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
|
||||
* source */
|
||||
case IP_BLOCK_SOURCE: /* Stop receiving multicast data from
|
||||
|
||||
Reference in New Issue
Block a user