74e2f784928d6d5e4897174b21dd35d5a5ab53faTinderbox User * Copyright (C) 1998-2017 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
c46f10e4a1702191b003cf8f8fc5059c15d29c48Mark Andrews#define DNS_AS_STR(t) ((t).value.as_textregion.base)
0b056755b2f423ba5f6adac8f7851d78f7d11437David Lawrence#define ARGS_FROMTEXT int rdclass, dns_rdatatype_t type, \
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence#define ARGS_TOTEXT dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, \
0b056755b2f423ba5f6adac8f7851d78f7d11437David Lawrence#define ARGS_FROMWIRE int rdclass, dns_rdatatype_t type, \
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence isc_buffer_t *source, dns_decompress_t *dctx, \
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence#define ARGS_TOWIRE dns_rdata_t *rdata, dns_compress_t *cctx, \
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence#define ARGS_COMPARE const dns_rdata_t *rdata1, const dns_rdata_t *rdata2
0b056755b2f423ba5f6adac8f7851d78f7d11437David Lawrence#define ARGS_FROMSTRUCT int rdclass, dns_rdatatype_t type, \
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence#define ARGS_TOSTRUCT dns_rdata_t *rdata, void *target, isc_mem_t *mctx
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence#define ARGS_ADDLDATA dns_rdata_t *rdata, dns_additionaldatafunc_t add, \
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence#define ARGS_DIGEST dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews#define ARGS_CHECKOWNER dns_name_t *name, dns_rdataclass_t rdclass, \
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews#define ARGS_CHECKNAMES dns_rdata_t *rdata, dns_name_t *owner, dns_name_t *bad
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Context structure for the totext_ functions.
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafsson * Contains formatting options for rdata-to-text
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein dns_name_t *origin; /*%< Current origin, or NULL. */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein unsigned int width; /*%< Width of rdata column. */
e672951ed28b2e9cc7a19c3d7fa4a258382f981cAutomatic Updater const char *linebreak; /*%< Line break string. */
2383eb527269d333df4222da20e4b422c3662daaEvan Hunttxt_totext(isc_region_t *source, isc_boolean_t quote, isc_buffer_t *target);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencetxt_fromtext(isc_textregion_t *source, isc_buffer_t *target);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencetxt_fromwire(isc_buffer_t *source, isc_buffer_t *target);
7712d1660a308ec3de17f1ddbbf801eb0d663f3eEvan Huntmultitxt_totext(isc_region_t *source, isc_buffer_t *target);
7712d1660a308ec3de17f1ddbbf801eb0d663f3eEvan Huntmultitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencename_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencestatic unsigned int
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencestr_totext(const char *source, isc_buffer_t *target);
330705066b03f6ce0bc08a4bbfc5d2418038c68dBrian Wellingtoninet_totext(int af, isc_region_t *src, isc_buffer_t *target);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencebuffer_fromregion(isc_buffer_t *buffer, isc_region_t *region);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrenceuint32_tobuffer(isc_uint32_t, isc_buffer_t *target);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrenceuint16_tobuffer(isc_uint32_t, isc_buffer_t *target);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrenceuint8_tobuffer(isc_uint32_t, isc_buffer_t *target);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencename_tobuffer(dns_name_t *name, isc_buffer_t *target);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencemem_tobuffer(isc_buffer_t *target, void *base, unsigned int length);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencebtoa_totext(unsigned char *inbuf, int inbuflen, isc_buffer_t *target);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrenceatob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target);
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafssondefault_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *, ...)
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefromtext_error(void (*callback)(dns_rdatacallbacks_t *, const char *, ...),
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence dns_rdatacallbacks_t *callbacks, const char *name,
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence unsigned long line, isc_token_t *token, isc_result_t result);
fd4810861c0c0ccb9aebde94e9d289442b2630dbMark Andrewsfromtext_warneof(isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencerdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewswarn_badname(dns_name_t *name, isc_lex_t *lexer,
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrewswarn_badmx(isc_token_t *token, isc_lex_t *lexer,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsuint16_consume_fromregion(isc_region_t *region);
fe3472c80b76b6fed0ae674fd63471d02477a03aMark Andrewsunknown_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
8b29fc0b7a13db404f1a13fcfad42c2e7cfbe25bMark Andrewsstatic inline void
63874956de9673be49d4a75484514836dd27e6edMark Andrewsgeneric_txt_current(dns_rdata_txt_t *txt, dns_rdata_txt_string_t *string);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews/*% INT16 Size */
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews/*% IPv6 Address Size */
dc3912f3caac1104fef441fd18571b7a975708eaMark Andrews * Active Diretory gc._msdcs.<forest> prefix.
dc3912f3caac1104fef441fd18571b7a975708eaMark Andrewsstatic unsigned char gc_msdcs_data[] = "\002gc\006_msdcs";
dc3912f3caac1104fef441fd18571b7a975708eaMark Andrewsstatic unsigned char gc_msdcs_offset [] = { 0, 3 };
3ed16e796dba90c96933c8a8a3f5b9404d8d3e61Mark Andrews DNS_NAME_INITNONABSOLUTE(gc_msdcs_data, gc_msdcs_offset);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * convert presentation level address to network order binary form.
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * (1) does not touch `dst' unless it's returning 1.
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline int
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewslocator_pton(const char *src, unsigned char *dst) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews static const char xdigits_l[] = "0123456789abcdef",
bddfe77128b0f16af263ff149db40f0d885f43d0Mark Andrewsstatic inline int
bddfe77128b0f16af263ff149db40f0d885f43d0Mark Andrews isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks)
23cb957a81a51a9656917ea98d0ae56b7abdcaccMark Andrews const char *name = isc_lex_getsourcename(lexer);
aa05bbdef7f7827dde158dcc913f4dade84c8511Brian Wellington (*callbacks->warn)(callbacks, "%s:%lu: \"%s\" "
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrewsname_duporclone(dns_name_t *source, isc_mem_t *mctx, dns_name_t *target) {
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington return (dns_name_dup(source, mctx, target));
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrewsstatic inline void *
2002be4f65776451676df6ee21a2e28f52bcad6dMark Andrewsmem_maybedup(isc_mem_t *mctx, void *source, size_t length) {
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrewstypemap_fromtext(isc_lex_t *lexer, isc_buffer_t *target,
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews } while (1);
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews * Find if we have a type in this window.
5b13a593fe7d8055992bd12aeb399bdb06e2a533Mukund Sivaraman for (octet = max_octet; octet >= 0; octet--) {
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews RETERR(mem_tobuffer(target, &bm[window * 32], octet + 1));
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrewstypemap_totext(isc_region_t *sr, dns_rdata_textctx_t *tctx,
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews unsigned int i, j, k;
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews (tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews for (j = 0; j < len; j++) {
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews for (k = 0; k < 8; k++) {
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrewstypemap_test(isc_region_t *sr, isc_boolean_t allow_empty) {
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews unsigned int i;
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews * Check for overflow.
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews * Check that bitmap windows are in the correct order.
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews * Check for legal lengths.
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews * Check for overflow.
f6e45a5c54b7af4b1c303e8d3ff3b7d78622df9eMark Andrews * The last octet of the bitmap must be non zero.
ffe74cc719aa0f10c38fbc1f2f3ea7db0960cb8fMark Andrewsstatic const char hexdigits[] = "0123456789abcdef";
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews *** Initialization
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews /* ISC_LIST_INIT(rdata->list); */
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrewsdns_rdata_clone(const dns_rdata_t *src, dns_rdata_t *target) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews *** Comparisons
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencedns_rdata_compare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2) {
735ca24fa61ad9cd0285776c2fc4c14032f8f194Mark Andrews REQUIRE(rdata1->length == 0 || rdata1->data != NULL);
735ca24fa61ad9cd0285776c2fc4c14032f8f194Mark Andrews REQUIRE(rdata2->length == 0 || rdata2->data != NULL);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley return (rdata1->rdclass < rdata2->rdclass ? -1 : 1);
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrewsdns_rdata_casecompare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2) {
735ca24fa61ad9cd0285776c2fc4c14032f8f194Mark Andrews REQUIRE(rdata1->length == 0 || rdata1->data != NULL);
735ca24fa61ad9cd0285776c2fc4c14032f8f194Mark Andrews REQUIRE(rdata2->length == 0 || rdata2->data != NULL);
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews return (rdata1->rdclass < rdata2->rdclass ? -1 : 1);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews *** Conversions
d981ca645597116d227a48bf37cc5edc061c854dBob Halleydns_rdata_fromregion(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencedns_rdata_toregion(const dns_rdata_t *rdata, isc_region_t *r) {
d981ca645597116d227a48bf37cc5edc061c854dBob Halleydns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
9916239908343b3eb17f0578de4c3cd6a313d85fMark Andrews activelength = isc_buffer_activelength(source);
9916239908343b3eb17f0578de4c3cd6a313d85fMark Andrews if (activelength > isc_buffer_availablelength(target))
9916239908343b3eb17f0578de4c3cd6a313d85fMark Andrews isc_buffer_putmem(target, isc_buffer_current(source),
1bbd36c4db2c86762b582db4b0504e6e68a183f6Mark Andrews * Reject any rdata that expands out to more than DNS_RDATA_MAXLENGTH
1bbd36c4db2c86762b582db4b0504e6e68a183f6Mark Andrews * as we cannot transmit it.
1bbd36c4db2c86762b582db4b0504e6e68a183f6Mark Andrews length = isc_buffer_usedlength(target) - isc_buffer_usedlength(&st);
1bbd36c4db2c86762b582db4b0504e6e68a183f6Mark Andrews if (result == ISC_R_SUCCESS && length > DNS_RDATA_MAXLENGTH)
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * We should have consumed all of our buffer.
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff if (result == ISC_R_SUCCESS && !buffer_empty(source))
ad7209ea70d346527ffdcda335153831341d9dcfAndreas Gustafsson if (rdata != NULL && result == ISC_R_SUCCESS) {
d981ca645597116d227a48bf37cc5edc061c854dBob Halley dns_rdata_fromregion(rdata, rdclass, type, ®ion);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrewsdns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
693ddf84daa745a0ea8ca311a8154dfa03eabc43Andreas Gustafsson * Some DynDNS meta-RRs have empty rdata.
7c0378745269fe49a05904935afc42b85528f53aDavid Lawrence dns_compress_rollback(cctx, (isc_uint16_t)target->used);
7e4cda9965e2edf2ec43c57967eec8eff7061ab0Andreas Gustafsson * If the binary data in 'src' is valid uncompressed wire format
7e4cda9965e2edf2ec43c57967eec8eff7061ab0Andreas Gustafsson * rdata of class 'rdclass' and type 'type', return ISC_R_SUCCESS
7e4cda9965e2edf2ec43c57967eec8eff7061ab0Andreas Gustafsson * and copy the validated rdata to 'dest'. Otherwise return an error.
7e4cda9965e2edf2ec43c57967eec8eff7061ab0Andreas Gustafssonrdata_validate(isc_buffer_t *src, isc_buffer_t *dest, dns_rdataclass_t rdclass,
942d1a339b1fe617f7d17d66cb5fccce798d15aeBrian Wellington dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_NONE);
93ed317bb43658ed48ee7439f7a36bb9bcf80c94Brian Wellington isc_buffer_setactive(src, isc_buffer_usedlength(src));
7e9d637131516486630290d36c4c0db544cb700eMark Andrews result = dns_rdata_fromwire(NULL, rdclass, type, src, &dctx, 0, dest);
93ed317bb43658ed48ee7439f7a36bb9bcf80c94Brian Wellingtonunknown_fromtext(dns_rdataclass_t rdclass, dns_rdatatype_t type,
93ed317bb43658ed48ee7439f7a36bb9bcf80c94Brian Wellington isc_lex_t *lexer, isc_mem_t *mctx, isc_buffer_t *target)
de5247ae1683ce145662180ee50272d2214a0232Andreas Gustafsson if (type == 0 || dns_rdatatype_ismeta(type))
1cc4695f0da63f0190e3514adccf6a96f3dc1519Mark Andrews RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
f16495732753175e4a9fc144323a12fdcc29b561Brian Wellington result = isc_buffer_allocate(mctx, &buf, token.value.as_ulong);
93ed317bb43658ed48ee7439f7a36bb9bcf80c94Brian Wellington if (isc_buffer_usedlength(buf) != token.value.as_ulong) {
7e4cda9965e2edf2ec43c57967eec8eff7061ab0Andreas Gustafsson result = rdata_validate(buf, target, rdclass, type);
93ed317bb43658ed48ee7439f7a36bb9bcf80c94Brian Wellington result = isc_buffer_copyregion(target, &r);
d981ca645597116d227a48bf37cc5edc061c854dBob Halleydns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_t *origin, unsigned int options, isc_mem_t *mctx,
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrews isc_buffer_t *target, dns_rdatacallbacks_t *callbacks)
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews unsigned int lexoptions = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF |
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence void (*callback)(dns_rdatacallbacks_t *, const char *, ...);
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence REQUIRE(origin == NULL || dns_name_isabsolute(origin) == ISC_TRUE);
ebfcb6cf66283096ebda1503b6cc042ce86b6bedBrian Wellington result = isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
c51f2c9a529b2130a8058cb7a32bd284fa6cfdb9Mark Andrews fromtext_error(callback, callbacks, name, line, NULL, result);
e85702ce5be33d7c07eff6487c6bb4730165f331Mark Andrews * If this is a TXT record '\#' could be a escaped '#'.
e85702ce5be33d7c07eff6487c6bb4730165f331Mark Andrews * Look to see if the next token is a number and if so
e85702ce5be33d7c07eff6487c6bb4730165f331Mark Andrews * treat it as a unknown record format.
e85702ce5be33d7c07eff6487c6bb4730165f331Mark Andrews result = unknown_fromtext(rdclass, type, lexer,
3d5cad69ec20157912e95cf3b79316dfb0a314f3Mark Andrews * Consume to end of line / file.
3d5cad69ec20157912e95cf3b79316dfb0a314f3Mark Andrews * If not at end of line initially set error code.
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews * Call callback via fromtext_error once if there was an error.
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews tresult = isc_lex_gettoken(lexer, lexoptions, &token);
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff } else if (result != ISC_R_SUCCESS && callback != NULL) {
82d05588933a3c765aa8518fe455d6477d640b99Mark Andrews fromtext_error(callback, callbacks, name, line,
3d5cad69ec20157912e95cf3b79316dfb0a314f3Mark Andrews } while (1);
1bbd36c4db2c86762b582db4b0504e6e68a183f6Mark Andrews length = isc_buffer_usedlength(target) - isc_buffer_usedlength(&st);
1bbd36c4db2c86762b582db4b0504e6e68a183f6Mark Andrews if (result == ISC_R_SUCCESS && length > DNS_RDATA_MAXLENGTH)
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff if (rdata != NULL && result == ISC_R_SUCCESS) {
d981ca645597116d227a48bf37cc5edc061c854dBob Halley dns_rdata_fromregion(rdata, rdclass, type, ®ion);
fe3472c80b76b6fed0ae674fd63471d02477a03aMark Andrewsunknown_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
fe3472c80b76b6fed0ae674fd63471d02477a03aMark Andrews if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
ae70d32b67cf30e06553c01479e71c87b21d984cBob Halleyrdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence dns_name_isabsolute(tctx->origin) == ISC_TRUE);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Some DynDNS meta-RRs have empty rdata.
79a55d4f4dcf3d6f617523228503d8584b72a3a3Mukund Sivaraman if ((tctx->flags & DNS_STYLEFLAG_UNKNOWNFORMAT) != 0)
79a55d4f4dcf3d6f617523228503d8584b72a3a3Mukund Sivaraman return (unknown_totext(rdata, tctx, target));
ec3dbae9eb0fdbda37c76c2b41e819c7982be1c4Mukund Sivaraman if (use_default || (result == ISC_R_NOTIMPLEMENTED)) {
ec3dbae9eb0fdbda37c76c2b41e819c7982be1c4Mukund Sivaraman unsigned int u = isc_buffer_usedlength(target);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencedns_rdata_totext(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target)
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Set up formatting options for single-line output.
0c8649cea98afc061dd2938fd315df53b8fc35caAndreas Gustafssondns_rdata_tofmttext(dns_rdata_t *rdata, dns_name_t *origin,
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Set up formatting options for formatted output.
9a859983d7059a6eb9c877c1d2ac6a3a5b7170f7Evan Hunt tctx.width = 60; /* Used for hex word length only. */
d981ca645597116d227a48bf37cc5edc061c854dBob Halleydns_rdata_fromstruct(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
1bbd36c4db2c86762b582db4b0504e6e68a183f6Mark Andrews length = isc_buffer_usedlength(target) - isc_buffer_usedlength(&st);
1bbd36c4db2c86762b582db4b0504e6e68a183f6Mark Andrews if (result == ISC_R_SUCCESS && length > DNS_RDATA_MAXLENGTH)
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff if (rdata != NULL && result == ISC_R_SUCCESS) {
d981ca645597116d227a48bf37cc5edc061c854dBob Halley dns_rdata_fromregion(rdata, rdclass, type, ®ion);
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrewsdns_rdata_tostruct(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
d981ca645597116d227a48bf37cc5edc061c854dBob Halleydns_rdata_additionaldata(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
d981ca645597116d227a48bf37cc5edc061c854dBob Halley * Call 'add' for each name and type from 'rdata' which is subject to
d981ca645597116d227a48bf37cc5edc061c854dBob Halley * additional section processing.
9916239908343b3eb17f0578de4c3cd6a313d85fMark Andrews /* No additional processing for unknown types */
0513f89e68f82f9ec54e7af9c979a7c43babbe31Bob Halleydns_rdata_digest(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) {
0513f89e68f82f9ec54e7af9c979a7c43babbe31Bob Halley * Send 'rdata' in DNSSEC canonical form to 'digest'.
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsdns_rdata_checkowner(dns_name_t *name, dns_rdataclass_t rdclass,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsdns_rdata_checknames(dns_rdata_t *rdata, dns_name_t *owner, dns_name_t *bad)
0316be2d7786f72b886d9e5ba892c77038543ef7Evan Hunt if (type >= (dns_rdatatype_t)128 && type < (dns_rdatatype_t)255)
0316be2d7786f72b886d9e5ba892c77038543ef7Evan Hunt return (DNS_RDATATYPEATTR_UNKNOWN | DNS_RDATATYPEATTR_META);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencedns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source) {
a98551ef592e9be6008e0141ceeb32efd586c5efMark Andrews unsigned int n;
94a537e6ab3069f8d34e12e5ea722250be2b89c8Michael Graff unsigned char a, b;
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence b = tolower((unsigned char)source->base[n - 1]);
29747dfe5e073a299b3681e01f5c55540f8bfed7Mark Andrews * This switch block is inlined via \#define, and will use "return"
94a537e6ab3069f8d34e12e5ea722250be2b89c8Michael Graff * to return a result to the caller if it is a valid (known)
94a537e6ab3069f8d34e12e5ea722250be2b89c8Michael Graff * rdatatype name.
8695d7b357789bedff63e5b19c5ab25cd58fcd4bMark Andrews RDATATYPE_FROMTEXT_SW(hash, source->base, n, typep);
8695d7b357789bedff63e5b19c5ab25cd58fcd4bMark Andrews if (source->length > 4 && source->length < (4 + sizeof("65000")) &&
5a93d3be4e0c652f455066bb764416173a00c951Mark Andrews * source->base is not required to be NUL terminated.
5a93d3be4e0c652f455066bb764416173a00c951Mark Andrews * Copy up to remaining bytes and NUL terminate.
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencedns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target) {
79a55d4f4dcf3d6f617523228503d8584b72a3a3Mukund Sivaraman return (dns_rdatatype_tounknowntext(type, target));
79a55d4f4dcf3d6f617523228503d8584b72a3a3Mukund Sivaramandns_rdatatype_tounknowntext(dns_rdatatype_t type, isc_buffer_t *target) {
8c962eba3d6faebc008806ebb6bb9d08089118e9Andreas Gustafssondns_rdatatype_format(dns_rdatatype_t rdtype,
8c962eba3d6faebc008806ebb6bb9d08089118e9Andreas Gustafsson result = dns_rdatatype_totext(rdtype, &buf);
d3a86da2e8f09e2c3f55721aae537b9cacc7e537Andreas Gustafsson * Null terminate.
d3a86da2e8f09e2c3f55721aae537b9cacc7e537Andreas Gustafsson if (isc_buffer_availablelength(&buf) >= 1)
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Private function.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrewsstatic unsigned int
2383eb527269d333df4222da20e4b422c3662daaEvan Hunttxt_totext(isc_region_t *source, isc_boolean_t quote, isc_buffer_t *target) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews unsigned int n;
2383eb527269d333df4222da20e4b422c3662daaEvan Hunt if (n == 0U)
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews while (n--) {
2383eb527269d333df4222da20e4b422c3662daaEvan Hunt * \DDD space (0x20) if not quoting.
9a36fb86f5019f25705d25ea729d03fcf8ecaa95Mark Andrews * Escape double quote and backslash. If we are not
9a36fb86f5019f25705d25ea729d03fcf8ecaa95Mark Andrews * enclosing the string in double quotes also escape
9a36fb86f5019f25705d25ea729d03fcf8ecaa95Mark Andrews * at sign and semicolon.
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews isc_buffer_add(target, (unsigned int)(tp - (char *)region.base));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrewstxt_fromtext(isc_textregion_t *source, isc_buffer_t *target) {
7d62ddffbb4d1cc97b8d80b7ee4944554a57523eMark Andrews unsigned char *t;
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence isc_buffer_availableregion(target, &tregion);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Length byte.
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Maximum text string length.
7d62ddffbb4d1cc97b8d80b7ee4944554a57523eMark Andrews while (n-- != 0) {
ad493ef9ddb5a3e78e9d99f57abe75552f36a8f4Andreas Gustafsson c = (*s++) & 0xff;
7c0378745269fe49a05904935afc42b85528f53aDavid Lawrence if (escape && (d = decvalue((char)c)) != -1) {
7d62ddffbb4d1cc97b8d80b7ee4944554a57523eMark Andrews c = c * 10 + d;
7d62ddffbb4d1cc97b8d80b7ee4944554a57523eMark Andrews c = c * 10 + d;
7d62ddffbb4d1cc97b8d80b7ee4944554a57523eMark Andrews if (c > 255)
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews *tregion.base = (unsigned char)(t - tregion.base - 1);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrewstxt_fromwire(isc_buffer_t *source, isc_buffer_t *target) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews unsigned int n;
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence isc_buffer_availableregion(target, &tregion);
2383eb527269d333df4222da20e4b422c3662daaEvan Hunt * Conversion of TXT-like rdata fields without length limits.
7712d1660a308ec3de17f1ddbbf801eb0d663f3eEvan Huntmultitxt_totext(isc_region_t *source, isc_buffer_t *target) {
9fe8cca06537c45375c1e1d36b82501caf0ae090Francis Dupont while (n--) {
59d940391ce90963cd3f4b22201b3fca2ffda22aMark Andrews /* double quote, backslash */
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews isc_buffer_add(target, (unsigned int)(tp - (char *)region.base));
7712d1660a308ec3de17f1ddbbf801eb0d663f3eEvan Huntmultitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target) {
9fe8cca06537c45375c1e1d36b82501caf0ae090Francis Dupont isc_buffer_availableregion(target, &tregion);
9fe8cca06537c45375c1e1d36b82501caf0ae090Francis Dupont while (n != 0) {
9fe8cca06537c45375c1e1d36b82501caf0ae090Francis Dupont c = (*s++) & 0xff;
9fe8cca06537c45375c1e1d36b82501caf0ae090Francis Dupont if (escape && (d = decvalue((char)c)) != -1) {
9fe8cca06537c45375c1e1d36b82501caf0ae090Francis Dupont c = c * 10 + d;
9fe8cca06537c45375c1e1d36b82501caf0ae090Francis Dupont c = c * 10 + d;
ab973ec40cc7a79bbf930085b1293824caf73e7fFrancis Dupont isc_buffer_add(target, (unsigned int)(t - t0));
9fe8cca06537c45375c1e1d36b82501caf0ae090Francis Dupont } while (n != 0);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrewsname_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews if (dns_name_compare(origin, dns_rootname) == 0)
38b84a1fcfdbda4d1d0fdca409004ae83be2ace8Mark Andrews /* Master files should be case preserving. */
38b84a1fcfdbda4d1d0fdca409004ae83be2ace8Mark Andrews dns_name_getlabelsequence(name, l1 - l2, l2, target);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_getlabelsequence(name, 0, l1 - l2, target);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencestr_totext(const char *source, isc_buffer_t *target) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews unsigned int l;
330705066b03f6ce0bc08a4bbfc5d2418038c68dBrian Wellingtoninet_totext(int af, isc_region_t *src, isc_buffer_t *target) {
330705066b03f6ce0bc08a4bbfc5d2418038c68dBrian Wellington /* Note - inet_ntop doesn't do size checking on its input. */
330705066b03f6ce0bc08a4bbfc5d2418038c68dBrian Wellington if (inet_ntop(af, src->base, tmpbuf, sizeof(tmpbuf)) == NULL)
330705066b03f6ce0bc08a4bbfc5d2418038c68dBrian Wellington if (strlen(tmpbuf) > isc_buffer_availablelength(target))
26b0f58b6c4d65bc8b131debf40b8c376c2978bfBob Halley return((source->current == source->active) ? ISC_TRUE : ISC_FALSE);
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrencebuffer_fromregion(isc_buffer_t *buffer, isc_region_t *region) {
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence isc_buffer_init(buffer, region->base, region->length);
15330e4fa27c82ac04cc2ce234ec930e4b6b42d3Mark Andrewsuint32_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
15330e4fa27c82ac04cc2ce234ec930e4b6b42d3Mark Andrewsuint16_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
7c0378745269fe49a05904935afc42b85528f53aDavid Lawrence isc_buffer_putuint16(target, (isc_uint16_t)value);
5a219d878f0bd786e86da2c9b92999260dda3f8dAndreas Gustafssonuint8_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
7c0378745269fe49a05904935afc42b85528f53aDavid Lawrence isc_buffer_putuint8(target, (isc_uint8_t)value);
5466ce3f279d9fa83ce826bcdc9482bc591152aeAndreas Gustafssonname_tobuffer(dns_name_t *name, isc_buffer_t *target) {
5466ce3f279d9fa83ce826bcdc9482bc591152aeAndreas Gustafsson return (isc_buffer_copyregion(target, &r));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsuint16_consume_fromregion(isc_region_t *region) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews return ((region->base[0] << 8) | region->base[1]);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsuint8_consume_fromregion(isc_region_t *region) {
44a966dff66061ac3f266c6b451a70733eb78e82Mark Andrewsmem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) {
d4422ec231e58b60693620cf298276e47f04f0ecMark Andrews const char *s;
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence unsigned char c;
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence c = (unsigned char)value;
ffe74cc719aa0f10c38fbc1f2f3ea7db0960cb8fMark Andrews return (-1);
ffe74cc719aa0f10c38fbc1f2f3ea7db0960cb8fMark Andrews return (-1);
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews return (int)(s - hexdigits);
d4422ec231e58b60693620cf298276e47f04f0ecMark Andrews const char *s;
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence * isascii() is valid for full range of int values, no need to
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence * mask or cast.
8a17d1e7cdba9fdcf71fb2f821a954a251204105Mark Andrews return (-1);
8a17d1e7cdba9fdcf71fb2f821a954a251204105Mark Andrews return (-1);
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews return (int)(s - decdigits);
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" \
47b26abe77184f9bedc68e36bdad03332cf67570David Lawrence "abcdefghijklmnopqrstu";
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * Subroutines to convert between 8 bit binary bytes and printable ASCII.
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * Computes the number of bytes, and three kinds of simple checksums.
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * Incoming bytes are collected into 32-bit words, then printed in base 85:
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * exp(85,5) > exp(2,32)
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * The ASCII characters used are between '!' and 'u';
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * 'z' encodes 32-bit zero; 'x' is used to mark the end of encoded data.
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * Originally by Paul Rutter (philabs!per) and Joe Orost (petsd!joe) for
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * the atob/btoa programs, released with the compress program, in mod.sources.
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * Modified by Mike Schwartz 8/19/86 for use in BIND.
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * Modified to be re-entrant 3/2/99.
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic isc_result_t byte_atob(int c, isc_buffer_t *target,
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic isc_result_t putbyte(int c, isc_buffer_t *, struct state *state);
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic isc_result_t byte_btoa(int c, isc_buffer_t *, struct state *state);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Decode ASCII-encoded byte c into binary representation and
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * place into *bufp, advancing bufp.
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrewsbyte_atob(int c, isc_buffer_t *target, struct state *state) {
d4422ec231e58b60693620cf298276e47f04f0ecMark Andrews const char *s;
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews if (c == 'z') {
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews } else if ((s = strchr(atob_digits, c)) != NULL) {
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews RETERR(putbyte((word >> 24) & 0xff, target, state));
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews RETERR(putbyte((word >> 16) & 0xff, target, state));
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews RETERR(putbyte((word >> 8) & 0xff, target, state));
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Compute checksum info and place c into target.
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrewsputbyte(int c, isc_buffer_t *target, struct state *state) {
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Read the ASCII-encoded data from inbuf, of length inbuflen, and convert
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * it into T_UNSPEC (binary data) in outbuf, not to exceed outbuflen bytes;
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * outbuflen must be divisible by 4. (Note: this is because outbuf is filled
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * in 4 bytes at a time. If the actual data doesn't end on an even 4-byte
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * boundary, there will be no problem...it will be padded with 0 bytes, and
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * numbytes will indicate the correct number of bytes. The main point is
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * that since the buffer is filled in 4 bytes at a time, even if there is
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * not a full 4 bytes of data at the end, there has to be room to 0-pad the
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * data, so the buffer must be of size divisible by 4). Place the number of
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * output bytes in numbytes, and return a failure/success status.
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrewsatob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target) {
add4043305ca411202ed9cf1929a4179016515ceBrian Wellington RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews while (token.value.as_textregion.length != 0) {
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews if ((c = token.value.as_textregion.base[0]) == 'x') {
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews isc_textregion_consume(&token.value.as_textregion, 1);
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Number of bytes.
add4043305ca411202ed9cf1929a4179016515ceBrian Wellington RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
984d2bb9e5aaca7c946bc78354c12b1dd75ed00aMukund Sivaraman unsigned long padding = 4 - (token.value.as_ulong % 4);
984d2bb9e5aaca7c946bc78354c12b1dd75ed00aMukund Sivaraman if (isc_buffer_usedlength(target) < padding)
add4043305ca411202ed9cf1929a4179016515ceBrian Wellington RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews if (*e != 0)
add4043305ca411202ed9cf1929a4179016515ceBrian Wellington RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews if (*e != 0)
add4043305ca411202ed9cf1929a4179016515ceBrian Wellington RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews if (*e != 0)
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews if ((oeor != Ceor) || (osum != Csum) || (orot != Crot))
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Encode binary byte c into ASCII representation and place into *bufp,
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * advancing bufp.
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrewsbyte_btoa(int c, isc_buffer_t *target, struct state *state) {
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence * Because some don't support u_long.
e672951ed28b2e9cc7a19c3d7fa4a258382f981cAutomatic Updater tmpword -= (isc_int32_t)(85 * 85 * 85 * 85 * 32);
e672951ed28b2e9cc7a19c3d7fa4a258382f981cAutomatic Updater tmpword -= (isc_int32_t)(85 * 85 * 85 * 85 * 32);
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews tr.base[1] = atob_digits[tmpword / (85 * 85 * 85)];
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * Encode the binary data from inbuf, of length inbuflen, into a
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * target. Return success/failure status
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrewsbtoa_totext(unsigned char *inbuf, int inbuflen, isc_buffer_t *target) {
f3ca27e9fe307b55e35ea8d7b37351650630e5a3Andreas Gustafsson char buf[sizeof("x 2000000000 ffffffff ffffffff ffffffff")];
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * Put byte count and checksum information at end of buffer,
3a4ec3da9fa14511cbc3660f75817cfacb3f4d1eMark Andrews * delimited by 'x'
806c235ecf533b98d068b3f8df9d7abbe1e30cf9Mark Andrews snprintf(buf, sizeof(buf), "x %d %x %x %x", inbuflen, Ceor, Csum, Crot);
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencedefault_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *fmt,
fd4810861c0c0ccb9aebde94e9d289442b2630dbMark Andrewsfromtext_warneof(isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks) {
b6a0341bcb113e93bd0bc41a9f9a1fc117444da6Mark Andrews if (isc_lex_isfile(lexer) && callbacks != NULL) {
23cb957a81a51a9656917ea98d0ae56b7abdcaccMark Andrews const char *name = isc_lex_getsourcename(lexer);
23cb957a81a51a9656917ea98d0ae56b7abdcaccMark Andrews "%s:%lu: file does not end with newline",
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrewswarn_badmx(isc_token_t *token, isc_lex_t *lexer,
e672951ed28b2e9cc7a19c3d7fa4a258382f981cAutomatic Updater (*callbacks->warn)(callbacks, "%s:%u: warning: '%s': %s",
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewswarn_badname(dns_name_t *name, isc_lex_t *lexer,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_format(name, namebuf, sizeof(namebuf));
e672951ed28b2e9cc7a19c3d7fa4a258382f981cAutomatic Updater (*callbacks->warn)(callbacks, "%s:%u: warning: %s: %s",
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefromtext_error(void (*callback)(dns_rdatacallbacks_t *, const char *, ...),
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence dns_rdatacallbacks_t *callbacks, const char *name,
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence unsigned long line, isc_token_t *token, isc_result_t result)
20b20b23948b90cb2f7d7f402da99d09f837efd0David Lawrence (*callback)(callbacks, "%s: %s:%lu: near eol: %s",
20b20b23948b90cb2f7d7f402da99d09f837efd0David Lawrence (*callback)(callbacks, "%s: %s:%lu: near eof: %s",
20b20b23948b90cb2f7d7f402da99d09f837efd0David Lawrence (*callback)(callbacks, "%s: %s:%lu: near %lu: %s",
20b20b23948b90cb2f7d7f402da99d09f837efd0David Lawrence (*callback)(callbacks, "%s: %s:%lu: near '%s': %s",
20b20b23948b90cb2f7d7f402da99d09f837efd0David Lawrence (*callback)(callbacks, "dns_rdata_fromtext: %s:%lu: %s",
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_META) != 0)
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencedns_rdatatype_issingleton(dns_rdatatype_t type) {
3bb3b7ac462a90c2b8b1fb783324d800e2ba748cMichael Graff if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_SINGLETON)
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencedns_rdatatype_notquestion(dns_rdatatype_t type) {
7ec579cd5d07228c0d6cece58b80694ad8d59de9Michael Graff if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_NOTQUESTION)
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencedns_rdatatype_questiononly(dns_rdatatype_t type) {
7ec579cd5d07228c0d6cece58b80694ad8d59de9Michael Graff if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_QUESTIONONLY)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_ATPARENT) != 0)
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencedns_rdataclass_ismeta(dns_rdataclass_t rdclass) {
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrence return (ISC_FALSE); /* Assume it is not a meta class. */
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencedns_rdatatype_isdnssec(dns_rdatatype_t type) {
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_DNSSEC) != 0)
8abddcd3f24476b945419659e7cb73bcb970886bDavid Lawrencedns_rdatatype_iszonecutauth(dns_rdatatype_t type) {
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff & (DNS_RDATATYPEATTR_DNSSEC | DNS_RDATATYPEATTR_ZONECUTAUTH))
014892d86d30b7eceb0003d51788f9b5cadfc1bfAndreas Gustafsson if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_UNKNOWN)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉dns_rdata_exists(dns_rdata_t *rdata, dns_rdatatype_t type) {
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉dns_rdata_notexist(dns_rdata_t *rdata, dns_rdatatype_t type) {
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉dns_rdata_deleterrset(dns_rdata_t *rdata, dns_rdatatype_t type) {
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉dns_rdata_makedelete(dns_rdata_t *rdata) {
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉dns_rdata_updateop(dns_rdata_t *rdata, dns_section_t section) {
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 return ("domain doesn't exist");
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 return ("rrset doesn't exist");
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 return ("domain exists");
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 return ("rrset exists (value independent)");
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 return ("rrset exists (value dependent)");
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 return ("delete");
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 return ("delete all rrsets");
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 return ("delete rrset");
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 return ("add");
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 return ("invalid");