mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-04 16:45:24 +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_buffer_init(&tbuf, outbuf, sizeof(outbuf),
|
||||||
ISC_BUFFERTYPE_TEXT);
|
ISC_BUFFERTYPE_TEXT);
|
||||||
result = dns_rdata_totext(&rdata, &tbuf);
|
result = dns_rdata_totext(&rdata, NULL, &tbuf);
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
fprintf(stdout, "dns_rdata_totext returned %s(%d)\n",
|
fprintf(stdout, "dns_rdata_totext returned %s(%d)\n",
|
||||||
dns_result_totext(result), result);
|
dns_result_totext(result), result);
|
||||||
|
@@ -51,7 +51,10 @@ typedef struct dns_rdatacallbacks {
|
|||||||
void dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks);
|
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:
|
* Requires:
|
||||||
* 'callbacks' is a valid dns_rdatacallbacks_t,
|
* 'callbacks' is a valid dns_rdatacallbacks_t,
|
||||||
|
@@ -18,6 +18,10 @@
|
|||||||
#ifndef DNS_MASTER_H
|
#ifndef DNS_MASTER_H
|
||||||
#define DNS_MASTER_H 1
|
#define DNS_MASTER_H 1
|
||||||
|
|
||||||
|
/***
|
||||||
|
*** Imports
|
||||||
|
***/
|
||||||
|
|
||||||
#include <isc/mem.h>
|
#include <isc/mem.h>
|
||||||
#include <isc/lex.h>
|
#include <isc/lex.h>
|
||||||
|
|
||||||
@@ -27,6 +31,10 @@
|
|||||||
#include <dns/rdataset.h>
|
#include <dns/rdataset.h>
|
||||||
#include <dns/callbacks.h>
|
#include <dns/callbacks.h>
|
||||||
|
|
||||||
|
/***
|
||||||
|
*** Function
|
||||||
|
***/
|
||||||
|
|
||||||
dns_result_t dns_master_load(char *master_file,
|
dns_result_t dns_master_load(char *master_file,
|
||||||
dns_name_t *top,
|
dns_name_t *top,
|
||||||
dns_name_t *origin,
|
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
|
* Loads a RFC 1305 master file from disk into rdatasets then call
|
||||||
* 'callbacks->commit' to commit the dataset. Rdata memory belongs
|
* 'callbacks->commit' to commit the dataset. Rdata memory belongs
|
||||||
* to dns_master_load and will be reused / released when the callback
|
* 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->commit' is assumed to call 'callbacks->error' or
|
||||||
* 'callbacks->warn' to generate any error messages required.
|
* '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->error' to point ta a valid function.
|
||||||
* 'callbacks->warn' to point ta a valid function.
|
* 'callbacks->warn' to point ta a valid function.
|
||||||
* 'mctx' to point to a memory context.
|
* '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 */
|
#endif /* DNS_MASTER_H */
|
||||||
|
@@ -276,6 +276,8 @@ dns_result_t dns_rdata_fromtext(dns_rdata_t *rdata,
|
|||||||
*
|
*
|
||||||
* 'target' is a valid region.
|
* 'target' is a valid region.
|
||||||
*
|
*
|
||||||
|
* 'origin' if non NULL it must be absolute.
|
||||||
|
*
|
||||||
* Ensures:
|
* Ensures:
|
||||||
* If result is success:
|
* If result is success:
|
||||||
* If 'rdata' is not NULL, it is attached to the target.
|
* 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
|
* 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);
|
isc_buffer_t *target);
|
||||||
/*
|
/*
|
||||||
* Convert 'rdata' into text format, storing the result in 'target'.
|
* Convert 'rdata' into text format, storing the result in 'target'.
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* SOFTWARE.
|
* 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>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -228,6 +228,9 @@ dns_rdata_fromregion(dns_rdata_t *rdata,
|
|||||||
dns_rdataclass_t class, dns_rdatatype_t type,
|
dns_rdataclass_t class, dns_rdatatype_t type,
|
||||||
isc_region_t *r) {
|
isc_region_t *r) {
|
||||||
|
|
||||||
|
REQUIRE(rdata != NULL);
|
||||||
|
REQUIRE(r != NULL);
|
||||||
|
|
||||||
rdata->data = r->base;
|
rdata->data = r->base;
|
||||||
rdata->length = r->length;
|
rdata->length = r->length;
|
||||||
rdata->class = class;
|
rdata->class = class;
|
||||||
@@ -237,6 +240,9 @@ dns_rdata_fromregion(dns_rdata_t *rdata,
|
|||||||
void
|
void
|
||||||
dns_rdata_toregion(dns_rdata_t *rdata, isc_region_t *r) {
|
dns_rdata_toregion(dns_rdata_t *rdata, isc_region_t *r) {
|
||||||
|
|
||||||
|
REQUIRE(rdata != NULL);
|
||||||
|
REQUIRE(r != NULL);
|
||||||
|
|
||||||
r->base = rdata->data;
|
r->base = rdata->data;
|
||||||
r->length = rdata->length;
|
r->length = rdata->length;
|
||||||
}
|
}
|
||||||
@@ -254,6 +260,10 @@ dns_rdata_fromwire(dns_rdata_t *rdata,
|
|||||||
isc_buffer_t st;
|
isc_buffer_t st;
|
||||||
isc_boolean_t use_default = ISC_FALSE;
|
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;
|
ss = *source;
|
||||||
st = *target;
|
st = *target;
|
||||||
region.base = (unsigned char *)(target->base) + target->used;
|
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_boolean_t use_default = ISC_FALSE;
|
||||||
isc_region_t tr;
|
isc_region_t tr;
|
||||||
|
|
||||||
|
REQUIRE(rdata != NULL);
|
||||||
|
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
|
||||||
|
|
||||||
TOWIRESWITCH
|
TOWIRESWITCH
|
||||||
|
|
||||||
if (use_default) {
|
if (use_default) {
|
||||||
@@ -318,6 +331,10 @@ dns_rdata_fromtext(dns_rdata_t *rdata,
|
|||||||
void (*callback)(dns_rdatacallbacks_t *, char *, ...);
|
void (*callback)(dns_rdatacallbacks_t *, char *, ...);
|
||||||
isc_result_t iresult;
|
isc_result_t iresult;
|
||||||
|
|
||||||
|
if (origin != NULL)
|
||||||
|
REQUIRE(dns_name_isabsolute(origin) == ISC_TRUE);
|
||||||
|
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
|
||||||
|
|
||||||
st = *target;
|
st = *target;
|
||||||
region.base = (unsigned char *)(target->base) + target->used;
|
region.base = (unsigned char *)(target->base) + target->used;
|
||||||
|
|
||||||
@@ -391,11 +408,17 @@ dns_rdata_fromtext(dns_rdata_t *rdata,
|
|||||||
}
|
}
|
||||||
|
|
||||||
dns_result_t
|
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_result_t result = DNS_R_NOTIMPLEMENTED;
|
||||||
dns_name_t *origin = NULL;
|
|
||||||
isc_boolean_t use_default = ISC_FALSE;
|
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
|
TOTEXTSWITCH
|
||||||
|
|
||||||
if (use_default)
|
if (use_default)
|
||||||
@@ -414,6 +437,9 @@ dns_rdata_fromstruct(dns_rdata_t *rdata,
|
|||||||
isc_region_t region;
|
isc_region_t region;
|
||||||
isc_boolean_t use_default = ISC_FALSE;
|
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;
|
region.base = (unsigned char *)(target->base) + target->used;
|
||||||
st = *target;
|
st = *target;
|
||||||
|
|
||||||
@@ -436,6 +462,9 @@ dns_rdata_tostruct(dns_rdata_t *rdata, void *target) {
|
|||||||
dns_result_t result = DNS_R_NOTIMPLEMENTED;
|
dns_result_t result = DNS_R_NOTIMPLEMENTED;
|
||||||
isc_boolean_t use_default = ISC_FALSE;
|
isc_boolean_t use_default = ISC_FALSE;
|
||||||
|
|
||||||
|
REQUIRE(rdata != NULL);
|
||||||
|
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
|
||||||
|
|
||||||
TOSTRUCTSWITCH
|
TOSTRUCTSWITCH
|
||||||
|
|
||||||
if (use_default)
|
if (use_default)
|
||||||
|
@@ -243,7 +243,7 @@ dns_rdataset_totext(dns_rdataset_t *rdataset,
|
|||||||
first = ISC_FALSE;
|
first = ISC_FALSE;
|
||||||
|
|
||||||
dns_rdataset_current(rdataset, &rdata);
|
dns_rdataset_current(rdataset, &rdata);
|
||||||
result = dns_rdata_totext(&rdata, target);
|
result = dns_rdata_totext(&rdata, NULL, target);
|
||||||
if (result != DNS_R_SUCCESS)
|
if (result != DNS_R_SUCCESS)
|
||||||
return (result);
|
return (result);
|
||||||
isc_buffer_available(target, &r);
|
isc_buffer_available(target, &r);
|
||||||
|
Reference in New Issue
Block a user