From: Stacey Son <[email protected]> Add helper function to convert target IPv6 socket address structure to host format, handling all sockaddr_in6 fields including address, port, flow info, and scope ID.
Signed-off-by: Stacey Son <[email protected]> Reviewed-by: Pierrick Bouvier <[email protected]> Signed-off-by: Warner Losh <[email protected]> --- bsd-user/bsd-ioctl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bsd-user/bsd-ioctl.c b/bsd-user/bsd-ioctl.c index 69d1ea1718..d2eb9105fc 100644 --- a/bsd-user/bsd-ioctl.c +++ b/bsd-user/bsd-ioctl.c @@ -249,3 +249,14 @@ static abi_long do_ioctl_unsupported(__unused const IOCTLEntry *ie, { return -TARGET_ENXIO; } + +static void target_to_host_sockaddr_in6(struct sockaddr_in6 *hsa_in6, + struct target_sockaddr_in6 *tsa_in6) +{ + __get_user(hsa_in6->sin6_len, &tsa_in6->sin6_len); + __get_user(hsa_in6->sin6_family, &tsa_in6->sin6_family); + __get_user(hsa_in6->sin6_port, &tsa_in6->sin6_port); + __get_user(hsa_in6->sin6_flowinfo, &tsa_in6->sin6_flowinfo); + memcpy(&hsa_in6->sin6_addr, &tsa_in6->sin6_addr, 16); + __get_user(hsa_in6->sin6_scope_id, &tsa_in6->sin6_scope_id); +} -- 2.52.0
