]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Reviewing and porting.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 14 Feb 2007 10:10:43 +0000 (10:10 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 14 Feb 2007 10:10:43 +0000 (10:10 +0000)
git-svn-id: file:///svn/unbound/trunk@97 be551aaa-1e26-0410-a405-d3ace91eadb9

Makefile.in
doc/Changelog
testcode/replay.c
testcode/replay.h
testcode/testbound.c
util/net_help.c
util/netevent.c

index 95718a1e573bf83318887ff5bf22c8a5895b062d..9aa890f1f2708ca9381e2821fe9ffeadb6bc00dd 100644 (file)
@@ -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) $< \
index 37983ee8b6ca6b4d9adfc44f6d8a5c1fb55f32bb..e47f22a7d65c95fa4652133cf98c5ee70e450ea1 100644 (file)
@@ -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.
index 4fe76698ded54824ab022c99bf7a0f97b1327039..216e1400f161b1d2eb6746fc48dd394ed9865424 100644 (file)
@@ -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)
index c605a8da37c9bf6547182cc71e7caa1a510ff808..51fd717173ac51d4e54f5e72f2e7817e6798ac08 100644 (file)
@@ -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.
index c700a51b55661c9b211e47b76731b6cf967d6484..0f5b9f62928506ae8ddca25311a139b3de09aa0c 100644 (file)
@@ -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);
index f5e065e9564f1902ada6d0457163cef109605645..ef2ee72acbe32d6edc4e5a121c36b1a61fc63998 100644 (file)
@@ -34,7 +34,7 @@
  */
 /**
  * \file
- * Implementation of log.h.
+ * Implementation of net_help.h.
  */
 
 #include "config.h"
index cc4f2d5f3e78e02eac43b0e313286f5918ae1d81..7002e65c2c1a38feaf02f857fbec4fb4a5d98862 100644 (file)
@@ -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),