From 70a15ba4df525838474dce086989582adf6e4de8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 29 Dec 2005 18:54:16 +0000 Subject: r12580: return the first 0x1B address as first address to 0x1C queries metze (This used to be commit 669009579dfe93b4d5008f93c2949dd4d929baf4) --- source4/nbt_server/wins/winsserver.c | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'source4') diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c index e30ac11397..02b2048f73 100644 --- a/source4/nbt_server/wins/winsserver.c +++ b/source4/nbt_server/wins/winsserver.c @@ -334,13 +334,31 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock, struct wins_server *winssrv = iface->nbtsrv->winssrv; struct nbt_name *name = &packet->questions[0].name; struct winsdb_record *rec; + struct winsdb_record *rec_1b = NULL; const char **addresses; + const char **addresses_1b = NULL; uint16_t nb_flags = 0; /* TODO: ... */ if (name->type == NBT_NAME_MASTER) { goto notfound; } + /* + * w2k3 returns the first address of the 0x1B record as first address + * to a 0x1C query + */ + if (name->type == NBT_NAME_LOGON) { + struct nbt_name name_1b; + + name_1b = *name; + name_1b.type = NBT_NAME_PDC; + + status = winsdb_lookup(winssrv->wins_db, &name_1b, packet, &rec_1b); + if (NT_STATUS_IS_OK(status)) { + addresses_1b = winsdb_addr_string_list(packet, rec_1b->addresses); + } + } + status = winsdb_lookup(winssrv->wins_db, name, packet, &rec); if (!NT_STATUS_IS_OK(status)) { goto notfound; @@ -371,6 +389,30 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock, goto notfound; } + /* + * if addresses_1b isn't NULL, we have a 0x1C query and need to return the + * first 0x1B address as first address + */ + if (addresses_1b && addresses_1b[0]) { + const char **addresses_1c = addresses; + uint32_t i; + + addresses = str_list_add(NULL, addresses_1b[0]); + if (!addresses) { + goto notfound; + } + talloc_steal(packet, addresses); + + for (i=0; addresses_1c[i]; i++) { + if (strcmp(addresses_1b[0], addresses_1c[i]) == 0) continue; + + addresses = str_list_add(addresses, addresses_1c[i]); + if (!addresses) { + goto notfound; + } + } + } + found: nbtd_name_query_reply(nbtsock, packet, src, name, 0, nb_flags, addresses); -- cgit