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