diff options
author | Tomek Mrugalski <tomasz@isc.org> | 2012-08-14 15:20:46 +0200 |
---|---|---|
committer | Tomek Mrugalski <tomasz@isc.org> | 2012-08-14 15:20:46 +0200 |
commit | 85c8df6dd08d48a4bab5fdec6ea71c70e9bd9dc2 (patch) | |
tree | ab009f3af64ad0e0dcd1c546e0b7ae277cfe26dd /server/mdb6.c | |
parent | a0497ac5ac9b787edebceaecb29da0c4e5e0b320 (diff) | |
parent | 0b483f01af4288c4be28ee06ba254435c954716e (diff) | |
download | isc-dhcp-85c8df6dd08d48a4bab5fdec6ea71c70e9bd9dc2.tar.gz |
[master] Merge branch 'rt25901_atf'
Conflicts:
configure
Diffstat (limited to 'server/mdb6.c')
-rw-r--r-- | server/mdb6.c | 669 |
1 files changed, 5 insertions, 664 deletions
diff --git a/server/mdb6.c b/server/mdb6.c index f82e301d..7b888c23 100644 --- a/server/mdb6.c +++ b/server/mdb6.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2012 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2007-2011 by Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -372,6 +372,8 @@ void ia_remove_iasubopt(struct ia_xx *ia, struct iasubopt *iasubopt, const char *file, int line) { int i, j; + if (ia == NULL || iasubopt == NULL) + return; for (i=0; i<ia->num_iasubopt; i++) { if (ia->iasubopt[i] == iasubopt) { @@ -1385,7 +1387,7 @@ release_lease6(struct ipv6_pool *pool, struct iasubopt *lease) { * Create a prefix by hashing the input, and using that for * the part subject to allocation. */ -static void +void build_prefix6(struct in6_addr *pref, const struct in6_addr *net_start_pref, int pool_bits, int pref_bits, @@ -2120,665 +2122,4 @@ mark_interfaces_unavailable(void) { } } - -#ifdef UNIT_TEST -#include <stdlib.h> - -int -main(int argc, char *argv[]) { - struct iasubopt *iaaddr; - struct iasubopt *iaaddr_copy; - u_int32_t iaid; - struct ia_xx *ia_na; - struct ia_xx *ia_na_copy; - int i; - struct in6_addr addr; - struct ipv6_pool *pool; - struct ipv6_pool *pool_copy; - char addr_buf[INET6_ADDRSTRLEN]; - char *uid; - struct data_string ds; - struct iasubopt *expired_iaaddr; - unsigned int attempts; - - /* - * Test 0: Basic iaaddr manipulation. - */ - iaaddr = NULL; - if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); - return 1; - } - if (iaaddr->state != FTS_FREE) { - printf("ERROR: bad state %s:%d\n", MDL); - return 1; - } - if (iaaddr->heap_index != -1) { - printf("ERROR: bad heap_index %s:%d\n", MDL); - return 1; - } - iaaddr_copy = NULL; - if (iasubopt_reference(&iaaddr_copy, iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_reference() %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_reference() %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&iaaddr_copy, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_reference() %s:%d\n", MDL); - return 1; - } - - /* - * Test 1: Error iaaddr manipulation. - */ - /* bogus allocate arguments */ - if (iasubopt_allocate(NULL, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); - return 1; - } - iaaddr = (struct iasubopt *)1; - if (iasubopt_allocate(&iaaddr, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); - return 1; - } - - /* bogus reference arguments */ - iaaddr = NULL; - if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); - return 1; - } - if (iasubopt_reference(NULL, iaaddr, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: iasubopt_reference() %s:%d\n", MDL); - return 1; - } - iaaddr_copy = (struct iasubopt *)1; - if (iasubopt_reference(&iaaddr_copy, iaaddr, - MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: iasubopt_reference() %s:%d\n", MDL); - return 1; - } - iaaddr_copy = NULL; - if (iasubopt_reference(&iaaddr_copy, NULL, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: iasubopt_reference() %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_reference() %s:%d\n", MDL); - return 1; - } - - /* bogus dereference arguments */ - if (iasubopt_dereference(NULL, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); - return 1; - } - iaaddr = NULL; - if (iasubopt_dereference(&iaaddr, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); - return 1; - } - - /* - * Test 2: Basic ia_na manipulation. - */ - iaid = 666; - ia_na = NULL; - if (ia_allocate(&ia_na, iaid, "TestDUID", 8, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_allocate() %s:%d\n", MDL); - return 1; - } - if (memcmp(ia_na->iaid_duid.data, &iaid, sizeof(iaid)) != 0) { - printf("ERROR: bad IAID_DUID %s:%d\n", MDL); - return 1; - } - if (memcmp(ia_na->iaid_duid.data+sizeof(iaid), "TestDUID", 8) != 0) { - printf("ERROR: bad IAID_DUID %s:%d\n", MDL); - return 1; - } - if (ia_na->num_iasubopt != 0) { - printf("ERROR: bad num_iasubopt %s:%d\n", MDL); - return 1; - } - ia_na_copy = NULL; - if (ia_reference(&ia_na_copy, ia_na, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_reference() %s:%d\n", MDL); - return 1; - } - iaaddr = NULL; - if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); - return 1; - } - if (ia_add_iasubopt(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_add_iasubopt() %s:%d\n", MDL); - return 1; - } - ia_remove_iasubopt(ia_na, iaaddr, MDL); - if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_reference() %s:%d\n", MDL); - return 1; - } - if (ia_dereference(&ia_na, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_dereference() %s:%d\n", MDL); - return 1; - } - if (ia_dereference(&ia_na_copy, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_dereference() %s:%d\n", MDL); - return 1; - } - - /* - * Test 3: lots of iaaddr in our ia_na - */ - - /* lots of iaaddr that we delete */ - iaid = 666; - ia_na = NULL; - if (ia_allocate(&ia_na, iaid, "TestDUID", 8, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_allocate() %s:%d\n", MDL); - return 1; - } - for (i=0; i<100; i++) { - iaaddr = NULL; - if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); - return 1; - } - if (ia_add_iasubopt(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_add_iasubopt() %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_reference() %s:%d\n", MDL); - return 1; - } - } - for (i=0; i<100; i++) { - iaaddr = ia_na->iasubopt[random() % ia_na->num_iasubopt]; - ia_remove_iasubopt(ia_na, iaaddr, MDL); - } - if (ia_dereference(&ia_na, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_dereference() %s:%d\n", MDL); - return 1; - } - - /* lots of iaaddr, let dereference cleanup */ - iaid = 666; - ia_na = NULL; - if (ia_allocate(&ia_na, iaid, "TestDUID", 8, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_allocate() %s:%d\n", MDL); - return 1; - } - for (i=0; i<100; i++) { - iaaddr = NULL; - if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); - return 1; - } - if (ia_add_iasubopt(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_add_iasubopt() %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_reference() %s:%d\n", MDL); - return 1; - } - } - if (ia_dereference(&ia_na, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_dereference() %s:%d\n", MDL); - return 1; - } - - /* - * Test 4: Errors in ia_na. - */ - /* bogus allocate arguments */ - if (ia_allocate(NULL, 123, "", 0, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ia_allocate() %s:%d\n", MDL); - return 1; - } - ia_na = (struct ia_na *)1; - if (ia_allocate(&ia_na, 456, "", 0, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ia_allocate() %s:%d\n", MDL); - return 1; - } - - /* bogus reference arguments */ - iaid = 666; - ia_na = NULL; - if (ia_allocate(&ia_na, iaid, "TestDUID", 8, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_allocate() %s:%d\n", MDL); - return 1; - } - if (ia_reference(NULL, ia_na, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ia_reference() %s:%d\n", MDL); - return 1; - } - ia_na_copy = (struct ia_na *)1; - if (ia_reference(&ia_na_copy, ia_na, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ia_reference() %s:%d\n", MDL); - return 1; - } - ia_na_copy = NULL; - if (ia_reference(&ia_na_copy, NULL, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ia_reference() %s:%d\n", MDL); - return 1; - } - if (ia_dereference(&ia_na, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_dereference() %s:%d\n", MDL); - return 1; - } - - /* bogus dereference arguments */ - if (ia_dereference(NULL, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ia_dereference() %s:%d\n", MDL); - return 1; - } - - /* bogus remove */ - iaid = 666; - ia_na = NULL; - if (ia_allocate(&ia_na, iaid, "TestDUID", 8, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_allocate() %s:%d\n", MDL); - return 1; - } - ia_remove_iasubopt(ia_na, NULL, MDL); - if (ia_dereference(&ia_na, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_dereference() %s:%d\n", MDL); - return 1; - } - - /* - * Test 5: Basic ipv6_pool manipulation. - */ - - /* allocate, reference */ - inet_pton(AF_INET6, "1:2:3:4::", &addr); - pool = NULL; - if (ipv6_pool_allocate(&pool, 0, &addr, 64, 128, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_allocate() %s:%d\n", MDL); - return 1; - } - if (pool->num_active != 0) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - if (pool->bits != 64) { - printf("ERROR: bad bits %s:%d\n", MDL); - return 1; - } - inet_ntop(AF_INET6, &pool->start_addr, addr_buf, sizeof(addr_buf)); - if (strcmp(inet_ntop(AF_INET6, &pool->start_addr, addr_buf, - sizeof(addr_buf)), "1:2:3:4::") != 0) { - printf("ERROR: bad start_addr %s:%d\n", MDL); - return 1; - } - pool_copy = NULL; - if (ipv6_pool_reference(&pool_copy, pool, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_reference() %s:%d\n", MDL); - return 1; - } - - /* create_lease6, renew_lease6, expire_lease6 */ - uid = "client0"; - memset(&ds, 0, sizeof(ds)); - ds.len = strlen(uid); - if (!buffer_allocate(&ds.buffer, ds.len, MDL)) { - printf("Out of memory\n"); - return 1; - } - ds.data = ds.buffer->data; - memcpy((char *)ds.data, uid, ds.len); - if (create_lease6(pool, &iaaddr, - &attempts, &ds, 1) != ISC_R_SUCCESS) { - printf("ERROR: create_lease6() %s:%d\n", MDL); - return 1; - } - if (pool->num_inactive != 1) { - printf("ERROR: bad num_inactive %s:%d\n", MDL); - return 1; - } - if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { - printf("ERROR: renew_lease6() %s:%d\n", MDL); - return 1; - } - if (pool->num_active != 1) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - expired_iaaddr = NULL; - if (expire_lease6(&expired_iaaddr, pool, 0) != ISC_R_SUCCESS) { - printf("ERROR: expire_lease6() %s:%d\n", MDL); - return 1; - } - if (expired_iaaddr != NULL) { - printf("ERROR: should not have expired a lease %s:%d\n", MDL); - return 1; - } - if (pool->num_active != 1) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - if (expire_lease6(&expired_iaaddr, pool, 1000) != ISC_R_SUCCESS) { - printf("ERROR: expire_lease6() %s:%d\n", MDL); - return 1; - } - if (expired_iaaddr == NULL) { - printf("ERROR: should have expired a lease %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&expired_iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); - return 1; - } - if (pool->num_active != 0) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); - return 1; - } - - /* release_lease6, decline_lease6 */ - if (create_lease6(pool, &iaaddr, &attempts, - &ds, 1) != ISC_R_SUCCESS) { - printf("ERROR: create_lease6() %s:%d\n", MDL); - return 1; - } - if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { - printf("ERROR: renew_lease6() %s:%d\n", MDL); - return 1; - } - if (pool->num_active != 1) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - if (release_lease6(pool, iaaddr) != ISC_R_SUCCESS) { - printf("ERROR: decline_lease6() %s:%d\n", MDL); - return 1; - } - if (pool->num_active != 0) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); - return 1; - } - if (create_lease6(pool, &iaaddr, &attempts, - &ds, 1) != ISC_R_SUCCESS) { - printf("ERROR: create_lease6() %s:%d\n", MDL); - return 1; - } - if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { - printf("ERROR: renew_lease6() %s:%d\n", MDL); - return 1; - } - if (pool->num_active != 1) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - if (decline_lease6(pool, iaaddr) != ISC_R_SUCCESS) { - printf("ERROR: decline_lease6() %s:%d\n", MDL); - return 1; - } - if (pool->num_active != 1) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); - return 1; - } - - /* dereference */ - if (ipv6_pool_dereference(&pool, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_reference() %s:%d\n", MDL); - return 1; - } - if (ipv6_pool_dereference(&pool_copy, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_reference() %s:%d\n", MDL); - return 1; - } - - /* - * Test 6: Error ipv6_pool manipulation - */ - if (ipv6_pool_allocate(NULL, 0, &addr, - 64, 128, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ipv6_pool_allocate() %s:%d\n", MDL); - return 1; - } - pool = (struct ipv6_pool *)1; - if (ipv6_pool_allocate(&pool, 0, &addr, - 64, 128, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ipv6_pool_allocate() %s:%d\n", MDL); - return 1; - } - if (ipv6_pool_reference(NULL, pool, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ipv6_pool_reference() %s:%d\n", MDL); - return 1; - } - pool_copy = (struct ipv6_pool *)1; - if (ipv6_pool_reference(&pool_copy, pool, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ipv6_pool_reference() %s:%d\n", MDL); - return 1; - } - pool_copy = NULL; - if (ipv6_pool_reference(&pool_copy, NULL, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ipv6_pool_reference() %s:%d\n", MDL); - return 1; - } - if (ipv6_pool_dereference(NULL, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ipv6_pool_dereference() %s:%d\n", MDL); - return 1; - } - if (ipv6_pool_dereference(&pool_copy, MDL) != DHCP_R_INVALIDARG) { - printf("ERROR: ipv6_pool_dereference() %s:%d\n", MDL); - return 1; - } - - /* - * Test 7: order of expiration - */ - pool = NULL; - if (ipv6_pool_allocate(&pool, 0, &addr, 64, 128, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_allocate() %s:%d\n", MDL); - return 1; - } - for (i=10; i<100; i+=10) { - if (create_lease6(pool, &iaaddr, &attempts, - &ds, i) != ISC_R_SUCCESS) { - printf("ERROR: create_lease6() %s:%d\n", MDL); - return 1; - } - if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { - printf("ERROR: renew_lease6() %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); - return 1; - } - if (pool->num_active != (i / 10)) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - } - if (pool->num_active != 9) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - for (i=10; i<100; i+=10) { - if (expire_lease6(&expired_iaaddr, - pool, 1000) != ISC_R_SUCCESS) { - printf("ERROR: expire_lease6() %s:%d\n", MDL); - return 1; - } - if (expired_iaaddr == NULL) { - printf("ERROR: should have expired a lease %s:%d\n", - MDL); - return 1; - } - if (pool->num_active != (9 - (i / 10))) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - if (expired_iaaddr->hard_lifetime_end_time != i) { - printf("ERROR: bad hard_lifetime_end_time %s:%d\n", - MDL); - return 1; - } - if (iasubopt_dereference(&expired_iaaddr, MDL) != - ISC_R_SUCCESS) { - printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); - return 1; - } - } - if (pool->num_active != 0) { - printf("ERROR: bad num_active %s:%d\n", MDL); - return 1; - } - expired_iaaddr = NULL; - if (expire_lease6(&expired_iaaddr, pool, 1000) != ISC_R_SUCCESS) { - printf("ERROR: expire_lease6() %s:%d\n", MDL); - return 1; - } - if (ipv6_pool_dereference(&pool, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_dereference() %s:%d\n", MDL); - return 1; - } - - /* - * Test 8: small pool - */ - pool = NULL; - addr.s6_addr[14] = 0x81; - if (ipv6_pool_allocate(&pool, 0, &addr, 127, 128, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_allocate() %s:%d\n", MDL); - return 1; - } - if (create_lease6(pool, &iaaddr, &attempts, - &ds, 42) != ISC_R_SUCCESS) { - printf("ERROR: create_lease6() %s:%d\n", MDL); - return 1; - } - if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { - printf("ERROR: renew_lease6() %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); - return 1; - } - if (create_lease6(pool, &iaaddr, &attempts, - &ds, 11) != ISC_R_SUCCESS) { - printf("ERROR: create_lease6() %s:%d\n", MDL); - return 1; - } - if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { - printf("ERROR: renew_lease6() %s:%d\n", MDL); - return 1; - } - if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); - return 1; - } - if (create_lease6(pool, &iaaddr, &attempts, - &ds, 11) != ISC_R_NORESOURCES) { - printf("ERROR: create_lease6() %s:%d\n", MDL); - return 1; - } - if (ipv6_pool_dereference(&pool, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_dereference() %s:%d\n", MDL); - return 1; - } - addr.s6_addr[14] = 0; - - /* - * Test 9: functions across all pools - */ - pool = NULL; - if (ipv6_pool_allocate(&pool, 0, &addr, 64, 128, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_allocate() %s:%d\n", MDL); - return 1; - } - if (add_ipv6_pool(pool) != ISC_R_SUCCESS) { - printf("ERROR: add_ipv6_pool() %s:%d\n", MDL); - return 1; - } - if (ipv6_pool_dereference(&pool, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_dereference() %s:%d\n", MDL); - return 1; - } - pool = NULL; - if (find_ipv6_pool(&pool, 0, &addr) != ISC_R_SUCCESS) { - printf("ERROR: find_ipv6_pool() %s:%d\n", MDL); - return 1; - } - if (ipv6_pool_dereference(&pool, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_dereference() %s:%d\n", MDL); - return 1; - } - inet_pton(AF_INET6, "1:2:3:4:ffff:ffff:ffff:ffff", &addr); - pool = NULL; - if (find_ipv6_pool(&pool, 0, &addr) != ISC_R_SUCCESS) { - printf("ERROR: find_ipv6_pool() %s:%d\n", MDL); - return 1; - } - if (ipv6_pool_dereference(&pool, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ipv6_pool_dereference() %s:%d\n", MDL); - return 1; - } - inet_pton(AF_INET6, "1:2:3:5::", &addr); - pool = NULL; - if (find_ipv6_pool(&pool, 0, &addr) != ISC_R_NOTFOUND) { - printf("ERROR: find_ipv6_pool() %s:%d\n", MDL); - return 1; - } - inet_pton(AF_INET6, "1:2:3:3:ffff:ffff:ffff:ffff", &addr); - pool = NULL; - if (find_ipv6_pool(&pool, 0, &addr) != ISC_R_NOTFOUND) { - printf("ERROR: find_ipv6_pool() %s:%d\n", MDL); - return 1; - } - -/* iaid = 666; - ia_na = NULL; - if (ia_allocate(&ia_na, iaid, "TestDUID", 8, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_allocate() %s:%d\n", MDL); - return 1; - }*/ - - { - struct in6_addr r; - struct data_string ds; - u_char data[16]; - char buf[64]; - int i, j; - - memset(&ds, 0, sizeof(ds)); - memset(data, 0xaa, sizeof(data)); - ds.len = 16; - ds.data = data; - - inet_pton(AF_INET6, "3ffe:501:ffff:100::", &addr); - for (i = 32; i < 42; i++) - for (j = i + 1; j < 49; j++) { - memset(&r, 0, sizeof(r)); - memset(buf, 0, 64); - build_prefix6(&r, &addr, i, j, &ds); - inet_ntop(AF_INET6, &r, buf, 64); - printf("%d,%d-> %s/%d\n", i, j, buf, j); - } - } - - printf("SUCCESS: all tests passed (ignore any warning messages)\n"); - return 0; -} -#endif +/* unittest moved to server/tests/mdb6_unittest.c */ |