summaryrefslogtreecommitdiff
path: root/source3/lib/util_sock.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util_sock.c')
-rw-r--r--source3/lib/util_sock.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index bdd167b04d..1d62da53c5 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -802,6 +802,11 @@ char *client_addr(void)
return get_peer_addr(client_fd);
}
+char *client_socket_addr(void)
+{
+ return get_socket_addr(client_fd);
+}
+
struct in_addr *client_inaddr(struct sockaddr *sa)
{
struct sockaddr_in *sockin = (struct sockaddr_in *) (sa);
@@ -941,6 +946,29 @@ char *get_peer_addr(int fd)
return addr_buf;
}
+char *get_socket_addr(int fd)
+{
+ struct sockaddr sa;
+ struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
+ int length = sizeof(sa);
+ static fstring addr_buf;
+
+ fstrcpy(addr_buf,"0.0.0.0");
+
+ if (fd == -1) {
+ return addr_buf;
+ }
+
+ if (getsockname(fd, &sa, &length) < 0) {
+ DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) ));
+ return addr_buf;
+ }
+
+ fstrcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr));
+
+ return addr_buf;
+}
+
/*******************************************************************
Create protected unix domain socket.