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>
(cherry picked from commit 2bd919f01e
)
This commit is contained in:
parent
ccb987e8e0
commit
a8a2342527
@ -466,7 +466,7 @@ void child_kill_children (int sig)
|
|||||||
|
|
||||||
int child_listening_sock (uint16_t port)
|
int child_listening_sock (uint16_t port)
|
||||||
{
|
{
|
||||||
listenfd = listen_sock (port);
|
listenfd = listen_sock (config.ipAddr, port);
|
||||||
return listenfd;
|
return listenfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ int socket_blocking (int sock)
|
|||||||
* Start listening on a socket. Create a socket with the selected port.
|
* Start listening on a socket. Create a socket with the selected port.
|
||||||
* The socket fd is returned upon success, -1 upon error.
|
* 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;
|
struct addrinfo hints, *result, *rp;
|
||||||
char portstr[6];
|
char portstr[6];
|
||||||
@ -182,7 +182,7 @@ int listen_sock (uint16_t port)
|
|||||||
|
|
||||||
snprintf (portstr, sizeof (portstr), "%d", 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,
|
log_message (LOG_ERR,
|
||||||
"Unable to getaddrinfo() because of %s",
|
"Unable to getaddrinfo() because of %s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#define MAXLINE (1024 * 4)
|
#define MAXLINE (1024 * 4)
|
||||||
|
|
||||||
extern int opensock (const char *host, int port, const char *bind_to);
|
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_nonblocking (int sock);
|
||||||
extern int socket_blocking (int sock);
|
extern int socket_blocking (int sock);
|
||||||
|
Loading…
Reference in New Issue
Block a user