diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/socket/socket.c | 12 | ||||
-rw-r--r-- | source4/lib/socket/socket.h | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c index 30db03fd97..4b5cecab34 100644 --- a/source4/lib/socket/socket.c +++ b/source4/lib/socket/socket.c @@ -25,6 +25,7 @@ #include "system/network.h" #include "param/param.h" #include "../lib/tsocket/tsocket.h" +#include "lib/util/util_net.h" /* auto-close sockets on free @@ -371,6 +372,17 @@ _PUBLIC_ struct tsocket_address *socket_address_to_tsocket_address(TALLOC_CTX *m return r; } +_PUBLIC_ void socket_address_set_port(struct socket_address *a, + uint16_t port) +{ + if (a->sockaddr) { + set_sockaddr_port(a->sockaddr, port); + } else { + a->port = port; + } + +} + _PUBLIC_ struct socket_address *tsocket_address_to_socket_address(TALLOC_CTX *mem_ctx, const struct tsocket_address *a) { diff --git a/source4/lib/socket/socket.h b/source4/lib/socket/socket.h index 8f8922bcea..4a744797b3 100644 --- a/source4/lib/socket/socket.h +++ b/source4/lib/socket/socket.h @@ -174,6 +174,8 @@ struct socket_address *socket_address_from_strings(TALLOC_CTX *mem_ctx, struct socket_address *socket_address_from_sockaddr(TALLOC_CTX *mem_ctx, struct sockaddr *sockaddr, size_t addrlen); +_PUBLIC_ void socket_address_set_port(struct socket_address *a, + uint16_t port); struct socket_address *socket_address_copy(TALLOC_CTX *mem_ctx, const struct socket_address *oaddr); const struct socket_ops *socket_getops_byname(const char *name, enum socket_type type); |