1
0
mirror of https://github.com/samba-team/samba.git synced 2025-09-20 17:44:21 +03:00

r11711: fixed the nbt server to use the right interface for outgoing requests

(This used to be commit d87df5fe8e)
This commit is contained in:
Andrew Tridgell
2005-11-14 01:50:55 +00:00
committed by Gerald (Jerry) Carter
parent df4624870b
commit cbb7a47cf2
2 changed files with 27 additions and 6 deletions

View File

@@ -286,3 +286,27 @@ failed:
talloc_free(ret); talloc_free(ret);
return NULL; 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;
}

View File

@@ -115,11 +115,10 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
{ {
struct nbtd_server *server = struct nbtd_server *server =
talloc_get_type(msg->private, struct nbtd_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 getdc_state *s;
struct nbt_ntlogon_packet p; struct nbt_ntlogon_packet p;
struct nbt_ntlogon_sam_logon *r; struct nbt_ntlogon_sam_logon *r;
struct nbt_dgram_socket *sock;
struct nbt_name src, dst; struct nbt_name src, dst;
struct nbt_peer_socket dest; struct nbt_peer_socket dest;
struct dgram_mailslot_handler *handler; struct dgram_mailslot_handler *handler;
@@ -127,15 +126,13 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
DEBUG(0, ("nbtd_getdcname called\n")); DEBUG(0, ("nbtd_getdcname called\n"));
sock = server->interfaces[0].dgmsock;
s = talloc(msg, struct getdc_state); s = talloc(msg, struct getdc_state);
NT_STATUS_HAVE_NO_MEMORY(s); NT_STATUS_HAVE_NO_MEMORY(s);
s->msg = msg; s->msg = msg;
s->req = req; 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); getdc_recv_ntlogon_reply, s);
NT_STATUS_HAVE_NO_MEMORY(handler); 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.addr = req->in.ip_address;
dest.port = 138; dest.port = 138;
status = dgram_mailslot_ntlogon_send(sock, DGRAM_DIRECT_GROUP, status = dgram_mailslot_ntlogon_send(iface->dgmsock, DGRAM_DIRECT_GROUP,
&dst, &dest, &dst, &dest,
&src, &p); &src, &p);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {