diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-11-14 01:50:55 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:46:16 -0500 |
commit | cbb7a47cf269dd741ae43be22cc27bf9035ac59e (patch) | |
tree | 484cb102a514128227a4048e89eb4489790f20b3 /source4 | |
parent | df4624870b6edbf6c426ae5bc2807dcee205e69f (diff) | |
download | samba-cbb7a47cf269dd741ae43be22cc27bf9035ac59e.tar.gz samba-cbb7a47cf269dd741ae43be22cc27bf9035ac59e.tar.bz2 samba-cbb7a47cf269dd741ae43be22cc27bf9035ac59e.zip |
r11711: fixed the nbt server to use the right interface for outgoing requests
(This used to be commit d87df5fe8e37d3daa3d9cb575450d756dc3d3c8f)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/nbt_server/interfaces.c | 24 | ||||
-rw-r--r-- | source4/nbt_server/irpc.c | 9 |
2 files changed, 27 insertions, 6 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; +} diff --git a/source4/nbt_server/irpc.c b/source4/nbt_server/irpc.c index 75a950b5c4..0cd65453a4 100644 --- a/source4/nbt_server/irpc.c +++ b/source4/nbt_server/irpc.c @@ -115,11 +115,10 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg, { struct nbtd_server *server = talloc_get_type(msg->private, struct nbtd_server); - + struct nbtd_interface *iface = nbtd_find_interface(server, req->in.ip_address); struct getdc_state *s; struct nbt_ntlogon_packet p; struct nbt_ntlogon_sam_logon *r; - struct nbt_dgram_socket *sock; struct nbt_name src, dst; struct nbt_peer_socket dest; struct dgram_mailslot_handler *handler; @@ -127,15 +126,13 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg, DEBUG(0, ("nbtd_getdcname called\n")); - sock = server->interfaces[0].dgmsock; - s = talloc(msg, struct getdc_state); NT_STATUS_HAVE_NO_MEMORY(s); s->msg = msg; s->req = req; - handler = dgram_mailslot_temp(sock, NBT_MAILSLOT_GETDC, + handler = dgram_mailslot_temp(iface->dgmsock, NBT_MAILSLOT_GETDC, getdc_recv_ntlogon_reply, s); NT_STATUS_HAVE_NO_MEMORY(handler); @@ -157,7 +154,7 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg, dest.addr = req->in.ip_address; dest.port = 138; - status = dgram_mailslot_ntlogon_send(sock, DGRAM_DIRECT_GROUP, + status = dgram_mailslot_ntlogon_send(iface->dgmsock, DGRAM_DIRECT_GROUP, &dst, &dest, &src, &p); if (!NT_STATUS_IS_OK(status)) { |