You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/05/13 14:34:28 UTC
[nuttx] branch master updated: ipv6: support SOL_IPV6 options IPV6_UNICAST_HOPS and IPV6_MULTICAST_HOPS
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new c9a843bdca ipv6: support SOL_IPV6 options IPV6_UNICAST_HOPS and IPV6_MULTICAST_HOPS
c9a843bdca is described below
commit c9a843bdca252e38ae561326ad49bb4842fbbcc9
Author: zhanghongyu <zh...@xiaomi.com>
AuthorDate: Fri May 12 15:28:24 2023 +0800
ipv6: support SOL_IPV6 options IPV6_UNICAST_HOPS and IPV6_MULTICAST_HOPS
Added simple support for IPV6_UNICAST_HOPS and IPV6_UNICAST_HOPS, the application can configure the ttl parameters of the socket in user mode.
Signed-off-by: zhanghongyu <zh...@xiaomi.com>
---
net/inet/ipv6_setsockopt.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/net/inet/ipv6_setsockopt.c b/net/inet/ipv6_setsockopt.c
index c55aa249d0..bb79cd2a2e 100644
--- a/net/inet/ipv6_setsockopt.c
+++ b/net/inet/ipv6_setsockopt.c
@@ -112,21 +112,57 @@ int ipv6_setsockopt(FAR struct socket *psock, int option,
}
break;
+ case IPV6_MULTICAST_HOPS: /* Multicast hop limit */
+ {
+ FAR struct socket_conn_s *conn;
+ uint8_t ttl;
+
+ if (value == NULL || value_len == 0)
+ {
+ ret = -EINVAL;
+ break;
+ }
+
+ ttl = (value_len >= sizeof(int)) ?
+ *(FAR int *)value : (int)*(FAR unsigned char *)value;
+ conn = psock->s_conn;
+ conn->ttl = ttl;
+ ret = OK;
+ }
+ break;
+
/* The following IPv6 socket options are defined, but not implemented */
- case IPV6_MULTICAST_HOPS: /* Multicast hop limit */
case IPV6_MULTICAST_IF: /* Interface to use for outgoing multicast
* packets */
case IPV6_MULTICAST_LOOP: /* Multicast packets are delivered back to
* the local application */
#endif
- case IPV6_UNICAST_HOPS: /* Unicast hop limit */
case IPV6_V6ONLY: /* Restrict AF_INET6 socket to IPv6
* communications only */
nwarn("WARNING: Unimplemented IPv6 option: %d\n", option);
ret = -ENOSYS;
break;
+ case IPV6_UNICAST_HOPS: /* Unicast hop limit */
+ {
+ FAR struct socket_conn_s *conn;
+ uint8_t ttl;
+
+ if (value == NULL || value_len == 0)
+ {
+ ret = -EINVAL;
+ break;
+ }
+
+ ttl = (value_len >= sizeof(int)) ?
+ *(FAR int *)value : (int)*(FAR unsigned char *)value;
+ conn = psock->s_conn;
+ conn->ttl = ttl;
+ ret = OK;
+ }
+ break;
+
case IPV6_RECVPKTINFO:
case IPV6_RECVHOPLIMIT:
{