conflsn.c revision 499b34cea04a46823d003d4c0520c8b03e8513cb
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews/*
9a006fe9a05abc03c0e81977802194dab8737206Tinderbox User * Copyright (C) 1999-2001 Internet Software Consortium.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews *
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * copyright notice and this permission notice appear in all copies.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews *
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews/* $Id: conflsn.c,v 1.19 2001/01/09 21:52:00 bwelling Exp $ */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#include <config.h>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#include <isc/mem.h>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#include <isc/util.h>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#include <dns/conflsn.h>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#include <dns/log.h>
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#include "confpvt.h"
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsisc_result_t
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsdns_c_lstnon_new(isc_mem_t *mem, dns_c_lstnon_t **listen) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_lstnon_t *ll;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews isc_result_t result;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(listen != NULL);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews *listen = NULL;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ll = isc_mem_get(mem, sizeof *ll);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ll->mem = mem;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ll->port = 0;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ll->magic = DNS_C_LISTEN_MAGIC;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews result = dns_c_ipmatchlist_new(mem, &ll->iml);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if (result != ISC_R_SUCCESS) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews isc_mem_put(mem, ll, sizeof *ll);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (result);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ISC_LINK_INIT(ll, next);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater *listen = ll;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_SUCCESS);
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsisc_result_t
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updaterdns_c_lstnon_delete(dns_c_lstnon_t **listen) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_lstnon_t *lo;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews isc_result_t r;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater REQUIRE(listen != NULL);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(DNS_C_LISTEN_VALID(*listen));
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lo = *listen;
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if (lo->iml != NULL) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews r = dns_c_ipmatchlist_detach(&lo->iml);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews } else {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews r = ISC_R_SUCCESS;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lo->magic = 0;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews isc_mem_put(lo->mem, lo, sizeof *lo);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews *listen = NULL;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (r);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsisc_result_t
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updaterdns_c_lstnon_setiml(dns_c_lstnon_t *listen,
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater dns_c_ipmatchlist_t *iml, isc_boolean_t deepcopy)
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews{
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater isc_result_t result;
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater REQUIRE(DNS_C_LISTEN_VALID(listen));
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(DNS_C_IPMLIST_VALID(iml));
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater if (listen->iml != NULL) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews result = dns_c_ipmatchlist_detach(&listen->iml);
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater if (result != ISC_R_SUCCESS) {
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater return (result);
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews } else {
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater result = ISC_R_SUCCESS;
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater }
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater if (deepcopy) {
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater result = dns_c_ipmatchlist_copy(listen->mem,
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater &listen->iml, iml);
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater } else {
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater listen->iml = iml;
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater }
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater return (result);
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater}
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updaterisc_result_t
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsdns_c_lstnlist_new(isc_mem_t *mem, dns_c_lstnlist_t **llist) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_lstnlist_t *ll;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(llist != NULL);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews *llist = NULL;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ll = isc_mem_get(mem, sizeof *ll);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if (ll == NULL) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews /* XXXJAB logwrite */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_NOMEMORY);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ll->mem = mem;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ll->magic = DNS_C_LLIST_MAGIC;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ISC_LIST_INIT(ll->elements);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews *llist = ll;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_SUCCESS);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsisc_result_t
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsdns_c_lstnlist_delete(dns_c_lstnlist_t **llist) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_lstnlist_t *ll;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_lstnon_t *lo, *lotmp;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews isc_result_t r;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
420a43c8d8028992a4e9c170022f97bfac689025Evan Hunt REQUIRE(llist != NULL);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(DNS_C_LISTENLIST_VALID(*llist));
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ll = *llist;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lo = ISC_LIST_HEAD(ll->elements);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews while (lo != NULL) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lotmp = ISC_LIST_NEXT(lo, next);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ISC_LIST_UNLINK(ll->elements, lo, next);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews r = dns_c_lstnon_delete(&lo);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if (r != ISC_R_SUCCESS) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (r);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lo = lotmp;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ll->magic = 0;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews isc_mem_put(ll->mem, ll, sizeof *ll);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews *llist = NULL;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_SUCCESS);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsisc_result_t
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsdns_c_lstnlist_print(FILE *fp, int indent, dns_c_lstnlist_t *ll,
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt in_port_t default_port)
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt{
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_lstnon_t *lo;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(DNS_C_LISTENLIST_VALID(ll));
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lo = ISC_LIST_HEAD(ll->elements);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews while (lo != NULL) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_printtabs(fp, indent);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_lstnon_print(fp, indent, lo, default_port);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lo = ISC_LIST_NEXT(lo, next);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews fprintf(fp, "\n");
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_SUCCESS);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews}
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsisc_result_t
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsdns_c_lstnlistv6_print(FILE *fp, int indent, dns_c_lstnlist_t *ll,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews in_port_t default_port)
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews{
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_lstnon_t *lo;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(DNS_C_LISTENLIST_VALID(ll));
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lo = ISC_LIST_HEAD(ll->elements);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews while (lo != NULL) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_printtabs(fp, indent);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_lstnonv6_print(fp, indent, lo, default_port);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lo = ISC_LIST_NEXT(lo, next);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews fprintf(fp, "\n");
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_SUCCESS);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsisc_result_t
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsdns_c_lstnon_print(FILE *fp, int indent, dns_c_lstnon_t *lo,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews in_port_t default_port) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(lo != NULL);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(DNS_C_LISTEN_VALID(lo));
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews fprintf(fp, "listen-on ");
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if (lo->port != default_port) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews fprintf(fp, "port %d ", lo->port);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_ipmatchlist_print(fp, indent + 1, lo->iml);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews fprintf(fp, ";\n");
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_SUCCESS);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsisc_result_t
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsdns_c_lstnonv6_print(FILE *fp, int indent, dns_c_lstnon_t *lo,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews in_port_t default_port) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(lo != NULL);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(DNS_C_LISTEN_VALID(lo));
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews fprintf(fp, "listen-on-v6 ");
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if (lo->port != default_port) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews fprintf(fp, "port %d ", lo->port);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_ipmatchlist_print(fp, indent + 1, lo->iml);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews fprintf(fp, ";\n");
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_SUCCESS);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#if 0
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updaterstatic isc_boolean_t
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewschecklisten_element(dns_c_ipmatchelement_t *element)
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews{
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater int pf;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews isc_boolean_t ok = ISC_FALSE;
bf216589c1a81e4431653a145b252b6ce367d7cdMark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews switch (element->type) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_pattern:
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater pf = isc_sockaddr_pf(&element->u.direct.address);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ok = ISC_TF(pf == AF_INET);
bf216589c1a81e4431653a145b252b6ce367d7cdMark Andrews break;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater case dns_c_ipmatch_key:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_localhost:
bf216589c1a81e4431653a145b252b6ce367d7cdMark Andrews case dns_c_ipmatch_localnets:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ok = ISC_FALSE;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews break;
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_any:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_none:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ok = ISC_TRUE;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews break;
6a1a8186afb298c87b3e5ae3fbbda95ea94f6bbdMark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_indirect:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews /* XXX shouldn't be reached */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews break;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_acl:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews /* XXX handle this. */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews break;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ok);
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsstatic isc_boolean_t
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updatercheckv6listen_element(dns_c_ipmatchelement_t *element)
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews{
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews int pf;
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater isc_boolean_t ok = ISC_FALSE;
bf216589c1a81e4431653a145b252b6ce367d7cdMark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews switch (element->type) {
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater case dns_c_ipmatch_pattern:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews pf = isc_sockaddr_pf(&element->u.direct.address);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ok = ISC_TF(pf == AF_INET6);
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater break;
6a1a8186afb298c87b3e5ae3fbbda95ea94f6bbdMark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_key:
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater case dns_c_ipmatch_localhost:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_localnets:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ok = ISC_FALSE;
ddad35552931651426ad70912d29d9ab7d2a8d80Automatic Updater break;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_any:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_none:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews ok = ISC_TRUE;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews break;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_indirect:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews /* XXX shouldn't be reached */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews break;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews case dns_c_ipmatch_acl:
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews /* XXX handle this. */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews break;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ok);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#endif
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews/*
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews * Post confirguation load validation of list-on lists.
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews */
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrewsisc_result_t
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrewsdns_c_lstnlist_validate(dns_c_lstnlist_t *ll)
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews{
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews#if 0
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews dns_c_lstnon_t *lo;
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews isc_boolean_t checkval;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(DNS_C_LISTENLIST_VALID(ll));
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews lo = ISC_LIST_HEAD(ll->elements);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews while (lo != NULL) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews checkval = dns_c_ipmatchlist_walk(lo->iml,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews checklisten_element);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if (!checkval) {
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews isc_log_write(dns_lctx,DNS_LOGCATEGORY_CONFIG,
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews DNS_LOGMODULE_CONFIG, ISC_LOG_ERROR,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews "listen-on must have IPv4 "
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews "addresses only.");
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_FAILURE);
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lo = ISC_LIST_NEXT(lo, next);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews return (ISC_R_SUCCESS);
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#else
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews UNUSED(ll);
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark Andrews return (ISC_R_SUCCESS);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#endif
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsisc_result_t
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsdns_c_lstnlistv6_validate(dns_c_lstnlist_t *ll)
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews{
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#if 0
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews dns_c_lstnon_t *lo;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews isc_boolean_t checkval;
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews REQUIRE(DNS_C_LISTENLIST_VALID(ll));
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lo = ISC_LIST_HEAD(ll->elements);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews while (lo != NULL) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews checkval = dns_c_ipmatchlist_walk(lo->iml,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews checkv6listen_element);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews if (!checkval) {
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews isc_log_write(dns_lctx,DNS_LOGCATEGORY_CONFIG,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews DNS_LOGMODULE_CONFIG, ISC_LOG_ERROR,
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews "listen-on-v6 must have IPv6 "
af669cb4fd7ecfb67ed145b176e5e764b249573bMark Andrews "addresses only.");
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_FAILURE);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews lo = ISC_LIST_NEXT(lo, next);
d97637ce117b4a99492926217a78edd8e134a2daMark Andrews }
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_SUCCESS);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#else
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews UNUSED(ll);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews return (ISC_R_SUCCESS);
d97637ce117b4a99492926217a78edd8e134a2daMark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews#endif
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews}
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews