}
return iface_n_ip(0);
}
+
+/*
+ return True if an IP is one one of our local networks
+*/
+BOOL iface_is_local(const char *dest)
+{
+ struct in_addr ip;
+ ip.s_addr = interpret_addr(dest);
+ if (iface_find(ip, True)) {
+ return True;
+ }
+ return False;
+}
c->state = SMBCLI_REQUEST_ERROR;
c->status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
} else {
+ struct nbt_name_query *q = &state->io_queries[i];
c->state = SMBCLI_REQUEST_DONE;
- state->reply_addr = talloc_steal(state, state->io_queries[i].out.reply_addrs[0]);
+ /* favor a local address if possible */
+ state->reply_addr = NULL;
+ for (i=0;i<q->out.num_addrs;i++) {
+ if (iface_is_local(q->out.reply_addrs[i])) {
+ state->reply_addr = talloc_steal(state,
+ q->out.reply_addrs[i]);
+ break;
+ }
+ }
+ if (state->reply_addr == NULL) {
+ state->reply_addr = talloc_steal(state,
+ q->out.reply_addrs[0]);
+ }
}
}