diff options
Diffstat (limited to 'source3/lib/util_sock.c')
-rw-r--r-- | source3/lib/util_sock.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index a59b1d5ef2..e49db340ae 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -627,6 +627,18 @@ static int get_socket_port(int fd) } #endif +void set_sockaddr_port(struct sockaddr_storage *psa, uint16 port) +{ +#if defined(HAVE_IPV6) + if (psa->ss_family == AF_INET6) { + ((struct sockaddr_in6 *)psa)->sin6_port = htons(port); + } +#endif + if (psa->ss_family == AF_INET) { + ((struct sockaddr_in *)psa)->sin_port = htons(port); + } +} + const char *client_name(int fd) { return get_peer_name(fd,false); |