mf_4.c revision 94a3bcd132e515b4baa0884ba9dd0f361d2e17bc
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt/*
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User * Copyright (C) 1998, 1999 Internet Software Consortium.
3e02c9e33656dcd9c364633d42dd785d3e6fdd66Automatic Updater *
3e02c9e33656dcd9c364633d42dd785d3e6fdd66Automatic Updater * Permission to use, copy, modify, and distribute this software for any
c6fb85f9500350e5ce58c9a24f5d264c8a8bd6f4Automatic Updater * purpose with or without fee is hereby granted, provided that the above
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt * copyright notice and this permission notice appear in all copies.
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt *
3e02c9e33656dcd9c364633d42dd785d3e6fdd66Automatic Updater * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
3e02c9e33656dcd9c364633d42dd785d3e6fdd66Automatic Updater * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt * SOFTWARE.
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt */
ea94d370123a5892f6c47a97f21d1b28d44bb168Tinderbox User
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt /* $Id: mf_4.c,v 1.12 1999/05/07 03:24:08 marka Exp $ */
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt#ifndef RDATA_GENERIC_MF_4_C
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt#define RDATA_GENERIC_MF_4_C
2cbb4ab75757fbb656997a82c14ca07db37d481aAutomatic Updater
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Huntstatic dns_result_t
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Huntfromtext_mf(dns_rdataclass_t class, dns_rdatatype_t type,
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt isc_lex_t *lexer, dns_name_t *origin,
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater isc_boolean_t downcase, isc_buffer_t *target)
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt{
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt isc_token_t token;
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_name_t name;
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt isc_buffer_t buffer;
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt REQUIRE(type == 4);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt class = class; /*unused*/
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_name_init(&name, NULL);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt buffer_fromregion(&buffer, &token.value.as_region,
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt ISC_BUFFERTYPE_TEXT);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt origin = (origin != NULL) ? origin : dns_rootname;
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt}
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Huntstatic dns_result_t
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunttotext_mf(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt isc_region_t region;
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_name_t name;
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_name_t prefix;
6f1205897504b8f50b1785975482c995888dd630Tinderbox User isc_boolean_t sub;
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt REQUIRE(rdata->type == 4);
6f1205897504b8f50b1785975482c995888dd630Tinderbox User
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_name_init(&name, NULL);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_rdata_toregion(rdata, &region);
fd0b768f4c23d22c89f8a156a632831583b7fb68Automatic Updater dns_name_fromregion(&name, &region);
fd0b768f4c23d22c89f8a156a632831583b7fb68Automatic Updater
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt sub = name_prefix(&name, origin, &prefix);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt return (dns_name_totext(&prefix, sub, target));
6f1205897504b8f50b1785975482c995888dd630Tinderbox User}
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Huntstatic dns_result_t
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Huntfromwire_mf(dns_rdataclass_t class, dns_rdatatype_t type,
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt isc_buffer_t *source, dns_decompress_t *dctx,
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt isc_boolean_t downcase, isc_buffer_t *target)
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater{
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_name_t name;
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt REQUIRE(type == 4);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt class = class; /*unused*/
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx))
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt else
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_name_init(&name, NULL);
6f1205897504b8f50b1785975482c995888dd630Tinderbox User return (dns_name_fromwire(&name, source, dctx, downcase, target));
6f1205897504b8f50b1785975482c995888dd630Tinderbox User}
6f1205897504b8f50b1785975482c995888dd630Tinderbox User
6f1205897504b8f50b1785975482c995888dd630Tinderbox Userstatic dns_result_t
8ec3c085233cedb22b05da36e2773c8f357a7e45Automatic Updatertowire_mf(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User dns_name_t name;
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User isc_region_t region;
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User REQUIRE(rdata->type == 4);
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User if (dns_compress_getedns(cctx) >= 1)
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User else
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User dns_name_init(&name, NULL);
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User dns_rdata_toregion(rdata, &region);
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User dns_name_fromregion(&name, &region);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt return (dns_name_towire(&name, cctx, target));
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt}
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Huntstatic int
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Huntcompare_mf(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
12bfbed87cfffa65ac300b72c5665ab38a355c2fAutomatic Updater dns_name_t name1;
12bfbed87cfffa65ac300b72c5665ab38a355c2fAutomatic Updater dns_name_t name2;
12bfbed87cfffa65ac300b72c5665ab38a355c2fAutomatic Updater isc_region_t region1;
12bfbed87cfffa65ac300b72c5665ab38a355c2fAutomatic Updater isc_region_t region2;
12bfbed87cfffa65ac300b72c5665ab38a355c2fAutomatic Updater
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt REQUIRE(rdata1->type == rdata2->type);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt REQUIRE(rdata1->class == rdata2->class);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt REQUIRE(rdata1->type == 4);
6f1205897504b8f50b1785975482c995888dd630Tinderbox User
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_name_init(&name1, NULL);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_name_init(&name2, NULL);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_rdata_toregion(rdata1, &region1);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_rdata_toregion(rdata2, &region2);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
6f1205897504b8f50b1785975482c995888dd630Tinderbox User dns_name_fromregion(&name1, &region1);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt dns_name_fromregion(&name2, &region2);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt return (dns_name_rdatacompare(&name1, &name2));
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt}
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Huntstatic dns_result_t
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Huntfromstruct_mf(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt isc_buffer_t *target)
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt{
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt REQUIRE(type == 4);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt class = class; /*unused*/
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt source = source;
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt target = target;
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt return (DNS_R_NOTIMPLEMENTED);
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater}
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Huntstatic dns_result_t
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunttostruct_mf(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt REQUIRE(rdata->type == 4);
1bc5499c2a0fc5d2b11849e97cdd6305a64eb242Evan Hunt
target = target;
mctx = mctx;
return (DNS_R_NOTIMPLEMENTED);
}
static void
freestruct_mf(void *source) {
REQUIRE(source != NULL);
REQUIRE(ISC_FALSE); /*XXX*/
}
#endif /* RDATA_GENERIC_MF_4_C */