mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
Added missing REQUIRE()'s to dns_rdata_*().
Restored origin to dns_rdata_totext(). Made include file comments more relevent.
This commit is contained in:
@@ -277,7 +277,7 @@ main(int argc, char *argv[]) {
|
||||
|
||||
isc_buffer_init(&tbuf, outbuf, sizeof(outbuf),
|
||||
ISC_BUFFERTYPE_TEXT);
|
||||
result = dns_rdata_totext(&rdata, &tbuf);
|
||||
result = dns_rdata_totext(&rdata, NULL, &tbuf);
|
||||
if (result != DNS_R_SUCCESS)
|
||||
fprintf(stdout, "dns_rdata_totext returned %s(%d)\n",
|
||||
dns_result_totext(result), result);
|
||||
|
@@ -51,7 +51,10 @@ typedef struct dns_rdatacallbacks {
|
||||
void dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks);
|
||||
|
||||
/*
|
||||
* Make 'callbacks' empty.
|
||||
* Initalise 'callbacks'.
|
||||
* 'error' and 'warn' are set to default callbacks that print the
|
||||
* error message to stderr.
|
||||
* All other elements are initalised to NULL.
|
||||
*
|
||||
* Requires:
|
||||
* 'callbacks' is a valid dns_rdatacallbacks_t,
|
||||
|
@@ -18,6 +18,10 @@
|
||||
#ifndef DNS_MASTER_H
|
||||
#define DNS_MASTER_H 1
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <isc/mem.h>
|
||||
#include <isc/lex.h>
|
||||
|
||||
@@ -27,6 +31,10 @@
|
||||
#include <dns/rdataset.h>
|
||||
#include <dns/callbacks.h>
|
||||
|
||||
/***
|
||||
*** Function
|
||||
***/
|
||||
|
||||
dns_result_t dns_master_load(char *master_file,
|
||||
dns_name_t *top,
|
||||
dns_name_t *origin,
|
||||
@@ -40,7 +48,8 @@ dns_result_t dns_master_load(char *master_file,
|
||||
* Loads a RFC 1305 master file from disk into rdatasets then call
|
||||
* 'callbacks->commit' to commit the dataset. Rdata memory belongs
|
||||
* to dns_master_load and will be reused / released when the callback
|
||||
* completes.
|
||||
* completes. dns_load_master will abort if callbacks->commit returns
|
||||
* any value other than DNS_R_SUCCESS.
|
||||
*
|
||||
* 'callbacks->commit' is assumed to call 'callbacks->error' or
|
||||
* 'callbacks->warn' to generate any error messages required.
|
||||
@@ -55,6 +64,18 @@ dns_result_t dns_master_load(char *master_file,
|
||||
* 'callbacks->error' to point ta a valid function.
|
||||
* 'callbacks->warn' to point ta a valid function.
|
||||
* 'mctx' to point to a memory context.
|
||||
*
|
||||
* Returns:
|
||||
* DNS_R_SUCCESS upon successfully loading the master file.
|
||||
* DNS_R_NOMEMORY out of memory.
|
||||
* DNS_R_UNEXPECTEDEND expected to be able to read a input token and
|
||||
* there was not one.
|
||||
* DNS_R_UNEXPECTED
|
||||
* DNS_R_NOOWNER failed to specify a ownername.
|
||||
* DNS_R_NOTTL failed to specify a ttl.
|
||||
* DNS_R_BADCLASS record class did not match zone class.
|
||||
* Any dns_rdata_fromtext() error code.
|
||||
* Any error code from callbacks->commit().
|
||||
*/
|
||||
|
||||
#endif /* DNS_MASTER_H */
|
||||
|
@@ -276,6 +276,8 @@ dns_result_t dns_rdata_fromtext(dns_rdata_t *rdata,
|
||||
*
|
||||
* 'target' is a valid region.
|
||||
*
|
||||
* 'origin' if non NULL it must be absolute.
|
||||
*
|
||||
* Ensures:
|
||||
* If result is success:
|
||||
* If 'rdata' is not NULL, it is attached to the target.
|
||||
@@ -293,7 +295,7 @@ dns_result_t dns_rdata_fromtext(dns_rdata_t *rdata,
|
||||
* Resource Limit: Not enough space
|
||||
*/
|
||||
|
||||
dns_result_t dns_rdata_totext(dns_rdata_t *rdata,
|
||||
dns_result_t dns_rdata_totext(dns_rdata_t *rdata, dns_name_t *origin,
|
||||
isc_buffer_t *target);
|
||||
/*
|
||||
* Convert 'rdata' into text format, storing the result in 'target'.
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: rdata.c,v 1.33 1999/02/12 03:08:44 marka Exp $ */
|
||||
/* $Id: rdata.c,v 1.34 1999/02/16 02:54:17 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -228,6 +228,9 @@ dns_rdata_fromregion(dns_rdata_t *rdata,
|
||||
dns_rdataclass_t class, dns_rdatatype_t type,
|
||||
isc_region_t *r) {
|
||||
|
||||
REQUIRE(rdata != NULL);
|
||||
REQUIRE(r != NULL);
|
||||
|
||||
rdata->data = r->base;
|
||||
rdata->length = r->length;
|
||||
rdata->class = class;
|
||||
@@ -237,6 +240,9 @@ dns_rdata_fromregion(dns_rdata_t *rdata,
|
||||
void
|
||||
dns_rdata_toregion(dns_rdata_t *rdata, isc_region_t *r) {
|
||||
|
||||
REQUIRE(rdata != NULL);
|
||||
REQUIRE(r != NULL);
|
||||
|
||||
r->base = rdata->data;
|
||||
r->length = rdata->length;
|
||||
}
|
||||
@@ -254,6 +260,10 @@ dns_rdata_fromwire(dns_rdata_t *rdata,
|
||||
isc_buffer_t st;
|
||||
isc_boolean_t use_default = ISC_FALSE;
|
||||
|
||||
REQUIRE(isc_buffer_type(source) == ISC_BUFFERTYPE_BINARY);
|
||||
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
|
||||
REQUIRE(dctx != NULL);
|
||||
|
||||
ss = *source;
|
||||
st = *target;
|
||||
region.base = (unsigned char *)(target->base) + target->used;
|
||||
@@ -286,6 +296,9 @@ dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
|
||||
isc_boolean_t use_default = ISC_FALSE;
|
||||
isc_region_t tr;
|
||||
|
||||
REQUIRE(rdata != NULL);
|
||||
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
|
||||
|
||||
TOWIRESWITCH
|
||||
|
||||
if (use_default) {
|
||||
@@ -318,6 +331,10 @@ dns_rdata_fromtext(dns_rdata_t *rdata,
|
||||
void (*callback)(dns_rdatacallbacks_t *, char *, ...);
|
||||
isc_result_t iresult;
|
||||
|
||||
if (origin != NULL)
|
||||
REQUIRE(dns_name_isabsolute(origin) == ISC_TRUE);
|
||||
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
|
||||
|
||||
st = *target;
|
||||
region.base = (unsigned char *)(target->base) + target->used;
|
||||
|
||||
@@ -391,11 +408,17 @@ dns_rdata_fromtext(dns_rdata_t *rdata,
|
||||
}
|
||||
|
||||
dns_result_t
|
||||
dns_rdata_totext(dns_rdata_t *rdata, isc_buffer_t *target) {
|
||||
dns_rdata_totext(dns_rdata_t *rdata, dns_name_t *origin,
|
||||
isc_buffer_t *target)
|
||||
{
|
||||
dns_result_t result = DNS_R_NOTIMPLEMENTED;
|
||||
dns_name_t *origin = NULL;
|
||||
isc_boolean_t use_default = ISC_FALSE;
|
||||
|
||||
REQUIRE(rdata != NULL);
|
||||
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_TEXT);
|
||||
if (origin != NULL)
|
||||
REQUIRE(dns_name_isabsolute(origin) == ISC_TRUE);
|
||||
|
||||
TOTEXTSWITCH
|
||||
|
||||
if (use_default)
|
||||
@@ -414,6 +437,9 @@ dns_rdata_fromstruct(dns_rdata_t *rdata,
|
||||
isc_region_t region;
|
||||
isc_boolean_t use_default = ISC_FALSE;
|
||||
|
||||
REQUIRE(source != NULL);
|
||||
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
|
||||
|
||||
region.base = (unsigned char *)(target->base) + target->used;
|
||||
st = *target;
|
||||
|
||||
@@ -436,6 +462,9 @@ dns_rdata_tostruct(dns_rdata_t *rdata, void *target) {
|
||||
dns_result_t result = DNS_R_NOTIMPLEMENTED;
|
||||
isc_boolean_t use_default = ISC_FALSE;
|
||||
|
||||
REQUIRE(rdata != NULL);
|
||||
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
|
||||
|
||||
TOSTRUCTSWITCH
|
||||
|
||||
if (use_default)
|
||||
|
@@ -243,7 +243,7 @@ dns_rdataset_totext(dns_rdataset_t *rdataset,
|
||||
first = ISC_FALSE;
|
||||
|
||||
dns_rdataset_current(rdataset, &rdata);
|
||||
result = dns_rdata_totext(&rdata, target);
|
||||
result = dns_rdata_totext(&rdata, NULL, target);
|
||||
if (result != DNS_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_available(target, &r);
|
||||
|
Reference in New Issue
Block a user