103. [func] libisc buffer API changes for <isc/buffer.h>:

Added:
                                isc_buffer_base(b)          (pointer)
                                isc_buffer_current(b)       (pointer)
                                isc_buffer_active(b)        (pointer)
                                isc_buffer_used(b)          (pointer)
                                isc_buffer_length(b)            (int)
                                isc_buffer_usedlength(b)        (int)
                                isc_buffer_consumedlength(b)    (int)
                                isc_buffer_remaininglength(b)   (int)
                                isc_buffer_activelength(b)      (int)
                                isc_buffer_availablelength(b)   (int)
                        Removed:
                                ISC_BUFFER_USEDCOUNT(b)
                                ISC_BUFFER_AVAILABLECOUNT(b)
                                isc_buffer_type(b)
                        Changed names:
                                isc_buffer_used(b, r) ->
                                        isc_buffer_usedregion(b, r)
                                isc_buffer_available(b, r) ->
                                        isc_buffer_available_region(b, r)
                                isc_buffer_consumed(b, r) ->
                                        isc_buffer_consumedregion(b, r)
                                isc_buffer_active(b, r) ->
                                        isc_buffer_activeregion(b, r)
                                isc_buffer_remaining(b, r) ->
                                        isc_buffer_remainingregion(b, r)

                        Buffer types were removed, so the ISC_BUFFERTYPE_*
                        macros are no more, and the type argument to
                        isc_buffer_init and isc_buffer_allocate were removed.
                        isc_buffer_putstr is now void (instead of isc_result_t)
                        and requires that the caller ensure that there
                        is enough available buffer space for the string.
This commit is contained in:
David Lawrence 2000-04-27 00:03:12 +00:00
parent ace0c1b3f4
commit 6e49e91bd0
133 changed files with 1165 additions and 1400 deletions

37
CHANGES
View file

@ -1,4 +1,39 @@
102. [bug] Correctly detect inet_aton, inet_pton and inet_ptop
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
102. [port] Correctly detect inet_aton, inet_pton and inet_ptop
on BSD/OS 4.1.
101. [cleanup] Quieted EGCS warnings from lib/isc/print.c.

View file

@ -59,9 +59,7 @@ extern int h_errno;
extern ISC_LIST(dig_lookup_t) lookup_list;
extern ISC_LIST(dig_server_t) server_list;
extern isc_boolean_t tcp_mode,
recurse,
have_ipv6;
extern isc_boolean_t tcp_mode, recurse, have_ipv6;
extern in_port_t port;
extern unsigned int timeout;
extern isc_mem_t *mctx;
@ -118,7 +116,7 @@ static char *rcodetext[] = {
static void
show_usage() {
fatal ("Usage.");
fatal("Usage.");
}
void
@ -128,14 +126,14 @@ check_next_lookup(dig_lookup_t *lookup) {
isc_boolean_t still_working=ISC_FALSE;
#ifdef DEBUG
fputs ("In check_next_lookup",stderr);
fputs("In check_next_lookup",stderr);
#endif
for (query = ISC_LIST_HEAD(lookup->q);
query != NULL;
query = ISC_LIST_NEXT(query, link)) {
if (query->working) {
#ifdef DEBUG
fputs ("Still have a worker.",stderr);
fputs("Still have a worker.",stderr);
#endif
still_working=ISC_TRUE;
}
@ -143,10 +141,10 @@ check_next_lookup(dig_lookup_t *lookup) {
if (still_working)
return;
next = ISC_LIST_NEXT (lookup, link);
next = ISC_LIST_NEXT(lookup, link);
if (next == NULL) {
#ifdef DEBUG
fputs ("Shutting Down.",stderr);
fputs("Shutting Down.",stderr);
#endif
isc_app_shutdown();
return;
@ -196,7 +194,7 @@ printsection(dns_message_t *msg, dns_section_t sectionid, char *section_name,
name = NULL;
dns_message_currentname(msg, sectionid, &name);
isc_buffer_init(&target, t, sizeof t, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, t, sizeof(t));
first = ISC_TRUE;
print_name = name;
@ -217,7 +215,7 @@ printsection(dns_message_t *msg, dns_section_t sectionid, char *section_name,
}
#endif
}
isc_buffer_used(&target, &r);
isc_buffer_usedregion(&target, &r);
if (no_rdata)
printf(";%.*s", (int)r.length, (char *)r.base);
else
@ -246,13 +244,13 @@ printrdata(dns_message_t *msg, dns_rdataset_t *rdataset, dns_name_t *owner,
if (headers)
printf(";; %s SECTION:\n", set_name);
isc_buffer_init(&target, t, sizeof t, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, t, sizeof(t));
result = dns_rdataset_totext(rdataset, owner, ISC_FALSE, ISC_FALSE,
&target);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_used(&target, &r);
isc_buffer_usedregion(&target, &r);
printf("%.*s", (int)r.length, (char *)r.base);
return (ISC_R_SUCCESS);
@ -262,7 +260,7 @@ isc_result_t
printmessage(dns_message_t *msg, isc_boolean_t headers) {
isc_boolean_t did_flag = ISC_FALSE;
isc_result_t result;
dns_rdataset_t *opt, *tsig;
dns_rdataset_t *opt, *tsig = NULL;
dns_name_t *tsigname;
result = ISC_R_SUCCESS;
@ -300,7 +298,8 @@ printmessage(dns_message_t *msg, isc_boolean_t headers) {
printf("%scd", did_flag ? " " : "");
did_flag = ISC_TRUE;
}
printf("; QUERY: %u, ANSWER: %u, AUTHORITY: %u, ADDITIONAL: %u\n",
printf("; QUERY: %u, ANSWER: %u, "
"AUTHORITY: %u, ADDITIONAL: %u\n",
msg->counts[DNS_SECTION_QUESTION],
msg->counts[DNS_SECTION_ANSWER],
msg->counts[DNS_SECTION_AUTHORITY],
@ -367,15 +366,14 @@ printmessage(dns_message_t *msg, isc_boolean_t headers) {
*/
void
parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
isc_boolean_t have_host=ISC_FALSE;
dig_server_t *srv=NULL;
dig_lookup_t *lookup=NULL;
char *batchname=NULL;
isc_boolean_t have_host = ISC_FALSE;
dig_server_t *srv = NULL;
dig_lookup_t *lookup = NULL;
char *batchname = NULL;
char batchline[MXNAME];
FILE *fp=NULL;
FILE *fp = NULL;
int bargc;
char *bargv[8];
char *ptr;
int i,n;
int adrs[4];
@ -384,7 +382,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
&& (!is_batchfile)) {
srv=isc_mem_allocate(mctx, sizeof(struct dig_server));
if (srv == NULL)
fatal ("Memory allocation failure.");
fatal("Memory allocation failure.");
strncpy(srv->servername,&argv[0][1],MXNAME-1);
ISC_LIST_APPEND(server_list, srv, link);
} else if ((strcmp(argv[0],"+vc") == 0)
@ -413,27 +411,27 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
argc--;
}
} else if (strncmp(argv[0],"-x",2) == 0) {
n = sscanf (argv[1],"%d.%d.%d.%d", &adrs[0], &adrs[1],
n = sscanf(argv[1],"%d.%d.%d.%d", &adrs[0], &adrs[1],
&adrs[2], &adrs[3]);
if (n == 0)
show_usage();
lookup = isc_mem_allocate (mctx,
sizeof(struct dig_lookup));
lookup = isc_mem_allocate(mctx,
sizeof(struct dig_lookup));
if (lookup == NULL)
fatal ("Memory allocation failure.");
fatal("Memory allocation failure.");
lookup->pending = ISC_FALSE;
lookup->textname[0]=0;
for (i=n-1; i>=0; i--) {
snprintf (batchline, MXNAME/8, "%d.",
for (i = n - 1; i >= 0; i--) {
snprintf(batchline, MXNAME/8, "%d.",
adrs[i]);
strncat (lookup->textname, batchline, MXNAME);
strncat(lookup->textname, batchline, MXNAME);
}
strncat (lookup->textname, "in-addr.arpa.", MXNAME);
strncat(lookup->textname, "in-addr.arpa.", MXNAME);
#ifdef DEBUG
fprintf (stderr,"Looking up %s\n",lookup->textname);
fprintf(stderr,"Looking up %s\n",lookup->textname);
#endif
strcpy (lookup->rttext, "ptr");
strcpy (lookup->rctext, "in");
strcpy(lookup->rttext, "ptr");
strcpy(lookup->rctext, "in");
lookup->namespace[0]=0;
lookup->sendspace[0]=0;
lookup->sendmsg=NULL;
@ -448,23 +446,22 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
argc--;
} else {
if (have_host) {
ENSURE ( lookup != NULL );
ENSURE(lookup != NULL);
if (isclass(argv[0])) {
strncpy (lookup->rctext,argv[0],
strncpy(lookup->rctext,argv[0],
MXRD);
continue;
} else if (istype(argv[0])) {
strncpy (lookup->rttext,argv[0],
MXRD);
strncpy(lookup->rttext,argv[0], MXRD);
continue;
}
}
lookup = isc_mem_allocate (mctx,
sizeof(struct dig_lookup));
lookup = isc_mem_allocate(mctx,
sizeof(struct dig_lookup));
if (lookup == NULL)
fatal ("Memory allocation failure.");
fatal("Memory allocation failure.");
lookup->pending = ISC_FALSE;
strncpy (lookup->textname,argv[0], MXNAME-1);
strncpy(lookup->textname,argv[0], MXNAME-1);
lookup->rttext[0]=0;
lookup->rctext[0]=0;
lookup->namespace[0]=0;
@ -478,17 +475,17 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
ISC_LIST_APPEND(lookup_list, lookup, link);
have_host = ISC_TRUE;
#ifdef DEBUG
fprintf (stderr,"Looking up %s\n",lookup->textname);
fprintf(stderr, "Looking up %s\n", lookup->textname);
#endif
}
}
if (batchname != NULL) {
fp = fopen (batchname, "r");
fp = fopen(batchname, "r");
if (fp == NULL) {
perror (batchname);
fatal ("Couldn't open specified batch file.");
perror(batchname);
fatal("Couldn't open specified batch file.");
}
while (fgets (batchline, MXNAME, fp) != 0) {
while (fgets(batchline, MXNAME, fp) != 0) {
bargc=1;
bargv[bargc]=strtok(batchline, " \t");
while (bargv[bargc] != NULL) {
@ -498,16 +495,15 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
bargc--;
bargv[0]="dig";
#ifdef DEBUG
fprintf (stderr,"Parsing %d:%s\n",bargc,bargv[1]);
fprintf(stderr,"Parsing %d:%s\n",bargc,bargv[1]);
#endif
parse_args(ISC_TRUE, bargc, (char**)bargv);
}
}
if (lookup_list.head == NULL) {
lookup = isc_mem_allocate (mctx,
sizeof(struct dig_lookup));
lookup = isc_mem_allocate(mctx, sizeof(struct dig_lookup));
if (lookup == NULL)
fatal ("Memory allocation failure.");
fatal("Memory allocation failure.");
lookup->pending = ISC_FALSE;
lookup->rctext[0]=0;
lookup->namespace[0]=0;
@ -518,10 +514,9 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
lookup->xfr_q = NULL;
lookup->doing_xfr = ISC_FALSE;
ISC_LIST_INIT(lookup->q);
strcpy (lookup->textname,".");
strcpy (lookup->rttext, "NS");
strcpy(lookup->textname,".");
strcpy(lookup->rttext, "NS");
lookup->rctext[0]=0;
ISC_LIST_APPEND(lookup_list, lookup, link);
}
}

View file

@ -61,21 +61,19 @@ extern int h_errno;
ISC_LIST(dig_lookup_t) lookup_list;
ISC_LIST(dig_server_t) server_list;
isc_boolean_t tcp_mode=ISC_FALSE,
recurse=ISC_TRUE,
have_ipv6=ISC_FALSE;
isc_boolean_t tcp_mode = ISC_FALSE, recurse = ISC_TRUE, have_ipv6 = ISC_FALSE;
in_port_t port;
unsigned int timeout;
isc_mem_t *mctx=NULL;
isc_taskmgr_t *taskmgr=NULL;
isc_task_t *task=NULL;
isc_timermgr_t *timermgr=NULL;
isc_socketmgr_t *socketmgr=NULL;
isc_mem_t *mctx = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_task_t *task = NULL;
isc_timermgr_t *timermgr = NULL;
isc_socketmgr_t *socketmgr = NULL;
dns_messageid_t id;
dns_name_t rootorg;
char *rootspace[BUFSIZE];
isc_buffer_t rootbuf;
int sendcount=0;
int sendcount = 0;
extern isc_boolean_t short_form;
@ -87,9 +85,9 @@ hex_dump(isc_buffer_t *b) {
unsigned int len;
isc_region_t r;
isc_buffer_remaining(b, &r);
isc_buffer_remainingregion(b, &r);
printf ("Printing a buffer with length %d\n",r.length);
printf("Printing a buffer with length %d\n", r.length);
for (len = 0 ; len < r.length ; len++) {
printf("%02x ", r.base[len]);
if (len != 0 && len % 16 == 0)
@ -110,9 +108,9 @@ fatal(char *format, ...) {
fprintf(stderr, "\n");
free_lists();
isc_app_finish();
if (mctx != NULL) {
isc_mem_destroy (&mctx);
}
if (mctx != NULL)
isc_mem_destroy(&mctx);
exit(1);
}
@ -131,10 +129,10 @@ isclass(char *text) {
const int numclasses = 3;
int i;
for (i=0;i<numclasses;i++) {
for (i = 0; i < numclasses; i++)
if (strcasecmp(text, classlist[i]) == 0)
return ISC_TRUE;
}
return ISC_FALSE;
}
@ -144,19 +142,19 @@ istype(char *text) {
initialized. This list will have to be manually kept in
sync with what the libs support. */
const char *typelist[] = {"a", "ns", "md", "mf", "cname",
"soa", "mb", "mg", "mr", "null",
"wks", "ptr", "hinfo", "minfo",
"mx", "txt", "rp", "afsdb",
"x25", "isdn", "rt", "nsap",
"nsap_ptr", "sig", "key", "px",
"gpos", "aaaa", "loc", "nxt",
"srv", "naptr", "kx", "cert",
"a6", "dname", "opt", "unspec",
"tkey", "tsig", "axfr"};
"soa", "mb", "mg", "mr", "null",
"wks", "ptr", "hinfo", "minfo",
"mx", "txt", "rp", "afsdb",
"x25", "isdn", "rt", "nsap",
"nsap_ptr", "sig", "key", "px",
"gpos", "aaaa", "loc", "nxt",
"srv", "naptr", "kx", "cert",
"a6", "dname", "opt", "unspec",
"tkey", "tsig", "axfr"};
const int numtypes = 41;
int i;
for (i=0;i<numtypes;i++) {
for (i = 0; i < numtypes; i++) {
if (strcasecmp(text, typelist[i]) == 0)
return ISC_TRUE;
}
@ -165,95 +163,88 @@ istype(char *text) {
static void
setup_system() {
setup_system(void) {
char rcinput[MXNAME];
FILE *fp;
char *ptr;
dig_server_t *srv;
id = getpid()<<8;
id = getpid() << 8;
if (server_list.head == NULL) {
fp = fopen (RESOLVCONF, "r");
if (fp != NULL) {
while (fgets(rcinput, MXNAME, fp) != 0) {
ptr = strtok (rcinput, " \t");
if (ptr != NULL) {
if (strcasecmp(ptr,"nameserver")
== 0) {
ptr = strtok (NULL, " \t");
if (ptr != NULL) {
srv=isc_mem_allocate
(mctx,
sizeof
(struct
dig_server));
if (srv == NULL)
fatal
("Memory allocation failure.");
if (ptr != NULL &&
strcasecmp(ptr, "nameserver") == 0) {
ptr = strtok (NULL, " \t");
if (ptr != NULL) {
srv = isc_mem_allocate(mctx,
sizeof(struct dig_server));
if (srv == NULL)
fatal("Memory "
"allocation "
"failure.");
strncpy(srv->
servername,
ptr,MXNAME-1);
ptr,
MXNAME - 1);
ISC_LIST_APPEND
(server_list,
srv, link);
}
}
}
}
fclose (fp);
}
}
if (server_list.head == NULL) {
srv = isc_mem_allocate(mctx, sizeof(dig_server_t));
if (srv == NULL)
fatal ("Memory allocation failure");
strcpy (srv->servername, "127.0.0.1");
fatal("Memory allocation failure");
strcpy(srv->servername, "127.0.0.1");
ISC_LIST_APPEND(server_list, srv, link);
}
}
static void
setup_libs() {
setup_libs(void) {
isc_result_t result;
isc_buffer_t b;
result = isc_app_start();
check_result (result, "isc_app_start");
check_result(result, "isc_app_start");
result = isc_net_probeipv4();
check_result (result, "isc_net_probeipv4");
check_result(result, "isc_net_probeipv4");
result = isc_net_probeipv6();
if (result == ISC_R_SUCCESS)
have_ipv6=ISC_TRUE;
result = isc_mem_create (0, 0, &mctx);
check_result (result, "isc_mem_create");
result = isc_mem_create(0, 0, &mctx);
check_result(result, "isc_mem_create");
result = isc_taskmgr_create (mctx, 1, 0, &taskmgr);
check_result (result, "isc_taskmgr_create");
check_result(result, "isc_taskmgr_create");
result = isc_task_create (taskmgr, 0, &task);
check_result (result, "isc_task_create");
check_result(result, "isc_task_create");
result = isc_timermgr_create (mctx, &timermgr);
check_result (result, "isc_timermgr_create");
check_result(result, "isc_timermgr_create");
result = isc_socketmgr_create (mctx, &socketmgr);
check_result (result, "isc_socketmgr_create");
check_result(result, "isc_socketmgr_create");
isc_buffer_init (&b, ".", 1, ISC_BUFFERTYPE_TEXT);
isc_buffer_add (&b, 1);
dns_name_init (&rootorg, NULL);
isc_buffer_init (&rootbuf, rootspace, BUFSIZE,
ISC_BUFFERTYPE_BINARY);
result = dns_name_fromtext (&rootorg, &b, NULL,
ISC_FALSE, &rootbuf);
check_result (result, "dns_name_fromtext");
isc_buffer_init(&b, ".", 1);
isc_buffer_add(&b, 1);
dns_name_init(&rootorg, NULL);
isc_buffer_init(&rootbuf, rootspace, BUFSIZE);
result = dns_name_fromtext(&rootorg, &b, NULL, ISC_FALSE, &rootbuf);
check_result(result, "dns_name_fromtext");
}
static void
@ -283,37 +274,35 @@ setup_lookup(dig_lookup_t *lookup) {
isc_buffer_t b;
#ifdef DEBUG
fprintf (stderr,"Setting up for looking up %s\n",lookup->textname);
fprintf(stderr, "Setting up for looking up %s\n", lookup->textname);
#endif
len=strlen(lookup->textname);
isc_buffer_init (&b, lookup->textname, len,
ISC_BUFFERTYPE_TEXT);
isc_buffer_add (&b, len);
isc_buffer_init(&b, lookup->textname, len);
isc_buffer_add(&b, len);
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER,
&lookup->sendmsg);
check_result (result, "dns_message_create");
check_result(result, "dns_message_create");
result = dns_message_gettempname(lookup->sendmsg, &lookup->name);
check_result (result,"dns_message_gettempname");
dns_name_init (lookup->name, NULL);
check_result(result, "dns_message_gettempname");
dns_name_init(lookup->name, NULL);
isc_buffer_init (&lookup->namebuf, lookup->namespace, BUFSIZE,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&lookup->namebuf, lookup->namespace, BUFSIZE);
result = dns_name_fromtext (lookup->name, &b, &rootorg,
result = dns_name_fromtext(lookup->name, &b, &rootorg,
ISC_FALSE, &lookup->namebuf);
if (result != ISC_R_SUCCESS) {
dns_message_puttempname (lookup->sendmsg, &lookup->name);
fatal ("Aborting: %s is not a legal name syntax.",
lookup->textname);
dns_message_puttempname(lookup->sendmsg, &lookup->name);
fatal("Aborting: %s is not a legal name syntax.",
lookup->textname);
}
if (lookup->rctext[0] == 0)
strcpy (lookup->rctext, "IN");
strcpy(lookup->rctext, "IN");
if (lookup->rttext[0] == 0)
strcpy (lookup->rttext, "A");
strcpy(lookup->rttext, "A");
lookup->sendmsg->id = id++;
lookup->sendmsg->opcode = dns_opcode_query;
@ -327,27 +316,28 @@ setup_lookup(dig_lookup_t *lookup) {
r.base=lookup->rttext;
r.length=strlen(lookup->rttext);
result = dns_rdatatype_fromtext(&rdtype, &r);
check_result (result, "dns_rdatatype_fromtext");
if (rdtype == dns_rdatatype_axfr) {
check_result(result, "dns_rdatatype_fromtext");
if (rdtype == dns_rdatatype_axfr) {
lookup->doing_xfr = ISC_TRUE;
/* Force TCP mode if we're doing an xfr */
/*
* Force TCP mode if we're doing an xfr.
*/
tcp_mode = ISC_TRUE;
}
r.base=lookup->rctext;
r.length=strlen(lookup->rctext);
result = dns_rdataclass_fromtext(&rdclass, &r);
check_result (result, "dns_rdataclass_fromtext");
check_result(result, "dns_rdataclass_fromtext");
add_type(lookup->sendmsg, lookup->name, rdclass, rdtype);
isc_buffer_init (&lookup->sendbuf, lookup->sendspace, COMMSIZE,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&lookup->sendbuf, lookup->sendspace, COMMSIZE);
result = dns_message_renderbegin(lookup->sendmsg, &lookup->sendbuf);
check_result (result, "dns_message_renderbegin");
check_result(result, "dns_message_renderbegin");
result = dns_message_rendersection(lookup->sendmsg,
DNS_SECTION_QUESTION,0);
check_result (result, "dns_message_rendersection");
DNS_SECTION_QUESTION, 0);
check_result(result, "dns_message_rendersection");
result = dns_message_renderend(lookup->sendmsg);
check_result (result, "dns_message_renderend");
check_result(result, "dns_message_renderend");
lookup->pending = ISC_FALSE;
@ -356,33 +346,30 @@ setup_lookup(dig_lookup_t *lookup) {
serv = ISC_LIST_NEXT(serv, link)) {
query = isc_mem_allocate(mctx, sizeof(dig_query_t));
if (query == NULL)
fatal ("Memory allocation failure.");
fatal("Memory allocation failure.");
query->lookup = lookup;
query->working = ISC_FALSE;
query->waiting_connect = ISC_FALSE;
query->first_pass = ISC_TRUE;
query->first_soa_rcvd = ISC_FALSE;
query->servname = serv->servername;
ISC_LIST_INIT (query->sendlist);
ISC_LIST_INIT (query->recvlist);
ISC_LIST_INIT (query->lengthlist);
ISC_LIST_INIT(query->sendlist);
ISC_LIST_INIT(query->recvlist);
ISC_LIST_INIT(query->lengthlist);
query->sock = NULL;
isc_buffer_init (&query->recvbuf, query->recvspace,
COMMSIZE, ISC_BUFFERTYPE_BINARY);
isc_buffer_init (&query->lengthbuf, query->lengthspace,
2, ISC_BUFFERTYPE_BINARY);
isc_buffer_init (&query->slbuf, query->slspace,
2, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&query->recvbuf, query->recvspace, COMMSIZE);
isc_buffer_init(&query->lengthbuf, query->lengthspace, 2);
isc_buffer_init(&query->slbuf, query->slspace, 2);
ISC_LIST_ENQUEUE (lookup->q, query, link);
ISC_LIST_ENQUEUE(lookup->q, query, link);
}
}
static void
send_done(isc_task_t *task, isc_event_t *event) {
UNUSED (task);
isc_event_free (&event);
UNUSED(task);
isc_event_free(&event);
}
static void
@ -390,7 +377,7 @@ cancel_lookup(dig_lookup_t *lookup) {
dig_query_t *query;
#ifdef DEBUG
fputs ("Cancelling all queries",stderr);
fputs("Cancelling all queries", stderr);
#endif
if (!lookup->pending)
return;
@ -399,8 +386,8 @@ cancel_lookup(dig_lookup_t *lookup) {
query != NULL;
query = ISC_LIST_NEXT(query, link)) {
if (query->working) {
isc_socket_cancel (query->sock, task,
ISC_SOCKCANCEL_ALL);
isc_socket_cancel(query->sock, task,
ISC_SOCKCANCEL_ALL);
}
}
}
@ -414,34 +401,34 @@ connect_timeout(isc_task_t *task, isc_event_t *event) {
isc_buffer_t *b;
isc_region_t r;
lookup=event->ev_arg;
lookup = event->ev_arg;
REQUIRE (event->ev_type == ISC_TIMEREVENT_IDLE);
REQUIRE(event->ev_type == ISC_TIMEREVENT_IDLE);
result = isc_buffer_allocate(mctx, &b, 256, ISC_BUFFERTYPE_TEXT);
check_result (result, "isc_buffer_allocate");
result = isc_buffer_allocate(mctx, &b, 256);
check_result(result, "isc_buffer_allocate");
for (q = ISC_LIST_HEAD(lookup->q);
q != NULL;
q = ISC_LIST_NEXT(q, link)) {
if (q->working) {
isc_buffer_clear (b);
isc_buffer_clear(b);
result = isc_sockaddr_totext(&q->sockaddr, b);
check_result (result, "isc_sockaddr_totext");
isc_buffer_used(b, &r);
printf (
";; Connection to server %.*s for %s failed: Connection timed out.\n",
(int)r.length, r.base, q->lookup->textname);
check_result(result, "isc_sockaddr_totext");
isc_buffer_usedregion(b, &r);
printf(";; Connection to server %.*s for %s failed: "
"Connection timed out.\n",
(int)r.length, r.base, q->lookup->textname);
isc_socket_cancel(q->sock, task, ISC_SOCKCANCEL_ALL);
}
}
ENSURE (lookup->timer != NULL);
isc_timer_detach (&lookup->timer);
isc_buffer_free (&b);
isc_event_free (&event);
ENSURE(lookup->timer != NULL);
isc_timer_detach(&lookup->timer);
isc_buffer_free(&b);
isc_event_free(&event);
}
static void
recv_done(isc_task_t *task, isc_event_t *event) ;
recv_done(isc_task_t *task, isc_event_t *event);
static void
tcp_length_done(isc_task_t *task, isc_event_t *event) {
@ -452,60 +439,59 @@ tcp_length_done(isc_task_t *task, isc_event_t *event) {
dig_query_t *query=NULL;
isc_uint16_t length;
UNUSED (task);
UNUSED(task);
#ifdef DEBUG
fputs ("In tcp_length_done",stderr);
fputs("In tcp_length_done", stderr);
#endif
REQUIRE (event->ev_type == ISC_SOCKEVENT_RECVDONE);
REQUIRE(event->ev_type == ISC_SOCKEVENT_RECVDONE);
sevent = (isc_socketevent_t *)event;
query = event->ev_arg;
if (sevent->result == ISC_R_CANCELED) {
query->working = ISC_FALSE;
isc_socket_detach (&query->sock);
isc_socket_detach(&query->sock);
check_next_lookup(query->lookup);
isc_event_free (&event);
isc_event_free(&event);
return;
}
if (sevent->result != ISC_R_SUCCESS) {
result = isc_buffer_allocate(mctx, &b, 256,
ISC_BUFFERTYPE_TEXT);
check_result (result, "isc_buffer_allocate");
result = isc_buffer_allocate(mctx, &b, 256);
check_result(result, "isc_buffer_allocate");
result = isc_sockaddr_totext(&query->sockaddr, b);
check_result (result, "isc_sockaddr_totext");
isc_buffer_used(b, &r);
printf ("%.*s: %s\n",(int)r.length, r.base,
isc_result_totext(sevent->result));
isc_buffer_free (&b);
check_result(result, "isc_sockaddr_totext");
isc_buffer_usedregion(b, &r);
printf("%.*s: %s\n", (int)r.length, r.base,
isc_result_totext(sevent->result));
isc_buffer_free(&b);
query->working = ISC_FALSE;
isc_socket_detach (&query->sock);
isc_socket_detach(&query->sock);
check_next_lookup(query->lookup);
isc_event_free (&event);
isc_event_free(&event);
return;
}
b = ISC_LIST_HEAD(sevent->bufferlist);
ISC_LIST_DEQUEUE (sevent->bufferlist, &query->lengthbuf, link);
ISC_LIST_DEQUEUE(sevent->bufferlist, &query->lengthbuf, link);
length = isc_buffer_getuint16(b);
if (length > COMMSIZE)
fatal ("Length was longer than I can handle!");
/* XXXMWS Fix the above. */
/* Even though the buffer was already init'ed, we need
to redo it now, to force the length we want. */
isc_buffer_invalidate (&query->recvbuf);
isc_buffer_init(&query->recvbuf, query->recvspace,
length, ISC_BUFFERTYPE_BINARY);
ENSURE (ISC_LIST_EMPTY (query->recvlist));
ISC_LIST_ENQUEUE (query->recvlist, &query->recvbuf, link);
result = isc_socket_recvv (query->sock, &query->recvlist,
length, task, recv_done,
query);
check_result (result, "isc_socket_recvv");
/*
* Even though the buffer was already init'ed, we need
* to redo it now, to force the length we want.
*/
isc_buffer_invalidate(&query->recvbuf);
isc_buffer_init(&query->recvbuf, query->recvspace, length);
ENSURE(ISC_LIST_EMPTY(query->recvlist));
ISC_LIST_ENQUEUE(query->recvlist, &query->recvbuf, link);
result = isc_socket_recvv(query->sock, &query->recvlist, length, task,
recv_done, query);
check_result(result, "isc_socket_recvv");
#ifdef DEBUG
fprintf (stderr,"Resubmitted recv request with length %d\n",length);
fprintf(stderr, "Resubmitted recv request with length %d\n", length);
#endif
isc_event_free (&event);
isc_event_free(&event);
}
static void
@ -514,13 +500,12 @@ launch_next_query(dig_query_t *query, isc_boolean_t include_question) {
if (!query->lookup->pending) {
#ifdef DEBUG
fputs ("Ignoring launch_next_query because !pending.",
stderr);
fputs("Ignoring launch_next_query because !pending.", stderr);
#endif
isc_socket_detach (&query->sock);
isc_socket_detach(&query->sock);
query->working = ISC_FALSE;
query->waiting_connect = ISC_FALSE;
check_next_lookup (query->lookup);
check_next_lookup(query->lookup);
return;
}
@ -535,14 +520,14 @@ launch_next_query(dig_query_t *query, isc_boolean_t include_question) {
result = isc_socket_recvv(query->sock, &query->lengthlist, 0, task,
tcp_length_done, query);
check_result (result, "isc_socket_recvv");
check_result(result, "isc_socket_recvv");
sendcount++;
#ifdef DEBUG
fputs ("Sending a request.",stderr);
fputs("Sending a request.", stderr);
#endif
result = isc_socket_sendv(query->sock, &query->sendlist, task,
send_done, query);
check_result (result, "isc_socket_recvv");
check_result(result, "isc_socket_recvv");
query->waiting_connect = ISC_FALSE;
check_next_lookup(query->lookup);
return;
@ -556,38 +541,37 @@ connect_done(isc_task_t *task, isc_event_t *event) {
isc_buffer_t *b;
isc_region_t r;
UNUSED (task);
UNUSED(task);
REQUIRE (event->ev_type == ISC_SOCKEVENT_CONNECT);
REQUIRE(event->ev_type == ISC_SOCKEVENT_CONNECT);
sevent = (isc_socketevent_t *)event;
query = sevent->ev_arg;
REQUIRE (query->waiting_connect);
REQUIRE(query->waiting_connect);
query->waiting_connect = ISC_FALSE;
#ifdef DEBUG
fputs ("In connect_done.",stderr);
fputs("In connect_done.", stderr);
#endif
if (sevent->result != ISC_R_SUCCESS) {
result = isc_buffer_allocate(mctx, &b, 256,
ISC_BUFFERTYPE_TEXT);
check_result (result, "isc_buffer_allocate");
result = isc_buffer_allocate(mctx, &b, 256);
check_result(result, "isc_buffer_allocate");
result = isc_sockaddr_totext(&query->sockaddr, b);
check_result (result, "isc_sockaddr_totext");
isc_buffer_used(b, &r);
printf (";; Connection to server %.*s for %s failed: %s.\n",
(int)r.length, r.base, query->lookup->textname,
isc_result_totext(sevent->result));
check_result(result, "isc_sockaddr_totext");
isc_buffer_usedregion(b, &r);
printf(";; Connection to server %.*s for %s failed: %s.\n",
(int)r.length, r.base, query->lookup->textname,
isc_result_totext(sevent->result));
isc_buffer_free(&b);
query->working = ISC_FALSE;
query->waiting_connect = ISC_FALSE;
check_next_lookup(query->lookup);
isc_event_free (&event);
isc_event_free(&event);
return;
}
isc_event_free (&event);
launch_next_query (query, ISC_TRUE);
isc_event_free(&event);
launch_next_query(query, ISC_TRUE);
}
static isc_boolean_t
@ -595,17 +579,17 @@ msg_contains_soa(dns_message_t *msg, dig_query_t *query) {
isc_result_t result;
dns_name_t *name=NULL;
result = dns_message_findname (msg, DNS_SECTION_ANSWER,
query->lookup->name, dns_rdatatype_soa,
0, &name, NULL);
result = dns_message_findname(msg, DNS_SECTION_ANSWER,
query->lookup->name, dns_rdatatype_soa,
0, &name, NULL);
if (result == ISC_R_SUCCESS) {
#ifdef DEBUG
fputs ("Found SOA",stderr);
fputs("Found SOA", stderr);
#endif
return (ISC_TRUE);
} else {
#ifdef DEBUG
fprintf (stderr,"Didn't find SOA, result=%d:%s\n",
fprintf(stderr, "Didn't find SOA, result=%d:%s\n",
result, dns_result_totext(result));
#endif
return (ISC_FALSE);
@ -614,11 +598,11 @@ msg_contains_soa(dns_message_t *msg, dig_query_t *query) {
}
static void
recv_done (isc_task_t *task, isc_event_t *event) {
isc_socketevent_t *sevent=NULL;
dig_query_t *query=NULL;
isc_buffer_t *b=NULL;
dns_message_t *msg=NULL;
recv_done(isc_task_t *task, isc_event_t *event) {
isc_socketevent_t *sevent = NULL;
dig_query_t *query = NULL;
isc_buffer_t *b = NULL;
dns_message_t *msg = NULL;
isc_result_t result;
isc_buffer_t ab;
char abspace[MXNAME];
@ -628,22 +612,22 @@ recv_done (isc_task_t *task, isc_event_t *event) {
sendcount--;
#ifdef DEBUG
fprintf (stderr,"In recv_done, counter down to %d\n",sendcount);
fprintf(stderr, "In recv_done, counter down to %d\n", sendcount);
#endif
REQUIRE (event->ev_type == ISC_SOCKEVENT_RECVDONE);
REQUIRE(event->ev_type == ISC_SOCKEVENT_RECVDONE);
sevent = (isc_socketevent_t *)event;
query = event->ev_arg;
if (!query->lookup->pending) {
#ifdef DEBUG
fprintf (stderr,"No longer pending. Got %s\n",
isc_result_totext (sevent->result));
fprintf(stderr, "No longer pending. Got %s\n",
isc_result_totext(sevent->result));
#endif
query->working = ISC_FALSE;
query->waiting_connect = ISC_FALSE;
cancel_lookup (query->lookup);
cancel_lookup(query->lookup);
check_next_lookup(query->lookup);
isc_event_free (&event);
isc_event_free(&event);
return;
}
@ -652,11 +636,11 @@ recv_done (isc_task_t *task, isc_event_t *event) {
ISC_LIST_DEQUEUE(sevent->bufferlist, &query->recvbuf, link);
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE,
&msg);
check_result (result, "dns_message_create");
check_result(result, "dns_message_create");
result = dns_message_parse(msg, b, ISC_TRUE);
if (result != ISC_R_SUCCESS)
hex_dump (b);
check_result (result, "dns_message_parse");
hex_dump(b);
check_result(result, "dns_message_parse");
if (query->lookup->xfr_q == NULL)
query->lookup->xfr_q = query;
if (query->lookup->xfr_q == query) {
@ -664,58 +648,57 @@ recv_done (isc_task_t *task, isc_event_t *event) {
query->lookup->doing_xfr)
printmessage(msg, ISC_FALSE);
else
printmessage (msg, ISC_TRUE);
printmessage(msg, ISC_TRUE);
}
#ifdef DEBUG
if (query->lookup->pending)
fputs ("Still pending.",stderr);
fputs("Still pending.", stderr);
#endif
if (query->lookup->doing_xfr) {
if (!query->first_soa_rcvd) {
if (!msg_contains_soa(msg,query)) {
puts (
"; Transfer failed. Didn't start with SOA answer.");
if (!msg_contains_soa(msg, query)) {
puts("; Transfer failed. "
"Didn't start with SOA answer.");
query->working = ISC_FALSE;
check_next_lookup (query->lookup);
isc_event_free (&event);
check_next_lookup(query->lookup);
isc_event_free(&event);
return;
}
else {
query->first_soa_rcvd = ISC_TRUE;
launch_next_query (query, ISC_FALSE);
launch_next_query(query, ISC_FALSE);
}
}
else {
if (msg_contains_soa(msg, query)) {
cancel_lookup (query->lookup);
cancel_lookup(query->lookup);
query->working = ISC_FALSE;
check_next_lookup (query->lookup);
isc_event_free (&event);
check_next_lookup(query->lookup);
isc_event_free(&event);
return;
}
else {
launch_next_query (query, ISC_FALSE);
launch_next_query(query, ISC_FALSE);
}
}
}
else {
query->working = ISC_FALSE;
cancel_lookup (query->lookup);
cancel_lookup(query->lookup);
}
if (!query->lookup->pending) {
isc_buffer_init (&ab, abspace, MXNAME,
ISC_BUFFERTYPE_TEXT);
check_result (result,"isc_buffer_init");
result = isc_sockaddr_totext (&sevent->address, &ab);
check_result (result, "isc_sockaddr_totext");
isc_buffer_used (&ab, &r);
isc_buffer_init(&ab, abspace, MXNAME);
check_result(result, "isc_buffer_init");
result = isc_sockaddr_totext(&sevent->address, &ab);
check_result(result, "isc_sockaddr_totext");
isc_buffer_usedregion(&ab, &r);
if (!short_form)
printf ("; Received %u bytes from %s\n",
b->used, r.base);
check_next_lookup (query->lookup);
printf("; Received %u bytes from %s\n",
b->used, r.base);
check_next_lookup(query->lookup);
}
dns_message_destroy (&msg);
isc_event_free (&event);
dns_message_destroy(&msg);
isc_event_free(&event);
return;
}
/* In truth, we should never get into the CANCELED routine, since
@ -724,10 +707,11 @@ recv_done (isc_task_t *task, isc_event_t *event) {
query->working = ISC_FALSE;
query->waiting_connect = ISC_FALSE;
check_next_lookup(query->lookup);
isc_event_free (&event);
isc_event_free(&event);
return;
}
fatal ("recv_done got result %s",isc_result_totext(sevent->result));
fatal("recv_done got result %s",
isc_result_totext(sevent->result));
}
static void
@ -758,15 +742,14 @@ do_lookup_tcp(dig_lookup_t *lookup) {
isc_result_t result;
#ifdef DEBUG
fputs ("Starting a TCP lookup",stderr);
fputs("Starting a TCP lookup", stderr);
#endif
lookup->pending = ISC_TRUE;
isc_interval_set (&lookup->interval, timeout, 0);
result = isc_timer_create (timermgr, isc_timertype_once,
NULL, &lookup->interval, task,
connect_timeout, lookup,
&lookup->timer);
check_result (result, "isc_timer_create");
isc_interval_set(&lookup->interval, timeout, 0);
result = isc_timer_create(timermgr, isc_timertype_once, NULL,
&lookup->interval, task, connect_timeout,
lookup, &lookup->timer);
check_result(result, "isc_timer_create");
for (query = ISC_LIST_HEAD(lookup->q);
query != NULL;
@ -775,14 +758,12 @@ do_lookup_tcp(dig_lookup_t *lookup) {
query->waiting_connect = ISC_TRUE;
get_address(query->servname, port, &query->sockaddr);
result = isc_socket_create (socketmgr,
isc_sockaddr_pf(&query->sockaddr),
isc_sockettype_tcp,
&query->sock) ;
check_result (result, "isc_socket_create");
result = isc_socket_connect (query->sock,
&query->sockaddr, task,
connect_done, query);
result = isc_socket_create(socketmgr,
isc_sockaddr_pf(&query->sockaddr),
isc_sockettype_tcp, &query->sock) ;
check_result(result, "isc_socket_create");
result = isc_socket_connect(query->sock, &query->sockaddr,
task, connect_done, query);
check_result (result, "isc_socket_connect");
}
}
@ -793,15 +774,14 @@ do_lookup_udp(dig_lookup_t *lookup) {
isc_result_t result;
#ifdef DEBUG
fputs ("Starting a UDP lookup.",stderr);
fputs("Starting a UDP lookup.", stderr);
#endif
lookup->pending = ISC_TRUE;
isc_interval_set (&lookup->interval, timeout, 0);
result = isc_timer_create (timermgr, isc_timertype_once,
NULL, &lookup->interval, task,
connect_timeout, lookup,
&lookup->timer);
check_result (result, "isc_timer_create");
isc_interval_set(&lookup->interval, timeout, 0);
result = isc_timer_create(timermgr, isc_timertype_once, NULL,
&lookup->interval, task, connect_timeout,
lookup, &lookup->timer);
check_result(result, "isc_timer_create");
for (query = ISC_LIST_HEAD(lookup->q);
query != NULL;
@ -810,24 +790,23 @@ do_lookup_udp(dig_lookup_t *lookup) {
query->waiting_connect = ISC_FALSE;
get_address(query->servname, port, &query->sockaddr);
result = isc_socket_create (socketmgr,
isc_sockaddr_pf(&query->sockaddr),
isc_sockettype_udp,
&query->sock) ;
check_result (result, "isc_socket_create");
ISC_LIST_ENQUEUE (query->recvlist, &query->recvbuf, link);
result = isc_socket_recvv (query->sock, &query->recvlist,
1, task, recv_done, query);
check_result (result, "isc_socket_recvv");
result = isc_socket_create(socketmgr,
isc_sockaddr_pf(&query->sockaddr),
isc_sockettype_udp, &query->sock) ;
check_result(result, "isc_socket_create");
ISC_LIST_ENQUEUE(query->recvlist, &query->recvbuf, link);
result = isc_socket_recvv(query->sock, &query->recvlist, 1,
task, recv_done, query);
check_result(result, "isc_socket_recvv");
sendcount++;
#ifdef DEBUG
fprintf (stderr,"Sent count number %d\n",sendcount);
fprintf(stderr, "Sent count number %d\n", sendcount);
#endif
ISC_LIST_ENQUEUE (query->sendlist, &lookup->sendbuf, link);
ISC_LIST_ENQUEUE(query->sendlist, &lookup->sendbuf, link);
result = isc_socket_sendtov(query->sock, &query->sendlist,
task, send_done, query,
&query->sockaddr, NULL);
check_result (result, "isc_socket_sendtov");
check_result(result, "isc_socket_sendtov");
}
}
@ -843,42 +822,42 @@ free_lists(void) {
q = ISC_LIST_HEAD(l->q);
while (q != NULL) {
if (q->sock != NULL)
isc_socket_detach (&q->sock);
if (ISC_LINK_LINKED (&q->recvbuf, link))
ISC_LIST_DEQUEUE (q->recvlist,
&q->recvbuf, link);
if (ISC_LINK_LINKED (&q->lengthbuf, link))
ISC_LIST_DEQUEUE (q->lengthlist,
&q->lengthbuf, link);
isc_buffer_invalidate (&q->recvbuf);
isc_buffer_invalidate (&q->lengthbuf);
isc_socket_detach(&q->sock);
if (ISC_LINK_LINKED(&q->recvbuf, link))
ISC_LIST_DEQUEUE(q->recvlist, &q->recvbuf,
link);
if (ISC_LINK_LINKED(&q->lengthbuf, link))
ISC_LIST_DEQUEUE(q->lengthlist, &q->lengthbuf,
link);
isc_buffer_invalidate(&q->recvbuf);
isc_buffer_invalidate(&q->lengthbuf);
ptr = q;
q = ISC_LIST_NEXT(q, link);
isc_mem_free (mctx, ptr);
isc_mem_free(mctx, ptr);
}
if (l->sendmsg != NULL)
dns_message_destroy (&l->sendmsg);
dns_message_destroy(&l->sendmsg);
if (l->timer != NULL)
isc_timer_detach (&l->timer);
isc_timer_detach(&l->timer);
ptr = l;
l = ISC_LIST_NEXT(l, link);
isc_mem_free (mctx, ptr);
isc_mem_free(mctx, ptr);
}
s = ISC_LIST_HEAD(server_list);
while (s != NULL) {
ptr = s;
s = ISC_LIST_NEXT(s, link);
isc_mem_free (mctx, ptr);
isc_mem_free(mctx, ptr);
}
dns_name_invalidate (&rootorg);
dns_name_invalidate(&rootorg);
if (socketmgr != NULL)
isc_socketmgr_destroy (&socketmgr);
isc_socketmgr_destroy(&socketmgr);
if (timermgr != NULL)
isc_timermgr_destroy (&timermgr);
isc_timermgr_destroy(&timermgr);
if (task != NULL)
isc_task_detach (&task);
isc_task_detach(&task);
if (taskmgr != NULL)
isc_taskmgr_destroy (&taskmgr);
isc_taskmgr_destroy(&taskmgr);
}
int
@ -905,8 +884,8 @@ main(int argc, char **argv) {
isc_mem_stats(mctx, stderr);
#endif
isc_app_finish();
if (mctx != NULL) {
isc_mem_destroy (&mctx);
}
if (mctx != NULL)
isc_mem_destroy(&mctx);
return (0);
}

View file

@ -171,7 +171,7 @@ say_message(char *host, char *msg, dns_rdata_t *rdata, isc_buffer_t *target) {
result = dns_rdata_totext( rdata, NULL, target);
check_result(result, "dns_rdata_totext");
isc_buffer_used(target, &r);
isc_buffer_usedregion(target, &r);
printf ( "%s %s %.*s\n", host, msg, (int)r.length,
(char *)r.base);
}
@ -212,7 +212,7 @@ printsection(dns_message_t *msg, dns_section_t sectionid, char *section_name,
name = NULL;
dns_message_currentname(msg, sectionid, &name);
isc_buffer_init(&target, t, sizeof t, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, t, sizeof(t));
first = ISC_TRUE;
print_name = name;
@ -261,7 +261,7 @@ printsection(dns_message_t *msg, dns_section_t sectionid, char *section_name,
}
}
if (!short_form) {
isc_buffer_used(&target, &r);
isc_buffer_usedregion(&target, &r);
if (no_rdata)
printf(";%.*s", (int)r.length,
(char *)r.base);
@ -292,13 +292,13 @@ printrdata(dns_message_t *msg, dns_rdataset_t *rdataset, dns_name_t *owner,
if (headers)
printf(";; %s SECTION:\n", set_name);
isc_buffer_init(&target, t, sizeof t, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, t, sizeof(t));
result = dns_rdataset_totext(rdataset, owner, ISC_FALSE, ISC_FALSE,
&target);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_used(&target, &r);
isc_buffer_usedregion(&target, &r);
printf("%.*s", (int)r.length, (char *)r.base);
return (ISC_R_SUCCESS);
@ -307,11 +307,9 @@ printrdata(dns_message_t *msg, dns_rdataset_t *rdataset, dns_name_t *owner,
isc_result_t
printmessage(dns_message_t *msg, isc_boolean_t headers) {
isc_boolean_t did_flag = ISC_FALSE;
dns_rdataset_t *opt, *tsig;
dns_rdataset_t *opt, *tsig = NULL;
dns_name_t *tsigname;
isc_result_t result;
result = ISC_R_SUCCESS;
isc_result_t result = ISC_R_SUCCESS;
if (!short_form) {
printf(";; ->>HEADER<<- opcode: %s, status: %s, id: %u\n",
@ -346,7 +344,8 @@ printmessage(dns_message_t *msg, isc_boolean_t headers) {
printf("%scd", did_flag ? " " : "");
did_flag = ISC_TRUE;
}
printf("; QUERY: %u, ANSWER: %u, AUTHORITY: %u, ADDITIONAL: %u\n",
printf("; QUERY: %u, ANSWER: %u, "
"AUTHORITY: %u, ADDITIONAL: %u\n",
msg->counts[DNS_SECTION_QUESTION],
msg->counts[DNS_SECTION_ANSWER],
msg->counts[DNS_SECTION_AUTHORITY],

View file

@ -91,6 +91,8 @@ struct dig_server {
/* Routines in dighost.c */
void
fatal(char *format, ...) ;
inline void
check_result(isc_result_t result, char *msg);
isc_boolean_t
isclass(char *text) ;
isc_boolean_t

View file

@ -111,9 +111,9 @@ nametostr(dns_name_t *name) {
isc_region_t r;
static char data[1025];
isc_buffer_init(&b, data, sizeof(data), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, data, sizeof(data));
dns_name_totext(name, ISC_FALSE, &b);
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
r.base[r.length] = 0;
return (char *) r.base;
}
@ -125,9 +125,9 @@ typetostr(const dns_rdatatype_t type) {
isc_region_t r;
static char data[10];
isc_buffer_init(&b, data, sizeof(data), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, data, sizeof(data));
dns_rdatatype_totext(type, &b);
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
r.base[r.length] = 0;
return (char *) r.base;
}
@ -139,9 +139,9 @@ algtostr(const dns_secalg_t alg) {
isc_region_t r;
static char data[10];
isc_buffer_init(&b, data, sizeof(data), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, data, sizeof(data));
dns_secalg_totext(alg, &b);
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
r.base[r.length] = 0;
return (char *) r.base;
}
@ -198,7 +198,7 @@ iszonekey(signer_key_t *key, dns_db_t *db) {
isc_buffer_t b;
isc_result_t result;
isc_buffer_init(&b, origin, sizeof(origin), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, origin, sizeof(origin));
result = dns_name_totext(dns_db_origin(db), ISC_FALSE, &b);
check_result(result, "dns_name_totext()");
@ -295,8 +295,7 @@ setverifies(dns_name_t *name, dns_rdataset_t *set, signer_key_t *key,
ISC_LIST_APPEND(arraylist, tdata, link); \
if (trdata == NULL || tdata == NULL) \
check_result(ISC_R_FAILURE, "isc_mem_get"); \
isc_buffer_init(&b, tdata->array, sizeof(tdata->array), \
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b, tdata->array, sizeof(tdata->array));
/*
* Signs a set. Goes through contortions to decide if each SIG should
@ -882,10 +881,10 @@ loadzone(char *file, char *origin, dns_zone_t **zone) {
isc_result_t result;
len = strlen(origin);
isc_buffer_init(&b, origin, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, origin, len);
isc_buffer_add(&b, len);
isc_buffer_init(&b2, namedata, sizeof(namedata), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b2, namedata, sizeof(namedata));
dns_name_init(&name, NULL);
result = dns_name_fromtext(&name, &b, dns_rootname, ISC_FALSE, &b2);

View file

@ -381,7 +381,7 @@ client_init_gabn(client_t *client)
* Set up the internal buffer to point to the receive region.
*/
isc_buffer_init(&client->recv_buffer, client->buffer,
LWRES_RECVLENGTH, ISC_BUFFERTYPE_TEXT);
LWRES_RECVLENGTH);
}
void
@ -401,5 +401,5 @@ client_init_gnba(client_t *client)
client->gnba.baselen = 0;
isc_buffer_init(&client->recv_buffer, client->buffer,
LWRES_RECVLENGTH, ISC_BUFFERTYPE_TEXT);
LWRES_RECVLENGTH);
}

View file

@ -497,8 +497,7 @@ process_gabn(client_t *client, lwres_buffer_t *b)
if (result != LWRES_R_SUCCESS)
goto out;
isc_buffer_init(&namebuf, req->name, req->namelen,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&namebuf, req->name, req->namelen);
isc_buffer_add(&namebuf, req->namelen);
dns_fixedname_init(&client->target_name);

View file

@ -88,7 +88,7 @@ convert_keyname(char *txtname, isc_mem_t *mctx, dns_name_t *dnsname) {
unsigned int keylen;
keylen = strlen(txtname);
isc_buffer_init(&buf, txtname, keylen, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buf, txtname, keylen);
isc_buffer_add(&buf, keylen);
dns_fixedname_init(&fixname);
result = dns_name_fromtext(dns_fixedname_name(&fixname), &buf,

View file

@ -180,7 +180,7 @@ sockaddr_format(isc_sockaddr_t *sa, char *array, unsigned int size)
{
isc_result_t result;
isc_buffer_t buf;
isc_buffer_init(&buf, array, size, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buf, array, size);
result = isc_sockaddr_totext(sa, &buf);
if (result != ISC_R_SUCCESS) {
strncpy(array, "<unknown address>", size);
@ -626,16 +626,14 @@ ns_client_send(ns_client_t *client) {
/*
* XXXRTH "tcpbuffer" is a hack to get things working.
*/
isc_buffer_init(&tcpbuffer, data, SEND_BUFFER_SIZE,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buffer, data + 2, SEND_BUFFER_SIZE - 2,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&tcpbuffer, data, SEND_BUFFER_SIZE);
isc_buffer_init(&buffer, data + 2, SEND_BUFFER_SIZE - 2);
} else {
if (client->udpsize < SEND_BUFFER_SIZE)
bufsize = client->udpsize;
else
bufsize = SEND_BUFFER_SIZE;
isc_buffer_init(&buffer, data, bufsize, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buffer, data, bufsize);
}
result = dns_message_renderbegin(client->message, &buffer);
@ -682,14 +680,14 @@ ns_client_send(ns_client_t *client) {
if (TCP_CLIENT(client)) {
socket = client->tcpsocket;
address = NULL;
isc_buffer_used(&buffer, &r);
isc_buffer_usedregion(&buffer, &r);
isc_buffer_putuint16(&tcpbuffer, (isc_uint16_t) r.length);
isc_buffer_add(&tcpbuffer, r.length);
isc_buffer_used(&tcpbuffer, &r);
isc_buffer_usedregion(&tcpbuffer, &r);
} else {
socket = dns_dispatch_getsocket(client->dispatch);
address = &client->dispevent->addr;
isc_buffer_used(&buffer, &r);
isc_buffer_usedregion(&buffer, &r);
}
CTRACE("sendto");
if ((client->attributes & NS_CLIENTATTR_PKTINFO) != 0)

View file

@ -74,7 +74,7 @@ sockaddr_format(isc_sockaddr_t *sa, char *array, unsigned int size)
{
isc_result_t result;
isc_buffer_t buf;
isc_buffer_init(&buf, array, size, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buf, array, size);
result = isc_sockaddr_totext(sa, &buf);
if (result != ISC_R_SUCCESS) {
strncpy(array, "<unknown address>", size);

View file

@ -203,8 +203,7 @@ query_newnamebuf(ns_client_t *client) {
*/
dbuf = NULL;
result = isc_buffer_allocate(client->mctx, &dbuf, 1024,
ISC_BUFFERTYPE_BINARY);
result = isc_buffer_allocate(client->mctx, &dbuf, 1024);
if (result != ISC_R_SUCCESS) {
CTRACE("query_newnamebuf: isc_buffer_allocate failed: done");
return (result);
@ -237,7 +236,7 @@ query_getnamebuf(ns_client_t *client) {
dbuf = ISC_LIST_TAIL(client->query.namebufs);
INSIST(dbuf != NULL);
isc_buffer_available(dbuf, &r);
isc_buffer_availableregion(dbuf, &r);
if (r.length < 255) {
result = query_newnamebuf(client);
if (result != ISC_R_SUCCESS) {
@ -246,7 +245,7 @@ query_getnamebuf(ns_client_t *client) {
}
dbuf = ISC_LIST_TAIL(client->query.namebufs);
isc_buffer_available(dbuf, &r);
isc_buffer_availableregion(dbuf, &r);
INSIST(r.length >= 255);
}
CTRACE("query_getnamebuf: done");
@ -308,8 +307,8 @@ query_newname(ns_client_t *client, isc_buffer_t *dbuf,
CTRACE("query_newname: dns_message_gettempname failed: done");
return (NULL);
}
isc_buffer_available(dbuf, &r);
isc_buffer_init(nbuf, r.base, r.length, ISC_BUFFERTYPE_BINARY);
isc_buffer_availableregion(dbuf, &r);
isc_buffer_init(nbuf, r.base, r.length);
dns_name_init(name, NULL);
dns_name_setbuffer(name, nbuf);
client->query.attributes |= NS_QUERYATTR_NAMEBUFUSED;
@ -2792,12 +2791,11 @@ log_query(ns_client_t *client) {
dns_name_format(client->query.qname, namebuf, sizeof(namebuf));
isc_buffer_init(&b, (unsigned char *)text, sizeof text,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, (unsigned char *)text, sizeof(text));
for (rdataset = ISC_LIST_HEAD(client->query.qname->list);
rdataset != NULL;
rdataset = ISC_LIST_NEXT(rdataset, link)) {
isc_buffer_available(&b, &r);
isc_buffer_availableregion(&b, &r);
if (r.length < 1)
return;
*r.base = ' ';
@ -2805,7 +2803,7 @@ log_query(ns_client_t *client) {
if (dns_rdatatype_totext(rdataset->type, &b) != ISC_R_SUCCESS)
return;
}
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
ns_client_log(client, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_QUERY,
ISC_LOG_DEBUG(1), "query: %s%.*s", namebuf,
(int)r.length, (char *)r.base);

View file

@ -172,7 +172,7 @@ base64_cstring_tobuffer(isc_mem_t *mctx, char *cstr, isc_buffer_t *target)
isc_lex_t *lex = NULL;
isc_boolean_t isopen = ISC_FALSE;
isc_buffer_init(&source, cstr, strlen(cstr), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, cstr, strlen(cstr));
isc_buffer_add(&source, strlen(cstr));
CHECK(isc_lex_create(mctx, 256, &lex));
CHECK(isc_lex_openbuffer(lex, &source));
@ -252,14 +252,12 @@ configure_view_dnsseckeys(dns_c_ctx_t *cctx,
keystruct.protocol = proto;
keystruct.algorithm = alg;
isc_buffer_init(&keydatabuf, keydata, sizeof(keydata),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&rrdatabuf, rrdata, sizeof(rrdata),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&keydatabuf, keydata, sizeof(keydata));
isc_buffer_init(&rrdatabuf, rrdata, sizeof(rrdata));
CHECK(base64_cstring_tobuffer(mctx, ckey->pubkey->key,
&keydatabuf));
isc_buffer_used(&keydatabuf, &r);
isc_buffer_usedregion(&keydatabuf, &r);
keystruct.datalen = r.length;
keystruct.data = r.base;
@ -716,8 +714,7 @@ configure_zone(dns_c_ctx_t *cctx, dns_c_zone_t *czone, dns_c_view_t *cview,
corigin = NULL;
/* XXX casting away const */
CHECK(dns_c_zone_getname(czone, (const char **) &corigin));
isc_buffer_init(&buffer, corigin, strlen(corigin),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer, corigin, strlen(corigin));
isc_buffer_add(&buffer, strlen(corigin));
dns_fixedname_init(&fixorigin);
CHECK(dns_name_fromtext(dns_fixedname_name(&fixorigin),

View file

@ -67,9 +67,9 @@ dns_tkeyctx_fromconfig(dns_c_ctx_t *cfg, isc_mem_t *mctx,
goto failure;
}
dns_name_init(tctx->domain, NULL);
isc_buffer_init(&b, s, strlen(s), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, s, strlen(s));
isc_buffer_add(&b, strlen(s));
isc_buffer_init(&namebuf, data, sizeof(data), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&namebuf, data, sizeof(data));
RETERR(dns_name_fromtext(&domain, &b, dns_rootname, ISC_FALSE,
&namebuf));
RETERR(dns_name_dup(&domain, mctx, tctx->domain));

View file

@ -50,11 +50,9 @@ add_initial_keys(dns_c_kdeflist_t *list, dns_tsig_keyring_t *ring,
dns_name_init(&alg, NULL);
/* Create the key name */
isc_buffer_init(&keynamesrc, key->keyid, strlen(key->keyid),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&keynamesrc, key->keyid, strlen(key->keyid));
isc_buffer_add(&keynamesrc, strlen(key->keyid));
isc_buffer_init(&keynamebuf, keynamedata, sizeof(keynamedata),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&keynamebuf, keynamedata, sizeof(keynamedata));
ret = dns_name_fromtext(&keyname, &keynamesrc, dns_rootname,
ISC_TRUE, &keynamebuf);
if (ret != ISC_R_SUCCESS)
@ -65,11 +63,9 @@ add_initial_keys(dns_c_kdeflist_t *list, dns_tsig_keyring_t *ring,
alg = *dns_tsig_hmacmd5_name;
else {
isc_buffer_init(&algsrc, key->algorithm,
strlen(key->algorithm),
ISC_BUFFERTYPE_TEXT);
strlen(key->algorithm));
isc_buffer_add(&algsrc, strlen(key->algorithm));
isc_buffer_init(&algbuf, algdata, sizeof(algdata),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&algbuf, algdata, sizeof(algdata));
ret = dns_name_fromtext(&alg, &algsrc, dns_rootname,
ISC_TRUE, &algbuf);
if (ret != ISC_R_SUCCESS)
@ -86,11 +82,9 @@ add_initial_keys(dns_c_kdeflist_t *list, dns_tsig_keyring_t *ring,
ret = ISC_R_NOMEMORY;
goto failure;
}
isc_buffer_init(&secretsrc, key->secret, strlen(key->secret),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&secretsrc, key->secret, strlen(key->secret));
isc_buffer_add(&secretsrc, strlen(key->secret));
isc_buffer_init(&secretbuf, secret, secretlen,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&secretbuf, secret, secretlen);
ret = isc_lex_create(mctx, strlen(key->secret), &lex);
if (ret != ISC_R_SUCCESS)
goto failure;
@ -100,7 +94,7 @@ add_initial_keys(dns_c_kdeflist_t *list, dns_tsig_keyring_t *ring,
ret = isc_base64_tobuffer(lex, &secretbuf, -1);
if (ret != ISC_R_SUCCESS)
goto failure;
secretlen = ISC_BUFFER_USEDCOUNT(&secretbuf);
secretlen = isc_buffer_usedlength(&secretbuf);
isc_lex_close(lex);
isc_lex_destroy(&lex);

View file

@ -1401,7 +1401,7 @@ add_sigs(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name,
unsigned int i;
dns_rdataset_init(&rdataset);
isc_buffer_init(&buffer, data, sizeof data, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buffer, data, sizeof(data));
/* Get the rdataset to sign. */
CHECK(dns_db_findnode(db, name, ISC_FALSE, &node));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: xfrout.c,v 1.58 2000/04/19 18:26:22 halley Exp $ */
/* $Id: xfrout.c,v 1.59 2000/04/27 00:00:40 tale Exp $ */
#include <config.h>
@ -263,7 +263,7 @@ log_rr(dns_name_t *name, dns_rdata_t *rdata, isc_uint32_t ttl) {
ISC_LIST_APPEND(rdl.rdata, rdata, link);
RUNTIME_CHECK(dns_rdatalist_tordataset(&rdl, &rds) == ISC_R_SUCCESS);
isc_buffer_init(&buf, mem, sizeof(mem), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buf, mem, sizeof(mem));
result = dns_rdataset_totext(&rds, name,
ISC_FALSE, ISC_FALSE, &buf);
@ -276,7 +276,7 @@ log_rr(dns_name_t *name, dns_rdata_t *rdata, isc_uint32_t ttl) {
* very long lines with a repetitive prefix.
*/
if (result == ISC_R_SUCCESS) {
isc_buffer_used(&buf, &r);
isc_buffer_usedregion(&buf, &r);
isc_log_write(XFROUT_DEBUG_LOGARGS(8),
"%.*s", (int) r.length, (char *) r.base);
} else {
@ -1119,7 +1119,7 @@ xfrout_ctx_create(isc_mem_t *mctx, ns_client_t *client, unsigned int id,
result = ISC_R_NOMEMORY;
goto failure;
}
isc_buffer_init(&xfr->buf, mem, len, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&xfr->buf, mem, len);
/*
* Allocate another temporary buffer for the compressed
@ -1131,9 +1131,8 @@ xfrout_ctx_create(isc_mem_t *mctx, ns_client_t *client, unsigned int id,
result = ISC_R_NOMEMORY;
goto failure;
}
isc_buffer_init(&xfr->txlenbuf, mem, 2, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&xfr->txbuf, (char *) mem + 2, len - 2,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&xfr->txlenbuf, mem, 2);
isc_buffer_init(&xfr->txbuf, (char *) mem + 2, len - 2);
xfr->txmem = mem;
xfr->txmemlen = len;
@ -1231,7 +1230,7 @@ sendstream(xfrout_ctx_t *xfr)
if (result != ISC_R_SUCCESS)
goto failure;
dns_name_init(qname, NULL);
isc_buffer_available(&xfr->buf, &r);
isc_buffer_availableregion(&xfr->buf, &r);
INSIST(r.length >= xfr->qname->length);
r.length = xfr->qname->length;
isc_buffer_putmem(&xfr->buf, xfr->qname->ndata,
@ -1265,7 +1264,7 @@ sendstream(xfrout_ctx_t *xfr)
xfr->stream->methods->current(xfr->stream,
&name, &ttl, &rdata);
size = name->length + 10 + rdata->length;
isc_buffer_available(&xfr->buf, &r);
isc_buffer_availableregion(&xfr->buf, &r);
if (size >= r.length) {
/*
* RR would not fit. If there are other RRs in the
@ -1294,7 +1293,7 @@ sendstream(xfrout_ctx_t *xfr)
dns_message_gettempname(msg, &msgname);
dns_name_init(msgname, NULL);
isc_buffer_available(&xfr->buf, &r);
isc_buffer_availableregion(&xfr->buf, &r);
INSIST(r.length >= name->length);
r.length = name->length;
isc_buffer_putmem(&xfr->buf, name->ndata, name->length);
@ -1304,7 +1303,7 @@ sendstream(xfrout_ctx_t *xfr)
isc_buffer_add(&xfr->buf, 10);
dns_message_gettemprdata(msg, &msgrdata);
isc_buffer_available(&xfr->buf, &r);
isc_buffer_availableregion(&xfr->buf, &r);
r.length = rdata->length;
isc_buffer_putmem(&xfr->buf, rdata->data, rdata->length);
dns_rdata_init(msgrdata);
@ -1345,7 +1344,7 @@ sendstream(xfrout_ctx_t *xfr)
CHECK(dns_message_rendersection(msg, DNS_SECTION_ANSWER, 0));
CHECK(dns_message_renderend(msg));
isc_buffer_used(&xfr->txbuf, &used);
isc_buffer_usedregion(&xfr->txbuf, &used);
isc_buffer_putuint16(&xfr->txlenbuf, used.length);
region.base = xfr->txlenbuf.base;
region.length = 2 + used.length;

View file

@ -230,10 +230,9 @@ lookup(char *target)
INSIST(target != NULL);
client = new_client();
isc_buffer_init(&t, target, strlen(target), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&t, target, strlen(target));
isc_buffer_add(&t, strlen(target));
isc_buffer_init(&namebuf, namedata, sizeof namedata,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&namebuf, namedata, sizeof(namedata));
dns_name_init(&name, NULL);
result = dns_name_fromtext(&name, &t, dns_rootname, ISC_FALSE,
&namebuf);

View file

@ -69,8 +69,7 @@ done(isc_task_t *task, isc_event_t *event) {
isc_result_totext(bevent->result));
if (bevent->result == ISC_R_SUCCESS) {
isc_buffer_init(&buffer, textname, sizeof textname,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer, textname, sizeof(textname));
for (name = ISC_LIST_HEAD(bevent->names);
name != NULL;
name = ISC_LIST_NEXT(name, link)) {
@ -81,7 +80,7 @@ done(isc_task_t *task, isc_event_t *event) {
isc_result_totext(result));
break;
}
isc_buffer_used(&buffer, &r);
isc_buffer_usedregion(&buffer, &r);
printf("%.*s\n", (int)r.length, r.base);
}
}

View file

@ -107,7 +107,7 @@ print_addresses(dns_adbfind_t *find) {
isc_region_t r;
char text[1024];
isc_buffer_init(&b, text, sizeof text, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, text, sizeof(text));
for (address = ISC_LIST_HEAD(find->list);
address != NULL;
@ -115,7 +115,7 @@ print_addresses(dns_adbfind_t *find) {
isc_buffer_clear(&b);
result = isc_sockaddr_totext(address->sockaddr, &b);
if (result == ISC_R_SUCCESS) {
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
printf("%.*s\n", (int)r.length, r.base);
} else
printf("isc_sockaddr_totext() failed: %s\n",
@ -130,11 +130,11 @@ print_name(dns_name_t *name) {
isc_region_t r;
char text[1024];
isc_buffer_init(&b, text, sizeof text, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, text, sizeof(text));
result = dns_name_totext(name, ISC_FALSE, &b);
if (result == ISC_R_SUCCESS) {
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
printf("%.*s\n", (int)r.length, r.base);
} else
printf("dns_name_totext() failed: %s\n",
@ -311,8 +311,7 @@ main(int argc, char *argv[]) {
printf("name = %s\n", argv[isc_commandline_index]);
isc_buffer_init(&b, argv[isc_commandline_index],
strlen(argv[isc_commandline_index]),
ISC_BUFFERTYPE_TEXT);
strlen(argv[isc_commandline_index]));
isc_buffer_add(&b, strlen(argv[isc_commandline_index]));
dns_fixedname_init(&name);
dns_fixedname_init(&target);

View file

@ -136,7 +136,7 @@ test(unsigned int allowed, dns_name_t *name1, dns_name_t *name2,
fprintf(stdout, "Allowed = %s\n", s);
}
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
isc_buffer_init(&source, buf1, sizeof buf1, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&source, buf1, sizeof(buf1));
RUNTIME_CHECK(dns_compress_init(&cctx, -1, mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(dns_name_towire(name1, &cctx, &source) == ISC_R_SUCCESS);
@ -172,7 +172,7 @@ test(unsigned int allowed, dns_name_t *name1, dns_name_t *name2,
}
isc_buffer_setactive(&source, source.used);
isc_buffer_init(&target, buf2, sizeof buf2, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, buf2, sizeof(buf2));
dns_decompress_init(&dctx, -1, ISC_TRUE);
dns_name_init(&name, NULL);

View file

@ -68,7 +68,7 @@ t_create(char *db_type, char *origin, char *class, char *cache,
dns_fixedname_init(&dns_origin);
len = strlen(origin);
isc_buffer_init(&origin_buffer, origin, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&origin_buffer, origin, len);
isc_buffer_add(&origin_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_origin),
&origin_buffer, NULL, ISC_FALSE, NULL);
@ -172,7 +172,7 @@ t_dns_db_load(char **av) {
dns_fixedname_init(&dns_findname);
len = strlen(findname);
isc_buffer_init(&findname_buffer, findname, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&findname_buffer, findname, len);
isc_buffer_add(&findname_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname),
&findname_buffer, NULL, ISC_FALSE, NULL);
@ -281,7 +281,7 @@ t_dns_db_zc_x(char *filename,
dns_fixedname_init(&dns_origin);
len = strlen(origin);
isc_buffer_init(&origin_buffer, origin, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&origin_buffer, origin, len);
isc_buffer_add(&origin_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_origin),
&origin_buffer, NULL, ISC_FALSE, NULL);
@ -506,7 +506,7 @@ t_dns_db_origin(char **av) {
dns_fixedname_init(&dns_dborigin);
len = strlen(origin);
isc_buffer_init(&origin_buffer, origin, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&origin_buffer, origin, len);
isc_buffer_add(&origin_buffer, len);
dns_result = dns_db_load(db, filename);
@ -621,11 +621,10 @@ t_dns_db_class(char **av) {
}
db_rdataclass = dns_db_class(db);
if (db_rdataclass == rdataclass) {
if (db_rdataclass == rdataclass)
result = T_PASS;
}
else {
isc_buffer_init(&isc_buffer, buf, CLASSBUFLEN, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&isc_buffer, buf, CLASSBUFLEN);
dns_rdataclass_totext(db_rdataclass, &isc_buffer);
t_info("dns_db_class returned %.*s, expected %s\n",
isc_buffer.used, isc_buffer.base, class);
@ -716,7 +715,7 @@ t_dns_db_currentversion(char **av) {
dns_fixedname_init(&dns_findname);
len = strlen(findname);
isc_buffer_init(&findname_buffer, findname, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&findname_buffer, findname, len);
isc_buffer_add(&findname_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname),
&findname_buffer, NULL, ISC_FALSE, NULL);
@ -960,7 +959,7 @@ t_dns_db_newversion(char **av) {
dns_fixedname_init(&dns_newname);
len = strlen(newname);
isc_buffer_init(&newname_buffer, newname, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&newname_buffer, newname, len);
isc_buffer_add(&newname_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_newname),
&newname_buffer, NULL, ISC_FALSE, NULL);
@ -1238,7 +1237,7 @@ t_dns_db_closeversion_1(char **av) {
dns_fixedname_init(&dns_existingname);
len = strlen(existing_name);
isc_buffer_init(&name_buffer, existing_name, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&name_buffer, existing_name, len);
isc_buffer_add(&name_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_existingname),
&name_buffer, NULL, ISC_FALSE, NULL);
@ -1306,7 +1305,7 @@ t_dns_db_closeversion_1(char **av) {
dns_fixedname_init(&dns_newname);
len = strlen(new_name);
isc_buffer_init(&name_buffer, new_name, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&name_buffer, new_name, len);
isc_buffer_add(&name_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_newname),
&name_buffer, NULL, ISC_FALSE, NULL);
@ -1596,7 +1595,7 @@ t_dns_db_closeversion_2(char **av) {
dns_fixedname_init(&dns_existingname);
len = strlen(existing_name);
isc_buffer_init(&name_buffer, existing_name, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&name_buffer, existing_name, len);
isc_buffer_add(&name_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_existingname),
&name_buffer, NULL, ISC_FALSE, NULL);
@ -1664,7 +1663,7 @@ t_dns_db_closeversion_2(char **av) {
dns_fixedname_init(&dns_newname);
len = strlen(new_name);
isc_buffer_init(&name_buffer, new_name, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&name_buffer, new_name, len);
isc_buffer_add(&name_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_newname),
&name_buffer, NULL, ISC_FALSE, NULL);
@ -1974,7 +1973,7 @@ t_dns_db_expirenode(char **av) {
dns_fixedname_init(&dns_existingname);
len = strlen(existing_name);
isc_buffer_init(&name_buffer, existing_name, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&name_buffer, existing_name, len);
isc_buffer_add(&name_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_existingname),
&name_buffer, NULL, ISC_FALSE, NULL);
@ -2178,7 +2177,7 @@ t_dns_db_findnode_1(char **av) {
dns_fixedname_init(&dns_name);
len = strlen(find_name);
isc_buffer_init(&name_buffer, find_name, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&name_buffer, find_name, len);
isc_buffer_add(&name_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_name),
&name_buffer, NULL, ISC_FALSE, NULL);
@ -2313,7 +2312,7 @@ t_dns_db_findnode_2(char **av) {
/* make sure the name isn't there */
len = strlen(newname);
isc_buffer_init(&name_buffer, newname, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&name_buffer, newname, len);
isc_buffer_add(&name_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_name),
&name_buffer, NULL, ISC_FALSE, NULL);
@ -2482,7 +2481,7 @@ t_dns_db_find_x(char **av) {
dns_fixedname_init(&dns_findname);
len = strlen(findname);
isc_buffer_init(&findname_buffer, findname, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&findname_buffer, findname, len);
isc_buffer_add(&findname_buffer, len);
dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname),
&findname_buffer, NULL, ISC_FALSE, NULL);

View file

@ -96,10 +96,10 @@ print_rdataset(dns_name_t *name, dns_rdataset_t *rdataset) {
isc_result_t result;
isc_region_t r;
isc_buffer_init(&text, t, sizeof t, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&text, t, sizeof(t));
result = dns_rdataset_totext(rdataset, name, ISC_FALSE, ISC_FALSE,
&text);
isc_buffer_used(&text, &r);
isc_buffer_usedregion(&text, &r);
if (result == ISC_R_SUCCESS)
printf("%.*s", (int)r.length, (char *)r.base);
else
@ -138,7 +138,7 @@ select_db(char *origintext) {
return (cache_dbi);
}
len = strlen(origintext);
isc_buffer_init(&source, origintext, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, origintext, len);
isc_buffer_add(&source, len);
dns_fixedname_init(&forigin);
origin = dns_fixedname_name(&forigin);
@ -190,8 +190,7 @@ list(dbinfo *dbi, char *seektext) {
if (result == ISC_R_SUCCESS) {
if (seektext != NULL) {
len = strlen(seektext);
isc_buffer_init(&source, seektext, len,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, seektext, len);
isc_buffer_add(&source, len);
dns_fixedname_init(&fseekname);
seekname = dns_fixedname_name(&fseekname);
@ -276,7 +275,7 @@ load(char *filename, char *origintext, isc_boolean_t cache) {
dbi->ascending = ascending;
len = strlen(origintext);
isc_buffer_init(&source, origintext, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, origintext, len);
isc_buffer_add(&source, len);
dns_fixedname_init(&forigin);
origin = dns_fixedname_name(&forigin);
@ -730,9 +729,9 @@ main(int argc, char *argv[]) {
continue;
}
isc_buffer_init(&source, s, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, s, len);
isc_buffer_add(&source, len);
isc_buffer_init(&target, b, sizeof b, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, b, sizeof(b));
result = dns_name_fromtext(&name, &source, origin,
ISC_FALSE, &target);
if (result != ISC_R_SUCCESS) {
@ -755,8 +754,7 @@ main(int argc, char *argv[]) {
}
continue;
}
isc_buffer_init(&tb1, t1, sizeof t1,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&tb1, t1, sizeof(t1));
result = dns_name_totext(dns_db_origin(db), ISC_FALSE,
&tb1);
if (result != ISC_R_SUCCESS) {
@ -765,7 +763,7 @@ main(int argc, char *argv[]) {
dns_db_detach(&db);
continue;
}
isc_buffer_used(&tb1, &r1);
isc_buffer_usedregion(&tb1, &r1);
printf("\ndatabase = %.*s (%s)\n",
(int)r1.length, r1.base,
(dns_db_iszone(db)) ? "zone" : "cache");
@ -833,10 +831,8 @@ main(int argc, char *argv[]) {
continue;
}
if (found_as && !quiet) {
isc_buffer_init(&tb1, t1, sizeof t1,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&tb2, t2, sizeof t2,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&tb1, t1, sizeof(t1));
isc_buffer_init(&tb2, t2, sizeof(t2));
result = dns_name_totext(&name, ISC_FALSE, &tb1);
if (result != ISC_R_SUCCESS) {
print_result("", result);
@ -853,8 +849,8 @@ main(int argc, char *argv[]) {
dns_db_detach(&db);
continue;
}
isc_buffer_used(&tb1, &r1);
isc_buffer_used(&tb2, &r2);
isc_buffer_usedregion(&tb1, &r1);
isc_buffer_usedregion(&tb2, &r2);
printf("found %.*s as %.*s\n",
(int)r1.length, r1.base,
(int)r2.length, r2.base);

View file

@ -69,7 +69,7 @@ hex_dump(isc_buffer_t *b)
unsigned int len;
isc_region_t r;
isc_buffer_remaining(b, &r);
isc_buffer_remainingregion(b, &r);
printf("Buffer %p (%p, %d): used region base %p, length %d",
b, b->base, b->length, r.base, r.length);
@ -159,12 +159,10 @@ start_response(void)
#define QUESTION "flame.org."
isc_buffer_init(&source, QUESTION, strlen(QUESTION),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, QUESTION, strlen(QUESTION));
isc_buffer_add(&source, strlen(QUESTION));
isc_buffer_setactive(&source, strlen(QUESTION));
isc_buffer_init(&target, namebuf, sizeof(namebuf),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, namebuf, sizeof(namebuf));
memset(&from, 0, sizeof(from));
from.length = sizeof(struct sockaddr_in);
@ -205,8 +203,7 @@ start_response(void)
result = printmessage(msg);
CHECKRESULT(result, "printmessage()");
isc_buffer_init(&render, render_buffer, sizeof(render_buffer),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&render, render_buffer, sizeof(render_buffer));
result = dns_message_renderbegin(msg, &render);
CHECKRESULT(result, "dns_message_renderbegin()");
@ -242,7 +239,7 @@ start_response(void)
dns_message_destroy(&msg);
isc_buffer_used(&render, &region);
isc_buffer_usedregion(&render, &region);
result = isc_socket_send(dns_dispatch_getsocket(disp), &region,
t2, send_done, resp);
CHECKRESULT(result, "isc_socket_send()");

View file

@ -77,7 +77,7 @@ hex_dump(isc_buffer_t *b)
unsigned int len;
isc_region_t r;
isc_buffer_remaining(b, &r);
isc_buffer_remainingregion(b, &r);
printf("Buffer %p: used region base %p, length %d",
b, r.base, r.length);
@ -136,11 +136,10 @@ start_response(clictx_t *cli, char *query, isc_task_t *task)
isc_buffer_t source;
isc_region_t region;
isc_buffer_init(&source, query, strlen(query), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, query, strlen(query));
isc_buffer_add(&source, strlen(query));
isc_buffer_setactive(&source, strlen(query));
isc_buffer_init(&target, namebuf, sizeof(namebuf),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, namebuf, sizeof(namebuf));
memset(&from, 0, sizeof(from));
from.length = sizeof(struct sockaddr_in);
@ -182,7 +181,7 @@ start_response(clictx_t *cli, char *query, isc_task_t *task)
CHECKRESULT(result, "printmessage()");
isc_buffer_init(&cli->render, cli->render_buffer,
sizeof(cli->render_buffer), ISC_BUFFERTYPE_BINARY);
sizeof(cli->render_buffer));
result = dns_message_renderbegin(msg, &cli->render);
CHECKRESULT(result, "dns_message_renderbegin()");
@ -221,7 +220,7 @@ start_response(clictx_t *cli, char *query, isc_task_t *task)
dns_message_destroy(&msg);
isc_buffer_used(&cli->render, &region);
isc_buffer_usedregion(&cli->render, &region);
result = isc_socket_sendto(dns_dispatch_getsocket(disp), &region,
task, send_done, cli->resp, &from, NULL);
CHECKRESULT(result, "isc_socket_sendto()");

View file

@ -46,20 +46,20 @@ use(dst_key_t *key) {
isc_buffer_t databuf, sigbuf;
isc_region_t datareg, sigreg;
isc_buffer_init(&sigbuf, sig, sizeof(sig), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&sigbuf, sig, sizeof(sig));
/* Advance 1 byte for fun */
isc_buffer_add(&sigbuf, 1);
isc_buffer_init(&databuf, data, strlen(data), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&databuf, data, strlen(data));
isc_buffer_add(&databuf, strlen(data));
isc_buffer_used(&databuf, &datareg);
isc_buffer_usedregion(&databuf, &datareg);
ret = dst_sign(DST_SIGMODE_ALL, key, NULL, &datareg, &sigbuf);
printf("sign(%d) returned: %s\n", dst_key_alg(key),
isc_result_totext(ret));
isc_buffer_forward(&sigbuf, 1);
isc_buffer_remaining(&sigbuf, &sigreg);
isc_buffer_remainingregion(&sigbuf, &sigreg);
ret = dst_verify(DST_SIGMODE_ALL, key, NULL, &datareg, &sigreg);
printf("verify(%d) returned: %s\n", dst_key_alg(key),
isc_result_totext(ret));
@ -75,7 +75,7 @@ dns(dst_key_t *key, isc_mem_t *mctx) {
isc_result_t ret;
isc_boolean_t match;
isc_buffer_init(&buf1, buffer1, sizeof(buffer1), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buf1, buffer1, sizeof(buffer1));
ret = dst_key_todns(key, &buf1);
printf("todns(%d) returned: %s\n", dst_key_alg(key),
isc_result_totext(ret));
@ -86,14 +86,14 @@ dns(dst_key_t *key, isc_mem_t *mctx) {
isc_result_totext(ret));
if (ret != ISC_R_SUCCESS)
return;
isc_buffer_init(&buf2, buffer2, sizeof(buffer2), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buf2, buffer2, sizeof(buffer2));
ret = dst_key_todns(newkey, &buf2);
printf("todns2(%d) returned: %s\n", dst_key_alg(key),
isc_result_totext(ret));
if (ret != ISC_R_SUCCESS)
return;
isc_buffer_used(&buf1, &r1);
isc_buffer_used(&buf2, &r2);
isc_buffer_usedregion(&buf1, &r1);
isc_buffer_usedregion(&buf2, &r2);
match = (r1.length == r2.length &&
memcmp(r1.base, r2.base, r1.length) == 0);
printf("compare(%d): %s\n", dst_key_alg(key), match ? "true" : "false");
@ -150,20 +150,20 @@ dh(char *name1, int id1, char *name2, int id2, isc_mem_t *mctx) {
if (ret != 0)
return;
isc_buffer_init(&b1, array1, sizeof(array1), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b1, array1, sizeof(array1));
ret = dst_computesecret(key1, key2, &b1);
printf("computesecret() returned: %s\n", isc_result_totext(ret));
if (ret != 0)
return;
isc_buffer_init(&b2, array2, sizeof(array2), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b2, array2, sizeof(array2));
ret = dst_computesecret(key2, key1, &b2);
printf("computesecret() returned: %s\n", isc_result_totext(ret));
if (ret != 0)
return;
isc_buffer_used(&b1, &r1);
isc_buffer_used(&b2, &r2);
isc_buffer_usedregion(&b1, &r1);
isc_buffer_usedregion(&b2, &r2);
if (r1.length != r2.length || memcmp(r1.base, r2.base, r1.length) != 0)
{
@ -203,7 +203,7 @@ get_random() {
isc_result_t ret;
unsigned int i;
isc_buffer_init(&databuf, data, sizeof data, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&databuf, data, sizeof(data));
ret = dst_random_get(sizeof(data), &databuf);
printf("random() returned: %s\n", isc_result_totext(ret));
for (i = 0; i < sizeof data; i++)

View file

@ -91,10 +91,10 @@ use(dst_key_t *key, isc_result_t exp_result, int *nfails) {
isc_buffer_t databuf, sigbuf;
isc_region_t datareg, sigreg;
isc_buffer_init(&sigbuf, sig, sizeof(sig), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&databuf, data, strlen(data), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&sigbuf, sig, sizeof(sig));
isc_buffer_init(&databuf, data, strlen(data));
isc_buffer_add(&databuf, strlen(data));
isc_buffer_used(&databuf, &datareg);
isc_buffer_usedregion(&databuf, &datareg);
ret = dst_sign(DST_SIGMODE_ALL, key, NULL, &datareg, &sigbuf);
if (ret != exp_result) {
@ -106,7 +106,7 @@ use(dst_key_t *key, isc_result_t exp_result, int *nfails) {
}
isc_buffer_remaining(&sigbuf, &sigreg);
isc_buffer_remainingregion(&sigbuf, &sigreg);
ret = dst_verify(DST_SIGMODE_ALL, key, NULL, &datareg, &sigreg);
if (ret != exp_result) {
t_info("dst_verify(%d) returned (%s) expected (%s)\n",
@ -204,7 +204,7 @@ dh(char *name1, int id1, char *name2, int id2, isc_mem_t *mctx,
cleandir(tmp);
isc_buffer_init(&b1, array1, sizeof(array1), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b1, array1, sizeof(array1));
ret = dst_computesecret(key1, key2, &b1);
if (ret != 0) {
t_info("dst_computesecret() returned: %s\n",
@ -213,7 +213,7 @@ dh(char *name1, int id1, char *name2, int id2, isc_mem_t *mctx,
return;
}
isc_buffer_init(&b2, array2, sizeof(array2), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b2, array2, sizeof(array2));
ret = dst_computesecret(key2, key1, &b2);
if (ret != 0) {
t_info("dst_computesecret() returned: %s\n",
@ -222,8 +222,8 @@ dh(char *name1, int id1, char *name2, int id2, isc_mem_t *mctx,
return;
}
isc_buffer_used(&b1, &r1);
isc_buffer_used(&b2, &r2);
isc_buffer_usedregion(&b1, &r1);
isc_buffer_usedregion(&b2, &r2);
if (r1.length != r2.length || memcmp(r1.base, r2.base, r1.length) != 0)
{
t_info("computed secrets don't match\n");
@ -330,7 +330,7 @@ get_random(int *nfails) {
isc_result_t ret;
unsigned int i;
isc_buffer_init(&databuf1, data1, sizeof(data1), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&databuf1, data1, sizeof(data1));
ret = dst_random_get(sizeof(data1), &databuf1);
if (ret != ISC_R_SUCCESS) {
t_info("random() returned: %s\n", dst_result_totext(ret));
@ -338,7 +338,7 @@ get_random(int *nfails) {
return;
}
isc_buffer_init(&databuf2, data2, sizeof(data2), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&databuf2, data2, sizeof(data2));
ret = dst_random_get(sizeof(data2), &databuf2);
if (ret != ISC_R_SUCCESS) {
t_info("random() returned: %s\n", dst_result_totext(ret));
@ -640,23 +640,24 @@ t2_sigchk(char *datapath, char *sigpath, char *keyname,
return;
}
isc_buffer_init(&databuf, data, sb.st_size, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&databuf, data, sb.st_size);
isc_buffer_add(&databuf, sb.st_size);
isc_buffer_used(&databuf, &datareg);
isc_buffer_usedregion(&databuf, &datareg);
#ifdef NEWSIG
/*
* if we're generating a signature for the first time,
* If we're generating a signature for the first time,
* sign the data and save the signature to a file
*/
memset(sig, 0, sizeof(sig));
isc_buffer_init(&sigbuf, sig, sizeof(sig), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&sigbuf, sig, sizeof(sig));
isc_result = dst_sign(DST_SIGMODE_ALL, key, NULL, &datareg, &sigbuf);
if (isc_result != ISC_R_SUCCESS) {
t_info("dst_sign(%d) failed %s\n", dst_result_totext(isc_result));
t_info("dst_sign(%d) failed %s\n",
dst_result_totext(isc_result));
(void) free(data);
(void) dst_key_free(key);
++*nprobs;
@ -675,9 +676,11 @@ t2_sigchk(char *datapath, char *sigpath, char *keyname,
#endif /* NEWSIG */
memset(sig, 0, sizeof(sig));
isc_buffer_init(&sigbuf, sig, sizeof(sig), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&sigbuf, sig, sizeof(sig));
/* read precomputed signature from file in a form usable by dst_verify */
/*
* Read precomputed signature from file in a form usable by dst_verify.
*/
rval = sig_fromfile(sigpath, &sigbuf);
if (rval != 0) {
t_info("sig_fromfile failed\n");
@ -688,7 +691,7 @@ t2_sigchk(char *datapath, char *sigpath, char *keyname,
}
/* verify that the key signed the data */
isc_buffer_remaining(&sigbuf, &sigreg);
isc_buffer_remainingregion(&sigbuf, &sigreg);
exp_res = 0;
if (strstr(expected_result, "!"))

View file

@ -25,6 +25,7 @@
#include <isc/mem.h>
#include <isc/buffer.h>
#include <isc/error.h>
#include <isc/util.h>
#include <dns/master.h>
#include <dns/name.h>
@ -37,23 +38,23 @@
#define BUFLEN 255
#define BIGBUFLEN (64 * 1024)
static isc_result_t t1_add_callback(void *arg, dns_name_t *owner,
dns_rdataset_t *dataset);
static void t1(void);
static isc_result_t
t1_add_callback(void *arg, dns_name_t *owner, dns_rdataset_t *dataset);
static void
t1(void);
isc_mem_t *T1_mctx;
char *Tokens[T_MAXTOKS + 1];
static isc_result_t
t1_add_callback(void *arg, dns_name_t *owner, dns_rdataset_t *dataset) {
char buf[BIGBUFLEN];
isc_buffer_t target;
isc_result_t result;
arg = arg; /*unused*/
UNUSED(arg);
isc_buffer_init(&target, buf, BIGBUFLEN, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, buf, BIGBUFLEN);
result = dns_rdataset_totext(dataset, owner, ISC_FALSE, ISC_FALSE,
&target);
if (result != ISC_R_SUCCESS)
@ -91,11 +92,10 @@ test_master(char *testfile, char *origin, char *class,
}
len = strlen(origin);
isc_buffer_init(&source, origin, len,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, origin, len);
isc_buffer_add(&source, len);
isc_buffer_setactive(&source, len);
isc_buffer_init(&target, name_buf, BUFLEN, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, name_buf, BUFLEN);
dns_name_init(&dns_origin, NULL);
dns_result = dns_name_fromtext(&dns_origin, &source, dns_rootname,
ISC_FALSE, &target);

View file

@ -24,6 +24,7 @@
#include <isc/mem.h>
#include <isc/buffer.h>
#include <isc/error.h>
#include <isc/util.h>
#include <dns/master.h>
#include <dns/name.h>
@ -31,20 +32,17 @@
#include <dns/result.h>
#include <dns/types.h>
isc_result_t print_dataset(void *arg, dns_name_t *owner,
dns_rdataset_t *dataset);
isc_mem_t *mctx;
isc_result_t
static isc_result_t
print_dataset(void *arg, dns_name_t *owner, dns_rdataset_t *dataset) {
char buf[64*1024];
isc_buffer_t target;
isc_result_t result;
arg = arg; /*unused*/
UNUSED(arg);
isc_buffer_init(&target, buf, 64*1024, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, buf, 64*1024);
result = dns_rdataset_totext(dataset, owner, ISC_FALSE, ISC_FALSE,
&target);
if (result == ISC_R_SUCCESS)
@ -68,16 +66,15 @@ main(int argc, char *argv[]) {
int nscount = 0;
dns_rdatacallbacks_t callbacks;
argc = argc;
UNUSED(argc);
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
if (argv[1]) {
isc_buffer_init(&source, argv[1], strlen(argv[1]),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, argv[1], strlen(argv[1]));
isc_buffer_add(&source, strlen(argv[1]));
isc_buffer_setactive(&source, strlen(argv[1]));
isc_buffer_init(&target, name_buf, 255, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, name_buf, 255);
dns_name_init(&origin, NULL);
result = dns_name_fromtext(&origin, &source, dns_rootname,
ISC_FALSE, &target);

View file

@ -54,13 +54,13 @@ print_name(dns_name_t *name) {
isc_region_t r;
char s[1000];
isc_buffer_init(&source, s, sizeof s, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, s, sizeof(s));
if (dns_name_countlabels(name) > 0)
result = dns_name_totext(name, ISC_FALSE, &source);
else
result = ISC_R_SUCCESS;
if (result == ISC_R_SUCCESS) {
isc_buffer_used(&source, &r);
isc_buffer_usedregion(&source, &r);
if (r.length > 0)
printf("%.*s\n", (int)r.length, r.base);
else
@ -127,8 +127,7 @@ main(int argc, char *argv[]) {
origin = NULL;
else {
len = strlen(argv[0]);
isc_buffer_init(&source, argv[0], len,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, argv[0], len);
isc_buffer_add(&source, len);
dns_fixedname_init(&oname);
origin = &oname.name;
@ -152,8 +151,7 @@ main(int argc, char *argv[]) {
comp = NULL;
else {
len = strlen(argv[0]);
isc_buffer_init(&source, argv[0], len,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, argv[0], len);
isc_buffer_add(&source, len);
dns_fixedname_init(&compname);
comp = &compname.name;
@ -178,7 +176,7 @@ main(int argc, char *argv[]) {
s[len - 1] = '\0';
len--;
}
isc_buffer_init(&source, s, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, s, len);
isc_buffer_add(&source, len);
if (len > 0)
@ -259,13 +257,13 @@ main(int argc, char *argv[]) {
} else
got_name = ISC_TRUE;
}
isc_buffer_init(&source, s, sizeof s, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, s, sizeof(s));
if (dns_name_countlabels(name) > 0)
result = dns_name_totext(name, ISC_FALSE, &source);
else
result = ISC_R_SUCCESS;
if (result == ISC_R_SUCCESS) {
isc_buffer_used(&source, &r);
isc_buffer_usedregion(&source, &r);
if (r.length > 0)
printf("%.*s\n", (int)r.length, r.base);
else
@ -292,8 +290,7 @@ main(int argc, char *argv[]) {
dns_name_countlabels(down),
r.length);
}
isc_buffer_init(&source, s, sizeof s,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, s, sizeof(s));
print_name(down);
}

View file

@ -260,7 +260,7 @@ getmsg(char *datafile_name, unsigned char *buf, int buflen,
}
*p = '\0';
isc_buffer_init(pbuf, buf, cnt, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(pbuf, buf, cnt);
isc_buffer_add(pbuf, cnt);
return(cnt);
}
@ -360,12 +360,12 @@ dname_from_tname(char *name, dns_name_t *dns_name)
isc_result_t result;
len = strlen(name);
isc_buffer_init(&txtbuf, name, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&txtbuf, name, len);
isc_buffer_add(&txtbuf, len);
junk = (unsigned char *) malloc(sizeof(unsigned char) * BUFLEN);
binbuf = (isc_buffer_t *)malloc(sizeof(isc_buffer_t));
if ((junk != NULL) && (binbuf != NULL)) {
isc_buffer_init(binbuf, junk, BUFLEN, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(binbuf, junk, BUFLEN);
dns_name_init(dns_name, NULL);
dns_name_setbuffer(dns_name, binbuf);
result = dns_name_fromtext(dns_name, &txtbuf,
@ -659,7 +659,7 @@ t_dns_name_setbuffer() {
t_assert("dns_name_setbuffer", 1, T_REQUIRED, a5);
isc_buffer_init(&buffer, junk, BUFLEN, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buffer, junk, BUFLEN);
dns_name_init(&name, NULL);
dns_name_setbuffer(&name, &buffer);
if (name.buffer == &buffer)
@ -684,7 +684,7 @@ t_dns_name_hasbuffer() {
t_assert("dns_name_hasbuffer", 1, T_REQUIRED, a6);
rval = 0;
isc_buffer_init(&buffer, junk, BUFLEN, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buffer, junk, BUFLEN);
dns_name_init(&name, NULL);
if (dns_name_hasbuffer(&name) != ISC_FALSE)
++rval;
@ -718,9 +718,9 @@ test_dns_name_isabsolute(char *test_name, isc_boolean_t expected) {
t_info("testing name %s\n", test_name);
len = strlen(test_name);
isc_buffer_init(&buf, test_name, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buf, test_name, len);
isc_buffer_add(&buf, len);
isc_buffer_init(&binbuf, &junk[0], BUFLEN, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&binbuf, &junk[0], BUFLEN);
dns_name_init(&name, NULL);
dns_name_setbuffer(&name, &binbuf);
result = dns_name_fromtext(&name, &buf, NULL, ISC_FALSE, NULL);
@ -1600,10 +1600,8 @@ test_dns_name_getlabelsequence(char *test_name1, int label1_start,
range, &dns_targetname2);
/* now convert both targets to text for comparison */
isc_buffer_init(&buffer1, junk1,
BUFLEN, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer2, junk2,
BUFLEN, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer1, junk1, BUFLEN);
isc_buffer_init(&buffer2, junk2, BUFLEN);
dns_name_totext(&dns_targetname1, ISC_TRUE, &buffer1);
dns_name_totext(&dns_targetname2, ISC_TRUE, &buffer2);
if (buffer1.used == buffer2.used) {
@ -1856,20 +1854,17 @@ test_dns_name_fromtext(char *test_name1, char *test_name2,
t_info("testing %s %s %s\n", test_name1, test_name2, test_origin);
isc_buffer_init(&binbuf1, junk1, BUFLEN, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&binbuf2, junk2, BUFLEN, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&binbuf3, junk3, BUFLEN, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&binbuf1, junk1, BUFLEN);
isc_buffer_init(&binbuf2, junk2, BUFLEN);
isc_buffer_init(&binbuf3, junk3, BUFLEN);
isc_buffer_init(&txtbuf1, test_name1, strlen(test_name1),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&txtbuf1, test_name1, strlen(test_name1));
isc_buffer_add(&txtbuf1, strlen(test_name1));
isc_buffer_init(&txtbuf2, test_name2, strlen(test_name2),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&txtbuf2, test_name2, strlen(test_name2));
isc_buffer_add(&txtbuf2, strlen(test_name2));
isc_buffer_init(&txtbuf3, test_origin, strlen(test_origin),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&txtbuf3, test_origin, strlen(test_origin));
isc_buffer_add(&txtbuf3, strlen(test_origin));
dns_name_init(&dns_name1, NULL);
dns_name_init(&dns_name2, NULL);
@ -1994,11 +1989,11 @@ test_dns_name_totext(char *test_name, isc_boolean_t omit_final) {
t_info("testing %s\n", test_name);
len = strlen(test_name);
isc_buffer_init(&buf1, test_name, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buf1, test_name, len);
isc_buffer_add(&buf1, len);
dns_name_init(&dns_name1, NULL);
isc_buffer_init(&buf2, junk2, BUFLEN, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buf2, junk2, BUFLEN);
/* out of the data file to dns_name1 */
dns_result = dns_name_fromtext(&dns_name1, &buf1, NULL, ISC_FALSE,
@ -2011,7 +2006,7 @@ test_dns_name_totext(char *test_name, isc_boolean_t omit_final) {
/* from dns_name1 into a text buffer */
isc_buffer_invalidate(&buf1);
isc_buffer_init(&buf1, junk1, BUFLEN, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buf1, junk1, BUFLEN);
dns_result = dns_name_totext(&dns_name1, omit_final, &buf1);
if (dns_result != ISC_R_SUCCESS) {
t_info("dns_name_totext failed, result == %s\n",
@ -2021,7 +2016,7 @@ test_dns_name_totext(char *test_name, isc_boolean_t omit_final) {
/* from the text buffer into dns_name2 */
dns_name_init(&dns_name2, NULL);
isc_buffer_init(&buf3, junk3, BUFLEN, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buf3, junk3, BUFLEN);
dns_result = dns_name_fromtext(&dns_name2, &buf1,
NULL, ISC_FALSE, &buf3);
if (dns_result != ISC_R_SUCCESS) {
@ -2153,7 +2148,7 @@ test_dns_name_fromwire( char *datafile_name,
isc_buffer_setactive(&iscbuf1, len);
iscbuf1.current = testname_offset;
isc_buffer_init(&iscbuf2, buf2, buflen, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&iscbuf2, buf2, buflen);
dns_name_init(&dns_name1, NULL);
dns_decompress_init(&dctx, -1, ISC_FALSE);
dns_decompress_setmethods(&dctx, dc_method);
@ -2364,12 +2359,13 @@ test_dns_name_towire( char *testname,
dns_compress_setmethods(&cctx, dc_method);
dns_name_init(&dns_name, NULL);
len = strlen(testname);
isc_buffer_init(&iscbuf1, testname, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&iscbuf1, testname, len);
isc_buffer_add(&iscbuf1, len);
isc_buffer_init(&iscbuf2, buf2, BUFLEN, ISC_BUFFERTYPE_BINARY);
dns_result = dns_name_fromtext(&dns_name, &iscbuf1, NULL, ISC_FALSE, &iscbuf2);
isc_buffer_init(&iscbuf2, buf2, BUFLEN);
dns_result = dns_name_fromtext(&dns_name, &iscbuf1, NULL, ISC_FALSE,
&iscbuf2);
if (dns_result == ISC_R_SUCCESS) {
isc_buffer_init(&iscbuf3, buf3, buflen, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&iscbuf3, buf3, buflen);
dns_result = dns_name_towire(&dns_name, &cctx, &iscbuf3);
if (dns_result == exp_result) {
if (exp_result == ISC_R_SUCCESS) {

View file

@ -143,7 +143,7 @@ nxtify(char *filename) {
else
origintext++; /* Skip '/'. */
len = strlen(origintext);
isc_buffer_init(&b, origintext, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, origintext, len);
isc_buffer_add(&b, len);
result = dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL);
check_result(result, "dns_name_fromtext()");

View file

@ -112,7 +112,7 @@ printsection(dns_message_t *msg, dns_section_t sectionid, char *section_name)
name = NULL;
dns_message_currentname(msg, sectionid, &name);
isc_buffer_init(&target, t, sizeof t, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, t, sizeof(t));
first = ISC_TRUE;
print_name = name;
@ -133,7 +133,7 @@ printsection(dns_message_t *msg, dns_section_t sectionid, char *section_name)
}
#endif
}
isc_buffer_used(&target, &r);
isc_buffer_usedregion(&target, &r);
printf("%.*s", (int)r.length, (char *)r.base);
result = dns_message_nextname(msg, sectionid);
@ -158,13 +158,13 @@ printrdata(dns_message_t *msg, dns_rdataset_t *rdataset, dns_name_t *owner,
UNUSED(msg);
printf(";; %s SECTION:\n", set_name);
isc_buffer_init(&target, t, sizeof t, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, t, sizeof(t));
result = dns_rdataset_totext(rdataset, owner, ISC_FALSE, ISC_FALSE,
&target);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_used(&target, &r);
isc_buffer_usedregion(&target, &r);
printf("%.*s", (int)r.length, (char *)r.base);
return (ISC_R_SUCCESS);

View file

@ -24,6 +24,7 @@
#include <unistd.h>
#include <isc/boolean.h>
#include <isc/util.h>
#include <dns/rbt.h>
#include <dns/fixedname.h>
@ -72,7 +73,7 @@ dnsname_totext(dns_name_t *name) {
static char buf[BUFLEN];
isc_buffer_t target;
isc_buffer_init(&target, buf, BUFLEN, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, buf, BUFLEN);
dns_name_totext(name, ISC_FALSE, &target);
*((char *)(target.base) + target.used) = '\0';
return(target.base);
@ -84,7 +85,7 @@ fixedname_totext(dns_fixedname_t *name) {
isc_buffer_t target;
memset(buf, 0, BUFLEN);
isc_buffer_init(&target, buf, BUFLEN, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, buf, BUFLEN);
dns_name_totext(dns_fixedname_name(name), ISC_FALSE, &target);
*((char *)(target.base) + target.used) = '\0';
return(target.base);
@ -98,7 +99,7 @@ print_data(void *data) {
isc_buffer_t target;
char *buffer[DNSNAMELEN];
isc_buffer_init(&target, buffer, sizeof(buffer), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, buffer, sizeof(buffer));
dns_result = dns_name_totext(data, ISC_FALSE, &target);
if (dns_result != ISC_R_SUCCESS) {
@ -124,7 +125,7 @@ create_name(char *s, isc_mem_t *mctx, dns_name_t **dns_name) {
length = strlen(s);
isc_buffer_init(&source, s, length, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, s, length);
isc_buffer_add(&source, length);
/*
@ -138,8 +139,7 @@ create_name(char *s, isc_mem_t *mctx, dns_name_t **dns_name) {
}
dns_name_init(*dns_name, NULL);
isc_buffer_init(&target, *dns_name + 1, DNSNAMELEN,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, *dns_name + 1, DNSNAMELEN);
result = dns_name_fromtext(*dns_name, &source, dns_rootname,
ISC_FALSE, &target);
@ -757,7 +757,7 @@ t_dns_rbtnodechain_init(char *dbfile, char *findname,
}
len = strlen(findname);
isc_buffer_init(&isc_buffer, findname, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&isc_buffer, findname, len);
isc_buffer_add(&isc_buffer, len);
dns_fixedname_init(&dns_foundname);
@ -1316,7 +1316,7 @@ t_dns_rbtnodechain_next(char *dbfile, char *findname,
}
len = strlen(findname);
isc_buffer_init(&isc_buffer, findname, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&isc_buffer, findname, len);
isc_buffer_add(&isc_buffer, len);
dns_fixedname_init(&dns_foundname);
@ -1488,7 +1488,7 @@ t_dns_rbtnodechain_prev(char *dbfile, char *findname,
}
len = strlen(findname);
isc_buffer_init(&isc_buffer, findname, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&isc_buffer, findname, len);
isc_buffer_add(&isc_buffer, len);
dns_fixedname_init(&dns_foundname);

View file

@ -45,7 +45,7 @@ create_name(char *s) {
length = strlen(s);
isc_buffer_init(&source, s, length, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&source, s, length);
isc_buffer_add(&source, length);
/*
@ -65,7 +65,7 @@ create_name(char *s) {
}
dns_name_init(name, NULL);
isc_buffer_init(&target, name + 1, DNSNAMELEN, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, name + 1, DNSNAMELEN);
result = dns_name_fromtext(name, &source, dns_rootname,
ISC_FALSE, &target);
@ -93,7 +93,7 @@ print_name(dns_name_t *name) {
isc_buffer_t target;
char *buffer[256];
isc_buffer_init(&target, buffer, sizeof(buffer), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, buffer, sizeof(buffer));
/*
* ISC_FALSE means absolute names have the final dot added.

View file

@ -132,8 +132,7 @@ main(int argc, char *argv[]) {
/* get type */
if (token.type == isc_tokentype_number) {
type = token.value.as_ulong;
isc_buffer_init(&tbuf, outbuf, sizeof(outbuf),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&tbuf, outbuf, sizeof(outbuf));
result = dns_rdatatype_totext(type, &tbuf);
fprintf(stdout, "type = %.*s(%d)\n",
(int)tbuf.used, (char*)tbuf.base, type);
@ -163,8 +162,7 @@ main(int argc, char *argv[]) {
break;
if (token.type == isc_tokentype_number) {
class = token.value.as_ulong;
isc_buffer_init(&tbuf, outbuf, sizeof(outbuf),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&tbuf, outbuf, sizeof(outbuf));
result = dns_rdatatype_totext(class, &tbuf);
fprintf(stdout, "class = %.*s(%d)\n",
(int)tbuf.used, (char*)tbuf.base, class);
@ -187,8 +185,7 @@ main(int argc, char *argv[]) {
fflush(stdout);
dns_rdata_init(&rdata);
isc_buffer_init(&dbuf, inbuf, sizeof(inbuf),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&dbuf, inbuf, sizeof(inbuf));
result = dns_rdata_fromtext(&rdata, class, type, lex,
NULL, ISC_FALSE, &dbuf, NULL);
if (result != ISC_R_SUCCESS) {
@ -221,8 +218,7 @@ main(int argc, char *argv[]) {
dns_result_totext(result), result);
continue;
}
isc_buffer_init(&wbuf, wirebuf, sizeof(wirebuf),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&wbuf, wirebuf, sizeof(wirebuf));
result = dns_rdata_towire(&rdata, &cctx, &wbuf);
dns_compress_invalidate(&cctx);
if (result != ISC_R_SUCCESS) {
@ -258,8 +254,7 @@ main(int argc, char *argv[]) {
isc_buffer_setactive(&wbuf, len);
dns_rdata_init(&rdata);
isc_buffer_init(&dbuf, inbuf, sizeof(inbuf),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&dbuf, inbuf, sizeof(inbuf));
dns_decompress_init(&dctx, -1, ISC_FALSE);
result = dns_rdata_fromwire(&rdata, class, type, &wbuf,
&dctx, ISC_FALSE, &dbuf);
@ -287,8 +282,7 @@ main(int argc, char *argv[]) {
}
}
isc_buffer_init(&tbuf, outbuf, sizeof(outbuf),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&tbuf, outbuf, sizeof(outbuf));
result = dns_rdata_totext(&rdata, NULL, &tbuf);
if (result != ISC_R_SUCCESS)
fprintf(stdout, "dns_rdata_totext returned %s(%d)\n",

View file

@ -150,7 +150,7 @@ hex_dump(isc_buffer_t *b)
unsigned int len;
isc_region_t r;
isc_buffer_remaining(b, &r);
isc_buffer_remainingregion(b, &r);
for (len = 0 ; len < r.length ; len++) {
printf("%02x ", r.base[len]);
@ -292,8 +292,7 @@ main(int argc, char *argv[]) {
check_result(result, "dns_message_gettempname()");
dns_name_init(name, NULL);
isc_buffer_init(&namebuffer, namedata, sizeof(namedata),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&namebuffer, namedata, sizeof(namedata));
printf("\n; <<>> sdig <<>>");
for (i = 1; i < argc; i++) {
@ -324,8 +323,7 @@ main(int argc, char *argv[]) {
tr.base = argv[0];
tr.length = len;
if (!have_name) {
isc_buffer_init(&b, argv[0], len,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, argv[0], len);
isc_buffer_add(&b, len);
result = dns_name_fromtext(name, &b,
dns_rootname,
@ -361,7 +359,7 @@ main(int argc, char *argv[]) {
message->flags |= DNS_MESSAGEFLAG_RD;
dns_message_addname(message, name, DNS_SECTION_QUESTION);
isc_buffer_init(&b, data, sizeof data, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b, data, sizeof(data));
result = dns_message_renderbegin(message, &b);
check_result(result, "dns_message_renderbegin()");
if (edns0)
@ -380,7 +378,7 @@ main(int argc, char *argv[]) {
check_result(result, "isc_socket_create()");
ISC_LIST_INIT(bufferlist);
isc_buffer_init(&b2, data2, sizeof data2, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b2, data2, sizeof data2);
ISC_LIST_ENQUEUE(bufferlist, &b2, link);
result = isc_socket_recvv(sock, &bufferlist, 1, task, recv_done, NULL);
check_result(result, "isc_socket_recvv()");

View file

@ -111,9 +111,9 @@ nametostr(dns_name_t *name) {
isc_region_t r;
static char data[1025];
isc_buffer_init(&b, data, sizeof(data), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, data, sizeof(data));
dns_name_totext(name, ISC_FALSE, &b);
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
r.base[r.length] = 0;
return (char *) r.base;
}
@ -125,9 +125,9 @@ typetostr(const dns_rdatatype_t type) {
isc_region_t r;
static char data[10];
isc_buffer_init(&b, data, sizeof(data), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, data, sizeof(data));
dns_rdatatype_totext(type, &b);
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
r.base[r.length] = 0;
return (char *) r.base;
}
@ -139,9 +139,9 @@ algtostr(const dns_secalg_t alg) {
isc_region_t r;
static char data[10];
isc_buffer_init(&b, data, sizeof(data), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, data, sizeof(data));
dns_secalg_totext(alg, &b);
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
r.base[r.length] = 0;
return (char *) r.base;
}
@ -198,7 +198,7 @@ iszonekey(signer_key_t *key, dns_db_t *db) {
isc_buffer_t b;
isc_result_t result;
isc_buffer_init(&b, origin, sizeof(origin), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, origin, sizeof(origin));
result = dns_name_totext(dns_db_origin(db), ISC_FALSE, &b);
check_result(result, "dns_name_totext()");
@ -295,8 +295,7 @@ setverifies(dns_name_t *name, dns_rdataset_t *set, signer_key_t *key,
ISC_LIST_APPEND(arraylist, tdata, link); \
if (trdata == NULL || tdata == NULL) \
check_result(ISC_R_FAILURE, "isc_mem_get"); \
isc_buffer_init(&b, tdata->array, sizeof(tdata->array), \
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b, tdata->array, sizeof(tdata->array));
/*
* Signs a set. Goes through contortions to decide if each SIG should
@ -882,10 +881,10 @@ loadzone(char *file, char *origin, dns_zone_t **zone) {
isc_result_t result;
len = strlen(origin);
isc_buffer_init(&b, origin, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, origin, len);
isc_buffer_add(&b, len);
isc_buffer_init(&b2, namedata, sizeof(namedata), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b2, namedata, sizeof(namedata));
dns_name_init(&name, NULL);
result = dns_name_fromtext(&name, &b, dns_rootname, ISC_FALSE, &b2);

View file

@ -111,8 +111,7 @@ recvdone(isc_task_t *task, isc_event_t *event) {
exit(-1);
}
isc_buffer_init(&source, sevent->region.base, sevent->region.length,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&source, sevent->region.base, sevent->region.length);
isc_buffer_add(&source, sevent->n);
response = NULL;
@ -159,8 +158,7 @@ recvdone2(isc_task_t *task, isc_event_t *event) {
exit(-1);
}
isc_buffer_init(&source, sevent->region.base, sevent->region.length,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&source, sevent->region.base, sevent->region.length);
isc_buffer_add(&source, sevent->n);
response = NULL;
@ -197,7 +195,7 @@ buildquery(void) {
unsigned char keydata[3];
dns_fixedname_init(&keyname);
isc_buffer_init(&namestr, "tkeytest.", 9, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&namestr, "tkeytest.", 9);
isc_buffer_add(&namestr, 9);
result = dns_name_fromtext(dns_fixedname_name(&keyname), &namestr,
NULL, ISC_FALSE, NULL);
@ -206,16 +204,16 @@ buildquery(void) {
result = isc_lex_create(mctx, 1024, &lex);
CHECK("isc_lex_create", result);
isc_buffer_init(&keybufin, "1234", 4, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&keybufin, "1234", 4);
isc_buffer_add(&keybufin, 4);
result = isc_lex_openbuffer(lex, &keybufin);
CHECK("isc_lex_openbuffer", result);
isc_buffer_init(&keybuf, keydata, 3, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&keybuf, keydata, 3);
result = isc_base64_tobuffer(lex, &keybuf, -1);
CHECK("isc_base64_tobuffer", result);
isc_buffer_used(&keybuf, &r);
isc_buffer_usedregion(&keybuf, &r);
result = dns_tsigkey_create(dns_fixedname_name(&keyname),
DNS_TSIG_HMACMD5_NAME,
@ -223,7 +221,7 @@ buildquery(void) {
NULL, 0, 0, mctx, ring, &key);
CHECK("dns_tsigkey_create", result);
result = isc_buffer_allocate(mctx, &nonce, 16, ISC_BUFFERTYPE_BINARY);
result = isc_buffer_allocate(mctx, &nonce, 16);
CHECK("isc_buffer_allocate", result);
result = dst_random_get(16, nonce);
@ -239,7 +237,7 @@ buildquery(void) {
DNS_TSIG_HMACMD5_NAME, nonce, 3600);
CHECK("dns_tkey_builddhquery", result);
isc_buffer_init(&qbuffer, qdata, sizeof(qdata), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&qbuffer, qdata, sizeof(qdata));
result = dns_message_renderbegin(query, &qbuffer);
CHECK("dns_message_renderbegin", result);
@ -254,7 +252,7 @@ buildquery(void) {
result = dns_message_renderend(query);
CHECK("dns_message_renderend", result);
isc_buffer_used(&qbuffer, &r);
isc_buffer_usedregion(&qbuffer, &r);
result = isc_socket_sendto(s, &r, task1, senddone, NULL, &address,
NULL);
CHECK("isc_socket_sendto", result);
@ -279,7 +277,7 @@ buildquery2(void) {
result = dns_tkey_builddeletequery(query2, tsigkey);
CHECK("dns_tkey_builddeletequery", result);
isc_buffer_init(&qbuffer, qdata, sizeof(qdata), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&qbuffer, qdata, sizeof(qdata));
result = dns_message_renderbegin(query2, &qbuffer);
CHECK("dns_message_renderbegin", result);
@ -294,7 +292,7 @@ buildquery2(void) {
result = dns_message_renderend(query2);
CHECK("dns_message_renderend", result);
isc_buffer_used(&qbuffer, &r);
isc_buffer_usedregion(&qbuffer, &r);
result = isc_socket_sendto(s, &r, task2, senddone2, NULL, &address,
NULL);
CHECK("isc_socket_sendto", result);

View file

@ -129,7 +129,7 @@ main(int argc, char *argv[]) {
if (need_close)
fclose(f);
isc_buffer_init(&source, b, sizeof b, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&source, b, sizeof(b));
isc_buffer_add(&source, bp - b);
message = NULL;

View file

@ -174,10 +174,10 @@ print_rdataset(dns_name_t *name, dns_rdataset_t *rdataset) {
isc_result_t result;
isc_region_t r;
isc_buffer_init(&text, t, sizeof t, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&text, t, sizeof(t));
result = dns_rdataset_totext(rdataset, name, ISC_FALSE, ISC_FALSE,
&text);
isc_buffer_used(&text, &r);
isc_buffer_usedregion(&text, &r);
if (result == ISC_R_SUCCESS)
printf("%.*s", (int)r.length, (char *)r.base);
else
@ -237,7 +237,7 @@ query(dns_view_t *view) {
}
dns_fixedname_init(&name);
isc_buffer_init(&buffer, buf, strlen(buf), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer, buf, strlen(buf));
isc_buffer_add(&buffer, strlen(buf));
result = dns_name_fromtext(dns_fixedname_name(&name),
&buffer, dns_rootname, ISC_FALSE, NULL);

View file

@ -83,8 +83,7 @@ setup(char *zonename, char *filename, char *classname) {
dns_zone_settype(zone, zonetype);
isc_buffer_init(&buffer, zonename, strlen(zonename),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer, zonename, strlen(zonename));
isc_buffer_add(&buffer, strlen(zonename));
dns_fixedname_init(&fixorigin);
result = dns_name_fromtext(dns_fixedname_name(&fixorigin),
@ -125,10 +124,10 @@ print_rdataset(dns_name_t *name, dns_rdataset_t *rdataset) {
isc_result_t result;
isc_region_t r;
isc_buffer_init(&text, t, sizeof t, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&text, t, sizeof(t));
result = dns_rdataset_totext(rdataset, name, ISC_FALSE, ISC_FALSE,
&text);
isc_buffer_used(&text, &r);
isc_buffer_usedregion(&text, &r);
if (result == ISC_R_SUCCESS)
printf("%.*s", (int)r.length, (char *)r.base);
else
@ -186,8 +185,7 @@ query(void) {
if (strlen(buf) == 0)
continue;
dns_fixedname_init(&name);
isc_buffer_init(&buffer, buf, strlen(buf),
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer, buf, strlen(buf));
isc_buffer_add(&buffer, strlen(buf));
result = dns_name_fromtext(dns_fixedname_name(&name),
&buffer, dns_rootname, ISC_FALSE, NULL);

View file

@ -88,7 +88,7 @@ convert_keyname(char *txtname, isc_mem_t *mctx, dns_name_t *dnsname) {
unsigned int keylen;
keylen = strlen(txtname);
isc_buffer_init(&buf, txtname, keylen, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buf, txtname, keylen);
isc_buffer_add(&buf, keylen);
dns_fixedname_init(&fixname);
result = dns_name_fromtext(dns_fixedname_name(&fixname), &buf,

View file

@ -3057,10 +3057,10 @@ print_dns_name(FILE *f, dns_name_t *name)
INSIST(f != NULL);
isc_buffer_init(&b, buf, sizeof buf, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, buf, sizeof(buf));
if (dns_name_totext(name, ISC_FALSE, &b) == ISC_R_SUCCESS) {
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
fprintf(f, "%.*s", (int)r.length, r.base);
}
}

View file

@ -128,7 +128,7 @@ address_to_ptr_name(dns_byaddr_t *byaddr, isc_netaddr_t *address) {
return (ISC_R_NOTIMPLEMENTED);
len = (unsigned int)strlen(textname);
isc_buffer_init(&buffer, textname, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer, textname, len);
isc_buffer_add(&buffer, len);
return (dns_name_fromtext(dns_fixedname_name(&byaddr->name),
&buffer, dns_rootname, ISC_FALSE, NULL));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: compress.c,v 1.25 2000/04/19 18:23:29 halley Exp $ */
/* $Id: compress.c,v 1.26 2000/04/27 00:01:21 tale Exp $ */
#include <config.h>
#include <string.h>
@ -285,8 +285,7 @@ compress_add(dns_rbt_t *root, dns_name_t *prefix, dns_name_t *suffix,
if (offset >= 16384 && !global16)
break;
dns_name_getlabelsequence(prefix, start, count, &name);
isc_buffer_init(&target, buffer, sizeof buffer,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, buffer, sizeof(buffer));
result = dns_name_concatenate(&name, suffix, &full, &target);
if (result != ISC_R_SUCCESS)
return;

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: confcommon.c,v 1.22 2000/04/07 17:40:40 brister Exp $ */
/* $Id: confcommon.c,v 1.23 2000/04/27 00:02:15 tale Exp $ */
#include <config.h>
@ -163,8 +163,7 @@ static void default_cfgerror(isc_result_t result, const char *fmt,
void
dns_c_printinunits(FILE *fp, isc_uint32_t val)
{
dns_c_printinunits(FILE *fp, isc_uint32_t val) {
isc_uint32_t one_gig = (1024 * 1024 * 1024);
isc_uint32_t one_meg = (1024 * 1024);
isc_uint32_t one_k = 1024;
@ -187,39 +186,35 @@ dns_c_printinunits(FILE *fp, isc_uint32_t val)
void
dns_c_dataclass_tostream(FILE *fp, dns_rdataclass_t rclass)
{
dns_c_dataclass_tostream(FILE *fp, dns_rdataclass_t rclass) {
char buffer[64];
isc_buffer_t sourceb;
isc_buffer_init(&sourceb, buffer, sizeof buffer,
ISC_BUFFERTYPE_GENERIC);
isc_buffer_init(&sourceb, buffer, sizeof(buffer));
if (dns_rdataclass_totext(rclass, &sourceb) == ISC_R_SUCCESS) {
INSIST(sourceb.used + 1 < sizeof buffer);
INSIST(sourceb.used + 1 < sizeof(buffer));
buffer[sourceb.used] = '\0';
fputs(buffer, fp);
} else {
fprintf(fp, "UNKNOWN-CLASS(%d)",(int) rclass);
fprintf(fp, "UNKNOWN-CLASS(%d)", (int)rclass);
}
}
void
dns_c_datatype_tostream(FILE *fp, dns_rdatatype_t rtype)
{
dns_c_datatype_tostream(FILE *fp, dns_rdatatype_t rtype) {
char buffer[64];
isc_buffer_t sourceb;
isc_buffer_init(&sourceb, buffer, sizeof buffer,
ISC_BUFFERTYPE_GENERIC);
isc_buffer_init(&sourceb, buffer, sizeof(buffer));
if (dns_rdatatype_totext(rtype, &sourceb) == ISC_R_SUCCESS) {
INSIST(sourceb.used + 1 < sizeof buffer);
buffer[sourceb.used] = '\0';
fputs(buffer, fp);
} else {
fprintf(fp, "UNKNOWN-RDATATYPE(%d)",(int) rtype);
fprintf(fp, "UNKNOWN-RDATATYPE(%d)", (int)rtype);
}
}
@ -710,13 +705,12 @@ dns_c_charptoname(isc_mem_t *mem, const char *keyval, dns_name_t **name)
len = strlen(keyval);
dns_name_init(&newkey, NULL);
res = isc_buffer_allocate(mem, &b1, len + 2,
ISC_BUFFERTYPE_BINARY);
res = isc_buffer_allocate(mem, &b1, len + 2);
REQUIRE(res == ISC_R_SUCCESS);
dns_name_setbuffer(&newkey, b1);
isc_buffer_init(&b2, (char *)keyval, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b2, (char *)keyval, len);
isc_buffer_add(&b2, len);
res = dns_name_fromtext(&newkey, &b2, NULL, ISC_FALSE, NULL);

View file

@ -454,8 +454,7 @@ udp_recv(isc_task_t *task, isc_event_t *ev_in)
/*
* Peek into the buffer to see what we can see.
*/
isc_buffer_init(&source, ev->region.base, ev->region.length,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&source, ev->region.base, ev->region.length);
isc_buffer_add(&source, ev->n);
dres = dns_message_peekheader(&source, &id, &flags);
if (dres != ISC_R_SUCCESS) {
@ -514,8 +513,7 @@ udp_recv(isc_task_t *task, isc_event_t *ev_in)
* resp contains the information on the place to send it to.
* Send the event off.
*/
isc_buffer_init(&rev->buffer, ev->region.base, ev->region.length,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&rev->buffer, ev->region.base, ev->region.length);
isc_buffer_add(&rev->buffer, ev->n);
rev->result = ISC_R_SUCCESS;
rev->id = id;

View file

@ -16,7 +16,7 @@
*/
/*
* $Id: dnssec.c,v 1.28 2000/04/19 20:57:54 bwelling Exp $
* $Id: dnssec.c,v 1.29 2000/04/27 00:01:24 tale Exp $
* Principal Author: Brian Wellington
*/
@ -102,9 +102,9 @@ keyname_to_name(char *keyname, isc_mem_t *mctx, dns_name_t *name) {
dns_name_init(name, NULL);
dns_name_init(&tname, NULL);
isc_buffer_init(&src, keyname, strlen(keyname), ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&src, keyname, strlen(keyname));
isc_buffer_add(&src, strlen(keyname));
isc_buffer_init(&dst, data, sizeof(data), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&dst, data, sizeof(data));
ret = dns_name_fromtext(&tname, &src, NULL, ISC_TRUE, &dst);
if (ret != ISC_R_SUCCESS)
return (ret);
@ -171,15 +171,14 @@ dns_dnssec_keyfromrdata(dns_name_t *name, dns_rdata_t *rdata, isc_mem_t *mctx,
INSIST(key != NULL);
INSIST(*key == NULL);
isc_buffer_init(&namebuf, namestr, sizeof(namestr) - 1,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&namebuf, namestr, sizeof(namestr) - 1);
ret = dns_name_totext(name, ISC_FALSE, &namebuf);
if (ret != ISC_R_SUCCESS)
return ret;
isc_buffer_used(&namebuf, &r);
isc_buffer_usedregion(&namebuf, &r);
namestr[r.length] = 0;
dns_rdata_toregion(rdata, &r);
isc_buffer_init(&b, r.base, r.length, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b, r.base, r.length);
isc_buffer_add(&b, r.length);
return (dst_key_fromdns(namestr, &b, mctx, key));
}
@ -246,13 +245,13 @@ dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
if (sig.signature == NULL)
goto cleanup_name;
isc_buffer_init(&b, data, sizeof(data), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b, data, sizeof(data));
ret = dns_rdata_fromstruct(NULL, sig.common.rdclass,
sig.common.rdtype, &sig, &b);
if (ret != ISC_R_SUCCESS)
goto cleanup_signature;
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
/* Digest the SIG rdata */
r.length -= sig.siglen;
@ -265,7 +264,7 @@ dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
dns_name_toregion(name, &r);
/* create an envelope for each rdata: <name|type|class|ttl> */
isc_buffer_init(&envbuf, data, sizeof(data), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&envbuf, data, sizeof(data));
memcpy(data, r.base, r.length);
isc_buffer_add(&envbuf, r.length);
isc_buffer_putuint16(&envbuf, set->type);
@ -280,7 +279,7 @@ dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
ret = rdataset_to_sortedarray(set, mctx, &rdatas, &nrdatas);
if (ret != ISC_R_SUCCESS)
goto cleanup_signature;
isc_buffer_used(&envbuf, &r);
isc_buffer_usedregion(&envbuf, &r);
for (i = 0; i < nrdatas; i++) {
isc_uint16_t len;
@ -293,11 +292,10 @@ dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
goto cleanup_array;
/* Digest the length of the rdata */
isc_buffer_init(&lenbuf, &len, sizeof(len),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&lenbuf, &len, sizeof(len));
INSIST(rdatas[i].length < 65536);
isc_buffer_putuint16(&lenbuf, (isc_uint16_t)rdatas[i].length);
isc_buffer_used(&lenbuf, &lenr);
isc_buffer_usedregion(&lenbuf, &lenr);
ret = dst_sign(DST_SIGMODE_UPDATE, key, &ctx, &lenr, NULL);
if (ret != ISC_R_SUCCESS)
goto cleanup_array;
@ -308,12 +306,11 @@ dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
goto cleanup_array;
}
isc_buffer_init(&sigbuf, sig.signature, sig.siglen,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&sigbuf, sig.signature, sig.siglen);
ret = dst_sign(DST_SIGMODE_FINAL, key, &ctx, NULL, &sigbuf);
if (ret != ISC_R_SUCCESS)
goto cleanup_array;
isc_buffer_used(&sigbuf, &r);
isc_buffer_usedregion(&sigbuf, &r);
if (r.length != sig.siglen) {
ret = ISC_R_NOSPACE;
goto cleanup_array;
@ -396,7 +393,7 @@ dns_dnssec_verify(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
dns_name_toregion(name, &r);
/* create an envelope for each rdata: <name|type|class|ttl> */
isc_buffer_init(&envbuf, data, sizeof(data), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&envbuf, data, sizeof(data));
if (labels - sig.labels > 0) {
isc_buffer_putuint8(&envbuf, 1);
isc_buffer_putuint8(&envbuf, '*');
@ -417,7 +414,7 @@ dns_dnssec_verify(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
ret = rdataset_to_sortedarray(set, mctx, &rdatas, &nrdatas);
if (ret != ISC_R_SUCCESS)
goto cleanup_struct;
isc_buffer_used(&envbuf, &r);
isc_buffer_usedregion(&envbuf, &r);
for (i = 0; i < nrdatas; i++) {
isc_uint16_t len;
@ -430,11 +427,10 @@ dns_dnssec_verify(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
goto cleanup_array;
/* Digest the rdata length */
isc_buffer_init(&lenbuf, &len, sizeof(len),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&lenbuf, &len, sizeof(len));
INSIST(rdatas[i].length < 65536);
isc_buffer_putuint16(&lenbuf, (isc_uint16_t)rdatas[i].length);
isc_buffer_used(&lenbuf, &lenr);
isc_buffer_usedregion(&lenbuf, &lenr);
/* Digest the rdata */
ret = dst_verify(DST_SIGMODE_UPDATE, key, &ctx, &lenr, NULL);
@ -572,7 +568,7 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
sig.siglen = 0;
sig.signature = NULL;
isc_buffer_init(&databuf, data, sizeof(data), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&databuf, data, sizeof(data));
RETERR(dst_sign(DST_SIGMODE_INIT, key, &ctx, NULL, NULL));
@ -581,14 +577,13 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
NULL));
/* Digest the header */
isc_buffer_init(&headerbuf, header, sizeof(header),
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&headerbuf, header, sizeof(header));
dns_message_renderheader(msg, &headerbuf);
isc_buffer_used(&headerbuf, &r);
isc_buffer_usedregion(&headerbuf, &r);
RETERR(dst_sign(DST_SIGMODE_UPDATE, key, &ctx, &r, NULL));
/* Digest the remainder of the message */
isc_buffer_used(msg->buffer, &r);
isc_buffer_usedregion(msg->buffer, &r);
isc_region_consume(&r, DNS_MESSAGE_HEADERLEN);
RETERR(dst_sign(DST_SIGMODE_UPDATE, key, &ctx, &r, NULL));
@ -599,7 +594,7 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
*/
RETERR(dns_rdata_fromstruct(NULL, dns_rdataclass_any,
dns_rdatatype_sig, &sig, &databuf));
isc_buffer_used(&databuf, &r);
isc_buffer_usedregion(&databuf, &r);
r.length -= 2;
RETERR(dst_sign(DST_SIGMODE_UPDATE, key, &ctx, &r, NULL));
@ -611,15 +606,13 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
goto failure;
}
isc_buffer_init(&sigbuf, sig.signature, sig.siglen,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&sigbuf, sig.signature, sig.siglen);
RETERR(dst_sign(DST_SIGMODE_FINAL, key, &ctx, NULL, &sigbuf));
rdata = NULL;
RETERR(dns_message_gettemprdata(msg, &rdata));
dynbuf = NULL;
RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 1024,
ISC_BUFFERTYPE_BINARY));
RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 1024));
RETERR(dns_rdata_fromstruct(rdata, dns_rdataclass_any,
dns_rdatatype_sig, &sig, dynbuf));
@ -680,7 +673,7 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg,
msg->verify_attempted = 1;
isc_buffer_used(source, &source_r);
isc_buffer_usedregion(source, &source_r);
RETERR(dns_rdataset_first(msg->sig0));
dns_rdataset_current(msg->sig0, &rdata);

View file

@ -73,8 +73,7 @@ struct dns_fixedname {
#define dns_fixedname_init(fn) \
do { \
dns_name_init(&((fn)->name), (fn)->offsets); \
isc_buffer_init(&((fn)->buffer), (fn)->data, 255, \
ISC_BUFFERTYPE_BINARY); \
isc_buffer_init(&((fn)->buffer), (fn)->data, 255); \
dns_name_setbuffer(&((fn)->name), &((fn)->buffer)); \
} while (0)

View file

@ -77,7 +77,7 @@
* Since the buffer itself exists until the message is destroyed, this sort
* of code can be written:
*
* buffer = isc_buffer_allocate(mctx, 512, ISC_BUFFERTYPE_BINARY);
* buffer = isc_buffer_allocate(mctx, 512);
* name = NULL;
* name = dns_message_gettempname(message, &name);
* dns_name_init(name, NULL);

View file

@ -710,12 +710,11 @@ isc_result_t dns_name_fromwire(dns_name_t *name,
*
* 'name' is a valid name.
*
* 'source' is a valid buffer of type ISC_BUFFERTYPE_BINARY, and the
* first byte of the active region should be the first byte of a DNS
* wire format domain name.
* 'source' is a valid buffer and the first byte of the active
* region should be the first byte of a DNS wire format domain name.
*
* 'target' is a valid buffer of type ISC_BUFFERTYPE_BINARY or
* 'target' is NULL and 'name' has a dedicated buffer.
* 'target' is a valid buffer or 'target' is NULL and 'name' has
* a dedicated buffer.
*
* 'dctx' is a valid decompression context.
*
@ -742,8 +741,7 @@ isc_result_t dns_name_fromwire(dns_name_t *name,
* Bad Form: Bad compression pointer
* Bad Form: Input too short
* Resource Limit: Too many compression pointers
* Resource Limit: Not enough space in buffer
*/
* Resource Limit: Not enough space in buffer */
isc_result_t dns_name_towire(dns_name_t *name,
dns_compress_t *cctx,
@ -763,7 +761,7 @@ isc_result_t dns_name_towire(dns_name_t *name,
*
* dns_name_isabsolute(name) == TRUE
*
* target is a valid buffer of type ISC_BUFFERTYPE_BINARY.
* target is a valid buffer.
*
* Any offsets specified in a global compression table are valid
* for buffer.
@ -802,10 +800,10 @@ isc_result_t dns_name_fromtext(dns_name_t *name,
*
* 'name' is a valid name.
*
* 'source' is a valid buffer of type ISC_BUFFERTYPE_TEXT.
* 'source' is a valid buffer.
*
* 'target' is a valid buffer of type ISC_BUFFERTYPE_BINARY or
* 'target' is NULL and 'name' has a dedicated buffer.
* 'target' is a valid buffer or 'target' is NULL and 'name' has
* a dedicated buffer.
*
* Ensures:
*
@ -829,8 +827,7 @@ isc_result_t dns_name_fromtext(dns_name_t *name,
* DNS_R_BITSTRINGTOOLONG
* DNS_R_BADDOTTEDQUAD
* ISC_R_NOSPACE
* ISC_R_UNEXPECTEDEND
*/
* ISC_R_UNEXPECTEDEND */
isc_result_t dns_name_totext(dns_name_t *name,
isc_boolean_t omit_final_dot,
@ -846,7 +843,7 @@ isc_result_t dns_name_totext(dns_name_t *name,
*
* 'name' is a valid name
*
* 'target' is a valid buffer of type ISC_BUFFERTYPE_TEXT
* 'target' is a valid buffer.
*
* dns_name_countlabels(name) > 0
*
@ -881,15 +878,14 @@ dns_name_downcase(dns_name_t *source, dns_name_t *name,
*
* Otherwise,
*
* 'target' is a valid buffer of type ISC_BUFFERTYPE_BINARY, or
* 'target' is NULL and 'name' has a dedicated buffer.
* 'target' is a valid buffer or 'target' is NULL and
* 'name' has a dedicated buffer.
*
* Returns:
* ISC_R_SUCCESS
* ISC_R_NOSPACE
*
* Note: if source == name, then the result will always be ISC_R_SUCCESS.
*/
* Note: if source == name, then the result will always be ISC_R_SUCCESS. */
isc_result_t dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix,
dns_name_t *name, isc_buffer_t *target);
@ -904,8 +900,8 @@ isc_result_t dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix,
*
* 'name' is a valid name or NULL.
*
* 'target' is a valid buffer of type ISC_BUFFERTYPE_BINARY, or
* 'target' is NULL and 'name' has a dedicated buffer.
* 'target' is a valid buffer or 'target' is NULL and 'name' has
* a dedicated buffer.
*
* If 'prefix' is absolute, 'suffix' must be NULL or the empty name.
*
@ -921,8 +917,7 @@ isc_result_t dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix,
*
* Returns:
* ISC_R_SUCCESS
* ISC_R_NOSPACE
*/
* ISC_R_NOSPACE */
isc_result_t
dns_name_split(dns_name_t *name,

View file

@ -631,7 +631,7 @@ dns_diff_print(dns_diff_t *diff, FILE *file) {
goto cleanup;
}
again:
isc_buffer_init(&buf, mem, size, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buf, mem, size);
result = dns_rdataset_totext(&rds, &t->name,
ISC_FALSE, ISC_FALSE, &buf);
@ -650,7 +650,7 @@ dns_diff_print(dns_diff_t *diff, FILE *file) {
goto again;
}
if (result == ISC_R_SUCCESS) {
isc_buffer_used(&buf, &r);
isc_buffer_usedregion(&buf, &r);
if (file != NULL)
fprintf(file, "%s %.*s\n",
t->op == DNS_DIFFOP_ADD ?
@ -1196,8 +1196,8 @@ dns_journal_open(isc_mem_t *mctx, const char *filename, isc_boolean_t write,
* wire format RR data. They will be reallocated
* later.
*/
isc_buffer_init(&j->it.source, NULL, 0, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&j->it.target, NULL, 0, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&j->it.source, NULL, 0);
isc_buffer_init(&j->it.target, NULL, 0);
dns_decompress_init(&j->it.dctx, -1, ISC_FALSE);
j->state =
@ -1512,7 +1512,7 @@ dns_journal_writediff(dns_journal_t *j, dns_diff_t *diff) {
if (mem == NULL)
return (ISC_R_NOMEMORY);
isc_buffer_init(&buffer, mem, size, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buffer, mem, size);
/*
* Pass 2. Write RRs to buffer.
@ -1531,11 +1531,11 @@ dns_journal_writediff(dns_journal_t *j, dns_diff_t *diff) {
isc_buffer_putuint32(&buffer, t->ttl);
INSIST(t->rdata.length < 65536);
isc_buffer_putuint16(&buffer, (isc_uint16_t)t->rdata.length);
isc_buffer_available(&buffer, &avail);
isc_buffer_availableregion(&buffer, &avail);
isc_buffer_putmem(&buffer, t->rdata.data, t->rdata.length);
}
isc_buffer_used(&buffer, &used);
isc_buffer_usedregion(&buffer, &used);
INSIST(used.length == size);
j->x.pos[1].offset += used.length;
@ -1722,8 +1722,8 @@ roll_forward(dns_journal_t *j, dns_db_t *db) {
* wire format transaction data. They will be reallocated
* later.
*/
isc_buffer_init(&source, NULL, 0, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, NULL, 0, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&source, NULL, 0);
isc_buffer_init(&target, NULL, 0);
/* Create the new database version. */
CHECK(dns_db_newversion(db, &ver));
@ -1872,8 +1872,8 @@ dns_journal_print(isc_mem_t *mctx, const char *filename, FILE *file) {
* wire format transaction data. They will be reallocated
* later.
*/
isc_buffer_init(&source, NULL, 0, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, NULL, 0, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&source, NULL, 0);
isc_buffer_init(&target, NULL, 0);
start_serial = dns_journal_first_serial(j);
end_serial = dns_journal_last_serial(j);
@ -2114,7 +2114,7 @@ read_one_rr(dns_journal_t *j) {
&j->it.dctx, ISC_FALSE, &j->it.target));
/* Check that the RR header is there, and parse it. */
isc_buffer_remaining(&j->it.source, &r);
isc_buffer_remainingregion(&j->it.source, &r);
if (r.length < 10)
FAIL(DNS_R_FORMERR);

View file

@ -204,7 +204,7 @@ dns_keytable_add(dns_keytable_t *keytable, dst_key_t **keyp) {
keyname = dst_key_name(*keyp);
INSIST(keyname != NULL);
len = strlen(keyname);
isc_buffer_init(&buffer, keyname, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer, keyname, len);
isc_buffer_add(&buffer, len);
dns_fixedname_init(&fname);
result = dns_name_fromtext(dns_fixedname_name(&fname), &buffer,

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: master.c,v 1.48 2000/04/20 18:47:17 bwelling Exp $ */
/* $Id: master.c,v 1.49 2000/04/27 00:01:29 tale Exp $ */
#include <config.h>
@ -251,8 +251,7 @@ load(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
result = ISC_R_NOMEMORY;
goto error_cleanup;
}
isc_buffer_init(&target, target_mem, target_size,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, target_mem, target_size);
target_save = target;
memset(name_in_use, 0, NBUFS * sizeof(isc_boolean_t));
@ -417,11 +416,10 @@ load(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
break;
INSIST(new_in_use < NBUFS);
isc_buffer_init(&name, &name_buf[new_in_use][0],
MAXWIRESZ, ISC_BUFFERTYPE_BINARY);
MAXWIRESZ);
dns_name_init(&new_name, NULL);
isc_buffer_init(&buffer, token.value.as_region.base,
token.value.as_region.length,
ISC_BUFFERTYPE_TEXT);
token.value.as_region.length);
isc_buffer_add(&buffer, token.value.as_region.length);
isc_buffer_setactive(&buffer,
token.value.as_region.length);
@ -520,8 +518,7 @@ load(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
current_known = ISC_TRUE;
current_has_delegation = ISC_FALSE;
isc_buffer_init(&target, target_mem,
target_size,
ISC_BUFFERTYPE_BINARY);
target_size);
}
}
} else {
@ -623,8 +620,7 @@ load(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
isc_buffer_t buffer;
isc_region_t region;
isc_buffer_init(&buffer, buf1, sizeof buf1,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer, buf1, sizeof(buf1));
result = dns_rdataclass_totext(rdclass, &buffer);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
@ -633,10 +629,9 @@ load(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
result = ISC_R_UNEXPECTED;
goto cleanup;
}
isc_buffer_used(&buffer, &region);
isc_buffer_usedregion(&buffer, &region);
len1 = region.length;
isc_buffer_init(&buffer, buf2, sizeof buf2,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer, buf2, sizeof(buf2));
result = dns_rdataclass_totext(zclass, &buffer);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
@ -645,7 +640,7 @@ load(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
result = ISC_R_UNEXPECTED;
goto cleanup;
}
isc_buffer_used(&buffer, &region);
isc_buffer_usedregion(&buffer, &region);
len2 = region.length;
(*callbacks->error)(callbacks,
"%s: %s:%d: class (%.*s) != zone class (%.*s)",
@ -790,8 +785,7 @@ load(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
glue_in_use = -1;
in_glue = ISC_FALSE;
current_has_delegation = ISC_FALSE;
isc_buffer_init(&target, target_mem, target_size,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&target, target_mem, target_size);
}
} while (!done);
/*

View file

@ -186,7 +186,7 @@ indent(unsigned int *current, unsigned int to, int tabwidth,
ntabs = 0;
if (ntabs > 0) {
isc_buffer_available(target, &r);
isc_buffer_availableregion(target, &r);
if (r.length < (unsigned) ntabs)
return (ISC_R_NOSPACE);
p = r.base;
@ -207,7 +207,7 @@ indent(unsigned int *current, unsigned int to, int tabwidth,
nspaces = to - from;
INSIST(nspaces >= 0);
isc_buffer_available(target, &r);
isc_buffer_availableregion(target, &r);
if (r.length < (unsigned) nspaces)
return (ISC_R_NOSPACE);
p = r.base;
@ -243,10 +243,9 @@ totext_ctx_init(const dns_master_style_t *style, dns_totext_ctx_t *ctx)
unsigned int col = 0;
isc_buffer_init(&buf, ctx->linebreak_buf,
sizeof(ctx->linebreak_buf),
ISC_BUFFERTYPE_TEXT);
sizeof(ctx->linebreak_buf));
isc_buffer_available(&buf, &r);
isc_buffer_availableregion(&buf, &r);
if (r.length < 1)
return (DNS_R_TEXTTOOLONG);
r.base[0] = '\n';
@ -266,7 +265,7 @@ totext_ctx_init(const dns_master_style_t *style, dns_totext_ctx_t *ctx)
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_available(&buf, &r);
isc_buffer_availableregion(&buf, &r);
if (r.length < 1)
return (DNS_R_TEXTTOOLONG);
r.base[0] = '\0';
@ -346,7 +345,7 @@ rdataset_totext(dns_rdataset_t *rdataset,
INDENT_TO(ttl_column);
length = sprintf(ttlbuf, "%u", rdataset->ttl);
INSIST(length <= sizeof ttlbuf);
isc_buffer_available(target, &r);
isc_buffer_availableregion(target, &r);
if (r.length < length)
return (ISC_R_NOSPACE);
memcpy(r.base, ttlbuf, length);
@ -404,7 +403,7 @@ rdataset_totext(dns_rdataset_t *rdataset,
ctx->linebreak,
target));
isc_buffer_available(target, &r);
isc_buffer_availableregion(target, &r);
if (r.length < 1)
return (ISC_R_NOSPACE);
r.base[0] = '\n';
@ -485,7 +484,7 @@ question_totext(dns_rdataset_t *rdataset,
column += (target->used - type_start);
}
isc_buffer_available(target, &r);
isc_buffer_availableregion(target, &r);
if (r.length < 1)
return (ISC_R_NOSPACE);
r.base[0] = '\n';
@ -562,7 +561,7 @@ dump_rdataset(isc_mem_t *mctx, dns_name_t *name, dns_rdataset_t *rdataset,
result = dns_ttl_totext(rdataset->ttl,
ISC_TRUE, buffer);
INSIST(result == ISC_R_SUCCESS);
isc_buffer_used(buffer, &r);
isc_buffer_usedregion(buffer, &r);
fprintf(f, "$TTL %u\t; %.*s\n", rdataset->ttl,
(int) r.length, (char *) r.base);
} else {
@ -592,14 +591,13 @@ dump_rdataset(isc_mem_t *mctx, dns_name_t *name, dns_rdataset_t *rdataset,
newmem = isc_mem_get(mctx, newlength);
if (newmem == NULL)
return (ISC_R_NOMEMORY);
isc_buffer_init(buffer, newmem, newlength,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(buffer, newmem, newlength);
}
if (result != ISC_R_SUCCESS)
return (result);
/* Write the buffer contents to the master file. */
isc_buffer_used(buffer, &r);
isc_buffer_usedregion(buffer, &r);
nwritten = fwrite(r.base, 1, (size_t) r.length, f);
if (nwritten != (size_t) r.length) {
@ -698,8 +696,7 @@ dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db,
if (bufmem == NULL)
return (ISC_R_NOMEMORY);
isc_buffer_init(&buffer, bufmem, initial_buffer_length,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&buffer, bufmem, initial_buffer_length);
/*
* If the database has cache semantics, output an RFC2540
@ -711,7 +708,7 @@ dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db,
if (dns_db_iscache(db)) {
result = dns_time32_totext(now, &buffer);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
isc_buffer_used(&buffer, &r);
isc_buffer_usedregion(&buffer, &r);
fprintf(f, "$DATE %.*s\n", (int) r.length, (char *) r.base);
}
@ -738,7 +735,7 @@ dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db,
isc_buffer_clear(&buffer);
result = dns_name_totext(origin, ISC_FALSE, &buffer);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
isc_buffer_used(&buffer, &r);
isc_buffer_usedregion(&buffer, &r);
fprintf(f, "$ORIGIN %.*s\n", (int) r.length,
(char *) r.base);
if ((ctx.style.flags & DNS_STYLEFLAG_REL_DATA) != 0)

View file

@ -170,8 +170,7 @@ newbuffer(dns_message_t *msg, unsigned int size)
isc_buffer_t *dynbuf;
dynbuf = NULL;
result = isc_buffer_allocate(msg->mctx, &dynbuf, size,
ISC_BUFFERTYPE_BINARY);
result = isc_buffer_allocate(msg->mctx, &dynbuf, size);
if (result != ISC_R_SUCCESS)
return (ISC_R_NOMEMORY);
@ -577,8 +576,7 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp)
isc_mempool_setname(m->rdspool, "msg:rdataset");
dynbuf = NULL;
result = isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE,
ISC_BUFFERTYPE_BINARY);
result = isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE);
if (result != ISC_R_SUCCESS)
goto cleanup;
ISC_LIST_APPEND(m->scratchpad, dynbuf, link);
@ -830,7 +828,7 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx)
/*
* Parse the name out of this packet.
*/
isc_buffer_remaining(source, &r);
isc_buffer_remainingregion(source, &r);
isc_buffer_setactive(source, r.length);
result = getname(name, source, msg, dctx);
if (result != ISC_R_SUCCESS)
@ -872,7 +870,7 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx)
/*
* Get type and class.
*/
isc_buffer_remaining(source, &r);
isc_buffer_remainingregion(source, &r);
if (r.length < 4) {
result = ISC_R_UNEXPECTEDEND;
goto cleanup;
@ -998,7 +996,7 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
/*
* Parse the name out of this packet.
*/
isc_buffer_remaining(source, &r);
isc_buffer_remainingregion(source, &r);
isc_buffer_setactive(source, r.length);
result = getname(name, source, msg, dctx);
if (result != ISC_R_SUCCESS)
@ -1009,7 +1007,7 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
* rdatalen bytes remain. (Some of this is deferred to
* later.)
*/
isc_buffer_remaining(source, &r);
isc_buffer_remainingregion(source, &r);
if (r.length < 2 + 2 + 4 + 2) {
result = ISC_R_UNEXPECTEDEND;
goto cleanup;
@ -1353,7 +1351,7 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
msg->header_ok = 0;
msg->question_ok = 0;
isc_buffer_remaining(source, &r);
isc_buffer_remainingregion(source, &r);
if (r.length < DNS_MESSAGE_HEADERLEN)
return (ISC_R_UNEXPECTEDEND);
@ -1401,7 +1399,7 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
if (ret != ISC_R_SUCCESS)
return (ret);
isc_buffer_remaining(source, &r);
isc_buffer_remainingregion(source, &r);
if (r.length != 0)
return (DNS_R_FORMERR);
@ -1409,7 +1407,7 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
msg->saved = isc_mem_get(msg->mctx, sizeof(isc_region_t));
if (msg->saved == NULL)
return (ISC_R_NOMEMORY);
isc_buffer_used(&origsource, &r);
isc_buffer_usedregion(&origsource, &r);
msg->saved->length = r.length;
msg->saved->base = isc_mem_get(msg->mctx, msg->saved->length);
if (msg->saved->base == NULL) {
@ -1444,7 +1442,7 @@ dns_message_renderbegin(dns_message_t *msg, isc_buffer_t *buffer)
* Make certain there is enough for at least the header in this
* buffer.
*/
isc_buffer_available(buffer, &r);
isc_buffer_availableregion(buffer, &r);
REQUIRE(r.length >= DNS_MESSAGE_HEADERLEN);
result = dns_compress_init(&msg->cctx, -1, msg->mctx);
@ -1477,8 +1475,8 @@ dns_message_renderchangebuffer(dns_message_t *msg, isc_buffer_t *buffer)
*/
isc_buffer_clear(buffer);
isc_buffer_available(buffer, &rn);
isc_buffer_used(msg->buffer, &r);
isc_buffer_availableregion(buffer, &rn);
isc_buffer_usedregion(msg->buffer, &r);
REQUIRE(rn.length > r.length);
/*
@ -1510,7 +1508,7 @@ dns_message_renderreserve(dns_message_t *msg, unsigned int space)
REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(msg->buffer != NULL);
isc_buffer_available(msg->buffer, &r);
isc_buffer_availableregion(msg->buffer, &r);
if (r.length < (space + msg->reserved))
return (ISC_R_NOSPACE);
@ -1667,7 +1665,7 @@ dns_message_renderheader(dns_message_t *msg, isc_buffer_t *target)
REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(target != NULL);
isc_buffer_available(target, &r);
isc_buffer_availableregion(target, &r);
REQUIRE(r.length >= DNS_MESSAGE_HEADERLEN);
isc_buffer_putuint16(target, msg->id);
@ -1759,8 +1757,8 @@ dns_message_renderend(dns_message_t *msg)
return (result);
}
isc_buffer_used(msg->buffer, &r);
isc_buffer_init(&tmpbuf, r.base, r.length, ISC_BUFFERTYPE_BINARY);
isc_buffer_usedregion(msg->buffer, &r);
isc_buffer_init(&tmpbuf, r.base, r.length);
dns_message_renderheader(msg, &tmpbuf);
@ -2050,7 +2048,7 @@ dns_message_peekheader(isc_buffer_t *source, dns_messageid_t *idp,
buffer = *source;
isc_buffer_remaining(&buffer, &r);
isc_buffer_remainingregion(&buffer, &r);
if (r.length < DNS_MESSAGE_HEADERLEN)
return (ISC_R_UNEXPECTEDEND);
@ -2229,8 +2227,7 @@ dns_message_signer(dns_message_t *msg, dns_name_t *signer) {
if (!dns_name_hasbuffer(signer)) {
isc_buffer_t *dynbuf = NULL;
result = isc_buffer_allocate(msg->mctx, &dynbuf, 512,
ISC_BUFFERTYPE_BINARY);
result = isc_buffer_allocate(msg->mctx, &dynbuf, 512);
if (result != ISC_R_SUCCESS)
return (result);
dns_name_setbuffer(signer, dynbuf);
@ -2288,8 +2285,7 @@ dns_message_checksig(dns_message_t *msg, dns_view_t *view) {
if (msg->tsigkey == NULL && msg->tsigset == NULL && msg->sig0 == NULL)
return (ISC_R_SUCCESS);
INSIST(msg->saved != NULL);
isc_buffer_init(&msgb, msg->saved->base, msg->saved->length,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&msgb, msg->saved->base, msg->saved->length);
isc_buffer_add(&msgb, msg->saved->length);
if (msg->tsigkey != NULL || msg->tsigset != NULL)
return (dns_view_checksig(view, &msgb, msg));
@ -2330,8 +2326,7 @@ dns_message_checksig(dns_message_t *msg, dns_view_t *view) {
dst_key_t *key = NULL;
dns_rdataset_current(&keyset, &rdata);
isc_buffer_init(&b, rdata.data, rdata.length,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&b, rdata.data, rdata.length);
isc_buffer_add(&b, rdata.length);
/*

View file

@ -319,9 +319,7 @@ dns_name_setbuffer(dns_name_t *name, isc_buffer_t *buffer) {
*/
REQUIRE(VALID_NAME(name));
REQUIRE((buffer != NULL &&
name->buffer == NULL &&
isc_buffer_type(buffer) == ISC_BUFFERTYPE_BINARY) ||
REQUIRE((buffer != NULL && name->buffer == NULL) ||
(buffer == NULL));
name->buffer = buffer;
@ -1039,7 +1037,7 @@ dns_name_fromregion(dns_name_t *name, isc_region_t *r) {
if (name->buffer != NULL) {
isc_buffer_clear(name->buffer);
isc_buffer_available(name->buffer, &r2);
isc_buffer_availableregion(name->buffer, &r2);
len = (r->length < r2.length) ? r->length : r2.length;
if (len > 255)
len = 255;
@ -1103,12 +1101,12 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source,
*/
REQUIRE(VALID_NAME(name));
REQUIRE(isc_buffer_type(source) == ISC_BUFFERTYPE_TEXT);
if (target == NULL && name->buffer != NULL) {
target = name->buffer;
isc_buffer_clear(target);
}
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
REQUIRE(BINDABLE(name));
INIT_OFFSETS(name, offsets, odata);
@ -1679,7 +1677,6 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
*/
REQUIRE(VALID_NAME(name));
REQUIRE(name->labels > 0);
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_TEXT);
ndata = name->ndata;
nlen = name->length;
@ -1823,9 +1820,7 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot,
}
isc_result_t
dns_name_downcase(dns_name_t *source, dns_name_t *name,
isc_buffer_t *target)
{
dns_name_downcase(dns_name_t *source, dns_name_t *name, isc_buffer_t *target) {
unsigned char *sndata, *ndata;
unsigned int nlen, count, bytes, labels;
isc_buffer_t buffer;
@ -1838,8 +1833,7 @@ dns_name_downcase(dns_name_t *source, dns_name_t *name,
REQUIRE(VALID_NAME(name));
if (source == name) {
REQUIRE((name->attributes & DNS_NAMEATTR_READONLY) == 0);
isc_buffer_init(&buffer, source->ndata, source->length,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buffer, source->ndata, source->length);
target = &buffer;
ndata = source->ndata;
} else {
@ -2128,12 +2122,12 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
*/
REQUIRE(VALID_NAME(name));
REQUIRE(isc_buffer_type(source) == ISC_BUFFERTYPE_BINARY);
if (target == NULL && name->buffer != NULL) {
target = name->buffer;
isc_buffer_clear(target);
}
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
REQUIRE(dctx != NULL);
REQUIRE(BINDABLE(name));
@ -2302,9 +2296,7 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
}
isc_result_t
dns_name_towire(dns_name_t *name, dns_compress_t *cctx,
isc_buffer_t *target)
{
dns_name_towire(dns_name_t *name, dns_compress_t *cctx, isc_buffer_t *target) {
unsigned int methods;
isc_uint16_t offset;
dns_name_t gp, gs;
@ -2322,7 +2314,6 @@ dns_name_towire(dns_name_t *name, dns_compress_t *cctx,
REQUIRE(VALID_NAME(name));
REQUIRE(cctx != NULL);
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
/*
* If 'name' doesn't have an offsets table, make a clone which
@ -2335,7 +2326,7 @@ dns_name_towire(dns_name_t *name, dns_compress_t *cctx,
}
dns_name_init(&gp, po);
dns_name_init(&gs, so);
isc_buffer_init(&gws, gb, sizeof gb, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&gws, gb, sizeof (gb));
offset = target->used; /*XXX*/
@ -2421,7 +2412,7 @@ dns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix, dns_name_t *name,
target = name->buffer;
isc_buffer_clear(name->buffer);
}
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
REQUIRE(BINDABLE(name));
/*
@ -2556,12 +2547,10 @@ dns_name_split(dns_name_t *name,
REQUIRE(prefix == NULL ||
(VALID_NAME(prefix) &&
prefix->buffer != NULL &&
isc_buffer_type(prefix->buffer) == ISC_BUFFERTYPE_BINARY &&
BINDABLE(prefix)));
REQUIRE(suffix == NULL ||
(VALID_NAME(suffix) &&
suffix->buffer != NULL &&
isc_buffer_type(suffix->buffer) == ISC_BUFFERTYPE_BINARY &&
BINDABLE(suffix)));
/*
@ -2982,13 +2971,13 @@ dns_name_digest(dns_name_t *name, dns_digestfunc_t digest, void *arg) {
REQUIRE(digest != NULL);
dns_name_init(&downname, NULL);
isc_buffer_init(&buffer, data, sizeof data, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buffer, data, sizeof(data));
result = dns_name_downcase(name, &downname, &buffer);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_used(&buffer, &r);
isc_buffer_usedregion(&buffer, &r);
return ((digest)(arg, &r));
}
@ -3018,19 +3007,18 @@ dns_name_print(dns_name_t *name, FILE *stream) {
REQUIRE(VALID_NAME(name));
isc_buffer_init(&b, t, sizeof t, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&b, t, sizeof(t));
result = dns_name_totext(name, ISC_FALSE, &b);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_used(&b, &r);
isc_buffer_usedregion(&b, &r);
fprintf(stream, "%.*s", (int)r.length, (char *)r.base);
return (ISC_R_SUCCESS);
}
void
dns_name_format(dns_name_t *name, char *cp, unsigned int size)
{
dns_name_format(dns_name_t *name, char *cp, unsigned int size) {
isc_result_t result;
isc_buffer_t buf;
isc_boolean_t omit_final_dot = ISC_TRUE;
@ -3040,16 +3028,20 @@ dns_name_format(dns_name_t *name, char *cp, unsigned int size)
if (dns_name_equal(name, dns_rootname))
omit_final_dot = ISC_FALSE;
/* Leave room for null termination after buffer. */
isc_buffer_init(&buf, cp, size - 1, ISC_BUFFERTYPE_TEXT);
/*
* Leave room for null termination after buffer.
*/
isc_buffer_init(&buf, cp, size - 1);
result = dns_name_totext(name, omit_final_dot, &buf);
if (result == ISC_R_SUCCESS) {
/* Null terminate. */
/*
* Null terminate.
*/
isc_region_t r;
isc_buffer_used(&buf, &r);
isc_buffer_usedregion(&buf, &r);
((char *) r.base)[r.length] = '\0';
} else {
} else
snprintf(cp, size, "<unknown>");
}
}

View file

@ -53,7 +53,7 @@ copy_rdataset(dns_rdataset_t *rdataset, isc_buffer_t *buffer) {
/*
* Copy the rdataset count to the buffer.
*/
isc_buffer_available(buffer, &ar);
isc_buffer_availableregion(buffer, &ar);
if (ar.length < 2)
return (ISC_R_NOSPACE);
count = dns_rdataset_count(rdataset);
@ -65,7 +65,7 @@ copy_rdataset(dns_rdataset_t *rdataset, isc_buffer_t *buffer) {
dns_rdataset_current(rdataset, &rdata);
dns_rdata_toregion(&rdata, &r);
INSIST(r.length <= 65535);
isc_buffer_available(buffer, &ar);
isc_buffer_availableregion(buffer, &ar);
if (ar.length < 2)
return (ISC_R_NOSPACE);
/*
@ -121,7 +121,7 @@ dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
*/
ttl = 0xffffffff;
trust = 0xffff;
isc_buffer_init(&buffer, data, sizeof data, ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buffer, data, sizeof(data));
result = dns_message_firstname(message, DNS_SECTION_AUTHORITY);
while (result == ISC_R_SUCCESS) {
name = NULL;
@ -154,7 +154,7 @@ dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
/*
* Copy the type to the buffer.
*/
isc_buffer_available(&buffer, &r);
isc_buffer_availableregion(&buffer, &r);
if (r.length < 2)
return (ISC_R_NOSPACE);
isc_buffer_putuint16(&buffer,
@ -199,7 +199,7 @@ dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
/*
* Copy the type and a zero rdata count to the buffer.
*/
isc_buffer_available(&buffer, &r);
isc_buffer_availableregion(&buffer, &r);
if (r.length < 4)
return (ISC_R_NOSPACE);
isc_buffer_putuint16(&buffer, 0);
@ -228,7 +228,7 @@ dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
*/
INSIST(trust != 0xffff);
dns_rdata_init(&rdata);
isc_buffer_used(&buffer, &r);
isc_buffer_usedregion(&buffer, &r);
rdata.data = r.base;
rdata.length = r.length;
rdata.rdclass = dns_db_class(cache);
@ -277,8 +277,7 @@ dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
return (result);
dns_rdataset_current(rdataset, &rdata);
INSIST(dns_rdataset_next(rdataset) == ISC_R_NOMORE);
isc_buffer_init(&source, rdata.data, rdata.length,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&source, rdata.data, rdata.length);
isc_buffer_add(&source, rdata.length);
if (dns_compress_getedns(cctx) >= 1)
@ -291,7 +290,7 @@ dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
count = 0;
do {
dns_name_init(&name, NULL);
isc_buffer_remaining(&source, &remaining);
isc_buffer_remainingregion(&source, &remaining);
dns_name_fromregion(&name, &remaining);
INSIST(remaining.length >= name.length);
isc_buffer_forward(&source, name.length);
@ -306,11 +305,11 @@ dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
* Get the length of this rdata and set up an
* rdata structure for it.
*/
isc_buffer_remaining(&source, &remaining);
isc_buffer_remainingregion(&source, &remaining);
INSIST(remaining.length >= 2);
dns_rdata_init(&rdata);
rdata.length = isc_buffer_getuint16(&source);
isc_buffer_remaining(&source, &remaining);
isc_buffer_remainingregion(&source, &remaining);
rdata.data = remaining.base;
rdata.type = type;
rdata.rdclass = rdataset->rdclass;
@ -328,7 +327,7 @@ dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
* See if we have space for type, class, ttl, and
* rdata length. Write the type, class, and ttl.
*/
isc_buffer_remaining(target, &tremaining);
isc_buffer_remainingregion(target, &tremaining);
if (tremaining.length < 10) {
result = ISC_R_NOSPACE;
goto rollback;
@ -362,7 +361,7 @@ dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
count++;
}
isc_buffer_remaining(&source, &remaining);
isc_buffer_remainingregion(&source, &remaining);
} while (remaining.length > 0);
*countp = count;

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rbt.c,v 1.75 2000/04/24 21:18:16 tale Exp $ */
/* $Id: rbt.c,v 1.76 2000/04/27 00:01:39 tale Exp $ */
/* Principal Authors: DCL */
@ -1901,7 +1901,7 @@ dns_rbt_printnodename(dns_rbtnode_t *node) {
dns_name_init(&name, offsets);
dns_name_fromregion(&name, &r);
isc_buffer_init(&target, buffer, 255, ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&target, buffer, 255);
/*
* ISC_FALSE means absolute names have the final dot added.

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rdata.c,v 1.79 2000/04/25 21:11:50 explorer Exp $ */
/* $Id: rdata.c,v 1.80 2000/04/27 00:01:44 tale Exp $ */
#include <config.h>
@ -75,8 +75,7 @@ static unsigned int name_length(dns_name_t *name);
static isc_result_t str_totext(char *source, isc_buffer_t *target);
static isc_boolean_t buffer_empty(isc_buffer_t *source);
static void buffer_fromregion(isc_buffer_t *buffer,
isc_region_t *region,
unsigned int type);
isc_region_t *region);
static isc_result_t uint32_tobuffer(isc_uint32_t,
isc_buffer_t *target);
static isc_result_t uint16_tobuffer(isc_uint32_t,
@ -308,8 +307,6 @@ dns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
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;
@ -348,13 +345,13 @@ dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
isc_buffer_t st;
REQUIRE(rdata != NULL);
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_BINARY);
st = *target;
TOWIRESWITCH
if (use_default) {
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (tr.length < rdata->length)
return (ISC_R_NOSPACE);
memcpy(tr.base, rdata->data, rdata->length);
@ -387,9 +384,7 @@ dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
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);
REQUIRE(origin == NULL || dns_name_isabsolute(origin) == ISC_TRUE);
st = *target;
region.base = (unsigned char *)(target->base) + target->used;
@ -471,9 +466,8 @@ rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
isc_boolean_t use_default = ISC_FALSE;
REQUIRE(rdata != NULL);
REQUIRE(isc_buffer_type(target) == ISC_BUFFERTYPE_TEXT);
if (tctx->origin != NULL)
REQUIRE(dns_name_isabsolute(tctx->origin) == ISC_TRUE);
REQUIRE(tctx->origin == NULL ||
dns_name_isabsolute(tctx->origin) == ISC_TRUE);
/* Some DynDNS meta-RRs have empty rdata. */
if (rdata->length == 0)
@ -530,7 +524,6 @@ dns_rdata_fromstruct(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
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;
@ -931,7 +924,7 @@ txt_totext(isc_region_t *source, isc_buffer_t *target) {
char *tp;
isc_region_t region;
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
sp = source->base;
tp = (char *)region.base;
tl = region.length;
@ -983,7 +976,7 @@ txt_fromtext(isc_textregion_t *source, isc_buffer_t *target) {
int d;
int c;
isc_buffer_available(target, &tregion);
isc_buffer_availableregion(target, &tregion);
s = source->base;
n = source->length;
t = tregion.base;
@ -1040,14 +1033,14 @@ txt_fromwire(isc_buffer_t *source, isc_buffer_t *target) {
isc_region_t sregion;
isc_region_t tregion;
isc_buffer_active(source, &sregion);
isc_buffer_activeregion(source, &sregion);
if (sregion.length == 0)
return(ISC_R_UNEXPECTEDEND);
n = *sregion.base + 1;
if (n > sregion.length)
return (ISC_R_UNEXPECTEDEND);
isc_buffer_available(target, &tregion);
isc_buffer_availableregion(target, &tregion);
if (n > tregion.length)
return (ISC_R_NOSPACE);
@ -1089,7 +1082,7 @@ str_totext(char *source, isc_buffer_t *target) {
unsigned int l;
isc_region_t region;
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
l = strlen(source);
if (l > region.length)
@ -1106,10 +1099,8 @@ buffer_empty(isc_buffer_t *source) {
}
static void
buffer_fromregion(isc_buffer_t *buffer, isc_region_t *region,
unsigned int type) {
isc_buffer_init(buffer, region->base, region->length, type);
buffer_fromregion(isc_buffer_t *buffer, isc_region_t *region) {
isc_buffer_init(buffer, region->base, region->length);
isc_buffer_add(buffer, region->length);
isc_buffer_setactive(buffer, region->length);
}
@ -1118,7 +1109,7 @@ static isc_result_t
uint32_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
isc_region_t region;
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (region.length < 4)
return (ISC_R_NOSPACE);
isc_buffer_putuint32(target, value);
@ -1131,7 +1122,7 @@ uint16_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
if (value > 0xffff)
return (DNS_R_RANGE);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (region.length < 2)
return (ISC_R_NOSPACE);
isc_buffer_putuint16(target, (isc_uint16_t)value);
@ -1144,7 +1135,7 @@ uint8_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
if (value > 0xff)
return (DNS_R_RANGE);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (region.length < 1)
return (ISC_R_NOSPACE);
isc_buffer_putuint8(target, (isc_uint8_t)value);
@ -1225,7 +1216,7 @@ static isc_result_t
mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) {
isc_region_t tr;
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (length > tr.length)
return (ISC_R_NOSPACE);
memcpy(tr.base, base, length);
@ -1360,7 +1351,7 @@ putbyte(int c, isc_buffer_t *target, struct state *state) {
Crot <<= 1;
}
Crot += c;
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (tr.length < 1)
return (ISC_R_NOSPACE);
tr.base[0] = c;
@ -1432,7 +1423,7 @@ static isc_result_t
byte_btoa(int c, isc_buffer_t *target, struct state *state) {
isc_region_t tr;
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
Ceor ^= c;
Csum += c;
Csum += 1;

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tsig_250.c,v 1.28 2000/04/14 20:13:48 explorer Exp $ */
/* $Id: tsig_250.c,v 1.29 2000/04/27 00:02:22 tale Exp $ */
/* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */
@ -45,8 +45,7 @@ fromtext_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* Algorithm Name */
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
RETERR(dns_name_fromtext(&name, &buffer, origin, downcase, target));
@ -210,7 +209,7 @@ fromwire_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
dns_name_init(&name, NULL);
RETERR(dns_name_fromwire(&name, source, dctx, downcase, target));
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
/* Time Signed + Fudge */
if (sr.length < 8)
return (ISC_R_UNEXPECTEDEND);
@ -313,7 +312,7 @@ fromstruct_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(dns_name_towire(&tsig->algorithm, &cctx, target));
dns_compress_invalidate(&cctx);
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (tr.length < 6 + 2 + 2)
return (ISC_R_NOSPACE);
@ -330,14 +329,14 @@ fromstruct_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* Signature */
if (tsig->siglen > 0) {
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (tr.length < tsig->siglen)
return (ISC_R_NOSPACE);
memcpy(tr.base, tsig->signature, tsig->siglen);
isc_buffer_add(target, tsig->siglen);
}
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (tr.length < 2 + 2 + 2)
return (ISC_R_NOSPACE);
@ -352,7 +351,7 @@ fromstruct_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* Other Data */
if (tsig->otherlen > 0) {
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (tr.length < tsig->otherlen)
return (ISC_R_NOSPACE);
memcpy(tr.base, tsig->other, tsig->otherlen);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: afsdb_18.c,v 1.21 2000/04/07 03:54:07 explorer Exp $ */
/* $Id: afsdb_18.c,v 1.22 2000/04/27 00:02:23 tale Exp $ */
/* Reviewed: Wed Mar 15 14:59:00 PST 2000 by explorer */
@ -46,8 +46,7 @@ fromtext_afsdb(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* hostname */
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
@ -98,8 +97,8 @@ fromwire_afsdb(dns_rdataclass_t rdclass, dns_rdatatype_t type,
dns_name_init(&name, NULL);
isc_buffer_active(source, &sr);
isc_buffer_available(target, &tr);
isc_buffer_activeregion(source, &sr);
isc_buffer_availableregion(target, &tr);
if (tr.length < 2)
return (ISC_R_NOSPACE);
if (sr.length < 2)
@ -124,7 +123,7 @@ towire_afsdb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target)
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
dns_rdata_toregion(rdata, &sr);
if (tr.length < 2)
return (ISC_R_NOSPACE);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: cert_37.c,v 1.22 2000/04/07 03:54:08 explorer Exp $ */
/* $Id: cert_37.c,v 1.23 2000/04/27 00:02:24 tale Exp $ */
/* Reviewed: Wed Mar 15 21:14:32 EST 2000 by tale */
@ -112,7 +112,7 @@ fromwire_cert(dns_rdataclass_t rdclass, dns_rdatatype_t type,
UNUSED(dctx);
UNUSED(downcase);
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
if (sr.length < 5)
return (ISC_R_UNEXPECTEDEND);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: cname_5.c,v 1.24 2000/04/07 03:54:09 explorer Exp $ */
/* $Id: cname_5.c,v 1.25 2000/04/27 00:02:24 tale Exp $ */
/* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */
@ -40,8 +40,7 @@ fromtext_cname(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: dname_39.c,v 1.17 2000/04/07 03:54:10 explorer Exp $ */
/* $Id: dname_39.c,v 1.18 2000/04/27 00:02:25 tale Exp $ */
/* Reviewed: Wed Mar 15 16:52:38 PST 2000 by explorer */
@ -42,8 +42,7 @@ fromtext_dname(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: key_25.c,v 1.20 2000/04/26 01:41:58 marka Exp $ */
/* $Id: key_25.c,v 1.21 2000/04/27 00:02:26 tale Exp $ */
/*
* Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley.
@ -127,7 +127,7 @@ fromwire_key(dns_rdataclass_t rdclass, dns_rdatatype_t type,
REQUIRE(type == 25);
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
if (sr.length < 4)
return (ISC_R_UNEXPECTEDEND);
@ -187,7 +187,7 @@ fromstruct_key(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
/* Data */
if (key->datalen > 0) {
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (tr.length < key->datalen)
return (ISC_R_NOSPACE);
memcpy(tr.base, key->data, key->datalen);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: loc_29.c,v 1.14 2000/04/07 03:54:16 explorer Exp $ */
/* $Id: loc_29.c,v 1.15 2000/04/27 00:02:27 tale Exp $ */
/* Reviewed: Wed Mar 15 18:13:09 PST 2000 by explorer */
@ -494,7 +494,7 @@ fromwire_loc(dns_rdataclass_t rdclass, dns_rdatatype_t type,
REQUIRE(type == 29);
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
if (sr.length < 1)
return (ISC_R_UNEXPECTEDEND);
if (sr.base[0] != 0)
@ -537,7 +537,7 @@ fromwire_loc(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* altitiude */
/* all values possible */
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
isc_buffer_forward(source, 16);
return (mem_tobuffer(target, sr.base, 16));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mb_7.c,v 1.24 2000/04/07 03:54:17 explorer Exp $ */
/* $Id: mb_7.c,v 1.25 2000/04/27 00:02:27 tale Exp $ */
/* Reviewed: Wed Mar 15 17:31:26 PST 2000 by bwelling */
@ -40,8 +40,7 @@ fromtext_mb(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: md_3.c,v 1.25 2000/04/07 03:54:18 explorer Exp $ */
/* $Id: md_3.c,v 1.26 2000/04/27 00:02:28 tale Exp $ */
/* Reviewed: Wed Mar 15 17:48:20 PST 2000 by bwelling */
@ -40,8 +40,7 @@ fromtext_md(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mf_4.c,v 1.23 2000/04/07 03:54:20 explorer Exp $ */
/* $Id: mf_4.c,v 1.24 2000/04/27 00:02:29 tale Exp $ */
/* reviewed: Wed Mar 15 17:47:33 PST 2000 by brister */
@ -40,8 +40,7 @@ fromtext_mf(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mg_8.c,v 1.22 2000/04/07 03:54:21 explorer Exp $ */
/* $Id: mg_8.c,v 1.23 2000/04/27 00:02:29 tale Exp $ */
/* reviewed: Wed Mar 15 17:49:21 PST 2000 by brister */
@ -40,8 +40,7 @@ fromtext_mg(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: minfo_14.c,v 1.23 2000/04/07 03:54:22 explorer Exp $ */
/* $Id: minfo_14.c,v 1.24 2000/04/27 00:02:30 tale Exp $ */
/* reviewed: Wed Mar 15 17:45:32 PST 2000 by brister */
@ -42,8 +42,7 @@ fromtext_minfo(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
RETERR(dns_name_fromtext(&name, &buffer, origin,
downcase, target));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mr_9.c,v 1.21 2000/04/07 03:54:23 explorer Exp $ */
/* $Id: mr_9.c,v 1.22 2000/04/27 00:02:31 tale Exp $ */
/* Reviewed: Wed Mar 15 21:30:35 EST 2000 by tale */
@ -40,8 +40,7 @@ fromtext_mr(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mx_15.c,v 1.28 2000/04/07 03:54:24 explorer Exp $ */
/* $Id: mx_15.c,v 1.29 2000/04/27 00:02:31 tale Exp $ */
/* reviewed: Wed Mar 15 18:05:46 PST 2000 by brister */
@ -42,8 +42,7 @@ fromtext_mx(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
@ -96,7 +95,7 @@ fromwire_mx(dns_rdataclass_t rdclass, dns_rdatatype_t type,
dns_name_init(&name, NULL);
isc_buffer_active(source, &sregion);
isc_buffer_activeregion(source, &sregion);
if (sregion.length < 2)
return (ISC_R_UNEXPECTEDEND);
RETERR(mem_tobuffer(target, sregion.base, 2));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: ns_2.c,v 1.24 2000/04/07 03:54:25 explorer Exp $ */
/* $Id: ns_2.c,v 1.25 2000/04/27 00:02:33 tale Exp $ */
/* Reviewed: Wed Mar 15 18:15:00 PST 2000 by bwelling */
@ -40,8 +40,7 @@ fromtext_ns(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token,isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: null_10.c,v 1.20 2000/04/07 03:54:26 explorer Exp $ */
/* $Id: null_10.c,v 1.21 2000/04/27 00:02:33 tale Exp $ */
/* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */
@ -66,7 +66,7 @@ fromwire_null(dns_rdataclass_t rdclass, dns_rdatatype_t type,
REQUIRE(type == 10);
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
isc_buffer_forward(source, sr.length);
return (mem_tobuffer(target, sr.base, sr.length));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: nxt_30.c,v 1.25 2000/04/07 03:54:27 explorer Exp $ */
/* $Id: nxt_30.c,v 1.26 2000/04/27 00:02:34 tale Exp $ */
/* reviewed: Wed Mar 15 18:21:15 PST 2000 by brister */
@ -48,8 +48,7 @@ fromtext_nxt(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* next domain */
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
RETERR(dns_name_fromtext(&name, &buffer, origin, downcase, target));
@ -148,7 +147,7 @@ fromwire_nxt(dns_rdataclass_t rdclass, dns_rdatatype_t type,
dns_name_init(&name, NULL);
RETERR(dns_name_fromwire(&name, source, dctx, downcase, target));
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
/* XXXRTH Enforce RFC 2535 length rules if bit 0 is not set. */
if (sr.length > 8 * 1024)
return (DNS_R_EXTRADATA);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: opt_41.c,v 1.8 2000/04/14 20:13:49 explorer Exp $ */
/* $Id: opt_41.c,v 1.9 2000/04/27 00:02:35 tale Exp $ */
/* Reviewed: Thu Mar 16 14:06:44 PST 2000 by gson */
@ -78,7 +78,7 @@ fromwire_opt(dns_rdataclass_t rdclass, dns_rdatatype_t type,
UNUSED(dctx);
UNUSED(downcase);
isc_buffer_active(source, &sregion);
isc_buffer_activeregion(source, &sregion);
total = 0;
while (sregion.length != 0) {
if (sregion.length < 4)
@ -94,8 +94,8 @@ fromwire_opt(dns_rdataclass_t rdclass, dns_rdatatype_t type,
total += length;
}
isc_buffer_active(source, &sregion);
isc_buffer_available(target, &tregion);
isc_buffer_activeregion(source, &sregion);
isc_buffer_availableregion(target, &tregion);
if (tregion.length < total)
return (ISC_R_NOSPACE);
memcpy(tregion.base, sregion.base, total);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: ptr_12.c,v 1.22 2000/04/07 03:54:30 explorer Exp $ */
/* $Id: ptr_12.c,v 1.23 2000/04/27 00:02:36 tale Exp $ */
/* Reviewed: Thu Mar 16 14:05:12 PST 2000 by explorer */
@ -40,8 +40,7 @@ fromtext_ptr(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rp_17.c,v 1.19 2000/04/07 03:54:32 explorer Exp $ */
/* $Id: rp_17.c,v 1.20 2000/04/27 00:02:37 tale Exp $ */
/* RFC 1183 */
@ -44,8 +44,7 @@ fromtext_rp(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
RETERR(dns_name_fromtext(&name, &buffer, origin,
downcase, target));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: rt_21.c,v 1.19 2000/04/07 03:54:33 explorer Exp $ */
/* $Id: rt_21.c,v 1.20 2000/04/27 00:02:37 tale Exp $ */
/* reviewed: Thu Mar 16 15:02:31 PST 2000 by brister */
@ -46,8 +46,7 @@ fromtext_rt(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
@ -98,8 +97,8 @@ fromwire_rt(dns_rdataclass_t rdclass, dns_rdatatype_t type,
dns_name_init(&name, NULL);
isc_buffer_active(source, &sregion);
isc_buffer_available(target, &tregion);
isc_buffer_activeregion(source, &sregion);
isc_buffer_availableregion(target, &tregion);
if (tregion.length < 2)
return (ISC_R_NOSPACE);
if (sregion.length < 2)
@ -124,7 +123,7 @@ towire_rt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target)
else
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
dns_rdata_toregion(rdata, &region);
if (tr.length < 2)
return (ISC_R_NOSPACE);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: sig_24.c,v 1.32 2000/04/07 03:54:34 explorer Exp $ */
/* $Id: sig_24.c,v 1.33 2000/04/27 00:02:38 tale Exp $ */
/* Reviewed: Fri Mar 17 09:05:02 PST 2000 by gson */
@ -91,8 +91,7 @@ fromtext_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* signer */
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
RETERR(dns_name_fromtext(&name, &buffer, origin, downcase, target));
@ -201,7 +200,7 @@ fromwire_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
UNUSED(rdclass);
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
/*
* type covered: 2
* algorithm: 1
@ -222,7 +221,7 @@ fromwire_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(dns_name_fromwire(&name, source, dctx, downcase, target));
/* sig */
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
isc_buffer_forward(source, sr.length);
return (mem_tobuffer(target, sr.base, sr.length));
}
@ -347,7 +346,7 @@ fromstruct_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
/* Signature */
if (sig->siglen > 0) {
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (tr.length < sig->siglen)
return (ISC_R_NOSPACE);
memcpy(tr.base, sig->signature, sig->siglen);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: soa_6.c,v 1.32 2000/04/07 03:54:35 explorer Exp $ */
/* $Id: soa_6.c,v 1.33 2000/04/27 00:02:39 tale Exp $ */
/* Reviewed: Thu Mar 16 15:18:32 PST 2000 by explorer */
@ -46,8 +46,7 @@ fromtext_soa(dns_rdataclass_t rdclass, dns_rdatatype_t type,
ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
RETERR(dns_name_fromtext(&name, &buffer, origin,
downcase, target));
}
@ -162,8 +161,8 @@ fromwire_soa(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(dns_name_fromwire(&mname, source, dctx, downcase, target));
RETERR(dns_name_fromwire(&rname, source, dctx, downcase, target));
isc_buffer_active(source, &sregion);
isc_buffer_available(target, &tregion);
isc_buffer_activeregion(source, &sregion);
isc_buffer_availableregion(target, &tregion);
if (sregion.length < 20)
return (ISC_R_UNEXPECTEDEND);
@ -205,7 +204,7 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target)
isc_region_consume(&sregion, name_length(&rname));
RETERR(dns_name_towire(&rname, cctx, target));
isc_buffer_available(target, &tregion);
isc_buffer_availableregion(target, &tregion);
if (tregion.length < 20)
return (ISC_R_NOSPACE);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tkey_249.c,v 1.25 2000/04/07 03:54:36 explorer Exp $ */
/* $Id: tkey_249.c,v 1.26 2000/04/27 00:02:41 tale Exp $ */
/*
* Reviewed: Thu Mar 16 17:35:30 PST 2000 by halley.
@ -47,8 +47,7 @@ fromtext_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* Algorithm */
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
RETERR(dns_name_fromtext(&name, &buffer, origin, downcase, target));
@ -222,7 +221,7 @@ fromwire_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type,
* Mode: 2
* Error: 2
*/
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
if (sr.length < 12)
return (ISC_R_UNEXPECTEDEND);
RETERR(mem_tobuffer(target, sr.base, 12));
@ -337,7 +336,7 @@ fromstruct_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* Key */
if (tkey->keylen > 0) {
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (tr.length < tkey->keylen)
return (ISC_R_NOSPACE);
memcpy(tr.base, tkey->key, tkey->keylen);
@ -349,7 +348,7 @@ fromstruct_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* Other data */
if (tkey->otherlen > 0) {
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (tr.length < tkey->otherlen)
return (ISC_R_NOSPACE);
memcpy(tr.base, tkey->other, tkey->otherlen);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: txt_16.c,v 1.22 2000/04/07 03:54:37 explorer Exp $ */
/* $Id: txt_16.c,v 1.23 2000/04/27 00:02:42 tale Exp $ */
/* Reviewed: Thu Mar 16 15:40:00 PST 2000 by bwelling */
@ -100,7 +100,7 @@ towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
UNUSED(cctx);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (region.length < rdata->length)
return (ISC_R_NOSPACE);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: unspec_103.c,v 1.14 2000/04/07 03:54:38 explorer Exp $ */
/* $Id: unspec_103.c,v 1.15 2000/04/27 00:02:44 tale Exp $ */
#ifndef RDATA_GENERIC_UNSPEC_103_C
#define RDATA_GENERIC_UNSPEC_103_C
@ -62,7 +62,7 @@ fromwire_unspec(dns_rdataclass_t rdclass, dns_rdatatype_t type,
rdclass = rdclass; /*unused*/
dctx = dctx; /*unused*/
downcase = downcase; /*unused*/
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
isc_buffer_forward(source, sr.length);
return (mem_tobuffer(target, sr.base, sr.length));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: x25_19.c,v 1.14 2000/04/07 03:54:40 explorer Exp $ */
/* $Id: x25_19.c,v 1.15 2000/04/27 00:02:45 tale Exp $ */
/* Reviewed: Thu Mar 16 16:15:57 PST 2000 by bwelling */
@ -78,7 +78,7 @@ fromwire_x25(dns_rdataclass_t rdclass, dns_rdatatype_t type,
REQUIRE(type == 19);
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
if (sr.length < 5)
return (DNS_R_FORMERR);
return (txt_fromwire(source, target));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: a_1.c,v 1.7 2000/04/07 03:54:41 explorer Exp $ */
/* $Id: a_1.c,v 1.8 2000/04/27 00:02:45 tale Exp $ */
/* reviewed: Thu Mar 16 15:58:36 PST 2000 by brister */
@ -47,7 +47,7 @@ fromtext_hs_a(dns_rdataclass_t rdclass, dns_rdatatype_t type,
if (inet_aton(token.value.as_pointer, &addr) != 1)
return (DNS_R_BADDOTTEDQUAD);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (region.length < 4)
return (ISC_R_NOSPACE);
memcpy(region.base, &addr, 4);
@ -67,7 +67,7 @@ totext_hs_a(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
UNUSED(tctx);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (inet_ntop(AF_INET, rdata->data,
(char *)region.base, region.length) == NULL)
return (ISC_R_NOSPACE);
@ -91,8 +91,8 @@ fromwire_hs_a(dns_rdataclass_t rdclass, dns_rdatatype_t type,
UNUSED(downcase);
isc_buffer_active(source, &sregion);
isc_buffer_available(target, &tregion);
isc_buffer_activeregion(source, &sregion);
isc_buffer_availableregion(target, &tregion);
if (sregion.length < 4)
return (ISC_R_UNEXPECTEDEND);
if (tregion.length < 4)
@ -114,7 +114,7 @@ towire_hs_a(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target)
UNUSED(cctx);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (region.length < rdata->length)
return (ISC_R_NOSPACE);
memcpy(region.base, rdata->data, rdata->length);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: a6_38.c,v 1.24 2000/04/07 03:54:42 explorer Exp $ */
/* $Id: a6_38.c,v 1.25 2000/04/27 00:02:46 tale Exp $ */
/* draft-ietf-ipngwg-dns-lookups-03.txt */
@ -71,8 +71,7 @@ fromtext_in_a6(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
@ -109,7 +108,7 @@ totext_in_a6(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
memcpy(&addr[octets], sr.base, 16 - octets);
mask = 0xff >> (prefixlen % 8);
addr[octets] &= mask;
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (inet_ntop(AF_INET6, addr,
(char *)tr.base, tr.length) == NULL)
return (ISC_R_NOSPACE);
@ -148,7 +147,7 @@ fromwire_in_a6(dns_rdataclass_t rdclass, dns_rdatatype_t type,
else
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
/* prefix length */
if (sr.length < 1)
return (ISC_R_UNEXPECTEDEND);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: a_1.c,v 1.27 2000/04/07 03:54:43 explorer Exp $ */
/* $Id: a_1.c,v 1.28 2000/04/27 00:02:47 tale Exp $ */
/* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */
@ -47,7 +47,7 @@ fromtext_in_a(dns_rdataclass_t rdclass, dns_rdatatype_t type,
if (inet_aton(token.value.as_pointer, &addr) != 1)
return (DNS_R_BADDOTTEDQUAD);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (region.length < 4)
return (ISC_R_NOSPACE);
memcpy(region.base, &addr, 4);
@ -67,7 +67,7 @@ totext_in_a(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
REQUIRE(rdata->rdclass == 1);
REQUIRE(rdata->length == 4);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (inet_ntop(AF_INET, rdata->data,
(char *)region.base, region.length) == NULL)
return (ISC_R_NOSPACE);
@ -90,8 +90,8 @@ fromwire_in_a(dns_rdataclass_t rdclass, dns_rdatatype_t type,
REQUIRE(type == 1);
REQUIRE(rdclass == 1);
isc_buffer_active(source, &sregion);
isc_buffer_available(target, &tregion);
isc_buffer_activeregion(source, &sregion);
isc_buffer_availableregion(target, &tregion);
if (sregion.length < 4)
return (ISC_R_UNEXPECTEDEND);
if (tregion.length < 4)
@ -112,7 +112,7 @@ towire_in_a(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 1);
REQUIRE(rdata->rdclass == 1);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (region.length < rdata->length)
return (ISC_R_NOSPACE);
memcpy(region.base, rdata->data, rdata->length);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: aaaa_28.c,v 1.19 2000/04/07 03:54:44 explorer Exp $ */
/* $Id: aaaa_28.c,v 1.20 2000/04/27 00:02:48 tale Exp $ */
/* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */
@ -49,7 +49,7 @@ fromtext_in_aaaa(dns_rdataclass_t rdclass, dns_rdatatype_t type,
if (inet_pton(AF_INET6, token.value.as_pointer, addr) != 1)
return (DNS_R_BADAAAA);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (region.length < 16)
return (ISC_R_NOSPACE);
memcpy(region.base, addr, 16);
@ -69,7 +69,7 @@ totext_in_aaaa(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
REQUIRE(rdata->rdclass == 1);
REQUIRE(rdata->length == 16);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (inet_ntop(AF_INET6, rdata->data,
(char *)region.base, region.length) == NULL)
return (ISC_R_NOSPACE);
@ -92,8 +92,8 @@ fromwire_in_aaaa(dns_rdataclass_t rdclass, dns_rdatatype_t type,
REQUIRE(type == 28);
REQUIRE(rdclass == 1);
isc_buffer_active(source, &sregion);
isc_buffer_available(target, &tregion);
isc_buffer_activeregion(source, &sregion);
isc_buffer_availableregion(target, &tregion);
if (sregion.length < 16)
return (ISC_R_UNEXPECTEDEND);
if (tregion.length < 16)
@ -114,7 +114,7 @@ towire_in_aaaa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
REQUIRE(rdata->type == 28);
REQUIRE(rdata->rdclass == 1);
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (region.length < rdata->length)
return (ISC_R_NOSPACE);
memcpy(region.base, rdata->data, rdata->length);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: kx_36.c,v 1.21 2000/04/07 03:54:45 explorer Exp $ */
/* $Id: kx_36.c,v 1.22 2000/04/27 00:02:48 tale Exp $ */
/* Reviewed: Thu Mar 16 17:24:54 PST 2000 by explorer */
@ -43,8 +43,7 @@ fromtext_in_kx(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
@ -97,7 +96,7 @@ fromwire_in_kx(dns_rdataclass_t rdclass, dns_rdatatype_t type,
dns_name_init(&name, NULL);
isc_buffer_active(source, &sregion);
isc_buffer_activeregion(source, &sregion);
if (sregion.length < 2)
return (ISC_R_UNEXPECTEDEND);
RETERR(mem_tobuffer(target, sregion.base, 2));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: naptr_35.c,v 1.20 2000/04/07 03:54:46 explorer Exp $ */
/* $Id: naptr_35.c,v 1.21 2000/04/27 00:02:48 tale Exp $ */
/* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */
@ -61,8 +61,7 @@ fromtext_in_naptr(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* replacement */
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
@ -137,7 +136,7 @@ fromwire_in_naptr(dns_rdataclass_t rdclass, dns_rdatatype_t type,
dns_name_init(&name, NULL);
/* order, preference */
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
if (sr.length < 4)
return (ISC_R_UNEXPECTEDEND);
RETERR(mem_tobuffer(target, sr.base, 4));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: nsap-ptr_23.c,v 1.16 2000/04/07 03:54:47 explorer Exp $ */
/* $Id: nsap-ptr_23.c,v 1.17 2000/04/27 00:02:49 tale Exp $ */
/* Reviewed: Fri Mar 17 10:16:02 PST 2000 by gson */
@ -41,8 +41,7 @@ fromtext_in_nsap_ptr(dns_rdataclass_t rdclass, dns_rdatatype_t type,
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: nsap_22.c,v 1.16 2000/04/07 03:54:48 explorer Exp $ */
/* $Id: nsap_22.c,v 1.17 2000/04/27 00:02:49 tale Exp $ */
/* Reviewed: Fri Mar 17 10:41:07 PST 2000 by gson */
@ -110,7 +110,7 @@ fromwire_in_nsap(dns_rdataclass_t rdclass, dns_rdatatype_t type,
UNUSED(dctx);
UNUSED(downcase);
isc_buffer_active(source, &region);
isc_buffer_activeregion(source, &region);
if (region.length < 1)
return (ISC_R_UNEXPECTEDEND);

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: px_26.c,v 1.17 2000/04/07 03:54:50 explorer Exp $ */
/* $Id: px_26.c,v 1.18 2000/04/27 00:02:50 tale Exp $ */
/* Reviewed: Mon Mar 20 10:44:27 PST 2000 */
@ -45,16 +45,14 @@ fromtext_in_px(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* MAP822 */
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
RETERR(dns_name_fromtext(&name, &buffer, origin, downcase, target));
/* MAPX400 */
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
@ -116,7 +114,7 @@ fromwire_in_px(dns_rdataclass_t rdclass, dns_rdatatype_t type,
dns_name_init(&name, NULL);
/* preference */
isc_buffer_active(source, &sregion);
isc_buffer_activeregion(source, &sregion);
if (sregion.length < 2)
return (ISC_R_UNEXPECTEDEND);
RETERR(mem_tobuffer(target, sregion.base, 2));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: srv_33.c,v 1.18 2000/04/07 03:54:51 explorer Exp $ */
/* $Id: srv_33.c,v 1.19 2000/04/27 00:02:50 tale Exp $ */
/* Reviewed: Fri Mar 17 13:01:00 PST 2000 by bwelling */
@ -53,8 +53,7 @@ fromtext_in_srv(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* target */
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
buffer_fromregion(&buffer, &token.value.as_region);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
@ -123,7 +122,7 @@ fromwire_in_srv(dns_rdataclass_t rdclass, dns_rdatatype_t type,
dns_name_init(&name, NULL);
/* priority, weight, port */
isc_buffer_active(source, &sr);
isc_buffer_activeregion(source, &sr);
if (sr.length < 6)
return (ISC_R_UNEXPECTEDEND);
RETERR(mem_tobuffer(target, sr.base, 6));

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: wks_11.c,v 1.24 2000/04/07 03:54:52 explorer Exp $ */
/* $Id: wks_11.c,v 1.25 2000/04/27 00:02:51 tale Exp $ */
/* Reviewed: Fri Mar 17 15:01:49 PST 2000 by explorer */
@ -58,7 +58,7 @@ fromtext_in_wks(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/* IPv4 dotted quad */
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
isc_buffer_available(target, &region);
isc_buffer_availableregion(target, &region);
if (inet_aton(token.value.as_pointer, &addr) != 1)
return (DNS_R_BADDOTTEDQUAD);
if (region.length < 4)
@ -130,7 +130,7 @@ totext_in_wks(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
REQUIRE(rdata->rdclass == 1);
dns_rdata_toregion(rdata, &sr);
isc_buffer_available(target, &tr);
isc_buffer_availableregion(target, &tr);
if (inet_ntop(AF_INET, sr.base, (char *)tr.base, tr.length) == NULL)
return (ISC_R_NOSPACE);
isc_buffer_add(target, strlen((char *)tr.base));
@ -171,8 +171,8 @@ fromwire_in_wks(dns_rdataclass_t rdclass, dns_rdatatype_t type,
REQUIRE(type == 11);
REQUIRE(rdclass == 1);
isc_buffer_active(source, &sr);
isc_buffer_available(target, &tr);
isc_buffer_activeregion(source, &sr);
isc_buffer_availableregion(target, &tr);
if (sr.length < 5)
return (ISC_R_UNEXPECTEDEND);

View file

@ -371,7 +371,7 @@ dns_rdataset_towire(dns_rdataset_t *rdataset,
if (!question)
headlen += sizeof(dns_ttl_t)
+ 2; /* XXX 2 for rdata len */
isc_buffer_available(target, &r);
isc_buffer_availableregion(target, &r);
if (r.length < headlen) {
result = ISC_R_NOSPACE;
goto rollback;

Some files were not shown because too many files have changed in this diff Show more