Removed all code within #ifdef DNS_OPT_NEWCODES*.

It was the last thing being sanitized out of releases; removing
it makes it possible to eliminate the sanitation process.
This commit is contained in:
Andreas Gustafsson
2001-10-01 18:54:05 +00:00
parent 792de65053
commit 9066d09c3e
11 changed files with 12 additions and 726 deletions
+3 -26
View File
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dig.c,v 1.167 2001/09/26 00:38:37 gson Exp $ */
/* $Id: dig.c,v 1.168 2001/10/01 18:53:51 gson Exp $ */
#include <config.h>
#include <stdlib.h>
@@ -884,32 +884,9 @@ plus_option(char *option, isc_boolean_t is_batchfile,
}
break;
case 'v':
#ifdef DNS_OPT_NEWCODES_LIVE
switch (cmd[1]) {
default:
case 'c': /* vc, and default */
#endif /* DNS_OPT_NEWCODES_LIVE */
if (!is_batchfile)
lookup->tcp_mode = state;
break;
#ifdef DNS_OPT_NEWCODES_LIVE
case 'i': /* view */
if (value == NULL)
goto need_value;
if (!state)
goto invalid_option;
strncpy(lookup->viewname, value, MXNAME);
break;
}
if (!is_batchfile)
lookup->tcp_mode = state;
break;
case 'z': /* zone */
if (value == NULL)
goto need_value;
if (!state)
goto invalid_option;
strncpy(lookup->zonename, value, MXNAME);
break;
#endif /* DNS_OPT_NEWCODES_LIVE */
default:
invalid_option:
need_value:
+2 -88
View File
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dighost.c,v 1.228 2001/09/27 17:53:38 bwelling Exp $ */
/* $Id: dighost.c,v 1.229 2001/10/01 18:53:53 gson Exp $ */
/*
* Notice to programmers: Do not use this code as an example of how to
@@ -36,9 +36,6 @@
#include <dns/fixedname.h>
#include <dns/message.h>
#include <dns/name.h>
#ifdef DNS_OPT_NEWCODES
#include <dns/opt.h>
#endif /* DNS_OPT_NEWCODES */
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatalist.h>
@@ -424,10 +421,6 @@ make_empty_lookup(void) {
looknew->section_authority = ISC_TRUE;
looknew->section_additional = ISC_TRUE;
looknew->new_search = ISC_FALSE;
#ifdef DNS_OPT_NEWCODES_LIVE
looknew->zonename[0] = 0;
looknew->viewname[0] = 0;
#endif /* DNS_OPT_NEWCODES_LIVE */
ISC_LINK_INIT(looknew, link);
ISC_LIST_INIT(looknew->q);
ISC_LIST_INIT(looknew->my_server_list);
@@ -483,10 +476,6 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
looknew->section_authority = lookold->section_authority;
looknew->section_additional = lookold->section_additional;
looknew->retries = lookold->retries;
#ifdef DNS_OPT_NEWCODES_LIVE
strncpy(looknew->viewname, lookold->viewname, MXNAME);
strncpy(looknew->zonename, lookold->zonename, MXNAME);
#endif /* DNS_OPT_NEWCODES_LIVE */
if (servers)
clone_server_list(lookold->my_server_list,
@@ -789,20 +778,11 @@ setup_libs(void) {
* options are UDP buffer size and the DO bit.
*/
static void
add_opt(dns_message_t *msg, isc_uint16_t udpsize, isc_boolean_t dnssec
#ifdef DNS_OPT_NEWCODES_LIVE
, dns_optlist_t optlist
#endif /* DNS_OPT_NEWCODES_LIVE */
)
{
add_opt(dns_message_t *msg, isc_uint16_t udpsize, isc_boolean_t dnssec) {
dns_rdataset_t *rdataset = NULL;
dns_rdatalist_t *rdatalist = NULL;
dns_rdata_t *rdata = NULL;
isc_result_t result;
#ifdef DNS_OPT_NEWCODES_LIVE
isc_buffer_t *rdatabuf = NULL;
unsigned int i, optsize = 0;
#endif /* DNS_OPT_NEWCODES_LIVE */
debug("add_opt()");
result = dns_message_gettemprdataset(msg, &rdataset);
@@ -822,15 +802,6 @@ add_opt(dns_message_t *msg, isc_uint16_t udpsize, isc_boolean_t dnssec
rdatalist->ttl = DNS_MESSAGEEXTFLAG_DO;
rdata->data = NULL;
rdata->length = 0;
#ifdef DNS_OPT_NEWCODES_LIVE
for (i = 0; i < optlist.used; i++)
optsize += optlist.attrs[i].value.length + 4;
result = isc_buffer_allocate(mctx, &rdatabuf, optsize);
check_result(result, "isc_buffer_allocate");
result = dns_opt_add(rdata, &optlist, rdatabuf);
check_result(result, "dns_opt_add");
dns_message_takebuffer(msg, &rdatabuf);
#endif /* DNS_OPT_NEWCODES_LIVE */
ISC_LIST_INIT(rdatalist->rdata);
ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
dns_rdatalist_tordataset(rdatalist, rdataset);
@@ -1417,67 +1388,10 @@ setup_lookup(dig_lookup_t *lookup) {
result = dns_message_renderbegin(lookup->sendmsg, &cctx,
&lookup->sendbuf);
check_result(result, "dns_message_renderbegin");
#ifndef DNS_OPT_NEWCODES_LIVE
if (lookup->udpsize > 0 || lookup->dnssec) {
#else /* DNS_OPT_NEWCODES_LIVE */
if (lookup->udpsize > 0 || || lookup->dnssec ||
lookup->zonename[0] != 0 || lookup->viewname[0] != 0) {
dns_fixedname_t fname;
isc_buffer_t namebuf, *wirebuf = NULL;
dns_compress_t zcctx;
dns_optlist_t optlist;
dns_optattr_t optattr[2];
#endif /* DNS_OPT_NEWCODES_LIVE */
if (lookup->udpsize == 0)
lookup->udpsize = 2048;
#ifdef DNS_OPT_NEWCODES_LIVE
optlist.size = 2;
optlist.used = 0;
optlist.next = 0;
optlist.attrs = optattr;
if (lookup->zonename[0] != 0) {
optattr[optlist.used].code = DNS_OPTCODE_ZONE;
dns_fixedname_init(&fname);
isc_buffer_init(&namebuf, lookup->zonename,
strlen(lookup->zonename));
isc_buffer_add(&namebuf, strlen(lookup->zonename));
result = dns_name_fromtext(&(fname.name), &namebuf,
dns_rootname, ISC_FALSE,
NULL);
check_result(result, "; illegal zone option");
result = dns_compress_init(&zcctx, 0, mctx);
check_result(result, "dns_compress_init");
result = isc_buffer_allocate(mctx, &wirebuf,
MXNAME);
check_result(result, "isc_buffer_allocate");
result = dns_name_towire(&(fname.name), &zcctx,
wirebuf);
check_result(result, "dns_name_towire");
optattr[optlist.used].value.base =
isc_buffer_base(wirebuf);
optattr[optlist.used].value.length =
isc_buffer_usedlength(wirebuf);
optlist.used++;
dns_compress_invalidate(&zcctx);
}
if (lookup->viewname[0] != 0) {
optattr[optlist.used].code = DNS_OPTCODE_VIEW;
optattr[optlist.used].value.base =
lookup->viewname;
optattr[optlist.used].value.length =
strlen(lookup->viewname);
optlist.used++;
}
add_opt(lookup->sendmsg, lookup->udpsize, lookup->dnssec,
optlist);
if (wirebuf != NULL)
isc_buffer_free(&wirebuf);
#else /* DNS_OPT_NEWCODES_LIVE */
add_opt(lookup->sendmsg, lookup->udpsize, lookup->dnssec);
#endif /* DNS_OPT_NEWCODES_LIVE */
}
result = dns_message_rendersection(lookup->sendmsg,
+1 -5
View File
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dig.h,v 1.72 2001/08/29 18:57:12 gson Exp $ */
/* $Id: dig.h,v 1.73 2001/10/01 18:53:54 gson Exp $ */
#ifndef DIG_H
#define DIG_H
@@ -138,10 +138,6 @@ struct dig_lookup {
isc_uint32_t ixfr_serial;
isc_buffer_t rdatabuf;
char rdatastore[MXNAME];
#ifdef DNS_OPT_NEWCODES_LIVE
char zonename[MXNAME];
char viewname[MXNAME];
#endif /* DNS_OPT_NEWCODES_LIVE */
dst_context_t *tsigctx;
isc_buffer_t *querysig;
isc_uint32_t msgcounter;
+1 -185
View File
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: client.c,v 1.178 2001/09/19 23:08:18 gson Exp $ */
/* $Id: client.c,v 1.179 2001/10/01 18:53:56 gson Exp $ */
#include <config.h>
@@ -33,9 +33,6 @@
#include <dns/dispatch.h>
#include <dns/events.h>
#include <dns/message.h>
#ifdef DNS_OPT_NEWCODES
#include <dns/opt.h>
#endif /* DNS_OPT_NEWCODES */
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatalist.h>
@@ -246,15 +243,6 @@ client_free(ns_client_t *client) {
dns_rdataset_disassociate(client->opt);
dns_message_puttemprdataset(client->message, &client->opt);
}
#ifdef DNS_OPT_NEWCODES
if (client->opt_zone != NULL) {
isc_mem_put(client->mctx, client->opt_zone,
sizeof(*client->opt_zone));
client->opt_zone = NULL;
}
if (client->opt_view != NULL)
isc_buffer_free(&client->opt_view);
#endif /* DNS_OPT_NEWCODES */
dns_message_destroy(&client->message);
if (client->manager != NULL) {
manager = client->manager;
@@ -986,75 +974,6 @@ ns_client_error(ns_client_t *client, isc_result_t result) {
ns_client_send(client);
}
#ifdef DNS_OPT_NEWCODES
static isc_result_t
client_addoptattrs(ns_client_t *client, dns_rdata_t *rdata) {
isc_result_t result;
isc_buffer_t *zonebuf = NULL, *buf = NULL;
dns_optlist_t attrlist;
dns_optattr_t attrs[CLIENT_NUMATTRS];
dns_compress_t cctx;
int i, sizeneeded = 0;
result = dns_compress_init(&cctx, 0, client->mctx);
if (result != ISC_R_SUCCESS)
goto fail1;
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
attrlist.size=2;
attrlist.used=0;
attrlist.attrs=attrs;
for (i=0; i<CLIENT_NUMATTRS; i++) {
attrs[i].code = 0;
attrs[i].value.base = NULL;
attrs[i].value.length = 0;
}
if (client->opt_zone != NULL) {
result = isc_buffer_allocate(client->mctx, &zonebuf,
DNS_NAME_MAXWIRE);
if (result != ISC_R_SUCCESS)
goto fail2;
result = dns_name_towire(dns_fixedname_name(client->opt_zone),
&cctx, zonebuf);
if (result != ISC_R_SUCCESS)
goto fail2;
attrs[attrlist.used].code = DNS_OPTCODE_ZONE;
attrs[attrlist.used].value.base = isc_buffer_base(zonebuf);
attrs[attrlist.used].value.length =
isc_buffer_usedlength(zonebuf);
attrlist.used++;
sizeneeded += 4 + isc_buffer_usedlength(zonebuf);
}
if (client->opt_view != NULL) {
attrs[attrlist.used].code = DNS_OPTCODE_VIEW;
attrs[attrlist.used].value.base =
isc_buffer_base(client->opt_view);
attrs[attrlist.used].value.length =
isc_buffer_usedlength(client->opt_view);
attrlist.used++;
sizeneeded += 4 + isc_buffer_usedlength(client->opt_view);
}
if (sizeneeded == 0) {
result = ISC_R_SUCCESS;
goto fail2;
}
result = isc_buffer_allocate(client->mctx, &buf, sizeneeded+1);
if (result != ISC_R_SUCCESS)
goto fail2;
result = dns_opt_add(rdata, &attrlist, buf);
if (result != ISC_R_SUCCESS)
goto fail2;
dns_message_takebuffer(client->message, &buf);
fail2:
dns_compress_invalidate(&cctx);
fail1:
if (buf != NULL)
isc_buffer_free(&buf);
if (zonebuf != NULL)
isc_buffer_free(&zonebuf);
return (result);
}
#endif /* DNS_OPT_NEWCODES */
static inline isc_result_t
client_addopt(ns_client_t *client) {
dns_rdataset_t *rdataset;
@@ -1100,13 +1019,6 @@ client_addopt(ns_client_t *client) {
rdata->type = rdatalist->type;
rdata->flags = 0;
#ifdef DNS_OPT_NEWCODES
/*
* Set the attributes
*/
client_addoptattrs(client, rdata);
#endif /* DNS_OPT_NEWCODES */
ISC_LIST_INIT(rdatalist->rdata);
ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
dns_rdatalist_tordataset(rdatalist, rdataset);
@@ -1116,80 +1028,6 @@ client_addopt(ns_client_t *client) {
return (ISC_R_SUCCESS);
}
#ifdef DNS_OPT_NEWCODES
static void
client_getoptattrs(ns_client_t *client, dns_rdataset_t *opt) {
dns_optlist_t optlist;
dns_optattr_t optattr;
isc_result_t result, iresult;
isc_buffer_t zonebuf;
dns_decompress_t dctx;
/* If an old set of opts are still around, free them. */
if (client->opt_zone != NULL) {
isc_mem_put(client->mctx, client->opt_zone,
sizeof(*client->opt_zone));
client->opt_zone = NULL;
}
if (client->opt_view != NULL)
isc_buffer_free(&client->opt_view);
/*
* If there are any options, extract them here
*/
optlist.size = 1;
optlist.used = 0;
optlist.next = 0;
optlist.attrs = &optattr;
do {
result = dns_opt_decodeall(&optlist, opt);
if (result == ISC_R_SUCCESS ||
result == DNS_R_MOREDATA) {
switch (optattr.code) {
case DNS_OPTCODE_ZONE:
dns_decompress_init(&dctx, 0,
DNS_DECOMPRESS_NONE);
client->opt_zone = isc_mem_get(
client->mctx,
sizeof(*client->opt_zone));
if (client->opt_zone == NULL)
goto zonefail1;
dns_fixedname_init(client->opt_zone);
isc_buffer_init(&zonebuf,
optattr.value.base,
optattr.value.length);
isc_buffer_add(&zonebuf,optattr.value.length);
isc_buffer_setactive(&zonebuf,
optattr.value.length);
iresult = dns_name_fromwire(
dns_fixedname_name(
client->opt_zone),
&zonebuf,
&dctx, ISC_FALSE,
NULL);
if (iresult != ISC_R_SUCCESS) {
dns_fixedname_invalidate(
client->opt_zone);
zonefail1:
dns_decompress_invalidate(&dctx);
}
break;
case DNS_OPTCODE_VIEW:
iresult = isc_buffer_allocate(client->mctx,
&client->opt_view,
optattr.value.length);
if (iresult != ISC_R_SUCCESS)
break;
isc_buffer_putmem(client->opt_view,
optattr.value.base,
optattr.value.length);
break;
}
}
} while (result == DNS_R_MOREDATA);
}
#endif /* DNS_OPT_NEWCODES */
static inline isc_boolean_t
allowed(isc_netaddr_t *addr, dns_acl_t *acl) {
int match;
@@ -1391,28 +1229,10 @@ client_request(isc_task_t *task, isc_event_t *event) {
if (client->udpsize < 512)
client->udpsize = 512;
#ifdef DNS_OPT_NEWCODES
/*
* Get the flags out of the OPT record.
*/
client->extflags = DNS_OPT_FLAGS(opt);
/*
* Set up the rest of the opt stuff
*/
client_getoptattrs(client, opt);
/*
* If we're using a fixed zone option (opt_zone), set it to
* allow glue here.
*/
if (client->opt_zone != NULL)
client->query.dboptions |= DNS_DBFIND_GLUEOK;
#else /* DNS_OPT_NEWCODES */
/*
* Get the flags out of the OPT record.
*/
client->extflags = (isc_uint16_t)(opt->ttl & 0xFFFF);
#endif /* DNS_OPT_NEWCODES */
/*
* Create an OPT for our reply.
@@ -1714,10 +1534,6 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp)
client->opt = NULL;
client->udpsize = 512;
client->extflags = 0;
#ifdef DNS_OPT_NEWCODES
client->opt_zone = NULL;
client->opt_view = NULL;
#endif /* DNS_OPT_NEWCODES */
client->next = NULL;
client->shutdown = NULL;
client->shutdown_arg = NULL;
+1 -16
View File
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: client.h,v 1.60 2001/08/28 03:57:59 marka Exp $ */
/* $Id: client.h,v 1.61 2001/10/01 18:53:58 gson Exp $ */
#ifndef NAMED_CLIENT_H
#define NAMED_CLIENT_H 1
@@ -72,9 +72,6 @@
#include <dns/types.h>
#include <dns/tcpmsg.h>
#include <dns/fixedname.h>
#ifdef DNS_OPT_NEWCODES
#include <dns/opt.h>
#endif /* DNS_OPT_NEWCODES */
#include <named/types.h>
#include <named/query.h>
@@ -114,10 +111,6 @@ struct ns_client {
dns_rdataset_t * opt;
isc_uint16_t udpsize;
isc_uint16_t extflags;
#ifdef DNS_OPT_NEWCODES
dns_fixedname_t * opt_zone;
isc_buffer_t * opt_view;
#endif /* DNS_OPT_NEWCODES */
void (*next)(ns_client_t *);
void (*shutdown)(void *arg, isc_result_t result);
void *shutdown_arg;
@@ -152,14 +145,6 @@ struct ns_client {
client_list_t *list;
};
#ifdef DNS_OPT_NEWCODES
/*
* Number of attr fields (opt_zone, opt_view) in above structure. Used in
* client_addoptattrs()
*/
#define CLIENT_NUMATTRS 2
#endif /* DNS_OPT_NEWCODES */
#define NS_CLIENT_MAGIC ISC_MAGIC('N','S','C','c')
#define NS_CLIENT_VALID(c) ISC_MAGIC_VALID(c, NS_CLIENT_MAGIC)
+1 -44
View File
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: query.c,v 1.202 2001/09/21 19:08:05 gson Exp $ */
/* $Id: query.c,v 1.203 2001/10/01 18:53:57 gson Exp $ */
#include <config.h>
@@ -29,9 +29,6 @@
#include <dns/db.h>
#include <dns/events.h>
#include <dns/message.h>
#ifdef DNS_OPT_NEWCODES
#include <dns/opt.h>
#endif /* DNS_OPT_NEWCODES */
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatalist.h>
@@ -820,25 +817,6 @@ query_getdb(ns_client_t *client, dns_name_t *name, unsigned int options,
{
isc_result_t result;
#ifdef DNS_OPT_NEWCODES_LIVE
if (client->opt_zone != NULL) {
result = query_getzonedb(client, &(client->opt_zone->name),
options, zonep, dbp, versionp);
if (result == ISC_R_SUCCESS)
*is_zonep = ISC_TRUE;
else
result = DNS_R_REFUSED;
} else {
result = query_getzonedb(client, name, options, zonep, dbp,
versionp);
if (result == ISC_R_SUCCESS) {
*is_zonep = ISC_TRUE;
} else if (result == ISC_R_NOTFOUND) {
result = query_getcachedb(client, dbp, options);
*is_zonep = ISC_FALSE;
}
}
#else /* DNS_OPT_NEWCODES_LIVE */
result = query_getzonedb(client, name, options, zonep, dbp, versionp);
if (result == ISC_R_SUCCESS) {
*is_zonep = ISC_TRUE;
@@ -846,7 +824,6 @@ query_getdb(ns_client_t *client, dns_name_t *name, unsigned int options,
result = query_getcachedb(client, dbp, options);
*is_zonep = ISC_FALSE;
}
#endif /* DNS_OPT_NEWCODES_LIVE */
return (result);
}
@@ -2600,11 +2577,6 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
*/
break;
case DNS_R_GLUE:
#ifdef DNS_OPT_NEWCODES_LIVE
if (client->opt_zone != NULL)
break;
/* Fallthrough if we don't have opt_zone */
#endif /* DNS_OPT_NEWCODES_LIVE */
case DNS_R_ZONECUT:
/*
* These cases are handled in the main line below.
@@ -2613,13 +2585,6 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
authoritative = ISC_FALSE;
break;
case ISC_R_NOTFOUND:
#ifdef DNS_OPT_NEWCODES_LIVE
/*
* If we've passed in opt_zone, don't try anything more.
*/
if (client->opt_zone != NULL)
break;
#endif /* DNS_OPT_NEWCODES_LIVE */
/*
* The cache doesn't even have the root NS. Get them from
* the hints DB.
@@ -2677,14 +2642,6 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
*/
/* FALLTHROUGH */
case DNS_R_DELEGATION:
#ifdef DNS_OPT_NEWCODES_LIVE
/*
* If we've passed in opt_zone, don't try anything more.
*/
if (client->opt_zone != NULL) {
break;
}
#endif /* DNS_OPT_NEWCODES_LIVE */
authoritative = ISC_FALSE;
if (is_zone) {
/*
+1 -6
View File
@@ -13,7 +13,7 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# $Id: Makefile.in,v 1.127 2001/09/20 15:16:53 marka Exp $
# $Id: Makefile.in,v 1.128 2001/10/01 18:54:00 gson Exp $
srcdir = @srcdir@
VPATH = @srcdir@
@@ -32,11 +32,6 @@ CWARNINGS =
LIBS = @LIBS@
#ifdef DNS_OPT_NEWCODES
OTHEROBJS = opt.@O@
OTHERSRCS = opt.c
#endif /* DNS_OPT_NEWCODES */
# Alphabetically
DSTOBJS = sec/dst/dst_api.@O@ \
-86
View File
@@ -1,86 +0,0 @@
/*
* Copyright (C) 2000, 2001 Internet Software Consortium.
*
* 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.
*
* 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.
*/
/* $Id: opt.h,v 1.8 2001/03/12 22:27:15 bwelling Exp $ */
/* DNS_OPT_NEWCODES_KEEP */
#ifndef DNS_OPT_H
#define DNS_OPT_H 1
#include <isc/lang.h>
#include <isc/result.h>
#include <isc/mem.h>
#include <isc/region.h>
#include <isc/types.h>
#include <dns/rdataset.h>
#include <dns/message.h>
/*
* XXX WARNING XXX These codes have not yet been assigned by IANA.
* These are here as placekeepers ONLY.
* Hide these definitions and anything that uses them behind a #define
* which happens only in internal debugging code.
* This #ifdef will go away once these are defined by IANA.
*/
#ifdef DNS_OPT_NEWCODES
#define DNS_OPTCODE_ZONE 0xfff0
#define DNS_OPTCODE_VIEW 0xfff1
#endif /* DNS_OPT_NEWCODES */
#define DNS_OPT_FLAGS(opt) ((isc_uint16_t)((opt)->ttl & 0xFFFF))
/*
* OPT records contain a series of attributes which contain different types.
* These structures are used for holding the individual attribute
* records.
*/
typedef struct dns_optattr {
isc_uint16_t code;
isc_region_t value;
} dns_optattr_t;
typedef struct dns_optlist {
unsigned int size;
unsigned int used;
unsigned int next;
dns_optattr_t *attrs;
} dns_optlist_t;
isc_result_t
dns_opt_decode(dns_optlist_t *optlist, dns_rdataset_t *optset,
isc_uint16_t code);
isc_result_t
dns_opt_decodeall(dns_optlist_t *optlist, dns_rdataset_t *optset);
isc_result_t
dns_opt_add(dns_rdata_t *rdata, dns_optlist_t *optlist,
isc_buffer_t *target);
isc_result_t
dns_opt_attrtotext(dns_optattr_t *attr, isc_buffer_t *target,
dns_messagetextflag_t flags);
isc_result_t
dns_opt_totext(dns_rdataset_t *opt, isc_buffer_t *target,
dns_messagetextflag_t flags);
ISC_LANG_ENDDECLS
#endif /* DNS_OPT_H */
+2 -12
View File
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: message.c,v 1.194 2001/07/10 20:09:24 gson Exp $ */
/* $Id: message.c,v 1.195 2001/10/01 18:54:01 gson Exp $ */
/***
*** Imports
@@ -33,9 +33,6 @@
#include <dns/log.h>
#include <dns/masterdump.h>
#include <dns/message.h>
#ifdef DNS_OPT_NEWCODES
#include <dns/opt.h>
#endif /* DNS_OPT_NEWCODES */
#include <dns/rdata.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
@@ -2892,9 +2889,7 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
dns_rdataset_t *ps = NULL;
dns_name_t *name = NULL;
isc_result_t result;
#ifndef DNS_OPT_NEWCODES
char buf[sizeof("1234567890")];
#endif /* DNS_OPT_NEWCODES */
REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(target != NULL);
@@ -2905,9 +2900,6 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
ps = dns_message_getopt(msg);
if (ps == NULL)
return (ISC_R_SUCCESS);
#ifdef DNS_OPT_NEWCODES
result = dns_opt_totext(ps, target, flags);
#else /* DNS_OPT_NEWCODES */
if ((flags & DNS_MESSAGETEXTFLAG_NOCOMMENTS) == 0)
ADD_STRING(target, ";; OPT PSEUDOSECTION:\n");
ADD_STRING(target, "; EDNS: version: ");
@@ -2919,9 +2911,7 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
sprintf(buf, "%7u\n",
(unsigned int)ps->rdclass);
ADD_STRING(target, buf);
result = ISC_R_SUCCESS;
#endif /* DNS_OPT_NEWCODES */
return (result);
return (ISC_R_SUCCESS);
case DNS_PSEUDOSECTION_TSIG:
ps = dns_message_gettsig(msg, &name);
if (ps == NULL)
-256
View File
@@ -1,256 +0,0 @@
/*
* Copyright (C) 2000, 2001 Internet Software Consortium.
*
* 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.
*
* 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.
*/
/* $Id: opt.c,v 1.14 2001/05/06 02:24:08 mayer Exp $ */
/* DNS_OPT_NEWCODES_KEEP */
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <isc/buffer.h>
#include <isc/util.h>
#include <dns/compress.h>
#include <dns/fixedname.h>
#include <dns/message.h>
#include <dns/name.h>
#include <dns/ncache.h>
#include <dns/opt.h>
#include <dns/rdata.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/result.h>
#define ADD_STRING(b, s, g) {if (strlen(s) >= \
isc_buffer_availablelength(b)) \
{ result = ISC_R_NOSPACE; \
goto g; } else \
isc_buffer_putstr(b, s);}
static isc_result_t
optget(dns_optlist_t *optlist, dns_rdataset_t *optset,
isc_uint16_t code, isc_boolean_t getall)
{
isc_result_t result;
dns_rdata_t rdata = DNS_RDATA_INIT;
unsigned int location;
isc_region_t rdataregion;
isc_buffer_t rdatabuf;
isc_uint16_t thiscode, thislength;
REQUIRE(DNS_RDATASET_VALID(optset));
REQUIRE(optset->type == dns_rdatatype_opt);
result = dns_rdataset_first(optset);
if (result != ISC_R_SUCCESS)
return(result);
dns_rdataset_current(optset, &rdata);
dns_rdata_toregion(&rdata, &rdataregion);
isc_buffer_init(&rdatabuf, rdataregion.base, rdataregion.length);
isc_buffer_add(&rdatabuf, rdataregion.length);
optlist->used = 0;
location = 0;
/*
* We don't do the test in the while loop, since I want to
* actually keep searching the list for more data until I reach
* the first one I *can't* fit in. This way, I can correctly
* decide between MOREDATA and SUCCESS.
*/
while (1) {
if (isc_buffer_remaininglength(&rdatabuf) == 0) {
optlist->next = 0;
return (ISC_R_SUCCESS);
}
if (isc_buffer_remaininglength(&rdatabuf) < 4)
return (ISC_R_UNEXPECTEDEND);
thiscode = isc_buffer_getuint16(&rdatabuf);
thislength = isc_buffer_getuint16(&rdatabuf);
if (isc_buffer_remaininglength(&rdatabuf) < thislength)
return (ISC_R_UNEXPECTEDEND);
if ((thiscode == code || getall) &&
(location >= optlist->next)) {
if (optlist->used >= optlist->size) {
optlist->next = location;
return (DNS_R_MOREDATA);
}
optlist->attrs[optlist->used].code = thiscode;
optlist->attrs[optlist->used].value.base =
isc_buffer_current(&rdatabuf);
optlist->attrs[optlist->used].value.length =
thislength;
optlist->used++;
}
isc_buffer_forward(&rdatabuf, thislength);
location++;
}
/*NOTREACHED*/
}
isc_result_t
dns_opt_decode(dns_optlist_t *optlist, dns_rdataset_t *optset,
isc_uint16_t code)
{
return (optget(optlist, optset, code, ISC_FALSE));
}
isc_result_t
dns_opt_decodeall(dns_optlist_t *optlist, dns_rdataset_t *optset) {
return (optget(optlist, optset, 0, ISC_TRUE));
}
isc_result_t
dns_opt_add(dns_rdata_t *rdata, dns_optlist_t *optlist,
isc_buffer_t *target)
{
unsigned char *base;
unsigned int i;
REQUIRE(rdata->length == 0);
base = isc_buffer_current(target);
if (optlist != NULL) {
for (i = 0; i < optlist->used; i++) {
rdata->length += optlist->attrs[i].value.length;
rdata->length += 4;
}
if (isc_buffer_availablelength(target) < rdata->length) {
rdata->length = 0;
return (ISC_R_NOSPACE);
}
for (i = 0; i < optlist->used; i++) {
isc_buffer_putuint16(target, optlist->attrs[i].code);
isc_buffer_putuint16(target,
(isc_uint16_t) optlist->attrs[i].value.length);
isc_buffer_putmem(target,
optlist->attrs[i].value.base,
optlist->attrs[i].value.length);
}
rdata->data = base;
}
return (ISC_R_SUCCESS);
}
isc_result_t
dns_opt_attrtotext(dns_optattr_t *attr, isc_buffer_t *target,
dns_messagetextflag_t flags) {
isc_result_t result = ISC_R_SUCCESS;
char store[sizeof("012345678")];
#ifdef DNS_OPT_NEWCODES
dns_decompress_t dctx;
dns_fixedname_t fname;
isc_buffer_t source;
#else /* DNS_OPT_NEWCODES */
UNUSED (flags);
#endif /* DNS_OPT_NEWCODES */
switch (attr->code) {
#ifdef DNS_OPT_NEWCODES
case DNS_OPTCODE_ZONE:
ADD_STRING(target, "; ZONE attribute: ", zonefail0);
dns_fixedname_init(&fname);
dns_decompress_init(&dctx, 0, DNS_DECOMPRESS_NONE);
isc_buffer_init(&source, attr->value.base, attr->value.length);
isc_buffer_add(&source, attr->value.length);
isc_buffer_setactive(&source, attr->value.length);
result = dns_name_fromwire(&fname.name, &source, &dctx,
ISC_FALSE, NULL);
if (result != ISC_R_SUCCESS)
goto zonefail1;
result = dns_name_totext(&fname.name, ISC_FALSE,
target);
ADD_STRING(target, "\n", zonefail1);
zonefail1:
dns_decompress_invalidate(&dctx);
dns_fixedname_invalidate(&fname);
zonefail0:
return (result);
case DNS_OPTCODE_VIEW:
ADD_STRING(target, "; VIEW attribute: ", viewfail0);
if (attr->value.length >= isc_buffer_availablelength(target))
return(ISC_R_NOSPACE);
else
isc_buffer_putmem(target, attr->value.base,
attr->value.length);
ADD_STRING(target, "\n", viewfail0);
viewfail0:
return (result);
#endif /* DNS_OPT_NEWCODES */
/*
* This routine is a placekeeper, awaiting assignment of
* OPT attribute values from IANA.
*/
default:
ADD_STRING(target, "; Unknown EDNS attribute ", deffail);
sprintf(store,"%d",attr->code);
ADD_STRING(target, store, deffail);
ADD_STRING(target, "\n", deffail);
result = DNS_R_UNKNOWNOPT;
deffail:
return (result);
}
}
isc_result_t
dns_opt_totext(dns_rdataset_t *opt, isc_buffer_t *target,
dns_messagetextflag_t flags) {
isc_result_t result, iresult;
char buf[sizeof("1234567890")];
dns_optattr_t attr;
dns_optlist_t list;
REQUIRE(DNS_RDATASET_VALID(opt));
REQUIRE(target != NULL);
if ((flags & DNS_MESSAGETEXTFLAG_NOCOMMENTS) == 0)
ADD_STRING(target, ";; OPT PSEUDOSECTION:\n", fail);
ADD_STRING(target, "; EDNS: version: ", fail);
sprintf(buf, "%4u",
(unsigned int)((opt->ttl &
0x00ff0000 >> 16)));
ADD_STRING(target, buf, fail);
ADD_STRING(target, ", udp=", fail);
sprintf(buf, "%7u",
(unsigned int)opt->rdclass);
ADD_STRING(target, buf, fail);
ADD_STRING(target, ", flags:", fail);
if ((DNS_OPT_FLAGS(opt) & DNS_MESSAGEEXTFLAG_DO) != 0)
ADD_STRING(target, " do", fail);
ADD_STRING(target, "\n", fail);
list.attrs = &attr;
list.size = 1;
list.used = 0;
list.next = 0;
do {
result = dns_opt_decodeall(&list, opt);
if ((result == ISC_R_SUCCESS || result == DNS_R_MOREDATA)
&& list.used != 0) {
iresult = dns_opt_attrtotext(list.attrs, target,
flags);
if (iresult != ISC_R_SUCCESS &&
iresult != DNS_R_UNKNOWNOPT)
result = iresult;
}
} while (result == DNS_R_MOREDATA);
fail:
return (result);
}
-2
View File
@@ -1579,7 +1579,6 @@
./lib/dns/include/dns/name.h C 1998,1999,2000,2001
./lib/dns/include/dns/ncache.h C 1999,2000,2001
./lib/dns/include/dns/nxt.h C 1999,2000,2001
./lib/dns/include/dns/opt.h C 2000,2001
./lib/dns/include/dns/peer.h C 2000,2001
./lib/dns/include/dns/rbt.h C 1999,2000,2001
./lib/dns/include/dns/rcode.h C 1999,2000,2001
@@ -1624,7 +1623,6 @@
./lib/dns/name.c C 1998,1999,2000,2001
./lib/dns/ncache.c C 1999,2000,2001
./lib/dns/nxt.c C 1999,2000,2001
./lib/dns/opt.c C 2000,2001
./lib/dns/peer.c C 2000,2001
./lib/dns/rbt.c C 1999,2000,2001
./lib/dns/rbtdb.c C 1999,2000,2001