mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
Implement IPV6_UNICAST_HOPS socket option
Implements the IPV6_UNICAST_HOPS socket option, which sets the hop limit for outgoing unicast IPv6 packets. Based on work from https://savannah.nongnu.org/patch/?9554 Co-authored-by: Christina Schoenrogge <christina.schoenrogge@garmin.com> Co-authored-by: Chee Bin Hoh <hohcheebin@gmail.com> Co-authored-by: hanhui <hanhui03@163.com>
This commit is contained in:
parent
732d3411bf
commit
64b758d00c
@ -3169,6 +3169,12 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt
|
||||
/* Level: IPPROTO_IPV6 */
|
||||
case IPPROTO_IPV6:
|
||||
switch (optname) {
|
||||
case IPV6_UNICAST_HOPS:
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, *optlen, int);
|
||||
*(int *)optval = sock->conn->pcb.ip->ttl;
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IPV6, IPV6_UNICAST_HOPS) = %d\n",
|
||||
s, *(int *)optval));
|
||||
break;
|
||||
case IPV6_V6ONLY:
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN(sock, *optlen, int);
|
||||
*(int *)optval = (netconn_get_ipv6only(sock->conn) ? 1 : 0);
|
||||
@ -3646,6 +3652,12 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
|
||||
/* Level: IPPROTO_IPV6 */
|
||||
case IPPROTO_IPV6:
|
||||
switch (optname) {
|
||||
case IPV6_UNICAST_HOPS:
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, optlen, int);
|
||||
sock->conn->pcb.ip->ttl = *(int *)optval;
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IPV6, IPV6_UNICAST_HOPS, ...) -> %d\n",
|
||||
s, *(int *)optval));
|
||||
break;
|
||||
case IPV6_V6ONLY:
|
||||
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, optlen, int);
|
||||
if (*(const int *)optval) {
|
||||
|
@ -297,6 +297,7 @@ struct linger {
|
||||
* Options for level IPPROTO_IPV6
|
||||
*/
|
||||
#define IPV6_CHECKSUM 7 /* RFC3542: calculate and insert the ICMPv6 checksum for raw sockets. */
|
||||
#define IPV6_UNICAST_HOPS 16 /* RFC3493: hop limit in outgoing unicast IPv6 packets */
|
||||
#define IPV6_V6ONLY 27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */
|
||||
#endif /* LWIP_IPV6 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user