r12580: return the first 0x1B address as first address to 0x1C queries
authorStefan Metzmacher <metze@samba.org>
Thu, 29 Dec 2005 18:54:16 +0000 (18:54 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:48:56 +0000 (13:48 -0500)
metze

source/nbt_server/wins/winsserver.c

index e30ac1139757f2d51168a74e29ec21f8a39eef1c..02b2048f730a1298af2b57289a14e2386158c95a 100644 (file)
@@ -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);