Author: metze
Date: 2005-11-02 17:15:17 +0000 (Wed, 02 Nov 2005)
New Revision: 11480

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11480

Log:
demonstrate the only the positive name query response cares,
not the addresses that are returned in it

metze
Modified:
   branches/SAMBA_4_0/source/torture/nbt/winsreplication.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/nbt/winsreplication.c
===================================================================
--- branches/SAMBA_4_0/source/torture/nbt/winsreplication.c     2005-11-02 
16:48:22 UTC (rev 11479)
+++ branches/SAMBA_4_0/source/torture/nbt/winsreplication.c     2005-11-02 
17:15:17 UTC (rev 11480)
@@ -5531,6 +5531,9 @@
                BOOL positive;
                BOOL expect_release;
                BOOL ret;
+               /* when num_ips == 0, then .wins.ips are used */
+               uint32_t num_ips;
+               const struct wrepl_ip *ips;
        } defend;
        struct {
                enum wrepl_name_type type;
@@ -5616,6 +5619,35 @@
                },
        },
        /*
+        * unique,active vs. unique,active with different ip(s), positive 
response other ips
+        */
+       {
+               .line   = __location__,
+               .name   = _NBT_NAME("_UA_UA_DI_O", 0x00, NULL),
+               .wins   = {
+                       .nb_flags       = 0,
+                       .mhomed         = False,
+                       .num_ips        = ctx->addresses_best_num,
+                       .ips            = ctx->addresses_best,
+                       .apply_expected = True
+               },
+               .defend = {
+                       .timeout        = 10,
+                       .positive       = True,
+                       .num_ips        = ARRAY_SIZE(addresses_A_3_4),
+                       .ips            = addresses_A_3_4,
+               },
+               .replica= {
+                       .type           = WREPL_TYPE_UNIQUE,
+                       .state          = WREPL_STATE_ACTIVE,
+                       .node           = WREPL_NODE_B,
+                       .is_static      = False,
+                       .num_ips        = ARRAY_SIZE(addresses_B_1),
+                       .ips            = addresses_B_1,
+                       .apply_expected = False
+               },
+       },
+       /*
         * unique,active vs. unique,active with different ip(s), negative 
response
         */
        {
@@ -5995,6 +6027,35 @@
                },
        },
        /*
+        * unique,active vs. mhomed,active with different ip(s), positive 
response other ips
+        */
+       {
+               .line   = __location__,
+               .name   = _NBT_NAME("_UA_MA_DI_O", 0x00, NULL),
+               .wins   = {
+                       .nb_flags       = 0,
+                       .mhomed         = False,
+                       .num_ips        = ctx->addresses_best_num,
+                       .ips            = ctx->addresses_best,
+                       .apply_expected = True
+               },
+               .defend = {
+                       .timeout        = 10,
+                       .positive       = True,
+                       .num_ips        = ARRAY_SIZE(addresses_A_3_4),
+                       .ips            = addresses_A_3_4,
+               },
+               .replica= {
+                       .type           = WREPL_TYPE_MHOMED,
+                       .state          = WREPL_STATE_ACTIVE,
+                       .node           = WREPL_NODE_B,
+                       .is_static      = False,
+                       .num_ips        = ARRAY_SIZE(addresses_B_3_4),
+                       .ips            = addresses_B_3_4,
+                       .apply_expected = False
+               },
+       },
+       /*
         * unique,active vs. mhomed,active with different ip(s), negative 
response
         */
        {
@@ -6879,6 +6940,35 @@
                },
        },
        /*
+        * mhomed,active vs. unique,active with different ip(s), positive 
response other ips
+        */
+       {
+               .line   = __location__,
+               .name   = _NBT_NAME("_MA_UA_DI_O", 0x00, NULL),
+               .wins   = {
+                       .nb_flags       = 0,
+                       .mhomed         = True,
+                       .num_ips        = ctx->addresses_best_num,
+                       .ips            = ctx->addresses_best,
+                       .apply_expected = True
+               },
+               .defend = {
+                       .timeout        = 10,
+                       .positive       = True,
+                       .num_ips        = ARRAY_SIZE(addresses_A_3_4),
+                       .ips            = addresses_A_3_4,
+               },
+               .replica= {
+                       .type           = WREPL_TYPE_UNIQUE,
+                       .state          = WREPL_STATE_ACTIVE,
+                       .node           = WREPL_NODE_B,
+                       .is_static      = False,
+                       .num_ips        = ARRAY_SIZE(addresses_B_1),
+                       .ips            = addresses_B_1,
+                       .apply_expected = False
+               },
+       },
+       /*
         * mhomed,active vs. unique,active with different ip(s), negative 
response
         */
        {
@@ -7252,12 +7342,41 @@
                        .state          = WREPL_STATE_ACTIVE,
                        .node           = WREPL_NODE_B,
                        .is_static      = False,
-                       .num_ips        = ARRAY_SIZE(addresses_B_1),
-                       .ips            = addresses_B_1,
+                       .num_ips        = ARRAY_SIZE(addresses_B_3_4),
+                       .ips            = addresses_B_3_4,
                        .apply_expected = False
                },
        },
        /*
+        * mhomed,active vs. mhomed,active with different ip(s), positive 
response other ips
+        */
+       {
+               .line   = __location__,
+               .name   = _NBT_NAME("_MA_MA_DI_O", 0x00, NULL),
+               .wins   = {
+                       .nb_flags       = 0,
+                       .mhomed         = True,
+                       .num_ips        = ctx->addresses_best_num,
+                       .ips            = ctx->addresses_best,
+                       .apply_expected = True
+               },
+               .defend = {
+                       .timeout        = 10,
+                       .positive       = True,
+                       .num_ips        = ARRAY_SIZE(addresses_A_3_4),
+                       .ips            = addresses_A_3_4,
+               },
+               .replica= {
+                       .type           = WREPL_TYPE_MHOMED,
+                       .state          = WREPL_STATE_ACTIVE,
+                       .node           = WREPL_NODE_B,
+                       .is_static      = False,
+                       .num_ips        = ARRAY_SIZE(addresses_B_3_4),
+                       .ips            = addresses_B_3_4,
+                       .apply_expected = False
+               },
+       },
+       /*
         * mhomed,active vs. mhomed,active with different ip(s), negative 
response
         */
        {
@@ -7519,8 +7638,17 @@
        rep_packet->answers[0].ttl       = 0;
 
        if (rec->defend.positive) {
-               uint32_t i;
+               uint32_t i, num_ips;
+               const struct wrepl_ip *ips;             
 
+               if (rec->defend.num_ips > 0) {
+                       num_ips = rec->defend.num_ips;
+                       ips     = rec->defend.ips;
+               } else {
+                       num_ips = rec->wins.num_ips;
+                       ips     = rec->wins.ips;
+               }
+
                /* send a positive reply */
                rep_packet->operation   = 
                                        NBT_FLAG_REPLY | 
@@ -7531,16 +7659,16 @@
 
                rep_packet->answers[0].rr_type   = NBT_QTYPE_NETBIOS;
 
-               rep_packet->answers[0].rdata.netbios.length = 
rec->wins.num_ips*6;
+               rep_packet->answers[0].rdata.netbios.length = num_ips*6;
                rep_packet->answers[0].rdata.netbios.addresses = 
-                       talloc_array(rep_packet->answers, struct 
nbt_rdata_address, rec->wins.num_ips);
+                       talloc_array(rep_packet->answers, struct 
nbt_rdata_address, num_ips);
                if (rep_packet->answers[0].rdata.netbios.addresses == NULL) 
return;
 
-               for (i=0; i < rec->wins.num_ips; i++) {
+               for (i=0; i < num_ips; i++) {
                        struct nbt_rdata_address *addr = 
                                
&rep_packet->answers[0].rdata.netbios.addresses[i];
                        addr->nb_flags  = rec->wins.nb_flags;
-                       addr->ipaddr    = rec->wins.ips[i].ip;
+                       addr->ipaddr    = ips[i].ip;
                }
                DEBUG(2,("Sending positive name query reply for %s to %s:%d\n", 
                        nbt_name_string(rep_packet, name), src->addr, 
src->port));

Reply via email to