summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2004-06-10 17:09:00 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:51:55 -0500
commit76ca0f6f3f57c487564697c795da65672bbf4052 (patch)
tree18c473f3522154958bf2f906d470db769bd9d780 /source3/lib
parent8018892b3c63fdb7cf0d0a72cba59f847cee718d (diff)
downloadsamba-76ca0f6f3f57c487564697c795da65672bbf4052.tar.gz
samba-76ca0f6f3f57c487564697c795da65672bbf4052.tar.bz2
samba-76ca0f6f3f57c487564697c795da65672bbf4052.zip
r1104: get_called_name is used in the printing subsystem. In case of multi-homed
servers we need to make sure that the clients are given back the IP address they connected to. Volker (This used to be commit 5f482df169eebae87ec769a05e3c3fc6e32af1e3)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_sock.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index b6bfdca5cf..4b9881a449 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -52,6 +52,23 @@ static char *get_socket_addr(int fd)
return addr_buf;
}
+static int get_socket_port(int fd)
+{
+ struct sockaddr sa;
+ struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
+ socklen_t length = sizeof(sa);
+
+ if (fd == -1)
+ return -1;
+
+ if (getsockname(fd, &sa, &length) < 0) {
+ DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) ));
+ return -1;
+ }
+
+ return ntohs(sockin->sin_port);
+}
+
/****************************************************************************
Determine if a file descriptor is in fact a socket.
****************************************************************************/
@@ -837,6 +854,11 @@ char *client_socket_addr(void)
return get_socket_addr(client_fd);
}
+int client_socket_port(void)
+{
+ return get_socket_port(client_fd);
+}
+
struct in_addr *client_inaddr(struct sockaddr *sa)
{
struct sockaddr_in *sockin = (struct sockaddr_in *) (sa);