sock: add addr argument to listen_sock()
authorMichael Adam <obnox@samba.org>
Thu, 7 Nov 2013 11:15:20 +0000 (12:15 +0100)
committerMichael Adam <obnox@samba.org>
Sat, 9 Nov 2013 12:34:33 +0000 (13:34 +0100)
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>
src/child.c
src/sock.c
src/sock.h

index 9f8ae10e70ece946db4ce7194d02fc1aba5ae8c3..3ed403017ec4e47ac71c280347b842283a5bfcd1 100644 (file)
@@ -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;
 }
 
index b9691ef770328879973dec99379bb365de939506..fe28de626f4d7c699da656d9462611e4f94fda1d 100644 (file)
@@ -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));
index 5ed7e35cd73102a79cee572a8a239e15f7253946..5cca744c8dd894bb66b375f0ebbad52b2f36f790 100644 (file)
@@ -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);