r11484: test some multi homed record merging
[abartlet/samba.git/.git] / source4 / torture / nbt / winsreplication.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    WINS replication testing
5
6    Copyright (C) Andrew Tridgell 2005
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "libcli/nbt/libnbt.h"
25 #include "libcli/wrepl/winsrepl.h"
26 #include "lib/events/events.h"
27 #include "lib/socket/socket.h"
28 #include "system/time.h"
29
30 #define CHECK_STATUS(status, correct) do { \
31         if (!NT_STATUS_EQUAL(status, correct)) { \
32                 printf("(%s) Incorrect status %s - should be %s\n", \
33                        __location__, nt_errstr(status), nt_errstr(correct)); \
34                 ret = False; \
35                 goto done; \
36         }} while (0)
37
38 #define CHECK_VALUE(v, correct) do { \
39         if ((v) != (correct)) { \
40                 printf("(%s) Incorrect value %s=%d - should be %d\n", \
41                        __location__, #v, v, correct); \
42                 ret = False; \
43                 goto done; \
44         }} while (0)
45
46 #define CHECK_VALUE_UINT64(v, correct) do { \
47         if ((v) != (correct)) { \
48                 printf("(%s) Incorrect value %s=%llu - should be %llu\n", \
49                        __location__, #v, v, correct); \
50                 ret = False; \
51                 goto done; \
52         }} while (0)
53
54 #define CHECK_VALUE_STRING(v, correct) do { \
55         if ( ((!v) && (correct)) || \
56              ((v) && (!correct)) || \
57              ((v) && (correct) && strcmp(v,correct) != 0)) { \
58                 printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \
59                        __location__, #v, v, correct); \
60                 ret = False; \
61                 goto done; \
62         }} while (0)
63
64 #define _NBT_NAME(n,t,s) {\
65         .name   = n,\
66         .type   = t,\
67         .scope  = s\
68 }
69
70 static const char *wrepl_name_type_string(enum wrepl_name_type type)
71 {
72         switch (type) {
73         case WREPL_TYPE_UNIQUE: return "UNIQUE";
74         case WREPL_TYPE_GROUP: return "GROUP";
75         case WREPL_TYPE_SGROUP: return "SGROUP";
76         case WREPL_TYPE_MHOMED: return "MHOMED";
77         }
78         return "UNKNOWN_TYPE";
79 }
80
81 static const char *wrepl_name_state_string(enum wrepl_name_state state)
82 {
83         switch (state) {
84         case WREPL_STATE_ACTIVE: return "ACTIVE";
85         case WREPL_STATE_RELEASED: return "RELEASED";
86         case WREPL_STATE_TOMBSTONE: return "TOMBSTONE";
87         case WREPL_STATE_RESERVED: return "RESERVED";
88         }
89         return "UNKNOWN_STATE";
90 }
91
92 /*
93   test how assoc_ctx's are only usable on the connection
94   they are created on.
95 */
96 static BOOL test_assoc_ctx1(TALLOC_CTX *mem_ctx, const char *address)
97 {
98         BOOL ret = True;
99         struct wrepl_request *req;
100         struct wrepl_socket *wrepl_socket1;
101         struct wrepl_associate associate1;
102         struct wrepl_socket *wrepl_socket2;
103         struct wrepl_associate associate2;
104         struct wrepl_pull_table pull_table;
105         struct wrepl_packet *rep_packet;
106         struct wrepl_associate_stop assoc_stop;
107         NTSTATUS status;
108
109         if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
110                 printf("winsrepl: cross connection assoc_ctx usage disabled - enable dangerous tests to use\n");
111                 return True;
112         }
113
114         printf("Test if assoc_ctx is only valid on the conection it was created on\n");
115
116         wrepl_socket1 = wrepl_socket_init(mem_ctx, NULL);
117         wrepl_socket2 = wrepl_socket_init(mem_ctx, NULL);
118
119         printf("Setup 2 wrepl connections\n");
120         status = wrepl_connect(wrepl_socket1, NULL, address);
121         CHECK_STATUS(status, NT_STATUS_OK);
122
123         status = wrepl_connect(wrepl_socket2, NULL, address);
124         CHECK_STATUS(status, NT_STATUS_OK);
125
126         printf("Send a start association request (conn1)\n");
127         status = wrepl_associate(wrepl_socket1, &associate1);
128         CHECK_STATUS(status, NT_STATUS_OK);
129
130         printf("association context (conn1): 0x%x\n", associate1.out.assoc_ctx);
131
132         printf("Send a start association request (conn2)\n");
133         status = wrepl_associate(wrepl_socket2, &associate2);
134         CHECK_STATUS(status, NT_STATUS_OK);
135
136         printf("association context (conn2): 0x%x\n", associate2.out.assoc_ctx);
137
138         printf("Send a replication table query, with assoc 1 (conn2), the anwser should be on conn1\n");
139         pull_table.in.assoc_ctx = associate1.out.assoc_ctx;
140         req = wrepl_pull_table_send(wrepl_socket2, &pull_table);
141         req->send_only = True;
142         status = wrepl_request_recv(req, mem_ctx, &rep_packet);
143         CHECK_STATUS(status, NT_STATUS_OK);
144
145         printf("Send a association request (conn2), to make sure the last request was ignored\n");
146         status = wrepl_associate(wrepl_socket2, &associate2);
147         CHECK_STATUS(status, NT_STATUS_OK);
148
149         printf("Send a replication table query, with invalid assoc (conn1), receive answer from conn2\n");
150         pull_table.in.assoc_ctx = 0;
151         req = wrepl_pull_table_send(wrepl_socket1, &pull_table);
152         status = wrepl_request_recv(req, mem_ctx, &rep_packet);
153         CHECK_STATUS(status, NT_STATUS_OK);
154
155         printf("Send a association request (conn1), to make sure the last request was handled correct\n");
156         status = wrepl_associate(wrepl_socket1, &associate2);
157         CHECK_STATUS(status, NT_STATUS_OK);
158
159         assoc_stop.in.assoc_ctx = associate1.out.assoc_ctx;
160         assoc_stop.in.reason    = 4;
161         printf("Send a association stop request (conn1), reson: %u\n", assoc_stop.in.reason);
162         status = wrepl_associate_stop(wrepl_socket1, &assoc_stop);
163         CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
164
165         assoc_stop.in.assoc_ctx = associate2.out.assoc_ctx;
166         assoc_stop.in.reason    = 0;
167         printf("Send a association stop request (conn2), reson: %u\n", assoc_stop.in.reason);
168         status = wrepl_associate_stop(wrepl_socket2, &assoc_stop);
169         CHECK_STATUS(status, NT_STATUS_OK);
170
171 done:
172         printf("Close 2 wrepl connections\n");
173         talloc_free(wrepl_socket1);
174         talloc_free(wrepl_socket2);
175         return ret;
176 }
177
178 /*
179   test if we always get back the same assoc_ctx
180 */
181 static BOOL test_assoc_ctx2(TALLOC_CTX *mem_ctx, const char *address)
182 {
183         BOOL ret = True;
184         struct wrepl_socket *wrepl_socket;
185         struct wrepl_associate associate;
186         uint32_t assoc_ctx1;
187         NTSTATUS status;
188
189         printf("Test if we always get back the same assoc_ctx\n");
190
191         wrepl_socket = wrepl_socket_init(mem_ctx, NULL);
192         
193         printf("Setup wrepl connections\n");
194         status = wrepl_connect(wrepl_socket, NULL, address);
195         CHECK_STATUS(status, NT_STATUS_OK);
196
197
198         printf("Send 1st start association request\n");
199         status = wrepl_associate(wrepl_socket, &associate);
200         CHECK_STATUS(status, NT_STATUS_OK);
201         assoc_ctx1 = associate.out.assoc_ctx;
202         printf("1st association context: 0x%x\n", associate.out.assoc_ctx);
203
204         printf("Send 2nd start association request\n");
205         status = wrepl_associate(wrepl_socket, &associate);
206         CHECK_VALUE(associate.out.assoc_ctx, assoc_ctx1);
207         CHECK_STATUS(status, NT_STATUS_OK);
208         printf("2nd association context: 0x%x\n", associate.out.assoc_ctx);
209
210         printf("Send 3rd start association request\n");
211         status = wrepl_associate(wrepl_socket, &associate);
212         CHECK_VALUE(associate.out.assoc_ctx, assoc_ctx1);
213         CHECK_STATUS(status, NT_STATUS_OK);
214         printf("3rd association context: 0x%x\n", associate.out.assoc_ctx);
215
216 done:
217         printf("Close wrepl connections\n");
218         talloc_free(wrepl_socket);
219         return ret;
220 }
221
222
223 /*
224   display a replication entry
225 */
226 static void display_entry(TALLOC_CTX *mem_ctx, struct wrepl_name *name)
227 {
228         int i;
229
230         printf("%s\n", nbt_name_string(mem_ctx, &name->name));
231         printf("\tTYPE:%u STATE:%u NODE:%u STATIC:%u VERSION_ID: %llu\n",
232                 name->type, name->state, name->node, name->is_static, name->version_id);
233         printf("\tRAW_FLAGS: 0x%08X OWNER: %-15s\n",
234                 name->raw_flags, name->owner);
235         for (i=0;i<name->num_addresses;i++) {
236                 printf("\tADDR: %-15s OWNER: %-15s\n", 
237                         name->addresses[i].address, name->addresses[i].owner);
238         }
239 }
240
241 /*
242   test a full replication dump from a WINS server
243 */
244 static BOOL test_wins_replication(TALLOC_CTX *mem_ctx, const char *address)
245 {
246         BOOL ret = True;
247         struct wrepl_socket *wrepl_socket;
248         NTSTATUS status;
249         int i, j;
250         struct wrepl_associate associate;
251         struct wrepl_pull_table pull_table;
252         struct wrepl_pull_names pull_names;
253
254         printf("Test one pull replication cycle\n");
255
256         wrepl_socket = wrepl_socket_init(mem_ctx, NULL);
257         
258         printf("Setup wrepl connections\n");
259         status = wrepl_connect(wrepl_socket, NULL, address);
260         CHECK_STATUS(status, NT_STATUS_OK);
261
262         printf("Send a start association request\n");
263
264         status = wrepl_associate(wrepl_socket, &associate);
265         CHECK_STATUS(status, NT_STATUS_OK);
266
267         printf("association context: 0x%x\n", associate.out.assoc_ctx);
268
269         printf("Send a replication table query\n");
270         pull_table.in.assoc_ctx = associate.out.assoc_ctx;
271
272         status = wrepl_pull_table(wrepl_socket, mem_ctx, &pull_table);
273         if (NT_STATUS_EQUAL(NT_STATUS_NETWORK_ACCESS_DENIED,status)) {
274                 struct wrepl_packet packet;
275                 struct wrepl_request *req;
276
277                 ZERO_STRUCT(packet);
278                 packet.opcode                      = WREPL_OPCODE_BITS;
279                 packet.assoc_ctx                   = associate.out.assoc_ctx;
280                 packet.mess_type                   = WREPL_STOP_ASSOCIATION;
281                 packet.message.stop.reason         = 0;
282
283                 req = wrepl_request_send(wrepl_socket, &packet);
284                 talloc_free(req);
285
286                 printf("failed - We are not a valid pull partner for the server\n");
287                 ret = False;
288                 goto done;
289         }
290         CHECK_STATUS(status, NT_STATUS_OK);
291
292         printf("Found %d replication partners\n", pull_table.out.num_partners);
293
294         for (i=0;i<pull_table.out.num_partners;i++) {
295                 struct wrepl_wins_owner *partner = &pull_table.out.partners[i];
296                 printf("%s   max_version=%6llu   min_version=%6llu type=%d\n",
297                        partner->address, 
298                        partner->max_version, 
299                        partner->min_version, 
300                        partner->type);
301
302                 pull_names.in.assoc_ctx = associate.out.assoc_ctx;
303                 pull_names.in.partner = *partner;
304                 
305                 status = wrepl_pull_names(wrepl_socket, mem_ctx, &pull_names);
306                 CHECK_STATUS(status, NT_STATUS_OK);
307
308                 printf("Received %d names\n", pull_names.out.num_names);
309
310                 for (j=0;j<pull_names.out.num_names;j++) {
311                         display_entry(mem_ctx, &pull_names.out.names[j]);
312                 }
313         }
314
315 done:
316         printf("Close wrepl connections\n");
317         talloc_free(wrepl_socket);
318         return ret;
319 }
320
321 struct test_wrepl_conflict_conn {
322         const char *address;
323         struct wrepl_socket *pull;
324         uint32_t pull_assoc;
325
326 #define TEST_OWNER_A_ADDRESS "127.65.65.1"
327 #define TEST_ADDRESS_A_PREFIX "127.0.65"
328 #define TEST_OWNER_B_ADDRESS "127.66.66.1"
329 #define TEST_ADDRESS_B_PREFIX "127.0.66"
330
331         struct wrepl_wins_owner a, b, c;
332
333         const char *myaddr;
334         const char *myaddr2;
335         struct nbt_name_socket *nbtsock;
336         struct nbt_name_socket *nbtsock2;
337
338         struct nbt_name_socket *nbtsock_srv;
339         struct nbt_name_socket *nbtsock_srv2;
340
341         uint32_t addresses_best_num;
342         struct wrepl_ip *addresses_best;
343
344         uint32_t addresses_best2_num;
345         struct wrepl_ip *addresses_best2;
346
347         uint32_t addresses_all_num;
348         struct wrepl_ip *addresses_all;
349
350         uint32_t addresses_mhomed_num;
351         struct wrepl_ip *addresses_mhomed;
352 };
353
354 static const struct wrepl_ip addresses_A_1[] = {
355         {
356         .owner  = TEST_OWNER_A_ADDRESS,
357         .ip     = TEST_ADDRESS_A_PREFIX".1"
358         }
359 };
360 static const struct wrepl_ip addresses_A_2[] = {
361         {
362         .owner  = TEST_OWNER_A_ADDRESS,
363         .ip     = TEST_ADDRESS_A_PREFIX".2"
364         }
365 };
366 static const struct wrepl_ip addresses_A_3_4[] = {
367         {
368         .owner  = TEST_OWNER_A_ADDRESS,
369         .ip     = TEST_ADDRESS_A_PREFIX".3"
370         },
371         {
372         .owner  = TEST_OWNER_A_ADDRESS,
373         .ip     = TEST_ADDRESS_A_PREFIX".4"
374         }
375 };
376
377 static const struct wrepl_ip addresses_B_1[] = {
378         {
379         .owner  = TEST_OWNER_B_ADDRESS,
380         .ip     = TEST_ADDRESS_B_PREFIX".1"
381         }
382 };
383 static const struct wrepl_ip addresses_B_2[] = {
384         {
385         .owner  = TEST_OWNER_B_ADDRESS,
386         .ip     = TEST_ADDRESS_B_PREFIX".2"
387         }
388 };
389 static const struct wrepl_ip addresses_B_3_4[] = {
390         {
391         .owner  = TEST_OWNER_B_ADDRESS,
392         .ip     = TEST_ADDRESS_B_PREFIX".3"
393         },
394         {
395         .owner  = TEST_OWNER_B_ADDRESS,
396         .ip     = TEST_ADDRESS_B_PREFIX".4"
397         }
398 };
399
400 static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *mem_ctx,
401                                                                  const char *address)
402 {
403         struct test_wrepl_conflict_conn *ctx;
404         struct wrepl_associate associate;
405         struct wrepl_pull_table pull_table;
406         NTSTATUS status;
407         uint32_t i;
408
409         ctx = talloc_zero(mem_ctx, struct test_wrepl_conflict_conn);
410         if (!ctx) return NULL;
411
412         ctx->address    = address;
413         ctx->pull       = wrepl_socket_init(ctx, NULL);
414         if (!ctx->pull) return NULL;
415
416         printf("Setup wrepl conflict pull connection\n");
417         status = wrepl_connect(ctx->pull, NULL, ctx->address);
418         if (!NT_STATUS_IS_OK(status)) return NULL;
419
420         status = wrepl_associate(ctx->pull, &associate);
421         if (!NT_STATUS_IS_OK(status)) return NULL;
422
423         ctx->pull_assoc = associate.out.assoc_ctx;
424
425         ctx->a.address          = TEST_OWNER_A_ADDRESS;
426         ctx->a.max_version      = 0;
427         ctx->a.min_version      = 0;
428         ctx->a.type             = 1;
429
430         ctx->b.address          = TEST_OWNER_B_ADDRESS;
431         ctx->b.max_version      = 0;
432         ctx->b.min_version      = 0;
433         ctx->b.type             = 1;
434
435         ctx->c.address          = address;
436         ctx->c.max_version      = 0;
437         ctx->c.min_version      = 0;
438         ctx->c.type             = 1;
439
440         pull_table.in.assoc_ctx = ctx->pull_assoc;
441         status = wrepl_pull_table(ctx->pull, ctx->pull, &pull_table);
442         if (!NT_STATUS_IS_OK(status)) return NULL;
443
444         for (i=0; i < pull_table.out.num_partners; i++) {
445                 if (strcmp(TEST_OWNER_A_ADDRESS,pull_table.out.partners[i].address)==0) {
446                         ctx->a.max_version      = pull_table.out.partners[i].max_version;
447                         ctx->a.min_version      = pull_table.out.partners[i].min_version;
448                 }
449                 if (strcmp(TEST_OWNER_B_ADDRESS,pull_table.out.partners[i].address)==0) {
450                         ctx->b.max_version      = pull_table.out.partners[i].max_version;
451                         ctx->b.min_version      = pull_table.out.partners[i].min_version;
452                 }
453                 if (strcmp(address,pull_table.out.partners[i].address)==0) {
454                         ctx->c.max_version      = pull_table.out.partners[i].max_version;
455                         ctx->c.min_version      = pull_table.out.partners[i].min_version;
456                 }
457         }
458
459         talloc_free(pull_table.out.partners);
460
461         ctx->myaddr = talloc_strdup(mem_ctx, iface_best_ip(address));
462         if (!ctx->myaddr) return NULL;
463
464         for (i = 0; i < iface_count(); i++) {
465                 if (strcmp(ctx->myaddr, iface_n_ip(i)) == 0) continue;
466                 ctx->myaddr2 = talloc_strdup(mem_ctx, iface_n_ip(i));
467                 if (!ctx->myaddr2) return NULL;
468                 break;
469         }
470
471         ctx->nbtsock = nbt_name_socket_init(ctx, NULL);
472         if (!ctx->nbtsock) return NULL;
473
474         status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0, 0);
475         if (!NT_STATUS_IS_OK(status)) return NULL;
476
477         ctx->nbtsock_srv = nbt_name_socket_init(ctx, NULL);
478         if (!ctx->nbtsock_srv) return NULL;
479
480         status = socket_listen(ctx->nbtsock_srv->sock, ctx->myaddr, lp_nbt_port(), 0, 0);
481         if (!NT_STATUS_IS_OK(status)) {
482                 talloc_free(ctx->nbtsock_srv);
483                 ctx->nbtsock_srv = NULL;
484         }
485
486         if (ctx->myaddr2) {
487                 ctx->nbtsock2 = nbt_name_socket_init(ctx, NULL);
488                 if (!ctx->nbtsock2) return NULL;
489
490                 status = socket_listen(ctx->nbtsock2->sock, ctx->myaddr2, 0, 0, 0);
491                 if (!NT_STATUS_IS_OK(status)) return NULL;
492
493                 ctx->nbtsock_srv2 = nbt_name_socket_init(ctx, ctx->nbtsock_srv->event_ctx);
494                 if (!ctx->nbtsock_srv2) return NULL;
495
496                 status = socket_listen(ctx->nbtsock_srv2->sock, ctx->myaddr2, lp_nbt_port(), 0, 0);
497                 if (!NT_STATUS_IS_OK(status)) {
498                         talloc_free(ctx->nbtsock_srv2);
499                         ctx->nbtsock_srv2 = NULL;
500                 }
501         }
502
503         ctx->addresses_best_num = 1;
504         ctx->addresses_best = talloc_array(ctx, struct wrepl_ip, ctx->addresses_best_num);
505         if (!ctx->addresses_best) return NULL;
506         ctx->addresses_best[0].owner    = ctx->b.address;
507         ctx->addresses_best[0].ip       = ctx->myaddr;
508
509         ctx->addresses_all_num = iface_count();
510         ctx->addresses_all = talloc_array(ctx, struct wrepl_ip, ctx->addresses_all_num);
511         if (!ctx->addresses_all) return NULL;
512         for (i=0; i < ctx->addresses_all_num; i++) {
513                 ctx->addresses_all[i].owner     = ctx->b.address;
514                 ctx->addresses_all[i].ip        = talloc_strdup(ctx->addresses_all, iface_n_ip(i));
515                 if (!ctx->addresses_all[i].ip) return NULL;
516         }
517
518         if (ctx->nbtsock_srv2) {
519                 ctx->addresses_best2_num = 1;
520                 ctx->addresses_best2 = talloc_array(ctx, struct wrepl_ip, ctx->addresses_best2_num);
521                 if (!ctx->addresses_best2) return NULL;
522                 ctx->addresses_best2[0].owner   = ctx->b.address;
523                 ctx->addresses_best2[0].ip      = ctx->myaddr2;
524
525                 ctx->addresses_mhomed_num = 2;
526                 ctx->addresses_mhomed = talloc_array(ctx, struct wrepl_ip, ctx->addresses_mhomed_num);
527                 if (!ctx->addresses_mhomed) return NULL;
528                 ctx->addresses_mhomed[0].owner  = ctx->b.address;
529                 ctx->addresses_mhomed[0].ip     = ctx->myaddr;
530                 ctx->addresses_mhomed[1].owner  = ctx->b.address;
531                 ctx->addresses_mhomed[1].ip     = ctx->myaddr2;
532         }
533
534         return ctx;
535 }
536
537 static BOOL test_wrepl_update_one(struct test_wrepl_conflict_conn *ctx,
538                                   const struct wrepl_wins_owner *owner,
539                                   const struct wrepl_wins_name *name)
540 {
541         BOOL ret = True;
542         struct wrepl_socket *wrepl_socket;
543         struct wrepl_associate associate;
544         struct wrepl_packet update_packet, repl_send;
545         struct wrepl_table *update;
546         struct wrepl_wins_owner wrepl_wins_owners[1];
547         struct wrepl_packet *repl_recv;
548         struct wrepl_wins_owner *send_request;
549         struct wrepl_send_reply *send_reply;
550         struct wrepl_wins_name wrepl_wins_names[1];
551         uint32_t assoc_ctx;
552         NTSTATUS status;
553
554         wrepl_socket = wrepl_socket_init(ctx, NULL);
555
556         status = wrepl_connect(wrepl_socket, NULL, ctx->address);
557         CHECK_STATUS(status, NT_STATUS_OK);
558
559         status = wrepl_associate(wrepl_socket, &associate);
560         CHECK_STATUS(status, NT_STATUS_OK);
561         assoc_ctx = associate.out.assoc_ctx;
562
563         /* now send a WREPL_REPL_UPDATE message */
564         ZERO_STRUCT(update_packet);
565         update_packet.opcode                    = WREPL_OPCODE_BITS;
566         update_packet.assoc_ctx                 = assoc_ctx;
567         update_packet.mess_type                 = WREPL_REPLICATION;
568         update_packet.message.replication.command       = WREPL_REPL_UPDATE;
569         update  = &update_packet.message.replication.info.table;
570
571         update->partner_count   = ARRAY_SIZE(wrepl_wins_owners);
572         update->partners        = wrepl_wins_owners;
573         update->initiator       = "0.0.0.0";
574
575         wrepl_wins_owners[0]    = *owner;
576
577         status = wrepl_request(wrepl_socket, wrepl_socket,
578                                &update_packet, &repl_recv);
579         CHECK_STATUS(status, NT_STATUS_OK);
580         CHECK_VALUE(repl_recv->mess_type, WREPL_REPLICATION);
581         CHECK_VALUE(repl_recv->message.replication.command, WREPL_REPL_SEND_REQUEST);
582         send_request = &repl_recv->message.replication.info.owner;
583
584         ZERO_STRUCT(repl_send);
585         repl_send.opcode                        = WREPL_OPCODE_BITS;
586         repl_send.assoc_ctx                     = assoc_ctx;
587         repl_send.mess_type                     = WREPL_REPLICATION;
588         repl_send.message.replication.command   = WREPL_REPL_SEND_REPLY;
589         send_reply = &repl_send.message.replication.info.reply;
590
591         send_reply->num_names   = ARRAY_SIZE(wrepl_wins_names);
592         send_reply->names       = wrepl_wins_names;
593
594         wrepl_wins_names[0]     = *name;
595
596         status = wrepl_request(wrepl_socket, wrepl_socket,
597                                &repl_send, &repl_recv);
598         CHECK_STATUS(status, NT_STATUS_OK);
599         CHECK_VALUE(repl_recv->mess_type, WREPL_STOP_ASSOCIATION);
600         CHECK_VALUE(repl_recv->message.stop.reason, 0);
601
602 done:
603         talloc_free(wrepl_socket);
604         return ret;
605 }
606
607 #if 0
608 static BOOL test_wrepl_update_two(struct test_wrepl_conflict_conn *ctx,
609                                   const struct wrepl_wins_owner *owner,
610                                   const struct wrepl_wins_name *name1,
611                                   const struct wrepl_wins_name *name2)
612 {
613         BOOL ret = True;
614         struct wrepl_socket *wrepl_socket;
615         struct wrepl_associate associate;
616         struct wrepl_packet update_packet, repl_send;
617         struct wrepl_table *update;
618         struct wrepl_wins_owner wrepl_wins_owners[1];
619         struct wrepl_packet *repl_recv;
620         struct wrepl_wins_owner *send_request;
621         struct wrepl_send_reply *send_reply;
622         struct wrepl_wins_name wrepl_wins_names[2];
623         uint32_t assoc_ctx;
624         NTSTATUS status;
625
626         wrepl_socket = wrepl_socket_init(ctx, NULL);
627
628         status = wrepl_connect(wrepl_socket, NULL, ctx->address);
629         CHECK_STATUS(status, NT_STATUS_OK);
630
631         status = wrepl_associate(wrepl_socket, &associate);
632         CHECK_STATUS(status, NT_STATUS_OK);
633         assoc_ctx = associate.out.assoc_ctx;
634
635         /* now send a WREPL_REPL_UPDATE message */
636         ZERO_STRUCT(update_packet);
637         update_packet.opcode                    = WREPL_OPCODE_BITS;
638         update_packet.assoc_ctx                 = assoc_ctx;
639         update_packet.mess_type                 = WREPL_REPLICATION;
640         update_packet.message.replication.command       = WREPL_REPL_UPDATE;
641         update  = &update_packet.message.replication.info.table;
642
643         update->partner_count   = ARRAY_SIZE(wrepl_wins_owners);
644         update->partners        = wrepl_wins_owners;
645         update->initiator       = "0.0.0.0";
646
647         wrepl_wins_owners[0]    = *owner;
648
649         status = wrepl_request(wrepl_socket, wrepl_socket,
650                                &update_packet, &repl_recv);
651         CHECK_STATUS(status, NT_STATUS_OK);
652         CHECK_VALUE(repl_recv->mess_type, WREPL_REPLICATION);
653         CHECK_VALUE(repl_recv->message.replication.command, WREPL_REPL_SEND_REQUEST);
654         send_request = &repl_recv->message.replication.info.owner;
655
656         ZERO_STRUCT(repl_send);
657         repl_send.opcode                        = WREPL_OPCODE_BITS;
658         repl_send.assoc_ctx                     = assoc_ctx;
659         repl_send.mess_type                     = WREPL_REPLICATION;
660         repl_send.message.replication.command   = WREPL_REPL_SEND_REPLY;
661         send_reply = &repl_send.message.replication.info.reply;
662
663         send_reply->num_names   = ARRAY_SIZE(wrepl_wins_names);
664         send_reply->names       = wrepl_wins_names;
665
666         wrepl_wins_names[0]     = *name1;
667         wrepl_wins_names[1]     = *name2;
668
669         status = wrepl_request(wrepl_socket, wrepl_socket,
670                                &repl_send, &repl_recv);
671         CHECK_STATUS(status, NT_STATUS_OK);
672         CHECK_VALUE(repl_recv->mess_type, WREPL_STOP_ASSOCIATION);
673         CHECK_VALUE(repl_recv->message.stop.reason, 0);
674
675 done:
676         talloc_free(wrepl_socket);
677         return ret;
678 }
679 #endif
680
681 static BOOL test_wrepl_is_applied(struct test_wrepl_conflict_conn *ctx,
682                                   const struct wrepl_wins_owner *owner,
683                                   const struct wrepl_wins_name *name,
684                                   BOOL expected)
685 {
686         BOOL ret = True;
687         NTSTATUS status;
688         struct wrepl_pull_names pull_names;
689         struct wrepl_name *names;
690
691         pull_names.in.assoc_ctx = ctx->pull_assoc;
692         pull_names.in.partner   = *owner;
693         pull_names.in.partner.min_version = pull_names.in.partner.max_version;
694                 
695         status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names);
696         CHECK_STATUS(status, NT_STATUS_OK);
697         CHECK_VALUE(pull_names.out.num_names, (expected?1:0));
698
699         names = pull_names.out.names;
700
701         if (expected) {
702                 uint32_t flags = WREPL_NAME_FLAGS(names[0].type,
703                                                   names[0].state,
704                                                   names[0].node,
705                                                   names[0].is_static);
706                 CHECK_VALUE(names[0].name.type, name->name->type);
707                 CHECK_VALUE_STRING(names[0].name.name, name->name->name);
708                 CHECK_VALUE_STRING(names[0].name.scope, name->name->scope);
709                 CHECK_VALUE(flags, name->flags);
710                 CHECK_VALUE_UINT64(names[0].version_id, name->id);
711
712                 if (flags & 2) {
713                         CHECK_VALUE(names[0].num_addresses,
714                                     name->addresses.addresses.num_ips);
715                 } else {
716                         CHECK_VALUE(names[0].num_addresses, 1);
717                         CHECK_VALUE_STRING(names[0].addresses[0].address,
718                                            name->addresses.ip);
719                 }
720         }
721 done:
722         talloc_free(pull_names.out.names);
723         return ret;
724 }
725
726 static BOOL test_wrepl_mhomed_merged(struct test_wrepl_conflict_conn *ctx,
727                                      const struct wrepl_wins_owner *owner1,
728                                      uint32_t num_ips1, const struct wrepl_ip *ips1,
729                                      const struct wrepl_wins_owner *owner2,
730                                      uint32_t num_ips2, const struct wrepl_ip *ips2,
731                                      const struct wrepl_wins_name *name2)
732 {
733         BOOL ret = True;
734         NTSTATUS status;
735         struct wrepl_pull_names pull_names;
736         struct wrepl_name *names;
737         uint32_t flags;
738         uint32_t i, j;
739         uint32_t num_ips = num_ips1 + num_ips2;
740
741         for (i = 0; i < num_ips2; i++) {
742                 for (j = 0; j < num_ips1; j++) {
743                         if (strcmp(ips2[i].ip,ips1[j].ip) == 0) {
744                                 num_ips--;
745                                 break;
746                         }
747                 } 
748         }
749
750         pull_names.in.assoc_ctx = ctx->pull_assoc;
751         pull_names.in.partner   = *owner2;
752         pull_names.in.partner.min_version = pull_names.in.partner.max_version;
753
754         status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names);
755         CHECK_STATUS(status, NT_STATUS_OK);
756         CHECK_VALUE(pull_names.out.num_names, 1);
757
758         names = pull_names.out.names;
759
760         flags = WREPL_NAME_FLAGS(names[0].type,
761                                  names[0].state,
762                                  names[0].node,
763                                  names[0].is_static);
764         CHECK_VALUE(names[0].name.type, name2->name->type);
765         CHECK_VALUE_STRING(names[0].name.name, name2->name->name);
766         CHECK_VALUE_STRING(names[0].name.scope, name2->name->scope);
767         CHECK_VALUE(flags, name2->flags | WREPL_TYPE_MHOMED);
768         CHECK_VALUE_UINT64(names[0].version_id, name2->id);
769
770         CHECK_VALUE(names[0].num_addresses, num_ips);
771
772         for (i = 0; i < names[0].num_addresses; i++) {
773                 const char *addr = names[0].addresses[i].address; 
774                 const char *owner = names[0].addresses[i].owner;
775                 BOOL found = False;
776
777                 for (j = 0; j < num_ips2; j++) {
778                         if (strcmp(addr, ips2[j].ip) == 0) {
779                                 found = True;
780                                 CHECK_VALUE_STRING(owner, owner2->address);
781                                 break;
782                         }
783                 }
784
785                 if (found) continue;
786
787                 for (j = 0; j < num_ips1; j++) {
788                         if (strcmp(addr, ips1[j].ip) == 0) {
789                                 found = True;
790                                 CHECK_VALUE_STRING(owner, owner1->address);
791                                 break;
792                         }
793                 }
794
795                 if (found) continue;
796
797                 CHECK_VALUE_STRING(addr, "not found in address list");
798         }
799 done:
800         talloc_free(pull_names.out.names);
801         return ret;
802 }
803
804 static BOOL test_wrepl_is_merged(struct test_wrepl_conflict_conn *ctx,
805                                  const struct wrepl_wins_name *name1,
806                                  const struct wrepl_wins_name *name2)
807 {
808         return True;
809 #if 0
810         BOOL ret = True;
811         NTSTATUS status;
812         struct wrepl_pull_names pull_names;
813         struct wrepl_name *names;
814         uint32_t num_ips;
815
816         pull_names.in.assoc_ctx = ctx->pull_assoc;
817         pull_names.in.partner   = ctx->c;
818         pull_names.in.partner.min_version = ctx->c.max_version-1;
819
820         status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names);
821         CHECK_STATUS(status, NT_STATUS_OK);
822         CHECK_VALUE(pull_names.out.num_names, 1);
823
824         names = pull_names.out.names;
825
826         num_ips = name1->addresses.addresses.num_ips + name2->addresses.addresses.num_ips;
827
828         CHECK_VALUE(names[0].name.type, name1->name->type);
829         CHECK_VALUE_STRING(names[0].name.name, name1->name->name);
830         CHECK_VALUE_STRING(names[0].name.scope, name1->name->scope);
831         CHECK_VALUE(names[0].type, WREPL_TYPE_SGROUP);
832         CHECK_VALUE(names[0].state, (num_ips>0?WREPL_STATE_ACTIVE:WREPL_STATE_RELEASED));
833         CHECK_VALUE_UINT64(names[0].version_id, ctx->c.max_version);
834
835         CHECK_VALUE(names[0].num_addresses,
836                     name1->addresses.addresses.num_ips+
837                     name2->addresses.addresses.num_ips);
838 done:
839         talloc_free(pull_names.out.names);
840         return ret;
841 #endif
842 }
843
844 static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx)
845 {
846         BOOL ret = True;
847         struct nbt_name name;
848         struct wrepl_wins_name wins_name1;
849         struct wrepl_wins_name wins_name2;
850         struct wrepl_wins_name *wins_name_tmp;
851         struct wrepl_wins_name *wins_name_last;
852         struct wrepl_wins_name *wins_name_cur;
853         uint32_t i,j;
854         uint8_t types[] = { 0x00, 0x1C };
855         struct {
856                 enum wrepl_name_type type;
857                 enum wrepl_name_state state;
858                 enum wrepl_name_node node;
859                 BOOL is_static;
860                 uint32_t num_ips;
861                 const struct wrepl_ip *ips;
862         } records[] = {
863                 {
864                 .type           = WREPL_TYPE_GROUP,
865                 .state          = WREPL_STATE_ACTIVE,
866                 .node           = WREPL_NODE_B,
867                 .is_static      = False,
868                 .num_ips        = ARRAY_SIZE(addresses_A_1),
869                 .ips            = addresses_A_1,
870                 },{
871                 .type           = WREPL_TYPE_UNIQUE,
872                 .state          = WREPL_STATE_ACTIVE,
873                 .node           = WREPL_NODE_B,
874                 .is_static      = False,
875                 .num_ips        = ARRAY_SIZE(addresses_A_1),
876                 .ips            = addresses_A_1,
877                 },{
878                 .type           = WREPL_TYPE_UNIQUE,
879                 .state          = WREPL_STATE_ACTIVE,
880                 .node           = WREPL_NODE_B,
881                 .is_static      = False,
882                 .num_ips        = ARRAY_SIZE(addresses_A_2),
883                 .ips            = addresses_A_2,
884                 },{
885                 .type           = WREPL_TYPE_UNIQUE,
886                 .state          = WREPL_STATE_ACTIVE,
887                 .node           = WREPL_NODE_B,
888                 .is_static      = True,
889                 .num_ips        = ARRAY_SIZE(addresses_A_1),
890                 .ips            = addresses_A_1,
891                 },{
892                 .type           = WREPL_TYPE_UNIQUE,
893                 .state          = WREPL_STATE_ACTIVE,
894                 .node           = WREPL_NODE_B,
895                 .is_static      = False,
896                 .num_ips        = ARRAY_SIZE(addresses_A_2),
897                 .ips            = addresses_A_2,
898                 },{
899                 .type           = WREPL_TYPE_SGROUP,
900                 .state          = WREPL_STATE_TOMBSTONE,
901                 .node           = WREPL_NODE_B,
902                 .is_static      = False,
903                 .num_ips        = ARRAY_SIZE(addresses_A_2),
904                 .ips            = addresses_A_2,
905                 },{
906                 .type           = WREPL_TYPE_MHOMED,
907                 .state          = WREPL_STATE_TOMBSTONE,
908                 .node           = WREPL_NODE_B,
909                 .is_static      = False,
910                 .num_ips        = ARRAY_SIZE(addresses_A_1),
911                 .ips            = addresses_A_1,
912                 },{
913                 .type           = WREPL_TYPE_MHOMED,
914                 .state          = WREPL_STATE_RELEASED,
915                 .node           = WREPL_NODE_B,
916                 .is_static      = False,
917                 .num_ips        = ARRAY_SIZE(addresses_A_2),
918                 .ips            = addresses_A_2,
919                 },{
920                 .type           = WREPL_TYPE_SGROUP,
921                 .state          = WREPL_STATE_ACTIVE,
922                 .node           = WREPL_NODE_B,
923                 .is_static      = False,
924                 .num_ips        = ARRAY_SIZE(addresses_A_1),
925                 .ips            = addresses_A_1,
926                 },{
927                 .type           = WREPL_TYPE_SGROUP,
928                 .state          = WREPL_STATE_ACTIVE,
929                 .node           = WREPL_NODE_B,
930                 .is_static      = False,
931                 .num_ips        = ARRAY_SIZE(addresses_A_3_4),
932                 .ips            = addresses_A_3_4,
933                 },{
934                 .type           = WREPL_TYPE_SGROUP,
935                 .state          = WREPL_STATE_TOMBSTONE,
936                 .node           = WREPL_NODE_B,
937                 .is_static      = False,
938                 .num_ips        = ARRAY_SIZE(addresses_B_3_4),
939                 .ips            = addresses_B_3_4,
940                 },{
941                 /* the last one should always be a unique,tomstone record! */
942                 .type           = WREPL_TYPE_UNIQUE,
943                 .state          = WREPL_STATE_TOMBSTONE,
944                 .node           = WREPL_NODE_B,
945                 .is_static      = False,
946                 .num_ips        = ARRAY_SIZE(addresses_A_1),
947                 .ips            = addresses_A_1,
948                 }
949         };
950
951         if (!ctx) return False;
952
953         name.name       = "_SAME_OWNER_A";
954         name.type       = 0;
955         name.scope      = NULL;
956
957         wins_name_tmp   = NULL;
958         wins_name_last  = &wins_name2;
959         wins_name_cur   = &wins_name1;
960
961         for (j=0; ret && j < ARRAY_SIZE(types); j++) {
962                 name.type = types[j];
963                 printf("Test Replica Conflicts with same owner[%s] for %s\n",
964                         nbt_name_string(ctx, &name), ctx->a.address);
965
966                 for(i=0; ret && i < ARRAY_SIZE(records); i++) {
967                         wins_name_tmp   = wins_name_last;
968                         wins_name_last  = wins_name_cur;
969                         wins_name_cur   = wins_name_tmp;
970
971                         if (i > 0) {
972                                 printf("%s,%s%s vs. %s,%s%s with %s ip(s) => %s\n",
973                                         wrepl_name_type_string(records[i-1].type),
974                                         wrepl_name_state_string(records[i-1].state),
975                                         (records[i-1].is_static?",static":""),
976                                         wrepl_name_type_string(records[i].type),
977                                         wrepl_name_state_string(records[i].state),
978                                         (records[i].is_static?",static":""),
979                                         (records[i-1].ips==records[i].ips?"same":"different"),
980                                         "REPLACE");
981                         }
982
983                         wins_name_cur->name     = &name;
984                         wins_name_cur->flags    = WREPL_NAME_FLAGS(records[i].type,
985                                                                    records[i].state,
986                                                                    records[i].node,
987                                                                    records[i].is_static);
988                         wins_name_cur->id       = ++ctx->a.max_version;
989                         if (wins_name_cur->flags & 2) {
990                                 wins_name_cur->addresses.addresses.num_ips = records[i].num_ips;
991                                 wins_name_cur->addresses.addresses.ips     = discard_const(records[i].ips);
992                         } else {
993                                 wins_name_cur->addresses.ip = records[i].ips[0].ip;
994                         }
995                         wins_name_cur->unknown  = "255.255.255.255";
996
997                         ret &= test_wrepl_update_one(ctx, &ctx->a,wins_name_cur);
998                         if (records[i].state == WREPL_STATE_RELEASED) {
999                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_last, False);
1000                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_cur, False);
1001                         } else {
1002                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_cur, True);
1003                         }
1004
1005                         /* the first one is a cleanup run */
1006                         if (!ret && i == 0) ret = True;
1007
1008                         if (!ret) {
1009                                 printf("conflict handled wrong or record[%u]: %s\n", i, __location__);
1010                                 return ret;
1011                         }
1012                 }
1013         }
1014         return ret;
1015 }
1016
1017 static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx)
1018 {
1019         BOOL ret = True;
1020         struct wrepl_wins_name wins_name1;
1021         struct wrepl_wins_name wins_name2;
1022         struct wrepl_wins_name *wins_name_r1;
1023         struct wrepl_wins_name *wins_name_r2;
1024         uint32_t i;
1025         struct {
1026                 const char *line; /* just better debugging */
1027                 struct nbt_name name;
1028                 BOOL extra; /* not the worst case, this is an extra test */
1029                 BOOL cleanup;
1030                 struct {
1031                         struct wrepl_wins_owner *owner;
1032                         enum wrepl_name_type type;
1033                         enum wrepl_name_state state;
1034                         enum wrepl_name_node node;
1035                         BOOL is_static;
1036                         uint32_t num_ips;
1037                         const struct wrepl_ip *ips;
1038                         BOOL apply_expected;
1039                         BOOL merge_expected;
1040                 } r1, r2;
1041         } records[] = {
1042         /* 
1043          * NOTE: the first record and the last applied one
1044          *       needs to be from the same owner,
1045          *       to not conflict in the next smbtorture run!!!
1046          */
1047         {
1048                 .line   = __location__,
1049                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1050                 .cleanup= True,
1051                 .r1     = {
1052                         .owner          = &ctx->b,
1053                         .type           = WREPL_TYPE_UNIQUE,
1054                         .state          = WREPL_STATE_TOMBSTONE,
1055                         .node           = WREPL_NODE_B,
1056                         .is_static      = False,
1057                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1058                         .ips            = addresses_B_1,
1059                         .apply_expected = True /* ignored */
1060                 },
1061                 .r2     = {
1062                         .owner          = &ctx->a,
1063                         .type           = WREPL_TYPE_UNIQUE,
1064                         .state          = WREPL_STATE_TOMBSTONE,
1065                         .node           = WREPL_NODE_B,
1066                         .is_static      = False,
1067                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1068                         .ips            = addresses_A_1,
1069                         .apply_expected = True /* ignored */
1070                 }
1071         },
1072
1073 /*
1074  * unique vs unique section
1075  */
1076         /* 
1077          * unique,active vs. unique,active
1078          * => should be replaced
1079          */
1080         {
1081                 .line   = __location__,
1082                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1083                 .r1     = {
1084                         .owner          = &ctx->a,
1085                         .type           = WREPL_TYPE_UNIQUE,
1086                         .state          = WREPL_STATE_ACTIVE,
1087                         .node           = WREPL_NODE_B,
1088                         .is_static      = False,
1089                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1090                         .ips            = addresses_A_1,
1091                         .apply_expected = True
1092                 },
1093                 .r2     = {
1094                         .owner          = &ctx->b,
1095                         .type           = WREPL_TYPE_UNIQUE,
1096                         .state          = WREPL_STATE_ACTIVE,
1097                         .node           = WREPL_NODE_B,
1098                         .is_static      = False,
1099                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1100                         .ips            = addresses_B_1,
1101                         .apply_expected = True
1102                 }
1103         },
1104
1105         /* 
1106          * unique,active vs. unique,tombstone
1107          * => should NOT be replaced
1108          */
1109         {
1110                 .line   = __location__,
1111                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1112                 .r1     = {
1113                         .owner          = &ctx->b,
1114                         .type           = WREPL_TYPE_UNIQUE,
1115                         .state          = WREPL_STATE_ACTIVE,
1116                         .node           = WREPL_NODE_B,
1117                         .is_static      = False,
1118                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1119                         .ips            = addresses_B_1,
1120                         .apply_expected = True
1121                 },
1122                 .r2     = {
1123                         .owner          = &ctx->a,
1124                         .type           = WREPL_TYPE_UNIQUE,
1125                         .state          = WREPL_STATE_TOMBSTONE,
1126                         .node           = WREPL_NODE_B,
1127                         .is_static      = False,
1128                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1129                         .ips            = addresses_B_1,
1130                         .apply_expected = False
1131                 }
1132         },
1133
1134         /* 
1135          * unique,released vs. unique,active
1136          * => should be replaced
1137          */
1138         {
1139                 .line   = __location__,
1140                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1141                 .r1     = {
1142                         .owner          = &ctx->b,
1143                         .type           = WREPL_TYPE_UNIQUE,
1144                         .state          = WREPL_STATE_RELEASED,
1145                         .node           = WREPL_NODE_B,
1146                         .is_static      = False,
1147                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1148                         .ips            = addresses_B_1,
1149                         .apply_expected = False
1150                 },
1151                 .r2     = {
1152                         .owner          = &ctx->a,
1153                         .type           = WREPL_TYPE_UNIQUE,
1154                         .state          = WREPL_STATE_ACTIVE,
1155                         .node           = WREPL_NODE_B,
1156                         .is_static      = False,
1157                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1158                         .ips            = addresses_A_1,
1159                         .apply_expected = True
1160                 }
1161         },
1162
1163         /* 
1164          * unique,released vs. unique,tombstone
1165          * => should be replaced
1166          */
1167         {
1168                 .line   = __location__,
1169                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1170                 .r1     = {
1171                         .owner          = &ctx->a,
1172                         .type           = WREPL_TYPE_UNIQUE,
1173                         .state          = WREPL_STATE_RELEASED,
1174                         .node           = WREPL_NODE_B,
1175                         .is_static      = False,
1176                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1177                         .ips            = addresses_A_1,
1178                         .apply_expected = False
1179                 },
1180                 .r2     = {
1181                         .owner          = &ctx->b,
1182                         .type           = WREPL_TYPE_UNIQUE,
1183                         .state          = WREPL_STATE_TOMBSTONE,
1184                         .node           = WREPL_NODE_B,
1185                         .is_static      = False,
1186                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1187                         .ips            = addresses_B_1,
1188                         .apply_expected = True
1189                 }
1190         },
1191
1192         /* 
1193          * unique,tombstone vs. unique,active
1194          * => should be replaced
1195          */
1196         {
1197                 .line   = __location__,
1198                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1199                 .r1     = {
1200                         .owner          = &ctx->b,
1201                         .type           = WREPL_TYPE_UNIQUE,
1202                         .state          = WREPL_STATE_TOMBSTONE,
1203                         .node           = WREPL_NODE_B,
1204                         .is_static      = False,
1205                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1206                         .ips            = addresses_B_1,
1207                         .apply_expected = True
1208                 },
1209                 .r2     = {
1210                         .owner          = &ctx->a,
1211                         .type           = WREPL_TYPE_UNIQUE,
1212                         .state          = WREPL_STATE_ACTIVE,
1213                         .node           = WREPL_NODE_B,
1214                         .is_static      = False,
1215                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1216                         .ips            = addresses_A_1,
1217                         .apply_expected = True
1218                 }
1219         },
1220
1221         /* 
1222          * unique,tombstone vs. unique,tombstone
1223          * => should be replaced
1224          */
1225         {
1226                 .line   = __location__,
1227                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1228                 .r1     = {
1229                         .owner          = &ctx->a,
1230                         .type           = WREPL_TYPE_UNIQUE,
1231                         .state          = WREPL_STATE_TOMBSTONE,
1232                         .node           = WREPL_NODE_B,
1233                         .is_static      = False,
1234                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1235                         .ips            = addresses_A_1,
1236                         .apply_expected = True
1237                 },
1238                 .r2     = {
1239                         .owner          = &ctx->b,
1240                         .type           = WREPL_TYPE_UNIQUE,
1241                         .state          = WREPL_STATE_TOMBSTONE,
1242                         .node           = WREPL_NODE_B,
1243                         .is_static      = False,
1244                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1245                         .ips            = addresses_B_1,
1246                         .apply_expected = True
1247                 }
1248         },
1249
1250
1251 /*
1252  * unique vs normal groups section,
1253  */
1254         /* 
1255          * unique,active vs. group,active
1256          * => should be replaced
1257          */
1258         {
1259                 .line   = __location__,
1260                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1261                 .r1     = {
1262                         .owner          = &ctx->b,
1263                         .type           = WREPL_TYPE_UNIQUE,
1264                         .state          = WREPL_STATE_ACTIVE,
1265                         .node           = WREPL_NODE_B,
1266                         .is_static      = False,
1267                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1268                         .ips            = addresses_B_1,
1269                         .apply_expected = True
1270                 },
1271                 .r2     = {
1272                         .owner          = &ctx->a,
1273                         .type           = WREPL_TYPE_GROUP,
1274                         .state          = WREPL_STATE_ACTIVE,
1275                         .node           = WREPL_NODE_B,
1276                         .is_static      = False,
1277                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1278                         .ips            = addresses_A_1,
1279                         .apply_expected = True
1280                 }
1281         },
1282
1283         /* 
1284          * unique,active vs. group,tombstone
1285          * => should NOT be replaced
1286          */
1287         {
1288                 .line   = __location__,
1289                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1290                 .r1     = {
1291                         .owner          = &ctx->a,
1292                         .type           = WREPL_TYPE_UNIQUE,
1293                         .state          = WREPL_STATE_ACTIVE,
1294                         .node           = WREPL_NODE_B,
1295                         .is_static      = False,
1296                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1297                         .ips            = addresses_A_1,
1298                         .apply_expected = True
1299                 },
1300                 .r2     = {
1301                         .owner          = &ctx->b,
1302                         .type           = WREPL_TYPE_GROUP,
1303                         .state          = WREPL_STATE_TOMBSTONE,
1304                         .node           = WREPL_NODE_B,
1305                         .is_static      = False,
1306                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1307                         .ips            = addresses_A_1,
1308                         .apply_expected = False
1309                 }
1310         },
1311
1312         /* 
1313          * unique,released vs. group,active
1314          * => should be replaced
1315          */
1316         {
1317                 .line   = __location__,
1318                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1319                 .r1     = {
1320                         .owner          = &ctx->a,
1321                         .type           = WREPL_TYPE_UNIQUE,
1322                         .state          = WREPL_STATE_RELEASED,
1323                         .node           = WREPL_NODE_B,
1324                         .is_static      = False,
1325                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1326                         .ips            = addresses_A_1,
1327                         .apply_expected = False
1328                 },
1329                 .r2     = {
1330                         .owner          = &ctx->b,
1331                         .type           = WREPL_TYPE_GROUP,
1332                         .state          = WREPL_STATE_ACTIVE,
1333                         .node           = WREPL_NODE_B,
1334                         .is_static      = False,
1335                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1336                         .ips            = addresses_B_1,
1337                         .apply_expected = True
1338                 }
1339         },
1340
1341         /* 
1342          * unique,released vs. group,tombstone
1343          * => should be replaced
1344          */
1345         {
1346                 .line   = __location__,
1347                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1348                 .r1     = {
1349                         .owner          = &ctx->b,
1350                         .type           = WREPL_TYPE_UNIQUE,
1351                         .state          = WREPL_STATE_RELEASED,
1352                         .node           = WREPL_NODE_B,
1353                         .is_static      = False,
1354                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1355                         .ips            = addresses_B_1,
1356                         .apply_expected = False
1357                 },
1358                 .r2     = {
1359                         .owner          = &ctx->a,
1360                         .type           = WREPL_TYPE_GROUP,
1361                         .state          = WREPL_STATE_TOMBSTONE,
1362                         .node           = WREPL_NODE_B,
1363                         .is_static      = False,
1364                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1365                         .ips            = addresses_A_1,
1366                         .apply_expected = True
1367                 }
1368         },
1369
1370         /* 
1371          * unique,tombstone vs. group,active
1372          * => should be replaced
1373          */
1374         {
1375                 .line   = __location__,
1376                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1377                 .r1     = {
1378                         .owner          = &ctx->a,
1379                         .type           = WREPL_TYPE_UNIQUE,
1380                         .state          = WREPL_STATE_TOMBSTONE,
1381                         .node           = WREPL_NODE_B,
1382                         .is_static      = False,
1383                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1384                         .ips            = addresses_A_1,
1385                         .apply_expected = True
1386                 },
1387                 .r2     = {
1388                         .owner          = &ctx->b,
1389                         .type           = WREPL_TYPE_GROUP,
1390                         .state          = WREPL_STATE_ACTIVE,
1391                         .node           = WREPL_NODE_B,
1392                         .is_static      = False,
1393                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1394                         .ips            = addresses_B_1,
1395                         .apply_expected = True
1396                 }
1397         },
1398
1399         /* 
1400          * unique,tombstone vs. group,tombstone
1401          * => should be replaced
1402          */
1403         {
1404                 .line   = __location__,
1405                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1406                 .r1     = {
1407                         .owner          = &ctx->b,
1408                         .type           = WREPL_TYPE_UNIQUE,
1409                         .state          = WREPL_STATE_TOMBSTONE,
1410                         .node           = WREPL_NODE_B,
1411                         .is_static      = False,
1412                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1413                         .ips            = addresses_B_1,
1414                         .apply_expected = True
1415                 },
1416                 .r2     = {
1417                         .owner          = &ctx->a,
1418                         .type           = WREPL_TYPE_GROUP,
1419                         .state          = WREPL_STATE_TOMBSTONE,
1420                         .node           = WREPL_NODE_B,
1421                         .is_static      = False,
1422                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1423                         .ips            = addresses_A_1,
1424                         .apply_expected = True
1425                 }
1426         },
1427
1428 /*
1429  * unique vs special groups section,
1430  */
1431         /* 
1432          * unique,active vs. sgroup,active
1433          * => should NOT be replaced
1434          */
1435         {
1436                 .line   = __location__,
1437                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1438                 .r1     = {
1439                         .owner          = &ctx->a,
1440                         .type           = WREPL_TYPE_UNIQUE,
1441                         .state          = WREPL_STATE_ACTIVE,
1442                         .node           = WREPL_NODE_B,
1443                         .is_static      = False,
1444                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1445                         .ips            = addresses_A_1,
1446                         .apply_expected = True
1447                 },
1448                 .r2     = {
1449                         .owner          = &ctx->b,
1450                         .type           = WREPL_TYPE_SGROUP,
1451                         .state          = WREPL_STATE_ACTIVE,
1452                         .node           = WREPL_NODE_B,
1453                         .is_static      = False,
1454                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1455                         .ips            = addresses_A_1,
1456                         .apply_expected = False
1457                 }
1458         },
1459
1460         /* 
1461          * unique,active vs. sgroup,tombstone
1462          * => should NOT be replaced
1463          */
1464         {
1465                 .line   = __location__,
1466                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1467                 .r1     = {
1468                         .owner          = &ctx->a,
1469                         .type           = WREPL_TYPE_UNIQUE,
1470                         .state          = WREPL_STATE_ACTIVE,
1471                         .node           = WREPL_NODE_B,
1472                         .is_static      = False,
1473                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1474                         .ips            = addresses_A_1,
1475                         .apply_expected = True
1476                 },
1477                 .r2     = {
1478                         .owner          = &ctx->b,
1479                         .type           = WREPL_TYPE_SGROUP,
1480                         .state          = WREPL_STATE_TOMBSTONE,
1481                         .node           = WREPL_NODE_B,
1482                         .is_static      = False,
1483                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1484                         .ips            = addresses_A_1,
1485                         .apply_expected = False
1486                 }
1487         },
1488
1489         /* 
1490          * unique,released vs. sgroup,active
1491          * => should be replaced
1492          */
1493         {
1494                 .line   = __location__,
1495                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1496                 .r1     = {
1497                         .owner          = &ctx->a,
1498                         .type           = WREPL_TYPE_UNIQUE,
1499                         .state          = WREPL_STATE_RELEASED,
1500                         .node           = WREPL_NODE_B,
1501                         .is_static      = False,
1502                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1503                         .ips            = addresses_A_1,
1504                         .apply_expected = False
1505                 },
1506                 .r2     = {
1507                         .owner          = &ctx->b,
1508                         .type           = WREPL_TYPE_SGROUP,
1509                         .state          = WREPL_STATE_ACTIVE,
1510                         .node           = WREPL_NODE_B,
1511                         .is_static      = False,
1512                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1513                         .ips            = addresses_B_3_4,
1514                         .apply_expected = True
1515                 }
1516         },
1517
1518         /* 
1519          * unique,released vs. sgroup,tombstone
1520          * => should be replaced
1521          */
1522         {
1523                 .line   = __location__,
1524                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1525                 .r1     = {
1526                         .owner          = &ctx->b,
1527                         .type           = WREPL_TYPE_UNIQUE,
1528                         .state          = WREPL_STATE_RELEASED,
1529                         .node           = WREPL_NODE_B,
1530                         .is_static      = False,
1531                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1532                         .ips            = addresses_B_1,
1533                         .apply_expected = False
1534                 },
1535                 .r2     = {
1536                         .owner          = &ctx->a,
1537                         .type           = WREPL_TYPE_SGROUP,
1538                         .state          = WREPL_STATE_TOMBSTONE,
1539                         .node           = WREPL_NODE_B,
1540                         .is_static      = False,
1541                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1542                         .ips            = addresses_A_3_4,
1543                         .apply_expected = True
1544                 }
1545         },
1546
1547         /* 
1548          * unique,tombstone vs. sgroup,active
1549          * => should be replaced
1550          */
1551         {
1552                 .line   = __location__,
1553                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1554                 .r1     = {
1555                         .owner          = &ctx->a,
1556                         .type           = WREPL_TYPE_UNIQUE,
1557                         .state          = WREPL_STATE_TOMBSTONE,
1558                         .node           = WREPL_NODE_B,
1559                         .is_static      = False,
1560                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1561                         .ips            = addresses_A_1,
1562                         .apply_expected = True
1563                 },
1564                 .r2     = {
1565                         .owner          = &ctx->b,
1566                         .type           = WREPL_TYPE_SGROUP,
1567                         .state          = WREPL_STATE_ACTIVE,
1568                         .node           = WREPL_NODE_B,
1569                         .is_static      = False,
1570                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1571                         .ips            = addresses_B_3_4,
1572                         .apply_expected = True
1573                 }
1574         },
1575
1576         /* 
1577          * unique,tombstone vs. sgroup,tombstone
1578          * => should be replaced
1579          */
1580         {
1581                 .line   = __location__,
1582                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1583                 .r1     = {
1584                         .owner          = &ctx->b,
1585                         .type           = WREPL_TYPE_UNIQUE,
1586                         .state          = WREPL_STATE_TOMBSTONE,
1587                         .node           = WREPL_NODE_B,
1588                         .is_static      = False,
1589                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1590                         .ips            = addresses_B_1,
1591                         .apply_expected = True
1592                 },
1593                 .r2     = {
1594                         .owner          = &ctx->a,
1595                         .type           = WREPL_TYPE_SGROUP,
1596                         .state          = WREPL_STATE_TOMBSTONE,
1597                         .node           = WREPL_NODE_B,
1598                         .is_static      = False,
1599                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1600                         .ips            = addresses_A_3_4,
1601                         .apply_expected = True
1602                 }
1603         },
1604
1605 /*
1606  * unique vs multi homed section,
1607  */
1608         /* 
1609          * unique,active vs. mhomed,active
1610          * => should be replaced
1611          */
1612         {
1613                 .line   = __location__,
1614                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1615                 .r1     = {
1616                         .owner          = &ctx->a,
1617                         .type           = WREPL_TYPE_UNIQUE,
1618                         .state          = WREPL_STATE_ACTIVE,
1619                         .node           = WREPL_NODE_B,
1620                         .is_static      = False,
1621                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1622                         .ips            = addresses_A_1,
1623                         .apply_expected = True
1624                 },
1625                 .r2     = {
1626                         .owner          = &ctx->b,
1627                         .type           = WREPL_TYPE_MHOMED,
1628                         .state          = WREPL_STATE_ACTIVE,
1629                         .node           = WREPL_NODE_B,
1630                         .is_static      = False,
1631                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1632                         .ips            = addresses_B_3_4,
1633                         .apply_expected = True
1634                 }
1635         },
1636
1637         /* 
1638          * unique,active vs. mhomed,tombstone
1639          * => should NOT be replaced
1640          */
1641         {
1642                 .line   = __location__,
1643                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1644                 .r1     = {
1645                         .owner          = &ctx->b,
1646                         .type           = WREPL_TYPE_UNIQUE,
1647                         .state          = WREPL_STATE_ACTIVE,
1648                         .node           = WREPL_NODE_B,
1649                         .is_static      = False,
1650                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1651                         .ips            = addresses_B_3_4,
1652                         .apply_expected = True
1653                 },
1654                 .r2     = {
1655                         .owner          = &ctx->a,
1656                         .type           = WREPL_TYPE_MHOMED,
1657                         .state          = WREPL_STATE_TOMBSTONE,
1658                         .node           = WREPL_NODE_B,
1659                         .is_static      = False,
1660                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1661                         .ips            = addresses_B_3_4,
1662                         .apply_expected = False
1663                 }
1664         },
1665
1666         /* 
1667          * unique,released vs. mhomed,active
1668          * => should be replaced
1669          */
1670         {
1671                 .line   = __location__,
1672                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1673                 .r1     = {
1674                         .owner          = &ctx->b,
1675                         .type           = WREPL_TYPE_UNIQUE,
1676                         .state          = WREPL_STATE_RELEASED,
1677                         .node           = WREPL_NODE_B,
1678                         .is_static      = False,
1679                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1680                         .ips            = addresses_B_1,
1681                         .apply_expected = False
1682                 },
1683                 .r2     = {
1684                         .owner          = &ctx->a,
1685                         .type           = WREPL_TYPE_MHOMED,
1686                         .state          = WREPL_STATE_ACTIVE,
1687                         .node           = WREPL_NODE_B,
1688                         .is_static      = False,
1689                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1690                         .ips            = addresses_A_3_4,
1691                         .apply_expected = True
1692                 }
1693         },
1694
1695         /* 
1696          * unique,released vs. mhomed,tombstone
1697          * => should be replaced
1698          */
1699         {
1700                 .line   = __location__,
1701                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1702                 .r1     = {
1703                         .owner          = &ctx->a,
1704                         .type           = WREPL_TYPE_UNIQUE,
1705                         .state          = WREPL_STATE_RELEASED,
1706                         .node           = WREPL_NODE_B,
1707                         .is_static      = False,
1708                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1709                         .ips            = addresses_A_1,
1710                         .apply_expected = False
1711                 },
1712                 .r2     = {
1713                         .owner          = &ctx->b,
1714                         .type           = WREPL_TYPE_MHOMED,
1715                         .state          = WREPL_STATE_TOMBSTONE,
1716                         .node           = WREPL_NODE_B,
1717                         .is_static      = False,
1718                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1719                         .ips            = addresses_B_3_4,
1720                         .apply_expected = True
1721                 }
1722         },
1723
1724         /* 
1725          * unique,tombstone vs. mhomed,active
1726          * => should be replaced
1727          */
1728         {
1729                 .line   = __location__,
1730                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1731                 .r1     = {
1732                         .owner          = &ctx->b,
1733                         .type           = WREPL_TYPE_UNIQUE,
1734                         .state          = WREPL_STATE_TOMBSTONE,
1735                         .node           = WREPL_NODE_B,
1736                         .is_static      = False,
1737                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1738                         .ips            = addresses_B_1,
1739                         .apply_expected = True
1740                 },
1741                 .r2     = {
1742                         .owner          = &ctx->a,
1743                         .type           = WREPL_TYPE_MHOMED,
1744                         .state          = WREPL_STATE_ACTIVE,
1745                         .node           = WREPL_NODE_B,
1746                         .is_static      = False,
1747                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1748                         .ips            = addresses_A_3_4,
1749                         .apply_expected = True
1750                 }
1751         },
1752
1753         /* 
1754          * unique,tombstone vs. mhomed,tombstone
1755          * => should be replaced
1756          */
1757         {
1758                 .line   = __location__,
1759                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1760                 .r1     = {
1761                         .owner          = &ctx->a,
1762                         .type           = WREPL_TYPE_UNIQUE,
1763                         .state          = WREPL_STATE_TOMBSTONE,
1764                         .node           = WREPL_NODE_B,
1765                         .is_static      = False,
1766                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1767                         .ips            = addresses_A_1,
1768                         .apply_expected = True
1769                 },
1770                 .r2     = {
1771                         .owner          = &ctx->b,
1772                         .type           = WREPL_TYPE_MHOMED,
1773                         .state          = WREPL_STATE_TOMBSTONE,
1774                         .node           = WREPL_NODE_B,
1775                         .is_static      = False,
1776                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1777                         .ips            = addresses_B_3_4,
1778                         .apply_expected = True
1779                 }
1780         },
1781
1782 /*
1783  * normal groups vs unique section,
1784  */
1785         /* 
1786          * group,active vs. unique,active
1787          * => should NOT be replaced
1788          */
1789         {
1790                 .line   = __location__,
1791                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1792                 .r1     = {
1793                         .owner          = &ctx->a,
1794                         .type           = WREPL_TYPE_GROUP,
1795                         .state          = WREPL_STATE_ACTIVE,
1796                         .node           = WREPL_NODE_B,
1797                         .is_static      = False,
1798                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1799                         .ips            = addresses_A_1,
1800                         .apply_expected = True
1801                 },
1802                 .r2     = {
1803                         .owner          = &ctx->b,
1804                         .type           = WREPL_TYPE_UNIQUE,
1805                         .state          = WREPL_STATE_ACTIVE,
1806                         .node           = WREPL_NODE_B,
1807                         .is_static      = False,
1808                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1809                         .ips            = addresses_A_1,
1810                         .apply_expected = False
1811                 }
1812         },
1813
1814         /* 
1815          * group,active vs. unique,tombstone
1816          * => should NOT be replaced
1817          */
1818         {
1819                 .line   = __location__,
1820                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1821                 .r1     = {
1822                         .owner          = &ctx->a,
1823                         .type           = WREPL_TYPE_GROUP,
1824                         .state          = WREPL_STATE_ACTIVE,
1825                         .node           = WREPL_NODE_B,
1826                         .is_static      = False,
1827                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1828                         .ips            = addresses_A_1,
1829                         .apply_expected = True
1830                 },
1831                 .r2     = {
1832                         .owner          = &ctx->b,
1833                         .type           = WREPL_TYPE_UNIQUE,
1834                         .state          = WREPL_STATE_TOMBSTONE,
1835                         .node           = WREPL_NODE_B,
1836                         .is_static      = False,
1837                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1838                         .ips            = addresses_A_1,
1839                         .apply_expected = False
1840                 }
1841         },
1842
1843         /* 
1844          * group,released vs. unique,active
1845          * => should NOT be replaced
1846          */
1847         {
1848                 .line   = __location__,
1849                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1850                 .r1     = {
1851                         .owner          = &ctx->a,
1852                         .type           = WREPL_TYPE_GROUP,
1853                         .state          = WREPL_STATE_RELEASED,
1854                         .node           = WREPL_NODE_B,
1855                         .is_static      = False,
1856                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1857                         .ips            = addresses_A_1,
1858                         .apply_expected = False
1859                 },
1860                 .r2     = {
1861                         .owner          = &ctx->b,
1862                         .type           = WREPL_TYPE_UNIQUE,
1863                         .state          = WREPL_STATE_ACTIVE,
1864                         .node           = WREPL_NODE_B,
1865                         .is_static      = False,
1866                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1867                         .ips            = addresses_A_1,
1868                         .apply_expected = False
1869                 }
1870         },
1871
1872         /* 
1873          * group,released vs. unique,tombstone
1874          * => should NOT be replaced
1875          */
1876         {
1877                 .line   = __location__,
1878                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1879                 .r1     = {
1880                         .owner          = &ctx->a,
1881                         .type           = WREPL_TYPE_GROUP,
1882                         .state          = WREPL_STATE_RELEASED,
1883                         .node           = WREPL_NODE_B,
1884                         .is_static      = False,
1885                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1886                         .ips            = addresses_A_1,
1887                         .apply_expected = False
1888                 },
1889                 .r2     = {
1890                         .owner          = &ctx->b,
1891                         .type           = WREPL_TYPE_UNIQUE,
1892                         .state          = WREPL_STATE_TOMBSTONE,
1893                         .node           = WREPL_NODE_B,
1894                         .is_static      = False,
1895                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1896                         .ips            = addresses_A_1,
1897                         .apply_expected = False
1898                 }
1899         },
1900
1901         /* 
1902          * group,tombstone vs. unique,active
1903          * => should NOT be replaced
1904          */
1905         {
1906                 .line   = __location__,
1907                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1908                 .r1     = {
1909                         .owner          = &ctx->a,
1910                         .type           = WREPL_TYPE_GROUP,
1911                         .state          = WREPL_STATE_TOMBSTONE,
1912                         .node           = WREPL_NODE_B,
1913                         .is_static      = False,
1914                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1915                         .ips            = addresses_A_1,
1916                         .apply_expected = True
1917                 },
1918                 .r2     = {
1919                         .owner          = &ctx->b,
1920                         .type           = WREPL_TYPE_UNIQUE,
1921                         .state          = WREPL_STATE_ACTIVE,
1922                         .node           = WREPL_NODE_B,
1923                         .is_static      = False,
1924                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1925                         .ips            = addresses_A_1,
1926                         .apply_expected = False
1927                 }
1928         },
1929
1930         /* 
1931          * group,tombstone vs. unique,tombstone
1932          * => should NOT be replaced
1933          */
1934         {
1935                 .line   = __location__,
1936                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1937                 .r1     = {
1938                         .owner          = &ctx->a,
1939                         .type           = WREPL_TYPE_GROUP,
1940                         .state          = WREPL_STATE_TOMBSTONE,
1941                         .node           = WREPL_NODE_B,
1942                         .is_static      = False,
1943                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1944                         .ips            = addresses_A_1,
1945                         .apply_expected = True
1946                 },
1947                 .r2     = {
1948                         .owner          = &ctx->b,
1949                         .type           = WREPL_TYPE_UNIQUE,
1950                         .state          = WREPL_STATE_TOMBSTONE,
1951                         .node           = WREPL_NODE_B,
1952                         .is_static      = False,
1953                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1954                         .ips            = addresses_A_1,
1955                         .apply_expected = False
1956                 }
1957         },
1958
1959 /*
1960  * normal groups vs normal groups section,
1961  */
1962         /* 
1963          * group,active vs. group,active
1964          * => should NOT be replaced
1965          */
1966         {
1967                 .line   = __location__,
1968                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1969                 .r1     = {
1970                         .owner          = &ctx->a,
1971                         .type           = WREPL_TYPE_GROUP,
1972                         .state          = WREPL_STATE_ACTIVE,
1973                         .node           = WREPL_NODE_B,
1974                         .is_static      = False,
1975                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1976                         .ips            = addresses_A_1,
1977                         .apply_expected = True
1978                 },
1979                 .r2     = {
1980                         .owner          = &ctx->b,
1981                         .type           = WREPL_TYPE_GROUP,
1982                         .state          = WREPL_STATE_ACTIVE,
1983                         .node           = WREPL_NODE_B,
1984                         .is_static      = False,
1985                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1986                         .ips            = addresses_A_1,
1987                         .apply_expected = False
1988                 }
1989         },
1990
1991         /* 
1992          * group,active vs. group,tombstone
1993          * => should NOT be replaced
1994          */
1995         {
1996                 .line   = __location__,
1997                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1998                 .r1     = {
1999                         .owner          = &ctx->a,
2000                         .type           = WREPL_TYPE_GROUP,
2001                         .state          = WREPL_STATE_ACTIVE,
2002                         .node           = WREPL_NODE_B,
2003                         .is_static      = False,
2004                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2005                         .ips            = addresses_A_1,
2006                         .apply_expected = True
2007                 },
2008                 .r2     = {
2009                         .owner          = &ctx->b,
2010                         .type           = WREPL_TYPE_GROUP,
2011                         .state          = WREPL_STATE_TOMBSTONE,
2012                         .node           = WREPL_NODE_B,
2013                         .is_static      = False,
2014                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2015                         .ips            = addresses_A_1,
2016                         .apply_expected = False
2017                 }
2018         },
2019
2020         /* 
2021          * group,released vs. group,active
2022          * => should be replaced
2023          */
2024         {
2025                 .line   = __location__,
2026                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2027                 .r1     = {
2028                         .owner          = &ctx->a,
2029                         .type           = WREPL_TYPE_GROUP,
2030                         .state          = WREPL_STATE_RELEASED,
2031                         .node           = WREPL_NODE_B,
2032                         .is_static      = False,
2033                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2034                         .ips            = addresses_A_1,
2035                         .apply_expected = False
2036                 },
2037                 .r2     = {
2038                         .owner          = &ctx->b,
2039                         .type           = WREPL_TYPE_GROUP,
2040                         .state          = WREPL_STATE_ACTIVE,
2041                         .node           = WREPL_NODE_B,
2042                         .is_static      = False,
2043                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2044                         .ips            = addresses_B_1,
2045                         .apply_expected = True
2046                 }
2047         },
2048
2049         /* 
2050          * group,released vs. group,tombstone
2051          * => should be replaced
2052          */
2053         {
2054                 .line   = __location__,
2055                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2056                 .r1     = {
2057                         .owner          = &ctx->a,
2058                         .type           = WREPL_TYPE_GROUP,
2059                         .state          = WREPL_STATE_RELEASED,
2060                         .node           = WREPL_NODE_B,
2061                         .is_static      = False,
2062                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2063                         .ips            = addresses_A_1,
2064                         .apply_expected = False
2065                 },
2066                 .r2     = {
2067                         .owner          = &ctx->b,
2068                         .type           = WREPL_TYPE_GROUP,
2069                         .state          = WREPL_STATE_TOMBSTONE,
2070                         .node           = WREPL_NODE_B,
2071                         .is_static      = False,
2072                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2073                         .ips            = addresses_B_1,
2074                         .apply_expected = True
2075                 }
2076         },
2077
2078         /* 
2079          * group,tombstone vs. group,active
2080          * => should be replaced
2081          */
2082         {
2083                 .line   = __location__,
2084                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2085                 .r1     = {
2086                         .owner          = &ctx->b,
2087                         .type           = WREPL_TYPE_GROUP,
2088                         .state          = WREPL_STATE_TOMBSTONE,
2089                         .node           = WREPL_NODE_B,
2090                         .is_static      = False,
2091                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2092                         .ips            = addresses_B_1,
2093                         .apply_expected = True
2094                 },
2095                 .r2     = {
2096                         .owner          = &ctx->a,
2097                         .type           = WREPL_TYPE_GROUP,
2098                         .state          = WREPL_STATE_ACTIVE,
2099                         .node           = WREPL_NODE_B,
2100                         .is_static      = False,
2101                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2102                         .ips            = addresses_A_1,
2103                         .apply_expected = True
2104                 }
2105         },
2106
2107         /* 
2108          * group,tombstone vs. group,tombstone
2109          * => should be replaced
2110          */
2111         {
2112                 .line   = __location__,
2113                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2114                 .r1     = {
2115                         .owner          = &ctx->a,
2116                         .type           = WREPL_TYPE_GROUP,
2117                         .state          = WREPL_STATE_TOMBSTONE,
2118                         .node           = WREPL_NODE_B,
2119                         .is_static      = False,
2120                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2121                         .ips            = addresses_A_1,
2122                         .apply_expected = True
2123                 },
2124                 .r2     = {
2125                         .owner          = &ctx->b,
2126                         .type           = WREPL_TYPE_GROUP,
2127                         .state          = WREPL_STATE_TOMBSTONE,
2128                         .node           = WREPL_NODE_B,
2129                         .is_static      = False,
2130                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2131                         .ips            = addresses_B_1,
2132                         .apply_expected = True
2133                 }
2134         },
2135
2136 /*
2137  * normal groups vs special groups section,
2138  */
2139         /* 
2140          * group,active vs. sgroup,active
2141          * => should NOT be replaced
2142          */
2143         {
2144                 .line   = __location__,
2145                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2146                 .r1     = {
2147                         .owner          = &ctx->b,
2148                         .type           = WREPL_TYPE_GROUP,
2149                         .state          = WREPL_STATE_ACTIVE,
2150                         .node           = WREPL_NODE_B,
2151                         .is_static      = False,
2152                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2153                         .ips            = addresses_B_1,
2154                         .apply_expected = True
2155                 },
2156                 .r2     = {
2157                         .owner          = &ctx->a,
2158                         .type           = WREPL_TYPE_SGROUP,
2159                         .state          = WREPL_STATE_ACTIVE,
2160                         .node           = WREPL_NODE_B,
2161                         .is_static      = False,
2162                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2163                         .ips            = addresses_B_1,
2164                         .apply_expected = False
2165                 }
2166         },
2167
2168         /* 
2169          * group,active vs. sgroup,tombstone
2170          * => should NOT be replaced
2171          */
2172         {
2173                 .line   = __location__,
2174                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2175                 .r1     = {
2176                         .owner          = &ctx->b,
2177                         .type           = WREPL_TYPE_GROUP,
2178                         .state          = WREPL_STATE_ACTIVE,
2179                         .node           = WREPL_NODE_B,
2180                         .is_static      = False,
2181                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2182                         .ips            = addresses_B_1,
2183                         .apply_expected = True
2184                 },
2185                 .r2     = {
2186                         .owner          = &ctx->a,
2187                         .type           = WREPL_TYPE_SGROUP,
2188                         .state          = WREPL_STATE_TOMBSTONE,
2189                         .node           = WREPL_NODE_B,
2190                         .is_static      = False,
2191                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2192                         .ips            = addresses_B_1,
2193                         .apply_expected = False
2194                 }
2195         },
2196
2197         /* 
2198          * group,released vs. sgroup,active
2199          * => should be replaced
2200          */
2201         {
2202                 .line   = __location__,
2203                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2204                 .r1     = {
2205                         .owner          = &ctx->a,
2206                         .type           = WREPL_TYPE_GROUP,
2207                         .state          = WREPL_STATE_RELEASED,
2208                         .node           = WREPL_NODE_B,
2209                         .is_static      = False,
2210                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2211                         .ips            = addresses_A_1,
2212                         .apply_expected = False
2213                 },
2214                 .r2     = {
2215                         .owner          = &ctx->b,
2216                         .type           = WREPL_TYPE_SGROUP,
2217                         .state          = WREPL_STATE_ACTIVE,
2218                         .node           = WREPL_NODE_B,
2219                         .is_static      = False,
2220                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2221                         .ips            = addresses_B_1,
2222                         .apply_expected = True
2223                 }
2224         },
2225
2226         /* 
2227          * group,released vs. sgroup,tombstone
2228          * => should NOT be replaced
2229          */
2230         {
2231                 .line   = __location__,
2232                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2233                 .r1     = {
2234                         .owner          = &ctx->b,
2235                         .type           = WREPL_TYPE_GROUP,
2236                         .state          = WREPL_STATE_RELEASED,
2237                         .node           = WREPL_NODE_B,
2238                         .is_static      = False,
2239                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2240                         .ips            = addresses_B_1,
2241                         .apply_expected = False
2242                 },
2243                 .r2     = {
2244                         .owner          = &ctx->a,
2245                         .type           = WREPL_TYPE_SGROUP,
2246                         .state          = WREPL_STATE_TOMBSTONE,
2247                         .node           = WREPL_NODE_B,
2248                         .is_static      = False,
2249                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2250                         .ips            = addresses_B_1,
2251                         .apply_expected = False
2252                 }
2253         },
2254
2255         /* 
2256          * group,tombstone vs. sgroup,active
2257          * => should be replaced
2258          */
2259         {
2260                 .line   = __location__,
2261                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2262                 .r1     = {
2263                         .owner          = &ctx->b,
2264                         .type           = WREPL_TYPE_GROUP,
2265                         .state          = WREPL_STATE_TOMBSTONE,
2266                         .node           = WREPL_NODE_B,
2267                         .is_static      = False,
2268                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2269                         .ips            = addresses_B_1,
2270                         .apply_expected = True
2271                 },
2272                 .r2     = {
2273                         .owner          = &ctx->a,
2274                         .type           = WREPL_TYPE_SGROUP,
2275                         .state          = WREPL_STATE_ACTIVE,
2276                         .node           = WREPL_NODE_B,
2277                         .is_static      = False,
2278                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2279                         .ips            = addresses_A_1,
2280                         .apply_expected = True
2281                 }
2282         },
2283
2284         /* 
2285          * group,tombstone vs. sgroup,tombstone
2286          * => should be replaced
2287          */
2288         {
2289                 .line   = __location__,
2290                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2291                 .r1     = {
2292                         .owner          = &ctx->a,
2293                         .type           = WREPL_TYPE_GROUP,
2294                         .state          = WREPL_STATE_TOMBSTONE,
2295                         .node           = WREPL_NODE_B,
2296                         .is_static      = False,
2297                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2298                         .ips            = addresses_A_1,
2299                         .apply_expected = True
2300                 },
2301                 .r2     = {
2302                         .owner          = &ctx->b,
2303                         .type           = WREPL_TYPE_SGROUP,
2304                         .state          = WREPL_STATE_TOMBSTONE,
2305                         .node           = WREPL_NODE_B,
2306                         .is_static      = False,
2307                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2308                         .ips            = addresses_B_1,
2309                         .apply_expected = True
2310                 }
2311         },
2312
2313 /*
2314  * normal groups vs multi homed section,
2315  */
2316         /* 
2317          * group,active vs. mhomed,active
2318          * => should NOT be replaced
2319          */
2320         {
2321                 .line   = __location__,
2322                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2323                 .r1     = {
2324                         .owner          = &ctx->b,
2325                         .type           = WREPL_TYPE_GROUP,
2326                         .state          = WREPL_STATE_ACTIVE,
2327                         .node           = WREPL_NODE_B,
2328                         .is_static      = False,
2329                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2330                         .ips            = addresses_B_1,
2331                         .apply_expected = True
2332                 },
2333                 .r2     = {
2334                         .owner          = &ctx->a,
2335                         .type           = WREPL_TYPE_MHOMED,
2336                         .state          = WREPL_STATE_ACTIVE,
2337                         .node           = WREPL_NODE_B,
2338                         .is_static      = False,
2339                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2340                         .ips            = addresses_B_1,
2341                         .apply_expected = False
2342                 }
2343         },
2344
2345         /* 
2346          * group,active vs. mhomed,tombstone
2347          * => should NOT be replaced
2348          */
2349         {
2350                 .line   = __location__,
2351                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2352                 .r1     = {
2353                         .owner          = &ctx->b,
2354                         .type           = WREPL_TYPE_GROUP,
2355                         .state          = WREPL_STATE_ACTIVE,
2356                         .node           = WREPL_NODE_B,
2357                         .is_static      = False,
2358                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2359                         .ips            = addresses_B_1,
2360                         .apply_expected = True
2361                 },
2362                 .r2     = {
2363                         .owner          = &ctx->a,
2364                         .type           = WREPL_TYPE_MHOMED,
2365                         .state          = WREPL_STATE_TOMBSTONE,
2366                         .node           = WREPL_NODE_B,
2367                         .is_static      = False,
2368                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2369                         .ips            = addresses_B_1,
2370                         .apply_expected = False
2371                 }
2372         },
2373
2374         /* 
2375          * group,released vs. mhomed,active
2376          * => should NOT be replaced
2377          */
2378         {
2379                 .line   = __location__,
2380                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2381                 .r1     = {
2382                         .owner          = &ctx->b,
2383                         .type           = WREPL_TYPE_GROUP,
2384                         .state          = WREPL_STATE_RELEASED,
2385                         .node           = WREPL_NODE_B,
2386                         .is_static      = False,
2387                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2388                         .ips            = addresses_B_1,
2389                         .apply_expected = False
2390                 },
2391                 .r2     = {
2392                         .owner          = &ctx->a,
2393                         .type           = WREPL_TYPE_MHOMED,
2394                         .state          = WREPL_STATE_ACTIVE,
2395                         .node           = WREPL_NODE_B,
2396                         .is_static      = False,
2397                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2398                         .ips            = addresses_B_1,
2399                         .apply_expected = False
2400                 }
2401         },
2402
2403         /* 
2404          * group,released vs. mhomed,tombstone
2405          * => should NOT be replaced
2406          */
2407         {
2408                 .line   = __location__,
2409                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2410                 .r1     = {
2411                         .owner          = &ctx->b,
2412                         .type           = WREPL_TYPE_GROUP,
2413                         .state          = WREPL_STATE_RELEASED,
2414                         .node           = WREPL_NODE_B,
2415                         .is_static      = False,
2416                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2417                         .ips            = addresses_B_1,
2418                         .apply_expected = False
2419                 },
2420                 .r2     = {
2421                         .owner          = &ctx->a,
2422                         .type           = WREPL_TYPE_MHOMED,
2423                         .state          = WREPL_STATE_TOMBSTONE,
2424                         .node           = WREPL_NODE_B,
2425                         .is_static      = False,
2426                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2427                         .ips            = addresses_B_1,
2428                         .apply_expected = False
2429                 }
2430         },
2431
2432         /* 
2433          * group,tombstone vs. mhomed,active
2434          * => should be replaced
2435          */
2436         {
2437                 .line   = __location__,
2438                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2439                 .r1     = {
2440                         .owner          = &ctx->b,
2441                         .type           = WREPL_TYPE_GROUP,
2442                         .state          = WREPL_STATE_TOMBSTONE,
2443                         .node           = WREPL_NODE_B,
2444                         .is_static      = False,
2445                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2446                         .ips            = addresses_B_1,
2447                         .apply_expected = True
2448                 },
2449                 .r2     = {
2450                         .owner          = &ctx->a,
2451                         .type           = WREPL_TYPE_MHOMED,
2452                         .state          = WREPL_STATE_ACTIVE,
2453                         .node           = WREPL_NODE_B,
2454                         .is_static      = False,
2455                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2456                         .ips            = addresses_A_1,
2457                         .apply_expected = True
2458                 }
2459         },
2460
2461         /* 
2462          * group,tombstone vs. mhomed,tombstone
2463          * => should be replaced
2464          */
2465         {
2466                 .line   = __location__,
2467                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2468                 .r1     = {
2469                         .owner          = &ctx->a,
2470                         .type           = WREPL_TYPE_GROUP,
2471                         .state          = WREPL_STATE_TOMBSTONE,
2472                         .node           = WREPL_NODE_B,
2473                         .is_static      = False,
2474                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2475                         .ips            = addresses_A_1,
2476                         .apply_expected = True
2477                 },
2478                 .r2     = {
2479                         .owner          = &ctx->b,
2480                         .type           = WREPL_TYPE_MHOMED,
2481                         .state          = WREPL_STATE_TOMBSTONE,
2482                         .node           = WREPL_NODE_B,
2483                         .is_static      = False,
2484                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2485                         .ips            = addresses_B_1,
2486                         .apply_expected = True
2487                 }
2488         },
2489
2490 /*
2491  * special groups vs unique section,
2492  */
2493         /* 
2494          * sgroup,active vs. unique,active
2495          * => should NOT be replaced
2496          */
2497         {
2498                 .line   = __location__,
2499                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2500                 .r1     = {
2501                         .owner          = &ctx->b,
2502                         .type           = WREPL_TYPE_SGROUP,
2503                         .state          = WREPL_STATE_ACTIVE,
2504                         .node           = WREPL_NODE_B,
2505                         .is_static      = False,
2506                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2507                         .ips            = addresses_B_1,
2508                         .apply_expected = True
2509                 },
2510                 .r2     = {
2511                         .owner          = &ctx->a,
2512                         .type           = WREPL_TYPE_UNIQUE,
2513                         .state          = WREPL_STATE_ACTIVE,
2514                         .node           = WREPL_NODE_B,
2515                         .is_static      = False,
2516                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2517                         .ips            = addresses_B_1,
2518                         .apply_expected = False
2519                 }
2520         },
2521
2522         /* 
2523          * sgroup,active vs. unique,tombstone
2524          * => should NOT be replaced
2525          */
2526         {
2527                 .line   = __location__,
2528                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2529                 .r1     = {
2530                         .owner          = &ctx->b,
2531                         .type           = WREPL_TYPE_SGROUP,
2532                         .state          = WREPL_STATE_ACTIVE,
2533                         .node           = WREPL_NODE_B,
2534                         .is_static      = False,
2535                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2536                         .ips            = addresses_B_1,
2537                         .apply_expected = True
2538                 },
2539                 .r2     = {
2540                         .owner          = &ctx->a,
2541                         .type           = WREPL_TYPE_UNIQUE,
2542                         .state          = WREPL_STATE_TOMBSTONE,
2543                         .node           = WREPL_NODE_B,
2544                         .is_static      = False,
2545                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2546                         .ips            = addresses_B_1,
2547                         .apply_expected = False
2548                 }
2549         },
2550
2551         /* 
2552          * sgroup,released vs. unique,active
2553          * => should be replaced
2554          */
2555         {
2556                 .line   = __location__,
2557                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2558                 .r1     = {
2559                         .owner          = &ctx->b,
2560                         .type           = WREPL_TYPE_SGROUP,
2561                         .state          = WREPL_STATE_RELEASED,
2562                         .node           = WREPL_NODE_B,
2563                         .is_static      = False,
2564                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2565                         .ips            = addresses_B_1,
2566                         .apply_expected = False
2567                 },
2568                 .r2     = {
2569                         .owner          = &ctx->a,
2570                         .type           = WREPL_TYPE_UNIQUE,
2571                         .state          = WREPL_STATE_ACTIVE,
2572                         .node           = WREPL_NODE_B,
2573                         .is_static      = False,
2574                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2575                         .ips            = addresses_A_1,
2576                         .apply_expected = True
2577                 }
2578         },
2579
2580         /* 
2581          * sgroup,released vs. unique,tombstone
2582          * => should be replaced
2583          */
2584         {
2585                 .line   = __location__,
2586                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2587                 .r1     = {
2588                         .owner          = &ctx->a,
2589                         .type           = WREPL_TYPE_SGROUP,
2590                         .state          = WREPL_STATE_RELEASED,
2591                         .node           = WREPL_NODE_B,
2592                         .is_static      = False,
2593                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2594                         .ips            = addresses_A_1,
2595                         .apply_expected = False
2596                 },
2597                 .r2     = {
2598                         .owner          = &ctx->b,
2599                         .type           = WREPL_TYPE_UNIQUE,
2600                         .state          = WREPL_STATE_TOMBSTONE,
2601                         .node           = WREPL_NODE_B,
2602                         .is_static      = False,
2603                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2604                         .ips            = addresses_B_1,
2605                         .apply_expected = True
2606                 }
2607         },
2608
2609         /* 
2610          * sgroup,tombstone vs. unique,active
2611          * => should be replaced
2612          */
2613         {
2614                 .line   = __location__,
2615                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2616                 .r1     = {
2617                         .owner          = &ctx->a,
2618                         .type           = WREPL_TYPE_SGROUP,
2619                         .state          = WREPL_STATE_TOMBSTONE,
2620                         .node           = WREPL_NODE_B,
2621                         .is_static      = False,
2622                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2623                         .ips            = addresses_A_1,
2624                         .apply_expected = True
2625                 },
2626                 .r2     = {
2627                         .owner          = &ctx->b,
2628                         .type           = WREPL_TYPE_UNIQUE,
2629                         .state          = WREPL_STATE_ACTIVE,
2630                         .node           = WREPL_NODE_B,
2631                         .is_static      = False,
2632                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2633                         .ips            = addresses_B_1,
2634                         .apply_expected = True
2635                 }
2636         },
2637
2638         /* 
2639          * sgroup,tombstone vs. unique,tombstone
2640          * => should be replaced
2641          */
2642         {
2643                 .line   = __location__,
2644                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2645                 .r1     = {
2646                         .owner          = &ctx->b,
2647                         .type           = WREPL_TYPE_SGROUP,
2648                         .state          = WREPL_STATE_TOMBSTONE,
2649                         .node           = WREPL_NODE_B,
2650                         .is_static      = False,
2651                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2652                         .ips            = addresses_B_1,
2653                         .apply_expected = True
2654                 },
2655                 .r2     = {
2656                         .owner          = &ctx->a,
2657                         .type           = WREPL_TYPE_UNIQUE,
2658                         .state          = WREPL_STATE_TOMBSTONE,
2659                         .node           = WREPL_NODE_B,
2660                         .is_static      = False,
2661                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2662                         .ips            = addresses_A_1,
2663                         .apply_expected = True
2664                 }
2665         },
2666
2667 /*
2668  * special groups vs normal group section,
2669  */
2670         /* 
2671          * sgroup,active vs. group,active
2672          * => should NOT be replaced
2673          */
2674         {
2675                 .line   = __location__,
2676                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2677                 .r1     = {
2678                         .owner          = &ctx->a,
2679                         .type           = WREPL_TYPE_SGROUP,
2680                         .state          = WREPL_STATE_ACTIVE,
2681                         .node           = WREPL_NODE_B,
2682                         .is_static      = False,
2683                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2684                         .ips            = addresses_A_1,
2685                         .apply_expected = True
2686                 },
2687                 .r2     = {
2688                         .owner          = &ctx->b,
2689                         .type           = WREPL_TYPE_GROUP,
2690                         .state          = WREPL_STATE_ACTIVE,
2691                         .node           = WREPL_NODE_B,
2692                         .is_static      = False,
2693                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2694                         .ips            = addresses_A_1,
2695                         .apply_expected = False
2696                 }
2697         },
2698
2699         /* 
2700          * sgroup,active vs. group,tombstone
2701          * => should NOT be replaced
2702          */
2703         {
2704                 .line   = __location__,
2705                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2706                 .r1     = {
2707                         .owner          = &ctx->a,
2708                         .type           = WREPL_TYPE_SGROUP,
2709                         .state          = WREPL_STATE_ACTIVE,
2710                         .node           = WREPL_NODE_B,
2711                         .is_static      = False,
2712                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2713                         .ips            = addresses_A_1,
2714                         .apply_expected = True
2715                 },
2716                 .r2     = {
2717                         .owner          = &ctx->b,
2718                         .type           = WREPL_TYPE_GROUP,
2719                         .state          = WREPL_STATE_TOMBSTONE,
2720                         .node           = WREPL_NODE_B,
2721                         .is_static      = False,
2722                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2723                         .ips            = addresses_A_1,
2724                         .apply_expected = False
2725                 }
2726         },
2727
2728         /* 
2729          * sgroup,released vs. group,active
2730          * => should be replaced
2731          */
2732         {
2733                 .line   = __location__,
2734                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2735                 .r1     = {
2736                         .owner          = &ctx->a,
2737                         .type           = WREPL_TYPE_SGROUP,
2738                         .state          = WREPL_STATE_RELEASED,
2739                         .node           = WREPL_NODE_B,
2740                         .is_static      = False,
2741                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2742                         .ips            = addresses_A_1,
2743                         .apply_expected = False
2744                 },
2745                 .r2     = {
2746                         .owner          = &ctx->b,
2747                         .type           = WREPL_TYPE_GROUP,
2748                         .state          = WREPL_STATE_ACTIVE,
2749                         .node           = WREPL_NODE_B,
2750                         .is_static      = False,
2751                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2752                         .ips            = addresses_B_1,
2753                         .apply_expected = True
2754                 }
2755         },
2756
2757         /* 
2758          * sgroup,released vs. group,tombstone
2759          * => should be replaced
2760          */
2761         {
2762                 .line   = __location__,
2763                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2764                 .r1     = {
2765                         .owner          = &ctx->b,
2766                         .type           = WREPL_TYPE_SGROUP,
2767                         .state          = WREPL_STATE_RELEASED,
2768                         .node           = WREPL_NODE_B,
2769                         .is_static      = False,
2770                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2771                         .ips            = addresses_B_1,
2772                         .apply_expected = False
2773                 },
2774                 .r2     = {
2775                         .owner          = &ctx->a,
2776                         .type           = WREPL_TYPE_GROUP,
2777                         .state          = WREPL_STATE_TOMBSTONE,
2778                         .node           = WREPL_NODE_B,
2779                         .is_static      = False,
2780                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2781                         .ips            = addresses_A_1,
2782                         .apply_expected = True
2783                 }
2784         },
2785
2786         /* 
2787          * sgroup,tombstone vs. group,active
2788          * => should NOT be replaced
2789          */
2790         {
2791                 .line   = __location__,
2792                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2793                 .r1     = {
2794                         .owner          = &ctx->a,
2795                         .type           = WREPL_TYPE_SGROUP,
2796                         .state          = WREPL_STATE_TOMBSTONE,
2797                         .node           = WREPL_NODE_B,
2798                         .is_static      = False,
2799                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2800                         .ips            = addresses_A_1,
2801                         .apply_expected = True
2802                 },
2803                 .r2     = {
2804                         .owner          = &ctx->b,
2805                         .type           = WREPL_TYPE_GROUP,
2806                         .state          = WREPL_STATE_ACTIVE,
2807                         .node           = WREPL_NODE_B,
2808                         .is_static      = False,
2809                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2810                         .ips            = addresses_B_1,
2811                         .apply_expected = True
2812                 }
2813         },
2814
2815         /* 
2816          * sgroup,tombstone vs. group,tombstone
2817          * => should NOT be replaced
2818          */
2819         {
2820                 .line   = __location__,
2821                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2822                 .r1     = {
2823                         .owner          = &ctx->b,
2824                         .type           = WREPL_TYPE_SGROUP,
2825                         .state          = WREPL_STATE_TOMBSTONE,
2826                         .node           = WREPL_NODE_B,
2827                         .is_static      = False,
2828                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2829                         .ips            = addresses_B_1,
2830                         .apply_expected = True
2831                 },
2832                 .r2     = {
2833                         .owner          = &ctx->a,
2834                         .type           = WREPL_TYPE_GROUP,
2835                         .state          = WREPL_STATE_TOMBSTONE,
2836                         .node           = WREPL_NODE_B,
2837                         .is_static      = False,
2838                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2839                         .ips            = addresses_A_1,
2840                         .apply_expected = True
2841                 }
2842         },
2843
2844 /*
2845  * special groups vs multi homed section,
2846  */
2847         /* 
2848          * sgroup,active vs. mhomed,active
2849          * => should NOT be replaced
2850          */
2851         {
2852                 .line   = __location__,
2853                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2854                 .r1     = {
2855                         .owner          = &ctx->a,
2856                         .type           = WREPL_TYPE_SGROUP,
2857                         .state          = WREPL_STATE_ACTIVE,
2858                         .node           = WREPL_NODE_B,
2859                         .is_static      = False,
2860                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2861                         .ips            = addresses_A_1,
2862                         .apply_expected = True
2863                 },
2864                 .r2     = {
2865                         .owner          = &ctx->b,
2866                         .type           = WREPL_TYPE_MHOMED,
2867                         .state          = WREPL_STATE_ACTIVE,
2868                         .node           = WREPL_NODE_B,
2869                         .is_static      = False,
2870                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2871                         .ips            = addresses_A_1,
2872                         .apply_expected = False
2873                 }
2874         },
2875
2876         /* 
2877          * sgroup,active vs. mhomed,tombstone
2878          * => should NOT be replaced
2879          */
2880         {
2881                 .line   = __location__,
2882                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2883                 .r1     = {
2884                         .owner          = &ctx->a,
2885                         .type           = WREPL_TYPE_SGROUP,
2886                         .state          = WREPL_STATE_ACTIVE,
2887                         .node           = WREPL_NODE_B,
2888                         .is_static      = False,
2889                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2890                         .ips            = addresses_A_1,
2891                         .apply_expected = True
2892                 },
2893                 .r2     = {
2894                         .owner          = &ctx->b,
2895                         .type           = WREPL_TYPE_MHOMED,
2896                         .state          = WREPL_STATE_TOMBSTONE,
2897                         .node           = WREPL_NODE_B,
2898                         .is_static      = False,
2899                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2900                         .ips            = addresses_A_1,
2901                         .apply_expected = False
2902                 }
2903         },
2904
2905         /* 
2906          * sgroup,released vs. mhomed,active
2907          * => should be replaced
2908          */
2909         {
2910                 .line   = __location__,
2911                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2912                 .r1     = {
2913                         .owner          = &ctx->a,
2914                         .type           = WREPL_TYPE_SGROUP,
2915                         .state          = WREPL_STATE_RELEASED,
2916                         .node           = WREPL_NODE_B,
2917                         .is_static      = False,
2918                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2919                         .ips            = addresses_A_1,
2920                         .apply_expected = False
2921                 },
2922                 .r2     = {
2923                         .owner          = &ctx->b,
2924                         .type           = WREPL_TYPE_MHOMED,
2925                         .state          = WREPL_STATE_ACTIVE,
2926                         .node           = WREPL_NODE_B,
2927                         .is_static      = False,
2928                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2929                         .ips            = addresses_B_1,
2930                         .apply_expected = True
2931                 }
2932         },
2933
2934         /* 
2935          * sgroup,released vs. mhomed,tombstone
2936          * => should be replaced
2937          */
2938         {
2939                 .line   = __location__,
2940                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2941                 .r1     = {
2942                         .owner          = &ctx->b,
2943                         .type           = WREPL_TYPE_SGROUP,
2944                         .state          = WREPL_STATE_RELEASED,
2945                         .node           = WREPL_NODE_B,
2946                         .is_static      = False,
2947                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2948                         .ips            = addresses_B_1,
2949                         .apply_expected = False
2950                 },
2951                 .r2     = {
2952                         .owner          = &ctx->a,
2953                         .type           = WREPL_TYPE_MHOMED,
2954                         .state          = WREPL_STATE_TOMBSTONE,
2955                         .node           = WREPL_NODE_B,
2956                         .is_static      = False,
2957                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2958                         .ips            = addresses_A_1,
2959                         .apply_expected = True
2960                 }
2961         },
2962
2963         /* 
2964          * sgroup,tombstone vs. mhomed,active
2965          * => should be replaced
2966          */
2967         {
2968                 .line   = __location__,
2969                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2970                 .r1     = {
2971                         .owner          = &ctx->a,
2972                         .type           = WREPL_TYPE_SGROUP,
2973                         .state          = WREPL_STATE_TOMBSTONE,
2974                         .node           = WREPL_NODE_B,
2975                         .is_static      = False,
2976                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2977                         .ips            = addresses_A_1,
2978                         .apply_expected = True
2979                 },
2980                 .r2     = {
2981                         .owner          = &ctx->b,
2982                         .type           = WREPL_TYPE_MHOMED,
2983                         .state          = WREPL_STATE_ACTIVE,
2984                         .node           = WREPL_NODE_B,
2985                         .is_static      = False,
2986                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2987                         .ips            = addresses_B_1,
2988                         .apply_expected = True
2989                 }
2990         },
2991
2992         /* 
2993          * sgroup,tombstone vs. mhomed,tombstone
2994          * => should be replaced
2995          */
2996         {
2997                 .line   = __location__,
2998                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2999                 .r1     = {
3000                         .owner          = &ctx->b,
3001                         .type           = WREPL_TYPE_SGROUP,
3002                         .state          = WREPL_STATE_TOMBSTONE,
3003                         .node           = WREPL_NODE_B,
3004                         .is_static      = False,
3005                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3006                         .ips            = addresses_B_1,
3007                         .apply_expected = True
3008                 },
3009                 .r2     = {
3010                         .owner          = &ctx->a,
3011                         .type           = WREPL_TYPE_MHOMED,
3012                         .state          = WREPL_STATE_TOMBSTONE,
3013                         .node           = WREPL_NODE_B,
3014                         .is_static      = False,
3015                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3016                         .ips            = addresses_A_1,
3017                         .apply_expected = True
3018                 }
3019         },
3020
3021 /*
3022  * multi homed vs. unique section,
3023  */
3024         /* 
3025          * mhomed,active vs. unique,active
3026          * => should be replaced
3027          */
3028         {
3029                 .line   = __location__,
3030                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3031                 .r1     = {
3032                         .owner          = &ctx->a,
3033                         .type           = WREPL_TYPE_MHOMED,
3034                         .state          = WREPL_STATE_ACTIVE,
3035                         .node           = WREPL_NODE_B,
3036                         .is_static      = False,
3037                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3038                         .ips            = addresses_A_3_4,
3039                         .apply_expected = True
3040                 },
3041                 .r2     = {
3042                         .owner          = &ctx->b,
3043                         .type           = WREPL_TYPE_UNIQUE,
3044                         .state          = WREPL_STATE_ACTIVE,
3045                         .node           = WREPL_NODE_B,
3046                         .is_static      = False,
3047                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3048                         .ips            = addresses_B_1,
3049                         .apply_expected = True
3050                 }
3051         },
3052
3053         /* 
3054          * mhomed,active vs. unique,tombstone
3055          * => should NOT be replaced
3056          */
3057         {
3058                 .line   = __location__,
3059                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3060                 .r1     = {
3061                         .owner          = &ctx->b,
3062                         .type           = WREPL_TYPE_MHOMED,
3063                         .state          = WREPL_STATE_ACTIVE,
3064                         .node           = WREPL_NODE_B,
3065                         .is_static      = False,
3066                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3067                         .ips            = addresses_B_1,
3068                         .apply_expected = True
3069                 },
3070                 .r2     = {
3071                         .owner          = &ctx->a,
3072                         .type           = WREPL_TYPE_UNIQUE,
3073                         .state          = WREPL_STATE_TOMBSTONE,
3074                         .node           = WREPL_NODE_B,
3075                         .is_static      = False,
3076                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3077                         .ips            = addresses_B_1,
3078                         .apply_expected = False
3079                 }
3080         },
3081
3082         /* 
3083          * mhomed,released vs. unique,active
3084          * => should be replaced
3085          */
3086         {
3087                 .line   = __location__,
3088                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3089                 .r1     = {
3090                         .owner          = &ctx->a,
3091                         .type           = WREPL_TYPE_MHOMED,
3092                         .state          = WREPL_STATE_RELEASED,
3093                         .node           = WREPL_NODE_B,
3094                         .is_static      = False,
3095                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3096                         .ips            = addresses_A_1,
3097                         .apply_expected = False
3098                 },
3099                 .r2     = {
3100                         .owner          = &ctx->b,
3101                         .type           = WREPL_TYPE_UNIQUE,
3102                         .state          = WREPL_STATE_ACTIVE,
3103                         .node           = WREPL_NODE_B,
3104                         .is_static      = False,
3105                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3106                         .ips            = addresses_B_1,
3107                         .apply_expected = True
3108                 }
3109         },
3110
3111         /* 
3112          * mhomed,released vs. uinique,tombstone
3113          * => should be replaced
3114          */
3115         {
3116                 .line   = __location__,
3117                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3118                 .r1     = {
3119                         .owner          = &ctx->b,
3120                         .type           = WREPL_TYPE_MHOMED,
3121                         .state          = WREPL_STATE_RELEASED,
3122                         .node           = WREPL_NODE_B,
3123                         .is_static      = False,
3124                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3125                         .ips            = addresses_B_1,
3126                         .apply_expected = False
3127                 },
3128                 .r2     = {
3129                         .owner          = &ctx->a,
3130                         .type           = WREPL_TYPE_UNIQUE,
3131                         .state          = WREPL_STATE_TOMBSTONE,
3132                         .node           = WREPL_NODE_B,
3133                         .is_static      = False,
3134                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3135                         .ips            = addresses_A_1,
3136                         .apply_expected = True
3137                 }
3138         },
3139
3140         /* 
3141          * mhomed,tombstone vs. unique,active
3142          * => should be replaced
3143          */
3144         {
3145                 .line   = __location__,
3146                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3147                 .r1     = {
3148                         .owner          = &ctx->a,
3149                         .type           = WREPL_TYPE_MHOMED,
3150                         .state          = WREPL_STATE_TOMBSTONE,
3151                         .node           = WREPL_NODE_B,
3152                         .is_static      = False,
3153                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3154                         .ips            = addresses_A_1,
3155                         .apply_expected = True
3156                 },
3157                 .r2     = {
3158                         .owner          = &ctx->b,
3159                         .type           = WREPL_TYPE_UNIQUE,
3160                         .state          = WREPL_STATE_ACTIVE,
3161                         .node           = WREPL_NODE_B,
3162                         .is_static      = False,
3163                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3164                         .ips            = addresses_B_1,
3165                         .apply_expected = True
3166                 }
3167         },
3168
3169         /* 
3170          * mhomed,tombstone vs. uinique,tombstone
3171          * => should be replaced
3172          */
3173         {
3174                 .line   = __location__,
3175                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3176                 .r1     = {
3177                         .owner          = &ctx->b,
3178                         .type           = WREPL_TYPE_MHOMED,
3179                         .state          = WREPL_STATE_TOMBSTONE,
3180                         .node           = WREPL_NODE_B,
3181                         .is_static      = False,
3182                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3183                         .ips            = addresses_B_1,
3184                         .apply_expected = True
3185                 },
3186                 .r2     = {
3187                         .owner          = &ctx->a,
3188                         .type           = WREPL_TYPE_UNIQUE,
3189                         .state          = WREPL_STATE_TOMBSTONE,
3190                         .node           = WREPL_NODE_B,
3191                         .is_static      = False,
3192                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3193                         .ips            = addresses_A_1,
3194                         .apply_expected = True
3195                 }
3196         },
3197
3198 /*
3199  * multi homed vs. normal group section,
3200  */
3201         /* 
3202          * mhomed,active vs. group,active
3203          * => should be replaced
3204          */
3205         {
3206                 .line   = __location__,
3207                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3208                 .r1     = {
3209                         .owner          = &ctx->a,
3210                         .type           = WREPL_TYPE_MHOMED,
3211                         .state          = WREPL_STATE_ACTIVE,
3212                         .node           = WREPL_NODE_B,
3213                         .is_static      = False,
3214                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3215                         .ips            = addresses_A_1,
3216                         .apply_expected = True
3217                 },
3218                 .r2     = {
3219                         .owner          = &ctx->b,
3220                         .type           = WREPL_TYPE_GROUP,
3221                         .state          = WREPL_STATE_ACTIVE,
3222                         .node           = WREPL_NODE_B,
3223                         .is_static      = False,
3224                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3225                         .ips            = addresses_B_1,
3226                         .apply_expected = True
3227                 }
3228         },
3229
3230         /* 
3231          * mhomed,active vs. group,tombstone
3232          * => should NOT be replaced
3233          */
3234         {
3235                 .line   = __location__,
3236                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3237                 .r1     = {
3238                         .owner          = &ctx->b,
3239                         .type           = WREPL_TYPE_MHOMED,
3240                         .state          = WREPL_STATE_ACTIVE,
3241                         .node           = WREPL_NODE_B,
3242                         .is_static      = False,
3243                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3244                         .ips            = addresses_B_1,
3245                         .apply_expected = True
3246                 },
3247                 .r2     = {
3248                         .owner          = &ctx->a,
3249                         .type           = WREPL_TYPE_GROUP,
3250                         .state          = WREPL_STATE_TOMBSTONE,
3251                         .node           = WREPL_NODE_B,
3252                         .is_static      = False,
3253                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3254                         .ips            = addresses_B_1,
3255                         .apply_expected = False
3256                 }
3257         },
3258
3259         /* 
3260          * mhomed,released vs. group,active
3261          * => should be replaced
3262          */
3263         {
3264                 .line   = __location__,
3265                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3266                 .r1     = {
3267                         .owner          = &ctx->b,
3268                         .type           = WREPL_TYPE_MHOMED,
3269                         .state          = WREPL_STATE_RELEASED,
3270                         .node           = WREPL_NODE_B,
3271                         .is_static      = False,
3272                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3273                         .ips            = addresses_B_1,
3274                         .apply_expected = False
3275                 },
3276                 .r2     = {
3277                         .owner          = &ctx->a,
3278                         .type           = WREPL_TYPE_GROUP,
3279                         .state          = WREPL_STATE_ACTIVE,
3280                         .node           = WREPL_NODE_B,
3281                         .is_static      = False,
3282                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3283                         .ips            = addresses_A_1,
3284                         .apply_expected = True
3285                 }
3286         },
3287
3288         /* 
3289          * mhomed,released vs. group,tombstone
3290          * => should be replaced
3291          */
3292         {
3293                 .line   = __location__,
3294                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3295                 .r1     = {
3296                         .owner          = &ctx->a,
3297                         .type           = WREPL_TYPE_MHOMED,
3298                         .state          = WREPL_STATE_RELEASED,
3299                         .node           = WREPL_NODE_B,
3300                         .is_static      = False,
3301                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3302                         .ips            = addresses_A_1,
3303                         .apply_expected = False
3304                 },
3305                 .r2     = {
3306                         .owner          = &ctx->b,
3307                         .type           = WREPL_TYPE_GROUP,
3308                         .state          = WREPL_STATE_TOMBSTONE,
3309                         .node           = WREPL_NODE_B,
3310                         .is_static      = False,
3311                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3312                         .ips            = addresses_B_1,
3313                         .apply_expected = True
3314                 }
3315         },
3316
3317         /* 
3318          * mhomed,tombstone vs. group,active
3319          * => should be replaced
3320          */
3321         {
3322                 .line   = __location__,
3323                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3324                 .r1     = {
3325                         .owner          = &ctx->b,
3326                         .type           = WREPL_TYPE_MHOMED,
3327                         .state          = WREPL_STATE_TOMBSTONE,
3328                         .node           = WREPL_NODE_B,
3329                         .is_static      = False,
3330                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3331                         .ips            = addresses_B_1,
3332                         .apply_expected = True
3333                 },
3334                 .r2     = {
3335                         .owner          = &ctx->a,
3336                         .type           = WREPL_TYPE_GROUP,
3337                         .state          = WREPL_STATE_ACTIVE,
3338                         .node           = WREPL_NODE_B,
3339                         .is_static      = False,
3340                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3341                         .ips            = addresses_A_1,
3342                         .apply_expected = True
3343                 }
3344         },
3345
3346         /* 
3347          * mhomed,tombstone vs. group,tombstone
3348          * => should be replaced
3349          */
3350         {
3351                 .line   = __location__,
3352                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3353                 .r1     = {
3354                         .owner          = &ctx->a,
3355                         .type           = WREPL_TYPE_MHOMED,
3356                         .state          = WREPL_STATE_TOMBSTONE,
3357                         .node           = WREPL_NODE_B,
3358                         .is_static      = False,
3359                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3360                         .ips            = addresses_A_1,
3361                         .apply_expected = True
3362                 },
3363                 .r2     = {
3364                         .owner          = &ctx->b,
3365                         .type           = WREPL_TYPE_GROUP,
3366                         .state          = WREPL_STATE_TOMBSTONE,
3367                         .node           = WREPL_NODE_B,
3368                         .is_static      = False,
3369                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3370                         .ips            = addresses_B_1,
3371                         .apply_expected = True
3372                 }
3373         },
3374
3375 /*
3376  * multi homed vs. special group section,
3377  */
3378         /* 
3379          * mhomed,active vs. sgroup,active
3380          * => should NOT be replaced
3381          */
3382         {
3383                 .line   = __location__,
3384                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3385                 .r1     = {
3386                         .owner          = &ctx->a,
3387                         .type           = WREPL_TYPE_MHOMED,
3388                         .state          = WREPL_STATE_ACTIVE,
3389                         .node           = WREPL_NODE_B,
3390                         .is_static      = False,
3391                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3392                         .ips            = addresses_A_1,
3393                         .apply_expected = True
3394                 },
3395                 .r2     = {
3396                         .owner          = &ctx->b,
3397                         .type           = WREPL_TYPE_SGROUP,
3398                         .state          = WREPL_STATE_ACTIVE,
3399                         .node           = WREPL_NODE_B,
3400                         .is_static      = False,
3401                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3402                         .ips            = addresses_A_1,
3403                         .apply_expected = False
3404                 }
3405         },
3406
3407         /* 
3408          * mhomed,active vs. sgroup,tombstone
3409          * => should NOT be replaced
3410          */
3411         {
3412                 .line   = __location__,
3413                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3414                 .r1     = {
3415                         .owner          = &ctx->a,
3416                         .type           = WREPL_TYPE_MHOMED,
3417                         .state          = WREPL_STATE_ACTIVE,
3418                         .node           = WREPL_NODE_B,
3419                         .is_static      = False,
3420                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3421                         .ips            = addresses_A_1,
3422                         .apply_expected = True
3423                 },
3424                 .r2     = {
3425                         .owner          = &ctx->b,
3426                         .type           = WREPL_TYPE_SGROUP,
3427                         .state          = WREPL_STATE_TOMBSTONE,
3428                         .node           = WREPL_NODE_B,
3429                         .is_static      = False,
3430                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3431                         .ips            = addresses_A_1,
3432                         .apply_expected = False
3433                 }
3434         },
3435
3436         /* 
3437          * mhomed,released vs. sgroup,active
3438          * => should be replaced
3439          */
3440         {
3441                 .line   = __location__,
3442                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3443                 .r1     = {
3444                         .owner          = &ctx->a,
3445                         .type           = WREPL_TYPE_MHOMED,
3446                         .state          = WREPL_STATE_RELEASED,
3447                         .node           = WREPL_NODE_B,
3448                         .is_static      = False,
3449                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3450                         .ips            = addresses_A_1,
3451                         .apply_expected = False
3452                 },
3453                 .r2     = {
3454                         .owner          = &ctx->b,
3455                         .type           = WREPL_TYPE_SGROUP,
3456                         .state          = WREPL_STATE_ACTIVE,
3457                         .node           = WREPL_NODE_B,
3458                         .is_static      = False,
3459                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3460                         .ips            = addresses_B_1,
3461                         .apply_expected = True
3462                 }
3463         },
3464
3465         /* 
3466          * mhomed,released vs. sgroup,tombstone
3467          * => should be replaced
3468          */
3469         {
3470                 .line   = __location__,
3471                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3472                 .r1     = {
3473                         .owner          = &ctx->b,
3474                         .type           = WREPL_TYPE_MHOMED,
3475                         .state          = WREPL_STATE_RELEASED,
3476                         .node           = WREPL_NODE_B,
3477                         .is_static      = False,
3478                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3479                         .ips            = addresses_B_1,
3480                         .apply_expected = False
3481                 },
3482                 .r2     = {
3483                         .owner          = &ctx->a,
3484                         .type           = WREPL_TYPE_SGROUP,
3485                         .state          = WREPL_STATE_TOMBSTONE,
3486                         .node           = WREPL_NODE_B,
3487                         .is_static      = False,
3488                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3489                         .ips            = addresses_A_1,
3490                         .apply_expected = True
3491                 }
3492         },
3493
3494         /* 
3495          * mhomed,tombstone vs. sgroup,active
3496          * => should be replaced
3497          */
3498         {
3499                 .line   = __location__,
3500                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3501                 .r1     = {
3502                         .owner          = &ctx->a,
3503                         .type           = WREPL_TYPE_MHOMED,
3504                         .state          = WREPL_STATE_TOMBSTONE,
3505                         .node           = WREPL_NODE_B,
3506                         .is_static      = False,
3507                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3508                         .ips            = addresses_A_1,
3509                         .apply_expected = True
3510                 },
3511                 .r2     = {
3512                         .owner          = &ctx->b,
3513                         .type           = WREPL_TYPE_SGROUP,
3514                         .state          = WREPL_STATE_ACTIVE,
3515                         .node           = WREPL_NODE_B,
3516                         .is_static      = False,
3517                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3518                         .ips            = addresses_B_1,
3519                         .apply_expected = True
3520                 }
3521         },
3522
3523         /* 
3524          * mhomed,tombstone vs. sgroup,tombstone
3525          * => should be replaced
3526          */
3527         {
3528                 .line   = __location__,
3529                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3530                 .r1     = {
3531                         .owner          = &ctx->b,
3532                         .type           = WREPL_TYPE_MHOMED,
3533                         .state          = WREPL_STATE_TOMBSTONE,
3534                         .node           = WREPL_NODE_B,
3535                         .is_static      = False,
3536                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3537                         .ips            = addresses_B_1,
3538                         .apply_expected = True
3539                 },
3540                 .r2     = {
3541                         .owner          = &ctx->a,
3542                         .type           = WREPL_TYPE_SGROUP,
3543                         .state          = WREPL_STATE_TOMBSTONE,
3544                         .node           = WREPL_NODE_B,
3545                         .is_static      = False,
3546                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3547                         .ips            = addresses_A_1,
3548                         .apply_expected = True
3549                 }
3550         },
3551
3552 /*
3553  * multi homed vs. mlti homed section,
3554  */
3555         /* 
3556          * mhomed,active vs. mhomed,active
3557          * => should be replaced
3558          */
3559         {
3560                 .line   = __location__,
3561                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3562                 .r1     = {
3563                         .owner          = &ctx->a,
3564                         .type           = WREPL_TYPE_MHOMED,
3565                         .state          = WREPL_STATE_ACTIVE,
3566                         .node           = WREPL_NODE_B,
3567                         .is_static      = False,
3568                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3569                         .ips            = addresses_A_3_4,
3570                         .apply_expected = True
3571                 },
3572                 .r2     = {
3573                         .owner          = &ctx->b,
3574                         .type           = WREPL_TYPE_MHOMED,
3575                         .state          = WREPL_STATE_ACTIVE,
3576                         .node           = WREPL_NODE_B,
3577                         .is_static      = False,
3578                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3579                         .ips            = addresses_B_3_4,
3580                         .apply_expected = True
3581                 }
3582         },
3583
3584         /* 
3585          * mhomed,active vs. mhomed,tombstone
3586          * => should NOT be replaced
3587          */
3588         {
3589                 .line   = __location__,
3590                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3591                 .r1     = {
3592                         .owner          = &ctx->b,
3593                         .type           = WREPL_TYPE_MHOMED,
3594                         .state          = WREPL_STATE_ACTIVE,
3595                         .node           = WREPL_NODE_B,
3596                         .is_static      = False,
3597                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3598                         .ips            = addresses_B_3_4,
3599                         .apply_expected = True
3600                 },
3601                 .r2     = {
3602                         .owner          = &ctx->a,
3603                         .type           = WREPL_TYPE_MHOMED,
3604                         .state          = WREPL_STATE_TOMBSTONE,
3605                         .node           = WREPL_NODE_B,
3606                         .is_static      = False,
3607                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3608                         .ips            = addresses_B_3_4,
3609                         .apply_expected = False
3610                 }
3611         },
3612
3613         /* 
3614          * mhomed,released vs. mhomed,active
3615          * => should be replaced
3616          */
3617         {
3618                 .line   = __location__,
3619                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3620                 .r1     = {
3621                         .owner          = &ctx->b,
3622                         .type           = WREPL_TYPE_MHOMED,
3623                         .state          = WREPL_STATE_RELEASED,
3624                         .node           = WREPL_NODE_B,
3625                         .is_static      = False,
3626                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3627                         .ips            = addresses_B_3_4,
3628                         .apply_expected = False
3629                 },
3630                 .r2     = {
3631                         .owner          = &ctx->a,
3632                         .type           = WREPL_TYPE_MHOMED,
3633                         .state          = WREPL_STATE_ACTIVE,
3634                         .node           = WREPL_NODE_B,
3635                         .is_static      = False,
3636                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3637                         .ips            = addresses_A_3_4,
3638                         .apply_expected = True
3639                 }
3640         },
3641
3642         /* 
3643          * mhomed,released vs. mhomed,tombstone
3644          * => should be replaced
3645          */
3646         {
3647                 .line   = __location__,
3648                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3649                 .r1     = {
3650                         .owner          = &ctx->a,
3651                         .type           = WREPL_TYPE_MHOMED,
3652                         .state          = WREPL_STATE_RELEASED,
3653                         .node           = WREPL_NODE_B,
3654                         .is_static      = False,
3655                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3656                         .ips            = addresses_A_3_4,
3657                         .apply_expected = False
3658                 },
3659                 .r2     = {
3660                         .owner          = &ctx->b,
3661                         .type           = WREPL_TYPE_MHOMED,
3662                         .state          = WREPL_STATE_TOMBSTONE,
3663                         .node           = WREPL_NODE_B,
3664                         .is_static      = False,
3665                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3666                         .ips            = addresses_B_3_4,
3667                         .apply_expected = True
3668                 }
3669         },
3670
3671         /* 
3672          * mhomed,tombstone vs. mhomed,active
3673          * => should be replaced
3674          */
3675         {
3676                 .line   = __location__,
3677                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3678                 .r1     = {
3679                         .owner          = &ctx->b,
3680                         .type           = WREPL_TYPE_MHOMED,
3681                         .state          = WREPL_STATE_TOMBSTONE,
3682                         .node           = WREPL_NODE_B,
3683                         .is_static      = False,
3684                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3685                         .ips            = addresses_B_3_4,
3686                         .apply_expected = True
3687                 },
3688                 .r2     = {
3689                         .owner          = &ctx->a,
3690                         .type           = WREPL_TYPE_MHOMED,
3691                         .state          = WREPL_STATE_ACTIVE,
3692                         .node           = WREPL_NODE_B,
3693                         .is_static      = False,
3694                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3695                         .ips            = addresses_A_3_4,
3696                         .apply_expected = True
3697                 }
3698         },
3699
3700         /* 
3701          * mhomed,tombstone vs. mhomed,tombstone
3702          * => should be replaced
3703          */
3704         {
3705                 .line   = __location__,
3706                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3707                 .r1     = {
3708                         .owner          = &ctx->a,
3709                         .type           = WREPL_TYPE_MHOMED,
3710                         .state          = WREPL_STATE_TOMBSTONE,
3711                         .node           = WREPL_NODE_B,
3712                         .is_static      = False,
3713                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3714                         .ips            = addresses_A_3_4,
3715                         .apply_expected = True
3716                 },
3717                 .r2     = {
3718                         .owner          = &ctx->b,
3719                         .type           = WREPL_TYPE_MHOMED,
3720                         .state          = WREPL_STATE_TOMBSTONE,
3721                         .node           = WREPL_NODE_B,
3722                         .is_static      = False,
3723                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3724                         .ips            = addresses_B_3_4,
3725                         .apply_expected = True
3726                 }
3727         },
3728
3729 #if 0
3730 /*
3731  * special group vs special group section,
3732  */
3733         /* 
3734          * sgroup,active vs. sgroup,active
3735          * => should be merged
3736          */
3737         {
3738                 .line   = __location__,
3739                 .name   = _NBT_NAME("_DIFF_OWNER_SG", 0x00, NULL),
3740                 .extra  = True,
3741                 .r1     = {
3742                         .owner          = &ctx->a,
3743                         .type           = WREPL_TYPE_SGROUP,
3744                         .state          = WREPL_STATE_ACTIVE,
3745                         .node           = WREPL_NODE_B,
3746                         .is_static      = False,
3747                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3748                         .ips            = addresses_A_3_4,
3749                         .apply_expected = True,
3750                 },
3751                 .r2     = {
3752                         .owner          = &ctx->b,
3753                         .type           = WREPL_TYPE_SGROUP,
3754                         .state          = WREPL_STATE_ACTIVE,
3755                         .node           = WREPL_NODE_B,
3756                         .is_static      = False,
3757                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3758                         .ips            = addresses_B_3_4,
3759                         .apply_expected = False,
3760                         .merge_expected = True
3761                 }
3762         },
3763         {
3764                 .line   = __location__,
3765                 .name   = _NBT_NAME("_DIFF_OWNER_SG", 0x00, NULL),
3766                 .cleanup= True,
3767                 .r1     = {
3768                         .owner          = &ctx->a,
3769                         .type           = WREPL_TYPE_SGROUP,
3770                         .state          = WREPL_STATE_ACTIVE,
3771                         .node           = WREPL_NODE_B,
3772                         .is_static      = False,
3773                         .num_ips        = 0,
3774                         .ips            = NULL,
3775                         .apply_expected = False
3776                 },
3777                 .r2     = {
3778                         .owner          = &ctx->b,
3779                         .type           = WREPL_TYPE_SGROUP,
3780                         .state          = WREPL_STATE_ACTIVE,
3781                         .node           = WREPL_NODE_B,
3782                         .is_static      = False,
3783                         .num_ips        = 0,
3784                         .ips            = NULL,
3785                         .apply_expected = False,
3786                         .merge_expected = False
3787                 }
3788         },
3789         {
3790                 .line   = __location__,
3791                 .name   = _NBT_NAME("_DIFF_OWNER_SG", 0x00, NULL),
3792                 .cleanup= True,
3793                 .r1     = {
3794                         .owner          = &ctx->a,
3795                         .type           = WREPL_TYPE_SGROUP,
3796                         .state          = WREPL_STATE_ACTIVE,
3797                         .node           = WREPL_NODE_B,
3798                         .is_static      = False,
3799                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3800                         .ips            = addresses_A_1,
3801                         .apply_expected = True
3802                 },
3803                 .r2     = {
3804                         .owner          = &ctx->a,
3805                         .type           = WREPL_TYPE_UNIQUE,
3806                         .state          = WREPL_STATE_TOMBSTONE,
3807                         .node           = WREPL_NODE_B,
3808                         .is_static      = False,
3809                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3810                         .ips            = addresses_A_1,
3811                         .apply_expected = True
3812                 }
3813         },
3814 #endif
3815         /* 
3816          * This should be the last record in this array,
3817          * we need to make sure the we leave a tombstoned unique entry
3818          * owned by OWNER_A
3819          */
3820         {
3821                 .line   = __location__,
3822                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3823                 .cleanup= True,
3824                 .r1     = {
3825                         .owner          = &ctx->b,
3826                         .type           = WREPL_TYPE_UNIQUE,
3827                         .state          = WREPL_STATE_TOMBSTONE,
3828                         .node           = WREPL_NODE_B,
3829                         .is_static      = False,
3830                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3831                         .ips            = addresses_A_1,
3832                         .apply_expected = True
3833                 },
3834                 .r2     = {
3835                         .owner          = &ctx->a,
3836                         .type           = WREPL_TYPE_UNIQUE,
3837                         .state          = WREPL_STATE_TOMBSTONE,
3838                         .node           = WREPL_NODE_B,
3839                         .is_static      = False,
3840                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3841                         .ips            = addresses_A_1,
3842                         .apply_expected = True
3843                 }
3844         }}; /* do not add entries here, this should be the last record! */
3845
3846         if (!ctx) return False;
3847
3848         wins_name_r1    = &wins_name1;
3849         wins_name_r2    = &wins_name2;
3850
3851         printf("Test Replica Conflicts with different owners\n");
3852
3853         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
3854         
3855                 if (!records[i].extra && !records[i].cleanup) {
3856                         /* we should test the worst cases */
3857                         if (records[i].r2.apply_expected && records[i].r1.ips==records[i].r2.ips) {
3858                                 printf("(%s) Programmer error, invalid record[%u]: %s\n",
3859                                         __location__, i, records[i].line);
3860                                 return False;
3861                         } else if (!records[i].r2.apply_expected && records[i].r1.ips!=records[i].r2.ips) {
3862                                 printf("(%s) Programmer error, invalid record[%u]: %s\n",
3863                                         __location__, i, records[i].line);
3864                                 return False;
3865                         }
3866                 }
3867
3868                 if (!records[i].cleanup) {
3869                         const char *expected;
3870                         const char *ips;
3871
3872                         if (records[i].r2.merge_expected) {
3873                                 expected = "MERGE";
3874                         } else if (records[i].r2.apply_expected) {
3875                                 expected = "REPLACE";
3876                         } else {
3877                                 expected = "NOT REPLACE";
3878                         }
3879
3880                         if (!records[i].r1.ips && !records[i].r2.ips) {
3881                                 ips = "no";
3882                         } else if (records[i].r1.ips==records[i].r2.ips) {
3883                                 ips = "same";
3884                         } else {
3885                                 ips = "different";
3886                         }
3887
3888                         printf("%s,%s%s vs. %s,%s%s with %s ip(s) => %s\n",
3889                                 wrepl_name_type_string(records[i].r1.type),
3890                                 wrepl_name_state_string(records[i].r1.state),
3891                                 (records[i].r1.is_static?",static":""),
3892                                 wrepl_name_type_string(records[i].r2.type),
3893                                 wrepl_name_state_string(records[i].r2.state),
3894                                 (records[i].r2.is_static?",static":""),
3895                                 ips, expected);
3896                 }
3897
3898                 /*
3899                  * Setup R1
3900                  */
3901                 wins_name_r1->name      = &records[i].name;
3902                 wins_name_r1->flags     = WREPL_NAME_FLAGS(records[i].r1.type,
3903                                                            records[i].r1.state,
3904                                                            records[i].r1.node,
3905                                                            records[i].r1.is_static);
3906                 wins_name_r1->id        = ++records[i].r1.owner->max_version;
3907                 if (wins_name_r1->flags & 2) {
3908                         wins_name_r1->addresses.addresses.num_ips = records[i].r1.num_ips;
3909                         wins_name_r1->addresses.addresses.ips     = discard_const(records[i].r1.ips);
3910                 } else {
3911                         wins_name_r1->addresses.ip = records[i].r1.ips[0].ip;
3912                 }
3913                 wins_name_r1->unknown   = "255.255.255.255";
3914
3915                 /* now apply R1 */
3916                 ret &= test_wrepl_update_one(ctx, records[i].r1.owner, wins_name_r1);
3917                 ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
3918                                              wins_name_r1, records[i].r1.apply_expected);
3919
3920                 /*
3921                  * Setup R2
3922                  */
3923                 wins_name_r2->name      = &records[i].name;
3924                 wins_name_r2->flags     = WREPL_NAME_FLAGS(records[i].r2.type,
3925                                                            records[i].r2.state,
3926                                                            records[i].r2.node,
3927                                                            records[i].r2.is_static);
3928                 wins_name_r2->id        = ++records[i].r2.owner->max_version;
3929                 if (wins_name_r2->flags & 2) {
3930                         wins_name_r2->addresses.addresses.num_ips = records[i].r2.num_ips;
3931                         wins_name_r2->addresses.addresses.ips     = discard_const(records[i].r2.ips);
3932                 } else {
3933                         wins_name_r2->addresses.ip = records[i].r2.ips[0].ip;
3934                 }
3935                 wins_name_r2->unknown   = "255.255.255.255";
3936
3937                 /* now apply R2 */
3938                 ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
3939                 if (records[i].r1.state == WREPL_STATE_RELEASED) {
3940                         ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
3941                                                      wins_name_r1, False);
3942                 } else if (records[i].r2.merge_expected) {
3943                         ret &= test_wrepl_is_merged(ctx, wins_name_r1, wins_name_r2);           
3944                 } else if (records[i].r1.owner != records[i].r2.owner) {
3945                         BOOL _expected;
3946                         _expected = (records[i].r1.apply_expected && !records[i].r2.apply_expected);
3947                         ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
3948                                                      wins_name_r1, _expected);
3949                 }
3950                 if (records[i].r2.state == WREPL_STATE_RELEASED) {
3951                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner,
3952                                                      wins_name_r2, False);
3953                 } else if (!records[i].r2.merge_expected) {
3954                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner,
3955                                                      wins_name_r2, records[i].r2.apply_expected);
3956                 }
3957
3958                 /* the first one is a cleanup run */
3959                 if (!ret && i == 0) ret = True;
3960
3961                 if (!ret) {
3962                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
3963                         return ret;
3964                 }
3965         }
3966
3967         return ret;
3968 }
3969
3970 static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_conn *ctx)
3971 {
3972         BOOL ret = True;
3973         NTSTATUS status;
3974         struct wrepl_wins_name wins_name_;
3975         struct wrepl_wins_name *wins_name = &wins_name_;
3976         struct nbt_name_register name_register_;
3977         struct nbt_name_register *name_register = &name_register_;
3978         struct nbt_name_release release_;
3979         struct nbt_name_release *release = &release_;
3980         uint32_t i;
3981         struct {
3982                 const char *line; /* just better debugging */
3983                 struct nbt_name name;
3984                 struct {
3985                         uint32_t nb_flags;
3986                         BOOL mhomed;
3987                         uint32_t num_ips;
3988                         const struct wrepl_ip *ips;
3989                         BOOL apply_expected;
3990                 } wins;
3991                 struct {
3992                         enum wrepl_name_type type;
3993                         enum wrepl_name_state state;
3994                         enum wrepl_name_node node;
3995                         BOOL is_static;
3996                         uint32_t num_ips;
3997                         const struct wrepl_ip *ips;
3998                         BOOL apply_expected;
3999                 } replica;
4000         } records[] = {
4001 /* 
4002  * unique vs. unique section
4003  */
4004         /*
4005          * unique,released vs. unique,active with same ip(s)
4006          */
4007         {
4008                 .line   = __location__,
4009                 .name   = _NBT_NAME("_UR_UA_SI", 0x00, NULL),
4010                 .wins   = {
4011                         .nb_flags       = 0,
4012                         .mhomed         = False,
4013                         .num_ips        = ctx->addresses_best_num,
4014                         .ips            = ctx->addresses_best,
4015                         .apply_expected = True
4016                 },
4017                 .replica= {
4018                         .type           = WREPL_TYPE_UNIQUE,
4019                         .state          = WREPL_STATE_ACTIVE,
4020                         .node           = WREPL_NODE_B,
4021                         .is_static      = False,
4022                         .num_ips        = ctx->addresses_best_num,
4023                         .ips            = ctx->addresses_best,
4024                         .apply_expected = True
4025                 },
4026         },
4027         /*
4028          * unique,released vs. unique,active with different ip(s)
4029          */
4030         {
4031                 .line   = __location__,
4032                 .name   = _NBT_NAME("_UR_UA_DI", 0x00, NULL),
4033                 .wins   = {
4034                         .nb_flags       = 0,
4035                         .mhomed         = False,
4036                         .num_ips        = ctx->addresses_best_num,
4037                         .ips            = ctx->addresses_best,
4038                         .apply_expected = True
4039                 },
4040                 .replica= {
4041                         .type           = WREPL_TYPE_UNIQUE,
4042                         .state          = WREPL_STATE_ACTIVE,
4043                         .node           = WREPL_NODE_B,
4044                         .is_static      = False,
4045                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4046                         .ips            = addresses_B_1,
4047                         .apply_expected = True
4048                 },
4049         },
4050         /*
4051          * unique,released vs. unique,tombstone with same ip(s)
4052          */
4053         {
4054                 .line   = __location__,
4055                 .name   = _NBT_NAME("_UR_UT_SI", 0x00, NULL),
4056                 .wins   = {
4057                         .nb_flags       = 0,
4058                         .mhomed         = False,
4059                         .num_ips        = ctx->addresses_best_num,
4060                         .ips            = ctx->addresses_best,
4061                         .apply_expected = True
4062                 },
4063                 .replica= {
4064                         .type           = WREPL_TYPE_UNIQUE,
4065                         .state          = WREPL_STATE_TOMBSTONE,
4066                         .node           = WREPL_NODE_B,
4067                         .is_static      = False,
4068                         .num_ips        = ctx->addresses_best_num,
4069                         .ips            = ctx->addresses_best,
4070                         .apply_expected = True
4071                 },
4072         },
4073         /*
4074          * unique,released vs. unique,tombstone with different ip(s)
4075          */
4076         {
4077                 .line   = __location__,
4078                 .name   = _NBT_NAME("_UR_UT_DI", 0x00, NULL),
4079                 .wins   = {
4080                         .nb_flags       = 0,
4081                         .mhomed         = False,
4082                         .num_ips        = ctx->addresses_best_num,
4083                         .ips            = ctx->addresses_best,
4084                         .apply_expected = True
4085                 },
4086                 .replica= {
4087                         .type           = WREPL_TYPE_UNIQUE,
4088                         .state          = WREPL_STATE_TOMBSTONE,
4089                         .node           = WREPL_NODE_B,
4090                         .is_static      = False,
4091                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4092                         .ips            = addresses_B_1,
4093                         .apply_expected = True
4094                 },
4095         },
4096 /* 
4097  * unique vs. group section
4098  */
4099         /*
4100          * unique,released vs. group,active with same ip(s)
4101          */
4102         {
4103                 .line   = __location__,
4104                 .name   = _NBT_NAME("_UR_GA_SI", 0x00, NULL),
4105                 .wins   = {
4106                         .nb_flags       = 0,
4107                         .mhomed         = False,
4108                         .num_ips        = ctx->addresses_best_num,
4109                         .ips            = ctx->addresses_best,
4110                         .apply_expected = True
4111                 },
4112                 .replica= {
4113                         .type           = WREPL_TYPE_GROUP,
4114                         .state          = WREPL_STATE_ACTIVE,
4115                         .node           = WREPL_NODE_B,
4116                         .is_static      = False,
4117                         .num_ips        = ctx->addresses_best_num,
4118                         .ips            = ctx->addresses_best,
4119                         .apply_expected = True
4120                 },
4121         },
4122         /*
4123          * unique,released vs. group,active with different ip(s)
4124          */
4125         {
4126                 .line   = __location__,
4127                 .name   = _NBT_NAME("_UR_GA_DI", 0x00, NULL),
4128                 .wins   = {
4129                         .nb_flags       = 0,
4130                         .mhomed         = False,
4131                         .num_ips        = ctx->addresses_best_num,
4132                         .ips            = ctx->addresses_best,
4133                         .apply_expected = True
4134                 },
4135                 .replica= {
4136                         .type           = WREPL_TYPE_GROUP,
4137                         .state          = WREPL_STATE_ACTIVE,
4138                         .node           = WREPL_NODE_B,
4139                         .is_static      = False,
4140                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4141                         .ips            = addresses_B_1,
4142                         .apply_expected = True
4143                 },
4144         },
4145         /*
4146          * unique,released vs. group,tombstone with same ip(s)
4147          */
4148         {
4149                 .line   = __location__,
4150                 .name   = _NBT_NAME("_UR_GT_SI", 0x00, NULL),
4151                 .wins   = {
4152                         .nb_flags       = 0,
4153                         .mhomed         = False,
4154                         .num_ips        = ctx->addresses_best_num,
4155                         .ips            = ctx->addresses_best,
4156                         .apply_expected = True
4157                 },
4158                 .replica= {
4159                         .type           = WREPL_TYPE_GROUP,
4160                         .state          = WREPL_STATE_TOMBSTONE,
4161                         .node           = WREPL_NODE_B,
4162                         .is_static      = False,
4163                         .num_ips        = ctx->addresses_best_num,
4164                         .ips            = ctx->addresses_best,
4165                         .apply_expected = True
4166                 },
4167         },
4168         /*
4169          * unique,released vs. group,tombstone with different ip(s)
4170          */
4171         {
4172                 .line   = __location__,
4173                 .name   = _NBT_NAME("_UR_GT_DI", 0x00, NULL),
4174                 .wins   = {
4175                         .nb_flags       = 0,
4176                         .mhomed         = False,
4177                         .num_ips        = ctx->addresses_best_num,
4178                         .ips            = ctx->addresses_best,
4179                         .apply_expected = True
4180                 },
4181                 .replica= {
4182                         .type           = WREPL_TYPE_GROUP,
4183                         .state          = WREPL_STATE_TOMBSTONE,
4184                         .node           = WREPL_NODE_B,
4185                         .is_static      = False,
4186                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4187                         .ips            = addresses_B_1,
4188                         .apply_expected = True
4189                 },
4190         },
4191 /* 
4192  * unique vs. special group section
4193  */
4194         /*
4195          * unique,released vs. sgroup,active with same ip(s)
4196          */
4197         {
4198                 .line   = __location__,
4199                 .name   = _NBT_NAME("_UR_SA_SI", 0x00, NULL),
4200                 .wins   = {
4201                         .nb_flags       = 0,
4202                         .mhomed         = False,
4203                         .num_ips        = ctx->addresses_best_num,
4204                         .ips            = ctx->addresses_best,
4205                         .apply_expected = True
4206                 },
4207                 .replica= {
4208                         .type           = WREPL_TYPE_SGROUP,
4209                         .state          = WREPL_STATE_ACTIVE,
4210                         .node           = WREPL_NODE_B,
4211                         .is_static      = False,
4212                         .num_ips        = ctx->addresses_best_num,
4213                         .ips            = ctx->addresses_best,
4214                         .apply_expected = True
4215                 },
4216         },
4217         /*
4218          * unique,released vs. sgroup,active with different ip(s)
4219          */
4220         {
4221                 .line   = __location__,
4222                 .name   = _NBT_NAME("_UR_SA_DI", 0x00, NULL),
4223                 .wins   = {
4224                         .nb_flags       = 0,
4225                         .mhomed         = False,
4226                         .num_ips        = ctx->addresses_best_num,
4227                         .ips            = ctx->addresses_best,
4228                         .apply_expected = True
4229                 },
4230                 .replica= {
4231                         .type           = WREPL_TYPE_SGROUP,
4232                         .state          = WREPL_STATE_ACTIVE,
4233                         .node           = WREPL_NODE_B,
4234                         .is_static      = False,
4235                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4236                         .ips            = addresses_B_1,
4237                         .apply_expected = True
4238                 },
4239         },
4240         /*
4241          * unique,released vs. sgroup,tombstone with same ip(s)
4242          */
4243         {
4244                 .line   = __location__,
4245                 .name   = _NBT_NAME("_UR_ST_SI", 0x00, NULL),
4246                 .wins   = {
4247                         .nb_flags       = 0,
4248                         .mhomed         = False,
4249                         .num_ips        = ctx->addresses_best_num,
4250                         .ips            = ctx->addresses_best,
4251                         .apply_expected = True
4252                 },
4253                 .replica= {
4254                         .type           = WREPL_TYPE_SGROUP,
4255                         .state          = WREPL_STATE_TOMBSTONE,
4256                         .node           = WREPL_NODE_B,
4257                         .is_static      = False,
4258                         .num_ips        = ctx->addresses_best_num,
4259                         .ips            = ctx->addresses_best,
4260                         .apply_expected = True
4261                 },
4262         },
4263         /*
4264          * unique,released vs. sgroup,tombstone with different ip(s)
4265          */
4266         {
4267                 .line   = __location__,
4268                 .name   = _NBT_NAME("_UR_ST_DI", 0x00, NULL),
4269                 .wins   = {
4270                         .nb_flags       = 0,
4271                         .mhomed         = False,
4272                         .num_ips        = ctx->addresses_best_num,
4273                         .ips            = ctx->addresses_best,
4274                         .apply_expected = True
4275                 },
4276                 .replica= {
4277                         .type           = WREPL_TYPE_SGROUP,
4278                         .state          = WREPL_STATE_TOMBSTONE,
4279                         .node           = WREPL_NODE_B,
4280                         .is_static      = False,
4281                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4282                         .ips            = addresses_B_1,
4283                         .apply_expected = True
4284                 },
4285         },
4286 /* 
4287  * unique vs. multi homed section
4288  */
4289         /*
4290          * unique,released vs. mhomed,active with same ip(s)
4291          */
4292         {
4293                 .line   = __location__,
4294                 .name   = _NBT_NAME("_UR_MA_SI", 0x00, NULL),
4295                 .wins   = {
4296                         .nb_flags       = 0,
4297                         .mhomed         = False,
4298                         .num_ips        = ctx->addresses_best_num,
4299                         .ips            = ctx->addresses_best,
4300                         .apply_expected = True
4301                 },
4302                 .replica= {
4303                         .type           = WREPL_TYPE_MHOMED,
4304                         .state          = WREPL_STATE_ACTIVE,
4305                         .node           = WREPL_NODE_B,
4306                         .is_static      = False,
4307                         .num_ips        = ctx->addresses_best_num,
4308                         .ips            = ctx->addresses_best,
4309                         .apply_expected = True
4310                 },
4311         },
4312         /*
4313          * unique,released vs. mhomed,active with different ip(s)
4314          */
4315         {
4316                 .line   = __location__,
4317                 .name   = _NBT_NAME("_UR_MA_DI", 0x00, NULL),
4318                 .wins   = {
4319                         .nb_flags       = 0,
4320                         .mhomed         = False,
4321                         .num_ips        = ctx->addresses_best_num,
4322                         .ips            = ctx->addresses_best,
4323                         .apply_expected = True
4324                 },
4325                 .replica= {
4326                         .type           = WREPL_TYPE_MHOMED,
4327                         .state          = WREPL_STATE_ACTIVE,
4328                         .node           = WREPL_NODE_B,
4329                         .is_static      = False,
4330                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4331                         .ips            = addresses_B_1,
4332                         .apply_expected = True
4333                 },
4334         },
4335         /*
4336          * unique,released vs. mhomed,tombstone with same ip(s)
4337          */
4338         {
4339                 .line   = __location__,
4340                 .name   = _NBT_NAME("_UR_MT_SI", 0x00, NULL),
4341                 .wins   = {
4342                         .nb_flags       = 0,
4343                         .mhomed         = False,
4344                         .num_ips        = ctx->addresses_best_num,
4345                         .ips            = ctx->addresses_best,
4346                         .apply_expected = True
4347                 },
4348                 .replica= {
4349                         .type           = WREPL_TYPE_MHOMED,
4350                         .state          = WREPL_STATE_TOMBSTONE,
4351                         .node           = WREPL_NODE_B,
4352                         .is_static      = False,
4353                         .num_ips        = ctx->addresses_best_num,
4354                         .ips            = ctx->addresses_best,
4355                         .apply_expected = True
4356                 },
4357         },
4358         /*
4359          * unique,released vs. mhomed,tombstone with different ip(s)
4360          */
4361         {
4362                 .line   = __location__,
4363                 .name   = _NBT_NAME("_UR_MT_DI", 0x00, NULL),
4364                 .wins   = {
4365                         .nb_flags       = 0,
4366                         .mhomed         = False,
4367                         .num_ips        = ctx->addresses_best_num,
4368                         .ips            = ctx->addresses_best,
4369                         .apply_expected = True
4370                 },
4371                 .replica= {
4372                         .type           = WREPL_TYPE_MHOMED,
4373                         .state          = WREPL_STATE_TOMBSTONE,
4374                         .node           = WREPL_NODE_B,
4375                         .is_static      = False,
4376                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4377                         .ips            = addresses_B_1,
4378                         .apply_expected = True
4379                 },
4380         },
4381 /* 
4382  * group vs. unique section
4383  */
4384         /*
4385          * group,released vs. unique,active with same ip(s)
4386          */
4387         {
4388                 .line   = __location__,
4389                 .name   = _NBT_NAME("_GR_UA_SI", 0x00, NULL),
4390                 .wins   = {
4391                         .nb_flags       = NBT_NM_GROUP,
4392                         .mhomed         = False,
4393                         .num_ips        = ctx->addresses_best_num,
4394                         .ips            = ctx->addresses_best,
4395                         .apply_expected = True
4396                 },
4397                 .replica= {
4398                         .type           = WREPL_TYPE_UNIQUE,
4399                         .state          = WREPL_STATE_ACTIVE,
4400                         .node           = WREPL_NODE_B,
4401                         .is_static      = False,
4402                         .num_ips        = ctx->addresses_best_num,
4403                         .ips            = ctx->addresses_best,
4404                         .apply_expected = False
4405                 },
4406         },
4407         /*
4408          * group,released vs. unique,active with different ip(s)
4409          */
4410         {
4411                 .line   = __location__,
4412                 .name   = _NBT_NAME("_GR_UA_DI", 0x00, NULL),
4413                 .wins   = {
4414                         .nb_flags       = NBT_NM_GROUP,
4415                         .mhomed         = False,
4416                         .num_ips        = ctx->addresses_best_num,
4417                         .ips            = ctx->addresses_best,
4418                         .apply_expected = True
4419                 },
4420                 .replica= {
4421                         .type           = WREPL_TYPE_UNIQUE,
4422                         .state          = WREPL_STATE_ACTIVE,
4423                         .node           = WREPL_NODE_B,
4424                         .is_static      = False,
4425                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4426                         .ips            = addresses_B_1,
4427                         .apply_expected = False
4428                 },
4429         },
4430         /*
4431          * group,released vs. unique,tombstone with same ip(s)
4432          */
4433         {
4434                 .line   = __location__,
4435                 .name   = _NBT_NAME("_GR_UT_SI", 0x00, NULL),
4436                 .wins   = {
4437                         .nb_flags       = NBT_NM_GROUP,
4438                         .mhomed         = False,
4439                         .num_ips        = ctx->addresses_best_num,
4440                         .ips            = ctx->addresses_best,
4441                         .apply_expected = True
4442                 },
4443                 .replica= {
4444                         .type           = WREPL_TYPE_UNIQUE,
4445                         .state          = WREPL_STATE_TOMBSTONE,
4446                         .node           = WREPL_NODE_B,
4447                         .is_static      = False,
4448                         .num_ips        = ctx->addresses_best_num,
4449                         .ips            = ctx->addresses_best,
4450                         .apply_expected = False
4451                 },
4452         },
4453         /*
4454          * group,released vs. unique,tombstone with different ip(s)
4455          */
4456         {
4457                 .line   = __location__,
4458                 .name   = _NBT_NAME("_GR_UT_DI", 0x00, NULL),
4459                 .wins   = {
4460                         .nb_flags       = NBT_NM_GROUP,
4461                         .mhomed         = False,
4462                         .num_ips        = ctx->addresses_best_num,
4463                         .ips            = ctx->addresses_best,
4464                         .apply_expected = True
4465                 },
4466                 .replica= {
4467                         .type           = WREPL_TYPE_UNIQUE,
4468                         .state          = WREPL_STATE_TOMBSTONE,
4469                         .node           = WREPL_NODE_B,
4470                         .is_static      = False,
4471                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4472                         .ips            = addresses_B_1,
4473                         .apply_expected = False
4474                 },
4475         },
4476 /* 
4477  * group vs. group section
4478  */
4479         /*
4480          * group,released vs. group,active with same ip(s)
4481          */
4482         {
4483                 .line   = __location__,
4484                 .name   = _NBT_NAME("_GR_GA_SI", 0x00, NULL),
4485                 .wins   = {
4486                         .nb_flags       = NBT_NM_GROUP,
4487                         .mhomed         = False,
4488                         .num_ips        = ctx->addresses_best_num,
4489                         .ips            = ctx->addresses_best,
4490                         .apply_expected = True
4491                 },
4492                 .replica= {
4493                         .type           = WREPL_TYPE_GROUP,
4494                         .state          = WREPL_STATE_ACTIVE,
4495                         .node           = WREPL_NODE_B,
4496                         .is_static      = False,
4497                         .num_ips        = ctx->addresses_best_num,
4498                         .ips            = ctx->addresses_best,
4499                         .apply_expected = True
4500                 },
4501         },
4502         /*
4503          * group,released vs. group,active with different ip(s)
4504          */
4505         {
4506                 .line   = __location__,
4507                 .name   = _NBT_NAME("_GR_GA_DI", 0x00, NULL),
4508                 .wins   = {
4509                         .nb_flags       = NBT_NM_GROUP,
4510                         .mhomed         = False,
4511                         .num_ips        = ctx->addresses_best_num,
4512                         .ips            = ctx->addresses_best,
4513                         .apply_expected = True
4514                 },
4515                 .replica= {
4516                         .type           = WREPL_TYPE_GROUP,
4517                         .state          = WREPL_STATE_ACTIVE,
4518                         .node           = WREPL_NODE_B,
4519                         .is_static      = False,
4520                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4521                         .ips            = addresses_B_1,
4522                         .apply_expected = True
4523                 },
4524         },
4525         /*
4526          * group,released vs. group,tombstone with same ip(s)
4527          */
4528         {
4529                 .line   = __location__,
4530                 .name   = _NBT_NAME("_GR_GT_SI", 0x00, NULL),
4531                 .wins   = {
4532                         .nb_flags       = NBT_NM_GROUP,
4533                         .mhomed         = False,
4534                         .num_ips        = ctx->addresses_best_num,
4535                         .ips            = ctx->addresses_best,
4536                         .apply_expected = True
4537                 },
4538                 .replica= {
4539                         .type           = WREPL_TYPE_GROUP,
4540                         .state          = WREPL_STATE_TOMBSTONE,
4541                         .node           = WREPL_NODE_B,
4542                         .is_static      = False,
4543                         .num_ips        = ctx->addresses_best_num,
4544                         .ips            = ctx->addresses_best,
4545                         .apply_expected = True
4546                 },
4547         },
4548         /*
4549          * group,released vs. group,tombstone with different ip(s)
4550          */
4551         {
4552                 .line   = __location__,
4553                 .name   = _NBT_NAME("_GR_GT_DI", 0x00, NULL),
4554                 .wins   = {
4555                         .nb_flags       = NBT_NM_GROUP,
4556                         .mhomed         = False,
4557                         .num_ips        = ctx->addresses_best_num,
4558                         .ips            = ctx->addresses_best,
4559                         .apply_expected = True
4560                 },
4561                 .replica= {
4562                         .type           = WREPL_TYPE_GROUP,
4563                         .state          = WREPL_STATE_TOMBSTONE,
4564                         .node           = WREPL_NODE_B,
4565                         .is_static      = False,
4566                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4567                         .ips            = addresses_B_1,
4568                         .apply_expected = True
4569                 },
4570         },
4571 /* 
4572  * group vs. special group section
4573  */
4574         /*
4575          * group,released vs. sgroup,active with same ip(s)
4576          */
4577         {
4578                 .line   = __location__,
4579                 .name   = _NBT_NAME("_GR_SA_SI", 0x00, NULL),
4580                 .wins   = {
4581                         .nb_flags       = NBT_NM_GROUP,
4582                         .mhomed         = False,
4583                         .num_ips        = ctx->addresses_best_num,
4584                         .ips            = ctx->addresses_best,
4585                         .apply_expected = True
4586                 },
4587                 .replica= {
4588                         .type           = WREPL_TYPE_SGROUP,
4589                         .state          = WREPL_STATE_ACTIVE,
4590                         .node           = WREPL_NODE_B,
4591                         .is_static      = False,
4592                         .num_ips        = ctx->addresses_best_num,
4593                         .ips            = ctx->addresses_best,
4594                         .apply_expected = False
4595                 },
4596         },
4597         /*
4598          * group,released vs. sgroup,active with different ip(s)
4599          */
4600         {
4601                 .line   = __location__,
4602                 .name   = _NBT_NAME("_GR_SA_DI", 0x00, NULL),
4603                 .wins   = {
4604                         .nb_flags       = NBT_NM_GROUP,
4605                         .mhomed         = False,
4606                         .num_ips        = ctx->addresses_best_num,
4607                         .ips            = ctx->addresses_best,
4608                         .apply_expected = True
4609                 },
4610                 .replica= {
4611                         .type           = WREPL_TYPE_SGROUP,
4612                         .state          = WREPL_STATE_ACTIVE,
4613                         .node           = WREPL_NODE_B,
4614                         .is_static      = False,
4615                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4616                         .ips            = addresses_B_1,
4617                         .apply_expected = False
4618                 },
4619         },
4620         /*
4621          * group,released vs. sgroup,tombstone with same ip(s)
4622          */
4623         {
4624                 .line   = __location__,
4625                 .name   = _NBT_NAME("_GR_ST_SI", 0x00, NULL),
4626                 .wins   = {
4627                         .nb_flags       = NBT_NM_GROUP,
4628                         .mhomed         = False,
4629                         .num_ips        = ctx->addresses_best_num,
4630                         .ips            = ctx->addresses_best,
4631                         .apply_expected = True
4632                 },
4633                 .replica= {
4634                         .type           = WREPL_TYPE_SGROUP,
4635                         .state          = WREPL_STATE_TOMBSTONE,
4636                         .node           = WREPL_NODE_B,
4637                         .is_static      = False,
4638                         .num_ips        = ctx->addresses_best_num,
4639                         .ips            = ctx->addresses_best,
4640                         .apply_expected = False
4641                 },
4642         },
4643         /*
4644          * group,released vs. sgroup,tombstone with different ip(s)
4645          */
4646         {
4647                 .line   = __location__,
4648                 .name   = _NBT_NAME("_GR_ST_DI", 0x00, NULL),
4649                 .wins   = {
4650                         .nb_flags       = NBT_NM_GROUP,
4651                         .mhomed         = False,
4652                         .num_ips        = ctx->addresses_best_num,
4653                         .ips            = ctx->addresses_best,
4654                         .apply_expected = True
4655                 },
4656                 .replica= {
4657                         .type           = WREPL_TYPE_SGROUP,
4658                         .state          = WREPL_STATE_TOMBSTONE,
4659                         .node           = WREPL_NODE_B,
4660                         .is_static      = False,
4661                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4662                         .ips            = addresses_B_1,
4663                         .apply_expected = False
4664                 },
4665         },
4666 /* 
4667  * group vs. multi homed section
4668  */
4669         /*
4670          * group,released vs. mhomed,active with same ip(s)
4671          */
4672         {
4673                 .line   = __location__,
4674                 .name   = _NBT_NAME("_GR_MA_SI", 0x00, NULL),
4675                 .wins   = {
4676                         .nb_flags       = NBT_NM_GROUP,
4677                         .mhomed         = False,
4678                         .num_ips        = ctx->addresses_best_num,
4679                         .ips            = ctx->addresses_best,
4680                         .apply_expected = True
4681                 },
4682                 .replica= {
4683                         .type           = WREPL_TYPE_MHOMED,
4684                         .state          = WREPL_STATE_ACTIVE,
4685                         .node           = WREPL_NODE_B,
4686                         .is_static      = False,
4687                         .num_ips        = ctx->addresses_best_num,
4688                         .ips            = ctx->addresses_best,
4689                         .apply_expected = False
4690                 },
4691         },
4692         /*
4693          * group,released vs. mhomed,active with different ip(s)
4694          */
4695         {
4696                 .line   = __location__,
4697                 .name   = _NBT_NAME("_GR_MA_DI", 0x00, NULL),
4698                 .wins   = {
4699                         .nb_flags       = NBT_NM_GROUP,
4700                         .mhomed         = False,
4701                         .num_ips        = ctx->addresses_best_num,
4702                         .ips            = ctx->addresses_best,
4703                         .apply_expected = True
4704                 },
4705                 .replica= {
4706                         .type           = WREPL_TYPE_MHOMED,
4707                         .state          = WREPL_STATE_ACTIVE,
4708                         .node           = WREPL_NODE_B,
4709                         .is_static      = False,
4710                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4711                         .ips            = addresses_B_1,
4712                         .apply_expected = False
4713                 },
4714         },
4715         /*
4716          * group,released vs. mhomed,tombstone with same ip(s)
4717          */
4718         {
4719                 .line   = __location__,
4720                 .name   = _NBT_NAME("_GR_MT_SI", 0x00, NULL),
4721                 .wins   = {
4722                         .nb_flags       = NBT_NM_GROUP,
4723                         .mhomed         = False,
4724                         .num_ips        = ctx->addresses_best_num,
4725                         .ips            = ctx->addresses_best,
4726                         .apply_expected = True
4727                 },
4728                 .replica= {
4729                         .type           = WREPL_TYPE_MHOMED,
4730                         .state          = WREPL_STATE_TOMBSTONE,
4731                         .node           = WREPL_NODE_B,
4732                         .is_static      = False,
4733                         .num_ips        = ctx->addresses_best_num,
4734                         .ips            = ctx->addresses_best,
4735                         .apply_expected = False
4736                 },
4737         },
4738         /*
4739          * group,released vs. mhomed,tombstone with different ip(s)
4740          */
4741         {
4742                 .line   = __location__,
4743                 .name   = _NBT_NAME("_GR_MT_DI", 0x00, NULL),
4744                 .wins   = {
4745                         .nb_flags       = NBT_NM_GROUP,
4746                         .mhomed         = False,
4747                         .num_ips        = ctx->addresses_best_num,
4748                         .ips            = ctx->addresses_best,
4749                         .apply_expected = True
4750                 },
4751                 .replica= {
4752                         .type           = WREPL_TYPE_MHOMED,
4753                         .state          = WREPL_STATE_TOMBSTONE,
4754                         .node           = WREPL_NODE_B,
4755                         .is_static      = False,
4756                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4757                         .ips            = addresses_B_1,
4758                         .apply_expected = False
4759                 },
4760         },
4761 /* 
4762  * special group vs. unique section
4763  */
4764         /*
4765          * sgroup,released vs. unique,active with same ip(s)
4766          */
4767         {
4768                 .line   = __location__,
4769                 .name   = _NBT_NAME("_SR_UA_SI", 0x1C, NULL),
4770                 .wins   = {
4771                         .nb_flags       = NBT_NM_GROUP,
4772                         .mhomed         = False,
4773                         .num_ips        = ctx->addresses_best_num,
4774                         .ips            = ctx->addresses_best,
4775                         .apply_expected = True
4776                 },
4777                 .replica= {
4778                         .type           = WREPL_TYPE_UNIQUE,
4779                         .state          = WREPL_STATE_ACTIVE,
4780                         .node           = WREPL_NODE_B,
4781                         .is_static      = False,
4782                         .num_ips        = ctx->addresses_best_num,
4783                         .ips            = ctx->addresses_best,
4784                         .apply_expected = True
4785                 },
4786         },
4787         /*
4788          * sgroup,released vs. unique,active with different ip(s)
4789          */
4790         {
4791                 .line   = __location__,
4792                 .name   = _NBT_NAME("_SR_UA_DI", 0x1C, NULL),
4793                 .wins   = {
4794                         .nb_flags       = NBT_NM_GROUP,
4795                         .mhomed         = False,
4796                         .num_ips        = ctx->addresses_best_num,
4797                         .ips            = ctx->addresses_best,
4798                         .apply_expected = True
4799                 },
4800                 .replica= {
4801                         .type           = WREPL_TYPE_UNIQUE,
4802                         .state          = WREPL_STATE_ACTIVE,
4803                         .node           = WREPL_NODE_B,
4804                         .is_static      = False,
4805                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4806                         .ips            = addresses_B_1,
4807                         .apply_expected = True
4808                 },
4809         },
4810         /*
4811          * sgroup,released vs. unique,tombstone with same ip(s)
4812          */
4813         {
4814                 .line   = __location__,
4815                 .name   = _NBT_NAME("_SR_UT_SI", 0x1C, NULL),
4816                 .wins   = {
4817                         .nb_flags       = NBT_NM_GROUP,
4818                         .mhomed         = False,
4819                         .num_ips        = ctx->addresses_best_num,
4820                         .ips            = ctx->addresses_best,
4821                         .apply_expected = True
4822                 },
4823                 .replica= {
4824                         .type           = WREPL_TYPE_UNIQUE,
4825                         .state          = WREPL_STATE_TOMBSTONE,
4826                         .node           = WREPL_NODE_B,
4827                         .is_static      = False,
4828                         .num_ips        = ctx->addresses_best_num,
4829                         .ips            = ctx->addresses_best,
4830                         .apply_expected = True
4831                 },
4832         },
4833         /*
4834          * sgroup,released vs. unique,tombstone with different ip(s)
4835          */
4836         {
4837                 .line   = __location__,
4838                 .name   = _NBT_NAME("_SR_UT_DI", 0x1C, NULL),
4839                 .wins   = {
4840                         .nb_flags       = NBT_NM_GROUP,
4841                         .mhomed         = False,
4842                         .num_ips        = ctx->addresses_best_num,
4843                         .ips            = ctx->addresses_best,
4844                         .apply_expected = True
4845                 },
4846                 .replica= {
4847                         .type           = WREPL_TYPE_UNIQUE,
4848                         .state          = WREPL_STATE_TOMBSTONE,
4849                         .node           = WREPL_NODE_B,
4850                         .is_static      = False,
4851                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4852                         .ips            = addresses_B_1,
4853                         .apply_expected = True
4854                 },
4855         },
4856 /* 
4857  * special group vs. group section
4858  */
4859         /*
4860          * sgroup,released vs. group,active with same ip(s)
4861          */
4862         {
4863                 .line   = __location__,
4864                 .name   = _NBT_NAME("_SR_GA_SI", 0x1C, NULL),
4865                 .wins   = {
4866                         .nb_flags       = NBT_NM_GROUP,
4867                         .mhomed         = False,
4868                         .num_ips        = ctx->addresses_best_num,
4869                         .ips            = ctx->addresses_best,
4870                         .apply_expected = True
4871                 },
4872                 .replica= {
4873                         .type           = WREPL_TYPE_GROUP,
4874                         .state          = WREPL_STATE_ACTIVE,
4875                         .node           = WREPL_NODE_B,
4876                         .is_static      = False,
4877                         .num_ips        = ctx->addresses_best_num,
4878                         .ips            = ctx->addresses_best,
4879                         .apply_expected = True
4880                 },
4881         },
4882         /*
4883          * sgroup,released vs. group,active with different ip(s)
4884          */
4885         {
4886                 .line   = __location__,
4887                 .name   = _NBT_NAME("_SR_GA_DI", 0x1C, NULL),
4888                 .wins   = {
4889                         .nb_flags       = NBT_NM_GROUP,
4890                         .mhomed         = False,
4891                         .num_ips        = ctx->addresses_best_num,
4892                         .ips            = ctx->addresses_best,
4893                         .apply_expected = True
4894                 },
4895                 .replica= {
4896                         .type           = WREPL_TYPE_GROUP,
4897                         .state          = WREPL_STATE_ACTIVE,
4898                         .node           = WREPL_NODE_B,
4899                         .is_static      = False,
4900                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4901                         .ips            = addresses_B_1,
4902                         .apply_expected = True
4903                 },
4904         },
4905         /*
4906          * sgroup,released vs. group,tombstone with same ip(s)
4907          */
4908         {
4909                 .line   = __location__,
4910                 .name   = _NBT_NAME("_SR_GT_SI", 0x1C, NULL),
4911                 .wins   = {
4912                         .nb_flags       = NBT_NM_GROUP,
4913                         .mhomed         = False,
4914                         .num_ips        = ctx->addresses_best_num,
4915                         .ips            = ctx->addresses_best,
4916                         .apply_expected = True
4917                 },
4918                 .replica= {
4919                         .type           = WREPL_TYPE_GROUP,
4920                         .state          = WREPL_STATE_TOMBSTONE,
4921                         .node           = WREPL_NODE_B,
4922                         .is_static      = False,
4923                         .num_ips        = ctx->addresses_best_num,
4924                         .ips            = ctx->addresses_best,
4925                         .apply_expected = True
4926                 },
4927         },
4928         /*
4929          * sgroup,released vs. group,tombstone with different ip(s)
4930          */
4931         {
4932                 .line   = __location__,
4933                 .name   = _NBT_NAME("_SR_GT_DI", 0x1C, NULL),
4934                 .wins   = {
4935                         .nb_flags       = NBT_NM_GROUP,
4936                         .mhomed         = False,
4937                         .num_ips        = ctx->addresses_best_num,
4938                         .ips            = ctx->addresses_best,
4939                         .apply_expected = True
4940                 },
4941                 .replica= {
4942                         .type           = WREPL_TYPE_GROUP,
4943                         .state          = WREPL_STATE_TOMBSTONE,
4944                         .node           = WREPL_NODE_B,
4945                         .is_static      = False,
4946                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4947                         .ips            = addresses_B_1,
4948                         .apply_expected = True
4949                 },
4950         },
4951 /* 
4952  * special group vs. special group section
4953  */
4954         /*
4955          * sgroup,released vs. sgroup,active with same ip(s)
4956          */
4957         {
4958                 .line   = __location__,
4959                 .name   = _NBT_NAME("_SR_SA_SI", 0x1C, NULL),
4960                 .wins   = {
4961                         .nb_flags       = NBT_NM_GROUP,
4962                         .mhomed         = False,
4963                         .num_ips        = ctx->addresses_best_num,
4964                         .ips            = ctx->addresses_best,
4965                         .apply_expected = True
4966                 },
4967                 .replica= {
4968                         .type           = WREPL_TYPE_SGROUP,
4969                         .state          = WREPL_STATE_ACTIVE,
4970                         .node           = WREPL_NODE_B,
4971                         .is_static      = False,
4972                         .num_ips        = ctx->addresses_best_num,
4973                         .ips            = ctx->addresses_best,
4974                         .apply_expected = True
4975                 },
4976         },
4977         /*
4978          * sgroup,released vs. sgroup,active with different ip(s)
4979          */
4980         {
4981                 .line   = __location__,
4982                 .name   = _NBT_NAME("_SR_SA_DI", 0x1C, NULL),
4983                 .wins   = {
4984                         .nb_flags       = NBT_NM_GROUP,
4985                         .mhomed         = False,
4986                         .num_ips        = ctx->addresses_best_num,
4987                         .ips            = ctx->addresses_best,
4988                         .apply_expected = True
4989                 },
4990                 .replica= {
4991                         .type           = WREPL_TYPE_SGROUP,
4992                         .state          = WREPL_STATE_ACTIVE,
4993                         .node           = WREPL_NODE_B,
4994                         .is_static      = False,
4995                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4996                         .ips            = addresses_B_1,
4997                         .apply_expected = True
4998                 },
4999         },
5000         /*
5001          * sgroup,released vs. sgroup,tombstone with same ip(s)
5002          */
5003         {
5004                 .line   = __location__,
5005                 .name   = _NBT_NAME("_SR_ST_SI", 0x1C, NULL),
5006                 .wins   = {
5007                         .nb_flags       = NBT_NM_GROUP,
5008                         .mhomed         = False,
5009                         .num_ips        = ctx->addresses_best_num,
5010                         .ips            = ctx->addresses_best,
5011                         .apply_expected = True
5012                 },
5013                 .replica= {
5014                         .type           = WREPL_TYPE_SGROUP,
5015                         .state          = WREPL_STATE_TOMBSTONE,
5016                         .node           = WREPL_NODE_B,
5017                         .is_static      = False,
5018                         .num_ips        = ctx->addresses_best_num,
5019                         .ips            = ctx->addresses_best,
5020                         .apply_expected = True
5021                 },
5022         },
5023         /*
5024          * sgroup,released vs. sgroup,tombstone with different ip(s)
5025          */
5026         {
5027                 .line   = __location__,
5028                 .name   = _NBT_NAME("_SR_ST_DI", 0x1C, NULL),
5029                 .wins   = {
5030                         .nb_flags       = NBT_NM_GROUP,
5031                         .mhomed         = False,
5032                         .num_ips        = ctx->addresses_best_num,
5033                         .ips            = ctx->addresses_best,
5034                         .apply_expected = True
5035                 },
5036                 .replica= {
5037                         .type           = WREPL_TYPE_SGROUP,
5038                         .state          = WREPL_STATE_TOMBSTONE,
5039                         .node           = WREPL_NODE_B,
5040                         .is_static      = False,
5041                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5042                         .ips            = addresses_B_1,
5043                         .apply_expected = True
5044                 },
5045         },
5046 /* 
5047  * special group vs. multi homed section
5048  */
5049         /*
5050          * sgroup,released vs. mhomed,active with same ip(s)
5051          */
5052         {
5053                 .line   = __location__,
5054                 .name   = _NBT_NAME("_SR_MA_SI", 0x1C, NULL),
5055                 .wins   = {
5056                         .nb_flags       = NBT_NM_GROUP,
5057                         .mhomed         = False,
5058                         .num_ips        = ctx->addresses_best_num,
5059                         .ips            = ctx->addresses_best,
5060                         .apply_expected = True
5061                 },
5062                 .replica= {
5063                         .type           = WREPL_TYPE_MHOMED,
5064                         .state          = WREPL_STATE_ACTIVE,
5065                         .node           = WREPL_NODE_B,
5066                         .is_static      = False,
5067                         .num_ips        = ctx->addresses_best_num,
5068                         .ips            = ctx->addresses_best,
5069                         .apply_expected = True
5070                 },
5071         },
5072         /*
5073          * sgroup,released vs. mhomed,active with different ip(s)
5074          */
5075         {
5076                 .line   = __location__,
5077                 .name   = _NBT_NAME("_SR_MA_DI", 0x1C, NULL),
5078                 .wins   = {
5079                         .nb_flags       = NBT_NM_GROUP,
5080                         .mhomed         = False,
5081                         .num_ips        = ctx->addresses_best_num,
5082                         .ips            = ctx->addresses_best,
5083                         .apply_expected = True
5084                 },
5085                 .replica= {
5086                         .type           = WREPL_TYPE_MHOMED,
5087                         .state          = WREPL_STATE_ACTIVE,
5088                         .node           = WREPL_NODE_B,
5089                         .is_static      = False,
5090                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5091                         .ips            = addresses_B_1,
5092                         .apply_expected = True
5093                 },
5094         },
5095         /*
5096          * sgroup,released vs. mhomed,tombstone with same ip(s)
5097          */
5098         {
5099                 .line   = __location__,
5100                 .name   = _NBT_NAME("_SR_MT_SI", 0x1C, NULL),
5101                 .wins   = {
5102                         .nb_flags       = NBT_NM_GROUP,
5103                         .mhomed         = False,
5104                         .num_ips        = ctx->addresses_best_num,
5105                         .ips            = ctx->addresses_best,
5106                         .apply_expected = True
5107                 },
5108                 .replica= {
5109                         .type           = WREPL_TYPE_MHOMED,
5110                         .state          = WREPL_STATE_TOMBSTONE,
5111                         .node           = WREPL_NODE_B,
5112                         .is_static      = False,
5113                         .num_ips        = ctx->addresses_best_num,
5114                         .ips            = ctx->addresses_best,
5115                         .apply_expected = True
5116                 },
5117         },
5118         /*
5119          * sgroup,released vs. mhomed,tombstone with different ip(s)
5120          */
5121         {
5122                 .line   = __location__,
5123                 .name   = _NBT_NAME("_SR_MT_DI", 0x1C, NULL),
5124                 .wins   = {
5125                         .nb_flags       = NBT_NM_GROUP,
5126                         .mhomed         = False,
5127                         .num_ips        = ctx->addresses_best_num,
5128                         .ips            = ctx->addresses_best,
5129                         .apply_expected = True
5130                 },
5131                 .replica= {
5132                         .type           = WREPL_TYPE_MHOMED,
5133                         .state          = WREPL_STATE_TOMBSTONE,
5134                         .node           = WREPL_NODE_B,
5135                         .is_static      = False,
5136                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5137                         .ips            = addresses_B_1,
5138                         .apply_expected = True
5139                 },
5140         },
5141 /* 
5142  * multi homed vs. unique section
5143  */
5144         /*
5145          * mhomed,released vs. unique,active with same ip(s)
5146          */
5147         {
5148                 .line   = __location__,
5149                 .name   = _NBT_NAME("_MR_UA_SI", 0x00, NULL),
5150                 .wins   = {
5151                         .nb_flags       = 0,
5152                         .mhomed         = True,
5153                         .num_ips        = ctx->addresses_best_num,
5154                         .ips            = ctx->addresses_best,
5155                         .apply_expected = True
5156                 },
5157                 .replica= {
5158                         .type           = WREPL_TYPE_UNIQUE,
5159                         .state          = WREPL_STATE_ACTIVE,
5160                         .node           = WREPL_NODE_B,
5161                         .is_static      = False,
5162                         .num_ips        = ctx->addresses_best_num,
5163                         .ips            = ctx->addresses_best,
5164                         .apply_expected = True
5165                 },
5166         },
5167         /*
5168          * mhomed,released vs. unique,active with different ip(s)
5169          */
5170         {
5171                 .line   = __location__,
5172                 .name   = _NBT_NAME("_MR_UA_DI", 0x00, NULL),
5173                 .wins   = {
5174                         .nb_flags       = 0,
5175                         .mhomed         = True,
5176                         .num_ips        = ctx->addresses_best_num,
5177                         .ips            = ctx->addresses_best,
5178                         .apply_expected = True
5179                 },
5180                 .replica= {
5181                         .type           = WREPL_TYPE_UNIQUE,
5182                         .state          = WREPL_STATE_ACTIVE,
5183                         .node           = WREPL_NODE_B,
5184                         .is_static      = False,
5185                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5186                         .ips            = addresses_B_1,
5187                         .apply_expected = True
5188                 },
5189         },
5190         /*
5191          * mhomed,released vs. unique,tombstone with same ip(s)
5192          */
5193         {
5194                 .line   = __location__,
5195                 .name   = _NBT_NAME("_MR_UT_SI", 0x00, NULL),
5196                 .wins   = {
5197                         .nb_flags       = 0,
5198                         .mhomed         = True,
5199                         .num_ips        = ctx->addresses_best_num,
5200                         .ips            = ctx->addresses_best,
5201                         .apply_expected = True
5202                 },
5203                 .replica= {
5204                         .type           = WREPL_TYPE_UNIQUE,
5205                         .state          = WREPL_STATE_TOMBSTONE,
5206                         .node           = WREPL_NODE_B,
5207                         .is_static      = False,
5208                         .num_ips        = ctx->addresses_best_num,
5209                         .ips            = ctx->addresses_best,
5210                         .apply_expected = True
5211                 },
5212         },
5213         /*
5214          * mhomed,released vs. unique,tombstone with different ip(s)
5215          */
5216         {
5217                 .line   = __location__,
5218                 .name   = _NBT_NAME("_MR_UT_DI", 0x00, NULL),
5219                 .wins   = {
5220                         .nb_flags       = 0,
5221                         .mhomed         = True,
5222                         .num_ips        = ctx->addresses_best_num,
5223                         .ips            = ctx->addresses_best,
5224                         .apply_expected = True
5225                 },
5226                 .replica= {
5227                         .type           = WREPL_TYPE_UNIQUE,
5228                         .state          = WREPL_STATE_TOMBSTONE,
5229                         .node           = WREPL_NODE_B,
5230                         .is_static      = False,
5231                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5232                         .ips            = addresses_B_1,
5233                         .apply_expected = True
5234                 },
5235         },
5236 /* 
5237  * multi homed vs. group section
5238  */
5239         /*
5240          * mhomed,released vs. group,active with same ip(s)
5241          */
5242         {
5243                 .line   = __location__,
5244                 .name   = _NBT_NAME("_MR_GA_SI", 0x00, NULL),
5245                 .wins   = {
5246                         .nb_flags       = 0,
5247                         .mhomed         = True,
5248                         .num_ips        = ctx->addresses_best_num,
5249                         .ips            = ctx->addresses_best,
5250                         .apply_expected = True
5251                 },
5252                 .replica= {
5253                         .type           = WREPL_TYPE_GROUP,
5254                         .state          = WREPL_STATE_ACTIVE,
5255                         .node           = WREPL_NODE_B,
5256                         .is_static      = False,
5257                         .num_ips        = ctx->addresses_best_num,
5258                         .ips            = ctx->addresses_best,
5259                         .apply_expected = True
5260                 },
5261         },
5262         /*
5263          * mhomed,released vs. group,active with different ip(s)
5264          */
5265         {
5266                 .line   = __location__,
5267                 .name   = _NBT_NAME("_MR_GA_DI", 0x00, NULL),
5268                 .wins   = {
5269                         .nb_flags       = 0,
5270                         .mhomed         = True,
5271                         .num_ips        = ctx->addresses_best_num,
5272                         .ips            = ctx->addresses_best,
5273                         .apply_expected = True
5274                 },
5275                 .replica= {
5276                         .type           = WREPL_TYPE_GROUP,
5277                         .state          = WREPL_STATE_ACTIVE,
5278                         .node           = WREPL_NODE_B,
5279                         .is_static      = False,
5280                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5281                         .ips            = addresses_B_1,
5282                         .apply_expected = True
5283                 },
5284         },
5285         /*
5286          * mhomed,released vs. group,tombstone with same ip(s)
5287          */
5288         {
5289                 .line   = __location__,
5290                 .name   = _NBT_NAME("_MR_GT_SI", 0x00, NULL),
5291                 .wins   = {
5292                         .nb_flags       = 0,
5293                         .mhomed         = True,
5294                         .num_ips        = ctx->addresses_best_num,
5295                         .ips            = ctx->addresses_best,
5296                         .apply_expected = True
5297                 },
5298                 .replica= {
5299                         .type           = WREPL_TYPE_GROUP,
5300                         .state          = WREPL_STATE_TOMBSTONE,
5301                         .node           = WREPL_NODE_B,
5302                         .is_static      = False,
5303                         .num_ips        = ctx->addresses_best_num,
5304                         .ips            = ctx->addresses_best,
5305                         .apply_expected = True
5306                 },
5307         },
5308         /*
5309          * mhomed,released vs. group,tombstone with different ip(s)
5310          */
5311         {
5312                 .line   = __location__,
5313                 .name   = _NBT_NAME("_MR_GT_DI", 0x00, NULL),
5314                 .wins   = {
5315                         .nb_flags       = 0,
5316                         .mhomed         = True,
5317                         .num_ips        = ctx->addresses_best_num,
5318                         .ips            = ctx->addresses_best,
5319                         .apply_expected = True
5320                 },
5321                 .replica= {
5322                         .type           = WREPL_TYPE_GROUP,
5323                         .state          = WREPL_STATE_TOMBSTONE,
5324                         .node           = WREPL_NODE_B,
5325                         .is_static      = False,
5326                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5327                         .ips            = addresses_B_1,
5328                         .apply_expected = True
5329                 },
5330         },
5331 /* 
5332  * multi homed vs. special group section
5333  */
5334         /*
5335          * mhomed,released vs. sgroup,active with same ip(s)
5336          */
5337         {
5338                 .line   = __location__,
5339                 .name   = _NBT_NAME("_MR_SA_SI", 0x00, NULL),
5340                 .wins   = {
5341                         .nb_flags       = 0,
5342                         .mhomed         = True,
5343                         .num_ips        = ctx->addresses_best_num,
5344                         .ips            = ctx->addresses_best,
5345                         .apply_expected = True
5346                 },
5347                 .replica= {
5348                         .type           = WREPL_TYPE_SGROUP,
5349                         .state          = WREPL_STATE_ACTIVE,
5350                         .node           = WREPL_NODE_B,
5351                         .is_static      = False,
5352                         .num_ips        = ctx->addresses_best_num,
5353                         .ips            = ctx->addresses_best,
5354                         .apply_expected = True
5355                 },
5356         },
5357         /*
5358          * mhomed,released vs. sgroup,active with different ip(s)
5359          */
5360         {
5361                 .line   = __location__,
5362                 .name   = _NBT_NAME("_MR_SA_DI", 0x00, NULL),
5363                 .wins   = {
5364                         .nb_flags       = 0,
5365                         .mhomed         = True,
5366                         .num_ips        = ctx->addresses_best_num,
5367                         .ips            = ctx->addresses_best,
5368                         .apply_expected = True
5369                 },
5370                 .replica= {
5371                         .type           = WREPL_TYPE_SGROUP,
5372                         .state          = WREPL_STATE_ACTIVE,
5373                         .node           = WREPL_NODE_B,
5374                         .is_static      = False,
5375                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5376                         .ips            = addresses_B_1,
5377                         .apply_expected = True
5378                 },
5379         },
5380         /*
5381          * mhomed,released vs. sgroup,tombstone with same ip(s)
5382          */
5383         {
5384                 .line   = __location__,
5385                 .name   = _NBT_NAME("_MR_ST_SI", 0x00, NULL),
5386                 .wins   = {
5387                         .nb_flags       = 0,
5388                         .mhomed         = True,
5389                         .num_ips        = ctx->addresses_best_num,
5390                         .ips            = ctx->addresses_best,
5391                         .apply_expected = True
5392                 },
5393                 .replica= {
5394                         .type           = WREPL_TYPE_SGROUP,
5395                         .state          = WREPL_STATE_TOMBSTONE,
5396                         .node           = WREPL_NODE_B,
5397                         .is_static      = False,
5398                         .num_ips        = ctx->addresses_best_num,
5399                         .ips            = ctx->addresses_best,
5400                         .apply_expected = True
5401                 },
5402         },
5403         /*
5404          * mhomed,released vs. sgroup,tombstone with different ip(s)
5405          */
5406         {
5407                 .line   = __location__,
5408                 .name   = _NBT_NAME("_MR_ST_DI", 0x00, NULL),
5409                 .wins   = {
5410                         .nb_flags       = 0,
5411                         .mhomed         = True,
5412                         .num_ips        = ctx->addresses_best_num,
5413                         .ips            = ctx->addresses_best,
5414                         .apply_expected = True
5415                 },
5416                 .replica= {
5417                         .type           = WREPL_TYPE_SGROUP,
5418                         .state          = WREPL_STATE_TOMBSTONE,
5419                         .node           = WREPL_NODE_B,
5420                         .is_static      = False,
5421                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5422                         .ips            = addresses_B_1,
5423                         .apply_expected = True
5424                 },
5425         },
5426 /* 
5427  * multi homed vs. multi homed section
5428  */
5429         /*
5430          * mhomed,released vs. mhomed,active with same ip(s)
5431          */
5432         {
5433                 .line   = __location__,
5434                 .name   = _NBT_NAME("_MR_MA_SI", 0x00, NULL),
5435                 .wins   = {
5436                         .nb_flags       = 0,
5437                         .mhomed         = True,
5438                         .num_ips        = ctx->addresses_best_num,
5439                         .ips            = ctx->addresses_best,
5440                         .apply_expected = True
5441                 },
5442                 .replica= {
5443                         .type           = WREPL_TYPE_MHOMED,
5444                         .state          = WREPL_STATE_ACTIVE,
5445                         .node           = WREPL_NODE_B,
5446                         .is_static      = False,
5447                         .num_ips        = ctx->addresses_best_num,
5448                         .ips            = ctx->addresses_best,
5449                         .apply_expected = True
5450                 },
5451         },
5452         /*
5453          * mhomed,released vs. mhomed,active with different ip(s)
5454          */
5455         {
5456                 .line   = __location__,
5457                 .name   = _NBT_NAME("_MR_MA_DI", 0x00, NULL),
5458                 .wins   = {
5459                         .nb_flags       = 0,
5460                         .mhomed         = True,
5461                         .num_ips        = ctx->addresses_best_num,
5462                         .ips            = ctx->addresses_best,
5463                         .apply_expected = True
5464                 },
5465                 .replica= {
5466                         .type           = WREPL_TYPE_MHOMED,
5467                         .state          = WREPL_STATE_ACTIVE,
5468                         .node           = WREPL_NODE_B,
5469                         .is_static      = False,
5470                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5471                         .ips            = addresses_B_1,
5472                         .apply_expected = True
5473                 },
5474         },
5475         /*
5476          * mhomed,released vs. mhomed,tombstone with same ip(s)
5477          */
5478         {
5479                 .line   = __location__,
5480                 .name   = _NBT_NAME("_MR_MT_SI", 0x00, NULL),
5481                 .wins   = {
5482                         .nb_flags       = 0,
5483                         .mhomed         = True,
5484                         .num_ips        = ctx->addresses_best_num,
5485                         .ips            = ctx->addresses_best,
5486                         .apply_expected = True
5487                 },
5488                 .replica= {
5489                         .type           = WREPL_TYPE_MHOMED,
5490                         .state          = WREPL_STATE_TOMBSTONE,
5491                         .node           = WREPL_NODE_B,
5492                         .is_static      = False,
5493                         .num_ips        = ctx->addresses_best_num,
5494                         .ips            = ctx->addresses_best,
5495                         .apply_expected = True
5496                 },
5497         },
5498         /*
5499          * mhomed,released vs. mhomed,tombstone with different ip(s)
5500          */
5501         {
5502                 .line   = __location__,
5503                 .name   = _NBT_NAME("_MR_MT_DI", 0x00, NULL),
5504                 .wins   = {
5505                         .nb_flags       = 0,
5506                         .mhomed         = True,
5507                         .num_ips        = ctx->addresses_best_num,
5508                         .ips            = ctx->addresses_best,
5509                         .apply_expected = True
5510                 },
5511                 .replica= {
5512                         .type           = WREPL_TYPE_MHOMED,
5513                         .state          = WREPL_STATE_TOMBSTONE,
5514                         .node           = WREPL_NODE_B,
5515                         .is_static      = False,
5516                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5517                         .ips            = addresses_B_1,
5518                         .apply_expected = True
5519                 },
5520         },
5521         };
5522
5523         if (!ctx) return False;
5524
5525         printf("Test Replica records vs. owned released records\n");
5526
5527         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
5528                 printf("%s => %s\n", nbt_name_string(ctx, &records[i].name),
5529                         (records[i].replica.apply_expected?"REPLACE":"NOT REPLACE"));
5530
5531                 /*
5532                  * Setup Register
5533                  */
5534                 name_register->in.name          = records[i].name;
5535                 name_register->in.dest_addr     = ctx->address;
5536                 name_register->in.address       = records[i].wins.ips[0].ip;
5537                 name_register->in.nb_flags      = records[i].wins.nb_flags;
5538                 name_register->in.register_demand= False;
5539                 name_register->in.broadcast     = False;
5540                 name_register->in.multi_homed   = records[i].wins.mhomed;
5541                 name_register->in.ttl           = 300000;
5542                 name_register->in.timeout       = 70;
5543                 name_register->in.retries       = 0;
5544
5545                 status = nbt_name_register(ctx->nbtsock, ctx, name_register);
5546                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
5547                         printf("No response from %s for name register\n", ctx->address);
5548                         ret = False;
5549                 }
5550                 if (!NT_STATUS_IS_OK(status)) {
5551                         printf("Bad response from %s for name register - %s\n",
5552                                ctx->address, nt_errstr(status));
5553                         ret = False;
5554                 }
5555                 CHECK_VALUE(name_register->out.rcode, 0);
5556                 CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address);
5557                 CHECK_VALUE(name_register->out.name.type, records[i].name.type);
5558                 CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name);
5559                 CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope);
5560                 CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[0].ip);
5561
5562                 /* release the record */
5563                 release->in.name        = records[i].name;
5564                 release->in.dest_addr   = ctx->address;
5565                 release->in.address     = records[i].wins.ips[0].ip;
5566                 release->in.nb_flags    = records[i].wins.nb_flags;
5567                 release->in.broadcast   = False;
5568                 release->in.timeout     = 30;
5569                 release->in.retries     = 0;
5570
5571                 status = nbt_name_release(ctx->nbtsock, ctx, release);
5572                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
5573                         printf("No response from %s for name release\n", ctx->address);
5574                         return False;
5575                 }
5576                 if (!NT_STATUS_IS_OK(status)) {
5577                         printf("Bad response from %s for name query - %s\n",
5578                                ctx->address, nt_errstr(status));
5579                         return False;
5580                 }
5581                 CHECK_VALUE(release->out.rcode, 0);
5582
5583                 /*
5584                  * Setup Replica
5585                  */
5586                 wins_name->name         = &records[i].name;
5587                 wins_name->flags        = WREPL_NAME_FLAGS(records[i].replica.type,
5588                                                            records[i].replica.state,
5589                                                            records[i].replica.node,
5590                                                            records[i].replica.is_static);
5591                 wins_name->id           = ++ctx->b.max_version;
5592                 if (wins_name->flags & 2) {
5593                         wins_name->addresses.addresses.num_ips = records[i].replica.num_ips;
5594                         wins_name->addresses.addresses.ips     = discard_const(records[i].replica.ips);
5595                 } else {
5596                         wins_name->addresses.ip = records[i].replica.ips[0].ip;
5597                 }
5598                 wins_name->unknown      = "255.255.255.255";
5599
5600                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
5601                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name,
5602                                              records[i].replica.apply_expected);
5603
5604                 if (records[i].replica.apply_expected) {
5605                         wins_name->name         = &records[i].name;
5606                         wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
5607                                                                    WREPL_STATE_TOMBSTONE,
5608                                                                    WREPL_NODE_B, False);
5609                         wins_name->id           = ++ctx->b.max_version;
5610                         wins_name->addresses.ip = addresses_B_1[0].ip;
5611                         wins_name->unknown      = "255.255.255.255";
5612
5613                         ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
5614                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
5615                 } else {
5616                         release->in.name        = records[i].name;
5617                         release->in.dest_addr   = ctx->address;
5618                         release->in.address     = records[i].wins.ips[0].ip;
5619                         release->in.nb_flags    = records[i].wins.nb_flags;
5620                         release->in.broadcast   = False;
5621                         release->in.timeout     = 30;
5622                         release->in.retries     = 0;
5623
5624                         status = nbt_name_release(ctx->nbtsock, ctx, release);
5625                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
5626                                 printf("No response from %s for name release\n", ctx->address);
5627                                 return False;
5628                         }
5629                         if (!NT_STATUS_IS_OK(status)) {
5630                                 printf("Bad response from %s for name query - %s\n",
5631                                        ctx->address, nt_errstr(status));
5632                                 return False;
5633                         }
5634                         CHECK_VALUE(release->out.rcode, 0);
5635                 }
5636 done:
5637                 if (!ret) {
5638                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
5639                         return ret;
5640                 }
5641         }
5642
5643         return ret;
5644 }
5645
5646 struct test_conflict_owned_active_vs_replica_struct {
5647         const char *line; /* just better debugging */
5648         const char *section; /* just better debugging */
5649         struct nbt_name name;
5650         BOOL skip;
5651         struct {
5652                 uint32_t nb_flags;
5653                 BOOL mhomed;
5654                 uint32_t num_ips;
5655                 const struct wrepl_ip *ips;
5656                 BOOL apply_expected;
5657         } wins;
5658         struct {
5659                 uint32_t timeout;
5660                 BOOL positive;
5661                 BOOL expect_release;
5662                 BOOL ret;
5663                 /* when num_ips == 0, then .wins.ips are used */
5664                 uint32_t num_ips;
5665                 const struct wrepl_ip *ips;
5666         } defend;
5667         struct {
5668                 enum wrepl_name_type type;
5669                 enum wrepl_name_state state;
5670                 enum wrepl_name_node node;
5671                 BOOL is_static;
5672                 uint32_t num_ips;
5673                 const struct wrepl_ip *ips;
5674                 BOOL apply_expected;
5675                 BOOL mhomed_merge;
5676         } replica;
5677 };
5678
5679 static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket *nbtsock, 
5680                                                           struct nbt_name_packet *req_packet, 
5681                                                           const struct nbt_peer_socket *src);
5682
5683 static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_conn *ctx)
5684 {
5685         BOOL ret = True;
5686         NTSTATUS status;
5687         struct wrepl_wins_name wins_name_;
5688         struct wrepl_wins_name *wins_name = &wins_name_;
5689         struct nbt_name_register name_register_;
5690         struct nbt_name_register *name_register = &name_register_;
5691         struct nbt_name_release release_;
5692         struct nbt_name_release *release = &release_;
5693         uint32_t i;
5694         struct test_conflict_owned_active_vs_replica_struct records[] = {
5695 /* 
5696  * unique vs. unique section
5697  */
5698         /*
5699          * unique,active vs. unique,active with same ip(s), unchecked
5700          */
5701         {
5702                 .line   = __location__,
5703                 .name   = _NBT_NAME("_UA_UA_SI_U", 0x00, NULL),
5704                 .wins   = {
5705                         .nb_flags       = 0,
5706                         .mhomed         = False,
5707                         .num_ips        = ctx->addresses_best_num,
5708                         .ips            = ctx->addresses_best,
5709                         .apply_expected = True
5710                 },
5711                 .defend = {
5712                         .timeout        = 0,
5713                 },
5714                 .replica= {
5715                         .type           = WREPL_TYPE_UNIQUE,
5716                         .state          = WREPL_STATE_ACTIVE,
5717                         .node           = WREPL_NODE_B,
5718                         .is_static      = False,
5719                         .num_ips        = ctx->addresses_best_num,
5720                         .ips            = ctx->addresses_best,
5721                         .apply_expected = True
5722                 },
5723         },
5724         /*
5725          * unique,active vs. unique,active with different ip(s), positive response
5726          */
5727         {
5728                 .line   = __location__,
5729                 .name   = _NBT_NAME("_UA_UA_DI_P", 0x00, NULL),
5730                 .wins   = {
5731                         .nb_flags       = 0,
5732                         .mhomed         = False,
5733                         .num_ips        = ctx->addresses_best_num,
5734                         .ips            = ctx->addresses_best,
5735                         .apply_expected = True
5736                 },
5737                 .defend = {
5738                         .timeout        = 10,
5739                         .positive       = True,
5740                 },
5741                 .replica= {
5742                         .type           = WREPL_TYPE_UNIQUE,
5743                         .state          = WREPL_STATE_ACTIVE,
5744                         .node           = WREPL_NODE_B,
5745                         .is_static      = False,
5746                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5747                         .ips            = addresses_B_1,
5748                         .apply_expected = False
5749                 },
5750         },
5751         /*
5752          * unique,active vs. unique,active with different ip(s), positive response other ips
5753          */
5754         {
5755                 .line   = __location__,
5756                 .name   = _NBT_NAME("_UA_UA_DI_O", 0x00, NULL),
5757                 .wins   = {
5758                         .nb_flags       = 0,
5759                         .mhomed         = False,
5760                         .num_ips        = ctx->addresses_best_num,
5761                         .ips            = ctx->addresses_best,
5762                         .apply_expected = True
5763                 },
5764                 .defend = {
5765                         .timeout        = 10,
5766                         .positive       = True,
5767                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
5768                         .ips            = addresses_A_3_4,
5769                 },
5770                 .replica= {
5771                         .type           = WREPL_TYPE_UNIQUE,
5772                         .state          = WREPL_STATE_ACTIVE,
5773                         .node           = WREPL_NODE_B,
5774                         .is_static      = False,
5775                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5776                         .ips            = addresses_B_1,
5777                         .apply_expected = False
5778                 },
5779         },
5780         /*
5781          * unique,active vs. unique,active with different ip(s), negative response
5782          */
5783         {
5784                 .line   = __location__,
5785                 .name   = _NBT_NAME("_UA_UA_DI_N", 0x00, NULL),
5786                 .wins   = {
5787                         .nb_flags       = 0,
5788                         .mhomed         = False,
5789                         .num_ips        = ctx->addresses_best_num,
5790                         .ips            = ctx->addresses_best,
5791                         .apply_expected = True
5792                 },
5793                 .defend = {
5794                         .timeout        = 10,
5795                         .positive       = False,
5796                 },
5797                 .replica= {
5798                         .type           = WREPL_TYPE_UNIQUE,
5799                         .state          = WREPL_STATE_ACTIVE,
5800                         .node           = WREPL_NODE_B,
5801                         .is_static      = False,
5802                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5803                         .ips            = addresses_B_1,
5804                         .apply_expected = True
5805                 },
5806         },
5807         /*
5808          * unique,active vs. unique,tombstone with same ip(s), unchecked
5809          */
5810         {
5811                 .line   = __location__,
5812                 .name   = _NBT_NAME("_UA_UT_SI_U", 0x00, NULL),
5813                 .wins   = {
5814                         .nb_flags       = 0,
5815                         .mhomed         = False,
5816                         .num_ips        = ctx->addresses_best_num,
5817                         .ips            = ctx->addresses_best,
5818                         .apply_expected = True
5819                 },
5820                 .defend = {
5821                         .timeout        = 0,
5822                 },
5823                 .replica= {
5824                         .type           = WREPL_TYPE_UNIQUE,
5825                         .state          = WREPL_STATE_TOMBSTONE,
5826                         .node           = WREPL_NODE_B,
5827                         .is_static      = False,
5828                         .num_ips        = ctx->addresses_best_num,
5829                         .ips            = ctx->addresses_best,
5830                         .apply_expected = False
5831                 },
5832         },
5833         /*
5834          * unique,active vs. unique,tombstone with different ip(s), unchecked
5835          */
5836         {
5837                 .line   = __location__,
5838                 .name   = _NBT_NAME("_UA_UT_DI_U", 0x00, NULL),
5839                 .wins   = {
5840                         .nb_flags       = 0,
5841                         .mhomed         = False,
5842                         .num_ips        = ctx->addresses_best_num,
5843                         .ips            = ctx->addresses_best,
5844                         .apply_expected = True
5845                 },
5846                 .defend = {
5847                         .timeout        = 0,
5848                 },
5849                 .replica= {
5850                         .type           = WREPL_TYPE_UNIQUE,
5851                         .state          = WREPL_STATE_TOMBSTONE,
5852                         .node           = WREPL_NODE_B,
5853                         .is_static      = False,
5854                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5855                         .ips            = addresses_B_1,
5856                         .apply_expected = False
5857                 },
5858         },
5859 /* 
5860  * unique vs. group section
5861  */
5862         /*
5863          * unique,active vs. group,active with same ip(s), release expected
5864          */
5865         {
5866                 .line   = __location__,
5867                 .name   = _NBT_NAME("_UA_GA_SI_R", 0x00, NULL),
5868                 .wins   = {
5869                         .nb_flags       = 0,
5870                         .mhomed         = False,
5871                         .num_ips        = ctx->addresses_best_num,
5872                         .ips            = ctx->addresses_best,
5873                         .apply_expected = True
5874                 },
5875                 .defend = {
5876                         .timeout        = 10,
5877                         .expect_release = True,
5878                 },
5879                 .replica= {
5880                         .type           = WREPL_TYPE_GROUP,
5881                         .state          = WREPL_STATE_ACTIVE,
5882                         .node           = WREPL_NODE_B,
5883                         .is_static      = False,
5884                         .num_ips        = ctx->addresses_best_num,
5885                         .ips            = ctx->addresses_best,
5886                         .apply_expected = True
5887                 },
5888         },
5889         /*
5890          * unique,active vs. group,active with different ip(s), release expected
5891          */
5892         {
5893                 .line   = __location__,
5894                 .name   = _NBT_NAME("_UA_GA_DI_R", 0x00, NULL),
5895                 .wins   = {
5896                         .nb_flags       = 0,
5897                         .mhomed         = False,
5898                         .num_ips        = ctx->addresses_best_num,
5899                         .ips            = ctx->addresses_best,
5900                         .apply_expected = True
5901                 },
5902                 .defend = {
5903                         .timeout        = 10,
5904                         .expect_release = True,
5905                 },
5906                 .replica= {
5907                         .type           = WREPL_TYPE_GROUP,
5908                         .state          = WREPL_STATE_ACTIVE,
5909                         .node           = WREPL_NODE_B,
5910                         .is_static      = False,
5911                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5912                         .ips            = addresses_B_1,
5913                         .apply_expected = True
5914                 },
5915         },
5916         /*
5917          * unique,active vs. group,tombstone with same ip(s), unchecked
5918          */
5919         {
5920                 .line   = __location__,
5921                 .name   = _NBT_NAME("_UA_GT_SI_U", 0x00, NULL),
5922                 .wins   = {
5923                         .nb_flags       = 0,
5924                         .mhomed         = False,
5925                         .num_ips        = ctx->addresses_best_num,
5926                         .ips            = ctx->addresses_best,
5927                         .apply_expected = True
5928                 },
5929                 .defend = {
5930                         .timeout        = 0,
5931                 },
5932                 .replica= {
5933                         .type           = WREPL_TYPE_GROUP,
5934                         .state          = WREPL_STATE_TOMBSTONE,
5935                         .node           = WREPL_NODE_B,
5936                         .is_static      = False,
5937                         .num_ips        = ctx->addresses_best_num,
5938                         .ips            = ctx->addresses_best,
5939                         .apply_expected = False
5940                 },
5941         },
5942         /*
5943          * unique,active vs. group,tombstone with different ip(s), unchecked
5944          */
5945         {
5946                 .line   = __location__,
5947                 .name   = _NBT_NAME("_UA_GT_DI_U", 0x00, NULL),
5948                 .wins   = {
5949                         .nb_flags       = 0,
5950                         .mhomed         = False,
5951                         .num_ips        = ctx->addresses_best_num,
5952                         .ips            = ctx->addresses_best,
5953                         .apply_expected = True
5954                 },
5955                 .defend = {
5956                         .timeout        = 0,
5957                 },
5958                 .replica= {
5959                         .type           = WREPL_TYPE_GROUP,
5960                         .state          = WREPL_STATE_TOMBSTONE,
5961                         .node           = WREPL_NODE_B,
5962                         .is_static      = False,
5963                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5964                         .ips            = addresses_B_1,
5965                         .apply_expected = False
5966                 },
5967         },
5968 /* 
5969  * unique vs. special group section
5970  */
5971         /*
5972          * unique,active vs. sgroup,active with same ip(s), release expected
5973          */
5974         {
5975                 .line   = __location__,
5976                 .name   = _NBT_NAME("_UA_SA_SI_R", 0x00, NULL),
5977                 .wins   = {
5978                         .nb_flags       = 0,
5979                         .mhomed         = False,
5980                         .num_ips        = ctx->addresses_best_num,
5981                         .ips            = ctx->addresses_best,
5982                         .apply_expected = True
5983                 },
5984                 .defend = {
5985                         .timeout        = 10,
5986                         .expect_release = True,
5987                 },
5988                 .replica= {
5989                         .type           = WREPL_TYPE_SGROUP,
5990                         .state          = WREPL_STATE_ACTIVE,
5991                         .node           = WREPL_NODE_B,
5992                         .is_static      = False,
5993                         .num_ips        = ctx->addresses_best_num,
5994                         .ips            = ctx->addresses_best,
5995                         .apply_expected = True
5996                 },
5997         },
5998         /*
5999          * unique,active vs. group,active with different ip(s), release expected
6000          */
6001         {
6002                 .line   = __location__,
6003                 .name   = _NBT_NAME("_UA_SA_DI_R", 0x00, NULL),
6004                 .wins   = {
6005                         .nb_flags       = 0,
6006                         .mhomed         = False,
6007                         .num_ips        = ctx->addresses_best_num,
6008                         .ips            = ctx->addresses_best,
6009                         .apply_expected = True
6010                 },
6011                 .defend = {
6012                         .timeout        = 10,
6013                         .expect_release = True,
6014                 },
6015                 .replica= {
6016                         .type           = WREPL_TYPE_SGROUP,
6017                         .state          = WREPL_STATE_ACTIVE,
6018                         .node           = WREPL_NODE_B,
6019                         .is_static      = False,
6020                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6021                         .ips            = addresses_B_1,
6022                         .apply_expected = True
6023                 },
6024         },
6025         /*
6026          * unique,active vs. sgroup,tombstone with same ip(s), unchecked
6027          */
6028         {
6029                 .line   = __location__,
6030                 .name   = _NBT_NAME("_UA_ST_SI_U", 0x00, NULL),
6031                 .wins   = {
6032                         .nb_flags       = 0,
6033                         .mhomed         = False,
6034                         .num_ips        = ctx->addresses_best_num,
6035                         .ips            = ctx->addresses_best,
6036                         .apply_expected = True
6037                 },
6038                 .defend = {
6039                         .timeout        = 0,
6040                 },
6041                 .replica= {
6042                         .type           = WREPL_TYPE_SGROUP,
6043                         .state          = WREPL_STATE_TOMBSTONE,
6044                         .node           = WREPL_NODE_B,
6045                         .is_static      = False,
6046                         .num_ips        = ctx->addresses_best_num,
6047                         .ips            = ctx->addresses_best,
6048                         .apply_expected = False
6049                 },
6050         },
6051         /*
6052          * unique,active vs. sgroup,tombstone with different ip(s), unchecked
6053          */
6054         {
6055                 .line   = __location__,
6056                 .name   = _NBT_NAME("_UA_ST_DI_U", 0x00, NULL),
6057                 .wins   = {
6058                         .nb_flags       = 0,
6059                         .mhomed         = False,
6060                         .num_ips        = ctx->addresses_best_num,
6061                         .ips            = ctx->addresses_best,
6062                         .apply_expected = True
6063                 },
6064                 .defend = {
6065                         .timeout        = 0,
6066                 },
6067                 .replica= {
6068                         .type           = WREPL_TYPE_SGROUP,
6069                         .state          = WREPL_STATE_TOMBSTONE,
6070                         .node           = WREPL_NODE_B,
6071                         .is_static      = False,
6072                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6073                         .ips            = addresses_B_1,
6074                         .apply_expected = False
6075                 },
6076         },
6077 /* 
6078  * unique vs. multi homed section
6079  */
6080         /*
6081          * unique,active vs. mhomed,active with same ip(s), unchecked
6082          */
6083         {
6084                 .line   = __location__,
6085                 .name   = _NBT_NAME("_UA_MA_SI_U", 0x00, NULL),
6086                 .wins   = {
6087                         .nb_flags       = 0,
6088                         .mhomed         = False,
6089                         .num_ips        = ctx->addresses_best_num,
6090                         .ips            = ctx->addresses_best,
6091                         .apply_expected = True
6092                 },
6093                 .defend = {
6094                         .timeout        = 0,
6095                 },
6096                 .replica= {
6097                         .type           = WREPL_TYPE_MHOMED,
6098                         .state          = WREPL_STATE_ACTIVE,
6099                         .node           = WREPL_NODE_B,
6100                         .is_static      = False,
6101                         .num_ips        = ctx->addresses_best_num,
6102                         .ips            = ctx->addresses_best,
6103                         .apply_expected = True
6104                 },
6105         },
6106         /*
6107          * unique,active vs. mhomed,active with superset ip(s), unchecked
6108          */
6109         {
6110                 .line   = __location__,
6111                 .name   = _NBT_NAME("_UA_MA_SP_U", 0x00, NULL),
6112                 .wins   = {
6113                         .nb_flags       = 0,
6114                         .mhomed         = False,
6115                         .num_ips        = ctx->addresses_best_num,
6116                         .ips            = ctx->addresses_best,
6117                         .apply_expected = True
6118                 },
6119                 .defend = {
6120                         .timeout        = 0,
6121                 },
6122                 .replica= {
6123                         .type           = WREPL_TYPE_MHOMED,
6124                         .state          = WREPL_STATE_ACTIVE,
6125                         .node           = WREPL_NODE_B,
6126                         .is_static      = False,
6127                         .num_ips        = ctx->addresses_all_num,
6128                         .ips            = ctx->addresses_all,
6129                         .apply_expected = True
6130                 },
6131         },
6132         /*
6133          * unique,active vs. mhomed,active with different ip(s), positive response
6134          */
6135         {
6136                 .line   = __location__,
6137                 .name   = _NBT_NAME("_UA_MA_DI_P", 0x00, NULL),
6138                 .wins   = {
6139                         .nb_flags       = 0,
6140                         .mhomed         = False,
6141                         .num_ips        = ctx->addresses_best_num,
6142                         .ips            = ctx->addresses_best,
6143                         .apply_expected = True
6144                 },
6145                 .defend = {
6146                         .timeout        = 10,
6147                         .positive       = True,
6148                 },
6149                 .replica= {
6150                         .type           = WREPL_TYPE_MHOMED,
6151                         .state          = WREPL_STATE_ACTIVE,
6152                         .node           = WREPL_NODE_B,
6153                         .is_static      = False,
6154                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
6155                         .ips            = addresses_B_3_4,
6156                         .apply_expected = False
6157                 },
6158         },
6159         /*
6160          * unique,active vs. mhomed,active with different ip(s), positive response other ips
6161          */
6162         {
6163                 .line   = __location__,
6164                 .name   = _NBT_NAME("_UA_MA_DI_O", 0x00, NULL),
6165                 .wins   = {
6166                         .nb_flags       = 0,
6167                         .mhomed         = False,
6168                         .num_ips        = ctx->addresses_best_num,
6169                         .ips            = ctx->addresses_best,
6170                         .apply_expected = True
6171                 },
6172                 .defend = {
6173                         .timeout        = 10,
6174                         .positive       = True,
6175                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
6176                         .ips            = addresses_A_3_4,
6177                 },
6178                 .replica= {
6179                         .type           = WREPL_TYPE_MHOMED,
6180                         .state          = WREPL_STATE_ACTIVE,
6181                         .node           = WREPL_NODE_B,
6182                         .is_static      = False,
6183                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
6184                         .ips            = addresses_B_3_4,
6185                         .apply_expected = False
6186                 },
6187         },
6188         /*
6189          * unique,active vs. mhomed,active with different ip(s), negative response
6190          */
6191         {
6192                 .line   = __location__,
6193                 .name   = _NBT_NAME("_UA_MA_DI_N", 0x00, NULL),
6194                 .wins   = {
6195                         .nb_flags       = 0,
6196                         .mhomed         = False,
6197                         .num_ips        = ctx->addresses_best_num,
6198                         .ips            = ctx->addresses_best,
6199                         .apply_expected = True
6200                 },
6201                 .defend = {
6202                         .timeout        = 10,
6203                         .positive       = False,
6204                 },
6205                 .replica= {
6206                         .type           = WREPL_TYPE_MHOMED,
6207                         .state          = WREPL_STATE_ACTIVE,
6208                         .node           = WREPL_NODE_B,
6209                         .is_static      = False,
6210                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
6211                         .ips            = addresses_B_3_4,
6212                         .apply_expected = True
6213                 },
6214         },
6215         /*
6216          * unique,active vs. mhomed,tombstone with same ip(s), unchecked
6217          */
6218         {
6219                 .line   = __location__,
6220                 .name   = _NBT_NAME("_UA_MT_SI_U", 0x00, NULL),
6221                 .wins   = {
6222                         .nb_flags       = 0,
6223                         .mhomed         = False,
6224                         .num_ips        = ctx->addresses_best_num,
6225                         .ips            = ctx->addresses_best,
6226                         .apply_expected = True
6227                 },
6228                 .defend = {
6229                         .timeout        = 0,
6230                 },
6231                 .replica= {
6232                         .type           = WREPL_TYPE_MHOMED,
6233                         .state          = WREPL_STATE_TOMBSTONE,
6234                         .node           = WREPL_NODE_B,
6235                         .is_static      = False,
6236                         .num_ips        = ctx->addresses_best_num,
6237                         .ips            = ctx->addresses_best,
6238                         .apply_expected = False
6239                 },
6240         },
6241         /*
6242          * unique,active vs. mhomed,tombstone with different ip(s), unchecked
6243          */
6244         {
6245                 .line   = __location__,
6246                 .name   = _NBT_NAME("_UA_MT_DI_U", 0x00, NULL),
6247                 .wins   = {
6248                         .nb_flags       = 0,
6249                         .mhomed         = False,
6250                         .num_ips        = ctx->addresses_best_num,
6251                         .ips            = ctx->addresses_best,
6252                         .apply_expected = True
6253                 },
6254                 .defend = {
6255                         .timeout        = 0,
6256                 },
6257                 .replica= {
6258                         .type           = WREPL_TYPE_MHOMED,
6259                         .state          = WREPL_STATE_TOMBSTONE,
6260                         .node           = WREPL_NODE_B,
6261                         .is_static      = False,
6262                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
6263                         .ips            = addresses_B_3_4,
6264                         .apply_expected = False
6265                 },
6266         },
6267 /* 
6268  * normal group vs. unique section
6269  */
6270         /*
6271          * group,active vs. unique,active with same ip(s), unchecked
6272          */
6273         {
6274                 .line   = __location__,
6275                 .name   = _NBT_NAME("_GA_UA_SI_U", 0x00, NULL),
6276                 .wins   = {
6277                         .nb_flags       = NBT_NM_GROUP,
6278                         .mhomed         = False,
6279                         .num_ips        = ctx->addresses_best_num,
6280                         .ips            = ctx->addresses_best,
6281                         .apply_expected = True
6282                 },
6283                 .defend = {
6284                         .timeout        = 0,
6285                 },
6286                 .replica= {
6287                         .type           = WREPL_TYPE_UNIQUE,
6288                         .state          = WREPL_STATE_ACTIVE,
6289                         .node           = WREPL_NODE_B,
6290                         .is_static      = False,
6291                         .num_ips        = ctx->addresses_best_num,
6292                         .ips            = ctx->addresses_best,
6293                         .apply_expected = False
6294                 },
6295         },
6296         /*
6297          * group,active vs. unique,active with different ip(s), unchecked
6298          */
6299         {
6300                 .line   = __location__,
6301                 .name   = _NBT_NAME("_GA_UA_DI_U", 0x00, NULL),
6302                 .wins   = {
6303                         .nb_flags       = NBT_NM_GROUP,
6304                         .mhomed         = False,
6305                         .num_ips        = ctx->addresses_best_num,
6306                         .ips            = ctx->addresses_best,
6307                         .apply_expected = True
6308                 },
6309                 .defend = {
6310                         .timeout        = 0,
6311                 },
6312                 .replica= {
6313                         .type           = WREPL_TYPE_UNIQUE,
6314                         .state          = WREPL_STATE_ACTIVE,
6315                         .node           = WREPL_NODE_B,
6316                         .is_static      = False,
6317                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6318                         .ips            = addresses_B_1,
6319                         .apply_expected = False
6320                 },
6321         },
6322         /*
6323          * group,active vs. unique,tombstone with same ip(s), unchecked
6324          */
6325         {
6326                 .line   = __location__,
6327                 .name   = _NBT_NAME("_GA_UT_SI_U", 0x00, NULL),
6328                 .wins   = {
6329                         .nb_flags       = NBT_NM_GROUP,
6330                         .mhomed         = False,
6331                         .num_ips        = ctx->addresses_best_num,
6332                         .ips            = ctx->addresses_best,
6333                         .apply_expected = True
6334                 },
6335                 .defend = {
6336                         .timeout        = 0,
6337                 },
6338                 .replica= {
6339                         .type           = WREPL_TYPE_UNIQUE,
6340                         .state          = WREPL_STATE_TOMBSTONE,
6341                         .node           = WREPL_NODE_B,
6342                         .is_static      = False,
6343                         .num_ips        = ctx->addresses_best_num,
6344                         .ips            = ctx->addresses_best,
6345                         .apply_expected = False
6346                 },
6347         },
6348         /*
6349          * group,active vs. unique,tombstone with different ip(s), unchecked
6350          */
6351         {
6352                 .line   = __location__,
6353                 .name   = _NBT_NAME("_GA_UT_DI_U", 0x00, NULL),
6354                 .wins   = {
6355                         .nb_flags       = NBT_NM_GROUP,
6356                         .mhomed         = False,
6357                         .num_ips        = ctx->addresses_best_num,
6358                         .ips            = ctx->addresses_best,
6359                         .apply_expected = True
6360                 },
6361                 .defend = {
6362                         .timeout        = 0,
6363                 },
6364                 .replica= {
6365                         .type           = WREPL_TYPE_UNIQUE,
6366                         .state          = WREPL_STATE_TOMBSTONE,
6367                         .node           = WREPL_NODE_B,
6368                         .is_static      = False,
6369                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6370                         .ips            = addresses_B_1,
6371                         .apply_expected = False
6372                 },
6373         },
6374 /* 
6375  * normal group vs. normal group section
6376  */
6377         /*
6378          * group,active vs. group,active with same ip(s), unchecked
6379          */
6380         {
6381                 .line   = __location__,
6382                 .name   = _NBT_NAME("_GA_GA_SI_U", 0x00, NULL),
6383                 .wins   = {
6384                         .nb_flags       = NBT_NM_GROUP,
6385                         .mhomed         = False,
6386                         .num_ips        = ctx->addresses_best_num,
6387                         .ips            = ctx->addresses_best,
6388                         .apply_expected = True
6389                 },
6390                 .defend = {
6391                         .timeout        = 0,
6392                 },
6393                 .replica= {
6394                         .type           = WREPL_TYPE_GROUP,
6395                         .state          = WREPL_STATE_ACTIVE,
6396                         .node           = WREPL_NODE_B,
6397                         .is_static      = False,
6398                         .num_ips        = ctx->addresses_best_num,
6399                         .ips            = ctx->addresses_best,
6400                         .apply_expected = True
6401                 },
6402         },
6403         /*
6404          * group,active vs. group,active with different ip(s), unchecked
6405          */
6406         {
6407                 .line   = __location__,
6408                 .name   = _NBT_NAME("_GA_GA_DI_U", 0x00, NULL),
6409                 .wins   = {
6410                         .nb_flags       = NBT_NM_GROUP,
6411                         .mhomed         = False,
6412                         .num_ips        = ctx->addresses_best_num,
6413                         .ips            = ctx->addresses_best,
6414                         .apply_expected = True
6415                 },
6416                 .defend = {
6417                         .timeout        = 0,
6418                 },
6419                 .replica= {
6420                         .type           = WREPL_TYPE_GROUP,
6421                         .state          = WREPL_STATE_ACTIVE,
6422                         .node           = WREPL_NODE_B,
6423                         .is_static      = False,
6424                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6425                         .ips            = addresses_B_1,
6426                         .apply_expected = True
6427                 },
6428         },
6429         /*
6430          * group,active vs. group,tombstone with same ip(s), unchecked
6431          */
6432         {
6433                 .line   = __location__,
6434                 .name   = _NBT_NAME("_GA_GT_SI_U", 0x00, NULL),
6435                 .wins   = {
6436                         .nb_flags       = NBT_NM_GROUP,
6437                         .mhomed         = False,
6438                         .num_ips        = ctx->addresses_best_num,
6439                         .ips            = ctx->addresses_best,
6440                         .apply_expected = True
6441                 },
6442                 .defend = {
6443                         .timeout        = 0,
6444                 },
6445                 .replica= {
6446                         .type           = WREPL_TYPE_GROUP,
6447                         .state          = WREPL_STATE_TOMBSTONE,
6448                         .node           = WREPL_NODE_B,
6449                         .is_static      = False,
6450                         .num_ips        = ctx->addresses_best_num,
6451                         .ips            = ctx->addresses_best,
6452                         .apply_expected = False
6453                 },
6454         },
6455         /*
6456          * group,active vs. group,tombstone with different ip(s), unchecked
6457          */
6458         {
6459                 .line   = __location__,
6460                 .name   = _NBT_NAME("_GA_GT_DI_U", 0x00, NULL),
6461                 .wins   = {
6462                         .nb_flags       = NBT_NM_GROUP,
6463                         .mhomed         = False,
6464                         .num_ips        = ctx->addresses_best_num,
6465                         .ips            = ctx->addresses_best,
6466                         .apply_expected = True
6467                 },
6468                 .defend = {
6469                         .timeout        = 0,
6470                 },
6471                 .replica= {
6472                         .type           = WREPL_TYPE_GROUP,
6473                         .state          = WREPL_STATE_TOMBSTONE,
6474                         .node           = WREPL_NODE_B,
6475                         .is_static      = False,
6476                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6477                         .ips            = addresses_B_1,
6478                         .apply_expected = False
6479                 },
6480         },
6481 /* 
6482  * normal group vs. special group section
6483  */
6484         /*
6485          * group,active vs. sgroup,active with same ip(s), unchecked
6486          */
6487         {
6488                 .line   = __location__,
6489                 .name   = _NBT_NAME("_GA_SA_SI_U", 0x00, NULL),
6490                 .wins   = {
6491                         .nb_flags       = NBT_NM_GROUP,
6492                         .mhomed         = False,
6493                         .num_ips        = ctx->addresses_best_num,
6494                         .ips            = ctx->addresses_best,
6495                         .apply_expected = True
6496                 },
6497                 .defend = {
6498                         .timeout        = 0,
6499                 },
6500                 .replica= {
6501                         .type           = WREPL_TYPE_SGROUP,
6502                         .state          = WREPL_STATE_ACTIVE,
6503                         .node           = WREPL_NODE_B,
6504                         .is_static      = False,
6505                         .num_ips        = ctx->addresses_best_num,
6506                         .ips            = ctx->addresses_best,
6507                         .apply_expected = False
6508                 },
6509         },
6510         /*
6511          * group,active vs. sgroup,active with different ip(s), unchecked
6512          */
6513         {
6514                 .line   = __location__,
6515                 .name   = _NBT_NAME("_GA_SA_DI_U", 0x00, NULL),
6516                 .wins   = {
6517                         .nb_flags       = NBT_NM_GROUP,
6518                         .mhomed         = False,
6519                         .num_ips        = ctx->addresses_best_num,
6520                         .ips            = ctx->addresses_best,
6521                         .apply_expected = True
6522                 },
6523                 .defend = {
6524                         .timeout        = 0,
6525                 },
6526                 .replica= {
6527                         .type           = WREPL_TYPE_SGROUP,
6528                         .state          = WREPL_STATE_ACTIVE,
6529                         .node           = WREPL_NODE_B,
6530                         .is_static      = False,
6531                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
6532                         .ips            = addresses_B_3_4,
6533                         .apply_expected = False
6534                 },
6535         },
6536         /*
6537          * group,active vs. sgroup,tombstone with same ip(s), unchecked
6538          */
6539         {
6540                 .line   = __location__,
6541                 .name   = _NBT_NAME("_GA_ST_SI_U", 0x00, NULL),
6542                 .wins   = {
6543                         .nb_flags       = NBT_NM_GROUP,
6544                         .mhomed         = False,
6545                         .num_ips        = ctx->addresses_best_num,
6546                         .ips            = ctx->addresses_best,
6547                         .apply_expected = True
6548                 },
6549                 .defend = {
6550                         .timeout        = 0,
6551                 },
6552                 .replica= {
6553                         .type           = WREPL_TYPE_SGROUP,
6554                         .state          = WREPL_STATE_TOMBSTONE,
6555                         .node           = WREPL_NODE_B,
6556                         .is_static      = False,
6557                         .num_ips        = ctx->addresses_best_num,
6558                         .ips            = ctx->addresses_best,
6559                         .apply_expected = False
6560                 },
6561         },
6562         /*
6563          * group,active vs. sgroup,tombstone with different ip(s), unchecked
6564          */
6565         {
6566                 .line   = __location__,
6567                 .name   = _NBT_NAME("_GA_ST_DI_U", 0x00, NULL),
6568                 .wins   = {
6569                         .nb_flags       = NBT_NM_GROUP,
6570                         .mhomed         = False,
6571                         .num_ips        = ctx->addresses_best_num,
6572                         .ips            = ctx->addresses_best,
6573                         .apply_expected = True
6574                 },
6575                 .defend = {
6576                         .timeout        = 0,
6577                 },
6578                 .replica= {
6579                         .type           = WREPL_TYPE_SGROUP,
6580                         .state          = WREPL_STATE_TOMBSTONE,
6581                         .node           = WREPL_NODE_B,
6582                         .is_static      = False,
6583                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
6584                         .ips            = addresses_B_3_4,
6585                         .apply_expected = False
6586                 },
6587         },
6588 /* 
6589  * normal group vs. multi homed section
6590  */
6591         /*
6592          * group,active vs. mhomed,active with same ip(s), unchecked
6593          */
6594         {
6595                 .line   = __location__,
6596                 .name   = _NBT_NAME("_GA_MA_SI_U", 0x00, NULL),
6597                 .wins   = {
6598                         .nb_flags       = NBT_NM_GROUP,
6599                         .mhomed         = False,
6600                         .num_ips        = ctx->addresses_best_num,
6601                         .ips            = ctx->addresses_best,
6602                         .apply_expected = True
6603                 },
6604                 .defend = {
6605                         .timeout        = 0,
6606                 },
6607                 .replica= {
6608                         .type           = WREPL_TYPE_MHOMED,
6609                         .state          = WREPL_STATE_ACTIVE,
6610                         .node           = WREPL_NODE_B,
6611                         .is_static      = False,
6612                         .num_ips        = ctx->addresses_best_num,
6613                         .ips            = ctx->addresses_best,
6614                         .apply_expected = False
6615                 },
6616         },
6617         /*
6618          * group,active vs. mhomed,active with different ip(s), unchecked
6619          */
6620         {
6621                 .line   = __location__,
6622                 .name   = _NBT_NAME("_GA_MA_DI_U", 0x00, NULL),
6623                 .wins   = {
6624                         .nb_flags       = NBT_NM_GROUP,
6625                         .mhomed         = False,
6626                         .num_ips        = ctx->addresses_best_num,
6627                         .ips            = ctx->addresses_best,
6628                         .apply_expected = True
6629                 },
6630                 .defend = {
6631                         .timeout        = 0,
6632                 },
6633                 .replica= {
6634                         .type           = WREPL_TYPE_MHOMED,
6635                         .state          = WREPL_STATE_ACTIVE,
6636                         .node           = WREPL_NODE_B,
6637                         .is_static      = False,
6638                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
6639                         .ips            = addresses_B_3_4,
6640                         .apply_expected = False
6641                 },
6642         },
6643         /*
6644          * group,active vs. mhomed,tombstone with same ip(s), unchecked
6645          */
6646         {
6647                 .line   = __location__,
6648                 .name   = _NBT_NAME("_GA_MT_SI_U", 0x00, NULL),
6649                 .wins   = {
6650                         .nb_flags       = NBT_NM_GROUP,
6651                         .mhomed         = False,
6652                         .num_ips        = ctx->addresses_best_num,
6653                         .ips            = ctx->addresses_best,
6654                         .apply_expected = True
6655                 },
6656                 .defend = {
6657                         .timeout        = 0,
6658                 },
6659                 .replica= {
6660                         .type           = WREPL_TYPE_MHOMED,
6661                         .state          = WREPL_STATE_TOMBSTONE,
6662                         .node           = WREPL_NODE_B,
6663                         .is_static      = False,
6664                         .num_ips        = ctx->addresses_best_num,
6665                         .ips            = ctx->addresses_best,
6666                         .apply_expected = False
6667                 },
6668         },
6669         /*
6670          * group,active vs. mhomed,tombstone with different ip(s), unchecked
6671          */
6672         {
6673                 .line   = __location__,
6674                 .name   = _NBT_NAME("_GA_MT_DI_U", 0x00, NULL),
6675                 .wins   = {
6676                         .nb_flags       = NBT_NM_GROUP,
6677                         .mhomed         = False,
6678                         .num_ips        = ctx->addresses_best_num,
6679                         .ips            = ctx->addresses_best,
6680                         .apply_expected = True
6681                 },
6682                 .defend = {
6683                         .timeout        = 0,
6684                 },
6685                 .replica= {
6686                         .type           = WREPL_TYPE_MHOMED,
6687                         .state          = WREPL_STATE_TOMBSTONE,
6688                         .node           = WREPL_NODE_B,
6689                         .is_static      = False,
6690                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
6691                         .ips            = addresses_B_3_4,
6692                         .apply_expected = False
6693                 },
6694         },
6695 /* 
6696  * special group vs. unique section
6697  */
6698         /*
6699          * sgroup,active vs. unique,active with same ip(s), unchecked
6700          */
6701         {
6702                 .line   = __location__,
6703                 .name   = _NBT_NAME("_SA_UA_SI_U", 0x1C, NULL),
6704                 .wins   = {
6705                         .nb_flags       = NBT_NM_GROUP,
6706                         .mhomed         = False,
6707                         .num_ips        = ctx->addresses_best_num,
6708                         .ips            = ctx->addresses_best,
6709                         .apply_expected = True
6710                 },
6711                 .defend = {
6712                         .timeout        = 0,
6713                 },
6714                 .replica= {
6715                         .type           = WREPL_TYPE_UNIQUE,
6716                         .state          = WREPL_STATE_ACTIVE,
6717                         .node           = WREPL_NODE_B,
6718                         .is_static      = False,
6719                         .num_ips        = ctx->addresses_best_num,
6720                         .ips            = ctx->addresses_best,
6721                         .apply_expected = False
6722                 },
6723         },
6724         /*
6725          * sgroup,active vs. unique,active with different ip(s), unchecked
6726          */
6727         {
6728                 .line   = __location__,
6729                 .name   = _NBT_NAME("_SA_UA_DI_U", 0x1C, NULL),
6730                 .wins   = {
6731                         .nb_flags       = NBT_NM_GROUP,
6732                         .mhomed         = False,
6733                         .num_ips        = ctx->addresses_best_num,
6734                         .ips            = ctx->addresses_best,
6735                         .apply_expected = True
6736                 },
6737                 .defend = {
6738                         .timeout        = 0,
6739                 },
6740                 .replica= {
6741                         .type           = WREPL_TYPE_UNIQUE,
6742                         .state          = WREPL_STATE_ACTIVE,
6743                         .node           = WREPL_NODE_B,
6744                         .is_static      = False,
6745                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6746                         .ips            = addresses_B_1,
6747                         .apply_expected = False
6748                 },
6749         },
6750         /*
6751          * sgroup,active vs. unique,tombstone with same ip(s), unchecked
6752          */
6753         {
6754                 .line   = __location__,
6755                 .name   = _NBT_NAME("_SA_UT_SI_U", 0x1C, NULL),
6756                 .wins   = {
6757                         .nb_flags       = NBT_NM_GROUP,
6758                         .mhomed         = False,
6759                         .num_ips        = ctx->addresses_best_num,
6760                         .ips            = ctx->addresses_best,
6761                         .apply_expected = True
6762                 },
6763                 .defend = {
6764                         .timeout        = 0,
6765                 },
6766                 .replica= {
6767                         .type           = WREPL_TYPE_UNIQUE,
6768                         .state          = WREPL_STATE_TOMBSTONE,
6769                         .node           = WREPL_NODE_B,
6770                         .is_static      = False,
6771                         .num_ips        = ctx->addresses_best_num,
6772                         .ips            = ctx->addresses_best,
6773                         .apply_expected = False
6774                 },
6775         },
6776         /*
6777          * sgroup,active vs. unique,tombstone with different ip(s), unchecked
6778          */
6779         {
6780                 .line   = __location__,
6781                 .name   = _NBT_NAME("_SA_UT_DI_U", 0x1C, NULL),
6782                 .wins   = {
6783                         .nb_flags       = NBT_NM_GROUP,
6784                         .mhomed         = False,
6785                         .num_ips        = ctx->addresses_best_num,
6786                         .ips            = ctx->addresses_best,
6787                         .apply_expected = True
6788                 },
6789                 .defend = {
6790                         .timeout        = 0,
6791                 },
6792                 .replica= {
6793                         .type           = WREPL_TYPE_UNIQUE,
6794                         .state          = WREPL_STATE_TOMBSTONE,
6795                         .node           = WREPL_NODE_B,
6796                         .is_static      = False,
6797                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6798                         .ips            = addresses_B_1,
6799                         .apply_expected = False
6800                 },
6801         },
6802 /* 
6803  * special group vs. normal group section
6804  */
6805         /*
6806          * sgroup,active vs. group,active with same ip(s), unchecked
6807          */
6808         {
6809                 .line   = __location__,
6810                 .name   = _NBT_NAME("_SA_GA_SI_U", 0x1C, NULL),
6811                 .wins   = {
6812                         .nb_flags       = NBT_NM_GROUP,
6813                         .mhomed         = False,
6814                         .num_ips        = ctx->addresses_best_num,
6815                         .ips            = ctx->addresses_best,
6816                         .apply_expected = True
6817                 },
6818                 .defend = {
6819                         .timeout        = 0,
6820                 },
6821                 .replica= {
6822                         .type           = WREPL_TYPE_GROUP,
6823                         .state          = WREPL_STATE_ACTIVE,
6824                         .node           = WREPL_NODE_B,
6825                         .is_static      = False,
6826                         .num_ips        = ctx->addresses_best_num,
6827                         .ips            = ctx->addresses_best,
6828                         .apply_expected = False
6829                 },
6830         },
6831         /*
6832          * sgroup,active vs. group,active with different ip(s), unchecked
6833          */
6834         {
6835                 .line   = __location__,
6836                 .name   = _NBT_NAME("_SA_GA_DI_U", 0x1C, NULL),
6837                 .wins   = {
6838                         .nb_flags       = NBT_NM_GROUP,
6839                         .mhomed         = False,
6840                         .num_ips        = ctx->addresses_best_num,
6841                         .ips            = ctx->addresses_best,
6842                         .apply_expected = True
6843                 },
6844                 .defend = {
6845                         .timeout        = 0,
6846                 },
6847                 .replica= {
6848                         .type           = WREPL_TYPE_GROUP,
6849                         .state          = WREPL_STATE_ACTIVE,
6850                         .node           = WREPL_NODE_B,
6851                         .is_static      = False,
6852                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6853                         .ips            = addresses_B_1,
6854                         .apply_expected = False
6855                 },
6856         },
6857         /*
6858          * sgroup,active vs. group,tombstone with same ip(s), unchecked
6859          */
6860         {
6861                 .line   = __location__,
6862                 .name   = _NBT_NAME("_SA_GT_SI_U", 0x1C, NULL),
6863                 .wins   = {
6864                         .nb_flags       = NBT_NM_GROUP,
6865                         .mhomed         = False,
6866                         .num_ips        = ctx->addresses_best_num,
6867                         .ips            = ctx->addresses_best,
6868                         .apply_expected = True
6869                 },
6870                 .defend = {
6871                         .timeout        = 0,
6872                 },
6873                 .replica= {
6874                         .type           = WREPL_TYPE_GROUP,
6875                         .state          = WREPL_STATE_TOMBSTONE,
6876                         .node           = WREPL_NODE_B,
6877                         .is_static      = False,
6878                         .num_ips        = ctx->addresses_best_num,
6879                         .ips            = ctx->addresses_best,
6880                         .apply_expected = False
6881                 },
6882         },
6883         /*
6884          * sgroup,active vs. group,tombstone with different ip(s), unchecked
6885          */
6886         {
6887                 .line   = __location__,
6888                 .name   = _NBT_NAME("_SA_GT_DI_U", 0x1C, NULL),
6889                 .wins   = {
6890                         .nb_flags       = NBT_NM_GROUP,
6891                         .mhomed         = False,
6892                         .num_ips        = ctx->addresses_best_num,
6893                         .ips            = ctx->addresses_best,
6894                         .apply_expected = True
6895                 },
6896                 .defend = {
6897                         .timeout        = 0,
6898                 },
6899                 .replica= {
6900                         .type           = WREPL_TYPE_GROUP,
6901                         .state          = WREPL_STATE_TOMBSTONE,
6902                         .node           = WREPL_NODE_B,
6903                         .is_static      = False,
6904                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6905                         .ips            = addresses_B_1,
6906                         .apply_expected = False
6907                 },
6908         },
6909 /* 
6910  * special group vs. multi homed section
6911  */
6912         /*
6913          * sgroup,active vs. mhomed,active with same ip(s), unchecked
6914          */
6915         {
6916                 .line   = __location__,
6917                 .name   = _NBT_NAME("_SA_MA_SI_U", 0x1C, NULL),
6918                 .wins   = {
6919                         .nb_flags       = NBT_NM_GROUP,
6920                         .mhomed         = False,
6921                         .num_ips        = ctx->addresses_best_num,
6922                         .ips            = ctx->addresses_best,
6923                         .apply_expected = True
6924                 },
6925                 .defend = {
6926                         .timeout        = 0,
6927                 },
6928                 .replica= {
6929                         .type           = WREPL_TYPE_MHOMED,
6930                         .state          = WREPL_STATE_ACTIVE,
6931                         .node           = WREPL_NODE_B,
6932                         .is_static      = False,
6933                         .num_ips        = ctx->addresses_best_num,
6934                         .ips            = ctx->addresses_best,
6935                         .apply_expected = False
6936                 },
6937         },
6938         /*
6939          * sgroup,active vs. mhomed,active with different ip(s), unchecked
6940          */
6941         {
6942                 .line   = __location__,
6943                 .name   = _NBT_NAME("_SA_MA_DI_U", 0x1C, NULL),
6944                 .wins   = {
6945                         .nb_flags       = NBT_NM_GROUP,
6946                         .mhomed         = False,
6947                         .num_ips        = ctx->addresses_best_num,
6948                         .ips            = ctx->addresses_best,
6949                         .apply_expected = True
6950                 },
6951                 .defend = {
6952                         .timeout        = 0,
6953                 },
6954                 .replica= {
6955                         .type           = WREPL_TYPE_MHOMED,
6956                         .state          = WREPL_STATE_ACTIVE,
6957                         .node           = WREPL_NODE_B,
6958                         .is_static      = False,
6959                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6960                         .ips            = addresses_B_1,
6961                         .apply_expected = False
6962                 },
6963         },
6964         /*
6965          * sgroup,active vs. mhomed,tombstone with same ip(s), unchecked
6966          */
6967         {
6968                 .line   = __location__,
6969                 .name   = _NBT_NAME("_SA_MT_SI_U", 0x1C, NULL),
6970                 .wins   = {
6971                         .nb_flags       = NBT_NM_GROUP,
6972                         .mhomed         = False,
6973                         .num_ips        = ctx->addresses_best_num,
6974                         .ips            = ctx->addresses_best,
6975                         .apply_expected = True
6976                 },
6977                 .defend = {
6978                         .timeout        = 0,
6979                 },
6980                 .replica= {
6981                         .type           = WREPL_TYPE_MHOMED,
6982                         .state          = WREPL_STATE_TOMBSTONE,
6983                         .node           = WREPL_NODE_B,
6984                         .is_static      = False,
6985                         .num_ips        = ctx->addresses_best_num,
6986                         .ips            = ctx->addresses_best,
6987                         .apply_expected = False
6988                 },
6989         },
6990         /*
6991          * sgroup,active vs. mhomed,tombstone with different ip(s), unchecked
6992          */
6993         {
6994                 .line   = __location__,
6995                 .name   = _NBT_NAME("_SA_MT_DI_U", 0x1C, NULL),
6996                 .wins   = {
6997                         .nb_flags       = NBT_NM_GROUP,
6998                         .mhomed         = False,
6999                         .num_ips        = ctx->addresses_best_num,
7000                         .ips            = ctx->addresses_best,
7001                         .apply_expected = True
7002                 },
7003                 .defend = {
7004                         .timeout        = 0,
7005                 },
7006                 .replica= {
7007                         .type           = WREPL_TYPE_MHOMED,
7008                         .state          = WREPL_STATE_TOMBSTONE,
7009                         .node           = WREPL_NODE_B,
7010                         .is_static      = False,
7011                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7012                         .ips            = addresses_B_1,
7013                         .apply_expected = False
7014                 },
7015         },
7016 /* 
7017  * multi homed vs. unique section
7018  */
7019         /*
7020          * mhomed,active vs. unique,active with same ip(s), unchecked
7021          */
7022         {
7023                 .line   = __location__,
7024                 .name   = _NBT_NAME("_MA_UA_SI_U", 0x00, NULL),
7025                 .wins   = {
7026                         .nb_flags       = 0,
7027                         .mhomed         = True,
7028                         .num_ips        = ctx->addresses_best_num,
7029                         .ips            = ctx->addresses_best,
7030                         .apply_expected = True
7031                 },
7032                 .defend = {
7033                         .timeout        = 0,
7034                 },
7035                 .replica= {
7036                         .type           = WREPL_TYPE_UNIQUE,
7037                         .state          = WREPL_STATE_ACTIVE,
7038                         .node           = WREPL_NODE_B,
7039                         .is_static      = False,
7040                         .num_ips        = ctx->addresses_best_num,
7041                         .ips            = ctx->addresses_best,
7042                         .apply_expected = True
7043                 },
7044         },
7045         /*
7046          * mhomed,active vs. unique,active with different ip(s), positive response
7047          */
7048         {
7049                 .line   = __location__,
7050                 .name   = _NBT_NAME("_MA_UA_DI_P", 0x00, NULL),
7051                 .wins   = {
7052                         .nb_flags       = 0,
7053                         .mhomed         = True,
7054                         .num_ips        = ctx->addresses_best_num,
7055                         .ips            = ctx->addresses_best,
7056                         .apply_expected = True
7057                 },
7058                 .defend = {
7059                         .timeout        = 10,
7060                         .positive       = True,
7061                 },
7062                 .replica= {
7063                         .type           = WREPL_TYPE_UNIQUE,
7064                         .state          = WREPL_STATE_ACTIVE,
7065                         .node           = WREPL_NODE_B,
7066                         .is_static      = False,
7067                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7068                         .ips            = addresses_B_1,
7069                         .apply_expected = False
7070                 },
7071         },
7072         /*
7073          * mhomed,active vs. unique,active with different ip(s), positive response other ips
7074          */
7075         {
7076                 .line   = __location__,
7077                 .name   = _NBT_NAME("_MA_UA_DI_O", 0x00, NULL),
7078                 .wins   = {
7079                         .nb_flags       = 0,
7080                         .mhomed         = True,
7081                         .num_ips        = ctx->addresses_best_num,
7082                         .ips            = ctx->addresses_best,
7083                         .apply_expected = True
7084                 },
7085                 .defend = {
7086                         .timeout        = 10,
7087                         .positive       = True,
7088                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
7089                         .ips            = addresses_A_3_4,
7090                 },
7091                 .replica= {
7092                         .type           = WREPL_TYPE_UNIQUE,
7093                         .state          = WREPL_STATE_ACTIVE,
7094                         .node           = WREPL_NODE_B,
7095                         .is_static      = False,
7096                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7097                         .ips            = addresses_B_1,
7098                         .apply_expected = False
7099                 },
7100         },
7101         /*
7102          * mhomed,active vs. unique,active with different ip(s), negative response
7103          */
7104         {
7105                 .line   = __location__,
7106                 .name   = _NBT_NAME("_MA_UA_DI_N", 0x00, NULL),
7107                 .wins   = {
7108                         .nb_flags       = 0,
7109                         .mhomed         = True,
7110                         .num_ips        = ctx->addresses_best_num,
7111                         .ips            = ctx->addresses_best,
7112                         .apply_expected = True
7113                 },
7114                 .defend = {
7115                         .timeout        = 10,
7116                         .positive       = False,
7117                 },
7118                 .replica= {
7119                         .type           = WREPL_TYPE_UNIQUE,
7120                         .state          = WREPL_STATE_ACTIVE,
7121                         .node           = WREPL_NODE_B,
7122                         .is_static      = False,
7123                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7124                         .ips            = addresses_B_1,
7125                         .apply_expected = True
7126                 },
7127         },
7128         /*
7129          * mhomed,active vs. unique,tombstone with same ip(s), unchecked
7130          */
7131         {
7132                 .line   = __location__,
7133                 .name   = _NBT_NAME("_MA_UT_SI_U", 0x00, NULL),
7134                 .wins   = {
7135                         .nb_flags       = 0,
7136                         .mhomed         = True,
7137                         .num_ips        = ctx->addresses_best_num,
7138                         .ips            = ctx->addresses_best,
7139                         .apply_expected = True
7140                 },
7141                 .defend = {
7142                         .timeout        = 0,
7143                 },
7144                 .replica= {
7145                         .type           = WREPL_TYPE_UNIQUE,
7146                         .state          = WREPL_STATE_TOMBSTONE,
7147                         .node           = WREPL_NODE_B,
7148                         .is_static      = False,
7149                         .num_ips        = ctx->addresses_best_num,
7150                         .ips            = ctx->addresses_best,
7151                         .apply_expected = False
7152                 },
7153         },
7154         /*
7155          * mhomed,active vs. unique,tombstone with different ip(s), unchecked
7156          */
7157         {
7158                 .line   = __location__,
7159                 .name   = _NBT_NAME("_MA_UT_DI_U", 0x00, NULL),
7160                 .wins   = {
7161                         .nb_flags       = 0,
7162                         .mhomed         = True,
7163                         .num_ips        = ctx->addresses_best_num,
7164                         .ips            = ctx->addresses_best,
7165                         .apply_expected = True
7166                 },
7167                 .defend = {
7168                         .timeout        = 0,
7169                 },
7170                 .replica= {
7171                         .type           = WREPL_TYPE_UNIQUE,
7172                         .state          = WREPL_STATE_TOMBSTONE,
7173                         .node           = WREPL_NODE_B,
7174                         .is_static      = False,
7175                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7176                         .ips            = addresses_B_1,
7177                         .apply_expected = False
7178                 },
7179         },
7180 /* 
7181  * multi homed vs. normal group section
7182  */
7183         /*
7184          * mhomed,active vs. group,active with same ip(s), release expected
7185          */
7186         {
7187                 .line   = __location__,
7188                 .name   = _NBT_NAME("_MA_GA_SI_R", 0x00, NULL),
7189                 .wins   = {
7190                         .nb_flags       = 0,
7191                         .mhomed         = True,
7192                         .num_ips        = ctx->addresses_best_num,
7193                         .ips            = ctx->addresses_best,
7194                         .apply_expected = True
7195                 },
7196                 .defend = {
7197                         .timeout        = 10,
7198                         .expect_release = True,
7199                 },
7200                 .replica= {
7201                         .type           = WREPL_TYPE_GROUP,
7202                         .state          = WREPL_STATE_ACTIVE,
7203                         .node           = WREPL_NODE_B,
7204                         .is_static      = False,
7205                         .num_ips        = ctx->addresses_best_num,
7206                         .ips            = ctx->addresses_best,
7207                         .apply_expected = True
7208                 },
7209         },
7210         /*
7211          * mhomed,active vs. group,active with different ip(s), release expected
7212          */
7213         {
7214                 .line   = __location__,
7215                 .name   = _NBT_NAME("_MA_GA_DI_R", 0x00, NULL),
7216                 .wins   = {
7217                         .nb_flags       = 0,
7218                         .mhomed         = True,
7219                         .num_ips        = ctx->addresses_best_num,
7220                         .ips            = ctx->addresses_best,
7221                         .apply_expected = True
7222                 },
7223                 .defend = {
7224                         .timeout        = 10,
7225                         .expect_release = True,
7226                 },
7227                 .replica= {
7228                         .type           = WREPL_TYPE_GROUP,
7229                         .state          = WREPL_STATE_ACTIVE,
7230                         .node           = WREPL_NODE_B,
7231                         .is_static      = False,
7232                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7233                         .ips            = addresses_B_1,
7234                         .apply_expected = True
7235                 },
7236         },
7237         /*
7238          * mhomed,active vs. group,tombstone with same ip(s), unchecked
7239          */
7240         {
7241                 .line   = __location__,
7242                 .name   = _NBT_NAME("_MA_GT_SI_U", 0x00, NULL),
7243                 .wins   = {
7244                         .nb_flags       = 0,
7245                         .mhomed         = True,
7246                         .num_ips        = ctx->addresses_best_num,
7247                         .ips            = ctx->addresses_best,
7248                         .apply_expected = True
7249                 },
7250                 .defend = {
7251                         .timeout        = 0,
7252                 },
7253                 .replica= {
7254                         .type           = WREPL_TYPE_GROUP,
7255                         .state          = WREPL_STATE_TOMBSTONE,
7256                         .node           = WREPL_NODE_B,
7257                         .is_static      = False,
7258                         .num_ips        = ctx->addresses_best_num,
7259                         .ips            = ctx->addresses_best,
7260                         .apply_expected = False
7261                 },
7262         },
7263         /*
7264          * mhomed,active vs. group,tombstone with different ip(s), unchecked
7265          */
7266         {
7267                 .line   = __location__,
7268                 .name   = _NBT_NAME("_MA_GT_DI_U", 0x00, NULL),
7269                 .wins   = {
7270                         .nb_flags       = 0,
7271                         .mhomed         = True,
7272                         .num_ips        = ctx->addresses_best_num,
7273                         .ips            = ctx->addresses_best,
7274                         .apply_expected = True
7275                 },
7276                 .defend = {
7277                         .timeout        = 0,
7278                 },
7279                 .replica= {
7280                         .type           = WREPL_TYPE_GROUP,
7281                         .state          = WREPL_STATE_TOMBSTONE,
7282                         .node           = WREPL_NODE_B,
7283                         .is_static      = False,
7284                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7285                         .ips            = addresses_B_1,
7286                         .apply_expected = False
7287                 },
7288         },
7289 /* 
7290  * multi homed vs. special group section
7291  */
7292         /*
7293          * mhomed,active vs. sgroup,active with same ip(s), release expected
7294          */
7295         {
7296                 .line   = __location__,
7297                 .name   = _NBT_NAME("_MA_SA_SI_R", 0x00, NULL),
7298                 .wins   = {
7299                         .nb_flags       = 0,
7300                         .mhomed         = True,
7301                         .num_ips        = ctx->addresses_best_num,
7302                         .ips            = ctx->addresses_best,
7303                         .apply_expected = True
7304                 },
7305                 .defend = {
7306                         .timeout        = 10,
7307                         .expect_release = True,
7308                 },
7309                 .replica= {
7310                         .type           = WREPL_TYPE_SGROUP,
7311                         .state          = WREPL_STATE_ACTIVE,
7312                         .node           = WREPL_NODE_B,
7313                         .is_static      = False,
7314                         .num_ips        = ctx->addresses_best_num,
7315                         .ips            = ctx->addresses_best,
7316                         .apply_expected = True
7317                 },
7318         },
7319         /*
7320          * mhomed,active vs. group,active with different ip(s), release expected
7321          */
7322         {
7323                 .line   = __location__,
7324                 .name   = _NBT_NAME("_MA_SA_DI_R", 0x00, NULL),
7325                 .wins   = {
7326                         .nb_flags       = 0,
7327                         .mhomed         = True,
7328                         .num_ips        = ctx->addresses_best_num,
7329                         .ips            = ctx->addresses_best,
7330                         .apply_expected = True
7331                 },
7332                 .defend = {
7333                         .timeout        = 10,
7334                         .expect_release = True,
7335                 },
7336                 .replica= {
7337                         .type           = WREPL_TYPE_SGROUP,
7338                         .state          = WREPL_STATE_ACTIVE,
7339                         .node           = WREPL_NODE_B,
7340                         .is_static      = False,
7341                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7342                         .ips            = addresses_B_1,
7343                         .apply_expected = True
7344                 },
7345         },
7346         /*
7347          * mhomed,active vs. sgroup,tombstone with same ip(s), unchecked
7348          */
7349         {
7350                 .line   = __location__,
7351                 .name   = _NBT_NAME("_MA_ST_SI_U", 0x00, NULL),
7352                 .wins   = {
7353                         .nb_flags       = 0,
7354                         .mhomed         = True,
7355                         .num_ips        = ctx->addresses_best_num,
7356                         .ips            = ctx->addresses_best,
7357                         .apply_expected = True
7358                 },
7359                 .defend = {
7360                         .timeout        = 0,
7361                 },
7362                 .replica= {
7363                         .type           = WREPL_TYPE_SGROUP,
7364                         .state          = WREPL_STATE_TOMBSTONE,
7365                         .node           = WREPL_NODE_B,
7366                         .is_static      = False,
7367                         .num_ips        = ctx->addresses_best_num,
7368                         .ips            = ctx->addresses_best,
7369                         .apply_expected = False
7370                 },
7371         },
7372         /*
7373          * mhomed,active vs. sgroup,tombstone with different ip(s), unchecked
7374          */
7375         {
7376                 .line   = __location__,
7377                 .name   = _NBT_NAME("_MA_ST_DI_U", 0x00, NULL),
7378                 .wins   = {
7379                         .nb_flags       = 0,
7380                         .mhomed         = True,
7381                         .num_ips        = ctx->addresses_best_num,
7382                         .ips            = ctx->addresses_best,
7383                         .apply_expected = True
7384                 },
7385                 .defend = {
7386                         .timeout        = 0,
7387                 },
7388                 .replica= {
7389                         .type           = WREPL_TYPE_SGROUP,
7390                         .state          = WREPL_STATE_TOMBSTONE,
7391                         .node           = WREPL_NODE_B,
7392                         .is_static      = False,
7393                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7394                         .ips            = addresses_B_1,
7395                         .apply_expected = False
7396                 },
7397         },
7398 /* 
7399  * multi homed vs. multi homed section
7400  */
7401         /*
7402          * mhomed,active vs. mhomed,active with same ip(s), unchecked
7403          */
7404         {
7405                 .line   = __location__,
7406                 .name   = _NBT_NAME("_MA_MA_SI_U", 0x00, NULL),
7407                 .wins   = {
7408                         .nb_flags       = 0,
7409                         .mhomed         = True,
7410                         .num_ips        = ctx->addresses_best_num,
7411                         .ips            = ctx->addresses_best,
7412                         .apply_expected = True
7413                 },
7414                 .defend = {
7415                         .timeout        = 0,
7416                 },
7417                 .replica= {
7418                         .type           = WREPL_TYPE_MHOMED,
7419                         .state          = WREPL_STATE_ACTIVE,
7420                         .node           = WREPL_NODE_B,
7421                         .is_static      = False,
7422                         .num_ips        = ctx->addresses_best_num,
7423                         .ips            = ctx->addresses_best,
7424                         .apply_expected = True
7425                 },
7426         },
7427         /*
7428          * mhomed,active vs. mhomed,active with superset ip(s), unchecked
7429          */
7430         {
7431                 .line   = __location__,
7432                 .name   = _NBT_NAME("_MA_MA_SP_U", 0x00, NULL),
7433                 .wins   = {
7434                         .nb_flags       = 0,
7435                         .mhomed         = True,
7436                         .num_ips        = ctx->addresses_best_num,
7437                         .ips            = ctx->addresses_best,
7438                         .apply_expected = True
7439                 },
7440                 .defend = {
7441                         .timeout        = 0,
7442                 },
7443                 .replica= {
7444                         .type           = WREPL_TYPE_MHOMED,
7445                         .state          = WREPL_STATE_ACTIVE,
7446                         .node           = WREPL_NODE_B,
7447                         .is_static      = False,
7448                         .num_ips        = ctx->addresses_all_num,
7449                         .ips            = ctx->addresses_all,
7450                         .apply_expected = True
7451                 },
7452         },
7453         /*
7454          * mhomed,active vs. mhomed,active with different ip(s), positive response
7455          */
7456         {
7457                 .line   = __location__,
7458                 .name   = _NBT_NAME("_MA_MA_DI_P", 0x00, NULL),
7459                 .wins   = {
7460                         .nb_flags       = 0,
7461                         .mhomed         = True,
7462                         .num_ips        = ctx->addresses_best_num,
7463                         .ips            = ctx->addresses_best,
7464                         .apply_expected = True
7465                 },
7466                 .defend = {
7467                         .timeout        = 10,
7468                         .positive       = True,
7469                 },
7470                 .replica= {
7471                         .type           = WREPL_TYPE_MHOMED,
7472                         .state          = WREPL_STATE_ACTIVE,
7473                         .node           = WREPL_NODE_B,
7474                         .is_static      = False,
7475                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7476                         .ips            = addresses_B_3_4,
7477                         .apply_expected = False
7478                 },
7479         },
7480         /*
7481          * mhomed,active vs. mhomed,active with different ip(s), positive response other ips
7482          */
7483         {
7484                 .line   = __location__,
7485                 .name   = _NBT_NAME("_MA_MA_DI_O", 0x00, NULL),
7486                 .wins   = {
7487                         .nb_flags       = 0,
7488                         .mhomed         = True,
7489                         .num_ips        = ctx->addresses_best_num,
7490                         .ips            = ctx->addresses_best,
7491                         .apply_expected = True
7492                 },
7493                 .defend = {
7494                         .timeout        = 10,
7495                         .positive       = True,
7496                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
7497                         .ips            = addresses_A_3_4,
7498                 },
7499                 .replica= {
7500                         .type           = WREPL_TYPE_MHOMED,
7501                         .state          = WREPL_STATE_ACTIVE,
7502                         .node           = WREPL_NODE_B,
7503                         .is_static      = False,
7504                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7505                         .ips            = addresses_B_3_4,
7506                         .apply_expected = False
7507                 },
7508         },
7509         /*
7510          * mhomed,active vs. mhomed,active with different ip(s), negative response
7511          */
7512         {
7513                 .line   = __location__,
7514                 .name   = _NBT_NAME("_MA_MA_DI_N", 0x00, NULL),
7515                 .wins   = {
7516                         .nb_flags       = 0,
7517                         .mhomed         = True,
7518                         .num_ips        = ctx->addresses_best_num,
7519                         .ips            = ctx->addresses_best,
7520                         .apply_expected = True
7521                 },
7522                 .defend = {
7523                         .timeout        = 10,
7524                         .positive       = False,
7525                 },
7526                 .replica= {
7527                         .type           = WREPL_TYPE_MHOMED,
7528                         .state          = WREPL_STATE_ACTIVE,
7529                         .node           = WREPL_NODE_B,
7530                         .is_static      = False,
7531                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7532                         .ips            = addresses_B_3_4,
7533                         .apply_expected = True
7534                 },
7535         },
7536         /*
7537          * mhomed,active vs. mhomed,tombstone with same ip(s), unchecked
7538          */
7539         {
7540                 .line   = __location__,
7541                 .name   = _NBT_NAME("_MA_MT_SI_U", 0x00, NULL),
7542                 .wins   = {
7543                         .nb_flags       = 0,
7544                         .mhomed         = True,
7545                         .num_ips        = ctx->addresses_best_num,
7546                         .ips            = ctx->addresses_best,
7547                         .apply_expected = True
7548                 },
7549                 .defend = {
7550                         .timeout        = 0,
7551                 },
7552                 .replica= {
7553                         .type           = WREPL_TYPE_MHOMED,
7554                         .state          = WREPL_STATE_TOMBSTONE,
7555                         .node           = WREPL_NODE_B,
7556                         .is_static      = False,
7557                         .num_ips        = ctx->addresses_best_num,
7558                         .ips            = ctx->addresses_best,
7559                         .apply_expected = False
7560                 },
7561         },
7562         /*
7563          * mhomed,active vs. mhomed,tombstone with different ip(s), unchecked
7564          */
7565         {
7566                 .line   = __location__,
7567                 .name   = _NBT_NAME("_MA_MT_DI_U", 0x00, NULL),
7568                 .wins   = {
7569                         .nb_flags       = 0,
7570                         .mhomed         = True,
7571                         .num_ips        = ctx->addresses_best_num,
7572                         .ips            = ctx->addresses_best,
7573                         .apply_expected = True
7574                 },
7575                 .defend = {
7576                         .timeout        = 0,
7577                 },
7578                 .replica= {
7579                         .type           = WREPL_TYPE_MHOMED,
7580                         .state          = WREPL_STATE_TOMBSTONE,
7581                         .node           = WREPL_NODE_B,
7582                         .is_static      = False,
7583                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7584                         .ips            = addresses_B_3_4,
7585                         .apply_expected = False
7586                 },
7587         },
7588 /*
7589  * some more multi homed test, including merging
7590  */
7591         /*
7592          * mhomed,active vs. mhomed,active with superset ip(s), unchecked
7593          */
7594         {
7595                 .line   = __location__,
7596                 .section= "Test Replica vs. owned active: some more MHOMED combinations",
7597                 .name   = _NBT_NAME("_MA_MA_SP_U", 0x00, NULL),
7598                 .skip   = (ctx->addresses_all_num < 3),
7599                 .wins   = {
7600                         .nb_flags       = 0,
7601                         .mhomed         = True,
7602                         .num_ips        = ctx->addresses_mhomed_num,
7603                         .ips            = ctx->addresses_mhomed,
7604                         .apply_expected = True
7605                 },
7606                 .defend = {
7607                         .timeout        = 0,
7608                 },
7609                 .replica= {
7610                         .type           = WREPL_TYPE_MHOMED,
7611                         .state          = WREPL_STATE_ACTIVE,
7612                         .node           = WREPL_NODE_B,
7613                         .is_static      = False,
7614                         .num_ips        = ctx->addresses_all_num,
7615                         .ips            = ctx->addresses_all,
7616                         .apply_expected = True
7617                 },
7618         },
7619         /*
7620          * mhomed,active vs. mhomed,active with same ips, unchecked
7621          */
7622         {
7623                 .line   = __location__,
7624                 .name   = _NBT_NAME("_MA_MA_SM_U", 0x00, NULL),
7625                 .skip   = (ctx->addresses_mhomed_num != 2),
7626                 .wins   = {
7627                         .nb_flags       = 0,
7628                         .mhomed         = True,
7629                         .num_ips        = ctx->addresses_mhomed_num,
7630                         .ips            = ctx->addresses_mhomed,
7631                         .apply_expected = True
7632                 },
7633                 .defend = {
7634                         .timeout        = 0,
7635                 },
7636                 .replica= {
7637                         .type           = WREPL_TYPE_MHOMED,
7638                         .state          = WREPL_STATE_ACTIVE,
7639                         .node           = WREPL_NODE_B,
7640                         .is_static      = False,
7641                         .num_ips        = ctx->addresses_mhomed_num,
7642                         .ips            = ctx->addresses_mhomed,
7643                         .apply_expected = True
7644                 },
7645         },
7646         /*
7647          * mhomed,active vs. mhomed,active with subset ip(s), positive response
7648          */
7649         {
7650                 .line   = __location__,
7651                 .name   = _NBT_NAME("_MA_MA_SB_P", 0x00, NULL),
7652                 .skip   = (ctx->addresses_mhomed_num != 2),
7653                 .wins   = {
7654                         .nb_flags       = 0,
7655                         .mhomed         = True,
7656                         .num_ips        = ctx->addresses_mhomed_num,
7657                         .ips            = ctx->addresses_mhomed,
7658                         .apply_expected = True
7659                 },
7660                 .defend = {
7661                         .timeout        = 10,
7662                         .positive       = True
7663                 },
7664                 .replica= {
7665                         .type           = WREPL_TYPE_MHOMED,
7666                         .state          = WREPL_STATE_ACTIVE,
7667                         .node           = WREPL_NODE_B,
7668                         .is_static      = False,
7669                         .num_ips        = ctx->addresses_best_num,
7670                         .ips            = ctx->addresses_best,
7671                         .mhomed_merge   = True
7672                 },
7673         },
7674         /*
7675          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with all addresses
7676          */
7677         {
7678                 .line   = __location__,
7679                 .name   = _NBT_NAME("_MA_MA_SB_A", 0x00, NULL),
7680                 .skip   = (ctx->addresses_all_num < 3),
7681                 .wins   = {
7682                         .nb_flags       = 0,
7683                         .mhomed         = True,
7684                         .num_ips        = ctx->addresses_mhomed_num,
7685                         .ips            = ctx->addresses_mhomed,
7686                         .apply_expected = True
7687                 },
7688                 .defend = {
7689                         .timeout        = 10,
7690                         .positive       = True,
7691                         .num_ips        = ctx->addresses_all_num,
7692                         .ips            = ctx->addresses_all,
7693                 },
7694                 .replica= {
7695                         .type           = WREPL_TYPE_MHOMED,
7696                         .state          = WREPL_STATE_ACTIVE,
7697                         .node           = WREPL_NODE_B,
7698                         .is_static      = False,
7699                         .num_ips        = ctx->addresses_best_num,
7700                         .ips            = ctx->addresses_best,
7701                         .mhomed_merge   = True
7702                 },
7703         },
7704         /*
7705          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with replicas addresses
7706  * TODO: here we got a release demand for the replica address from the server after doing
7707  *       a positive response with the replicas addresses
7708          */
7709         {
7710                 .line   = __location__,
7711                 .name   = _NBT_NAME("_MA_MA_SB_C", 0x00, NULL),
7712                 .skip   = (True /*ctx->addresses_all_num < 3*/),
7713                 .wins   = {
7714                         .nb_flags       = 0,
7715                         .mhomed         = True,
7716                         .num_ips        = ctx->addresses_mhomed_num,
7717                         .ips            = ctx->addresses_mhomed,
7718                         .apply_expected = True
7719                 },
7720                 .defend = {
7721                         .timeout        = 10,
7722                         .positive       = True,
7723                         .num_ips        = ctx->addresses_best_num,
7724                         .ips            = ctx->addresses_best,
7725                 },
7726                 .replica= {
7727                         .type           = WREPL_TYPE_MHOMED,
7728                         .state          = WREPL_STATE_ACTIVE,
7729                         .node           = WREPL_NODE_B,
7730                         .is_static      = False,
7731                         .num_ips        = ctx->addresses_best_num,
7732                         .ips            = ctx->addresses_best,
7733                         .apply_expected = False
7734                 },
7735         },
7736         /*
7737          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with other addresses
7738  * TODO: here the record is not applied and the old record becomes released
7739          */
7740         {
7741                 .line   = __location__,
7742                 .name   = _NBT_NAME("_MA_MA_SB_O", 0x00, NULL),
7743
7744                 .skip   = (True /*ctx->addresses_all_num < 3*/),
7745                 .wins   = {
7746                         .nb_flags       = 0,
7747                         .mhomed         = True,
7748                         .num_ips        = ctx->addresses_mhomed_num,
7749                         .ips            = ctx->addresses_mhomed,
7750                         .apply_expected = True
7751                 },
7752                 .defend = {
7753                         .timeout        = 10,
7754                         .positive       = True,
7755                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7756                         .ips            = addresses_B_3_4,
7757                 },
7758                 .replica= {
7759                         .type           = WREPL_TYPE_MHOMED,
7760                         .state          = WREPL_STATE_ACTIVE,
7761                         .node           = WREPL_NODE_B,
7762                         .is_static      = False,
7763                         .num_ips        = ctx->addresses_best_num,
7764                         .ips            = ctx->addresses_best,
7765                         .apply_expected = False
7766                 },
7767         },
7768         /*
7769          * mhomed,active vs. mhomed,active with subset ip(s), negative response
7770          */
7771         {
7772                 .line   = __location__,
7773                 .name   = _NBT_NAME("_MA_MA_SB_N", 0x00, NULL),
7774                 .skip   = (ctx->addresses_mhomed_num != 2),
7775                 .wins   = {
7776                         .nb_flags       = 0,
7777                         .mhomed         = True,
7778                         .num_ips        = ctx->addresses_mhomed_num,
7779                         .ips            = ctx->addresses_mhomed,
7780                         .apply_expected = True
7781                 },
7782                 .defend = {
7783                         .timeout        = 10,
7784                         .positive       = False
7785                 },
7786                 .replica= {
7787                         .type           = WREPL_TYPE_MHOMED,
7788                         .state          = WREPL_STATE_ACTIVE,
7789                         .node           = WREPL_NODE_B,
7790                         .is_static      = False,
7791                         .num_ips        = ctx->addresses_best_num,
7792                         .ips            = ctx->addresses_best,
7793                         .apply_expected = True
7794                 },
7795         },
7796 /*
7797  * some more multi homed and unique test, including merging
7798  */
7799         /*
7800          * mhomed,active vs. unique,active with subset ip(s), positive response
7801          */
7802         {
7803                 .line   = __location__,
7804                 .section= "Test Replica vs. owned active: some more UNIQUE,MHOMED combinations",
7805                 .name   = _NBT_NAME("_MA_UA_SB_A", 0x00, NULL),
7806                 .skip   = (ctx->addresses_all_num < 3),
7807                 .wins   = {
7808                         .nb_flags       = 0,
7809                         .mhomed         = True,
7810                         .num_ips        = ctx->addresses_mhomed_num,
7811                         .ips            = ctx->addresses_mhomed,
7812                         .apply_expected = True
7813                 },
7814                 .defend = {
7815                         .timeout        = 10,
7816                         .positive       = True,
7817                 },
7818                 .replica= {
7819                         .type           = WREPL_TYPE_UNIQUE,
7820                         .state          = WREPL_STATE_ACTIVE,
7821                         .node           = WREPL_NODE_B,
7822                         .is_static      = False,
7823                         .num_ips        = ctx->addresses_best_num,
7824                         .ips            = ctx->addresses_best,
7825                         .mhomed_merge   = True
7826                 },
7827         },
7828         /*
7829          * unique,active vs. unique,active with different ip(s), positive response, with all addresses
7830          */
7831         {
7832                 .line   = __location__,
7833                 .name   = _NBT_NAME("_UA_UA_DI_A", 0x00, NULL),
7834                 .skip   = (ctx->addresses_all_num < 3),
7835                 .wins   = {
7836                         .nb_flags       = 0,
7837                         .mhomed         = False,
7838                         .num_ips        = ctx->addresses_best_num,
7839                         .ips            = ctx->addresses_best,
7840                         .apply_expected = True
7841                 },
7842                 .defend = {
7843                         .timeout        = 10,
7844                         .positive       = True,
7845                         .num_ips        = ctx->addresses_all_num,
7846                         .ips            = ctx->addresses_all,
7847                 },
7848                 .replica= {
7849                         .type           = WREPL_TYPE_UNIQUE,
7850                         .state          = WREPL_STATE_ACTIVE,
7851                         .node           = WREPL_NODE_B,
7852                         .is_static      = False,
7853                         .num_ips        = ctx->addresses_best2_num,
7854                         .ips            = ctx->addresses_best2,
7855                         .mhomed_merge   = True,
7856                 },
7857         },
7858         /*
7859          * unique,active vs. mhomed,active with different ip(s), positive response, with all addresses
7860          */
7861         {
7862                 .line   = __location__,
7863                 .name   = _NBT_NAME("_UA_MA_DI_A", 0x00, NULL),
7864                 .skip   = (ctx->addresses_all_num < 3),
7865                 .wins   = {
7866                         .nb_flags       = 0,
7867                         .mhomed         = False,
7868                         .num_ips        = ctx->addresses_best_num,
7869                         .ips            = ctx->addresses_best,
7870                         .apply_expected = True
7871                 },
7872                 .defend = {
7873                         .timeout        = 10,
7874                         .positive       = True,
7875                         .num_ips        = ctx->addresses_all_num,
7876                         .ips            = ctx->addresses_all,
7877                 },
7878                 .replica= {
7879                         .type           = WREPL_TYPE_MHOMED,
7880                         .state          = WREPL_STATE_ACTIVE,
7881                         .node           = WREPL_NODE_B,
7882                         .is_static      = False,
7883                         .num_ips        = ctx->addresses_best2_num,
7884                         .ips            = ctx->addresses_best2,
7885                         .mhomed_merge   = True,
7886                 },
7887         },
7888         };
7889
7890         if (!ctx) return False;
7891
7892         if (!ctx->nbtsock_srv) {
7893                 printf("SKIP: Test Replica records vs. owned active records: not bound to port[%d]\n",
7894                         lp_nbt_port());
7895                 return True;
7896         }
7897
7898         printf("Test Replica records vs. owned active records\n");
7899
7900         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
7901                 struct timeval end;
7902                 struct test_conflict_owned_active_vs_replica_struct record = records[i];
7903                 uint32_t j, count = 1;
7904                 const char *action;
7905
7906                 if (records[i].wins.mhomed) {
7907                         count = records[i].wins.num_ips;
7908                 }
7909
7910                 if (records[i].section) {
7911                         printf("%s\n", records[i].section);
7912                 }
7913
7914                 if (records[i].skip) {
7915                         printf("%s => SKIPPED\n", nbt_name_string(ctx, &records[i].name));
7916                         continue;
7917                 }
7918
7919                 if (records[i].replica.mhomed_merge) {
7920                         action = "MHOMED_MERGE";
7921                 } else if (records[i].replica.apply_expected) {
7922                         action = "REPLACE";
7923                 } else {
7924                         action = "NOT REPLACE";
7925                 }
7926
7927                 printf("%s => %s\n", nbt_name_string(ctx, &records[i].name), action);
7928
7929                 /* Prepare for multi homed registration */
7930                 ZERO_STRUCT(records[i].defend);
7931                 records[i].defend.timeout       = 10;
7932                 records[i].defend.positive      = True;
7933                 nbt_set_incoming_handler(ctx->nbtsock_srv,
7934                                          test_conflict_owned_active_vs_replica_handler,
7935                                          &records[i]);
7936                 if (ctx->nbtsock_srv2) {
7937                         nbt_set_incoming_handler(ctx->nbtsock_srv2,
7938                                                  test_conflict_owned_active_vs_replica_handler,
7939                                                  &records[i]);
7940                 }
7941
7942                 /*
7943                  * Setup Register
7944                  */
7945                 for (j=0; j < count; j++) {
7946                         struct nbt_name_request *req;
7947
7948                         name_register->in.name          = records[i].name;
7949                         name_register->in.dest_addr     = ctx->address;
7950                         name_register->in.address       = records[i].wins.ips[j].ip;
7951                         name_register->in.nb_flags      = records[i].wins.nb_flags;
7952                         name_register->in.register_demand= False;
7953                         name_register->in.broadcast     = False;
7954                         name_register->in.multi_homed   = records[i].wins.mhomed;
7955                         name_register->in.ttl           = 300000;
7956                         name_register->in.timeout       = 70;
7957                         name_register->in.retries       = 0;
7958
7959                         req = nbt_name_register_send(ctx->nbtsock, name_register);
7960
7961                         /* push the request on the wire */
7962                         event_loop_once(ctx->nbtsock->event_ctx);
7963
7964                         /*
7965                          * if we register multiple addresses,
7966                          * the server will do name queries to see if the old addresses
7967                          * are still alive
7968                          */
7969                         if (j > 0) {
7970                                 end = timeval_current_ofs(records[i].defend.timeout,0);
7971                                 records[i].defend.ret = True;
7972                                 while (records[i].defend.timeout > 0) {
7973                                         event_loop_once(ctx->nbtsock_srv->event_ctx);
7974                                         if (timeval_expired(&end)) break;
7975                                 }
7976                                 ret &= records[i].defend.ret;
7977                         }
7978
7979                         status = nbt_name_register_recv(req, ctx, name_register);
7980                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
7981                                 printf("No response from %s for name register\n", ctx->address);
7982                                 ret = False;
7983                         }
7984                         if (!NT_STATUS_IS_OK(status)) {
7985                                 printf("Bad response from %s for name register - %s\n",
7986                                        ctx->address, nt_errstr(status));
7987                                 ret = False;
7988                         }
7989                         CHECK_VALUE(name_register->out.rcode, 0);
7990                         CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address);
7991                         CHECK_VALUE(name_register->out.name.type, records[i].name.type);
7992                         CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name);
7993                         CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope);
7994                         CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[j].ip);
7995                 }
7996
7997                 /* Prepare for the current test */
7998                 records[i].defend = record.defend;
7999                 nbt_set_incoming_handler(ctx->nbtsock_srv,
8000                                          test_conflict_owned_active_vs_replica_handler,
8001                                          &records[i]);
8002                 if (ctx->nbtsock_srv2) {
8003                         nbt_set_incoming_handler(ctx->nbtsock_srv2,
8004                                                  test_conflict_owned_active_vs_replica_handler,
8005                                                  &records[i]);
8006                 }
8007
8008                 /*
8009                  * Setup Replica
8010                  */
8011                 wins_name->name         = &records[i].name;
8012                 wins_name->flags        = WREPL_NAME_FLAGS(records[i].replica.type,
8013                                                            records[i].replica.state,
8014                                                            records[i].replica.node,
8015                                                            records[i].replica.is_static);
8016                 wins_name->id           = ++ctx->b.max_version;
8017                 if (wins_name->flags & 2) {
8018                         wins_name->addresses.addresses.num_ips = records[i].replica.num_ips;
8019                         wins_name->addresses.addresses.ips     = discard_const(records[i].replica.ips);
8020                 } else {
8021                         wins_name->addresses.ip = records[i].replica.ips[0].ip;
8022                 }
8023                 wins_name->unknown      = "255.255.255.255";
8024
8025                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
8026
8027                 /*
8028                  * wait for the name query, which is handled in
8029                  * test_conflict_owned_active_vs_replica_handler()
8030                  */
8031                 end = timeval_current_ofs(records[i].defend.timeout,0);
8032                 records[i].defend.ret = True;
8033                 while (records[i].defend.timeout > 0) {
8034                         event_loop_once(ctx->nbtsock_srv->event_ctx);
8035                         if (timeval_expired(&end)) break;
8036                 }
8037                 ret &= records[i].defend.ret;
8038
8039                 if (records[i].replica.mhomed_merge) {
8040                         ret &= test_wrepl_mhomed_merged(ctx, &ctx->c,
8041                                                         records[i].wins.num_ips, records[i].wins.ips,
8042                                                         &ctx->b,
8043                                                         records[i].replica.num_ips, records[i].replica.ips,
8044                                                         wins_name);
8045                 } else {
8046                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name,
8047                                                      records[i].replica.apply_expected);
8048                 }
8049
8050                 if (records[i].replica.apply_expected ||
8051                     records[i].replica.mhomed_merge) {
8052                         wins_name->name         = &records[i].name;
8053                         wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
8054                                                                    WREPL_STATE_TOMBSTONE,
8055                                                                    WREPL_NODE_B, False);
8056                         wins_name->id           = ++ctx->b.max_version;
8057                         wins_name->addresses.ip = addresses_B_1[0].ip;
8058                         wins_name->unknown      = "255.255.255.255";
8059
8060                         ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
8061                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
8062                 } else {
8063                         for (j=0; j < count; j++) {
8064                                 struct nbt_name_socket *nbtsock = ctx->nbtsock;
8065
8066                                 if (ctx->myaddr && strcmp(records[i].wins.ips[j].ip, ctx->myaddr2) == 0) {
8067                                         nbtsock = ctx->nbtsock2;
8068                                 }
8069
8070                                 release->in.name        = records[i].name;
8071                                 release->in.dest_addr   = ctx->address;
8072                                 release->in.address     = records[i].wins.ips[j].ip;
8073                                 release->in.nb_flags    = records[i].wins.nb_flags;
8074                                 release->in.broadcast   = False;
8075                                 release->in.timeout     = 30;
8076                                 release->in.retries     = 0;
8077
8078                                 status = nbt_name_release(nbtsock, ctx, release);
8079                                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
8080                                         printf("No response from %s for name release\n", ctx->address);
8081                                         return False;
8082                                 }
8083                                 if (!NT_STATUS_IS_OK(status)) {
8084                                         printf("Bad response from %s for name query - %s\n",
8085                                                ctx->address, nt_errstr(status));
8086                                         return False;
8087                                 }
8088                                 CHECK_VALUE(release->out.rcode, 0);
8089                         }
8090                 }
8091
8092 done:
8093                 if (!ret) {
8094                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
8095                         return ret;
8096                 }
8097         }
8098
8099         return ret;
8100 }
8101
8102 #define _NBT_ASSERT(v, correct) do { \
8103         if ((v) != (correct)) { \
8104                 printf("(%s) Incorrect value %s=%d - should be %s (%d)\n", \
8105                        __location__, #v, v, #correct, correct); \
8106                 return; \
8107         } \
8108 } while (0)
8109
8110 #define _NBT_ASSERT_STRING(v, correct) do { \
8111         if ( ((!v) && (correct)) || \
8112              ((v) && (!correct)) || \
8113              ((v) && (correct) && strcmp(v,correct) != 0)) { \
8114                 printf("(%s) Incorrect value %s=%s - should be %s\n", \
8115                        __location__, #v, v, correct); \
8116                 return; \
8117         } \
8118 } while (0)
8119
8120 static void test_conflict_owned_active_vs_replica_handler_query(struct nbt_name_socket *nbtsock, 
8121                                                                 struct nbt_name_packet *req_packet, 
8122                                                                 const struct nbt_peer_socket *src)
8123 {
8124         struct nbt_name *name;
8125         struct nbt_name_packet *rep_packet;
8126         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
8127
8128         _NBT_ASSERT(req_packet->qdcount, 1);
8129         _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS);
8130         _NBT_ASSERT(req_packet->questions[0].question_class, NBT_QCLASS_IP);
8131
8132         name = &req_packet->questions[0].name;
8133
8134         _NBT_ASSERT(name->type, rec->name.type);
8135         _NBT_ASSERT_STRING(name->name, rec->name.name);
8136         _NBT_ASSERT_STRING(name->scope, rec->name.scope);
8137
8138         _NBT_ASSERT(rec->defend.expect_release, False);
8139
8140         rep_packet = talloc_zero(nbtsock, struct nbt_name_packet);
8141         if (rep_packet == NULL) return;
8142
8143         rep_packet->name_trn_id = req_packet->name_trn_id;
8144         rep_packet->ancount     = 1;
8145
8146         rep_packet->answers     = talloc_array(rep_packet, struct nbt_res_rec, 1);
8147         if (rep_packet->answers == NULL) return;
8148
8149         rep_packet->answers[0].name      = *name;
8150         rep_packet->answers[0].rr_class  = NBT_QCLASS_IP;
8151         rep_packet->answers[0].ttl       = 0;
8152
8153         if (rec->defend.positive) {
8154                 uint32_t i, num_ips;
8155                 const struct wrepl_ip *ips;             
8156
8157                 if (rec->defend.num_ips > 0) {
8158                         num_ips = rec->defend.num_ips;
8159                         ips     = rec->defend.ips;
8160                 } else {
8161                         num_ips = rec->wins.num_ips;
8162                         ips     = rec->wins.ips;
8163                 }
8164
8165                 /* send a positive reply */
8166                 rep_packet->operation   = 
8167                                         NBT_FLAG_REPLY | 
8168                                         NBT_OPCODE_QUERY | 
8169                                         NBT_FLAG_AUTHORITIVE |
8170                                         NBT_FLAG_RECURSION_DESIRED |
8171                                         NBT_FLAG_RECURSION_AVAIL;
8172
8173                 rep_packet->answers[0].rr_type   = NBT_QTYPE_NETBIOS;
8174
8175                 rep_packet->answers[0].rdata.netbios.length = num_ips*6;
8176                 rep_packet->answers[0].rdata.netbios.addresses = 
8177                         talloc_array(rep_packet->answers, struct nbt_rdata_address, num_ips);
8178                 if (rep_packet->answers[0].rdata.netbios.addresses == NULL) return;
8179
8180                 for (i=0; i < num_ips; i++) {
8181                         struct nbt_rdata_address *addr = 
8182                                 &rep_packet->answers[0].rdata.netbios.addresses[i];
8183                         addr->nb_flags  = rec->wins.nb_flags;
8184                         addr->ipaddr    = ips[i].ip;
8185                 }
8186                 DEBUG(2,("Sending positive name query reply for %s to %s:%d\n", 
8187                         nbt_name_string(rep_packet, name), src->addr, src->port));
8188         } else {
8189                 /* send a negative reply */
8190                 rep_packet->operation   =
8191                                         NBT_FLAG_REPLY | 
8192                                         NBT_OPCODE_QUERY | 
8193                                         NBT_FLAG_AUTHORITIVE |
8194                                         NBT_RCODE_NAM;
8195
8196                 rep_packet->answers[0].rr_type   = NBT_QTYPE_NULL;
8197
8198                 ZERO_STRUCT(rep_packet->answers[0].rdata);
8199
8200                 DEBUG(2,("Sending negative name query reply for %s to %s:%d\n", 
8201                         nbt_name_string(rep_packet, name), src->addr, src->port));
8202         }
8203
8204         nbt_name_reply_send(nbtsock, src, rep_packet);
8205         talloc_free(rep_packet);
8206
8207         /* make sure we push the reply to the wire */
8208         event_loop_once(nbtsock->event_ctx);
8209
8210         rec->defend.timeout     = 0;
8211         rec->defend.ret         = True;
8212 }
8213
8214 static void test_conflict_owned_active_vs_replica_handler_release(struct nbt_name_socket *nbtsock, 
8215                                                                   struct nbt_name_packet *req_packet, 
8216                                                                   const struct nbt_peer_socket *src)
8217 {
8218         struct nbt_name *name;
8219         struct nbt_name_packet *rep_packet;
8220         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
8221
8222         _NBT_ASSERT(req_packet->qdcount, 1);
8223         _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS);
8224         _NBT_ASSERT(req_packet->questions[0].question_class, NBT_QCLASS_IP);
8225
8226         name = &req_packet->questions[0].name;
8227
8228         _NBT_ASSERT(name->type, rec->name.type);
8229         _NBT_ASSERT_STRING(name->name, rec->name.name);
8230         _NBT_ASSERT_STRING(name->scope, rec->name.scope);
8231
8232         _NBT_ASSERT(rec->defend.expect_release, True);
8233
8234         rep_packet = talloc_zero(nbtsock, struct nbt_name_packet);
8235         if (rep_packet == NULL) return;
8236
8237         rep_packet->name_trn_id = req_packet->name_trn_id;
8238         rep_packet->ancount     = 1;
8239         rep_packet->operation   = 
8240                                 NBT_FLAG_REPLY | 
8241                                 NBT_OPCODE_RELEASE |
8242                                 NBT_FLAG_AUTHORITIVE;
8243
8244         rep_packet->answers     = talloc_array(rep_packet, struct nbt_res_rec, 1);
8245         if (rep_packet->answers == NULL) return;
8246
8247         rep_packet->answers[0].name     = *name;
8248         rep_packet->answers[0].rr_type  = NBT_QTYPE_NETBIOS;
8249         rep_packet->answers[0].rr_class = NBT_QCLASS_IP;
8250         rep_packet->answers[0].ttl      = req_packet->additional[0].ttl;
8251         rep_packet->answers[0].rdata    = req_packet->additional[0].rdata;
8252
8253         DEBUG(2,("Sending name release reply for %s to %s:%d\n", 
8254                 nbt_name_string(rep_packet, name), src->addr, src->port));
8255
8256         nbt_name_reply_send(nbtsock, src, rep_packet);
8257         talloc_free(rep_packet);
8258
8259         /* make sure we push the reply to the wire */
8260         event_loop_once(nbtsock->event_ctx);
8261
8262         rec->defend.timeout     = 0;
8263         rec->defend.ret         = True;
8264 }
8265
8266 static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket *nbtsock, 
8267                                                           struct nbt_name_packet *req_packet, 
8268                                                           const struct nbt_peer_socket *src)
8269 {
8270         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
8271
8272         rec->defend.ret = False;
8273
8274         switch (req_packet->operation & NBT_OPCODE) {
8275         case NBT_OPCODE_QUERY:
8276                 test_conflict_owned_active_vs_replica_handler_query(nbtsock, req_packet, src);
8277                 break;
8278         case NBT_OPCODE_RELEASE:
8279                 test_conflict_owned_active_vs_replica_handler_release(nbtsock, req_packet, src);
8280                 break;
8281         default:
8282                 printf("%s: unexpected incoming packet\n", __location__);
8283                 return;
8284         }
8285 }
8286
8287 /*
8288   test WINS replication operations
8289 */
8290 BOOL torture_nbt_winsreplication_quick(void)
8291 {
8292         const char *address;
8293         struct nbt_name name;
8294         TALLOC_CTX *mem_ctx = talloc_new(NULL);
8295         NTSTATUS status;
8296         BOOL ret = True;
8297
8298         make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
8299
8300         /* do an initial name resolution to find its IP */
8301         status = resolve_name(&name, mem_ctx, &address, NULL);
8302         if (!NT_STATUS_IS_OK(status)) {
8303                 printf("Failed to resolve %s - %s\n",
8304                        name.name, nt_errstr(status));
8305                 talloc_free(mem_ctx);
8306                 return False;
8307         }
8308
8309         ret &= test_assoc_ctx1(mem_ctx, address);
8310         ret &= test_assoc_ctx2(mem_ctx, address);
8311
8312         talloc_free(mem_ctx);
8313
8314         return ret;
8315 }
8316
8317 /*
8318   test WINS replication operations
8319 */
8320 BOOL torture_nbt_winsreplication(void)
8321 {
8322         const char *address;
8323         struct nbt_name name;
8324         TALLOC_CTX *mem_ctx = talloc_new(NULL);
8325         NTSTATUS status;
8326         BOOL ret = True;
8327         struct test_wrepl_conflict_conn *ctx;
8328
8329         make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
8330
8331         /* do an initial name resolution to find its IP */
8332         status = resolve_name(&name, mem_ctx, &address, NULL);
8333         if (!NT_STATUS_IS_OK(status)) {
8334                 printf("Failed to resolve %s - %s\n",
8335                        name.name, nt_errstr(status));
8336                 talloc_free(mem_ctx);
8337                 return False;
8338         }
8339
8340         ret &= test_assoc_ctx1(mem_ctx, address);
8341         ret &= test_assoc_ctx2(mem_ctx, address);
8342
8343         ret &= test_wins_replication(mem_ctx, address);
8344
8345         ctx = test_create_conflict_ctx(mem_ctx, address);
8346
8347         ret &= test_conflict_same_owner(ctx);
8348         ret &= test_conflict_different_owner(ctx);
8349         ret &= test_conflict_owned_released_vs_replica(ctx);
8350         ret &= test_conflict_owned_active_vs_replica(ctx);
8351
8352         talloc_free(mem_ctx);
8353
8354         return ret;
8355 }