diff options
author | Stefan Metzmacher <metze@samba.org> | 2009-12-23 10:43:05 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2009-12-24 17:38:33 +0100 |
commit | d3ee0f021b7670404fdcb6171957dbf06ddf0651 (patch) | |
tree | 0042f9a73d2a4d391b5de946eb23db17c26a1b54 /source4/lib | |
parent | 445baf53a9c0c65dafd8558c2b3ec877c3c5fdc8 (diff) | |
download | samba-d3ee0f021b7670404fdcb6171957dbf06ddf0651.tar.gz samba-d3ee0f021b7670404fdcb6171957dbf06ddf0651.tar.bz2 samba-d3ee0f021b7670404fdcb6171957dbf06ddf0651.zip |
s4:lib/socket: add socket_get_{remote|local}_addr() to get a tsocket_address instead of a socket_address
metze
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/socket/socket.c | 30 | ||||
-rw-r--r-- | source4/lib/socket/socket.h | 2 |
2 files changed, 32 insertions, 0 deletions
diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c index 23eade7b53..30db03fd97 100644 --- a/source4/lib/socket/socket.c +++ b/source4/lib/socket/socket.c @@ -386,6 +386,36 @@ _PUBLIC_ struct socket_address *tsocket_address_to_socket_address(TALLOC_CTX *me return socket_address_from_sockaddr(mem_ctx, (struct sockaddr *)(void *)&ss, ret); } +_PUBLIC_ struct tsocket_address *socket_get_remote_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx) +{ + struct socket_address *a; + struct tsocket_address *r; + + a = socket_get_peer_addr(sock, mem_ctx); + if (a == NULL) { + return NULL; + } + + r = socket_address_to_tsocket_address(mem_ctx, a); + talloc_free(a); + return r; +} + +_PUBLIC_ struct tsocket_address *socket_get_local_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx) +{ + struct socket_address *a; + struct tsocket_address *r; + + a = socket_get_my_addr(sock, mem_ctx); + if (a == NULL) { + return NULL; + } + + r = socket_address_to_tsocket_address(mem_ctx, a); + talloc_free(a); + return r; +} + _PUBLIC_ int socket_get_fd(struct socket_context *sock) { if (!sock->ops->fn_get_fd) { diff --git a/source4/lib/socket/socket.h b/source4/lib/socket/socket.h index 5f29618f14..8f8922bcea 100644 --- a/source4/lib/socket/socket.h +++ b/source4/lib/socket/socket.h @@ -163,6 +163,8 @@ struct tsocket_address *socket_address_to_tsocket_address(TALLOC_CTX *mem_ctx, const struct socket_address *a); struct socket_address *tsocket_address_to_socket_address(TALLOC_CTX *mem_ctx, const struct tsocket_address *a); +struct tsocket_address *socket_get_remote_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx); +struct tsocket_address *socket_get_local_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx); int socket_get_fd(struct socket_context *sock); NTSTATUS socket_dup(struct socket_context *sock); struct socket_address *socket_address_from_strings(TALLOC_CTX *mem_ctx, |