unspec_103.c revision e14969d29389da21783a18d58c207266a94bb538
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews/*
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 1999, 2000 Internet Software Consortium.
2bef3713093349af52ba61eaab07adf3207da873Mark 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.
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews *
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt * SOFTWARE.
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt */
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt/* $Id: unspec_103.c,v 1.19 2000/05/13 22:39:03 tale Exp $ */
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt#ifndef RDATA_GENERIC_UNSPEC_103_C
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt#define RDATA_GENERIC_UNSPEC_103_C
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt#define RRTYPE_UNSPEC_ATTRIBUTES (0)
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
de7df3e56fe99c33a415674b018aae93eee94750Evan Huntstatic inline isc_result_t
2bef3713093349af52ba61eaab07adf3207da873Mark Andrewsfromtext_unspec(dns_rdataclass_t rdclass, dns_rdatatype_t type,
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews isc_lex_t *lexer, dns_name_t *origin,
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt isc_boolean_t downcase, isc_buffer_t *target)
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews{
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews REQUIRE(type == 103);
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews UNUSED(rdclass);
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews UNUSED(origin);
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews UNUSED(downcase);
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews return (atob_tobuffer(lexer, target));
761d135ed686601f36fe3d0d4aaa6bf41287bb0fEvan Hunt}
802e0662ef6041078cb7bad4cdb197a295eab770Mark Andrews
761d135ed686601f36fe3d0d4aaa6bf41287bb0fEvan Huntstatic inline isc_result_t
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunttotext_unspec(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt isc_buffer_t *target)
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt{
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt REQUIRE(rdata->type == 103);
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt UNUSED(tctx);
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt return (btoa_totext(rdata->data, rdata->length, target));
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews}
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews
2bef3713093349af52ba61eaab07adf3207da873Mark Andrewsstatic inline isc_result_t
2bef3713093349af52ba61eaab07adf3207da873Mark Andrewsfromwire_unspec(dns_rdataclass_t rdclass, dns_rdatatype_t type,
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews isc_buffer_t *source, dns_decompress_t *dctx,
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews isc_boolean_t downcase, isc_buffer_t *target)
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews{
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews isc_region_t sr;
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews REQUIRE(type == 103);
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews UNUSED(rdclass);
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews UNUSED(dctx);
2a184ff86544cc67c36e2ce6bb3ddb5ac44684b8Evan Hunt UNUSED(downcase);
498b0610312364afc5698b2e4caaa4dcc836133aEvan Hunt
498b0610312364afc5698b2e4caaa4dcc836133aEvan Hunt isc_buffer_activeregion(source, &sr);
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt isc_buffer_forward(source, sr.length);
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt return (mem_tobuffer(target, sr.base, sr.length));
2bef3713093349af52ba61eaab07adf3207da873Mark Andrews}
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
de7df3e56fe99c33a415674b018aae93eee94750Evan Huntstatic inline isc_result_t
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunttowire_unspec(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt REQUIRE(rdata->type == 103);
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt UNUSED(cctx);
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt return (mem_tobuffer(target, rdata->data, rdata->length));
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt}
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntstatic inline int
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntcompare_unspec(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt isc_region_t r1;
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt isc_region_t r2;
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt REQUIRE(rdata1->type == rdata1->type);
d454a60f5664d7b4d026df93bf7745edd25cd897Evan Hunt REQUIRE(rdata1->rdclass == rdata2->rdclass);
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt REQUIRE(rdata1->type == 103);
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt dns_rdata_toregion(rdata1, &r1);
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt dns_rdata_toregion(rdata2, &r2);
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt return (compare_region(&r1, &r2));
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt}
1c5990c2f98abf0c2adf7f54a531d8a4a3965414Mark Andrews
de7df3e56fe99c33a415674b018aae93eee94750Evan Huntstatic inline isc_result_t
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Huntfromstruct_unspec(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt isc_buffer_t *target)
85705b4b5a4b666981997ffe222738d281b9bf58Evan Hunt{
85705b4b5a4b666981997ffe222738d281b9bf58Evan Hunt
85705b4b5a4b666981997ffe222738d281b9bf58Evan Hunt REQUIRE(type == 103);
85705b4b5a4b666981997ffe222738d281b9bf58Evan Hunt
85705b4b5a4b666981997ffe222738d281b9bf58Evan Hunt UNUSED(rdclass);
85705b4b5a4b666981997ffe222738d281b9bf58Evan Hunt UNUSED(source);
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt UNUSED(target);
85705b4b5a4b666981997ffe222738d281b9bf58Evan Hunt
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt return (ISC_R_NOTIMPLEMENTED);
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt}
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Huntstatic inline isc_result_t
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunttostruct_unspec(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt dns_rdata_unspec_t *unspec = target;
226339ed435db90da8e072ef46e2c27cf0dc687bEvan Hunt isc_region_t r;
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt REQUIRE(rdata->type == 103);
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt REQUIRE(target != NULL);
de7df3e56fe99c33a415674b018aae93eee94750Evan Hunt
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt unspec->common.rdclass = rdata->rdclass;
a27bbd21cf07371fc71e7ade75c3d78a5b98b7f9Mark Andrews unspec->common.rdtype = rdata->type;
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt ISC_LINK_INIT(&unspec->common, link);
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt dns_rdata_toregion(rdata, &r);
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt unspec->datalen = r.length;
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt if (unspec->datalen != 0) {
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt unspec->data = mem_maybedup(mctx, r.base, r.length);
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt if (unspec->data == NULL)
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt return (ISC_R_NOMEMORY);
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt } else
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt unspec->data = NULL;
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt
22e29471c784acd09619841926c4f765e36ac74aEvan Hunt unspec->mctx = mctx;
22e29471c784acd09619841926c4f765e36ac74aEvan Hunt return (ISC_R_SUCCESS);
22e29471c784acd09619841926c4f765e36ac74aEvan Hunt}
22e29471c784acd09619841926c4f765e36ac74aEvan Hunt
22e29471c784acd09619841926c4f765e36ac74aEvan Huntstatic inline void
22e29471c784acd09619841926c4f765e36ac74aEvan Huntfreestruct_unspec(void *source) {
22e29471c784acd09619841926c4f765e36ac74aEvan Hunt dns_rdata_unspec_t *unspec = source;
22e29471c784acd09619841926c4f765e36ac74aEvan Hunt
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt REQUIRE(source != NULL);
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt REQUIRE(unspec->common.rdtype == 103);
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt if (unspec->mctx == NULL)
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt return;
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt if (unspec->data != NULL)
f5898cf3484b1588d5239faa4062a2b2b606ce91Evan Hunt isc_mem_free(unspec->mctx, unspec->data);
a0c1ad17abcf07a2765eb054304d9b8b09887af2Tinderbox User unspec->mctx = NULL;
a0c1ad17abcf07a2765eb054304d9b8b09887af2Tinderbox User}
a0c1ad17abcf07a2765eb054304d9b8b09887af2Tinderbox User
a0c1ad17abcf07a2765eb054304d9b8b09887af2Tinderbox Userstatic inline isc_result_t
a0c1ad17abcf07a2765eb054304d9b8b09887af2Tinderbox Useradditionaldata_unspec(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
a0c1ad17abcf07a2765eb054304d9b8b09887af2Tinderbox User void *arg)
a0c1ad17abcf07a2765eb054304d9b8b09887af2Tinderbox User{
f5898cf3484b1588d5239faa4062a2b2b606ce91Evan Hunt REQUIRE(rdata->type == 103);
0c2d891abeb2b35e290ca9da29e1227110b5be23Mark Andrews
0c2d891abeb2b35e290ca9da29e1227110b5be23Mark Andrews UNUSED(rdata);
0c2d891abeb2b35e290ca9da29e1227110b5be23Mark Andrews UNUSED(add);
0c2d891abeb2b35e290ca9da29e1227110b5be23Mark Andrews UNUSED(arg);
return (ISC_R_SUCCESS);
}
static inline isc_result_t
digest_unspec(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) {
isc_region_t r;
REQUIRE(rdata->type == 103);
dns_rdata_toregion(rdata, &r);
return ((digest)(arg, &r));
}
#endif /* RDATA_GENERIC_UNSPEC_103_C */