mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
Reviewing and porting.
git-svn-id: file:///svn/unbound/trunk@97 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
91049947a0
commit
c5fec5aa08
7 changed files with 33 additions and 21 deletions
|
|
@ -112,7 +112,7 @@ ifdef doxygen
|
|||
endif
|
||||
|
||||
# Automatic dependencies.
|
||||
$(BUILD)%.d: $(srcdir)/%.c
|
||||
$(BUILD)%.d: $(srcdir)/%.c testcode/ldns-testpkts.c
|
||||
$(INFO) Depend $<
|
||||
@if test ! -d $(dir $@); then $(INSTALL) -d $(patsubst %/,%,$(dir $@)); fi
|
||||
$Q$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< \
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@
|
|||
- Included configure.ac changes from ldns.
|
||||
- detect (some) headers before the standards check.
|
||||
- do not use isblank to test c99, since its not available on solaris9.
|
||||
- review of testcode.
|
||||
* entries in a RANGE are no longer reversed.
|
||||
* print name of file with replay entry parse errors.
|
||||
- port to OSX: cast to int for some prints of sizet.
|
||||
- Makefile copies ldnstestpkts.c before doing dependencies on it.
|
||||
|
||||
13 February 2007: Wouter
|
||||
- work on fake events, first fwd replay works.
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@
|
|||
* @param keyword: string.
|
||||
* @return: true if found, false if not.
|
||||
*/
|
||||
static int parse_keyword(char** line, char* keyword)
|
||||
static int
|
||||
parse_keyword(char** line, char* keyword)
|
||||
{
|
||||
size_t len = (size_t)strlen(keyword);
|
||||
if(strncmp(*line, keyword, len) == 0) {
|
||||
|
|
@ -88,6 +89,7 @@ replay_range_delete(struct replay_range* rng)
|
|||
* Read a range from file.
|
||||
* @param remain: Rest of line (after RANGE keyword).
|
||||
* @param in: file to read from.
|
||||
* @param name: name to print in errors.
|
||||
* @param lineno: incremented as lines are read.
|
||||
* @param line: line buffer.
|
||||
* @param ttl: for readentry
|
||||
|
|
@ -96,14 +98,14 @@ replay_range_delete(struct replay_range* rng)
|
|||
* @return: range object to add to list, or NULL on error.
|
||||
*/
|
||||
static struct replay_range*
|
||||
replay_range_read(char* remain, FILE* in, int* lineno, char* line,
|
||||
uint16_t* ttl, ldns_rdf** or, ldns_rdf** prev)
|
||||
replay_range_read(char* remain, FILE* in, const char* name, int* lineno,
|
||||
char* line, uint16_t* ttl, ldns_rdf** or, ldns_rdf** prev)
|
||||
{
|
||||
struct replay_range* rng = (struct replay_range*)malloc(
|
||||
sizeof(struct replay_range));
|
||||
off_t pos;
|
||||
char *parse;
|
||||
struct entry* entry;
|
||||
struct entry* entry, *last = NULL;
|
||||
if(!rng)
|
||||
return NULL;
|
||||
memset(rng, 0, sizeof(*rng));
|
||||
|
|
@ -128,11 +130,14 @@ replay_range_read(char* remain, FILE* in, int* lineno, char* line,
|
|||
/* set position before line; read entry */
|
||||
(*lineno)--;
|
||||
fseeko(in, pos, SEEK_SET);
|
||||
entry = read_entry(in, "datafile", lineno, ttl, or, prev);
|
||||
entry = read_entry(in, name, lineno, ttl, or, prev);
|
||||
if(!entry)
|
||||
fatal_exit("%d: bad entry", *lineno);
|
||||
entry->next = rng->match;
|
||||
rng->match = entry;
|
||||
entry->next = NULL;
|
||||
if(last)
|
||||
last->next = entry;
|
||||
else rng->match = entry;
|
||||
last = entry;
|
||||
|
||||
pos = ftello(in);
|
||||
}
|
||||
|
|
@ -144,6 +149,7 @@ replay_range_read(char* remain, FILE* in, int* lineno, char* line,
|
|||
* Read a replay moment 'STEP' from file.
|
||||
* @param remain: Rest of line (after STEP keyword).
|
||||
* @param in: file to read from.
|
||||
* @param name: name to print in errors.
|
||||
* @param lineno: incremented as lines are read.
|
||||
* @param ttl: for readentry
|
||||
* @param or: for readentry
|
||||
|
|
@ -151,7 +157,7 @@ replay_range_read(char* remain, FILE* in, int* lineno, char* line,
|
|||
* @return: range object to add to list, or NULL on error.
|
||||
*/
|
||||
static struct replay_moment*
|
||||
replay_moment_read(char* remain, FILE* in, int* lineno,
|
||||
replay_moment_read(char* remain, FILE* in, const char* name, int* lineno,
|
||||
uint16_t* ttl, ldns_rdf** or, ldns_rdf** prev)
|
||||
{
|
||||
struct replay_moment* mom = (struct replay_moment*)malloc(
|
||||
|
|
@ -162,7 +168,7 @@ replay_moment_read(char* remain, FILE* in, int* lineno,
|
|||
return NULL;
|
||||
memset(mom, 0, sizeof(*mom));
|
||||
if(sscanf(remain, " %d%n", &mom->time_step, &skip) != 1) {
|
||||
log_err("%d: cannot read value: %s", *lineno, remain);
|
||||
log_err("%d: cannot read number: %s", *lineno, remain);
|
||||
free(mom);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -194,7 +200,7 @@ replay_moment_read(char* remain, FILE* in, int* lineno,
|
|||
}
|
||||
|
||||
if(readentry) {
|
||||
mom->match = read_entry(in, "datafile", lineno, ttl, or, prev);
|
||||
mom->match = read_entry(in, name, lineno, ttl, or, prev);
|
||||
if(!mom->match) {
|
||||
free(mom);
|
||||
return NULL;
|
||||
|
|
@ -228,7 +234,7 @@ make_scenario(char* line)
|
|||
}
|
||||
|
||||
struct replay_scenario*
|
||||
replay_scenario_read(FILE* in)
|
||||
replay_scenario_read(FILE* in, const char* name)
|
||||
{
|
||||
char line[MAX_LINE_LEN];
|
||||
char *parse;
|
||||
|
|
@ -257,15 +263,15 @@ replay_scenario_read(FILE* in)
|
|||
if(!scen)
|
||||
fatal_exit("%d: expected SCENARIO", lineno);
|
||||
if(parse_keyword(&parse, "RANGE_BEGIN")) {
|
||||
struct replay_range* newr = replay_range_read(
|
||||
parse, in, &lineno, line, &ttl, &or, &prev);
|
||||
struct replay_range* newr = replay_range_read(parse,
|
||||
in, name, &lineno, line, &ttl, &or, &prev);
|
||||
if(!newr)
|
||||
fatal_exit("%d: bad range", lineno);
|
||||
newr->next_range = scen->range_list;
|
||||
scen->range_list = newr;
|
||||
} else if(parse_keyword(&parse, "STEP")) {
|
||||
struct replay_moment* mom = replay_moment_read(
|
||||
parse, in, &lineno, &ttl, &or, &prev);
|
||||
struct replay_moment* mom = replay_moment_read(parse,
|
||||
in, name, &lineno, &ttl, &or, &prev);
|
||||
if(!mom)
|
||||
fatal_exit("%d: bad moment", lineno);
|
||||
if(scen->mom_last)
|
||||
|
|
|
|||
|
|
@ -262,9 +262,10 @@ struct replay_answer {
|
|||
/**
|
||||
* Read a replay scenario from the file.
|
||||
* @param in: file to read from.
|
||||
* @param name: name to print in errors.
|
||||
* @return: Scenario. NULL if no scenario read.
|
||||
*/
|
||||
struct replay_scenario* replay_scenario_read(FILE* in);
|
||||
struct replay_scenario* replay_scenario_read(FILE* in, const char* name);
|
||||
|
||||
/**
|
||||
* Delete scenario.
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ setup_playback(const char* filename)
|
|||
perror(filename);
|
||||
exit(1);
|
||||
}
|
||||
scen = replay_scenario_read(in);
|
||||
scen = replay_scenario_read(in, filename);
|
||||
fclose(in);
|
||||
if(!scen)
|
||||
fatal_exit("Could not read: %s", filename);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
/**
|
||||
* \file
|
||||
* Implementation of log.h.
|
||||
* Implementation of net_help.h.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ comm_point_send_udp_msg(struct comm_point *c, ldns_buffer* packet,
|
|||
return 0;
|
||||
} else if((size_t)sent != ldns_buffer_remaining(packet)) {
|
||||
log_err("sent %d in place of %d bytes",
|
||||
sent, (int)ldns_buffer_remaining(packet));
|
||||
(int)sent, (int)ldns_buffer_remaining(packet));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
|
@ -383,7 +383,7 @@ comm_point_tcp_handle_read(int fd, struct comm_point* c)
|
|||
return 0;
|
||||
}
|
||||
log_info("Reading tcp query of length %d",
|
||||
ldns_buffer_limit(c->buffer));
|
||||
(int)ldns_buffer_limit(c->buffer));
|
||||
}
|
||||
|
||||
r = read(fd, ldns_buffer_current(c->buffer),
|
||||
|
|
|
|||
Loading…
Reference in a new issue