drivers: nsos: support IPV6_V6ONLY getsockopt() and setsockopt()
Handle IPV6_V6ONLY option in getsockopt() and setsockopt() APIs. Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
This commit is contained in:
parent
d47ec4f75d
commit
87a6df2a9b
3 changed files with 58 additions and 0 deletions
|
|
@ -641,6 +641,13 @@ int nsos_adapt_getsockopt(int fd, int nsos_mid_level, int nsos_mid_optname,
|
|||
return nsos_adapt_getsockopt_int(fd, IPPROTO_TCP, TCP_KEEPCNT,
|
||||
nsos_mid_optval, nsos_mid_optlen);
|
||||
}
|
||||
|
||||
case NSOS_MID_IPPROTO_IPV6:
|
||||
switch (nsos_mid_optname) {
|
||||
case NSOS_MID_IPV6_V6ONLY:
|
||||
return nsos_adapt_getsockopt_int(fd, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
nsos_mid_optval, nsos_mid_optlen);
|
||||
}
|
||||
}
|
||||
|
||||
return -NSOS_MID_EOPNOTSUPP;
|
||||
|
|
@ -720,6 +727,13 @@ int nsos_adapt_setsockopt(int fd, int nsos_mid_level, int nsos_mid_optname,
|
|||
return nsos_adapt_setsockopt_int(fd, IPPROTO_TCP, TCP_KEEPCNT,
|
||||
nsos_mid_optval, nsos_mid_optlen);
|
||||
}
|
||||
|
||||
case NSOS_MID_IPPROTO_IPV6:
|
||||
switch (nsos_mid_optname) {
|
||||
case NSOS_MID_IPV6_V6ONLY:
|
||||
return nsos_adapt_setsockopt_int(fd, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
nsos_mid_optval, nsos_mid_optlen);
|
||||
}
|
||||
}
|
||||
|
||||
return -NSOS_MID_EOPNOTSUPP;
|
||||
|
|
|
|||
|
|
@ -103,4 +103,32 @@ struct nsos_mid_timeval {
|
|||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name IPv6 level options (NSOS_MID_IPPROTO_IPV6)
|
||||
* @{
|
||||
*/
|
||||
/* Socket options for NSOS_MID_IPPROTO_IPV6 level */
|
||||
/** Set the unicast hop limit for the socket. */
|
||||
#define NSOS_MID_IPV6_UNICAST_HOPS 16
|
||||
|
||||
/** Set the multicast hop limit for the socket. */
|
||||
#define NSOS_MID_IPV6_MULTICAST_HOPS 18
|
||||
|
||||
/** Join IPv6 multicast group. */
|
||||
#define NSOS_MID_IPV6_ADD_MEMBERSHIP 20
|
||||
|
||||
/** Leave IPv6 multicast group. */
|
||||
#define NSOS_MID_IPV6_DROP_MEMBERSHIP 21
|
||||
|
||||
/** Don't support IPv4 access */
|
||||
#define NSOS_MID_IPV6_V6ONLY 26
|
||||
|
||||
/** Pass an IPV6_RECVPKTINFO ancillary message that contains a
|
||||
* in6_pktinfo structure that supplies some information about the
|
||||
* incoming packet. See RFC 3542.
|
||||
*/
|
||||
#define NSOS_MID_IPV6_RECVPKTINFO 49
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* __DRIVERS_NET_NSOS_SOCKET_H__ */
|
||||
|
|
|
|||
|
|
@ -1044,6 +1044,14 @@ static int nsos_getsockopt(void *obj, int level, int optname,
|
|||
NSOS_MID_IPPROTO_TCP, NSOS_MID_TCP_KEEPCNT,
|
||||
optval, optlen);
|
||||
}
|
||||
|
||||
case IPPROTO_IPV6:
|
||||
switch (optname) {
|
||||
case IPV6_V6ONLY:
|
||||
return nsos_getsockopt_int(sock,
|
||||
NSOS_MID_IPPROTO_IPV6, NSOS_MID_IPV6_V6ONLY,
|
||||
optval, optlen);
|
||||
}
|
||||
}
|
||||
|
||||
errno = EOPNOTSUPP;
|
||||
|
|
@ -1173,6 +1181,14 @@ static int nsos_setsockopt(void *obj, int level, int optname,
|
|||
NSOS_MID_IPPROTO_TCP, NSOS_MID_TCP_KEEPCNT,
|
||||
optval, optlen);
|
||||
}
|
||||
|
||||
case IPPROTO_IPV6:
|
||||
switch (optname) {
|
||||
case IPV6_V6ONLY:
|
||||
return nsos_setsockopt_int(sock,
|
||||
NSOS_MID_IPPROTO_IPV6, NSOS_MID_IPV6_V6ONLY,
|
||||
optval, optlen);
|
||||
}
|
||||
}
|
||||
|
||||
errno = EOPNOTSUPP;
|
||||
|
|
|
|||
Loading…
Reference in a new issue