version 1.12, 2020/02/24 13:49:38 |
version 1.13, 2020/09/13 09:33:39 |
|
|
/*! \file */ |
/*! \file */ |
#include <sys/cdefs.h> |
#include <sys/cdefs.h> |
|
|
|
#include <errno.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <time.h> |
#include <time.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
{ |
{ |
isc_result_t result; |
isc_result_t result; |
char option_store[256]; |
char option_store[256]; |
char *cmd, *value, *ptr, *code; |
char *cmd, *value, *ptr, *code, *ep; |
|
const char *errstr; |
|
long lval; |
uint32_t num; |
uint32_t num; |
isc_boolean_t state = ISC_TRUE; |
isc_boolean_t state = ISC_TRUE; |
size_t n; |
size_t n; |
|
|
goto need_value; |
goto need_value; |
if (!state) |
if (!state) |
goto invalid_option; |
goto invalid_option; |
result = parse_uint(&num, value, COMMSIZE, |
num = strtonum(value, 0, COMMSIZE, &errstr); |
"buffer size"); |
if (errstr != NULL) |
if (result != ISC_R_SUCCESS) |
fatal("buffer size is %s: '%s'", errstr, value); |
fatal("Couldn't parse buffer size"); |
|
lookup->udpsize = num; |
lookup->udpsize = num; |
break; |
break; |
default: |
default: |
|
|
lookup->edns = 0; |
lookup->edns = 0; |
break; |
break; |
} |
} |
result = parse_uint(&num, |
num = strtonum(value, 0, 255, |
value, |
&errstr); |
255, |
if (errstr != NULL) |
"edns"); |
fatal("edns is %s: " |
if (result != ISC_R_SUCCESS) |
"'%s'", errstr, |
fatal("Couldn't parse " |
value); |
"edns"); |
|
lookup->edns = num; |
lookup->edns = num; |
break; |
break; |
case 'f': |
case 'f': |
|
|
lookup->ednsflags = 0; |
lookup->ednsflags = 0; |
break; |
break; |
} |
} |
result = parse_xint(&num, |
errno = 0; |
value, |
lval = strtol(value, &ep, 0); |
0xffff, |
if (value[0] == '\0' || *ep != |
"ednsflags"); |
'\0' || lval < 0 || lval > |
if (result != ISC_R_SUCCESS) |
0xffff || errno != 0) |
fatal("Couldn't parse " |
fatal("Couldn't parse " |
"ednsflags"); |
"ednsflags"); |
lookup->ednsflags = num; |
lookup->ednsflags = lval; |
break; |
break; |
case 'n': |
case 'n': |
FULLCHECK("ednsnegotiation"); |
FULLCHECK("ednsnegotiation"); |
|
|
goto need_value; |
goto need_value; |
if (!state) |
if (!state) |
goto invalid_option; |
goto invalid_option; |
result = parse_uint(&num, value, MAXNDOTS, "ndots"); |
num = strtonum(value, 0, MAXNDOTS, &errstr); |
if (result != ISC_R_SUCCESS) |
if (errstr != NULL) |
fatal("Couldn't parse ndots"); |
fatal("ndots is %s: '%s'", errstr, value); |
ndots = num; |
ndots = num; |
break; |
break; |
case 's': |
case 's': |
|
|
lookup->opcode = (dns_opcode_t)num; |
lookup->opcode = (dns_opcode_t)num; |
break; |
break; |
} |
} |
result = parse_uint(&num, value, 15, "opcode"); |
num = strtonum(value, 0, 15, &errstr); |
if (result != ISC_R_SUCCESS) |
if (errstr != NULL) |
fatal("Couldn't parse opcode"); |
fatal("opcode is %s: '%s'", errstr, value); |
lookup->opcode = (dns_opcode_t)num; |
lookup->opcode = (dns_opcode_t)num; |
break; |
break; |
default: |
default: |
|
|
goto need_value; |
goto need_value; |
if (!state) |
if (!state) |
goto invalid_option; |
goto invalid_option; |
result = parse_uint(&lookup->retries, value, |
lookup->retries = strtonum(value, 0, |
MAXTRIES - 1, "retries"); |
MAXTRIES - 1, &errstr); |
if (result != ISC_R_SUCCESS) |
if (errstr != NULL) |
fatal("Couldn't parse retries"); |
fatal("retries is %s: '%s'", errstr, |
|
value); |
lookup->retries++; |
lookup->retries++; |
break; |
break; |
default: |
default: |
|
|
} else if (value == NULL) |
} else if (value == NULL) |
break; |
break; |
|
|
result = parse_uint(&splitwidth, value, |
splitwidth = strtonum(value, 0, 1023, &errstr); |
1023, "split"); |
if (errstr != NULL) |
|
fatal("split is %s: '%s'", errstr, value); |
if ((splitwidth % 4) != 0U) { |
if ((splitwidth % 4) != 0U) { |
splitwidth = ((splitwidth + 3) / 4) * 4; |
splitwidth = ((splitwidth + 3) / 4) * 4; |
fprintf(stderr, ";; Warning, split must be " |
fprintf(stderr, ";; Warning, split must be " |
|
|
*/ |
*/ |
if (splitwidth) |
if (splitwidth) |
splitwidth += 3; |
splitwidth += 3; |
if (result != ISC_R_SUCCESS) |
|
fatal("Couldn't parse split"); |
|
break; |
break; |
case 't': /* stats */ |
case 't': /* stats */ |
FULLCHECK("stats"); |
FULLCHECK("stats"); |
|
|
goto need_value; |
goto need_value; |
if (!state) |
if (!state) |
goto invalid_option; |
goto invalid_option; |
result = parse_uint(&timeout, value, MAXTIMEOUT, |
timeout = strtonum(value, 0, MAXTIMEOUT, &errstr); |
"timeout"); |
if (errstr != NULL) |
if (result != ISC_R_SUCCESS) |
fatal("timeout is %s: '%s'", errstr, value); |
fatal("Couldn't parse timeout"); |
|
if (timeout == 0) |
if (timeout == 0) |
timeout = 1; |
timeout = 1; |
break; |
break; |
|
|
goto need_value; |
goto need_value; |
if (!state) |
if (!state) |
goto invalid_option; |
goto invalid_option; |
result = parse_uint(&lookup->retries, value, |
lookup->retries = strtonum(value, 0, MAXTRIES, |
MAXTRIES, "tries"); |
&errstr); |
if (result != ISC_R_SUCCESS) |
if (errstr != NULL) |
fatal("Couldn't parse tries"); |
fatal("tries is %s: '%s'", errstr, |
|
value); |
if (lookup->retries == 0) |
if (lookup->retries == 0) |
lookup->retries = 1; |
lookup->retries = 1; |
break; |
break; |
|
|
in_port_t srcport; |
in_port_t srcport; |
char *hash, *cmd; |
char *hash, *cmd; |
uint32_t num; |
uint32_t num; |
|
const char *errstr; |
|
|
while (strpbrk(option, single_dash_opts) == &option[0]) { |
while (strpbrk(option, single_dash_opts) == &option[0]) { |
/* |
/* |
|
|
case 'b': |
case 'b': |
hash = strchr(value, '#'); |
hash = strchr(value, '#'); |
if (hash != NULL) { |
if (hash != NULL) { |
result = parse_uint(&num, hash + 1, MAXPORT, |
num = strtonum(hash + 1, 0, MAXPORT, &errstr); |
"port number"); |
if (errstr != NULL) |
if (result != ISC_R_SUCCESS) |
fatal("port number is %s: '%s'", errstr, |
fatal("Couldn't parse port number"); |
hash + 1); |
srcport = num; |
srcport = num; |
*hash = '\0'; |
*hash = '\0'; |
} else |
} else |
|
|
strlcpy(keyfile, value, sizeof(keyfile)); |
strlcpy(keyfile, value, sizeof(keyfile)); |
return (value_from_next); |
return (value_from_next); |
case 'p': |
case 'p': |
result = parse_uint(&num, value, MAXPORT, "port number"); |
num = strtonum(value, 0, MAXPORT, &errstr); |
if (result != ISC_R_SUCCESS) |
if (errstr != NULL) |
fatal("Couldn't parse port number"); |
fatal("port number is %s: '%s'", errstr, value); |
port = num; |
port = num; |
return (value_from_next); |
return (value_from_next); |
case 'q': |
case 'q': |
|
|
uint32_t serial; |
uint32_t serial; |
(*lookup)->rdtype = dns_rdatatype_ixfr; |
(*lookup)->rdtype = dns_rdatatype_ixfr; |
(*lookup)->rdtypeset = ISC_TRUE; |
(*lookup)->rdtypeset = ISC_TRUE; |
result = parse_uint(&serial, &value[5], |
serial = strtonum(&value[5], 0, MAXSERIAL, |
MAXSERIAL, "serial number"); |
&errstr); |
if (result != ISC_R_SUCCESS) |
if (errstr != NULL) |
fatal("Couldn't parse serial number"); |
fatal("serial number is %s: '%s'", |
|
errstr, &value[5]); |
(*lookup)->ixfr_serial = serial; |
(*lookup)->ixfr_serial = serial; |
(*lookup)->section_question = plusquest; |
(*lookup)->section_question = plusquest; |
(*lookup)->comments = pluscomm; |
(*lookup)->comments = pluscomm; |
|
|
char *input; |
char *input; |
int i; |
int i; |
isc_boolean_t need_clone = ISC_TRUE; |
isc_boolean_t need_clone = ISC_TRUE; |
|
const char *errstr; |
|
|
/* |
/* |
* The semantics for parsing the args is a bit complex; if |
* The semantics for parsing the args is a bit complex; if |
|
|
lookup->rdtype = |
lookup->rdtype = |
dns_rdatatype_ixfr; |
dns_rdatatype_ixfr; |
lookup->rdtypeset = ISC_TRUE; |
lookup->rdtypeset = ISC_TRUE; |
result = parse_uint(&serial, |
serial = strtonum(&rv[0][5], 0, |
&rv[0][5], |
MAXSERIAL, &errstr); |
MAXSERIAL, |
if (errstr != NULL) |
"serial number"); |
fatal("serial number " |
if (result != ISC_R_SUCCESS) |
"is %s: '%s'", |
fatal("Couldn't parse " |
errstr, &rv[0][5]); |
"serial number"); |
|
lookup->ixfr_serial = serial; |
lookup->ixfr_serial = serial; |
lookup->section_question = |
lookup->section_question = |
plusquest; |
plusquest; |