- if we have no configured network interfaces, then don't start nbtd (when I add dynamic
interface loading this will change to a delay until a network interface comes up)
- choose the best interface by netmask for torture tests that need a
specific IP (such as the WINS test). Added iface_best_ip() for that.
- if specific interfaces are chosen in smb.conf, then keep that ordering, and
default to the first one listed
(This used to be commit
4d08c114079ef6d1d10a96195046fe43631aefa2)
iface->nmask = tov4(nmask);
iface->bcast.addr = MKBCADDR(iface->ip.addr, iface->nmask.addr);
- DLIST_ADD(local_interfaces, iface);
+ DLIST_ADD_END(local_interfaces, iface, struct interface *);
DEBUG(2,("added interface ip=%s ",sys_inet_ntoa(iface->ip)));
DEBUG(2,("bcast=%s ",sys_inet_ntoa(iface->bcast)));
return NULL;
}
+/*
+ return the local IP address that best matches a destination IP, or
+ our first interface if none match
+*/
+const char *iface_best_ip(const char *dest)
+{
+ struct interface *iface;
+ struct in_addr ip;
+ ip.s_addr = interpret_addr(dest);
+ iface = iface_find(ip, True);
+ if (iface) {
+ return sys_inet_ntoa(iface->ip);
+ }
+ return iface_n_ip(0);
+}
struct nbtd_server *nbtsrv;
NTSTATUS status;
+ if (iface_count() == 0) {
+ task_terminate(task, "nbtd: no network interfaces configured");
+ return;
+ }
+
nbtsrv = talloc(task, struct nbtd_server);
if (nbtsrv == NULL) {
task_terminate(task, "nbtd: out of memory");
/* called when a task goes down */
static void single_terminate(struct event_context *ev, const char *reason)
{
+ DEBUG(2,("single_terminate: reason[%s]\n",reason));
}
static const struct model_ops single_ops = {
{
struct event_context *event_ctx = task->event_ctx;
const struct model_ops *model_ops = task->model_ops;
+ DEBUG(0,("task_terminate: [%s]\n", reason));
talloc_free(task);
model_ops->terminate(event_ctx, reason);
}
NTSTATUS status;
struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL);
BOOL ret = True;
- const char *myaddress = iface_n_ip(0);
+ const char *myaddress = iface_best_ip(address);
socket_listen(nbtsock->sock, myaddress, 0, 0, 0);
NTSTATUS status;
struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL);
BOOL ret = True;
- const char *myaddress = iface_n_ip(0);
+ const char *myaddress = iface_best_ip(address);
socket_listen(nbtsock->sock, myaddress, 0, 0, 0);
NTSTATUS status;
struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL);
BOOL ret = True;
- const char *myaddress = talloc_strdup(mem_ctx, iface_n_ip(0));
+ const char *myaddress = talloc_strdup(mem_ctx, iface_best_ip(address));
/* we do the listen here to ensure the WINS server receives the packets from
the right IP */
state->num_names = torture_entries;
state->registered = talloc_zero_array(state, BOOL, state->num_names);
state->wins_server = address;
- state->my_ip = talloc_strdup(mem_ctx, iface_n_ip(0));
+ state->my_ip = talloc_strdup(mem_ctx, iface_best_ip(address));
state->ttl = timelimit;
socket_listen(nbtsock->sock, state->my_ip, 0, 0, 0);