soa_6.h revision 26b0f58b6c4d65bc8b131debf40b8c376c2978bf
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff/*
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * Copyright (C) 1998 Internet Software Consortium.
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff *
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * Permission to use, copy, modify, and distribute this software for any
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * purpose with or without fee is hereby granted, provided that the above
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * copyright notice and this permission notice appear in all copies.
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff *
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff * SOFTWARE.
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff */
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff /* $Id: soa_6.h,v 1.5 1999/01/20 02:41:11 halley Exp $ */
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff#ifndef RDATA_GENERIC_SOA_6_H
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff#define RDATA_GENERIC_SOA_6_H
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffstatic dns_result_t
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Grafffromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type,
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_lex_t *lexer, dns_name_t *origin,
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_boolean_t downcase, isc_buffer_t *target) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_token_t token;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_t name;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_buffer_t buffer;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_result_t result;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff int i;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff INSIST(type == 6);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff class = class; /*unused*/
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_UNKNOWN);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (token.type != isc_tokentype_string)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_UNKNOWN);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&name, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff buffer_fromregion(&buffer, &token.value.as_region,
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff ISC_BUFFERTYPE_TEXT);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff origin = (origin != NULL) ? origin : dns_rootname;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = dns_name_fromtext(&name, &buffer, origin, downcase, target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != DNS_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_UNKNOWN);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (token.type != isc_tokentype_string)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_UNKNOWN);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff dns_name_init(&name, NULL);
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff buffer_fromregion(&buffer, &token.value.as_region,
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff ISC_BUFFERTYPE_TEXT);
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff origin = (origin != NULL) ? origin : dns_rootname;
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff result = dns_name_fromtext(&name, &buffer, origin, downcase, target);
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff if (result != DNS_R_SUCCESS)
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff return (result);
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff for (i = 0; i < 5; i++) {
db4871e8437dd0067614b4dfd9183cab3425e836Michael Graff if (isc_lex_gettoken(lexer, ISC_LEXOPT_NUMBER, &token)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff != ISC_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_UNKNOWN);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (token.type != isc_tokentype_number)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_UNKNOWN);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = uint32_fromtext(token.value.as_ulong, target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != DNS_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff }
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_SUCCESS);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff}
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffstatic dns_result_t
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Grafftotext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_t dregion;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_t mname;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_t rname;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_t prefix;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_result_t result;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_boolean_t sub;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff int i;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff INSIST(rdata->type == 6);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&mname, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&rname, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&prefix, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_rdata_toregion(rdata, &dregion);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_fromregion(&mname, &dregion);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_consume(&dregion, name_length(&mname));
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_fromregion(&rname, &dregion);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_consume(&dregion, name_length(&rname));
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff sub = name_prefix(&mname, origin, &prefix);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = dns_name_totext(&prefix, sub, target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != DNS_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = str_totext(" ", target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != DNS_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff sub = name_prefix(&rname, origin, &prefix);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = dns_name_totext(&prefix, sub, target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != DNS_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff for (i = 0; i < 5 ; i++) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff char buf[sizeof "2147483647"];
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff unsigned long num;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = str_totext(" ", target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != DNS_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff num = uint32_fromregion(&dregion);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_consume(&dregion, 4);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff sprintf(buf, "%lu", num);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = str_totext(buf, target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != DNS_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff }
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_SUCCESS);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff}
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffstatic dns_result_t
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Grafffromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type,
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_buffer_t *source, dns_decompress_t *dctx,
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_boolean_t downcase, isc_buffer_t *target) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_t mname;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_t rname;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_result_t result;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_t sregion;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_t tregion;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff INSIST(type == 6);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff class = class; /*unused*/
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&mname, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&rname, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = dns_name_fromwire(&mname, source, dctx, downcase, target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != DNS_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = dns_name_fromwire(&rname, source, dctx, downcase, target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != DNS_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_buffer_active(source, &sregion);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_buffer_available(target, &tregion);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (sregion.length != 20)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_WIRE);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (tregion.length < 20)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_NOSPACE);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff memcpy(tregion.base, sregion.base, 20);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_buffer_forward(source, 20);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_buffer_add(target, 20);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_SUCCESS);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff}
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffstatic dns_result_t
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Grafftowire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_t sregion;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_t tregion;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_t mname;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_t rname;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_result_t result;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff INSIST(rdata->type == 6);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&mname, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&rname, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_rdata_toregion(rdata, &sregion);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_fromregion(&mname, &sregion);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_consume(&sregion, name_length(&mname));
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = dns_name_towire(&mname, cctx, target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != DNS_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_fromregion(&rname, &sregion);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_consume(&sregion, name_length(&rname));
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = dns_name_towire(&rname, cctx, target);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != DNS_R_SUCCESS)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_buffer_available(target, &tregion);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (tregion.length < 20)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_NOSPACE);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff memcpy(tregion.base, sregion.base, 20);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_buffer_add(target, 20);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_SUCCESS);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff}
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffstatic int
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffcompare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_t region1;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_t region2;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_t name1;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_t name2;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff int result;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff INSIST(rdata1->type == rdata2->type);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff INSIST(rdata1->class == rdata2->class);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff INSIST(rdata1->type == 6);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&name1, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&name2, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_rdata_toregion(rdata1, &region1);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_rdata_toregion(rdata2, &region1);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_fromregion(&name1, &region1);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_fromregion(&name2, &region2);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = dns_name_compare(&name1, &name2);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != 0)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_consume(&region1, name1.length);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_consume(&region2, name2.length);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&name1, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_init(&name2, NULL);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_fromregion(&name1, &region1);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff dns_name_fromregion(&name2, &region2);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = dns_name_compare(&name1, &name2);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != 0)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (result);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_consume(&region1, name1.length);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_region_consume(&region2, name2.length);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff result = memcmp(region1.base, region2.base, 12);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if (result != 0)
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return ((result < 0) ? -1 : 1);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (0);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff}
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffstatic dns_result_t
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Grafffromstruct_soa(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff isc_buffer_t *target) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff INSIST(type == 6);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff class = class; /*unused*/
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff source = source;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff target = target;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff return (DNS_R_NOTIMPLEMENTED);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff}
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffstatic dns_result_t
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Grafftostruct_soa(dns_rdata_t *rdata, void *target) {
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff INSIST(rdata->type == 6);
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif /* RDATA_GENERIC_SOA_6_H */