summaryrefslogtreecommitdiff
path: root/source4/lib/socket
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2010-03-10 15:55:26 +1100
committerAndrew Bartlett <abartlet@samba.org>2010-03-11 11:27:47 +1100
commit0201b2fa9f31d8c9a75f3057f91b3f720f62292c (patch)
tree1e4ea6928f25827ed9af76c44eaffa163c656597 /source4/lib/socket
parent4ab3e220c4188b6c147e1a0fa8ce1e2965d74d43 (diff)
downloadsamba-0201b2fa9f31d8c9a75f3057f91b3f720f62292c.tar.gz
samba-0201b2fa9f31d8c9a75f3057f91b3f720f62292c.tar.bz2
samba-0201b2fa9f31d8c9a75f3057f91b3f720f62292c.zip
s4:lib/socket Add function to set a port on the socket address
Diffstat (limited to 'source4/lib/socket')
-rw-r--r--source4/lib/socket/socket.c12
-rw-r--r--source4/lib/socket/socket.h2
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);