9ab989b88ca3dc6a4f0f52ca450ea5e35242cc85Tinderbox User * Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
6db55b4ff9b099bc8d6621f6e13ec1f087d35e04Mark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
6db55b4ff9b099bc8d6621f6e13ec1f087d35e04Mark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
6db55b4ff9b099bc8d6621f6e13ec1f087d35e04Mark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6db55b4ff9b099bc8d6621f6e13ec1f087d35e04Mark Andrews * Helper functions
6db55b4ff9b099bc8d6621f6e13ec1f087d35e04Mark Andrews atf_tc_set_md_var(tc, "descr", "test that dns_acl_isinsecure works");
6db55b4ff9b099bc8d6621f6e13ec1f087d35e04Mark Andrews result = dns_acl_merge(notnone, none, ISC_FALSE);
6db55b4ff9b099bc8d6621f6e13ec1f087d35e04Mark Andrews result = dns_acl_merge(notany, any, ISC_FALSE);
6db55b4ff9b099bc8d6621f6e13ec1f087d35e04Mark Andrews ATF_CHECK(!dns_acl_isinsecure(none)); /* none; */
6db55b4ff9b099bc8d6621f6e13ec1f087d35e04Mark Andrews ATF_CHECK(!dns_acl_isinsecure(notany)); /* !any; */
6db55b4ff9b099bc8d6621f6e13ec1f087d35e04Mark Andrews ATF_CHECK(!dns_acl_isinsecure(notnone)); /* !none; */
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews for (pass = 0; pass < sizeof(ecs)/sizeof(ecs[0]); pass++) {
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_create(mctx, 1, ¬pos4pos6);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_create(mctx, 1, ¬neg4pos6);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_create(mctx, 1, ¬pos4neg6);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_create(mctx, 1, ¬neg4neg6);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews inaddr.s_addr = htonl(0x0a000000); /* 10.0.0.0 */
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(pos4pos6->iptable, &addr, 8,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(pos4pos6->iptable, &addr, 8,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_merge(notpos4pos6, pos4pos6, ISC_FALSE);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews inaddr.s_addr = htonl(0x0a000000); /* !10.0.0.0/8 */
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(neg4pos6->iptable, &addr, 8,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(neg4pos6->iptable, &addr, 8,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_merge(notneg4pos6, neg4pos6, ISC_FALSE);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews inaddr.s_addr = htonl(0x0a000000); /* 10.0.0.0/8 */
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(pos4neg6->iptable, &addr, 8,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(pos4neg6->iptable, &addr, 8,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_merge(notpos4neg6, pos4neg6, ISC_FALSE);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews inaddr.s_addr = htonl(0x0a000000); /* !10.0.0.0/8 */
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(neg4neg6->iptable, &addr, 8,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(neg4neg6->iptable, &addr, 8,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_merge(notneg4neg6, neg4neg6, ISC_FALSE);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews inaddr.s_addr = htonl(0x7f000001); /* 127.0.0.1 */
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(loop4->iptable, &addr, 32,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_merge(notloop4, loop4, ISC_FALSE);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews isc_netaddr_fromin6(&addr, &in6addr_loopback); /* ::1 */
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(loop6->iptable, &addr, 128,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_merge(notloop6, loop6, ISC_FALSE);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_create(mctx, 1, ¬loop4pos6);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_create(mctx, 1, ¬loop4neg6);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews inaddr.s_addr = htonl(0x7f000001); /* 127.0.0.1 */
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(loop4pos6->iptable, &addr, 32,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(loop4pos6->iptable, &addr, 32,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_merge(notloop4pos6, loop4pos6, ISC_FALSE);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews inaddr.s_addr = htonl(0x7f000001); /* 127.0.0.1 */
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(loop4neg6->iptable, &addr, 32,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_iptable_addprefix2(loop4neg6->iptable, &addr, 32,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews result = dns_acl_merge(notloop4neg6, loop4neg6, ISC_FALSE);
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews } else if (ecs[pass].first && !ecs[pass].second) {
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews } else if (!ecs[pass].first && ecs[pass].second) {