r11330: - split up owned,active vs replica and owned,released vs. replica
[bbaumbach/samba-autobuild/.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/socket/socket.h"
27
28 #define CHECK_STATUS(status, correct) do { \
29         if (!NT_STATUS_EQUAL(status, correct)) { \
30                 printf("(%s) Incorrect status %s - should be %s\n", \
31                        __location__, nt_errstr(status), nt_errstr(correct)); \
32                 ret = False; \
33                 goto done; \
34         }} while (0)
35
36 #define CHECK_VALUE(v, correct) do { \
37         if ((v) != (correct)) { \
38                 printf("(%s) Incorrect value %s=%d - should be %d\n", \
39                        __location__, #v, v, correct); \
40                 ret = False; \
41                 goto done; \
42         }} while (0)
43
44 #define CHECK_VALUE_UINT64(v, correct) do { \
45         if ((v) != (correct)) { \
46                 printf("(%s) Incorrect value %s=%llu - should be %llu\n", \
47                        __location__, #v, v, correct); \
48                 ret = False; \
49                 goto done; \
50         }} while (0)
51
52 #define CHECK_VALUE_STRING(v, correct) do { \
53         if ( ((!v) && (correct)) || \
54              ((v) && (!correct)) || \
55              ((v) && (correct) && strcmp(v,correct) != 0)) { \
56                 printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \
57                        __location__, #v, v, correct); \
58                 ret = False; \
59                 goto done; \
60         }} while (0)
61
62 #define _NBT_NAME(n,t,s) {\
63         .name   = n,\
64         .type   = t,\
65         .scope  = s\
66 }
67
68 static const char *wrepl_name_type_string(enum wrepl_name_type type)
69 {
70         switch (type) {
71         case WREPL_TYPE_UNIQUE: return "UNIQUE";
72         case WREPL_TYPE_GROUP: return "GROUP";
73         case WREPL_TYPE_SGROUP: return "SGROUP";
74         case WREPL_TYPE_MHOMED: return "MHOMED";
75         }
76         return "UNKNOWN_TYPE";
77 }
78
79 static const char *wrepl_name_state_string(enum wrepl_name_state state)
80 {
81         switch (state) {
82         case WREPL_STATE_ACTIVE: return "ACTIVE";
83         case WREPL_STATE_RELEASED: return "RELEASED";
84         case WREPL_STATE_TOMBSTONE: return "TOMBSTONE";
85         case WREPL_STATE_RESERVED: return "RESERVED";
86         }
87         return "UNKNOWN_STATE";
88 }
89
90 /*
91   test how assoc_ctx's are only usable on the connection
92   they are created on.
93 */
94 static BOOL test_assoc_ctx1(TALLOC_CTX *mem_ctx, const char *address)
95 {
96         BOOL ret = True;
97         struct wrepl_request *req;
98         struct wrepl_socket *wrepl_socket1;
99         struct wrepl_associate associate1;
100         struct wrepl_socket *wrepl_socket2;
101         struct wrepl_associate associate2;
102         struct wrepl_pull_table pull_table;
103         struct wrepl_packet *rep_packet;
104         struct wrepl_associate_stop assoc_stop;
105         NTSTATUS status;
106
107         if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
108                 printf("winsrepl: cross connection assoc_ctx usage disabled - enable dangerous tests to use\n");
109                 return True;
110         }
111
112         printf("Test if assoc_ctx is only valid on the conection it was created on\n");
113
114         wrepl_socket1 = wrepl_socket_init(mem_ctx, NULL);
115         wrepl_socket2 = wrepl_socket_init(mem_ctx, NULL);
116
117         printf("Setup 2 wrepl connections\n");
118         status = wrepl_connect(wrepl_socket1, NULL, address);
119         CHECK_STATUS(status, NT_STATUS_OK);
120
121         status = wrepl_connect(wrepl_socket2, NULL, address);
122         CHECK_STATUS(status, NT_STATUS_OK);
123
124         printf("Send a start association request (conn1)\n");
125         status = wrepl_associate(wrepl_socket1, &associate1);
126         CHECK_STATUS(status, NT_STATUS_OK);
127
128         printf("association context (conn1): 0x%x\n", associate1.out.assoc_ctx);
129
130         printf("Send a start association request (conn2)\n");
131         status = wrepl_associate(wrepl_socket2, &associate2);
132         CHECK_STATUS(status, NT_STATUS_OK);
133
134         printf("association context (conn2): 0x%x\n", associate2.out.assoc_ctx);
135
136         printf("Send a replication table query, with assoc 1 (conn2), the anwser should be on conn1\n");
137         pull_table.in.assoc_ctx = associate1.out.assoc_ctx;
138         req = wrepl_pull_table_send(wrepl_socket2, &pull_table);
139         req->send_only = True;
140         status = wrepl_request_recv(req, mem_ctx, &rep_packet);
141         CHECK_STATUS(status, NT_STATUS_OK);
142
143         printf("Send a association request (conn2), to make sure the last request was ignored\n");
144         status = wrepl_associate(wrepl_socket2, &associate2);
145         CHECK_STATUS(status, NT_STATUS_OK);
146
147         printf("Send a replication table query, with invalid assoc (conn1), receive answer from conn2\n");
148         pull_table.in.assoc_ctx = 0;
149         req = wrepl_pull_table_send(wrepl_socket1, &pull_table);
150         status = wrepl_request_recv(req, mem_ctx, &rep_packet);
151         CHECK_STATUS(status, NT_STATUS_OK);
152
153         printf("Send a association request (conn1), to make sure the last request was handled correct\n");
154         status = wrepl_associate(wrepl_socket1, &associate2);
155         CHECK_STATUS(status, NT_STATUS_OK);
156
157         assoc_stop.in.assoc_ctx = associate1.out.assoc_ctx;
158         assoc_stop.in.reason    = 4;
159         printf("Send a association stop request (conn1), reson: %u\n", assoc_stop.in.reason);
160         status = wrepl_associate_stop(wrepl_socket1, &assoc_stop);
161         CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
162
163         assoc_stop.in.assoc_ctx = associate2.out.assoc_ctx;
164         assoc_stop.in.reason    = 0;
165         printf("Send a association stop request (conn2), reson: %u\n", assoc_stop.in.reason);
166         status = wrepl_associate_stop(wrepl_socket2, &assoc_stop);
167         CHECK_STATUS(status, NT_STATUS_OK);
168
169 done:
170         printf("Close 2 wrepl connections\n");
171         talloc_free(wrepl_socket1);
172         talloc_free(wrepl_socket2);
173         return ret;
174 }
175
176 /*
177   test if we always get back the same assoc_ctx
178 */
179 static BOOL test_assoc_ctx2(TALLOC_CTX *mem_ctx, const char *address)
180 {
181         BOOL ret = True;
182         struct wrepl_socket *wrepl_socket;
183         struct wrepl_associate associate;
184         uint32_t assoc_ctx1;
185         NTSTATUS status;
186
187         printf("Test if we always get back the same assoc_ctx\n");
188
189         wrepl_socket = wrepl_socket_init(mem_ctx, NULL);
190         
191         printf("Setup wrepl connections\n");
192         status = wrepl_connect(wrepl_socket, NULL, address);
193         CHECK_STATUS(status, NT_STATUS_OK);
194
195
196         printf("Send 1st start association request\n");
197         status = wrepl_associate(wrepl_socket, &associate);
198         CHECK_STATUS(status, NT_STATUS_OK);
199         assoc_ctx1 = associate.out.assoc_ctx;
200         printf("1st association context: 0x%x\n", associate.out.assoc_ctx);
201
202         printf("Send 2nd start association request\n");
203         status = wrepl_associate(wrepl_socket, &associate);
204         CHECK_VALUE(associate.out.assoc_ctx, assoc_ctx1);
205         CHECK_STATUS(status, NT_STATUS_OK);
206         printf("2nd association context: 0x%x\n", associate.out.assoc_ctx);
207
208         printf("Send 3rd start association request\n");
209         status = wrepl_associate(wrepl_socket, &associate);
210         CHECK_VALUE(associate.out.assoc_ctx, assoc_ctx1);
211         CHECK_STATUS(status, NT_STATUS_OK);
212         printf("3rd association context: 0x%x\n", associate.out.assoc_ctx);
213
214 done:
215         printf("Close wrepl connections\n");
216         talloc_free(wrepl_socket);
217         return ret;
218 }
219
220
221 /*
222   display a replication entry
223 */
224 static void display_entry(TALLOC_CTX *mem_ctx, struct wrepl_name *name)
225 {
226         int i;
227
228         printf("%s\n", nbt_name_string(mem_ctx, &name->name));
229         printf("\tTYPE:%u STATE:%u NODE:%u STATIC:%u VERSION_ID: %llu\n",
230                 name->type, name->state, name->node, name->is_static, name->version_id);
231         printf("\tRAW_FLAGS: 0x%08X OWNER: %-15s\n",
232                 name->raw_flags, name->owner);
233         for (i=0;i<name->num_addresses;i++) {
234                 printf("\tADDR: %-15s OWNER: %-15s\n", 
235                         name->addresses[i].address, name->addresses[i].owner);
236         }
237 }
238
239 /*
240   test a full replication dump from a WINS server
241 */
242 static BOOL test_wins_replication(TALLOC_CTX *mem_ctx, const char *address)
243 {
244         BOOL ret = True;
245         struct wrepl_socket *wrepl_socket;
246         NTSTATUS status;
247         int i, j;
248         struct wrepl_associate associate;
249         struct wrepl_pull_table pull_table;
250         struct wrepl_pull_names pull_names;
251
252         printf("Test one pull replication cycle\n");
253
254         wrepl_socket = wrepl_socket_init(mem_ctx, NULL);
255         
256         printf("Setup wrepl connections\n");
257         status = wrepl_connect(wrepl_socket, NULL, address);
258         CHECK_STATUS(status, NT_STATUS_OK);
259
260         printf("Send a start association request\n");
261
262         status = wrepl_associate(wrepl_socket, &associate);
263         CHECK_STATUS(status, NT_STATUS_OK);
264
265         printf("association context: 0x%x\n", associate.out.assoc_ctx);
266
267         printf("Send a replication table query\n");
268         pull_table.in.assoc_ctx = associate.out.assoc_ctx;
269
270         status = wrepl_pull_table(wrepl_socket, mem_ctx, &pull_table);
271         if (NT_STATUS_EQUAL(NT_STATUS_NETWORK_ACCESS_DENIED,status)) {
272                 struct wrepl_packet packet;
273                 struct wrepl_request *req;
274
275                 ZERO_STRUCT(packet);
276                 packet.opcode                      = WREPL_OPCODE_BITS;
277                 packet.assoc_ctx                   = associate.out.assoc_ctx;
278                 packet.mess_type                   = WREPL_STOP_ASSOCIATION;
279                 packet.message.stop.reason         = 0;
280
281                 req = wrepl_request_send(wrepl_socket, &packet);
282                 talloc_free(req);
283
284                 printf("failed - We are not a valid pull partner for the server\n");
285                 ret = False;
286                 goto done;
287         }
288         CHECK_STATUS(status, NT_STATUS_OK);
289
290         printf("Found %d replication partners\n", pull_table.out.num_partners);
291
292         for (i=0;i<pull_table.out.num_partners;i++) {
293                 struct wrepl_wins_owner *partner = &pull_table.out.partners[i];
294                 printf("%s   max_version=%6llu   min_version=%6llu type=%d\n",
295                        partner->address, 
296                        partner->max_version, 
297                        partner->min_version, 
298                        partner->type);
299
300                 pull_names.in.assoc_ctx = associate.out.assoc_ctx;
301                 pull_names.in.partner = *partner;
302                 
303                 status = wrepl_pull_names(wrepl_socket, mem_ctx, &pull_names);
304                 CHECK_STATUS(status, NT_STATUS_OK);
305
306                 printf("Received %d names\n", pull_names.out.num_names);
307
308                 for (j=0;j<pull_names.out.num_names;j++) {
309                         display_entry(mem_ctx, &pull_names.out.names[j]);
310                 }
311         }
312
313 done:
314         printf("Close wrepl connections\n");
315         talloc_free(wrepl_socket);
316         return ret;
317 }
318
319 struct test_wrepl_conflict_conn {
320         const char *address;
321         struct wrepl_socket *pull;
322         uint32_t pull_assoc;
323
324 #define TEST_OWNER_A_ADDRESS "127.65.65.1"
325 #define TEST_ADDRESS_A_PREFIX "127.0.65"
326 #define TEST_OWNER_B_ADDRESS "127.66.66.1"
327 #define TEST_ADDRESS_B_PREFIX "127.0.66"
328
329         struct wrepl_wins_owner a, b, c;
330
331         const char *myaddr;
332         struct nbt_name_socket *nbtsock;
333         BOOL nbt_root_port;
334
335         uint32_t addresses_1_num;
336         struct wrepl_ip *addresses_1;
337 };
338
339 static const struct wrepl_ip addresses_A_1[] = {
340         {
341         .owner  = TEST_OWNER_A_ADDRESS,
342         .ip     = TEST_ADDRESS_A_PREFIX".1"
343         }
344 };
345 static const struct wrepl_ip addresses_A_2[] = {
346         {
347         .owner  = TEST_OWNER_A_ADDRESS,
348         .ip     = TEST_ADDRESS_A_PREFIX".2"
349         }
350 };
351 static const struct wrepl_ip addresses_A_3_4[] = {
352         {
353         .owner  = TEST_OWNER_A_ADDRESS,
354         .ip     = TEST_ADDRESS_A_PREFIX".3"
355         },
356         {
357         .owner  = TEST_OWNER_A_ADDRESS,
358         .ip     = TEST_ADDRESS_A_PREFIX".4"
359         }
360 };
361
362 static const struct wrepl_ip addresses_B_1[] = {
363         {
364         .owner  = TEST_OWNER_B_ADDRESS,
365         .ip     = TEST_ADDRESS_B_PREFIX".1"
366         }
367 };
368 static const struct wrepl_ip addresses_B_2[] = {
369         {
370         .owner  = TEST_OWNER_B_ADDRESS,
371         .ip     = TEST_ADDRESS_B_PREFIX".2"
372         }
373 };
374 static const struct wrepl_ip addresses_B_3_4[] = {
375         {
376         .owner  = TEST_OWNER_B_ADDRESS,
377         .ip     = TEST_ADDRESS_B_PREFIX".3"
378         },
379         {
380         .owner  = TEST_OWNER_B_ADDRESS,
381         .ip     = TEST_ADDRESS_B_PREFIX".4"
382         }
383 };
384
385 static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *mem_ctx,
386                                                                  const char *address)
387 {
388         struct test_wrepl_conflict_conn *ctx;
389         struct wrepl_associate associate;
390         struct wrepl_pull_table pull_table;
391         NTSTATUS status;
392         uint32_t i;
393
394         ctx = talloc_zero(mem_ctx, struct test_wrepl_conflict_conn);
395         if (!ctx) return NULL;
396
397         ctx->address    = address;
398         ctx->pull       = wrepl_socket_init(ctx, NULL);
399         if (!ctx->pull) return NULL;
400
401         printf("Setup wrepl conflict pull connection\n");
402         status = wrepl_connect(ctx->pull, NULL, ctx->address);
403         if (!NT_STATUS_IS_OK(status)) return NULL;
404
405         status = wrepl_associate(ctx->pull, &associate);
406         if (!NT_STATUS_IS_OK(status)) return NULL;
407
408         ctx->pull_assoc = associate.out.assoc_ctx;
409
410         ctx->a.address          = TEST_OWNER_A_ADDRESS;
411         ctx->a.max_version      = 0;
412         ctx->a.min_version      = 0;
413         ctx->a.type             = 1;
414
415         ctx->b.address          = TEST_OWNER_B_ADDRESS;
416         ctx->b.max_version      = 0;
417         ctx->b.min_version      = 0;
418         ctx->b.type             = 1;
419
420         ctx->c.address          = address;
421         ctx->c.max_version      = 0;
422         ctx->c.min_version      = 0;
423         ctx->c.type             = 1;
424
425         pull_table.in.assoc_ctx = ctx->pull_assoc;
426         status = wrepl_pull_table(ctx->pull, ctx->pull, &pull_table);
427         if (!NT_STATUS_IS_OK(status)) return NULL;
428
429         for (i=0; i < pull_table.out.num_partners; i++) {
430                 if (strcmp(TEST_OWNER_A_ADDRESS,pull_table.out.partners[i].address)==0) {
431                         ctx->a.max_version      = pull_table.out.partners[i].max_version;
432                         ctx->a.min_version      = pull_table.out.partners[i].min_version;
433                 }
434                 if (strcmp(TEST_OWNER_B_ADDRESS,pull_table.out.partners[i].address)==0) {
435                         ctx->b.max_version      = pull_table.out.partners[i].max_version;
436                         ctx->b.min_version      = pull_table.out.partners[i].min_version;
437                 }
438                 if (strcmp(address,pull_table.out.partners[i].address)==0) {
439                         ctx->c.max_version      = pull_table.out.partners[i].max_version;
440                         ctx->c.min_version      = pull_table.out.partners[i].min_version;
441                 }
442         }
443
444         talloc_free(pull_table.out.partners);
445
446         ctx->nbtsock = nbt_name_socket_init(ctx, NULL);
447         if (!ctx->nbtsock) return NULL;
448
449         ctx->myaddr = talloc_strdup(mem_ctx, iface_best_ip(address));
450         if (!ctx->myaddr) return NULL;
451
452         status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, lp_nbt_port(), 0, 0);
453         if (!NT_STATUS_IS_OK(status)) {
454                 status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0, 0);
455                 if (!NT_STATUS_IS_OK(status)) return NULL;
456         } else {
457                 ctx->nbt_root_port = True;
458         }
459
460         ctx->addresses_1_num = 1;
461         ctx->addresses_1 = talloc_array(ctx, struct wrepl_ip, ctx->addresses_1_num);
462         if (!ctx->addresses_1) return NULL;
463         ctx->addresses_1[0].owner       = ctx->c.address;
464         ctx->addresses_1[0].ip          = ctx->myaddr;
465
466         return ctx;
467 }
468
469 static BOOL test_wrepl_update_one(struct test_wrepl_conflict_conn *ctx,
470                                   const struct wrepl_wins_owner *owner,
471                                   const struct wrepl_wins_name *name)
472 {
473         BOOL ret = True;
474         struct wrepl_socket *wrepl_socket;
475         struct wrepl_associate associate;
476         struct wrepl_packet update_packet, repl_send;
477         struct wrepl_table *update;
478         struct wrepl_wins_owner wrepl_wins_owners[1];
479         struct wrepl_packet *repl_recv;
480         struct wrepl_wins_owner *send_request;
481         struct wrepl_send_reply *send_reply;
482         struct wrepl_wins_name wrepl_wins_names[1];
483         uint32_t assoc_ctx;
484         NTSTATUS status;
485
486         wrepl_socket = wrepl_socket_init(ctx, NULL);
487
488         status = wrepl_connect(wrepl_socket, NULL, ctx->address);
489         CHECK_STATUS(status, NT_STATUS_OK);
490
491         status = wrepl_associate(wrepl_socket, &associate);
492         CHECK_STATUS(status, NT_STATUS_OK);
493         assoc_ctx = associate.out.assoc_ctx;
494
495         /* now send a WREPL_REPL_UPDATE message */
496         ZERO_STRUCT(update_packet);
497         update_packet.opcode                    = WREPL_OPCODE_BITS;
498         update_packet.assoc_ctx                 = assoc_ctx;
499         update_packet.mess_type                 = WREPL_REPLICATION;
500         update_packet.message.replication.command       = WREPL_REPL_UPDATE;
501         update  = &update_packet.message.replication.info.table;
502
503         update->partner_count   = ARRAY_SIZE(wrepl_wins_owners);
504         update->partners        = wrepl_wins_owners;
505         update->initiator       = "0.0.0.0";
506
507         wrepl_wins_owners[0]    = *owner;
508
509         status = wrepl_request(wrepl_socket, wrepl_socket,
510                                &update_packet, &repl_recv);
511         CHECK_STATUS(status, NT_STATUS_OK);
512         CHECK_VALUE(repl_recv->mess_type, WREPL_REPLICATION);
513         CHECK_VALUE(repl_recv->message.replication.command, WREPL_REPL_SEND_REQUEST);
514         send_request = &repl_recv->message.replication.info.owner;
515
516         ZERO_STRUCT(repl_send);
517         repl_send.opcode                        = WREPL_OPCODE_BITS;
518         repl_send.assoc_ctx                     = assoc_ctx;
519         repl_send.mess_type                     = WREPL_REPLICATION;
520         repl_send.message.replication.command   = WREPL_REPL_SEND_REPLY;
521         send_reply = &repl_send.message.replication.info.reply;
522
523         send_reply->num_names   = ARRAY_SIZE(wrepl_wins_names);
524         send_reply->names       = wrepl_wins_names;
525
526         wrepl_wins_names[0]     = *name;
527
528         status = wrepl_request(wrepl_socket, wrepl_socket,
529                                &repl_send, &repl_recv);
530         CHECK_STATUS(status, NT_STATUS_OK);
531         CHECK_VALUE(repl_recv->mess_type, WREPL_STOP_ASSOCIATION);
532         CHECK_VALUE(repl_recv->message.stop.reason, 0);
533
534 done:
535         talloc_free(wrepl_socket);
536         return ret;
537 }
538
539 #if 0
540 static BOOL test_wrepl_update_two(struct test_wrepl_conflict_conn *ctx,
541                                   const struct wrepl_wins_owner *owner,
542                                   const struct wrepl_wins_name *name1,
543                                   const struct wrepl_wins_name *name2)
544 {
545         BOOL ret = True;
546         struct wrepl_socket *wrepl_socket;
547         struct wrepl_associate associate;
548         struct wrepl_packet update_packet, repl_send;
549         struct wrepl_table *update;
550         struct wrepl_wins_owner wrepl_wins_owners[1];
551         struct wrepl_packet *repl_recv;
552         struct wrepl_wins_owner *send_request;
553         struct wrepl_send_reply *send_reply;
554         struct wrepl_wins_name wrepl_wins_names[2];
555         uint32_t assoc_ctx;
556         NTSTATUS status;
557
558         wrepl_socket = wrepl_socket_init(ctx, NULL);
559
560         status = wrepl_connect(wrepl_socket, NULL, ctx->address);
561         CHECK_STATUS(status, NT_STATUS_OK);
562
563         status = wrepl_associate(wrepl_socket, &associate);
564         CHECK_STATUS(status, NT_STATUS_OK);
565         assoc_ctx = associate.out.assoc_ctx;
566
567         /* now send a WREPL_REPL_UPDATE message */
568         ZERO_STRUCT(update_packet);
569         update_packet.opcode                    = WREPL_OPCODE_BITS;
570         update_packet.assoc_ctx                 = assoc_ctx;
571         update_packet.mess_type                 = WREPL_REPLICATION;
572         update_packet.message.replication.command       = WREPL_REPL_UPDATE;
573         update  = &update_packet.message.replication.info.table;
574
575         update->partner_count   = ARRAY_SIZE(wrepl_wins_owners);
576         update->partners        = wrepl_wins_owners;
577         update->initiator       = "0.0.0.0";
578
579         wrepl_wins_owners[0]    = *owner;
580
581         status = wrepl_request(wrepl_socket, wrepl_socket,
582                                &update_packet, &repl_recv);
583         CHECK_STATUS(status, NT_STATUS_OK);
584         CHECK_VALUE(repl_recv->mess_type, WREPL_REPLICATION);
585         CHECK_VALUE(repl_recv->message.replication.command, WREPL_REPL_SEND_REQUEST);
586         send_request = &repl_recv->message.replication.info.owner;
587
588         ZERO_STRUCT(repl_send);
589         repl_send.opcode                        = WREPL_OPCODE_BITS;
590         repl_send.assoc_ctx                     = assoc_ctx;
591         repl_send.mess_type                     = WREPL_REPLICATION;
592         repl_send.message.replication.command   = WREPL_REPL_SEND_REPLY;
593         send_reply = &repl_send.message.replication.info.reply;
594
595         send_reply->num_names   = ARRAY_SIZE(wrepl_wins_names);
596         send_reply->names       = wrepl_wins_names;
597
598         wrepl_wins_names[0]     = *name1;
599         wrepl_wins_names[1]     = *name2;
600
601         status = wrepl_request(wrepl_socket, wrepl_socket,
602                                &repl_send, &repl_recv);
603         CHECK_STATUS(status, NT_STATUS_OK);
604         CHECK_VALUE(repl_recv->mess_type, WREPL_STOP_ASSOCIATION);
605         CHECK_VALUE(repl_recv->message.stop.reason, 0);
606
607 done:
608         talloc_free(wrepl_socket);
609         return ret;
610 }
611 #endif
612
613 static BOOL test_wrepl_is_applied(struct test_wrepl_conflict_conn *ctx,
614                                   const struct wrepl_wins_owner *owner,
615                                   const struct wrepl_wins_name *name,
616                                   BOOL expected)
617 {
618         BOOL ret = True;
619         NTSTATUS status;
620         struct wrepl_pull_names pull_names;
621         struct wrepl_name *names;
622
623         pull_names.in.assoc_ctx = ctx->pull_assoc;
624         pull_names.in.partner   = *owner;
625         pull_names.in.partner.min_version = pull_names.in.partner.max_version;
626                 
627         status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names);
628         CHECK_STATUS(status, NT_STATUS_OK);
629         CHECK_VALUE(pull_names.out.num_names, (expected?1:0));
630
631         names = pull_names.out.names;
632
633         if (expected) {
634                 uint32_t flags = WREPL_NAME_FLAGS(names[0].type,
635                                                   names[0].state,
636                                                   names[0].node,
637                                                   names[0].is_static);
638                 CHECK_VALUE(names[0].name.type, name->name->type);
639                 CHECK_VALUE_STRING(names[0].name.name, name->name->name);
640                 CHECK_VALUE_STRING(names[0].name.scope, name->name->scope);
641                 CHECK_VALUE(flags, name->flags);
642                 CHECK_VALUE_UINT64(names[0].version_id, name->id);
643
644                 if (flags & 2) {
645                         CHECK_VALUE(names[0].num_addresses,
646                                     name->addresses.addresses.num_ips);
647                 } else {
648                         CHECK_VALUE(names[0].num_addresses, 1);
649                         CHECK_VALUE_STRING(names[0].addresses[0].address,
650                                            name->addresses.ip);
651                 }
652         }
653 done:
654         talloc_free(pull_names.out.names);
655         return ret;
656 }
657
658 static BOOL test_wrepl_is_merged(struct test_wrepl_conflict_conn *ctx,
659                                  const struct wrepl_wins_name *name1,
660                                  const struct wrepl_wins_name *name2)
661 {
662         return True;
663 #if 0
664         BOOL ret = True;
665         NTSTATUS status;
666         struct wrepl_pull_names pull_names;
667         struct wrepl_name *names;
668         uint32_t num_ips;
669
670         pull_names.in.assoc_ctx = ctx->pull_assoc;
671         pull_names.in.partner   = ctx->c;
672         pull_names.in.partner.min_version = ctx->c.max_version-1;
673
674         status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names);
675         CHECK_STATUS(status, NT_STATUS_OK);
676         CHECK_VALUE(pull_names.out.num_names, 1);
677
678         names = pull_names.out.names;
679
680         num_ips = name1->addresses.addresses.num_ips + name2->addresses.addresses.num_ips;
681
682         CHECK_VALUE(names[0].name.type, name1->name->type);
683         CHECK_VALUE_STRING(names[0].name.name, name1->name->name);
684         CHECK_VALUE_STRING(names[0].name.scope, name1->name->scope);
685         CHECK_VALUE(names[0].type, WREPL_TYPE_SGROUP);
686         CHECK_VALUE(names[0].state, (num_ips>0?WREPL_STATE_ACTIVE:WREPL_STATE_RELEASED));
687         CHECK_VALUE_UINT64(names[0].version_id, ctx->c.max_version);
688
689         CHECK_VALUE(names[0].num_addresses,
690                     name1->addresses.addresses.num_ips+
691                     name2->addresses.addresses.num_ips);
692 done:
693         talloc_free(pull_names.out.names);
694         return ret;
695 #endif
696 }
697
698 static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx)
699 {
700         BOOL ret = True;
701         struct nbt_name name;
702         struct wrepl_wins_name wins_name1;
703         struct wrepl_wins_name wins_name2;
704         struct wrepl_wins_name *wins_name_tmp;
705         struct wrepl_wins_name *wins_name_last;
706         struct wrepl_wins_name *wins_name_cur;
707         uint32_t i,j;
708         uint8_t types[] = { 0x00, 0x1C };
709         struct {
710                 enum wrepl_name_type type;
711                 enum wrepl_name_state state;
712                 enum wrepl_name_node node;
713                 BOOL is_static;
714                 uint32_t num_ips;
715                 const struct wrepl_ip *ips;
716         } records[] = {
717                 {
718                 .type           = WREPL_TYPE_GROUP,
719                 .state          = WREPL_STATE_ACTIVE,
720                 .node           = WREPL_NODE_B,
721                 .is_static      = False,
722                 .num_ips        = ARRAY_SIZE(addresses_A_1),
723                 .ips            = addresses_A_1,
724                 },{
725                 .type           = WREPL_TYPE_UNIQUE,
726                 .state          = WREPL_STATE_ACTIVE,
727                 .node           = WREPL_NODE_B,
728                 .is_static      = False,
729                 .num_ips        = ARRAY_SIZE(addresses_A_1),
730                 .ips            = addresses_A_1,
731                 },{
732                 .type           = WREPL_TYPE_UNIQUE,
733                 .state          = WREPL_STATE_ACTIVE,
734                 .node           = WREPL_NODE_B,
735                 .is_static      = False,
736                 .num_ips        = ARRAY_SIZE(addresses_A_2),
737                 .ips            = addresses_A_2,
738                 },{
739                 .type           = WREPL_TYPE_UNIQUE,
740                 .state          = WREPL_STATE_ACTIVE,
741                 .node           = WREPL_NODE_B,
742                 .is_static      = True,
743                 .num_ips        = ARRAY_SIZE(addresses_A_1),
744                 .ips            = addresses_A_1,
745                 },{
746                 .type           = WREPL_TYPE_UNIQUE,
747                 .state          = WREPL_STATE_ACTIVE,
748                 .node           = WREPL_NODE_B,
749                 .is_static      = False,
750                 .num_ips        = ARRAY_SIZE(addresses_A_2),
751                 .ips            = addresses_A_2,
752                 },{
753                 .type           = WREPL_TYPE_SGROUP,
754                 .state          = WREPL_STATE_TOMBSTONE,
755                 .node           = WREPL_NODE_B,
756                 .is_static      = False,
757                 .num_ips        = ARRAY_SIZE(addresses_A_2),
758                 .ips            = addresses_A_2,
759                 },{
760                 .type           = WREPL_TYPE_MHOMED,
761                 .state          = WREPL_STATE_TOMBSTONE,
762                 .node           = WREPL_NODE_B,
763                 .is_static      = False,
764                 .num_ips        = ARRAY_SIZE(addresses_A_1),
765                 .ips            = addresses_A_1,
766                 },{
767                 .type           = WREPL_TYPE_MHOMED,
768                 .state          = WREPL_STATE_RELEASED,
769                 .node           = WREPL_NODE_B,
770                 .is_static      = False,
771                 .num_ips        = ARRAY_SIZE(addresses_A_2),
772                 .ips            = addresses_A_2,
773                 },{
774                 .type           = WREPL_TYPE_SGROUP,
775                 .state          = WREPL_STATE_ACTIVE,
776                 .node           = WREPL_NODE_B,
777                 .is_static      = False,
778                 .num_ips        = ARRAY_SIZE(addresses_A_1),
779                 .ips            = addresses_A_1,
780                 },{
781                 .type           = WREPL_TYPE_SGROUP,
782                 .state          = WREPL_STATE_ACTIVE,
783                 .node           = WREPL_NODE_B,
784                 .is_static      = False,
785                 .num_ips        = ARRAY_SIZE(addresses_A_3_4),
786                 .ips            = addresses_A_3_4,
787                 },{
788                 .type           = WREPL_TYPE_SGROUP,
789                 .state          = WREPL_STATE_TOMBSTONE,
790                 .node           = WREPL_NODE_B,
791                 .is_static      = False,
792                 .num_ips        = ARRAY_SIZE(addresses_B_3_4),
793                 .ips            = addresses_B_3_4,
794                 },{
795                 /* the last one should always be a unique,tomstone record! */
796                 .type           = WREPL_TYPE_UNIQUE,
797                 .state          = WREPL_STATE_TOMBSTONE,
798                 .node           = WREPL_NODE_B,
799                 .is_static      = False,
800                 .num_ips        = ARRAY_SIZE(addresses_A_1),
801                 .ips            = addresses_A_1,
802                 }
803         };
804
805         if (!ctx) return False;
806
807         name.name       = "_SAME_OWNER_A";
808         name.type       = 0;
809         name.scope      = NULL;
810
811         wins_name_tmp   = NULL;
812         wins_name_last  = &wins_name2;
813         wins_name_cur   = &wins_name1;
814
815         for (j=0; ret && j < ARRAY_SIZE(types); j++) {
816                 name.type = types[j];
817                 printf("Test Replica Conflicts with same owner[%s] for %s\n",
818                         nbt_name_string(ctx, &name), ctx->a.address);
819
820                 for(i=0; ret && i < ARRAY_SIZE(records); i++) {
821                         wins_name_tmp   = wins_name_last;
822                         wins_name_last  = wins_name_cur;
823                         wins_name_cur   = wins_name_tmp;
824
825                         if (i > 0) {
826                                 printf("%s,%s%s vs. %s,%s%s with %s ip(s) => %s\n",
827                                         wrepl_name_type_string(records[i-1].type),
828                                         wrepl_name_state_string(records[i-1].state),
829                                         (records[i-1].is_static?",static":""),
830                                         wrepl_name_type_string(records[i].type),
831                                         wrepl_name_state_string(records[i].state),
832                                         (records[i].is_static?",static":""),
833                                         (records[i-1].ips==records[i].ips?"same":"different"),
834                                         "REPLACE");
835                         }
836
837                         wins_name_cur->name     = &name;
838                         wins_name_cur->flags    = WREPL_NAME_FLAGS(records[i].type,
839                                                                    records[i].state,
840                                                                    records[i].node,
841                                                                    records[i].is_static);
842                         wins_name_cur->id       = ++ctx->a.max_version;
843                         if (wins_name_cur->flags & 2) {
844                                 wins_name_cur->addresses.addresses.num_ips = records[i].num_ips;
845                                 wins_name_cur->addresses.addresses.ips     = discard_const(records[i].ips);
846                         } else {
847                                 wins_name_cur->addresses.ip = records[i].ips[0].ip;
848                         }
849                         wins_name_cur->unknown  = "255.255.255.255";
850
851                         ret &= test_wrepl_update_one(ctx, &ctx->a,wins_name_cur);
852                         if (records[i].state == WREPL_STATE_RELEASED) {
853                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_last, False);
854                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_cur, False);
855                         } else {
856                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_cur, True);
857                         }
858
859                         /* the first one is a cleanup run */
860                         if (!ret && i == 0) ret = True;
861
862                         if (!ret) {
863                                 printf("conflict handled wrong or record[%u]: %s\n", i, __location__);
864                                 return ret;
865                         }
866                 }
867         }
868         return ret;
869 }
870
871 static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx)
872 {
873         BOOL ret = True;
874         struct wrepl_wins_name wins_name1;
875         struct wrepl_wins_name wins_name2;
876         struct wrepl_wins_name *wins_name_r1;
877         struct wrepl_wins_name *wins_name_r2;
878         uint32_t i;
879         struct {
880                 const char *line; /* just better debugging */
881                 struct nbt_name name;
882                 BOOL extra; /* not the worst case, this is an extra test */
883                 BOOL cleanup;
884                 struct {
885                         struct wrepl_wins_owner *owner;
886                         enum wrepl_name_type type;
887                         enum wrepl_name_state state;
888                         enum wrepl_name_node node;
889                         BOOL is_static;
890                         uint32_t num_ips;
891                         const struct wrepl_ip *ips;
892                         BOOL apply_expected;
893                         BOOL merge_expected;
894                 } r1, r2;
895         } records[] = {
896         /* 
897          * NOTE: the first record and the last applied one
898          *       needs to be from the same owner,
899          *       to not conflict in the next smbtorture run!!!
900          */
901         {
902                 .line   = __location__,
903                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
904                 .cleanup= True,
905                 .r1     = {
906                         .owner          = &ctx->b,
907                         .type           = WREPL_TYPE_UNIQUE,
908                         .state          = WREPL_STATE_TOMBSTONE,
909                         .node           = WREPL_NODE_B,
910                         .is_static      = False,
911                         .num_ips        = ARRAY_SIZE(addresses_B_1),
912                         .ips            = addresses_B_1,
913                         .apply_expected = True /* ignored */
914                 },
915                 .r2     = {
916                         .owner          = &ctx->a,
917                         .type           = WREPL_TYPE_UNIQUE,
918                         .state          = WREPL_STATE_TOMBSTONE,
919                         .node           = WREPL_NODE_B,
920                         .is_static      = False,
921                         .num_ips        = ARRAY_SIZE(addresses_A_1),
922                         .ips            = addresses_A_1,
923                         .apply_expected = True /* ignored */
924                 }
925         },
926
927 /*
928  * unique vs unique section
929  */
930         /* 
931          * unique,active vs. unique,active
932          * => should be replaced
933          */
934         {
935                 .line   = __location__,
936                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
937                 .r1     = {
938                         .owner          = &ctx->a,
939                         .type           = WREPL_TYPE_UNIQUE,
940                         .state          = WREPL_STATE_ACTIVE,
941                         .node           = WREPL_NODE_B,
942                         .is_static      = False,
943                         .num_ips        = ARRAY_SIZE(addresses_A_1),
944                         .ips            = addresses_A_1,
945                         .apply_expected = True
946                 },
947                 .r2     = {
948                         .owner          = &ctx->b,
949                         .type           = WREPL_TYPE_UNIQUE,
950                         .state          = WREPL_STATE_ACTIVE,
951                         .node           = WREPL_NODE_B,
952                         .is_static      = False,
953                         .num_ips        = ARRAY_SIZE(addresses_B_1),
954                         .ips            = addresses_B_1,
955                         .apply_expected = True
956                 }
957         },
958
959         /* 
960          * unique,active vs. unique,tombstone
961          * => should NOT be replaced
962          */
963         {
964                 .line   = __location__,
965                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
966                 .r1     = {
967                         .owner          = &ctx->b,
968                         .type           = WREPL_TYPE_UNIQUE,
969                         .state          = WREPL_STATE_ACTIVE,
970                         .node           = WREPL_NODE_B,
971                         .is_static      = False,
972                         .num_ips        = ARRAY_SIZE(addresses_B_1),
973                         .ips            = addresses_B_1,
974                         .apply_expected = True
975                 },
976                 .r2     = {
977                         .owner          = &ctx->a,
978                         .type           = WREPL_TYPE_UNIQUE,
979                         .state          = WREPL_STATE_TOMBSTONE,
980                         .node           = WREPL_NODE_B,
981                         .is_static      = False,
982                         .num_ips        = ARRAY_SIZE(addresses_B_1),
983                         .ips            = addresses_B_1,
984                         .apply_expected = False
985                 }
986         },
987
988         /* 
989          * unique,released vs. unique,active
990          * => should be replaced
991          */
992         {
993                 .line   = __location__,
994                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
995                 .r1     = {
996                         .owner          = &ctx->b,
997                         .type           = WREPL_TYPE_UNIQUE,
998                         .state          = WREPL_STATE_RELEASED,
999                         .node           = WREPL_NODE_B,
1000                         .is_static      = False,
1001                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1002                         .ips            = addresses_B_1,
1003                         .apply_expected = False
1004                 },
1005                 .r2     = {
1006                         .owner          = &ctx->a,
1007                         .type           = WREPL_TYPE_UNIQUE,
1008                         .state          = WREPL_STATE_ACTIVE,
1009                         .node           = WREPL_NODE_B,
1010                         .is_static      = False,
1011                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1012                         .ips            = addresses_A_1,
1013                         .apply_expected = True
1014                 }
1015         },
1016
1017         /* 
1018          * unique,released vs. unique,tombstone
1019          * => should be replaced
1020          */
1021         {
1022                 .line   = __location__,
1023                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1024                 .r1     = {
1025                         .owner          = &ctx->a,
1026                         .type           = WREPL_TYPE_UNIQUE,
1027                         .state          = WREPL_STATE_RELEASED,
1028                         .node           = WREPL_NODE_B,
1029                         .is_static      = False,
1030                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1031                         .ips            = addresses_A_1,
1032                         .apply_expected = False
1033                 },
1034                 .r2     = {
1035                         .owner          = &ctx->b,
1036                         .type           = WREPL_TYPE_UNIQUE,
1037                         .state          = WREPL_STATE_TOMBSTONE,
1038                         .node           = WREPL_NODE_B,
1039                         .is_static      = False,
1040                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1041                         .ips            = addresses_B_1,
1042                         .apply_expected = True
1043                 }
1044         },
1045
1046         /* 
1047          * unique,tombstone vs. unique,active
1048          * => should be replaced
1049          */
1050         {
1051                 .line   = __location__,
1052                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1053                 .r1     = {
1054                         .owner          = &ctx->b,
1055                         .type           = WREPL_TYPE_UNIQUE,
1056                         .state          = WREPL_STATE_TOMBSTONE,
1057                         .node           = WREPL_NODE_B,
1058                         .is_static      = False,
1059                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1060                         .ips            = addresses_B_1,
1061                         .apply_expected = True
1062                 },
1063                 .r2     = {
1064                         .owner          = &ctx->a,
1065                         .type           = WREPL_TYPE_UNIQUE,
1066                         .state          = WREPL_STATE_ACTIVE,
1067                         .node           = WREPL_NODE_B,
1068                         .is_static      = False,
1069                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1070                         .ips            = addresses_A_1,
1071                         .apply_expected = True
1072                 }
1073         },
1074
1075         /* 
1076          * unique,tombstone vs. unique,tombstone
1077          * => should be replaced
1078          */
1079         {
1080                 .line   = __location__,
1081                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1082                 .r1     = {
1083                         .owner          = &ctx->a,
1084                         .type           = WREPL_TYPE_UNIQUE,
1085                         .state          = WREPL_STATE_TOMBSTONE,
1086                         .node           = WREPL_NODE_B,
1087                         .is_static      = False,
1088                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1089                         .ips            = addresses_A_1,
1090                         .apply_expected = True
1091                 },
1092                 .r2     = {
1093                         .owner          = &ctx->b,
1094                         .type           = WREPL_TYPE_UNIQUE,
1095                         .state          = WREPL_STATE_TOMBSTONE,
1096                         .node           = WREPL_NODE_B,
1097                         .is_static      = False,
1098                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1099                         .ips            = addresses_B_1,
1100                         .apply_expected = True
1101                 }
1102         },
1103
1104
1105 /*
1106  * unique vs normal groups section,
1107  */
1108         /* 
1109          * unique,active vs. group,active
1110          * => should be replaced
1111          */
1112         {
1113                 .line   = __location__,
1114                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1115                 .r1     = {
1116                         .owner          = &ctx->b,
1117                         .type           = WREPL_TYPE_UNIQUE,
1118                         .state          = WREPL_STATE_ACTIVE,
1119                         .node           = WREPL_NODE_B,
1120                         .is_static      = False,
1121                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1122                         .ips            = addresses_B_1,
1123                         .apply_expected = True
1124                 },
1125                 .r2     = {
1126                         .owner          = &ctx->a,
1127                         .type           = WREPL_TYPE_GROUP,
1128                         .state          = WREPL_STATE_ACTIVE,
1129                         .node           = WREPL_NODE_B,
1130                         .is_static      = False,
1131                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1132                         .ips            = addresses_A_1,
1133                         .apply_expected = True
1134                 }
1135         },
1136
1137         /* 
1138          * unique,active vs. group,tombstone
1139          * => should NOT be replaced
1140          */
1141         {
1142                 .line   = __location__,
1143                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1144                 .r1     = {
1145                         .owner          = &ctx->a,
1146                         .type           = WREPL_TYPE_UNIQUE,
1147                         .state          = WREPL_STATE_ACTIVE,
1148                         .node           = WREPL_NODE_B,
1149                         .is_static      = False,
1150                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1151                         .ips            = addresses_A_1,
1152                         .apply_expected = True
1153                 },
1154                 .r2     = {
1155                         .owner          = &ctx->b,
1156                         .type           = WREPL_TYPE_GROUP,
1157                         .state          = WREPL_STATE_TOMBSTONE,
1158                         .node           = WREPL_NODE_B,
1159                         .is_static      = False,
1160                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1161                         .ips            = addresses_A_1,
1162                         .apply_expected = False
1163                 }
1164         },
1165
1166         /* 
1167          * unique,released vs. group,active
1168          * => should be replaced
1169          */
1170         {
1171                 .line   = __location__,
1172                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1173                 .r1     = {
1174                         .owner          = &ctx->a,
1175                         .type           = WREPL_TYPE_UNIQUE,
1176                         .state          = WREPL_STATE_RELEASED,
1177                         .node           = WREPL_NODE_B,
1178                         .is_static      = False,
1179                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1180                         .ips            = addresses_A_1,
1181                         .apply_expected = False
1182                 },
1183                 .r2     = {
1184                         .owner          = &ctx->b,
1185                         .type           = WREPL_TYPE_GROUP,
1186                         .state          = WREPL_STATE_ACTIVE,
1187                         .node           = WREPL_NODE_B,
1188                         .is_static      = False,
1189                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1190                         .ips            = addresses_B_1,
1191                         .apply_expected = True
1192                 }
1193         },
1194
1195         /* 
1196          * unique,released vs. group,tombstone
1197          * => should be replaced
1198          */
1199         {
1200                 .line   = __location__,
1201                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1202                 .r1     = {
1203                         .owner          = &ctx->b,
1204                         .type           = WREPL_TYPE_UNIQUE,
1205                         .state          = WREPL_STATE_RELEASED,
1206                         .node           = WREPL_NODE_B,
1207                         .is_static      = False,
1208                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1209                         .ips            = addresses_B_1,
1210                         .apply_expected = False
1211                 },
1212                 .r2     = {
1213                         .owner          = &ctx->a,
1214                         .type           = WREPL_TYPE_GROUP,
1215                         .state          = WREPL_STATE_TOMBSTONE,
1216                         .node           = WREPL_NODE_B,
1217                         .is_static      = False,
1218                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1219                         .ips            = addresses_A_1,
1220                         .apply_expected = True
1221                 }
1222         },
1223
1224         /* 
1225          * unique,tombstone vs. group,active
1226          * => should be replaced
1227          */
1228         {
1229                 .line   = __location__,
1230                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1231                 .r1     = {
1232                         .owner          = &ctx->a,
1233                         .type           = WREPL_TYPE_UNIQUE,
1234                         .state          = WREPL_STATE_TOMBSTONE,
1235                         .node           = WREPL_NODE_B,
1236                         .is_static      = False,
1237                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1238                         .ips            = addresses_A_1,
1239                         .apply_expected = True
1240                 },
1241                 .r2     = {
1242                         .owner          = &ctx->b,
1243                         .type           = WREPL_TYPE_GROUP,
1244                         .state          = WREPL_STATE_ACTIVE,
1245                         .node           = WREPL_NODE_B,
1246                         .is_static      = False,
1247                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1248                         .ips            = addresses_B_1,
1249                         .apply_expected = True
1250                 }
1251         },
1252
1253         /* 
1254          * unique,tombstone vs. group,tombstone
1255          * => should be replaced
1256          */
1257         {
1258                 .line   = __location__,
1259                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1260                 .r1     = {
1261                         .owner          = &ctx->b,
1262                         .type           = WREPL_TYPE_UNIQUE,
1263                         .state          = WREPL_STATE_TOMBSTONE,
1264                         .node           = WREPL_NODE_B,
1265                         .is_static      = False,
1266                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1267                         .ips            = addresses_B_1,
1268                         .apply_expected = True
1269                 },
1270                 .r2     = {
1271                         .owner          = &ctx->a,
1272                         .type           = WREPL_TYPE_GROUP,
1273                         .state          = WREPL_STATE_TOMBSTONE,
1274                         .node           = WREPL_NODE_B,
1275                         .is_static      = False,
1276                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1277                         .ips            = addresses_A_1,
1278                         .apply_expected = True
1279                 }
1280         },
1281
1282 /*
1283  * unique vs special groups section,
1284  */
1285         /* 
1286          * unique,active vs. sgroup,active
1287          * => should NOT be replaced
1288          */
1289         {
1290                 .line   = __location__,
1291                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1292                 .r1     = {
1293                         .owner          = &ctx->a,
1294                         .type           = WREPL_TYPE_UNIQUE,
1295                         .state          = WREPL_STATE_ACTIVE,
1296                         .node           = WREPL_NODE_B,
1297                         .is_static      = False,
1298                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1299                         .ips            = addresses_A_1,
1300                         .apply_expected = True
1301                 },
1302                 .r2     = {
1303                         .owner          = &ctx->b,
1304                         .type           = WREPL_TYPE_SGROUP,
1305                         .state          = WREPL_STATE_ACTIVE,
1306                         .node           = WREPL_NODE_B,
1307                         .is_static      = False,
1308                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1309                         .ips            = addresses_A_1,
1310                         .apply_expected = False
1311                 }
1312         },
1313
1314         /* 
1315          * unique,active vs. sgroup,tombstone
1316          * => should NOT be replaced
1317          */
1318         {
1319                 .line   = __location__,
1320                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1321                 .r1     = {
1322                         .owner          = &ctx->a,
1323                         .type           = WREPL_TYPE_UNIQUE,
1324                         .state          = WREPL_STATE_ACTIVE,
1325                         .node           = WREPL_NODE_B,
1326                         .is_static      = False,
1327                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1328                         .ips            = addresses_A_1,
1329                         .apply_expected = True
1330                 },
1331                 .r2     = {
1332                         .owner          = &ctx->b,
1333                         .type           = WREPL_TYPE_SGROUP,
1334                         .state          = WREPL_STATE_TOMBSTONE,
1335                         .node           = WREPL_NODE_B,
1336                         .is_static      = False,
1337                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1338                         .ips            = addresses_A_1,
1339                         .apply_expected = False
1340                 }
1341         },
1342
1343         /* 
1344          * unique,released vs. sgroup,active
1345          * => should be replaced
1346          */
1347         {
1348                 .line   = __location__,
1349                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1350                 .r1     = {
1351                         .owner          = &ctx->a,
1352                         .type           = WREPL_TYPE_UNIQUE,
1353                         .state          = WREPL_STATE_RELEASED,
1354                         .node           = WREPL_NODE_B,
1355                         .is_static      = False,
1356                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1357                         .ips            = addresses_A_1,
1358                         .apply_expected = False
1359                 },
1360                 .r2     = {
1361                         .owner          = &ctx->b,
1362                         .type           = WREPL_TYPE_SGROUP,
1363                         .state          = WREPL_STATE_ACTIVE,
1364                         .node           = WREPL_NODE_B,
1365                         .is_static      = False,
1366                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1367                         .ips            = addresses_B_3_4,
1368                         .apply_expected = True
1369                 }
1370         },
1371
1372         /* 
1373          * unique,released vs. sgroup,tombstone
1374          * => should be replaced
1375          */
1376         {
1377                 .line   = __location__,
1378                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1379                 .r1     = {
1380                         .owner          = &ctx->b,
1381                         .type           = WREPL_TYPE_UNIQUE,
1382                         .state          = WREPL_STATE_RELEASED,
1383                         .node           = WREPL_NODE_B,
1384                         .is_static      = False,
1385                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1386                         .ips            = addresses_B_1,
1387                         .apply_expected = False
1388                 },
1389                 .r2     = {
1390                         .owner          = &ctx->a,
1391                         .type           = WREPL_TYPE_SGROUP,
1392                         .state          = WREPL_STATE_TOMBSTONE,
1393                         .node           = WREPL_NODE_B,
1394                         .is_static      = False,
1395                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1396                         .ips            = addresses_A_3_4,
1397                         .apply_expected = True
1398                 }
1399         },
1400
1401         /* 
1402          * unique,tombstone vs. sgroup,active
1403          * => should be replaced
1404          */
1405         {
1406                 .line   = __location__,
1407                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1408                 .r1     = {
1409                         .owner          = &ctx->a,
1410                         .type           = WREPL_TYPE_UNIQUE,
1411                         .state          = WREPL_STATE_TOMBSTONE,
1412                         .node           = WREPL_NODE_B,
1413                         .is_static      = False,
1414                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1415                         .ips            = addresses_A_1,
1416                         .apply_expected = True
1417                 },
1418                 .r2     = {
1419                         .owner          = &ctx->b,
1420                         .type           = WREPL_TYPE_SGROUP,
1421                         .state          = WREPL_STATE_ACTIVE,
1422                         .node           = WREPL_NODE_B,
1423                         .is_static      = False,
1424                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1425                         .ips            = addresses_B_3_4,
1426                         .apply_expected = True
1427                 }
1428         },
1429
1430         /* 
1431          * unique,tombstone vs. sgroup,tombstone
1432          * => should be replaced
1433          */
1434         {
1435                 .line   = __location__,
1436                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1437                 .r1     = {
1438                         .owner          = &ctx->b,
1439                         .type           = WREPL_TYPE_UNIQUE,
1440                         .state          = WREPL_STATE_TOMBSTONE,
1441                         .node           = WREPL_NODE_B,
1442                         .is_static      = False,
1443                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1444                         .ips            = addresses_B_1,
1445                         .apply_expected = True
1446                 },
1447                 .r2     = {
1448                         .owner          = &ctx->a,
1449                         .type           = WREPL_TYPE_SGROUP,
1450                         .state          = WREPL_STATE_TOMBSTONE,
1451                         .node           = WREPL_NODE_B,
1452                         .is_static      = False,
1453                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1454                         .ips            = addresses_A_3_4,
1455                         .apply_expected = True
1456                 }
1457         },
1458
1459 /*
1460  * unique vs multi homed section,
1461  */
1462         /* 
1463          * unique,active vs. mhomed,active
1464          * => should be replaced
1465          */
1466         {
1467                 .line   = __location__,
1468                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1469                 .r1     = {
1470                         .owner          = &ctx->a,
1471                         .type           = WREPL_TYPE_UNIQUE,
1472                         .state          = WREPL_STATE_ACTIVE,
1473                         .node           = WREPL_NODE_B,
1474                         .is_static      = False,
1475                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1476                         .ips            = addresses_A_1,
1477                         .apply_expected = True
1478                 },
1479                 .r2     = {
1480                         .owner          = &ctx->b,
1481                         .type           = WREPL_TYPE_MHOMED,
1482                         .state          = WREPL_STATE_ACTIVE,
1483                         .node           = WREPL_NODE_B,
1484                         .is_static      = False,
1485                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1486                         .ips            = addresses_B_3_4,
1487                         .apply_expected = True
1488                 }
1489         },
1490
1491         /* 
1492          * unique,active vs. mhomed,tombstone
1493          * => should NOT be replaced
1494          */
1495         {
1496                 .line   = __location__,
1497                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1498                 .r1     = {
1499                         .owner          = &ctx->b,
1500                         .type           = WREPL_TYPE_UNIQUE,
1501                         .state          = WREPL_STATE_ACTIVE,
1502                         .node           = WREPL_NODE_B,
1503                         .is_static      = False,
1504                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1505                         .ips            = addresses_B_3_4,
1506                         .apply_expected = True
1507                 },
1508                 .r2     = {
1509                         .owner          = &ctx->a,
1510                         .type           = WREPL_TYPE_MHOMED,
1511                         .state          = WREPL_STATE_TOMBSTONE,
1512                         .node           = WREPL_NODE_B,
1513                         .is_static      = False,
1514                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1515                         .ips            = addresses_B_3_4,
1516                         .apply_expected = False
1517                 }
1518         },
1519
1520         /* 
1521          * unique,released vs. mhomed,active
1522          * => should be replaced
1523          */
1524         {
1525                 .line   = __location__,
1526                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1527                 .r1     = {
1528                         .owner          = &ctx->b,
1529                         .type           = WREPL_TYPE_UNIQUE,
1530                         .state          = WREPL_STATE_RELEASED,
1531                         .node           = WREPL_NODE_B,
1532                         .is_static      = False,
1533                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1534                         .ips            = addresses_B_1,
1535                         .apply_expected = False
1536                 },
1537                 .r2     = {
1538                         .owner          = &ctx->a,
1539                         .type           = WREPL_TYPE_MHOMED,
1540                         .state          = WREPL_STATE_ACTIVE,
1541                         .node           = WREPL_NODE_B,
1542                         .is_static      = False,
1543                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1544                         .ips            = addresses_A_3_4,
1545                         .apply_expected = True
1546                 }
1547         },
1548
1549         /* 
1550          * unique,released vs. mhomed,tombstone
1551          * => should be replaced
1552          */
1553         {
1554                 .line   = __location__,
1555                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1556                 .r1     = {
1557                         .owner          = &ctx->a,
1558                         .type           = WREPL_TYPE_UNIQUE,
1559                         .state          = WREPL_STATE_RELEASED,
1560                         .node           = WREPL_NODE_B,
1561                         .is_static      = False,
1562                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1563                         .ips            = addresses_A_1,
1564                         .apply_expected = False
1565                 },
1566                 .r2     = {
1567                         .owner          = &ctx->b,
1568                         .type           = WREPL_TYPE_MHOMED,
1569                         .state          = WREPL_STATE_TOMBSTONE,
1570                         .node           = WREPL_NODE_B,
1571                         .is_static      = False,
1572                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1573                         .ips            = addresses_B_3_4,
1574                         .apply_expected = True
1575                 }
1576         },
1577
1578         /* 
1579          * unique,tombstone vs. mhomed,active
1580          * => should be replaced
1581          */
1582         {
1583                 .line   = __location__,
1584                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1585                 .r1     = {
1586                         .owner          = &ctx->b,
1587                         .type           = WREPL_TYPE_UNIQUE,
1588                         .state          = WREPL_STATE_TOMBSTONE,
1589                         .node           = WREPL_NODE_B,
1590                         .is_static      = False,
1591                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1592                         .ips            = addresses_B_1,
1593                         .apply_expected = True
1594                 },
1595                 .r2     = {
1596                         .owner          = &ctx->a,
1597                         .type           = WREPL_TYPE_MHOMED,
1598                         .state          = WREPL_STATE_ACTIVE,
1599                         .node           = WREPL_NODE_B,
1600                         .is_static      = False,
1601                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1602                         .ips            = addresses_A_3_4,
1603                         .apply_expected = True
1604                 }
1605         },
1606
1607         /* 
1608          * unique,tombstone vs. mhomed,tombstone
1609          * => should be replaced
1610          */
1611         {
1612                 .line   = __location__,
1613                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1614                 .r1     = {
1615                         .owner          = &ctx->a,
1616                         .type           = WREPL_TYPE_UNIQUE,
1617                         .state          = WREPL_STATE_TOMBSTONE,
1618                         .node           = WREPL_NODE_B,
1619                         .is_static      = False,
1620                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1621                         .ips            = addresses_A_1,
1622                         .apply_expected = True
1623                 },
1624                 .r2     = {
1625                         .owner          = &ctx->b,
1626                         .type           = WREPL_TYPE_MHOMED,
1627                         .state          = WREPL_STATE_TOMBSTONE,
1628                         .node           = WREPL_NODE_B,
1629                         .is_static      = False,
1630                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1631                         .ips            = addresses_B_3_4,
1632                         .apply_expected = True
1633                 }
1634         },
1635
1636 /*
1637  * normal groups vs unique section,
1638  */
1639         /* 
1640          * group,active vs. unique,active
1641          * => should NOT be replaced
1642          */
1643         {
1644                 .line   = __location__,
1645                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1646                 .r1     = {
1647                         .owner          = &ctx->a,
1648                         .type           = WREPL_TYPE_GROUP,
1649                         .state          = WREPL_STATE_ACTIVE,
1650                         .node           = WREPL_NODE_B,
1651                         .is_static      = False,
1652                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1653                         .ips            = addresses_A_1,
1654                         .apply_expected = True
1655                 },
1656                 .r2     = {
1657                         .owner          = &ctx->b,
1658                         .type           = WREPL_TYPE_UNIQUE,
1659                         .state          = WREPL_STATE_ACTIVE,
1660                         .node           = WREPL_NODE_B,
1661                         .is_static      = False,
1662                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1663                         .ips            = addresses_A_1,
1664                         .apply_expected = False
1665                 }
1666         },
1667
1668         /* 
1669          * group,active vs. unique,tombstone
1670          * => should NOT be replaced
1671          */
1672         {
1673                 .line   = __location__,
1674                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1675                 .r1     = {
1676                         .owner          = &ctx->a,
1677                         .type           = WREPL_TYPE_GROUP,
1678                         .state          = WREPL_STATE_ACTIVE,
1679                         .node           = WREPL_NODE_B,
1680                         .is_static      = False,
1681                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1682                         .ips            = addresses_A_1,
1683                         .apply_expected = True
1684                 },
1685                 .r2     = {
1686                         .owner          = &ctx->b,
1687                         .type           = WREPL_TYPE_UNIQUE,
1688                         .state          = WREPL_STATE_TOMBSTONE,
1689                         .node           = WREPL_NODE_B,
1690                         .is_static      = False,
1691                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1692                         .ips            = addresses_A_1,
1693                         .apply_expected = False
1694                 }
1695         },
1696
1697         /* 
1698          * group,released vs. unique,active
1699          * => should NOT be replaced
1700          */
1701         {
1702                 .line   = __location__,
1703                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1704                 .r1     = {
1705                         .owner          = &ctx->a,
1706                         .type           = WREPL_TYPE_GROUP,
1707                         .state          = WREPL_STATE_RELEASED,
1708                         .node           = WREPL_NODE_B,
1709                         .is_static      = False,
1710                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1711                         .ips            = addresses_A_1,
1712                         .apply_expected = False
1713                 },
1714                 .r2     = {
1715                         .owner          = &ctx->b,
1716                         .type           = WREPL_TYPE_UNIQUE,
1717                         .state          = WREPL_STATE_ACTIVE,
1718                         .node           = WREPL_NODE_B,
1719                         .is_static      = False,
1720                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1721                         .ips            = addresses_A_1,
1722                         .apply_expected = False
1723                 }
1724         },
1725
1726         /* 
1727          * group,released vs. unique,tombstone
1728          * => should NOT be replaced
1729          */
1730         {
1731                 .line   = __location__,
1732                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1733                 .r1     = {
1734                         .owner          = &ctx->a,
1735                         .type           = WREPL_TYPE_GROUP,
1736                         .state          = WREPL_STATE_RELEASED,
1737                         .node           = WREPL_NODE_B,
1738                         .is_static      = False,
1739                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1740                         .ips            = addresses_A_1,
1741                         .apply_expected = False
1742                 },
1743                 .r2     = {
1744                         .owner          = &ctx->b,
1745                         .type           = WREPL_TYPE_UNIQUE,
1746                         .state          = WREPL_STATE_TOMBSTONE,
1747                         .node           = WREPL_NODE_B,
1748                         .is_static      = False,
1749                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1750                         .ips            = addresses_A_1,
1751                         .apply_expected = False
1752                 }
1753         },
1754
1755         /* 
1756          * group,tombstone vs. unique,active
1757          * => should NOT be replaced
1758          */
1759         {
1760                 .line   = __location__,
1761                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1762                 .r1     = {
1763                         .owner          = &ctx->a,
1764                         .type           = WREPL_TYPE_GROUP,
1765                         .state          = WREPL_STATE_TOMBSTONE,
1766                         .node           = WREPL_NODE_B,
1767                         .is_static      = False,
1768                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1769                         .ips            = addresses_A_1,
1770                         .apply_expected = True
1771                 },
1772                 .r2     = {
1773                         .owner          = &ctx->b,
1774                         .type           = WREPL_TYPE_UNIQUE,
1775                         .state          = WREPL_STATE_ACTIVE,
1776                         .node           = WREPL_NODE_B,
1777                         .is_static      = False,
1778                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1779                         .ips            = addresses_A_1,
1780                         .apply_expected = False
1781                 }
1782         },
1783
1784         /* 
1785          * group,tombstone vs. unique,tombstone
1786          * => should NOT be replaced
1787          */
1788         {
1789                 .line   = __location__,
1790                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1791                 .r1     = {
1792                         .owner          = &ctx->a,
1793                         .type           = WREPL_TYPE_GROUP,
1794                         .state          = WREPL_STATE_TOMBSTONE,
1795                         .node           = WREPL_NODE_B,
1796                         .is_static      = False,
1797                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1798                         .ips            = addresses_A_1,
1799                         .apply_expected = True
1800                 },
1801                 .r2     = {
1802                         .owner          = &ctx->b,
1803                         .type           = WREPL_TYPE_UNIQUE,
1804                         .state          = WREPL_STATE_TOMBSTONE,
1805                         .node           = WREPL_NODE_B,
1806                         .is_static      = False,
1807                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1808                         .ips            = addresses_A_1,
1809                         .apply_expected = False
1810                 }
1811         },
1812
1813 /*
1814  * normal groups vs normal groups section,
1815  */
1816         /* 
1817          * group,active vs. group,active
1818          * => should NOT be replaced
1819          */
1820         {
1821                 .line   = __location__,
1822                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1823                 .r1     = {
1824                         .owner          = &ctx->a,
1825                         .type           = WREPL_TYPE_GROUP,
1826                         .state          = WREPL_STATE_ACTIVE,
1827                         .node           = WREPL_NODE_B,
1828                         .is_static      = False,
1829                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1830                         .ips            = addresses_A_1,
1831                         .apply_expected = True
1832                 },
1833                 .r2     = {
1834                         .owner          = &ctx->b,
1835                         .type           = WREPL_TYPE_GROUP,
1836                         .state          = WREPL_STATE_ACTIVE,
1837                         .node           = WREPL_NODE_B,
1838                         .is_static      = False,
1839                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1840                         .ips            = addresses_A_1,
1841                         .apply_expected = False
1842                 }
1843         },
1844
1845         /* 
1846          * group,active vs. group,tombstone
1847          * => should NOT be replaced
1848          */
1849         {
1850                 .line   = __location__,
1851                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1852                 .r1     = {
1853                         .owner          = &ctx->a,
1854                         .type           = WREPL_TYPE_GROUP,
1855                         .state          = WREPL_STATE_ACTIVE,
1856                         .node           = WREPL_NODE_B,
1857                         .is_static      = False,
1858                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1859                         .ips            = addresses_A_1,
1860                         .apply_expected = True
1861                 },
1862                 .r2     = {
1863                         .owner          = &ctx->b,
1864                         .type           = WREPL_TYPE_GROUP,
1865                         .state          = WREPL_STATE_TOMBSTONE,
1866                         .node           = WREPL_NODE_B,
1867                         .is_static      = False,
1868                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1869                         .ips            = addresses_A_1,
1870                         .apply_expected = False
1871                 }
1872         },
1873
1874         /* 
1875          * group,released vs. group,active
1876          * => should be replaced
1877          */
1878         {
1879                 .line   = __location__,
1880                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1881                 .r1     = {
1882                         .owner          = &ctx->a,
1883                         .type           = WREPL_TYPE_GROUP,
1884                         .state          = WREPL_STATE_RELEASED,
1885                         .node           = WREPL_NODE_B,
1886                         .is_static      = False,
1887                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1888                         .ips            = addresses_A_1,
1889                         .apply_expected = False
1890                 },
1891                 .r2     = {
1892                         .owner          = &ctx->b,
1893                         .type           = WREPL_TYPE_GROUP,
1894                         .state          = WREPL_STATE_ACTIVE,
1895                         .node           = WREPL_NODE_B,
1896                         .is_static      = False,
1897                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1898                         .ips            = addresses_B_1,
1899                         .apply_expected = True
1900                 }
1901         },
1902
1903         /* 
1904          * group,released vs. group,tombstone
1905          * => should be replaced
1906          */
1907         {
1908                 .line   = __location__,
1909                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1910                 .r1     = {
1911                         .owner          = &ctx->a,
1912                         .type           = WREPL_TYPE_GROUP,
1913                         .state          = WREPL_STATE_RELEASED,
1914                         .node           = WREPL_NODE_B,
1915                         .is_static      = False,
1916                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1917                         .ips            = addresses_A_1,
1918                         .apply_expected = False
1919                 },
1920                 .r2     = {
1921                         .owner          = &ctx->b,
1922                         .type           = WREPL_TYPE_GROUP,
1923                         .state          = WREPL_STATE_TOMBSTONE,
1924                         .node           = WREPL_NODE_B,
1925                         .is_static      = False,
1926                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1927                         .ips            = addresses_B_1,
1928                         .apply_expected = True
1929                 }
1930         },
1931
1932         /* 
1933          * group,tombstone vs. group,active
1934          * => should be replaced
1935          */
1936         {
1937                 .line   = __location__,
1938                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1939                 .r1     = {
1940                         .owner          = &ctx->b,
1941                         .type           = WREPL_TYPE_GROUP,
1942                         .state          = WREPL_STATE_TOMBSTONE,
1943                         .node           = WREPL_NODE_B,
1944                         .is_static      = False,
1945                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1946                         .ips            = addresses_B_1,
1947                         .apply_expected = True
1948                 },
1949                 .r2     = {
1950                         .owner          = &ctx->a,
1951                         .type           = WREPL_TYPE_GROUP,
1952                         .state          = WREPL_STATE_ACTIVE,
1953                         .node           = WREPL_NODE_B,
1954                         .is_static      = False,
1955                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1956                         .ips            = addresses_A_1,
1957                         .apply_expected = True
1958                 }
1959         },
1960
1961         /* 
1962          * group,tombstone vs. group,tombstone
1963          * => should be replaced
1964          */
1965         {
1966                 .line   = __location__,
1967                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1968                 .r1     = {
1969                         .owner          = &ctx->a,
1970                         .type           = WREPL_TYPE_GROUP,
1971                         .state          = WREPL_STATE_TOMBSTONE,
1972                         .node           = WREPL_NODE_B,
1973                         .is_static      = False,
1974                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1975                         .ips            = addresses_A_1,
1976                         .apply_expected = True
1977                 },
1978                 .r2     = {
1979                         .owner          = &ctx->b,
1980                         .type           = WREPL_TYPE_GROUP,
1981                         .state          = WREPL_STATE_TOMBSTONE,
1982                         .node           = WREPL_NODE_B,
1983                         .is_static      = False,
1984                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1985                         .ips            = addresses_B_1,
1986                         .apply_expected = True
1987                 }
1988         },
1989
1990 /*
1991  * normal groups vs special groups section,
1992  */
1993         /* 
1994          * group,active vs. sgroup,active
1995          * => should NOT be replaced
1996          */
1997         {
1998                 .line   = __location__,
1999                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2000                 .r1     = {
2001                         .owner          = &ctx->b,
2002                         .type           = WREPL_TYPE_GROUP,
2003                         .state          = WREPL_STATE_ACTIVE,
2004                         .node           = WREPL_NODE_B,
2005                         .is_static      = False,
2006                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2007                         .ips            = addresses_B_1,
2008                         .apply_expected = True
2009                 },
2010                 .r2     = {
2011                         .owner          = &ctx->a,
2012                         .type           = WREPL_TYPE_SGROUP,
2013                         .state          = WREPL_STATE_ACTIVE,
2014                         .node           = WREPL_NODE_B,
2015                         .is_static      = False,
2016                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2017                         .ips            = addresses_B_1,
2018                         .apply_expected = False
2019                 }
2020         },
2021
2022         /* 
2023          * group,active vs. sgroup,tombstone
2024          * => should NOT be replaced
2025          */
2026         {
2027                 .line   = __location__,
2028                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2029                 .r1     = {
2030                         .owner          = &ctx->b,
2031                         .type           = WREPL_TYPE_GROUP,
2032                         .state          = WREPL_STATE_ACTIVE,
2033                         .node           = WREPL_NODE_B,
2034                         .is_static      = False,
2035                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2036                         .ips            = addresses_B_1,
2037                         .apply_expected = True
2038                 },
2039                 .r2     = {
2040                         .owner          = &ctx->a,
2041                         .type           = WREPL_TYPE_SGROUP,
2042                         .state          = WREPL_STATE_TOMBSTONE,
2043                         .node           = WREPL_NODE_B,
2044                         .is_static      = False,
2045                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2046                         .ips            = addresses_B_1,
2047                         .apply_expected = False
2048                 }
2049         },
2050
2051         /* 
2052          * group,released vs. sgroup,active
2053          * => should be replaced
2054          */
2055         {
2056                 .line   = __location__,
2057                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2058                 .r1     = {
2059                         .owner          = &ctx->a,
2060                         .type           = WREPL_TYPE_GROUP,
2061                         .state          = WREPL_STATE_RELEASED,
2062                         .node           = WREPL_NODE_B,
2063                         .is_static      = False,
2064                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2065                         .ips            = addresses_A_1,
2066                         .apply_expected = False
2067                 },
2068                 .r2     = {
2069                         .owner          = &ctx->b,
2070                         .type           = WREPL_TYPE_SGROUP,
2071                         .state          = WREPL_STATE_ACTIVE,
2072                         .node           = WREPL_NODE_B,
2073                         .is_static      = False,
2074                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2075                         .ips            = addresses_B_1,
2076                         .apply_expected = True
2077                 }
2078         },
2079
2080         /* 
2081          * group,released vs. sgroup,tombstone
2082          * => should NOT be replaced
2083          */
2084         {
2085                 .line   = __location__,
2086                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2087                 .r1     = {
2088                         .owner          = &ctx->b,
2089                         .type           = WREPL_TYPE_GROUP,
2090                         .state          = WREPL_STATE_RELEASED,
2091                         .node           = WREPL_NODE_B,
2092                         .is_static      = False,
2093                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2094                         .ips            = addresses_B_1,
2095                         .apply_expected = False
2096                 },
2097                 .r2     = {
2098                         .owner          = &ctx->a,
2099                         .type           = WREPL_TYPE_SGROUP,
2100                         .state          = WREPL_STATE_TOMBSTONE,
2101                         .node           = WREPL_NODE_B,
2102                         .is_static      = False,
2103                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2104                         .ips            = addresses_B_1,
2105                         .apply_expected = False
2106                 }
2107         },
2108
2109         /* 
2110          * group,tombstone vs. sgroup,active
2111          * => should be replaced
2112          */
2113         {
2114                 .line   = __location__,
2115                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2116                 .r1     = {
2117                         .owner          = &ctx->b,
2118                         .type           = WREPL_TYPE_GROUP,
2119                         .state          = WREPL_STATE_TOMBSTONE,
2120                         .node           = WREPL_NODE_B,
2121                         .is_static      = False,
2122                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2123                         .ips            = addresses_B_1,
2124                         .apply_expected = True
2125                 },
2126                 .r2     = {
2127                         .owner          = &ctx->a,
2128                         .type           = WREPL_TYPE_SGROUP,
2129                         .state          = WREPL_STATE_ACTIVE,
2130                         .node           = WREPL_NODE_B,
2131                         .is_static      = False,
2132                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2133                         .ips            = addresses_A_1,
2134                         .apply_expected = True
2135                 }
2136         },
2137
2138         /* 
2139          * group,tombstone vs. sgroup,tombstone
2140          * => should be replaced
2141          */
2142         {
2143                 .line   = __location__,
2144                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2145                 .r1     = {
2146                         .owner          = &ctx->a,
2147                         .type           = WREPL_TYPE_GROUP,
2148                         .state          = WREPL_STATE_TOMBSTONE,
2149                         .node           = WREPL_NODE_B,
2150                         .is_static      = False,
2151                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2152                         .ips            = addresses_A_1,
2153                         .apply_expected = True
2154                 },
2155                 .r2     = {
2156                         .owner          = &ctx->b,
2157                         .type           = WREPL_TYPE_SGROUP,
2158                         .state          = WREPL_STATE_TOMBSTONE,
2159                         .node           = WREPL_NODE_B,
2160                         .is_static      = False,
2161                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2162                         .ips            = addresses_B_1,
2163                         .apply_expected = True
2164                 }
2165         },
2166
2167 /*
2168  * normal groups vs multi homed section,
2169  */
2170         /* 
2171          * group,active vs. mhomed,active
2172          * => should NOT be replaced
2173          */
2174         {
2175                 .line   = __location__,
2176                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2177                 .r1     = {
2178                         .owner          = &ctx->b,
2179                         .type           = WREPL_TYPE_GROUP,
2180                         .state          = WREPL_STATE_ACTIVE,
2181                         .node           = WREPL_NODE_B,
2182                         .is_static      = False,
2183                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2184                         .ips            = addresses_B_1,
2185                         .apply_expected = True
2186                 },
2187                 .r2     = {
2188                         .owner          = &ctx->a,
2189                         .type           = WREPL_TYPE_MHOMED,
2190                         .state          = WREPL_STATE_ACTIVE,
2191                         .node           = WREPL_NODE_B,
2192                         .is_static      = False,
2193                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2194                         .ips            = addresses_B_1,
2195                         .apply_expected = False
2196                 }
2197         },
2198
2199         /* 
2200          * group,active vs. mhomed,tombstone
2201          * => should NOT be replaced
2202          */
2203         {
2204                 .line   = __location__,
2205                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2206                 .r1     = {
2207                         .owner          = &ctx->b,
2208                         .type           = WREPL_TYPE_GROUP,
2209                         .state          = WREPL_STATE_ACTIVE,
2210                         .node           = WREPL_NODE_B,
2211                         .is_static      = False,
2212                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2213                         .ips            = addresses_B_1,
2214                         .apply_expected = True
2215                 },
2216                 .r2     = {
2217                         .owner          = &ctx->a,
2218                         .type           = WREPL_TYPE_MHOMED,
2219                         .state          = WREPL_STATE_TOMBSTONE,
2220                         .node           = WREPL_NODE_B,
2221                         .is_static      = False,
2222                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2223                         .ips            = addresses_B_1,
2224                         .apply_expected = False
2225                 }
2226         },
2227
2228         /* 
2229          * group,released vs. mhomed,active
2230          * => should NOT be replaced
2231          */
2232         {
2233                 .line   = __location__,
2234                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2235                 .r1     = {
2236                         .owner          = &ctx->b,
2237                         .type           = WREPL_TYPE_GROUP,
2238                         .state          = WREPL_STATE_RELEASED,
2239                         .node           = WREPL_NODE_B,
2240                         .is_static      = False,
2241                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2242                         .ips            = addresses_B_1,
2243                         .apply_expected = False
2244                 },
2245                 .r2     = {
2246                         .owner          = &ctx->a,
2247                         .type           = WREPL_TYPE_MHOMED,
2248                         .state          = WREPL_STATE_ACTIVE,
2249                         .node           = WREPL_NODE_B,
2250                         .is_static      = False,
2251                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2252                         .ips            = addresses_B_1,
2253                         .apply_expected = False
2254                 }
2255         },
2256
2257         /* 
2258          * group,released vs. mhomed,tombstone
2259          * => should NOT be replaced
2260          */
2261         {
2262                 .line   = __location__,
2263                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2264                 .r1     = {
2265                         .owner          = &ctx->b,
2266                         .type           = WREPL_TYPE_GROUP,
2267                         .state          = WREPL_STATE_RELEASED,
2268                         .node           = WREPL_NODE_B,
2269                         .is_static      = False,
2270                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2271                         .ips            = addresses_B_1,
2272                         .apply_expected = False
2273                 },
2274                 .r2     = {
2275                         .owner          = &ctx->a,
2276                         .type           = WREPL_TYPE_MHOMED,
2277                         .state          = WREPL_STATE_TOMBSTONE,
2278                         .node           = WREPL_NODE_B,
2279                         .is_static      = False,
2280                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2281                         .ips            = addresses_B_1,
2282                         .apply_expected = False
2283                 }
2284         },
2285
2286         /* 
2287          * group,tombstone vs. mhomed,active
2288          * => should be replaced
2289          */
2290         {
2291                 .line   = __location__,
2292                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2293                 .r1     = {
2294                         .owner          = &ctx->b,
2295                         .type           = WREPL_TYPE_GROUP,
2296                         .state          = WREPL_STATE_TOMBSTONE,
2297                         .node           = WREPL_NODE_B,
2298                         .is_static      = False,
2299                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2300                         .ips            = addresses_B_1,
2301                         .apply_expected = True
2302                 },
2303                 .r2     = {
2304                         .owner          = &ctx->a,
2305                         .type           = WREPL_TYPE_MHOMED,
2306                         .state          = WREPL_STATE_ACTIVE,
2307                         .node           = WREPL_NODE_B,
2308                         .is_static      = False,
2309                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2310                         .ips            = addresses_A_1,
2311                         .apply_expected = True
2312                 }
2313         },
2314
2315         /* 
2316          * group,tombstone vs. mhomed,tombstone
2317          * => should be replaced
2318          */
2319         {
2320                 .line   = __location__,
2321                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2322                 .r1     = {
2323                         .owner          = &ctx->a,
2324                         .type           = WREPL_TYPE_GROUP,
2325                         .state          = WREPL_STATE_TOMBSTONE,
2326                         .node           = WREPL_NODE_B,
2327                         .is_static      = False,
2328                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2329                         .ips            = addresses_A_1,
2330                         .apply_expected = True
2331                 },
2332                 .r2     = {
2333                         .owner          = &ctx->b,
2334                         .type           = WREPL_TYPE_MHOMED,
2335                         .state          = WREPL_STATE_TOMBSTONE,
2336                         .node           = WREPL_NODE_B,
2337                         .is_static      = False,
2338                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2339                         .ips            = addresses_B_1,
2340                         .apply_expected = True
2341                 }
2342         },
2343
2344 /*
2345  * special groups vs unique section,
2346  */
2347         /* 
2348          * sgroup,active vs. unique,active
2349          * => should NOT be replaced
2350          */
2351         {
2352                 .line   = __location__,
2353                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2354                 .r1     = {
2355                         .owner          = &ctx->b,
2356                         .type           = WREPL_TYPE_SGROUP,
2357                         .state          = WREPL_STATE_ACTIVE,
2358                         .node           = WREPL_NODE_B,
2359                         .is_static      = False,
2360                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2361                         .ips            = addresses_B_1,
2362                         .apply_expected = True
2363                 },
2364                 .r2     = {
2365                         .owner          = &ctx->a,
2366                         .type           = WREPL_TYPE_UNIQUE,
2367                         .state          = WREPL_STATE_ACTIVE,
2368                         .node           = WREPL_NODE_B,
2369                         .is_static      = False,
2370                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2371                         .ips            = addresses_B_1,
2372                         .apply_expected = False
2373                 }
2374         },
2375
2376         /* 
2377          * sgroup,active vs. unique,tombstone
2378          * => should NOT be replaced
2379          */
2380         {
2381                 .line   = __location__,
2382                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2383                 .r1     = {
2384                         .owner          = &ctx->b,
2385                         .type           = WREPL_TYPE_SGROUP,
2386                         .state          = WREPL_STATE_ACTIVE,
2387                         .node           = WREPL_NODE_B,
2388                         .is_static      = False,
2389                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2390                         .ips            = addresses_B_1,
2391                         .apply_expected = True
2392                 },
2393                 .r2     = {
2394                         .owner          = &ctx->a,
2395                         .type           = WREPL_TYPE_UNIQUE,
2396                         .state          = WREPL_STATE_TOMBSTONE,
2397                         .node           = WREPL_NODE_B,
2398                         .is_static      = False,
2399                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2400                         .ips            = addresses_B_1,
2401                         .apply_expected = False
2402                 }
2403         },
2404
2405         /* 
2406          * sgroup,released vs. unique,active
2407          * => should be replaced
2408          */
2409         {
2410                 .line   = __location__,
2411                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2412                 .r1     = {
2413                         .owner          = &ctx->b,
2414                         .type           = WREPL_TYPE_SGROUP,
2415                         .state          = WREPL_STATE_RELEASED,
2416                         .node           = WREPL_NODE_B,
2417                         .is_static      = False,
2418                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2419                         .ips            = addresses_B_1,
2420                         .apply_expected = False
2421                 },
2422                 .r2     = {
2423                         .owner          = &ctx->a,
2424                         .type           = WREPL_TYPE_UNIQUE,
2425                         .state          = WREPL_STATE_ACTIVE,
2426                         .node           = WREPL_NODE_B,
2427                         .is_static      = False,
2428                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2429                         .ips            = addresses_A_1,
2430                         .apply_expected = True
2431                 }
2432         },
2433
2434         /* 
2435          * sgroup,released vs. unique,tombstone
2436          * => should be replaced
2437          */
2438         {
2439                 .line   = __location__,
2440                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2441                 .r1     = {
2442                         .owner          = &ctx->a,
2443                         .type           = WREPL_TYPE_SGROUP,
2444                         .state          = WREPL_STATE_RELEASED,
2445                         .node           = WREPL_NODE_B,
2446                         .is_static      = False,
2447                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2448                         .ips            = addresses_A_1,
2449                         .apply_expected = False
2450                 },
2451                 .r2     = {
2452                         .owner          = &ctx->b,
2453                         .type           = WREPL_TYPE_UNIQUE,
2454                         .state          = WREPL_STATE_TOMBSTONE,
2455                         .node           = WREPL_NODE_B,
2456                         .is_static      = False,
2457                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2458                         .ips            = addresses_B_1,
2459                         .apply_expected = True
2460                 }
2461         },
2462
2463         /* 
2464          * sgroup,tombstone vs. unique,active
2465          * => should be replaced
2466          */
2467         {
2468                 .line   = __location__,
2469                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2470                 .r1     = {
2471                         .owner          = &ctx->a,
2472                         .type           = WREPL_TYPE_SGROUP,
2473                         .state          = WREPL_STATE_TOMBSTONE,
2474                         .node           = WREPL_NODE_B,
2475                         .is_static      = False,
2476                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2477                         .ips            = addresses_A_1,
2478                         .apply_expected = True
2479                 },
2480                 .r2     = {
2481                         .owner          = &ctx->b,
2482                         .type           = WREPL_TYPE_UNIQUE,
2483                         .state          = WREPL_STATE_ACTIVE,
2484                         .node           = WREPL_NODE_B,
2485                         .is_static      = False,
2486                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2487                         .ips            = addresses_B_1,
2488                         .apply_expected = True
2489                 }
2490         },
2491
2492         /* 
2493          * sgroup,tombstone vs. unique,tombstone
2494          * => should be replaced
2495          */
2496         {
2497                 .line   = __location__,
2498                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2499                 .r1     = {
2500                         .owner          = &ctx->b,
2501                         .type           = WREPL_TYPE_SGROUP,
2502                         .state          = WREPL_STATE_TOMBSTONE,
2503                         .node           = WREPL_NODE_B,
2504                         .is_static      = False,
2505                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2506                         .ips            = addresses_B_1,
2507                         .apply_expected = True
2508                 },
2509                 .r2     = {
2510                         .owner          = &ctx->a,
2511                         .type           = WREPL_TYPE_UNIQUE,
2512                         .state          = WREPL_STATE_TOMBSTONE,
2513                         .node           = WREPL_NODE_B,
2514                         .is_static      = False,
2515                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2516                         .ips            = addresses_A_1,
2517                         .apply_expected = True
2518                 }
2519         },
2520
2521 /*
2522  * special groups vs normal group section,
2523  */
2524         /* 
2525          * sgroup,active vs. group,active
2526          * => should NOT be replaced
2527          */
2528         {
2529                 .line   = __location__,
2530                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2531                 .r1     = {
2532                         .owner          = &ctx->a,
2533                         .type           = WREPL_TYPE_SGROUP,
2534                         .state          = WREPL_STATE_ACTIVE,
2535                         .node           = WREPL_NODE_B,
2536                         .is_static      = False,
2537                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2538                         .ips            = addresses_A_1,
2539                         .apply_expected = True
2540                 },
2541                 .r2     = {
2542                         .owner          = &ctx->b,
2543                         .type           = WREPL_TYPE_GROUP,
2544                         .state          = WREPL_STATE_ACTIVE,
2545                         .node           = WREPL_NODE_B,
2546                         .is_static      = False,
2547                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2548                         .ips            = addresses_A_1,
2549                         .apply_expected = False
2550                 }
2551         },
2552
2553         /* 
2554          * sgroup,active vs. group,tombstone
2555          * => should NOT be replaced
2556          */
2557         {
2558                 .line   = __location__,
2559                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2560                 .r1     = {
2561                         .owner          = &ctx->a,
2562                         .type           = WREPL_TYPE_SGROUP,
2563                         .state          = WREPL_STATE_ACTIVE,
2564                         .node           = WREPL_NODE_B,
2565                         .is_static      = False,
2566                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2567                         .ips            = addresses_A_1,
2568                         .apply_expected = True
2569                 },
2570                 .r2     = {
2571                         .owner          = &ctx->b,
2572                         .type           = WREPL_TYPE_GROUP,
2573                         .state          = WREPL_STATE_TOMBSTONE,
2574                         .node           = WREPL_NODE_B,
2575                         .is_static      = False,
2576                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2577                         .ips            = addresses_A_1,
2578                         .apply_expected = False
2579                 }
2580         },
2581
2582         /* 
2583          * sgroup,released vs. group,active
2584          * => should be replaced
2585          */
2586         {
2587                 .line   = __location__,
2588                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2589                 .r1     = {
2590                         .owner          = &ctx->a,
2591                         .type           = WREPL_TYPE_SGROUP,
2592                         .state          = WREPL_STATE_RELEASED,
2593                         .node           = WREPL_NODE_B,
2594                         .is_static      = False,
2595                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2596                         .ips            = addresses_A_1,
2597                         .apply_expected = False
2598                 },
2599                 .r2     = {
2600                         .owner          = &ctx->b,
2601                         .type           = WREPL_TYPE_GROUP,
2602                         .state          = WREPL_STATE_ACTIVE,
2603                         .node           = WREPL_NODE_B,
2604                         .is_static      = False,
2605                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2606                         .ips            = addresses_B_1,
2607                         .apply_expected = True
2608                 }
2609         },
2610
2611         /* 
2612          * sgroup,released vs. group,tombstone
2613          * => should be replaced
2614          */
2615         {
2616                 .line   = __location__,
2617                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2618                 .r1     = {
2619                         .owner          = &ctx->b,
2620                         .type           = WREPL_TYPE_SGROUP,
2621                         .state          = WREPL_STATE_RELEASED,
2622                         .node           = WREPL_NODE_B,
2623                         .is_static      = False,
2624                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2625                         .ips            = addresses_B_1,
2626                         .apply_expected = False
2627                 },
2628                 .r2     = {
2629                         .owner          = &ctx->a,
2630                         .type           = WREPL_TYPE_GROUP,
2631                         .state          = WREPL_STATE_TOMBSTONE,
2632                         .node           = WREPL_NODE_B,
2633                         .is_static      = False,
2634                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2635                         .ips            = addresses_A_1,
2636                         .apply_expected = True
2637                 }
2638         },
2639
2640         /* 
2641          * sgroup,tombstone vs. group,active
2642          * => should NOT be replaced
2643          */
2644         {
2645                 .line   = __location__,
2646                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2647                 .r1     = {
2648                         .owner          = &ctx->a,
2649                         .type           = WREPL_TYPE_SGROUP,
2650                         .state          = WREPL_STATE_TOMBSTONE,
2651                         .node           = WREPL_NODE_B,
2652                         .is_static      = False,
2653                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2654                         .ips            = addresses_A_1,
2655                         .apply_expected = True
2656                 },
2657                 .r2     = {
2658                         .owner          = &ctx->b,
2659                         .type           = WREPL_TYPE_GROUP,
2660                         .state          = WREPL_STATE_ACTIVE,
2661                         .node           = WREPL_NODE_B,
2662                         .is_static      = False,
2663                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2664                         .ips            = addresses_B_1,
2665                         .apply_expected = True
2666                 }
2667         },
2668
2669         /* 
2670          * sgroup,tombstone vs. group,tombstone
2671          * => should NOT be replaced
2672          */
2673         {
2674                 .line   = __location__,
2675                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2676                 .r1     = {
2677                         .owner          = &ctx->b,
2678                         .type           = WREPL_TYPE_SGROUP,
2679                         .state          = WREPL_STATE_TOMBSTONE,
2680                         .node           = WREPL_NODE_B,
2681                         .is_static      = False,
2682                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2683                         .ips            = addresses_B_1,
2684                         .apply_expected = True
2685                 },
2686                 .r2     = {
2687                         .owner          = &ctx->a,
2688                         .type           = WREPL_TYPE_GROUP,
2689                         .state          = WREPL_STATE_TOMBSTONE,
2690                         .node           = WREPL_NODE_B,
2691                         .is_static      = False,
2692                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2693                         .ips            = addresses_A_1,
2694                         .apply_expected = True
2695                 }
2696         },
2697
2698 /*
2699  * special groups vs multi homed section,
2700  */
2701         /* 
2702          * sgroup,active vs. mhomed,active
2703          * => should NOT be replaced
2704          */
2705         {
2706                 .line   = __location__,
2707                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2708                 .r1     = {
2709                         .owner          = &ctx->a,
2710                         .type           = WREPL_TYPE_SGROUP,
2711                         .state          = WREPL_STATE_ACTIVE,
2712                         .node           = WREPL_NODE_B,
2713                         .is_static      = False,
2714                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2715                         .ips            = addresses_A_1,
2716                         .apply_expected = True
2717                 },
2718                 .r2     = {
2719                         .owner          = &ctx->b,
2720                         .type           = WREPL_TYPE_MHOMED,
2721                         .state          = WREPL_STATE_ACTIVE,
2722                         .node           = WREPL_NODE_B,
2723                         .is_static      = False,
2724                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2725                         .ips            = addresses_A_1,
2726                         .apply_expected = False
2727                 }
2728         },
2729
2730         /* 
2731          * sgroup,active vs. mhomed,tombstone
2732          * => should NOT be replaced
2733          */
2734         {
2735                 .line   = __location__,
2736                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2737                 .r1     = {
2738                         .owner          = &ctx->a,
2739                         .type           = WREPL_TYPE_SGROUP,
2740                         .state          = WREPL_STATE_ACTIVE,
2741                         .node           = WREPL_NODE_B,
2742                         .is_static      = False,
2743                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2744                         .ips            = addresses_A_1,
2745                         .apply_expected = True
2746                 },
2747                 .r2     = {
2748                         .owner          = &ctx->b,
2749                         .type           = WREPL_TYPE_MHOMED,
2750                         .state          = WREPL_STATE_TOMBSTONE,
2751                         .node           = WREPL_NODE_B,
2752                         .is_static      = False,
2753                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2754                         .ips            = addresses_A_1,
2755                         .apply_expected = False
2756                 }
2757         },
2758
2759         /* 
2760          * sgroup,released vs. mhomed,active
2761          * => should be replaced
2762          */
2763         {
2764                 .line   = __location__,
2765                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2766                 .r1     = {
2767                         .owner          = &ctx->a,
2768                         .type           = WREPL_TYPE_SGROUP,
2769                         .state          = WREPL_STATE_RELEASED,
2770                         .node           = WREPL_NODE_B,
2771                         .is_static      = False,
2772                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2773                         .ips            = addresses_A_1,
2774                         .apply_expected = False
2775                 },
2776                 .r2     = {
2777                         .owner          = &ctx->b,
2778                         .type           = WREPL_TYPE_MHOMED,
2779                         .state          = WREPL_STATE_ACTIVE,
2780                         .node           = WREPL_NODE_B,
2781                         .is_static      = False,
2782                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2783                         .ips            = addresses_B_1,
2784                         .apply_expected = True
2785                 }
2786         },
2787
2788         /* 
2789          * sgroup,released vs. mhomed,tombstone
2790          * => should be replaced
2791          */
2792         {
2793                 .line   = __location__,
2794                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2795                 .r1     = {
2796                         .owner          = &ctx->b,
2797                         .type           = WREPL_TYPE_SGROUP,
2798                         .state          = WREPL_STATE_RELEASED,
2799                         .node           = WREPL_NODE_B,
2800                         .is_static      = False,
2801                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2802                         .ips            = addresses_B_1,
2803                         .apply_expected = False
2804                 },
2805                 .r2     = {
2806                         .owner          = &ctx->a,
2807                         .type           = WREPL_TYPE_MHOMED,
2808                         .state          = WREPL_STATE_TOMBSTONE,
2809                         .node           = WREPL_NODE_B,
2810                         .is_static      = False,
2811                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2812                         .ips            = addresses_A_1,
2813                         .apply_expected = True
2814                 }
2815         },
2816
2817         /* 
2818          * sgroup,tombstone vs. mhomed,active
2819          * => should be replaced
2820          */
2821         {
2822                 .line   = __location__,
2823                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2824                 .r1     = {
2825                         .owner          = &ctx->a,
2826                         .type           = WREPL_TYPE_SGROUP,
2827                         .state          = WREPL_STATE_TOMBSTONE,
2828                         .node           = WREPL_NODE_B,
2829                         .is_static      = False,
2830                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2831                         .ips            = addresses_A_1,
2832                         .apply_expected = True
2833                 },
2834                 .r2     = {
2835                         .owner          = &ctx->b,
2836                         .type           = WREPL_TYPE_MHOMED,
2837                         .state          = WREPL_STATE_ACTIVE,
2838                         .node           = WREPL_NODE_B,
2839                         .is_static      = False,
2840                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2841                         .ips            = addresses_B_1,
2842                         .apply_expected = True
2843                 }
2844         },
2845
2846         /* 
2847          * sgroup,tombstone vs. mhomed,tombstone
2848          * => should be replaced
2849          */
2850         {
2851                 .line   = __location__,
2852                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2853                 .r1     = {
2854                         .owner          = &ctx->b,
2855                         .type           = WREPL_TYPE_SGROUP,
2856                         .state          = WREPL_STATE_TOMBSTONE,
2857                         .node           = WREPL_NODE_B,
2858                         .is_static      = False,
2859                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2860                         .ips            = addresses_B_1,
2861                         .apply_expected = True
2862                 },
2863                 .r2     = {
2864                         .owner          = &ctx->a,
2865                         .type           = WREPL_TYPE_MHOMED,
2866                         .state          = WREPL_STATE_TOMBSTONE,
2867                         .node           = WREPL_NODE_B,
2868                         .is_static      = False,
2869                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2870                         .ips            = addresses_A_1,
2871                         .apply_expected = True
2872                 }
2873         },
2874
2875 /*
2876  * multi homed vs. unique section,
2877  */
2878         /* 
2879          * mhomed,active vs. unique,active
2880          * => should be replaced
2881          */
2882         {
2883                 .line   = __location__,
2884                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2885                 .r1     = {
2886                         .owner          = &ctx->a,
2887                         .type           = WREPL_TYPE_MHOMED,
2888                         .state          = WREPL_STATE_ACTIVE,
2889                         .node           = WREPL_NODE_B,
2890                         .is_static      = False,
2891                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
2892                         .ips            = addresses_A_3_4,
2893                         .apply_expected = True
2894                 },
2895                 .r2     = {
2896                         .owner          = &ctx->b,
2897                         .type           = WREPL_TYPE_UNIQUE,
2898                         .state          = WREPL_STATE_ACTIVE,
2899                         .node           = WREPL_NODE_B,
2900                         .is_static      = False,
2901                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2902                         .ips            = addresses_B_1,
2903                         .apply_expected = True
2904                 }
2905         },
2906
2907         /* 
2908          * mhomed,active vs. unique,tombstone
2909          * => should NOT be replaced
2910          */
2911         {
2912                 .line   = __location__,
2913                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2914                 .r1     = {
2915                         .owner          = &ctx->b,
2916                         .type           = WREPL_TYPE_MHOMED,
2917                         .state          = WREPL_STATE_ACTIVE,
2918                         .node           = WREPL_NODE_B,
2919                         .is_static      = False,
2920                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2921                         .ips            = addresses_B_1,
2922                         .apply_expected = True
2923                 },
2924                 .r2     = {
2925                         .owner          = &ctx->a,
2926                         .type           = WREPL_TYPE_UNIQUE,
2927                         .state          = WREPL_STATE_TOMBSTONE,
2928                         .node           = WREPL_NODE_B,
2929                         .is_static      = False,
2930                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2931                         .ips            = addresses_B_1,
2932                         .apply_expected = False
2933                 }
2934         },
2935
2936         /* 
2937          * mhomed,released vs. unique,active
2938          * => should be replaced
2939          */
2940         {
2941                 .line   = __location__,
2942                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2943                 .r1     = {
2944                         .owner          = &ctx->a,
2945                         .type           = WREPL_TYPE_MHOMED,
2946                         .state          = WREPL_STATE_RELEASED,
2947                         .node           = WREPL_NODE_B,
2948                         .is_static      = False,
2949                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2950                         .ips            = addresses_A_1,
2951                         .apply_expected = False
2952                 },
2953                 .r2     = {
2954                         .owner          = &ctx->b,
2955                         .type           = WREPL_TYPE_UNIQUE,
2956                         .state          = WREPL_STATE_ACTIVE,
2957                         .node           = WREPL_NODE_B,
2958                         .is_static      = False,
2959                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2960                         .ips            = addresses_B_1,
2961                         .apply_expected = True
2962                 }
2963         },
2964
2965         /* 
2966          * mhomed,released vs. uinique,tombstone
2967          * => should be replaced
2968          */
2969         {
2970                 .line   = __location__,
2971                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2972                 .r1     = {
2973                         .owner          = &ctx->b,
2974                         .type           = WREPL_TYPE_MHOMED,
2975                         .state          = WREPL_STATE_RELEASED,
2976                         .node           = WREPL_NODE_B,
2977                         .is_static      = False,
2978                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2979                         .ips            = addresses_B_1,
2980                         .apply_expected = False
2981                 },
2982                 .r2     = {
2983                         .owner          = &ctx->a,
2984                         .type           = WREPL_TYPE_UNIQUE,
2985                         .state          = WREPL_STATE_TOMBSTONE,
2986                         .node           = WREPL_NODE_B,
2987                         .is_static      = False,
2988                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2989                         .ips            = addresses_A_1,
2990                         .apply_expected = True
2991                 }
2992         },
2993
2994         /* 
2995          * mhomed,tombstone vs. unique,active
2996          * => should be replaced
2997          */
2998         {
2999                 .line   = __location__,
3000                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3001                 .r1     = {
3002                         .owner          = &ctx->a,
3003                         .type           = WREPL_TYPE_MHOMED,
3004                         .state          = WREPL_STATE_TOMBSTONE,
3005                         .node           = WREPL_NODE_B,
3006                         .is_static      = False,
3007                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3008                         .ips            = addresses_A_1,
3009                         .apply_expected = True
3010                 },
3011                 .r2     = {
3012                         .owner          = &ctx->b,
3013                         .type           = WREPL_TYPE_UNIQUE,
3014                         .state          = WREPL_STATE_ACTIVE,
3015                         .node           = WREPL_NODE_B,
3016                         .is_static      = False,
3017                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3018                         .ips            = addresses_B_1,
3019                         .apply_expected = True
3020                 }
3021         },
3022
3023         /* 
3024          * mhomed,tombstone vs. uinique,tombstone
3025          * => should be replaced
3026          */
3027         {
3028                 .line   = __location__,
3029                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3030                 .r1     = {
3031                         .owner          = &ctx->b,
3032                         .type           = WREPL_TYPE_MHOMED,
3033                         .state          = WREPL_STATE_TOMBSTONE,
3034                         .node           = WREPL_NODE_B,
3035                         .is_static      = False,
3036                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3037                         .ips            = addresses_B_1,
3038                         .apply_expected = True
3039                 },
3040                 .r2     = {
3041                         .owner          = &ctx->a,
3042                         .type           = WREPL_TYPE_UNIQUE,
3043                         .state          = WREPL_STATE_TOMBSTONE,
3044                         .node           = WREPL_NODE_B,
3045                         .is_static      = False,
3046                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3047                         .ips            = addresses_A_1,
3048                         .apply_expected = True
3049                 }
3050         },
3051
3052 /*
3053  * multi homed vs. normal group section,
3054  */
3055         /* 
3056          * mhomed,active vs. group,active
3057          * => should be replaced
3058          */
3059         {
3060                 .line   = __location__,
3061                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3062                 .r1     = {
3063                         .owner          = &ctx->a,
3064                         .type           = WREPL_TYPE_MHOMED,
3065                         .state          = WREPL_STATE_ACTIVE,
3066                         .node           = WREPL_NODE_B,
3067                         .is_static      = False,
3068                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3069                         .ips            = addresses_A_1,
3070                         .apply_expected = True
3071                 },
3072                 .r2     = {
3073                         .owner          = &ctx->b,
3074                         .type           = WREPL_TYPE_GROUP,
3075                         .state          = WREPL_STATE_ACTIVE,
3076                         .node           = WREPL_NODE_B,
3077                         .is_static      = False,
3078                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3079                         .ips            = addresses_B_1,
3080                         .apply_expected = True
3081                 }
3082         },
3083
3084         /* 
3085          * mhomed,active vs. group,tombstone
3086          * => should NOT be replaced
3087          */
3088         {
3089                 .line   = __location__,
3090                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3091                 .r1     = {
3092                         .owner          = &ctx->b,
3093                         .type           = WREPL_TYPE_MHOMED,
3094                         .state          = WREPL_STATE_ACTIVE,
3095                         .node           = WREPL_NODE_B,
3096                         .is_static      = False,
3097                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3098                         .ips            = addresses_B_1,
3099                         .apply_expected = True
3100                 },
3101                 .r2     = {
3102                         .owner          = &ctx->a,
3103                         .type           = WREPL_TYPE_GROUP,
3104                         .state          = WREPL_STATE_TOMBSTONE,
3105                         .node           = WREPL_NODE_B,
3106                         .is_static      = False,
3107                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3108                         .ips            = addresses_B_1,
3109                         .apply_expected = False
3110                 }
3111         },
3112
3113         /* 
3114          * mhomed,released vs. group,active
3115          * => should be replaced
3116          */
3117         {
3118                 .line   = __location__,
3119                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3120                 .r1     = {
3121                         .owner          = &ctx->b,
3122                         .type           = WREPL_TYPE_MHOMED,
3123                         .state          = WREPL_STATE_RELEASED,
3124                         .node           = WREPL_NODE_B,
3125                         .is_static      = False,
3126                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3127                         .ips            = addresses_B_1,
3128                         .apply_expected = False
3129                 },
3130                 .r2     = {
3131                         .owner          = &ctx->a,
3132                         .type           = WREPL_TYPE_GROUP,
3133                         .state          = WREPL_STATE_ACTIVE,
3134                         .node           = WREPL_NODE_B,
3135                         .is_static      = False,
3136                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3137                         .ips            = addresses_A_1,
3138                         .apply_expected = True
3139                 }
3140         },
3141
3142         /* 
3143          * mhomed,released vs. group,tombstone
3144          * => should be replaced
3145          */
3146         {
3147                 .line   = __location__,
3148                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3149                 .r1     = {
3150                         .owner          = &ctx->a,
3151                         .type           = WREPL_TYPE_MHOMED,
3152                         .state          = WREPL_STATE_RELEASED,
3153                         .node           = WREPL_NODE_B,
3154                         .is_static      = False,
3155                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3156                         .ips            = addresses_A_1,
3157                         .apply_expected = False
3158                 },
3159                 .r2     = {
3160                         .owner          = &ctx->b,
3161                         .type           = WREPL_TYPE_GROUP,
3162                         .state          = WREPL_STATE_TOMBSTONE,
3163                         .node           = WREPL_NODE_B,
3164                         .is_static      = False,
3165                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3166                         .ips            = addresses_B_1,
3167                         .apply_expected = True
3168                 }
3169         },
3170
3171         /* 
3172          * mhomed,tombstone vs. group,active
3173          * => should be replaced
3174          */
3175         {
3176                 .line   = __location__,
3177                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3178                 .r1     = {
3179                         .owner          = &ctx->b,
3180                         .type           = WREPL_TYPE_MHOMED,
3181                         .state          = WREPL_STATE_TOMBSTONE,
3182                         .node           = WREPL_NODE_B,
3183                         .is_static      = False,
3184                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3185                         .ips            = addresses_B_1,
3186                         .apply_expected = True
3187                 },
3188                 .r2     = {
3189                         .owner          = &ctx->a,
3190                         .type           = WREPL_TYPE_GROUP,
3191                         .state          = WREPL_STATE_ACTIVE,
3192                         .node           = WREPL_NODE_B,
3193                         .is_static      = False,
3194                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3195                         .ips            = addresses_A_1,
3196                         .apply_expected = True
3197                 }
3198         },
3199
3200         /* 
3201          * mhomed,tombstone vs. group,tombstone
3202          * => should be replaced
3203          */
3204         {
3205                 .line   = __location__,
3206                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3207                 .r1     = {
3208                         .owner          = &ctx->a,
3209                         .type           = WREPL_TYPE_MHOMED,
3210                         .state          = WREPL_STATE_TOMBSTONE,
3211                         .node           = WREPL_NODE_B,
3212                         .is_static      = False,
3213                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3214                         .ips            = addresses_A_1,
3215                         .apply_expected = True
3216                 },
3217                 .r2     = {
3218                         .owner          = &ctx->b,
3219                         .type           = WREPL_TYPE_GROUP,
3220                         .state          = WREPL_STATE_TOMBSTONE,
3221                         .node           = WREPL_NODE_B,
3222                         .is_static      = False,
3223                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3224                         .ips            = addresses_B_1,
3225                         .apply_expected = True
3226                 }
3227         },
3228
3229 /*
3230  * multi homed vs. special group section,
3231  */
3232         /* 
3233          * mhomed,active vs. sgroup,active
3234          * => should NOT be replaced
3235          */
3236         {
3237                 .line   = __location__,
3238                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3239                 .r1     = {
3240                         .owner          = &ctx->a,
3241                         .type           = WREPL_TYPE_MHOMED,
3242                         .state          = WREPL_STATE_ACTIVE,
3243                         .node           = WREPL_NODE_B,
3244                         .is_static      = False,
3245                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3246                         .ips            = addresses_A_1,
3247                         .apply_expected = True
3248                 },
3249                 .r2     = {
3250                         .owner          = &ctx->b,
3251                         .type           = WREPL_TYPE_SGROUP,
3252                         .state          = WREPL_STATE_ACTIVE,
3253                         .node           = WREPL_NODE_B,
3254                         .is_static      = False,
3255                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3256                         .ips            = addresses_A_1,
3257                         .apply_expected = False
3258                 }
3259         },
3260
3261         /* 
3262          * mhomed,active vs. sgroup,tombstone
3263          * => should NOT be replaced
3264          */
3265         {
3266                 .line   = __location__,
3267                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3268                 .r1     = {
3269                         .owner          = &ctx->a,
3270                         .type           = WREPL_TYPE_MHOMED,
3271                         .state          = WREPL_STATE_ACTIVE,
3272                         .node           = WREPL_NODE_B,
3273                         .is_static      = False,
3274                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3275                         .ips            = addresses_A_1,
3276                         .apply_expected = True
3277                 },
3278                 .r2     = {
3279                         .owner          = &ctx->b,
3280                         .type           = WREPL_TYPE_SGROUP,
3281                         .state          = WREPL_STATE_TOMBSTONE,
3282                         .node           = WREPL_NODE_B,
3283                         .is_static      = False,
3284                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3285                         .ips            = addresses_A_1,
3286                         .apply_expected = False
3287                 }
3288         },
3289
3290         /* 
3291          * mhomed,released vs. sgroup,active
3292          * => should be replaced
3293          */
3294         {
3295                 .line   = __location__,
3296                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3297                 .r1     = {
3298                         .owner          = &ctx->a,
3299                         .type           = WREPL_TYPE_MHOMED,
3300                         .state          = WREPL_STATE_RELEASED,
3301                         .node           = WREPL_NODE_B,
3302                         .is_static      = False,
3303                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3304                         .ips            = addresses_A_1,
3305                         .apply_expected = False
3306                 },
3307                 .r2     = {
3308                         .owner          = &ctx->b,
3309                         .type           = WREPL_TYPE_SGROUP,
3310                         .state          = WREPL_STATE_ACTIVE,
3311                         .node           = WREPL_NODE_B,
3312                         .is_static      = False,
3313                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3314                         .ips            = addresses_B_1,
3315                         .apply_expected = True
3316                 }
3317         },
3318
3319         /* 
3320          * mhomed,released vs. sgroup,tombstone
3321          * => should be replaced
3322          */
3323         {
3324                 .line   = __location__,
3325                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3326                 .r1     = {
3327                         .owner          = &ctx->b,
3328                         .type           = WREPL_TYPE_MHOMED,
3329                         .state          = WREPL_STATE_RELEASED,
3330                         .node           = WREPL_NODE_B,
3331                         .is_static      = False,
3332                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3333                         .ips            = addresses_B_1,
3334                         .apply_expected = False
3335                 },
3336                 .r2     = {
3337                         .owner          = &ctx->a,
3338                         .type           = WREPL_TYPE_SGROUP,
3339                         .state          = WREPL_STATE_TOMBSTONE,
3340                         .node           = WREPL_NODE_B,
3341                         .is_static      = False,
3342                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3343                         .ips            = addresses_A_1,
3344                         .apply_expected = True
3345                 }
3346         },
3347
3348         /* 
3349          * mhomed,tombstone vs. sgroup,active
3350          * => should be replaced
3351          */
3352         {
3353                 .line   = __location__,
3354                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3355                 .r1     = {
3356                         .owner          = &ctx->a,
3357                         .type           = WREPL_TYPE_MHOMED,
3358                         .state          = WREPL_STATE_TOMBSTONE,
3359                         .node           = WREPL_NODE_B,
3360                         .is_static      = False,
3361                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3362                         .ips            = addresses_A_1,
3363                         .apply_expected = True
3364                 },
3365                 .r2     = {
3366                         .owner          = &ctx->b,
3367                         .type           = WREPL_TYPE_SGROUP,
3368                         .state          = WREPL_STATE_ACTIVE,
3369                         .node           = WREPL_NODE_B,
3370                         .is_static      = False,
3371                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3372                         .ips            = addresses_B_1,
3373                         .apply_expected = True
3374                 }
3375         },
3376
3377         /* 
3378          * mhomed,tombstone vs. sgroup,tombstone
3379          * => should be replaced
3380          */
3381         {
3382                 .line   = __location__,
3383                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3384                 .r1     = {
3385                         .owner          = &ctx->b,
3386                         .type           = WREPL_TYPE_MHOMED,
3387                         .state          = WREPL_STATE_TOMBSTONE,
3388                         .node           = WREPL_NODE_B,
3389                         .is_static      = False,
3390                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3391                         .ips            = addresses_B_1,
3392                         .apply_expected = True
3393                 },
3394                 .r2     = {
3395                         .owner          = &ctx->a,
3396                         .type           = WREPL_TYPE_SGROUP,
3397                         .state          = WREPL_STATE_TOMBSTONE,
3398                         .node           = WREPL_NODE_B,
3399                         .is_static      = False,
3400                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3401                         .ips            = addresses_A_1,
3402                         .apply_expected = True
3403                 }
3404         },
3405
3406 /*
3407  * multi homed vs. mlti homed section,
3408  */
3409         /* 
3410          * mhomed,active vs. mhomed,active
3411          * => should be replaced
3412          */
3413         {
3414                 .line   = __location__,
3415                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3416                 .r1     = {
3417                         .owner          = &ctx->a,
3418                         .type           = WREPL_TYPE_MHOMED,
3419                         .state          = WREPL_STATE_ACTIVE,
3420                         .node           = WREPL_NODE_B,
3421                         .is_static      = False,
3422                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3423                         .ips            = addresses_A_3_4,
3424                         .apply_expected = True
3425                 },
3426                 .r2     = {
3427                         .owner          = &ctx->b,
3428                         .type           = WREPL_TYPE_MHOMED,
3429                         .state          = WREPL_STATE_ACTIVE,
3430                         .node           = WREPL_NODE_B,
3431                         .is_static      = False,
3432                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3433                         .ips            = addresses_B_3_4,
3434                         .apply_expected = True
3435                 }
3436         },
3437
3438         /* 
3439          * mhomed,active vs. mhomed,tombstone
3440          * => should NOT be replaced
3441          */
3442         {
3443                 .line   = __location__,
3444                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3445                 .r1     = {
3446                         .owner          = &ctx->b,
3447                         .type           = WREPL_TYPE_MHOMED,
3448                         .state          = WREPL_STATE_ACTIVE,
3449                         .node           = WREPL_NODE_B,
3450                         .is_static      = False,
3451                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3452                         .ips            = addresses_B_3_4,
3453                         .apply_expected = True
3454                 },
3455                 .r2     = {
3456                         .owner          = &ctx->a,
3457                         .type           = WREPL_TYPE_MHOMED,
3458                         .state          = WREPL_STATE_TOMBSTONE,
3459                         .node           = WREPL_NODE_B,
3460                         .is_static      = False,
3461                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3462                         .ips            = addresses_B_3_4,
3463                         .apply_expected = False
3464                 }
3465         },
3466
3467         /* 
3468          * mhomed,released vs. mhomed,active
3469          * => should be replaced
3470          */
3471         {
3472                 .line   = __location__,
3473                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3474                 .r1     = {
3475                         .owner          = &ctx->b,
3476                         .type           = WREPL_TYPE_MHOMED,
3477                         .state          = WREPL_STATE_RELEASED,
3478                         .node           = WREPL_NODE_B,
3479                         .is_static      = False,
3480                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3481                         .ips            = addresses_B_3_4,
3482                         .apply_expected = False
3483                 },
3484                 .r2     = {
3485                         .owner          = &ctx->a,
3486                         .type           = WREPL_TYPE_MHOMED,
3487                         .state          = WREPL_STATE_ACTIVE,
3488                         .node           = WREPL_NODE_B,
3489                         .is_static      = False,
3490                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3491                         .ips            = addresses_A_3_4,
3492                         .apply_expected = True
3493                 }
3494         },
3495
3496         /* 
3497          * mhomed,released vs. mhomed,tombstone
3498          * => should be replaced
3499          */
3500         {
3501                 .line   = __location__,
3502                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3503                 .r1     = {
3504                         .owner          = &ctx->a,
3505                         .type           = WREPL_TYPE_MHOMED,
3506                         .state          = WREPL_STATE_RELEASED,
3507                         .node           = WREPL_NODE_B,
3508                         .is_static      = False,
3509                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3510                         .ips            = addresses_A_3_4,
3511                         .apply_expected = False
3512                 },
3513                 .r2     = {
3514                         .owner          = &ctx->b,
3515                         .type           = WREPL_TYPE_MHOMED,
3516                         .state          = WREPL_STATE_TOMBSTONE,
3517                         .node           = WREPL_NODE_B,
3518                         .is_static      = False,
3519                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3520                         .ips            = addresses_B_3_4,
3521                         .apply_expected = True
3522                 }
3523         },
3524
3525         /* 
3526          * mhomed,tombstone vs. mhomed,active
3527          * => should be replaced
3528          */
3529         {
3530                 .line   = __location__,
3531                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3532                 .r1     = {
3533                         .owner          = &ctx->b,
3534                         .type           = WREPL_TYPE_MHOMED,
3535                         .state          = WREPL_STATE_TOMBSTONE,
3536                         .node           = WREPL_NODE_B,
3537                         .is_static      = False,
3538                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3539                         .ips            = addresses_B_3_4,
3540                         .apply_expected = True
3541                 },
3542                 .r2     = {
3543                         .owner          = &ctx->a,
3544                         .type           = WREPL_TYPE_MHOMED,
3545                         .state          = WREPL_STATE_ACTIVE,
3546                         .node           = WREPL_NODE_B,
3547                         .is_static      = False,
3548                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3549                         .ips            = addresses_A_3_4,
3550                         .apply_expected = True
3551                 }
3552         },
3553
3554         /* 
3555          * mhomed,tombstone vs. mhomed,tombstone
3556          * => should be replaced
3557          */
3558         {
3559                 .line   = __location__,
3560                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3561                 .r1     = {
3562                         .owner          = &ctx->a,
3563                         .type           = WREPL_TYPE_MHOMED,
3564                         .state          = WREPL_STATE_TOMBSTONE,
3565                         .node           = WREPL_NODE_B,
3566                         .is_static      = False,
3567                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3568                         .ips            = addresses_A_3_4,
3569                         .apply_expected = True
3570                 },
3571                 .r2     = {
3572                         .owner          = &ctx->b,
3573                         .type           = WREPL_TYPE_MHOMED,
3574                         .state          = WREPL_STATE_TOMBSTONE,
3575                         .node           = WREPL_NODE_B,
3576                         .is_static      = False,
3577                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3578                         .ips            = addresses_B_3_4,
3579                         .apply_expected = True
3580                 }
3581         },
3582
3583 #if 0
3584 /*
3585  * special group vs special group section,
3586  */
3587         /* 
3588          * sgroup,active vs. sgroup,active
3589          * => should be merged
3590          */
3591         {
3592                 .line   = __location__,
3593                 .name   = _NBT_NAME("_DIFF_OWNER_SG", 0x00, NULL),
3594                 .extra  = True,
3595                 .r1     = {
3596                         .owner          = &ctx->a,
3597                         .type           = WREPL_TYPE_SGROUP,
3598                         .state          = WREPL_STATE_ACTIVE,
3599                         .node           = WREPL_NODE_B,
3600                         .is_static      = False,
3601                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3602                         .ips            = addresses_A_3_4,
3603                         .apply_expected = True,
3604                 },
3605                 .r2     = {
3606                         .owner          = &ctx->b,
3607                         .type           = WREPL_TYPE_SGROUP,
3608                         .state          = WREPL_STATE_ACTIVE,
3609                         .node           = WREPL_NODE_B,
3610                         .is_static      = False,
3611                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3612                         .ips            = addresses_B_3_4,
3613                         .apply_expected = False,
3614                         .merge_expected = True
3615                 }
3616         },
3617         {
3618                 .line   = __location__,
3619                 .name   = _NBT_NAME("_DIFF_OWNER_SG", 0x00, NULL),
3620                 .cleanup= True,
3621                 .r1     = {
3622                         .owner          = &ctx->a,
3623                         .type           = WREPL_TYPE_SGROUP,
3624                         .state          = WREPL_STATE_ACTIVE,
3625                         .node           = WREPL_NODE_B,
3626                         .is_static      = False,
3627                         .num_ips        = 0,
3628                         .ips            = NULL,
3629                         .apply_expected = False
3630                 },
3631                 .r2     = {
3632                         .owner          = &ctx->b,
3633                         .type           = WREPL_TYPE_SGROUP,
3634                         .state          = WREPL_STATE_ACTIVE,
3635                         .node           = WREPL_NODE_B,
3636                         .is_static      = False,
3637                         .num_ips        = 0,
3638                         .ips            = NULL,
3639                         .apply_expected = False,
3640                         .merge_expected = False
3641                 }
3642         },
3643         {
3644                 .line   = __location__,
3645                 .name   = _NBT_NAME("_DIFF_OWNER_SG", 0x00, NULL),
3646                 .cleanup= True,
3647                 .r1     = {
3648                         .owner          = &ctx->a,
3649                         .type           = WREPL_TYPE_SGROUP,
3650                         .state          = WREPL_STATE_ACTIVE,
3651                         .node           = WREPL_NODE_B,
3652                         .is_static      = False,
3653                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3654                         .ips            = addresses_A_1,
3655                         .apply_expected = True
3656                 },
3657                 .r2     = {
3658                         .owner          = &ctx->a,
3659                         .type           = WREPL_TYPE_UNIQUE,
3660                         .state          = WREPL_STATE_TOMBSTONE,
3661                         .node           = WREPL_NODE_B,
3662                         .is_static      = False,
3663                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3664                         .ips            = addresses_A_1,
3665                         .apply_expected = True
3666                 }
3667         },
3668 #endif
3669         /* 
3670          * This should be the last record in this array,
3671          * we need to make sure the we leave a tombstoned unique entry
3672          * owned by OWNER_A
3673          */
3674         {
3675                 .line   = __location__,
3676                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3677                 .cleanup= True,
3678                 .r1     = {
3679                         .owner          = &ctx->b,
3680                         .type           = WREPL_TYPE_UNIQUE,
3681                         .state          = WREPL_STATE_TOMBSTONE,
3682                         .node           = WREPL_NODE_B,
3683                         .is_static      = False,
3684                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3685                         .ips            = addresses_A_1,
3686                         .apply_expected = True
3687                 },
3688                 .r2     = {
3689                         .owner          = &ctx->a,
3690                         .type           = WREPL_TYPE_UNIQUE,
3691                         .state          = WREPL_STATE_TOMBSTONE,
3692                         .node           = WREPL_NODE_B,
3693                         .is_static      = False,
3694                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3695                         .ips            = addresses_A_1,
3696                         .apply_expected = True
3697                 }
3698         }}; /* do not add entries here, this should be the last record! */
3699
3700         if (!ctx) return False;
3701
3702         wins_name_r1    = &wins_name1;
3703         wins_name_r2    = &wins_name2;
3704
3705         printf("Test Replica Conflicts with different owners\n");
3706
3707         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
3708         
3709                 if (!records[i].extra && !records[i].cleanup) {
3710                         /* we should test the worst cases */
3711                         if (records[i].r2.apply_expected && records[i].r1.ips==records[i].r2.ips) {
3712                                 printf("(%s) Programmer error, invalid record[%u]: %s\n",
3713                                         __location__, i, records[i].line);
3714                                 return False;
3715                         } else if (!records[i].r2.apply_expected && records[i].r1.ips!=records[i].r2.ips) {
3716                                 printf("(%s) Programmer error, invalid record[%u]: %s\n",
3717                                         __location__, i, records[i].line);
3718                                 return False;
3719                         }
3720                 }
3721
3722                 if (!records[i].cleanup) {
3723                         const char *expected;
3724                         const char *ips;
3725
3726                         if (records[i].r2.merge_expected) {
3727                                 expected = "MERGE";
3728                         } else if (records[i].r2.apply_expected) {
3729                                 expected = "REPLACE";
3730                         } else {
3731                                 expected = "NOT REPLACE";
3732                         }
3733
3734                         if (!records[i].r1.ips && !records[i].r2.ips) {
3735                                 ips = "no";
3736                         } else if (records[i].r1.ips==records[i].r2.ips) {
3737                                 ips = "same";
3738                         } else {
3739                                 ips = "different";
3740                         }
3741
3742                         printf("%s,%s%s vs. %s,%s%s with %s ip(s) => %s\n",
3743                                 wrepl_name_type_string(records[i].r1.type),
3744                                 wrepl_name_state_string(records[i].r1.state),
3745                                 (records[i].r1.is_static?",static":""),
3746                                 wrepl_name_type_string(records[i].r2.type),
3747                                 wrepl_name_state_string(records[i].r2.state),
3748                                 (records[i].r2.is_static?",static":""),
3749                                 ips, expected);
3750                 }
3751
3752                 /*
3753                  * Setup R1
3754                  */
3755                 wins_name_r1->name      = &records[i].name;
3756                 wins_name_r1->flags     = WREPL_NAME_FLAGS(records[i].r1.type,
3757                                                            records[i].r1.state,
3758                                                            records[i].r1.node,
3759                                                            records[i].r1.is_static);
3760                 wins_name_r1->id        = ++records[i].r1.owner->max_version;
3761                 if (wins_name_r1->flags & 2) {
3762                         wins_name_r1->addresses.addresses.num_ips = records[i].r1.num_ips;
3763                         wins_name_r1->addresses.addresses.ips     = discard_const(records[i].r1.ips);
3764                 } else {
3765                         wins_name_r1->addresses.ip = records[i].r1.ips[0].ip;
3766                 }
3767                 wins_name_r1->unknown   = "255.255.255.255";
3768
3769                 /* now apply R1 */
3770                 ret &= test_wrepl_update_one(ctx, records[i].r1.owner, wins_name_r1);
3771                 ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
3772                                              wins_name_r1, records[i].r1.apply_expected);
3773
3774                 /*
3775                  * Setup R2
3776                  */
3777                 wins_name_r2->name      = &records[i].name;
3778                 wins_name_r2->flags     = WREPL_NAME_FLAGS(records[i].r2.type,
3779                                                            records[i].r2.state,
3780                                                            records[i].r2.node,
3781                                                            records[i].r2.is_static);
3782                 wins_name_r2->id        = ++records[i].r2.owner->max_version;
3783                 if (wins_name_r2->flags & 2) {
3784                         wins_name_r2->addresses.addresses.num_ips = records[i].r2.num_ips;
3785                         wins_name_r2->addresses.addresses.ips     = discard_const(records[i].r2.ips);
3786                 } else {
3787                         wins_name_r2->addresses.ip = records[i].r2.ips[0].ip;
3788                 }
3789                 wins_name_r2->unknown   = "255.255.255.255";
3790
3791                 /* now apply R2 */
3792                 ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
3793                 if (records[i].r1.state == WREPL_STATE_RELEASED) {
3794                         ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
3795                                                      wins_name_r1, False);
3796                 } else if (records[i].r2.merge_expected) {
3797                         ret &= test_wrepl_is_merged(ctx, wins_name_r1, wins_name_r2);           
3798                 } else if (records[i].r1.owner != records[i].r2.owner) {
3799                         BOOL _expected;
3800                         _expected = (records[i].r1.apply_expected && !records[i].r2.apply_expected);
3801                         ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
3802                                                      wins_name_r1, _expected);
3803                 }
3804                 if (records[i].r2.state == WREPL_STATE_RELEASED) {
3805                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner,
3806                                                      wins_name_r2, False);
3807                 } else if (!records[i].r2.merge_expected) {
3808                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner,
3809                                                      wins_name_r2, records[i].r2.apply_expected);
3810                 }
3811
3812                 /* the first one is a cleanup run */
3813                 if (!ret && i == 0) ret = True;
3814
3815                 if (!ret) {
3816                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
3817                         return ret;
3818                 }
3819         }
3820
3821         return ret;
3822 }
3823
3824 static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_conn *ctx)
3825 {
3826         BOOL ret = True;
3827         NTSTATUS status;
3828         struct wrepl_wins_name wins_name_;
3829         struct wrepl_wins_name *wins_name = &wins_name_;
3830         struct nbt_name_register name_register_;
3831         struct nbt_name_register *name_register = &name_register_;
3832         struct nbt_name_release release_;
3833         struct nbt_name_release *release = &release_;
3834         uint32_t i;
3835         struct {
3836                 const char *line; /* just better debugging */
3837                 struct nbt_name name;
3838                 struct {
3839                         uint32_t nb_flags;
3840                         BOOL mhomed;
3841                         uint32_t num_ips;
3842                         const struct wrepl_ip *ips;
3843                         BOOL release;
3844                         BOOL apply_expected;
3845                 } wins;
3846                 struct {
3847                         enum wrepl_name_type type;
3848                         enum wrepl_name_state state;
3849                         enum wrepl_name_node node;
3850                         BOOL is_static;
3851                         uint32_t num_ips;
3852                         const struct wrepl_ip *ips;
3853                         BOOL apply_expected;
3854                 } replica;
3855         } records[] = {
3856         /*
3857          * unique,released vs. unique,active with same ip(s)
3858          */
3859         {
3860                 .line   = __location__,
3861                 .name   = _NBT_NAME("_UR_UA_SI", 0x00, NULL),
3862                 .wins   = {
3863                         .nb_flags       = 0,
3864                         .mhomed         = False,
3865                         .num_ips        = ctx->addresses_1_num,
3866                         .ips            = ctx->addresses_1,
3867                         .release        = True,
3868                         .apply_expected = True
3869                 },
3870                 .replica= {
3871                         .type           = WREPL_TYPE_UNIQUE,
3872                         .state          = WREPL_STATE_ACTIVE,
3873                         .node           = WREPL_NODE_B,
3874                         .is_static      = False,
3875                         .num_ips        = ctx->addresses_1_num,
3876                         .ips            = ctx->addresses_1,
3877                         .apply_expected = True
3878                 },
3879         },
3880         /*
3881          * unique,released vs. unique,active with different ip(s)
3882          */
3883         {
3884                 .line   = __location__,
3885                 .name   = _NBT_NAME("_UR_UA_DI", 0x00, NULL),
3886                 .wins   = {
3887                         .nb_flags       = 0,
3888                         .mhomed         = False,
3889                         .num_ips        = ctx->addresses_1_num,
3890                         .ips            = ctx->addresses_1,
3891                         .release        = True,
3892                         .apply_expected = True
3893                 },
3894                 .replica= {
3895                         .type           = WREPL_TYPE_UNIQUE,
3896                         .state          = WREPL_STATE_ACTIVE,
3897                         .node           = WREPL_NODE_B,
3898                         .is_static      = False,
3899                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3900                         .ips            = addresses_B_1,
3901                         .apply_expected = True
3902                 },
3903         },
3904         /*
3905          * unique,released vs. unique,tombstone with same ip(s)
3906          */
3907         {
3908                 .line   = __location__,
3909                 .name   = _NBT_NAME("_UR_UT_SI", 0x00, NULL),
3910                 .wins   = {
3911                         .nb_flags       = 0,
3912                         .mhomed         = False,
3913                         .num_ips        = ctx->addresses_1_num,
3914                         .ips            = ctx->addresses_1,
3915                         .release        = True,
3916                         .apply_expected = True
3917                 },
3918                 .replica= {
3919                         .type           = WREPL_TYPE_UNIQUE,
3920                         .state          = WREPL_STATE_TOMBSTONE,
3921                         .node           = WREPL_NODE_B,
3922                         .is_static      = False,
3923                         .num_ips        = ctx->addresses_1_num,
3924                         .ips            = ctx->addresses_1,
3925                         .apply_expected = True
3926                 },
3927         },
3928         /*
3929          * unique,released vs. unique,tombstone with different ip(s)
3930          */
3931         {
3932                 .line   = __location__,
3933                 .name   = _NBT_NAME("_UR_UT_DI", 0x00, NULL),
3934                 .wins   = {
3935                         .nb_flags       = 0,
3936                         .mhomed         = False,
3937                         .num_ips        = ctx->addresses_1_num,
3938                         .ips            = ctx->addresses_1,
3939                         .release        = True,
3940                         .apply_expected = True
3941                 },
3942                 .replica= {
3943                         .type           = WREPL_TYPE_UNIQUE,
3944                         .state          = WREPL_STATE_TOMBSTONE,
3945                         .node           = WREPL_NODE_B,
3946                         .is_static      = False,
3947                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3948                         .ips            = addresses_B_1,
3949                         .apply_expected = True
3950                 },
3951         },
3952         /*
3953          * unique,released vs. group,active with same ip(s)
3954          */
3955         {
3956                 .line   = __location__,
3957                 .name   = _NBT_NAME("_UR_GA_SI", 0x00, NULL),
3958                 .wins   = {
3959                         .nb_flags       = 0,
3960                         .mhomed         = False,
3961                         .num_ips        = ctx->addresses_1_num,
3962                         .ips            = ctx->addresses_1,
3963                         .release        = True,
3964                         .apply_expected = True
3965                 },
3966                 .replica= {
3967                         .type           = WREPL_TYPE_GROUP,
3968                         .state          = WREPL_STATE_ACTIVE,
3969                         .node           = WREPL_NODE_B,
3970                         .is_static      = False,
3971                         .num_ips        = ctx->addresses_1_num,
3972                         .ips            = ctx->addresses_1,
3973                         .apply_expected = True
3974                 },
3975         },
3976         /*
3977          * unique,released vs. group,active with different ip(s)
3978          */
3979         {
3980                 .line   = __location__,
3981                 .name   = _NBT_NAME("_UR_GA_DI", 0x00, NULL),
3982                 .wins   = {
3983                         .nb_flags       = 0,
3984                         .mhomed         = False,
3985                         .num_ips        = ctx->addresses_1_num,
3986                         .ips            = ctx->addresses_1,
3987                         .release        = True,
3988                         .apply_expected = True
3989                 },
3990                 .replica= {
3991                         .type           = WREPL_TYPE_GROUP,
3992                         .state          = WREPL_STATE_ACTIVE,
3993                         .node           = WREPL_NODE_B,
3994                         .is_static      = False,
3995                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3996                         .ips            = addresses_B_1,
3997                         .apply_expected = True
3998                 },
3999         },
4000         /*
4001          * unique,released vs. group,tombstone with same ip(s)
4002          */
4003         {
4004                 .line   = __location__,
4005                 .name   = _NBT_NAME("_UR_GT_SI", 0x00, NULL),
4006                 .wins   = {
4007                         .nb_flags       = 0,
4008                         .mhomed         = False,
4009                         .num_ips        = ctx->addresses_1_num,
4010                         .ips            = ctx->addresses_1,
4011                         .release        = True,
4012                         .apply_expected = True
4013                 },
4014                 .replica= {
4015                         .type           = WREPL_TYPE_GROUP,
4016                         .state          = WREPL_STATE_TOMBSTONE,
4017                         .node           = WREPL_NODE_B,
4018                         .is_static      = False,
4019                         .num_ips        = ctx->addresses_1_num,
4020                         .ips            = ctx->addresses_1,
4021                         .apply_expected = True
4022                 },
4023         },
4024         /*
4025          * unique,released vs. group,tombstone with different ip(s)
4026          */
4027         {
4028                 .line   = __location__,
4029                 .name   = _NBT_NAME("_UR_GT_DI", 0x00, NULL),
4030                 .wins   = {
4031                         .nb_flags       = 0,
4032                         .mhomed         = False,
4033                         .num_ips        = ctx->addresses_1_num,
4034                         .ips            = ctx->addresses_1,
4035                         .release        = True,
4036                         .apply_expected = True
4037                 },
4038                 .replica= {
4039                         .type           = WREPL_TYPE_GROUP,
4040                         .state          = WREPL_STATE_TOMBSTONE,
4041                         .node           = WREPL_NODE_B,
4042                         .is_static      = False,
4043                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4044                         .ips            = addresses_B_1,
4045                         .apply_expected = True
4046                 },
4047         },
4048         /*
4049          * unique,released vs. sgroup,active with same ip(s)
4050          */
4051         {
4052                 .line   = __location__,
4053                 .name   = _NBT_NAME("_UR_SA_SI", 0x00, NULL),
4054                 .wins   = {
4055                         .nb_flags       = 0,
4056                         .mhomed         = False,
4057                         .num_ips        = ctx->addresses_1_num,
4058                         .ips            = ctx->addresses_1,
4059                         .release        = True,
4060                         .apply_expected = True
4061                 },
4062                 .replica= {
4063                         .type           = WREPL_TYPE_SGROUP,
4064                         .state          = WREPL_STATE_ACTIVE,
4065                         .node           = WREPL_NODE_B,
4066                         .is_static      = False,
4067                         .num_ips        = ctx->addresses_1_num,
4068                         .ips            = ctx->addresses_1,
4069                         .apply_expected = True
4070                 },
4071         },
4072         /*
4073          * unique,released vs. sgroup,active with different ip(s)
4074          */
4075         {
4076                 .line   = __location__,
4077                 .name   = _NBT_NAME("_UR_SA_DI", 0x00, NULL),
4078                 .wins   = {
4079                         .nb_flags       = 0,
4080                         .mhomed         = False,
4081                         .num_ips        = ctx->addresses_1_num,
4082                         .ips            = ctx->addresses_1,
4083                         .release        = True,
4084                         .apply_expected = True
4085                 },
4086                 .replica= {
4087                         .type           = WREPL_TYPE_SGROUP,
4088                         .state          = WREPL_STATE_ACTIVE,
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,released vs. sgroup,tombstone with same ip(s)
4098          */
4099         {
4100                 .line   = __location__,
4101                 .name   = _NBT_NAME("_UR_ST_SI", 0x00, NULL),
4102                 .wins   = {
4103                         .nb_flags       = 0,
4104                         .mhomed         = False,
4105                         .num_ips        = ctx->addresses_1_num,
4106                         .ips            = ctx->addresses_1,
4107                         .release        = True,
4108                         .apply_expected = True
4109                 },
4110                 .replica= {
4111                         .type           = WREPL_TYPE_SGROUP,
4112                         .state          = WREPL_STATE_TOMBSTONE,
4113                         .node           = WREPL_NODE_B,
4114                         .is_static      = False,
4115                         .num_ips        = ctx->addresses_1_num,
4116                         .ips            = ctx->addresses_1,
4117                         .apply_expected = True
4118                 },
4119         },
4120         /*
4121          * unique,released vs. sgroup,tombstone with different ip(s)
4122          */
4123         {
4124                 .line   = __location__,
4125                 .name   = _NBT_NAME("_UR_ST_DI", 0x00, NULL),
4126                 .wins   = {
4127                         .nb_flags       = 0,
4128                         .mhomed         = False,
4129                         .num_ips        = ctx->addresses_1_num,
4130                         .ips            = ctx->addresses_1,
4131                         .release        = True,
4132                         .apply_expected = True
4133                 },
4134                 .replica= {
4135                         .type           = WREPL_TYPE_SGROUP,
4136                         .state          = WREPL_STATE_TOMBSTONE,
4137                         .node           = WREPL_NODE_B,
4138                         .is_static      = False,
4139                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4140                         .ips            = addresses_B_1,
4141                         .apply_expected = True
4142                 },
4143         },
4144         /*
4145          * unique,released vs. mhomed,active with same ip(s)
4146          */
4147         {
4148                 .line   = __location__,
4149                 .name   = _NBT_NAME("_UR_MA_SI", 0x00, NULL),
4150                 .wins   = {
4151                         .nb_flags       = 0,
4152                         .mhomed         = False,
4153                         .num_ips        = ctx->addresses_1_num,
4154                         .ips            = ctx->addresses_1,
4155                         .release        = True,
4156                         .apply_expected = True
4157                 },
4158                 .replica= {
4159                         .type           = WREPL_TYPE_MHOMED,
4160                         .state          = WREPL_STATE_ACTIVE,
4161                         .node           = WREPL_NODE_B,
4162                         .is_static      = False,
4163                         .num_ips        = ctx->addresses_1_num,
4164                         .ips            = ctx->addresses_1,
4165                         .apply_expected = True
4166                 },
4167         },
4168         /*
4169          * unique,released vs. mhomed,active with different ip(s)
4170          */
4171         {
4172                 .line   = __location__,
4173                 .name   = _NBT_NAME("_UR_MA_DI", 0x00, NULL),
4174                 .wins   = {
4175                         .nb_flags       = 0,
4176                         .mhomed         = False,
4177                         .num_ips        = ctx->addresses_1_num,
4178                         .ips            = ctx->addresses_1,
4179                         .release        = True,
4180                         .apply_expected = True
4181                 },
4182                 .replica= {
4183                         .type           = WREPL_TYPE_MHOMED,
4184                         .state          = WREPL_STATE_ACTIVE,
4185                         .node           = WREPL_NODE_B,
4186                         .is_static      = False,
4187                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4188                         .ips            = addresses_B_1,
4189                         .apply_expected = True
4190                 },
4191         },
4192         /*
4193          * unique,released vs. mhomed,tombstone with same ip(s)
4194          */
4195         {
4196                 .line   = __location__,
4197                 .name   = _NBT_NAME("_UR_MT_SI", 0x00, NULL),
4198                 .wins   = {
4199                         .nb_flags       = 0,
4200                         .mhomed         = False,
4201                         .num_ips        = ctx->addresses_1_num,
4202                         .ips            = ctx->addresses_1,
4203                         .release        = True,
4204                         .apply_expected = True
4205                 },
4206                 .replica= {
4207                         .type           = WREPL_TYPE_MHOMED,
4208                         .state          = WREPL_STATE_TOMBSTONE,
4209                         .node           = WREPL_NODE_B,
4210                         .is_static      = False,
4211                         .num_ips        = ctx->addresses_1_num,
4212                         .ips            = ctx->addresses_1,
4213                         .apply_expected = True
4214                 },
4215         },
4216         /*
4217          * unique,released vs. mhomed,tombstone with different ip(s)
4218          */
4219         {
4220                 .line   = __location__,
4221                 .name   = _NBT_NAME("_UR_MT_DI", 0x00, NULL),
4222                 .wins   = {
4223                         .nb_flags       = 0,
4224                         .mhomed         = False,
4225                         .num_ips        = ctx->addresses_1_num,
4226                         .ips            = ctx->addresses_1,
4227                         .release        = True,
4228                         .apply_expected = True
4229                 },
4230                 .replica= {
4231                         .type           = WREPL_TYPE_MHOMED,
4232                         .state          = WREPL_STATE_TOMBSTONE,
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          * group,released vs. unique,active with same ip(s)
4242          */
4243         {
4244                 .line   = __location__,
4245                 .name   = _NBT_NAME("_GR_UA_SI", 0x00, NULL),
4246                 .wins   = {
4247                         .nb_flags       = NBT_NM_GROUP,
4248                         .mhomed         = False,
4249                         .num_ips        = ctx->addresses_1_num,
4250                         .ips            = ctx->addresses_1,
4251                         .release        = True,
4252                         .apply_expected = True
4253                 },
4254                 .replica= {
4255                         .type           = WREPL_TYPE_UNIQUE,
4256                         .state          = WREPL_STATE_ACTIVE,
4257                         .node           = WREPL_NODE_B,
4258                         .is_static      = False,
4259                         .num_ips        = ctx->addresses_1_num,
4260                         .ips            = ctx->addresses_1,
4261                         .apply_expected = False
4262                 },
4263         },
4264         /*
4265          * group,released vs. unique,active with different ip(s)
4266          */
4267         {
4268                 .line   = __location__,
4269                 .name   = _NBT_NAME("_GR_UA_DI", 0x00, NULL),
4270                 .wins   = {
4271                         .nb_flags       = NBT_NM_GROUP,
4272                         .mhomed         = False,
4273                         .num_ips        = ctx->addresses_1_num,
4274                         .ips            = ctx->addresses_1,
4275                         .release        = True,
4276                         .apply_expected = True
4277                 },
4278                 .replica= {
4279                         .type           = WREPL_TYPE_UNIQUE,
4280                         .state          = WREPL_STATE_ACTIVE,
4281                         .node           = WREPL_NODE_B,
4282                         .is_static      = False,
4283                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4284                         .ips            = addresses_B_1,
4285                         .apply_expected = False
4286                 },
4287         },
4288         /*
4289          * group,released vs. unique,tombstone with same ip(s)
4290          */
4291         {
4292                 .line   = __location__,
4293                 .name   = _NBT_NAME("_GR_UT_SI", 0x00, NULL),
4294                 .wins   = {
4295                         .nb_flags       = NBT_NM_GROUP,
4296                         .mhomed         = False,
4297                         .num_ips        = ctx->addresses_1_num,
4298                         .ips            = ctx->addresses_1,
4299                         .release        = True,
4300                         .apply_expected = True
4301                 },
4302                 .replica= {
4303                         .type           = WREPL_TYPE_UNIQUE,
4304                         .state          = WREPL_STATE_TOMBSTONE,
4305                         .node           = WREPL_NODE_B,
4306                         .is_static      = False,
4307                         .num_ips        = ctx->addresses_1_num,
4308                         .ips            = ctx->addresses_1,
4309                         .apply_expected = False
4310                 },
4311         },
4312         /*
4313          * group,released vs. unique,tombstone with different ip(s)
4314          */
4315         {
4316                 .line   = __location__,
4317                 .name   = _NBT_NAME("_GR_UT_DI", 0x00, NULL),
4318                 .wins   = {
4319                         .nb_flags       = NBT_NM_GROUP,
4320                         .mhomed         = False,
4321                         .num_ips        = ctx->addresses_1_num,
4322                         .ips            = ctx->addresses_1,
4323                         .release        = True,
4324                         .apply_expected = True
4325                 },
4326                 .replica= {
4327                         .type           = WREPL_TYPE_UNIQUE,
4328                         .state          = WREPL_STATE_TOMBSTONE,
4329                         .node           = WREPL_NODE_B,
4330                         .is_static      = False,
4331                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4332                         .ips            = addresses_B_1,
4333                         .apply_expected = False
4334                 },
4335         },
4336         /*
4337          * group,released vs. group,active with same ip(s)
4338          */
4339         {
4340                 .line   = __location__,
4341                 .name   = _NBT_NAME("_GR_GA_SI", 0x00, NULL),
4342                 .wins   = {
4343                         .nb_flags       = NBT_NM_GROUP,
4344                         .mhomed         = False,
4345                         .num_ips        = ctx->addresses_1_num,
4346                         .ips            = ctx->addresses_1,
4347                         .release        = True,
4348                         .apply_expected = True
4349                 },
4350                 .replica= {
4351                         .type           = WREPL_TYPE_GROUP,
4352                         .state          = WREPL_STATE_ACTIVE,
4353                         .node           = WREPL_NODE_B,
4354                         .is_static      = False,
4355                         .num_ips        = ctx->addresses_1_num,
4356                         .ips            = ctx->addresses_1,
4357                         .apply_expected = True
4358                 },
4359         },
4360         /*
4361          * group,released vs. group,active with different ip(s)
4362          */
4363         {
4364                 .line   = __location__,
4365                 .name   = _NBT_NAME("_GR_GA_DI", 0x00, NULL),
4366                 .wins   = {
4367                         .nb_flags       = NBT_NM_GROUP,
4368                         .mhomed         = False,
4369                         .num_ips        = ctx->addresses_1_num,
4370                         .ips            = ctx->addresses_1,
4371                         .release        = True,
4372                         .apply_expected = True
4373                 },
4374                 .replica= {
4375                         .type           = WREPL_TYPE_GROUP,
4376                         .state          = WREPL_STATE_ACTIVE,
4377                         .node           = WREPL_NODE_B,
4378                         .is_static      = False,
4379                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4380                         .ips            = addresses_B_1,
4381                         .apply_expected = True
4382                 },
4383         },
4384         /*
4385          * group,released vs. group,tombstone with same ip(s)
4386          */
4387         {
4388                 .line   = __location__,
4389                 .name   = _NBT_NAME("_GR_GT_SI", 0x00, NULL),
4390                 .wins   = {
4391                         .nb_flags       = NBT_NM_GROUP,
4392                         .mhomed         = False,
4393                         .num_ips        = ctx->addresses_1_num,
4394                         .ips            = ctx->addresses_1,
4395                         .release        = True,
4396                         .apply_expected = True
4397                 },
4398                 .replica= {
4399                         .type           = WREPL_TYPE_GROUP,
4400                         .state          = WREPL_STATE_TOMBSTONE,
4401                         .node           = WREPL_NODE_B,
4402                         .is_static      = False,
4403                         .num_ips        = ctx->addresses_1_num,
4404                         .ips            = ctx->addresses_1,
4405                         .apply_expected = True
4406                 },
4407         },
4408         /*
4409          * group,released vs. group,tombstone with different ip(s)
4410          */
4411         {
4412                 .line   = __location__,
4413                 .name   = _NBT_NAME("_GR_GT_DI", 0x00, NULL),
4414                 .wins   = {
4415                         .nb_flags       = NBT_NM_GROUP,
4416                         .mhomed         = False,
4417                         .num_ips        = ctx->addresses_1_num,
4418                         .ips            = ctx->addresses_1,
4419                         .release        = True,
4420                         .apply_expected = True
4421                 },
4422                 .replica= {
4423                         .type           = WREPL_TYPE_GROUP,
4424                         .state          = WREPL_STATE_TOMBSTONE,
4425                         .node           = WREPL_NODE_B,
4426                         .is_static      = False,
4427                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4428                         .ips            = addresses_B_1,
4429                         .apply_expected = True
4430                 },
4431         },
4432         /*
4433          * group,released vs. sgroup,active with same ip(s)
4434          */
4435         {
4436                 .line   = __location__,
4437                 .name   = _NBT_NAME("_GR_SA_SI", 0x00, NULL),
4438                 .wins   = {
4439                         .nb_flags       = NBT_NM_GROUP,
4440                         .mhomed         = False,
4441                         .num_ips        = ctx->addresses_1_num,
4442                         .ips            = ctx->addresses_1,
4443                         .release        = True,
4444                         .apply_expected = True
4445                 },
4446                 .replica= {
4447                         .type           = WREPL_TYPE_SGROUP,
4448                         .state          = WREPL_STATE_ACTIVE,
4449                         .node           = WREPL_NODE_B,
4450                         .is_static      = False,
4451                         .num_ips        = ctx->addresses_1_num,
4452                         .ips            = ctx->addresses_1,
4453                         .apply_expected = False
4454                 },
4455         },
4456         /*
4457          * group,released vs. sgroup,active with different ip(s)
4458          */
4459         {
4460                 .line   = __location__,
4461                 .name   = _NBT_NAME("_GR_SA_DI", 0x00, NULL),
4462                 .wins   = {
4463                         .nb_flags       = NBT_NM_GROUP,
4464                         .mhomed         = False,
4465                         .num_ips        = ctx->addresses_1_num,
4466                         .ips            = ctx->addresses_1,
4467                         .release        = True,
4468                         .apply_expected = True
4469                 },
4470                 .replica= {
4471                         .type           = WREPL_TYPE_SGROUP,
4472                         .state          = WREPL_STATE_ACTIVE,
4473                         .node           = WREPL_NODE_B,
4474                         .is_static      = False,
4475                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4476                         .ips            = addresses_B_1,
4477                         .apply_expected = False
4478                 },
4479         },
4480         /*
4481          * group,released vs. sgroup,tombstone with same ip(s)
4482          */
4483         {
4484                 .line   = __location__,
4485                 .name   = _NBT_NAME("_GR_ST_SI", 0x00, NULL),
4486                 .wins   = {
4487                         .nb_flags       = NBT_NM_GROUP,
4488                         .mhomed         = False,
4489                         .num_ips        = ctx->addresses_1_num,
4490                         .ips            = ctx->addresses_1,
4491                         .release        = True,
4492                         .apply_expected = True
4493                 },
4494                 .replica= {
4495                         .type           = WREPL_TYPE_SGROUP,
4496                         .state          = WREPL_STATE_TOMBSTONE,
4497                         .node           = WREPL_NODE_B,
4498                         .is_static      = False,
4499                         .num_ips        = ctx->addresses_1_num,
4500                         .ips            = ctx->addresses_1,
4501                         .apply_expected = False
4502                 },
4503         },
4504         /*
4505          * group,released vs. sgroup,tombstone with different ip(s)
4506          */
4507         {
4508                 .line   = __location__,
4509                 .name   = _NBT_NAME("_GR_ST_DI", 0x00, NULL),
4510                 .wins   = {
4511                         .nb_flags       = NBT_NM_GROUP,
4512                         .mhomed         = False,
4513                         .num_ips        = ctx->addresses_1_num,
4514                         .ips            = ctx->addresses_1,
4515                         .release        = True,
4516                         .apply_expected = True
4517                 },
4518                 .replica= {
4519                         .type           = WREPL_TYPE_SGROUP,
4520                         .state          = WREPL_STATE_TOMBSTONE,
4521                         .node           = WREPL_NODE_B,
4522                         .is_static      = False,
4523                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4524                         .ips            = addresses_B_1,
4525                         .apply_expected = False
4526                 },
4527         },
4528         /*
4529          * group,released vs. mhomed,active with same ip(s)
4530          */
4531         {
4532                 .line   = __location__,
4533                 .name   = _NBT_NAME("_GR_MA_SI", 0x00, NULL),
4534                 .wins   = {
4535                         .nb_flags       = NBT_NM_GROUP,
4536                         .mhomed         = False,
4537                         .num_ips        = ctx->addresses_1_num,
4538                         .ips            = ctx->addresses_1,
4539                         .release        = True,
4540                         .apply_expected = True
4541                 },
4542                 .replica= {
4543                         .type           = WREPL_TYPE_MHOMED,
4544                         .state          = WREPL_STATE_ACTIVE,
4545                         .node           = WREPL_NODE_B,
4546                         .is_static      = False,
4547                         .num_ips        = ctx->addresses_1_num,
4548                         .ips            = ctx->addresses_1,
4549                         .apply_expected = False
4550                 },
4551         },
4552         /*
4553          * group,released vs. mhomed,active with different ip(s)
4554          */
4555         {
4556                 .line   = __location__,
4557                 .name   = _NBT_NAME("_GR_MA_DI", 0x00, NULL),
4558                 .wins   = {
4559                         .nb_flags       = NBT_NM_GROUP,
4560                         .mhomed         = False,
4561                         .num_ips        = ctx->addresses_1_num,
4562                         .ips            = ctx->addresses_1,
4563                         .release        = True,
4564                         .apply_expected = True
4565                 },
4566                 .replica= {
4567                         .type           = WREPL_TYPE_MHOMED,
4568                         .state          = WREPL_STATE_ACTIVE,
4569                         .node           = WREPL_NODE_B,
4570                         .is_static      = False,
4571                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4572                         .ips            = addresses_B_1,
4573                         .apply_expected = False
4574                 },
4575         },
4576         /*
4577          * group,released vs. mhomed,tombstone with same ip(s)
4578          */
4579         {
4580                 .line   = __location__,
4581                 .name   = _NBT_NAME("_GR_MT_SI", 0x00, NULL),
4582                 .wins   = {
4583                         .nb_flags       = NBT_NM_GROUP,
4584                         .mhomed         = False,
4585                         .num_ips        = ctx->addresses_1_num,
4586                         .ips            = ctx->addresses_1,
4587                         .release        = True,
4588                         .apply_expected = True
4589                 },
4590                 .replica= {
4591                         .type           = WREPL_TYPE_MHOMED,
4592                         .state          = WREPL_STATE_TOMBSTONE,
4593                         .node           = WREPL_NODE_B,
4594                         .is_static      = False,
4595                         .num_ips        = ctx->addresses_1_num,
4596                         .ips            = ctx->addresses_1,
4597                         .apply_expected = False
4598                 },
4599         },
4600         /*
4601          * group,released vs. mhomed,tombstone with different ip(s)
4602          */
4603         {
4604                 .line   = __location__,
4605                 .name   = _NBT_NAME("_GR_MT_DI", 0x00, NULL),
4606                 .wins   = {
4607                         .nb_flags       = NBT_NM_GROUP,
4608                         .mhomed         = False,
4609                         .num_ips        = ctx->addresses_1_num,
4610                         .ips            = ctx->addresses_1,
4611                         .release        = True,
4612                         .apply_expected = True
4613                 },
4614                 .replica= {
4615                         .type           = WREPL_TYPE_MHOMED,
4616                         .state          = WREPL_STATE_TOMBSTONE,
4617                         .node           = WREPL_NODE_B,
4618                         .is_static      = False,
4619                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4620                         .ips            = addresses_B_1,
4621                         .apply_expected = False
4622                 },
4623         },
4624         /*
4625          * sgroup,released vs. unique,active with same ip(s)
4626          */
4627         {
4628                 .line   = __location__,
4629                 .name   = _NBT_NAME("_SR_UA_SI", 0x1C, NULL),
4630                 .wins   = {
4631                         .nb_flags       = NBT_NM_GROUP,
4632                         .mhomed         = False,
4633                         .num_ips        = ctx->addresses_1_num,
4634                         .ips            = ctx->addresses_1,
4635                         .release        = True,
4636                         .apply_expected = True
4637                 },
4638                 .replica= {
4639                         .type           = WREPL_TYPE_UNIQUE,
4640                         .state          = WREPL_STATE_ACTIVE,
4641                         .node           = WREPL_NODE_B,
4642                         .is_static      = False,
4643                         .num_ips        = ctx->addresses_1_num,
4644                         .ips            = ctx->addresses_1,
4645                         .apply_expected = True
4646                 },
4647         },
4648         /*
4649          * sgroup,released vs. unique,active with different ip(s)
4650          */
4651         {
4652                 .line   = __location__,
4653                 .name   = _NBT_NAME("_SR_UA_DI", 0x1C, NULL),
4654                 .wins   = {
4655                         .nb_flags       = NBT_NM_GROUP,
4656                         .mhomed         = False,
4657                         .num_ips        = ctx->addresses_1_num,
4658                         .ips            = ctx->addresses_1,
4659                         .release        = True,
4660                         .apply_expected = True
4661                 },
4662                 .replica= {
4663                         .type           = WREPL_TYPE_UNIQUE,
4664                         .state          = WREPL_STATE_ACTIVE,
4665                         .node           = WREPL_NODE_B,
4666                         .is_static      = False,
4667                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4668                         .ips            = addresses_B_1,
4669                         .apply_expected = True
4670                 },
4671         },
4672         /*
4673          * sgroup,released vs. unique,tombstone with same ip(s)
4674          */
4675         {
4676                 .line   = __location__,
4677                 .name   = _NBT_NAME("_SR_UT_SI", 0x1C, NULL),
4678                 .wins   = {
4679                         .nb_flags       = NBT_NM_GROUP,
4680                         .mhomed         = False,
4681                         .num_ips        = ctx->addresses_1_num,
4682                         .ips            = ctx->addresses_1,
4683                         .release        = True,
4684                         .apply_expected = True
4685                 },
4686                 .replica= {
4687                         .type           = WREPL_TYPE_UNIQUE,
4688                         .state          = WREPL_STATE_TOMBSTONE,
4689                         .node           = WREPL_NODE_B,
4690                         .is_static      = False,
4691                         .num_ips        = ctx->addresses_1_num,
4692                         .ips            = ctx->addresses_1,
4693                         .apply_expected = True
4694                 },
4695         },
4696         /*
4697          * sgroup,released vs. unique,tombstone with different ip(s)
4698          */
4699         {
4700                 .line   = __location__,
4701                 .name   = _NBT_NAME("_SR_UT_DI", 0x1C, NULL),
4702                 .wins   = {
4703                         .nb_flags       = NBT_NM_GROUP,
4704                         .mhomed         = False,
4705                         .num_ips        = ctx->addresses_1_num,
4706                         .ips            = ctx->addresses_1,
4707                         .release        = True,
4708                         .apply_expected = True
4709                 },
4710                 .replica= {
4711                         .type           = WREPL_TYPE_UNIQUE,
4712                         .state          = WREPL_STATE_TOMBSTONE,
4713                         .node           = WREPL_NODE_B,
4714                         .is_static      = False,
4715                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4716                         .ips            = addresses_B_1,
4717                         .apply_expected = True
4718                 },
4719         },
4720         /*
4721          * sgroup,released vs. group,active with same ip(s)
4722          */
4723         {
4724                 .line   = __location__,
4725                 .name   = _NBT_NAME("_SR_GA_SI", 0x1C, NULL),
4726                 .wins   = {
4727                         .nb_flags       = NBT_NM_GROUP,
4728                         .mhomed         = False,
4729                         .num_ips        = ctx->addresses_1_num,
4730                         .ips            = ctx->addresses_1,
4731                         .release        = True,
4732                         .apply_expected = True
4733                 },
4734                 .replica= {
4735                         .type           = WREPL_TYPE_GROUP,
4736                         .state          = WREPL_STATE_ACTIVE,
4737                         .node           = WREPL_NODE_B,
4738                         .is_static      = False,
4739                         .num_ips        = ctx->addresses_1_num,
4740                         .ips            = ctx->addresses_1,
4741                         .apply_expected = True
4742                 },
4743         },
4744         /*
4745          * sgroup,released vs. group,active with different ip(s)
4746          */
4747         {
4748                 .line   = __location__,
4749                 .name   = _NBT_NAME("_SR_GA_DI", 0x1C, NULL),
4750                 .wins   = {
4751                         .nb_flags       = NBT_NM_GROUP,
4752                         .mhomed         = False,
4753                         .num_ips        = ctx->addresses_1_num,
4754                         .ips            = ctx->addresses_1,
4755                         .release        = True,
4756                         .apply_expected = True
4757                 },
4758                 .replica= {
4759                         .type           = WREPL_TYPE_GROUP,
4760                         .state          = WREPL_STATE_ACTIVE,
4761                         .node           = WREPL_NODE_B,
4762                         .is_static      = False,
4763                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4764                         .ips            = addresses_B_1,
4765                         .apply_expected = True
4766                 },
4767         },
4768         /*
4769          * sgroup,released vs. group,tombstone with same ip(s)
4770          */
4771         {
4772                 .line   = __location__,
4773                 .name   = _NBT_NAME("_SR_GT_SI", 0x1C, NULL),
4774                 .wins   = {
4775                         .nb_flags       = NBT_NM_GROUP,
4776                         .mhomed         = False,
4777                         .num_ips        = ctx->addresses_1_num,
4778                         .ips            = ctx->addresses_1,
4779                         .release        = True,
4780                         .apply_expected = True
4781                 },
4782                 .replica= {
4783                         .type           = WREPL_TYPE_GROUP,
4784                         .state          = WREPL_STATE_TOMBSTONE,
4785                         .node           = WREPL_NODE_B,
4786                         .is_static      = False,
4787                         .num_ips        = ctx->addresses_1_num,
4788                         .ips            = ctx->addresses_1,
4789                         .apply_expected = True
4790                 },
4791         },
4792         /*
4793          * sgroup,released vs. group,tombstone with different ip(s)
4794          */
4795         {
4796                 .line   = __location__,
4797                 .name   = _NBT_NAME("_SR_GT_DI", 0x1C, NULL),
4798                 .wins   = {
4799                         .nb_flags       = NBT_NM_GROUP,
4800                         .mhomed         = False,
4801                         .num_ips        = ctx->addresses_1_num,
4802                         .ips            = ctx->addresses_1,
4803                         .release        = True,
4804                         .apply_expected = True
4805                 },
4806                 .replica= {
4807                         .type           = WREPL_TYPE_GROUP,
4808                         .state          = WREPL_STATE_TOMBSTONE,
4809                         .node           = WREPL_NODE_B,
4810                         .is_static      = False,
4811                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4812                         .ips            = addresses_B_1,
4813                         .apply_expected = True
4814                 },
4815         },
4816         /*
4817          * sgroup,released vs. sgroup,active with same ip(s)
4818          */
4819         {
4820                 .line   = __location__,
4821                 .name   = _NBT_NAME("_SR_SA_SI", 0x1C, NULL),
4822                 .wins   = {
4823                         .nb_flags       = NBT_NM_GROUP,
4824                         .mhomed         = False,
4825                         .num_ips        = ctx->addresses_1_num,
4826                         .ips            = ctx->addresses_1,
4827                         .release        = True,
4828                         .apply_expected = True
4829                 },
4830                 .replica= {
4831                         .type           = WREPL_TYPE_SGROUP,
4832                         .state          = WREPL_STATE_ACTIVE,
4833                         .node           = WREPL_NODE_B,
4834                         .is_static      = False,
4835                         .num_ips        = ctx->addresses_1_num,
4836                         .ips            = ctx->addresses_1,
4837                         .apply_expected = True
4838                 },
4839         },
4840         /*
4841          * sgroup,released vs. sgroup,active with different ip(s)
4842          */
4843         {
4844                 .line   = __location__,
4845                 .name   = _NBT_NAME("_SR_SA_DI", 0x1C, NULL),
4846                 .wins   = {
4847                         .nb_flags       = NBT_NM_GROUP,
4848                         .mhomed         = False,
4849                         .num_ips        = ctx->addresses_1_num,
4850                         .ips            = ctx->addresses_1,
4851                         .release        = True,
4852                         .apply_expected = True
4853                 },
4854                 .replica= {
4855                         .type           = WREPL_TYPE_SGROUP,
4856                         .state          = WREPL_STATE_ACTIVE,
4857                         .node           = WREPL_NODE_B,
4858                         .is_static      = False,
4859                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4860                         .ips            = addresses_B_1,
4861                         .apply_expected = True
4862                 },
4863         },
4864         /*
4865          * sgroup,released vs. sgroup,tombstone with same ip(s)
4866          */
4867         {
4868                 .line   = __location__,
4869                 .name   = _NBT_NAME("_SR_ST_SI", 0x1C, NULL),
4870                 .wins   = {
4871                         .nb_flags       = NBT_NM_GROUP,
4872                         .mhomed         = False,
4873                         .num_ips        = ctx->addresses_1_num,
4874                         .ips            = ctx->addresses_1,
4875                         .release        = True,
4876                         .apply_expected = True
4877                 },
4878                 .replica= {
4879                         .type           = WREPL_TYPE_SGROUP,
4880                         .state          = WREPL_STATE_TOMBSTONE,
4881                         .node           = WREPL_NODE_B,
4882                         .is_static      = False,
4883                         .num_ips        = ctx->addresses_1_num,
4884                         .ips            = ctx->addresses_1,
4885                         .apply_expected = True
4886                 },
4887         },
4888         /*
4889          * sgroup,released vs. sgroup,tombstone with different ip(s)
4890          */
4891         {
4892                 .line   = __location__,
4893                 .name   = _NBT_NAME("_SR_ST_DI", 0x1C, NULL),
4894                 .wins   = {
4895                         .nb_flags       = NBT_NM_GROUP,
4896                         .mhomed         = False,
4897                         .num_ips        = ctx->addresses_1_num,
4898                         .ips            = ctx->addresses_1,
4899                         .release        = True,
4900                         .apply_expected = True
4901                 },
4902                 .replica= {
4903                         .type           = WREPL_TYPE_SGROUP,
4904                         .state          = WREPL_STATE_TOMBSTONE,
4905                         .node           = WREPL_NODE_B,
4906                         .is_static      = False,
4907                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4908                         .ips            = addresses_B_1,
4909                         .apply_expected = True
4910                 },
4911         },
4912         /*
4913          * sgroup,released vs. mhomed,active with same ip(s)
4914          */
4915         {
4916                 .line   = __location__,
4917                 .name   = _NBT_NAME("_SR_MA_SI", 0x1C, NULL),
4918                 .wins   = {
4919                         .nb_flags       = NBT_NM_GROUP,
4920                         .mhomed         = False,
4921                         .num_ips        = ctx->addresses_1_num,
4922                         .ips            = ctx->addresses_1,
4923                         .release        = True,
4924                         .apply_expected = True
4925                 },
4926                 .replica= {
4927                         .type           = WREPL_TYPE_MHOMED,
4928                         .state          = WREPL_STATE_ACTIVE,
4929                         .node           = WREPL_NODE_B,
4930                         .is_static      = False,
4931                         .num_ips        = ctx->addresses_1_num,
4932                         .ips            = ctx->addresses_1,
4933                         .apply_expected = True
4934                 },
4935         },
4936         /*
4937          * sgroup,released vs. mhomed,active with different ip(s)
4938          */
4939         {
4940                 .line   = __location__,
4941                 .name   = _NBT_NAME("_SR_MA_DI", 0x1C, NULL),
4942                 .wins   = {
4943                         .nb_flags       = NBT_NM_GROUP,
4944                         .mhomed         = False,
4945                         .num_ips        = ctx->addresses_1_num,
4946                         .ips            = ctx->addresses_1,
4947                         .release        = True,
4948                         .apply_expected = True
4949                 },
4950                 .replica= {
4951                         .type           = WREPL_TYPE_MHOMED,
4952                         .state          = WREPL_STATE_ACTIVE,
4953                         .node           = WREPL_NODE_B,
4954                         .is_static      = False,
4955                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4956                         .ips            = addresses_B_1,
4957                         .apply_expected = True
4958                 },
4959         },
4960         /*
4961          * sgroup,released vs. mhomed,tombstone with same ip(s)
4962          */
4963         {
4964                 .line   = __location__,
4965                 .name   = _NBT_NAME("_SR_MT_SI", 0x1C, NULL),
4966                 .wins   = {
4967                         .nb_flags       = NBT_NM_GROUP,
4968                         .mhomed         = False,
4969                         .num_ips        = ctx->addresses_1_num,
4970                         .ips            = ctx->addresses_1,
4971                         .release        = True,
4972                         .apply_expected = True
4973                 },
4974                 .replica= {
4975                         .type           = WREPL_TYPE_MHOMED,
4976                         .state          = WREPL_STATE_TOMBSTONE,
4977                         .node           = WREPL_NODE_B,
4978                         .is_static      = False,
4979                         .num_ips        = ctx->addresses_1_num,
4980                         .ips            = ctx->addresses_1,
4981                         .apply_expected = True
4982                 },
4983         },
4984         /*
4985          * sgroup,released vs. mhomed,tombstone with different ip(s)
4986          */
4987         {
4988                 .line   = __location__,
4989                 .name   = _NBT_NAME("_SR_MT_DI", 0x1C, NULL),
4990                 .wins   = {
4991                         .nb_flags       = NBT_NM_GROUP,
4992                         .mhomed         = False,
4993                         .num_ips        = ctx->addresses_1_num,
4994                         .ips            = ctx->addresses_1,
4995                         .release        = True,
4996                         .apply_expected = True
4997                 },
4998                 .replica= {
4999                         .type           = WREPL_TYPE_MHOMED,
5000                         .state          = WREPL_STATE_TOMBSTONE,
5001                         .node           = WREPL_NODE_B,
5002                         .is_static      = False,
5003                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5004                         .ips            = addresses_B_1,
5005                         .apply_expected = True
5006                 },
5007         },
5008         /*
5009          * mhomed,released vs. unique,active with same ip(s)
5010          */
5011         {
5012                 .line   = __location__,
5013                 .name   = _NBT_NAME("_MR_UA_SI", 0x00, NULL),
5014                 .wins   = {
5015                         .nb_flags       = 0,
5016                         .mhomed         = True,
5017                         .num_ips        = ctx->addresses_1_num,
5018                         .ips            = ctx->addresses_1,
5019                         .release        = True,
5020                         .apply_expected = True
5021                 },
5022                 .replica= {
5023                         .type           = WREPL_TYPE_UNIQUE,
5024                         .state          = WREPL_STATE_ACTIVE,
5025                         .node           = WREPL_NODE_B,
5026                         .is_static      = False,
5027                         .num_ips        = ctx->addresses_1_num,
5028                         .ips            = ctx->addresses_1,
5029                         .apply_expected = True
5030                 },
5031         },
5032         /*
5033          * mhomed,released vs. unique,active with different ip(s)
5034          */
5035         {
5036                 .line   = __location__,
5037                 .name   = _NBT_NAME("_MR_UA_DI", 0x00, NULL),
5038                 .wins   = {
5039                         .nb_flags       = 0,
5040                         .mhomed         = True,
5041                         .num_ips        = ctx->addresses_1_num,
5042                         .ips            = ctx->addresses_1,
5043                         .release        = True,
5044                         .apply_expected = True
5045                 },
5046                 .replica= {
5047                         .type           = WREPL_TYPE_UNIQUE,
5048                         .state          = WREPL_STATE_ACTIVE,
5049                         .node           = WREPL_NODE_B,
5050                         .is_static      = False,
5051                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5052                         .ips            = addresses_B_1,
5053                         .apply_expected = True
5054                 },
5055         },
5056         /*
5057          * mhomed,released vs. unique,tombstone with same ip(s)
5058          */
5059         {
5060                 .line   = __location__,
5061                 .name   = _NBT_NAME("_MR_UT_SI", 0x00, NULL),
5062                 .wins   = {
5063                         .nb_flags       = 0,
5064                         .mhomed         = True,
5065                         .num_ips        = ctx->addresses_1_num,
5066                         .ips            = ctx->addresses_1,
5067                         .release        = True,
5068                         .apply_expected = True
5069                 },
5070                 .replica= {
5071                         .type           = WREPL_TYPE_UNIQUE,
5072                         .state          = WREPL_STATE_TOMBSTONE,
5073                         .node           = WREPL_NODE_B,
5074                         .is_static      = False,
5075                         .num_ips        = ctx->addresses_1_num,
5076                         .ips            = ctx->addresses_1,
5077                         .apply_expected = True
5078                 },
5079         },
5080         /*
5081          * mhomed,released vs. unique,tombstone with different ip(s)
5082          */
5083         {
5084                 .line   = __location__,
5085                 .name   = _NBT_NAME("_MR_UT_DI", 0x00, NULL),
5086                 .wins   = {
5087                         .nb_flags       = 0,
5088                         .mhomed         = True,
5089                         .num_ips        = ctx->addresses_1_num,
5090                         .ips            = ctx->addresses_1,
5091                         .release        = True,
5092                         .apply_expected = True
5093                 },
5094                 .replica= {
5095                         .type           = WREPL_TYPE_UNIQUE,
5096                         .state          = WREPL_STATE_TOMBSTONE,
5097                         .node           = WREPL_NODE_B,
5098                         .is_static      = False,
5099                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5100                         .ips            = addresses_B_1,
5101                         .apply_expected = True
5102                 },
5103         },
5104         /*
5105          * mhomed,released vs. group,active with same ip(s)
5106          */
5107         {
5108                 .line   = __location__,
5109                 .name   = _NBT_NAME("_MR_GA_SI", 0x00, NULL),
5110                 .wins   = {
5111                         .nb_flags       = 0,
5112                         .mhomed         = True,
5113                         .num_ips        = ctx->addresses_1_num,
5114                         .ips            = ctx->addresses_1,
5115                         .release        = True,
5116                         .apply_expected = True
5117                 },
5118                 .replica= {
5119                         .type           = WREPL_TYPE_GROUP,
5120                         .state          = WREPL_STATE_ACTIVE,
5121                         .node           = WREPL_NODE_B,
5122                         .is_static      = False,
5123                         .num_ips        = ctx->addresses_1_num,
5124                         .ips            = ctx->addresses_1,
5125                         .apply_expected = True
5126                 },
5127         },
5128         /*
5129          * mhomed,released vs. group,active with different ip(s)
5130          */
5131         {
5132                 .line   = __location__,
5133                 .name   = _NBT_NAME("_MR_GA_DI", 0x00, NULL),
5134                 .wins   = {
5135                         .nb_flags       = 0,
5136                         .mhomed         = True,
5137                         .num_ips        = ctx->addresses_1_num,
5138                         .ips            = ctx->addresses_1,
5139                         .release        = True,
5140                         .apply_expected = True
5141                 },
5142                 .replica= {
5143                         .type           = WREPL_TYPE_GROUP,
5144                         .state          = WREPL_STATE_ACTIVE,
5145                         .node           = WREPL_NODE_B,
5146                         .is_static      = False,
5147                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5148                         .ips            = addresses_B_1,
5149                         .apply_expected = True
5150                 },
5151         },
5152         /*
5153          * mhomed,released vs. group,tombstone with same ip(s)
5154          */
5155         {
5156                 .line   = __location__,
5157                 .name   = _NBT_NAME("_MR_GT_SI", 0x00, NULL),
5158                 .wins   = {
5159                         .nb_flags       = 0,
5160                         .mhomed         = True,
5161                         .num_ips        = ctx->addresses_1_num,
5162                         .ips            = ctx->addresses_1,
5163                         .release        = True,
5164                         .apply_expected = True
5165                 },
5166                 .replica= {
5167                         .type           = WREPL_TYPE_GROUP,
5168                         .state          = WREPL_STATE_TOMBSTONE,
5169                         .node           = WREPL_NODE_B,
5170                         .is_static      = False,
5171                         .num_ips        = ctx->addresses_1_num,
5172                         .ips            = ctx->addresses_1,
5173                         .apply_expected = True
5174                 },
5175         },
5176         /*
5177          * mhomed,released vs. group,tombstone with different ip(s)
5178          */
5179         {
5180                 .line   = __location__,
5181                 .name   = _NBT_NAME("_MR_GT_DI", 0x00, NULL),
5182                 .wins   = {
5183                         .nb_flags       = 0,
5184                         .mhomed         = True,
5185                         .num_ips        = ctx->addresses_1_num,
5186                         .ips            = ctx->addresses_1,
5187                         .release        = True,
5188                         .apply_expected = True
5189                 },
5190                 .replica= {
5191                         .type           = WREPL_TYPE_GROUP,
5192                         .state          = WREPL_STATE_TOMBSTONE,
5193                         .node           = WREPL_NODE_B,
5194                         .is_static      = False,
5195                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5196                         .ips            = addresses_B_1,
5197                         .apply_expected = True
5198                 },
5199         },
5200         /*
5201          * mhomed,released vs. sgroup,active with same ip(s)
5202          */
5203         {
5204                 .line   = __location__,
5205                 .name   = _NBT_NAME("_MR_SA_SI", 0x00, NULL),
5206                 .wins   = {
5207                         .nb_flags       = 0,
5208                         .mhomed         = True,
5209                         .num_ips        = ctx->addresses_1_num,
5210                         .ips            = ctx->addresses_1,
5211                         .release        = True,
5212                         .apply_expected = True
5213                 },
5214                 .replica= {
5215                         .type           = WREPL_TYPE_SGROUP,
5216                         .state          = WREPL_STATE_ACTIVE,
5217                         .node           = WREPL_NODE_B,
5218                         .is_static      = False,
5219                         .num_ips        = ctx->addresses_1_num,
5220                         .ips            = ctx->addresses_1,
5221                         .apply_expected = True
5222                 },
5223         },
5224         /*
5225          * mhomed,released vs. sgroup,active with different ip(s)
5226          */
5227         {
5228                 .line   = __location__,
5229                 .name   = _NBT_NAME("_MR_SA_DI", 0x00, NULL),
5230                 .wins   = {
5231                         .nb_flags       = 0,
5232                         .mhomed         = True,
5233                         .num_ips        = ctx->addresses_1_num,
5234                         .ips            = ctx->addresses_1,
5235                         .release        = True,
5236                         .apply_expected = True
5237                 },
5238                 .replica= {
5239                         .type           = WREPL_TYPE_SGROUP,
5240                         .state          = WREPL_STATE_ACTIVE,
5241                         .node           = WREPL_NODE_B,
5242                         .is_static      = False,
5243                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5244                         .ips            = addresses_B_1,
5245                         .apply_expected = True
5246                 },
5247         },
5248         /*
5249          * mhomed,released vs. sgroup,tombstone with same ip(s)
5250          */
5251         {
5252                 .line   = __location__,
5253                 .name   = _NBT_NAME("_MR_ST_SI", 0x00, NULL),
5254                 .wins   = {
5255                         .nb_flags       = 0,
5256                         .mhomed         = True,
5257                         .num_ips        = ctx->addresses_1_num,
5258                         .ips            = ctx->addresses_1,
5259                         .release        = True,
5260                         .apply_expected = True
5261                 },
5262                 .replica= {
5263                         .type           = WREPL_TYPE_SGROUP,
5264                         .state          = WREPL_STATE_TOMBSTONE,
5265                         .node           = WREPL_NODE_B,
5266                         .is_static      = False,
5267                         .num_ips        = ctx->addresses_1_num,
5268                         .ips            = ctx->addresses_1,
5269                         .apply_expected = True
5270                 },
5271         },
5272         /*
5273          * mhomed,released vs. sgroup,tombstone with different ip(s)
5274          */
5275         {
5276                 .line   = __location__,
5277                 .name   = _NBT_NAME("_MR_ST_DI", 0x00, NULL),
5278                 .wins   = {
5279                         .nb_flags       = 0,
5280                         .mhomed         = True,
5281                         .num_ips        = ctx->addresses_1_num,
5282                         .ips            = ctx->addresses_1,
5283                         .release        = True,
5284                         .apply_expected = True
5285                 },
5286                 .replica= {
5287                         .type           = WREPL_TYPE_SGROUP,
5288                         .state          = WREPL_STATE_TOMBSTONE,
5289                         .node           = WREPL_NODE_B,
5290                         .is_static      = False,
5291                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5292                         .ips            = addresses_B_1,
5293                         .apply_expected = True
5294                 },
5295         },
5296         /*
5297          * mhomed,released vs. mhomed,active with same ip(s)
5298          */
5299         {
5300                 .line   = __location__,
5301                 .name   = _NBT_NAME("_MR_MA_SI", 0x00, NULL),
5302                 .wins   = {
5303                         .nb_flags       = 0,
5304                         .mhomed         = True,
5305                         .num_ips        = ctx->addresses_1_num,
5306                         .ips            = ctx->addresses_1,
5307                         .release        = True,
5308                         .apply_expected = True
5309                 },
5310                 .replica= {
5311                         .type           = WREPL_TYPE_MHOMED,
5312                         .state          = WREPL_STATE_ACTIVE,
5313                         .node           = WREPL_NODE_B,
5314                         .is_static      = False,
5315                         .num_ips        = ctx->addresses_1_num,
5316                         .ips            = ctx->addresses_1,
5317                         .apply_expected = True
5318                 },
5319         },
5320         /*
5321          * mhomed,released vs. mhomed,active with different ip(s)
5322          */
5323         {
5324                 .line   = __location__,
5325                 .name   = _NBT_NAME("_MR_MA_DI", 0x00, NULL),
5326                 .wins   = {
5327                         .nb_flags       = 0,
5328                         .mhomed         = True,
5329                         .num_ips        = ctx->addresses_1_num,
5330                         .ips            = ctx->addresses_1,
5331                         .release        = True,
5332                         .apply_expected = True
5333                 },
5334                 .replica= {
5335                         .type           = WREPL_TYPE_MHOMED,
5336                         .state          = WREPL_STATE_ACTIVE,
5337                         .node           = WREPL_NODE_B,
5338                         .is_static      = False,
5339                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5340                         .ips            = addresses_B_1,
5341                         .apply_expected = True
5342                 },
5343         },
5344         /*
5345          * mhomed,released vs. mhomed,tombstone with same ip(s)
5346          */
5347         {
5348                 .line   = __location__,
5349                 .name   = _NBT_NAME("_MR_MT_SI", 0x00, NULL),
5350                 .wins   = {
5351                         .nb_flags       = 0,
5352                         .mhomed         = True,
5353                         .num_ips        = ctx->addresses_1_num,
5354                         .ips            = ctx->addresses_1,
5355                         .release        = True,
5356                         .apply_expected = True
5357                 },
5358                 .replica= {
5359                         .type           = WREPL_TYPE_MHOMED,
5360                         .state          = WREPL_STATE_TOMBSTONE,
5361                         .node           = WREPL_NODE_B,
5362                         .is_static      = False,
5363                         .num_ips        = ctx->addresses_1_num,
5364                         .ips            = ctx->addresses_1,
5365                         .apply_expected = True
5366                 },
5367         },
5368         /*
5369          * mhomed,released vs. mhomed,tombstone with different ip(s)
5370          */
5371         {
5372                 .line   = __location__,
5373                 .name   = _NBT_NAME("_MR_MT_DI", 0x00, NULL),
5374                 .wins   = {
5375                         .nb_flags       = 0,
5376                         .mhomed         = True,
5377                         .num_ips        = ctx->addresses_1_num,
5378                         .ips            = ctx->addresses_1,
5379                         .release        = True,
5380                         .apply_expected = True
5381                 },
5382                 .replica= {
5383                         .type           = WREPL_TYPE_MHOMED,
5384                         .state          = WREPL_STATE_TOMBSTONE,
5385                         .node           = WREPL_NODE_B,
5386                         .is_static      = False,
5387                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5388                         .ips            = addresses_B_1,
5389                         .apply_expected = True
5390                 },
5391         },
5392         };
5393
5394         if (!ctx) return False;
5395
5396         printf("Test Replica records vs. owned released records\n");
5397
5398         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
5399                 printf("%s => %s\n", nbt_name_string(ctx, &records[i].name),
5400                         (records[i].replica.apply_expected?"REPLACE":"NOT REPLACE"));
5401
5402                 /*
5403                  * Setup Register
5404                  */
5405                 name_register->in.name          = records[i].name;
5406                 name_register->in.dest_addr     = ctx->address;
5407                 name_register->in.address       = records[i].wins.ips[0].ip;
5408                 name_register->in.nb_flags      = records[i].wins.nb_flags;
5409                 name_register->in.register_demand= False;
5410                 name_register->in.broadcast     = False;
5411                 name_register->in.multi_homed   = records[i].wins.mhomed;
5412                 name_register->in.ttl           = 300000;
5413                 name_register->in.timeout       = 70;
5414                 name_register->in.retries       = 0;
5415
5416                 status = nbt_name_register(ctx->nbtsock, ctx, name_register);
5417                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
5418                         printf("No response from %s for name register\n", ctx->address);
5419                         ret = False;
5420                 }
5421                 if (!NT_STATUS_IS_OK(status)) {
5422                         printf("Bad response from %s for name register - %s\n",
5423                                ctx->address, nt_errstr(status));
5424                         ret = False;
5425                 }
5426                 CHECK_VALUE(name_register->out.rcode, 0);
5427                 CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address);
5428                 CHECK_VALUE(name_register->out.name.type, records[i].name.type);
5429                 CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name);
5430                 CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope);
5431                 CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[0].ip);
5432
5433                 if (records[i].wins.release) {
5434                         release->in.name        = records[i].name;
5435                         release->in.dest_addr   = ctx->address;
5436                         release->in.address     = records[i].wins.ips[0].ip;
5437                         release->in.nb_flags    = records[i].wins.nb_flags;
5438                         release->in.broadcast   = False;
5439                         release->in.timeout     = 30;
5440                         release->in.retries     = 0;
5441
5442                         status = nbt_name_release(ctx->nbtsock, ctx, release);
5443                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
5444                                 printf("No response from %s for name release\n", ctx->address);
5445                                 return False;
5446                         }
5447                         if (!NT_STATUS_IS_OK(status)) {
5448                                 printf("Bad response from %s for name query - %s\n",
5449                                        ctx->address, nt_errstr(status));
5450                                 return False;
5451                         }
5452                         CHECK_VALUE(release->out.rcode, 0);
5453                 }
5454
5455                 /*
5456                  * Setup Replica
5457                  */
5458                 wins_name->name         = &records[i].name;
5459                 wins_name->flags        = WREPL_NAME_FLAGS(records[i].replica.type,
5460                                                            records[i].replica.state,
5461                                                            records[i].replica.node,
5462                                                            records[i].replica.is_static);
5463                 wins_name->id           = ++ctx->b.max_version;
5464                 if (wins_name->flags & 2) {
5465                         wins_name->addresses.addresses.num_ips = records[i].replica.num_ips;
5466                         wins_name->addresses.addresses.ips     = discard_const(records[i].replica.ips);
5467                 } else {
5468                         wins_name->addresses.ip = records[i].replica.ips[0].ip;
5469                 }
5470                 wins_name->unknown      = "255.255.255.255";
5471
5472                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
5473                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name,
5474                                              records[i].replica.apply_expected);
5475
5476                 if (records[i].replica.apply_expected) {
5477                         wins_name->name         = &records[i].name;
5478                         wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
5479                                                                    WREPL_STATE_TOMBSTONE,
5480                                                                    WREPL_NODE_B, False);
5481                         wins_name->id           = ++ctx->b.max_version;
5482                         wins_name->addresses.ip = addresses_B_1[0].ip;
5483                         wins_name->unknown      = "255.255.255.255";
5484
5485                         ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
5486                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
5487                 } else {
5488                         release->in.name        = records[i].name;
5489                         release->in.dest_addr   = ctx->address;
5490                         release->in.address     = records[i].wins.ips[0].ip;
5491                         release->in.nb_flags    = records[i].wins.nb_flags;
5492                         release->in.broadcast   = False;
5493                         release->in.timeout     = 30;
5494                         release->in.retries     = 0;
5495
5496                         status = nbt_name_release(ctx->nbtsock, ctx, release);
5497                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
5498                                 printf("No response from %s for name release\n", ctx->address);
5499                                 return False;
5500                         }
5501                         if (!NT_STATUS_IS_OK(status)) {
5502                                 printf("Bad response from %s for name query - %s\n",
5503                                        ctx->address, nt_errstr(status));
5504                                 return False;
5505                         }
5506                         CHECK_VALUE(release->out.rcode, 0);
5507                 }
5508 done:
5509                 if (!ret) {
5510                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
5511                         return ret;
5512                 }
5513         }
5514
5515         return ret;
5516 }
5517
5518 static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_conn *ctx)
5519 {
5520         BOOL ret = True;
5521         NTSTATUS status;
5522         struct wrepl_wins_name wins_name_;
5523         struct wrepl_wins_name *wins_name = &wins_name_;
5524         struct nbt_name_register name_register_;
5525         struct nbt_name_register *name_register = &name_register_;
5526         struct nbt_name_release release_;
5527         struct nbt_name_release *release = &release_;
5528         uint32_t i;
5529         struct {
5530                 const char *line; /* just better debugging */
5531                 struct nbt_name name;
5532                 struct {
5533                         uint32_t nb_flags;
5534                         BOOL mhomed;
5535                         uint32_t num_ips;
5536                         const struct wrepl_ip *ips;
5537                         BOOL release;
5538                         BOOL apply_expected;
5539                 } wins;
5540                 struct {
5541                         enum wrepl_name_type type;
5542                         enum wrepl_name_state state;
5543                         enum wrepl_name_node node;
5544                         BOOL is_static;
5545                         uint32_t num_ips;
5546                         const struct wrepl_ip *ips;
5547                         BOOL apply_expected;
5548                 } replica;
5549         } records[] = {
5550 #if 0
5551         /*
5552          * unique,active vs. unique,active with same ip(s)
5553          */
5554         {
5555                 .line   = __location__,
5556                 .name   = _NBT_NAME("_UA_UA_SI", 0x00, NULL),
5557                 .wins   = {
5558                         .nb_flags       = 0,
5559                         .mhomed         = False,
5560                         .num_ips        = ctx->addresses_1_num,
5561                         .ips            = ctx->addresses_1,
5562                         .release        = False,
5563                         .apply_expected = True
5564                 },
5565                 .replica= {
5566                         .type           = WREPL_TYPE_UNIQUE,
5567                         .state          = WREPL_STATE_ACTIVE,
5568                         .node           = WREPL_NODE_B,
5569                         .is_static      = False,
5570                         .num_ips        = ctx->addresses_1_num,
5571                         .ips            = ctx->addresses_1,
5572                         .apply_expected = True
5573                 },
5574         },
5575         /*
5576          * unique,active vs. unique,active with different ip(s)
5577          */
5578         {
5579                 .line   = __location__,
5580                 .name   = _NBT_NAME("_UA_UA_DI", 0x00, NULL),
5581                 .wins   = {
5582                         .nb_flags       = 0,
5583                         .mhomed         = False,
5584                         .num_ips        = ctx->addresses_1_num,
5585                         .ips            = ctx->addresses_1,
5586                         .release        = False,
5587                         .apply_expected = True
5588                 },
5589                 .replica= {
5590                         .type           = WREPL_TYPE_UNIQUE,
5591                         .state          = WREPL_STATE_ACTIVE,
5592                         .node           = WREPL_NODE_B,
5593                         .is_static      = False,
5594                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5595                         .ips            = addresses_B_1,
5596                         .apply_expected = True
5597                 },
5598         },
5599         /*
5600          * unique,active vs. unique,tombstone with same ip(s)
5601          */
5602         {
5603                 .line   = __location__,
5604                 .name   = _NBT_NAME("_UA_UT_SI", 0x00, NULL),
5605                 .wins   = {
5606                         .nb_flags       = 0,
5607                         .mhomed         = False,
5608                         .num_ips        = ctx->addresses_1_num,
5609                         .ips            = ctx->addresses_1,
5610                         .release        = False,
5611                         .apply_expected = True
5612                 },
5613                 .replica= {
5614                         .type           = WREPL_TYPE_UNIQUE,
5615                         .state          = WREPL_STATE_TOMBSTONE,
5616                         .node           = WREPL_NODE_B,
5617                         .is_static      = False,
5618                         .num_ips        = ctx->addresses_1_num,
5619                         .ips            = ctx->addresses_1,
5620                         .apply_expected = False
5621                 },
5622         },
5623         /*
5624          * unique,active vs. unique,tombstone with different ip(s)
5625          */
5626         {
5627                 .line   = __location__,
5628                 .name   = _NBT_NAME("_UA_UT_DI", 0x00, NULL),
5629                 .wins   = {
5630                         .nb_flags       = 0,
5631                         .mhomed         = False,
5632                         .num_ips        = ctx->addresses_1_num,
5633                         .ips            = ctx->addresses_1,
5634                         .release        = False,
5635                         .apply_expected = True
5636                 },
5637                 .replica= {
5638                         .type           = WREPL_TYPE_UNIQUE,
5639                         .state          = WREPL_STATE_TOMBSTONE,
5640                         .node           = WREPL_NODE_B,
5641                         .is_static      = False,
5642                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5643                         .ips            = addresses_B_1,
5644                         .apply_expected = True
5645                 },
5646         },
5647 #endif
5648         };
5649
5650         if (!ctx) return False;
5651
5652         if (!ctx->nbt_root_port) {
5653                 printf("SKIP: Test Replica records vs. owned active records: not bound to port[%d]\n",
5654                         lp_nbt_port());
5655                 return True;
5656         }
5657
5658         printf("Test Replica records vs. owned active records\n");
5659
5660         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
5661                 printf("%s => %s\n", nbt_name_string(ctx, &records[i].name),
5662                         (records[i].replica.apply_expected?"REPLACE":"NOT REPLACE"));
5663
5664                 /*
5665                  * Setup Register
5666                  */
5667                 name_register->in.name          = records[i].name;
5668                 name_register->in.dest_addr     = ctx->address;
5669                 name_register->in.address       = records[i].wins.ips[0].ip;
5670                 name_register->in.nb_flags      = records[i].wins.nb_flags;
5671                 name_register->in.register_demand= False;
5672                 name_register->in.broadcast     = False;
5673                 name_register->in.multi_homed   = records[i].wins.mhomed;
5674                 name_register->in.ttl           = 300000;
5675                 name_register->in.timeout       = 70;
5676                 name_register->in.retries       = 0;
5677
5678                 status = nbt_name_register(ctx->nbtsock, ctx, name_register);
5679                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
5680                         printf("No response from %s for name register\n", ctx->address);
5681                         ret = False;
5682                 }
5683                 if (!NT_STATUS_IS_OK(status)) {
5684                         printf("Bad response from %s for name register - %s\n",
5685                                ctx->address, nt_errstr(status));
5686                         ret = False;
5687                 }
5688                 CHECK_VALUE(name_register->out.rcode, 0);
5689                 CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address);
5690                 CHECK_VALUE(name_register->out.name.type, records[i].name.type);
5691                 CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name);
5692                 CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope);
5693                 CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[0].ip);
5694
5695                 if (records[i].wins.release) {
5696                         release->in.name        = records[i].name;
5697                         release->in.dest_addr   = ctx->address;
5698                         release->in.address     = records[i].wins.ips[0].ip;
5699                         release->in.nb_flags    = records[i].wins.nb_flags;
5700                         release->in.broadcast   = False;
5701                         release->in.timeout     = 30;
5702                         release->in.retries     = 0;
5703
5704                         status = nbt_name_release(ctx->nbtsock, ctx, release);
5705                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
5706                                 printf("No response from %s for name release\n", ctx->address);
5707                                 return False;
5708                         }
5709                         if (!NT_STATUS_IS_OK(status)) {
5710                                 printf("Bad response from %s for name query - %s\n",
5711                                        ctx->address, nt_errstr(status));
5712                                 return False;
5713                         }
5714                         CHECK_VALUE(release->out.rcode, 0);
5715                 }
5716
5717                 /*
5718                  * Setup Replica
5719                  */
5720                 wins_name->name         = &records[i].name;
5721                 wins_name->flags        = WREPL_NAME_FLAGS(records[i].replica.type,
5722                                                            records[i].replica.state,
5723                                                            records[i].replica.node,
5724                                                            records[i].replica.is_static);
5725                 wins_name->id           = ++ctx->b.max_version;
5726                 if (wins_name->flags & 2) {
5727                         wins_name->addresses.addresses.num_ips = records[i].replica.num_ips;
5728                         wins_name->addresses.addresses.ips     = discard_const(records[i].replica.ips);
5729                 } else {
5730                         wins_name->addresses.ip = records[i].replica.ips[0].ip;
5731                 }
5732                 wins_name->unknown      = "255.255.255.255";
5733
5734                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
5735                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name,
5736                                              records[i].replica.apply_expected);
5737
5738                 if (records[i].replica.apply_expected) {
5739                         wins_name->name         = &records[i].name;
5740                         wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
5741                                                                    WREPL_STATE_TOMBSTONE,
5742                                                                    WREPL_NODE_B, False);
5743                         wins_name->id           = ++ctx->b.max_version;
5744                         wins_name->addresses.ip = addresses_B_1[0].ip;
5745                         wins_name->unknown      = "255.255.255.255";
5746
5747                         ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
5748                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
5749                 } else {
5750                         release->in.name        = records[i].name;
5751                         release->in.dest_addr   = ctx->address;
5752                         release->in.address     = records[i].wins.ips[0].ip;
5753                         release->in.nb_flags    = records[i].wins.nb_flags;
5754                         release->in.broadcast   = False;
5755                         release->in.timeout     = 30;
5756                         release->in.retries     = 0;
5757
5758                         status = nbt_name_release(ctx->nbtsock, ctx, release);
5759                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
5760                                 printf("No response from %s for name release\n", ctx->address);
5761                                 return False;
5762                         }
5763                         if (!NT_STATUS_IS_OK(status)) {
5764                                 printf("Bad response from %s for name query - %s\n",
5765                                        ctx->address, nt_errstr(status));
5766                                 return False;
5767                         }
5768                         CHECK_VALUE(release->out.rcode, 0);
5769                 }
5770 done:
5771                 if (!ret) {
5772                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
5773                         return ret;
5774                 }
5775         }
5776
5777         return ret;
5778 }
5779
5780
5781 /*
5782   test WINS replication operations
5783 */
5784 BOOL torture_nbt_winsreplication_quick(void)
5785 {
5786         const char *address;
5787         struct nbt_name name;
5788         TALLOC_CTX *mem_ctx = talloc_new(NULL);
5789         NTSTATUS status;
5790         BOOL ret = True;
5791
5792         make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
5793
5794         /* do an initial name resolution to find its IP */
5795         status = resolve_name(&name, mem_ctx, &address, NULL);
5796         if (!NT_STATUS_IS_OK(status)) {
5797                 printf("Failed to resolve %s - %s\n",
5798                        name.name, nt_errstr(status));
5799                 talloc_free(mem_ctx);
5800                 return False;
5801         }
5802
5803         ret &= test_assoc_ctx1(mem_ctx, address);
5804         ret &= test_assoc_ctx2(mem_ctx, address);
5805
5806         talloc_free(mem_ctx);
5807
5808         return ret;
5809 }
5810
5811 /*
5812   test WINS replication operations
5813 */
5814 BOOL torture_nbt_winsreplication(void)
5815 {
5816         const char *address;
5817         struct nbt_name name;
5818         TALLOC_CTX *mem_ctx = talloc_new(NULL);
5819         NTSTATUS status;
5820         BOOL ret = True;
5821         struct test_wrepl_conflict_conn *ctx;
5822
5823         make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
5824
5825         /* do an initial name resolution to find its IP */
5826         status = resolve_name(&name, mem_ctx, &address, NULL);
5827         if (!NT_STATUS_IS_OK(status)) {
5828                 printf("Failed to resolve %s - %s\n",
5829                        name.name, nt_errstr(status));
5830                 talloc_free(mem_ctx);
5831                 return False;
5832         }
5833
5834         ret &= test_assoc_ctx1(mem_ctx, address);
5835         ret &= test_assoc_ctx2(mem_ctx, address);
5836
5837         ret &= test_wins_replication(mem_ctx, address);
5838
5839         ctx = test_create_conflict_ctx(mem_ctx, address);
5840
5841         ret &= test_conflict_same_owner(ctx);
5842         ret &= test_conflict_different_owner(ctx);
5843         ret &= test_conflict_owned_released_vs_replica(ctx);
5844         ret &= test_conflict_owned_active_vs_replica(ctx);
5845
5846         talloc_free(mem_ctx);
5847
5848         return ret;
5849 }