summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2013-11-07 12:15:20 +0100
committerMichael Adam <obnox@samba.org>2013-11-09 13:34:33 +0100
commit2bd919f01e8303aa1efdf39af89132a6ab9388cb (patch)
tree1701cc7ea1d60f9792505068c20054be38ac51f8 /src
parent7eea1638bc881c4466367102919fe393b4ceb724 (diff)
sock: add addr argument to listen_sock()
instead of using config.ipAddr internally. This is in preparation to make it possible to call it for multiple addresses. Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/child.c2
-rw-r--r--src/sock.c4
-rw-r--r--src/sock.h2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/child.c b/src/child.c
index 9f8ae10..3ed4030 100644
--- a/src/child.c
+++ b/src/child.c
@@ -466,7 +466,7 @@ void child_kill_children (int sig)
int child_listening_sock (uint16_t port)
{
- listenfd = listen_sock (port);
+ listenfd = listen_sock (config.ipAddr, port);
return listenfd;
}
diff --git a/src/sock.c b/src/sock.c
index b9691ef..fe28de6 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -166,7 +166,7 @@ int socket_blocking (int sock)
* Start listening on a socket. Create a socket with the selected port.
* The socket fd is returned upon success, -1 upon error.
*/
-int listen_sock (uint16_t port)
+int listen_sock (const char *addr, uint16_t port)
{
struct addrinfo hints, *result, *rp;
char portstr[6];
@@ -182,7 +182,7 @@ int listen_sock (uint16_t port)
snprintf (portstr, sizeof (portstr), "%d", port);
- if (getaddrinfo (config.ipAddr, portstr, &hints, &result) != 0) {
+ if (getaddrinfo (addr, portstr, &hints, &result) != 0) {
log_message (LOG_ERR,
"Unable to getaddrinfo() because of %s",
strerror (errno));
diff --git a/src/sock.h b/src/sock.h
index 5ed7e35..5cca744 100644
--- a/src/sock.h
+++ b/src/sock.h
@@ -29,7 +29,7 @@
#define MAXLINE (1024 * 4)
extern int opensock (const char *host, int port, const char *bind_to);
-extern int listen_sock (uint16_t port);
+extern int listen_sock (const char *addr, uint16_t port);
extern int socket_nonblocking (int sock);
extern int socket_blocking (int sock);