message.c revision db9781d4a2ed15c4b34bb5c97ea68b8f598992fc
12bfbed87cfffa65ac300b72c5665ab38a355c2fAutomatic Updater * Copyright (C) 1999-2016 Internet Systems Consortium, Inc. ("ISC")
c6fb85f9500350e5ce58c9a24f5d264c8a8bd6f4Automatic Updater * This Source Code Form is subject to the terms of the Mozilla Public
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt * License, v. 2.0. If a copy of the MPL was not distributed with this
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt * file, You can obtain one at http://mozilla.org/MPL/2.0/.
0ae35ecf053a29f61ad6b3659ac2445cf2c3f663Automatic Updater#include <isc/string.h> /* Required for HP/UX (and others?) */
12bfbed87cfffa65ac300b72c5665ab38a355c2fAutomatic Updaterhexdump(const char *msg, const char *msg2, void *base, size_t len) {
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt unsigned char *p;
0ae35ecf053a29f61ad6b3659ac2445cf2c3f663Automatic Updater unsigned int cnt;
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt printf("*** %s [%s] (%u bytes @ %p)\n", msg, msg2, len, base);
0ae35ecf053a29f61ad6b3659ac2445cf2c3f663Automatic Updater printf(" %02x %c", *p, (isprint(*p) ? *p : ' '));
12bfbed87cfffa65ac300b72c5665ab38a355c2fAutomatic Updater#define DNS_MESSAGE_EDNSRCODE_MASK 0xff000000U
12bfbed87cfffa65ac300b72c5665ab38a355c2fAutomatic Updater#define DNS_MESSAGE_EDNSVERSION_MASK 0x00ff0000U
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt#define VALID_NAMED_SECTION(s) (((s) > DNS_SECTION_ANY) \
12bfbed87cfffa65ac300b72c5665ab38a355c2fAutomatic Updater#define VALID_SECTION(s) (((s) >= DNS_SECTION_ANY) \
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt return(ISC_R_NOSPACE); else \
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt#define VALID_PSEUDOSECTION(s) (((s) >= DNS_PSEUDOSECTION_ANY) \
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt#define OPTOUT(x) (((x)->attributes & DNS_RDATASETATTR_OPTOUT) != 0)
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt * This is the size of each individual scratchpad buffer, and the numbers
static const char *sectiontext[] = {
static const char *updsectiontext[] = {
static const char *opcodetext[] = {
struct dns_msgblock {
unsigned int count;
unsigned int remaining;
static inline dns_msgblock_t *
static inline dns_msgblock_t *
unsigned int count)
unsigned int length;
return (NULL);
return (block);
void *ptr;
return (NULL);
+ sizeof(dns_msgblock_t)
return (ptr);
unsigned int length;
static inline isc_result_t
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static inline isc_buffer_t *
return (dynbuf);
static inline dns_rdata_t *
return (rdata);
return (NULL);
return (rdata);
static inline dns_rdatalist_t *
goto out;
sizeof(dns_rdatalist_t),
return (NULL);
out:
return (rdatalist);
static inline dns_offsets_t *
sizeof(dns_offsets_t),
return (NULL);
return (offsets);
m->id = 0;
m->flags = 0;
m->rcode = 0;
m->opcode = 0;
m->rdclass = 0;
for (i = 0; i < DNS_SECTION_MAX; i++) {
m->counts[i] = 0;
m->opt_reserved = 0;
m->sig_reserved = 0;
m->reserved = 0;
m->timeadjust = 0;
msginitheader(m);
msginitprivate(m);
msginittsig(m);
m->header_ok = 0;
m->question_ok = 0;
m->tcp_continuation = 0;
m->verified_sig = 0;
m->verify_attempted = 0;
m->free_query = 0;
m->free_saved = 0;
m->cc_ok = 0;
m->cc_bad = 0;
m->tkey = 0;
m->rdclass_set = 0;
if (replying) {
if (!everything) {
if (!everything)
dns_message_t *m;
if (m == NULL)
return (ISC_R_NOMEMORY);
msginit(m);
for (i = 0; i < DNS_SECTION_MAX; i++)
goto cleanup;
&m->rdspool);
goto cleanup;
goto cleanup;
*msgp = m;
return (ISC_R_SUCCESS);
m->magic = 0;
return (ISC_R_NOMEMORY);
static isc_result_t
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
static isc_result_t
unsigned int tries;
tries = 0;
scratch);
tries++;
return (result);
return (result);
return (ISC_R_UNEXPECTED);
static isc_result_t
unsigned int tries;
unsigned int trysize;
tries = 0;
trysize = 0;
scratch);
if (tries == 0) {
return (ISC_R_NOSPACE);
tries++;
return (result);
return (result);
#define DO_ERROR(r) \
if (best_effort) \
result = r; \
goto cleanup; \
static isc_result_t
unsigned int options)
isc_region_t r;
unsigned int count;
return (ISC_R_NOMEMORY);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
if (seen_problem)
return (DNS_R_RECOVERABLE);
return (ISC_R_SUCCESS);
if (free_name)
return (result);
static isc_boolean_t
return (ISC_FALSE);
static isc_result_t
isc_region_t r;
return (ISC_R_NOMEMORY);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
if (rdatalen != 0) {
goto cleanup;
goto cleanup;
if (covers == 0)
if (covers == 0) {
covers = 0;
ISC_FALSE)) {
goto cleanup;
&rdatalist);
goto cleanup;
goto cleanup;
== ISC_R_SUCCESS);
if (seen_problem) {
if (free_name)
if (free_rdataset)
if (seen_problem)
return (DNS_R_RECOVERABLE);
return (ISC_R_SUCCESS);
if (free_name)
if (free_rdataset)
return (result);
unsigned int options)
isc_region_t r;
return (ISC_R_UNEXPECTEDEND);
goto truncated;
return (ret);
goto truncated;
return (ret);
goto truncated;
return (ret);
goto truncated;
return (ret);
if (r.length != 0) {
r.length);
return (ISC_R_NOMEMORY);
return (DNS_R_RECOVERABLE);
return (DNS_R_RECOVERABLE);
return (ISC_R_SUCCESS);
isc_region_t r;
return (ISC_R_NOSPACE);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
isc_region_t r;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static inline isc_boolean_t
int pass_needed;
return (ISC_FALSE);
case dns_rdatatype_a:
case dns_rdatatype_aaaa:
case dns_rdatatype_rrsig:
case dns_rdatatype_dnskey:
return (ISC_FALSE);
return (ISC_TRUE);
#ifdef ALLOW_FILTER_AAAA
static inline isc_boolean_t
return (ISC_FALSE);
case dns_rdatatype_ns:
return (ISC_FALSE);
case dns_rdatatype_aaaa:
return (ISC_FALSE);
case dns_rdatatype_rrsig:
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
static isc_result_t
return (ISC_R_NOSPACE);
return (result);
unsigned int options)
int pass;
unsigned int rd_options;
rd_options = 0;
return (ISC_R_NOSPACE);
total = 0;
count = 0;
if (partial)
name,
&count,
NULL);
name,
&count);
return (result);
return (result);
return (ISC_R_SUCCESS);
DNS_RDATASETATTR_RENDERED) != 0)
goto next;
goto next;
#ifdef ALLOW_FILTER_AAAA
goto next;
count = 0;
if (partial)
name,
&count,
NULL);
name,
&count);
return (result);
return (result);
next:
} while (--pass != 0);
return (ISC_R_SUCCESS);
isc_region_t r;
isc_region_t r;
int result;
unsigned int count;
return (DNS_R_FORMERR);
return (result);
count = 0;
return (result);
return (result);
count = 0;
return (result);
return (result);
count = 0;
return (result);
return (ISC_R_SUCCESS);
for (i = 0; i < DNS_SECTION_MAX; i++) {
return (ISC_R_NOMORE);
return (ISC_R_SUCCESS);
return (ISC_R_NOMORE);
return (ISC_R_SUCCESS);
return (DNS_R_NXDOMAIN);
return (result);
return (ISC_R_SUCCESS);
return (DNS_R_NXRRSET);
return (result);
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
unsigned int *flagsp)
isc_region_t r;
unsigned int flags;
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
unsigned int clear_from;
return (DNS_R_FORMERR);
else if (want_question_section) {
return (DNS_R_FORMERR);
unsigned int otherlen = 0;
return (result);
return (ISC_R_SUCCESS);
goto cleanup;
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
return (result);
return (ISC_R_SUCCESS);
isc_region_t r;
return (ISC_R_SUCCESS);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
return (result);
return (ISC_R_NOMEMORY);
isc_region_t r;
return (ISC_R_SUCCESS);
return (result);
return (result);
return (ISC_R_SUCCESS);
isc_region_t r;
return (result);
return (result);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (DNS_R_NOTVERIFIEDYET);
return (result);
return (result);
return (result);
#ifdef SKAN_MSG_DEBUG
return (ISC_R_SUCCESS);
#ifdef SKAN_MSG_DEBUG
return (ISC_R_UNEXPECTEDEND);
return (result);
return (DNS_R_KEYUNAUTHORIZED);
goto freesig;
goto freesig;
return (result);
return (ISC_R_SUCCESS);
return (result);
if (seensoa &&
target);
target);
return (result);
return (result);
static isc_result_t
return (DNS_R_OPTERR);
return (DNS_R_OPTERR);
return (DNS_R_OPTERR);
for (i = 0; i < addrbytes; i ++)
switch (family) {
return (DNS_R_OPTERR);
return (DNS_R_OPTERR);
return (DNS_R_OPTERR);
return (DNS_R_OPTERR);
return (ISC_R_SUCCESS);
unsigned char *optdata;
switch (section) {
case DNS_PSEUDOSECTION_OPT:
return (ISC_R_SUCCESS);
if (mbz != 0) {
return (ISC_R_SUCCESS);
optlen);
return (result);
target);
return (result);
if (optlen != 0) {
for (i = 0; i < optlen; i++) {
const char *sep;
switch (optcode) {
case DNS_OPT_COOKIE:
return (ISC_R_NOSPACE);
for (i = 0; i < optlen; i++) {
&optdata[i],
return (ISC_R_SUCCESS);
case DNS_PSEUDOSECTION_TSIG:
return (ISC_R_SUCCESS);
return (result);
case DNS_PSEUDOSECTION_SIG0:
return (ISC_R_SUCCESS);
return (result);
return (ISC_R_UNEXPECTED);
return (result);
return (result);
return (result);
return (result);
return (result);
return (result);
return (result);
return (result);
return (ISC_R_SUCCESS);
const void *order_arg)
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
buf);
unsigned int len = 0, i;
return (result);
goto cleanup;
goto cleanup;
if (count != 0U) {
for (i = 0; i < count; i++)
goto cleanup;
goto cleanup;
for (i = 0; i < count; i++) {
return (ISC_R_SUCCESS);
return (result);