net/setsockopt/IP_MULTICAST_TTL: add handles of different prototypes
Reference here:
b3298500b2/net/ipv4/ip_sockglue.c (L923-L932)
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
5ad2c931a3
commit
e37001f269
@ -192,15 +192,18 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
|
|||||||
case IP_MULTICAST_TTL: /* Set/read the time-to-live value of
|
case IP_MULTICAST_TTL: /* Set/read the time-to-live value of
|
||||||
* outgoing multicast packets */
|
* outgoing multicast packets */
|
||||||
{
|
{
|
||||||
|
FAR struct udp_conn_s *conn;
|
||||||
|
int ttl;
|
||||||
|
|
||||||
if (psock->s_type != SOCK_DGRAM ||
|
if (psock->s_type != SOCK_DGRAM ||
|
||||||
value_len != sizeof(int))
|
value == NULL || value_len == 0)
|
||||||
{
|
{
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
ttl = (value_len >= sizeof(int)) ?
|
||||||
FAR struct udp_conn_s *conn;
|
*(FAR int *)value : (int)*(FAR unsigned char *)value;
|
||||||
int ttl = *(FAR int *)value;
|
|
||||||
|
|
||||||
if (ttl <= 0 || ttl > 255)
|
if (ttl <= 0 || ttl > 255)
|
||||||
{
|
{
|
||||||
@ -213,7 +216,6 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* The following IPv4 socket options are defined, but not implemented */
|
/* The following IPv4 socket options are defined, but not implemented */
|
||||||
|
Loading…
Reference in New Issue
Block a user