1999-01-19 02:20:26 +00:00
|
|
|
/*
|
2000-06-21 22:45:24 +00:00
|
|
|
* Copyright (C) 1998-2000 Internet Software Consortium.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
1999-01-19 02:20:26 +00:00
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2000-07-27 09:55:03 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
|
|
|
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
|
|
|
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
|
|
|
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
|
|
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
1999-01-19 02:20:26 +00:00
|
|
|
*/
|
|
|
|
|
2000-08-01 01:33:37 +00:00
|
|
|
/* $Id: minfo_14.c,v 1.32 2000/08/01 01:25:35 tale Exp $ */
|
2000-03-16 02:00:37 +00:00
|
|
|
|
|
|
|
/* reviewed: Wed Mar 15 17:45:32 PST 2000 by brister */
|
1999-01-19 05:38:36 +00:00
|
|
|
|
1999-05-05 00:19:04 +00:00
|
|
|
#ifndef RDATA_GENERIC_MINFO_14_C
|
|
|
|
#define RDATA_GENERIC_MINFO_14_C
|
1999-01-19 02:20:26 +00:00
|
|
|
|
2000-04-07 03:54:52 +00:00
|
|
|
#define RRTYPE_MINFO_ATTRIBUTES (0)
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
fromtext_minfo(ARGS_FROMTEXT) {
|
1999-01-19 02:20:26 +00:00
|
|
|
isc_token_t token;
|
|
|
|
dns_name_t name;
|
|
|
|
isc_buffer_t buffer;
|
1999-01-22 00:36:59 +00:00
|
|
|
int i;
|
1999-01-19 02:20:26 +00:00
|
|
|
|
1999-01-20 05:20:24 +00:00
|
|
|
REQUIRE(type == 14);
|
1999-01-19 06:49:33 +00:00
|
|
|
|
2000-03-16 02:00:37 +00:00
|
|
|
UNUSED(rdclass);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-01-22 00:36:59 +00:00
|
|
|
for (i = 0; i < 2 ; i++) {
|
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_string,
|
|
|
|
ISC_FALSE));
|
|
|
|
dns_name_init(&name, NULL);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
buffer_fromregion(&buffer, &token.value.as_region);
|
1999-01-22 00:36:59 +00:00
|
|
|
origin = (origin != NULL) ? origin : dns_rootname;
|
|
|
|
RETERR(dns_name_fromtext(&name, &buffer, origin,
|
|
|
|
downcase, target));
|
1999-01-20 05:20:24 +00:00
|
|
|
}
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
totext_minfo(ARGS_TOTEXT) {
|
1999-01-19 02:20:26 +00:00
|
|
|
isc_region_t region;
|
|
|
|
dns_name_t rmail;
|
|
|
|
dns_name_t email;
|
|
|
|
dns_name_t prefix;
|
|
|
|
isc_boolean_t sub;
|
|
|
|
|
1999-01-20 05:20:24 +00:00
|
|
|
REQUIRE(rdata->type == 14);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
|
|
|
dns_name_init(&rmail, NULL);
|
|
|
|
dns_name_init(&email, NULL);
|
|
|
|
dns_name_init(&prefix, NULL);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, ®ion);
|
|
|
|
|
|
|
|
dns_name_fromregion(&rmail, ®ion);
|
|
|
|
isc_region_consume(®ion, rmail.length);
|
|
|
|
|
|
|
|
dns_name_fromregion(&email, ®ion);
|
|
|
|
isc_region_consume(®ion, email.length);
|
|
|
|
|
1999-06-08 10:35:23 +00:00
|
|
|
sub = name_prefix(&rmail, tctx->origin, &prefix);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
1999-01-22 00:36:59 +00:00
|
|
|
RETERR(dns_name_totext(&prefix, sub, target));
|
1999-01-19 02:20:26 +00:00
|
|
|
|
1999-01-22 00:36:59 +00:00
|
|
|
RETERR(str_totext(" ", target));
|
1999-01-19 02:20:26 +00:00
|
|
|
|
1999-06-08 10:35:23 +00:00
|
|
|
sub = name_prefix(&email, tctx->origin, &prefix);
|
1999-01-22 00:36:59 +00:00
|
|
|
return (dns_name_totext(&prefix, sub, target));
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
fromwire_minfo(ARGS_FROMWIRE) {
|
1999-01-19 02:20:26 +00:00
|
|
|
dns_name_t rmail;
|
|
|
|
dns_name_t email;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-01-20 05:20:24 +00:00
|
|
|
REQUIRE(type == 14);
|
1999-01-19 06:49:33 +00:00
|
|
|
|
2000-05-04 22:19:34 +00:00
|
|
|
dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
|
1999-02-24 06:31:35 +00:00
|
|
|
|
2000-03-16 02:00:37 +00:00
|
|
|
UNUSED(rdclass);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
|
|
|
dns_name_init(&rmail, NULL);
|
|
|
|
dns_name_init(&email, NULL);
|
|
|
|
|
1999-01-22 00:36:59 +00:00
|
|
|
RETERR(dns_name_fromwire(&rmail, source, dctx, downcase, target));
|
1999-01-19 02:20:26 +00:00
|
|
|
return (dns_name_fromwire(&email, source, dctx, downcase, target));
|
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
towire_minfo(ARGS_TOWIRE) {
|
1999-01-19 02:20:26 +00:00
|
|
|
isc_region_t region;
|
|
|
|
dns_name_t rmail;
|
|
|
|
dns_name_t email;
|
|
|
|
|
1999-01-20 05:20:24 +00:00
|
|
|
REQUIRE(rdata->type == 14);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
2000-05-04 22:19:34 +00:00
|
|
|
dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
|
1999-02-22 07:24:05 +00:00
|
|
|
|
1999-01-19 02:20:26 +00:00
|
|
|
dns_name_init(&rmail, NULL);
|
|
|
|
dns_name_init(&email, NULL);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, ®ion);
|
|
|
|
|
|
|
|
dns_name_fromregion(&rmail, ®ion);
|
1999-01-27 13:38:21 +00:00
|
|
|
isc_region_consume(®ion, name_length(&rmail));
|
1999-01-19 02:20:26 +00:00
|
|
|
|
1999-01-22 00:36:59 +00:00
|
|
|
RETERR(dns_name_towire(&rmail, cctx, target));
|
1999-01-19 02:20:26 +00:00
|
|
|
|
|
|
|
dns_name_fromregion(&rmail, ®ion);
|
|
|
|
isc_region_consume(®ion, rmail.length);
|
|
|
|
|
1999-01-22 00:36:59 +00:00
|
|
|
return (dns_name_towire(&rmail, cctx, target));
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline int
|
2000-06-01 18:26:56 +00:00
|
|
|
compare_minfo(ARGS_COMPARE) {
|
1999-01-19 02:20:26 +00:00
|
|
|
isc_region_t region1;
|
|
|
|
isc_region_t region2;
|
|
|
|
dns_name_t name1;
|
|
|
|
dns_name_t name2;
|
2000-03-20 22:44:36 +00:00
|
|
|
int order;
|
1999-01-19 02:20:26 +00:00
|
|
|
|
1999-01-20 05:20:24 +00:00
|
|
|
REQUIRE(rdata1->type == rdata2->type);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdata1->rdclass == rdata2->rdclass);
|
1999-01-20 05:20:24 +00:00
|
|
|
REQUIRE(rdata1->type == 14);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
|
|
|
dns_name_init(&name1, NULL);
|
|
|
|
dns_name_init(&name2, NULL);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata1, ®ion1);
|
1999-01-22 00:36:59 +00:00
|
|
|
dns_rdata_toregion(rdata2, ®ion2);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
|
|
|
dns_name_fromregion(&name1, ®ion1);
|
|
|
|
dns_name_fromregion(&name2, ®ion2);
|
|
|
|
|
2000-03-20 22:44:36 +00:00
|
|
|
order = dns_name_rdatacompare(&name1, &name2);
|
|
|
|
if (order != 0)
|
|
|
|
return (order);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
1999-01-22 00:36:59 +00:00
|
|
|
isc_region_consume(®ion1, name_length(&name1));
|
|
|
|
isc_region_consume(®ion2, name_length(&name2));
|
1999-01-19 02:20:26 +00:00
|
|
|
|
|
|
|
dns_name_init(&name1, NULL);
|
|
|
|
dns_name_init(&name2, NULL);
|
|
|
|
|
|
|
|
dns_name_fromregion(&name1, ®ion1);
|
|
|
|
dns_name_fromregion(&name2, ®ion2);
|
|
|
|
|
2000-03-20 22:44:36 +00:00
|
|
|
order = dns_name_rdatacompare(&name1, &name2);
|
|
|
|
return (order);
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
fromstruct_minfo(ARGS_FROMSTRUCT) {
|
2000-05-22 12:38:12 +00:00
|
|
|
dns_rdata_minfo_t *minfo = source;
|
|
|
|
isc_region_t region;
|
1999-01-19 06:49:33 +00:00
|
|
|
|
1999-01-20 05:20:24 +00:00
|
|
|
REQUIRE(type == 14);
|
2000-05-22 12:38:12 +00:00
|
|
|
REQUIRE(source != NULL);
|
|
|
|
REQUIRE(minfo->common.rdtype == type);
|
|
|
|
REQUIRE(minfo->common.rdclass == rdclass);
|
|
|
|
|
|
|
|
dns_name_toregion(&minfo->rmailbox, ®ion);
|
|
|
|
RETERR(isc_buffer_copyregion(target, ®ion));
|
|
|
|
dns_name_toregion(&minfo->emailbox, ®ion);
|
|
|
|
return (isc_buffer_copyregion(target, ®ion));
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
tostruct_minfo(ARGS_TOSTRUCT) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_minfo_t *minfo = target;
|
2000-05-22 12:38:12 +00:00
|
|
|
isc_region_t region;
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_name_t name;
|
2000-05-22 12:38:12 +00:00
|
|
|
isc_result_t result;
|
2000-05-05 05:50:14 +00:00
|
|
|
|
1999-01-20 05:20:24 +00:00
|
|
|
REQUIRE(rdata->type == 14);
|
2000-05-05 05:50:14 +00:00
|
|
|
REQUIRE(target != NULL);
|
1999-01-19 06:49:33 +00:00
|
|
|
|
2000-05-05 05:50:14 +00:00
|
|
|
minfo->common.rdclass = rdata->rdclass;
|
|
|
|
minfo->common.rdtype = rdata->type;
|
|
|
|
ISC_LINK_INIT(&minfo->common, link);
|
1999-01-19 02:20:26 +00:00
|
|
|
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
dns_rdata_toregion(rdata, ®ion);
|
|
|
|
dns_name_fromregion(&name, ®ion);
|
|
|
|
dns_name_init(&minfo->rmailbox, NULL);
|
|
|
|
RETERR(name_duporclone(&name, mctx, &minfo->rmailbox));
|
|
|
|
isc_region_consume(®ion, name_length(&name));
|
|
|
|
|
|
|
|
dns_name_fromregion(&name, ®ion);
|
|
|
|
dns_name_init(&minfo->emailbox, NULL);
|
|
|
|
result = name_duporclone(&name, mctx, &minfo->emailbox);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
minfo->mctx = mctx;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (mctx != NULL)
|
|
|
|
dns_name_free(&minfo->rmailbox, mctx);
|
|
|
|
return (ISC_R_NOMEMORY);
|
1999-01-19 02:20:26 +00:00
|
|
|
}
|
1999-05-07 03:24:15 +00:00
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline void
|
2000-06-01 18:26:56 +00:00
|
|
|
freestruct_minfo(ARGS_FREESTRUCT) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_minfo_t *minfo = source;
|
|
|
|
|
1999-05-07 03:24:15 +00:00
|
|
|
REQUIRE(source != NULL);
|
2000-05-05 05:50:14 +00:00
|
|
|
REQUIRE(minfo->common.rdtype == 14);
|
2000-04-28 01:24:18 +00:00
|
|
|
|
2000-05-05 05:50:14 +00:00
|
|
|
if (minfo->mctx == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dns_name_free(&minfo->rmailbox, minfo->mctx);
|
|
|
|
dns_name_free(&minfo->emailbox, minfo->mctx);
|
|
|
|
minfo->mctx = NULL;
|
1999-05-07 03:24:15 +00:00
|
|
|
}
|
1999-08-02 22:18:31 +00:00
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
additionaldata_minfo(ARGS_ADDLDATA) {
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdata->type == 14);
|
|
|
|
|
2000-04-28 01:24:18 +00:00
|
|
|
UNUSED(rdata);
|
|
|
|
UNUSED(add);
|
|
|
|
UNUSED(arg);
|
1999-08-02 22:18:31 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-08-02 22:18:31 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-06-01 18:26:56 +00:00
|
|
|
digest_minfo(ARGS_DIGEST) {
|
1999-08-31 22:05:55 +00:00
|
|
|
isc_region_t r;
|
|
|
|
dns_name_t name;
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t result;
|
1999-08-31 22:05:55 +00:00
|
|
|
|
|
|
|
REQUIRE(rdata->type == 14);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &r);
|
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
dns_name_fromregion(&name, &r);
|
|
|
|
result = dns_name_digest(&name, digest, arg);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-08-31 22:05:55 +00:00
|
|
|
return (result);
|
|
|
|
isc_region_consume(&r, name_length(&name));
|
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
dns_name_fromregion(&name, &r);
|
|
|
|
|
|
|
|
return (dns_name_digest(&name, digest, arg));
|
|
|
|
}
|
|
|
|
|
1999-05-05 00:19:04 +00:00
|
|
|
#endif /* RDATA_GENERIC_MINFO_14_C */
|