ssu.c revision 15a44745412679c30a6d022733925af70a38b715
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt * Copyright (C) 2000 Internet Software Consortium.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt * Permission to use, copy, modify, and distribute this software for any
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * purpose with or without fee is hereby granted, provided that the above
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * copyright notice and this permission notice appear in all copies.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * $Id: ssu.c,v 1.12 2000/07/27 09:46:37 tale Exp $
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Principal Author: Brian Wellington
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#include <isc/string.h> /* Required for HP/UX (and others?) */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#define VALID_SSUTABLE(table) ISC_MAGIC_VALID((table), SSUTABLEMAGIC)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#define VALID_SSURULE(table) ISC_MAGIC_VALID((table), SSURULEMAGIC)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt isc_boolean_t grant; /* is this a grant or a deny? */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt unsigned int matchtype; /* which type of pattern match? */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt unsigned int ntypes; /* number of data types covered */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt dns_rdatatype_t *types; /* the data types. Can include ANY, */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt /* defaults to all but SIG,SOA,NS if NULL*/
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt unsigned int references;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntdns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **tablep) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt table = isc_mem_get(mctx, sizeof(dns_ssutable_t));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntstatic inline void
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt dns_ssurule_t *rule = ISC_LIST_HEAD(table->rules);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt isc_mem_put(mctx, rule->identity, sizeof(dns_name_t));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt isc_mem_put(mctx, rule->name, sizeof(dns_name_t));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntdns_ssutable_attach(dns_ssutable_t *source, dns_ssutable_t **targetp) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntdns_ssutable_addrule(dns_ssutable_t *table, isc_boolean_t grant,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt rule->identity = isc_mem_get(mctx, sizeof(dns_name_t));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt result = dns_name_dup(identity, mctx, rule->identity);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt rule->name = isc_mem_get(mctx, sizeof(dns_name_t));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt memcpy(rule->types, types, ntypes * sizeof(dns_rdatatype_t));
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt isc_mem_put(mctx, rule->identity, sizeof(dns_name_t));
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt isc_mem_put(mctx, rule->name, sizeof(dns_name_t));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntdns_ssutable_checkrules(dns_ssutable_t *table, dns_name_t *signer,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt unsigned int i;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt REQUIRE(signer == NULL || dns_name_isabsolute(signer));
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if (!dns_name_matcheswildcard(signer, rule->identity))
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt else if (rule->matchtype == DNS_SSUMATCHTYPE_SUBDOMAIN) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt else if (rule->matchtype == DNS_SSUMATCHTYPE_WILDCARD) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt else if (rule->matchtype == DNS_SSUMATCHTYPE_SELF) {
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Huntdns_ssurule_types(const dns_ssurule_t *rule, dns_rdatatype_t **types) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntdns_ssutable_firstrule(const dns_ssutable_t *table, dns_ssurule_t **rule) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt return (*rule != NULL ? ISC_R_SUCCESS : ISC_R_NOMORE);
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntdns_ssutable_nextrule(dns_ssurule_t *rule, dns_ssurule_t **nextrule) {
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt return (*nextrule != NULL ? ISC_R_SUCCESS : ISC_R_NOMORE);