return true;
}
+static size_t smbd_open_socket_for_ip(struct smbd_parent_context *parent,
+ struct tevent_context *ev_ctx,
+ const char *smb_ports,
+ const struct sockaddr_storage *ifss);
+
/****************************************************************************
Open the socket communication.
****************************************************************************/
for(i = 0; i < num_interfaces; i++) {
const struct sockaddr_storage *ifss =
iface_n_sockaddr_storage(i);
+ size_t num_ok;
+
if (ifss == NULL) {
DEBUG(0,("open_sockets_smbd: "
"interface %d has NULL IP address !\n",
continue;
}
- for (j = 0; ports && ports[j]; j++) {
- unsigned port = atoi(ports[j]);
-
- if (!smbd_open_one_socket(parent,
- ev_ctx,
- ifss,
- port)) {
- return false;
- }
+ num_ok = smbd_open_socket_for_ip(parent,
+ ev_ctx,
+ smb_ports,
+ ifss);
+ if (num_ok == 0) {
+ return false;
}
}
} else {
for (i = 0; i < ARRAY_SIZE(sock_addrs); i++) {
const char *sock_tok = sock_addrs[i];
struct sockaddr_storage ss;
+ size_t num_ok;
/* open an incoming socket */
if (!interpret_string_addr(&ss, sock_tok,
continue;
}
- for (j = 0; ports && ports[j]; j++) {
- unsigned port = atoi(ports[j]);
-
+ num_ok = smbd_open_socket_for_ip(parent,
+ ev_ctx,
+ smb_ports,
+ &ss);
+ if (num_ok == 0) {
/*
* If we fail to open any sockets
* in this loop the parent-sockets == NULL
* case below will prevent us from starting.
*/
-
- (void)smbd_open_one_socket(parent,
- ev_ctx,
- &ss,
- port);
}
}
}