summaryrefslogtreecommitdiff
path: root/source4/nbt_server/interfaces.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/nbt_server/interfaces.c')
-rw-r--r--source4/nbt_server/interfaces.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c
index 23276123d5..4ef2afb8ee 100644
--- a/source4/nbt_server/interfaces.c
+++ b/source4/nbt_server/interfaces.c
@@ -286,3 +286,27 @@ failed:
talloc_free(ret);
return NULL;
}
+
+
+/*
+ find the interface to use for sending a outgoing request
+*/
+struct nbtd_interface *nbtd_find_interface(struct nbtd_server *nbtd_server,
+ const char *address)
+{
+ struct nbtd_interface *iface;
+ /* try to find a exact match */
+ for (iface=nbtd_server->interfaces;iface;iface=iface->next) {
+ if (iface_same_net(address, iface->ip_address, iface->netmask)) {
+ return iface;
+ }
+ }
+
+ /* no exact match, if we have the broadcast interface, use that */
+ if (nbtd_server->bcast_interface) {
+ return nbtd_server->bcast_interface;
+ }
+
+ /* fallback to first interface */
+ return nbtd_server->interfaces;
+}