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