diff options
Diffstat (limited to 'testcode')
-rw-r--r-- | testcode/fake_event.c | 8 | ||||
-rw-r--r-- | testcode/petal.c | 48 | ||||
-rw-r--r-- | testcode/replay.c | 10 | ||||
-rw-r--r-- | testcode/replay.h | 2 | ||||
-rw-r--r-- | testcode/streamtcp.1 | 66 | ||||
-rw-r--r-- | testcode/streamtcp.c | 2 | ||||
-rw-r--r-- | testcode/unitmain.c | 4 | ||||
-rw-r--r-- | testcode/unitmsgparse.c | 4 | ||||
-rw-r--r-- | testcode/unitneg.c | 2 | ||||
-rw-r--r-- | testcode/unitverify.c | 4 |
10 files changed, 116 insertions, 34 deletions
diff --git a/testcode/fake_event.c b/testcode/fake_event.c index 180ff30697e2..085068c67c56 100644 --- a/testcode/fake_event.c +++ b/testcode/fake_event.c @@ -478,7 +478,7 @@ time_passes(struct replay_runtime* runtime, struct replay_moment* mom) #endif } timeval_add(&runtime->now_tv, &tv); - runtime->now_secs = (uint32_t)runtime->now_tv.tv_sec; + runtime->now_secs = (time_t)runtime->now_tv.tv_sec; #ifndef S_SPLINT_S log_info("elapsed %d.%6.6d now %d.%6.6d", (int)tv.tv_sec, (int)tv.tv_usec, @@ -801,7 +801,7 @@ comm_base_delete(struct comm_base* b) } void -comm_base_timept(struct comm_base* b, uint32_t** tt, struct timeval** tv) +comm_base_timept(struct comm_base* b, time_t** tt, struct timeval** tv) { struct replay_runtime* runtime = (struct replay_runtime*)b; *tt = &runtime->now_secs; @@ -909,8 +909,10 @@ outside_network_create(struct comm_base* base, size_t bufsize, runtime->infra = infra; outnet->base = base; outnet->udp_buff = ldns_buffer_new(bufsize); - if(!outnet->udp_buff) + if(!outnet->udp_buff) { + free(outnet); return NULL; + } return outnet; } diff --git a/testcode/petal.c b/testcode/petal.c index 14a187e3ff26..61f8250d89ec 100644 --- a/testcode/petal.c +++ b/testcode/petal.c @@ -349,13 +349,14 @@ provide_file_10(SSL* ssl, char* fname) "rb" #endif ); - int r; + size_t r; const char* rcode = "200 OK"; if(!in) { char hdr[1024]; rcode = "404 File not found"; - r = snprintf(hdr, sizeof(hdr), "HTTP/1.1 %s\r\n\r\n", rcode); - if(SSL_write(ssl, hdr, r) <= 0) { + snprintf(hdr, sizeof(hdr), "HTTP/1.1 %s\r\n\r\n", rcode); + r = strlen(hdr); + if(SSL_write(ssl, hdr, (int)r) <= 0) { /* write failure */ } return; @@ -371,16 +372,20 @@ provide_file_10(SSL* ssl, char* fname) } avail = len+header_reserve; at = buf; - r = snprintf(at, avail, "HTTP/1.1 %s\r\n", rcode); + snprintf(at, avail, "HTTP/1.1 %s\r\n", rcode); + r = strlen(at); at += r; avail -= r; - r = snprintf(at, avail, "Server: petal/%s\r\n", PACKAGE_VERSION); + snprintf(at, avail, "Server: petal/%s\r\n", PACKAGE_VERSION); + r = strlen(at); at += r; avail -= r; - r = snprintf(at, avail, "Content-Length: %u\r\n", (unsigned)len); + snprintf(at, avail, "Content-Length: %u\r\n", (unsigned)len); + r = strlen(at); at += r; avail -= r; - r = snprintf(at, avail, "\r\n"); + snprintf(at, avail, "\r\n"); + r = strlen(at); at += r; avail -= r; if(avail < len) { /* robust */ @@ -409,7 +414,7 @@ provide_file_chunked(SSL* ssl, char* fname) char buf[16384]; char* at = buf; size_t avail = sizeof(buf); - int r; + size_t r; FILE* in = fopen(fname, #ifndef USE_WINSOCK "r" @@ -423,19 +428,24 @@ provide_file_chunked(SSL* ssl, char* fname) } /* print headers */ - r = snprintf(at, avail, "HTTP/1.1 %s\r\n", rcode); + snprintf(at, avail, "HTTP/1.1 %s\r\n", rcode); + r = strlen(at); at += r; avail -= r; - r = snprintf(at, avail, "Server: petal/%s\r\n", PACKAGE_VERSION); + snprintf(at, avail, "Server: petal/%s\r\n", PACKAGE_VERSION); + r = strlen(at); at += r; avail -= r; - r = snprintf(at, avail, "Transfer-Encoding: chunked\r\n"); + snprintf(at, avail, "Transfer-Encoding: chunked\r\n"); + r = strlen(at); at += r; avail -= r; - r = snprintf(at, avail, "Connection: close\r\n"); + snprintf(at, avail, "Connection: close\r\n"); + r = strlen(at); at += r; avail -= r; - r = snprintf(at, avail, "\r\n"); + snprintf(at, avail, "\r\n"); + r = strlen(at); at += r; avail -= r; if(avail < 16) { /* robust */ @@ -448,7 +458,8 @@ provide_file_chunked(SSL* ssl, char* fname) /* read chunk; space-16 for xxxxCRLF..CRLF0CRLFCRLF (3 spare)*/ size_t red = in?fread(tmpbuf, 1, avail-16, in):0; /* prepare chunk */ - r = snprintf(at, avail, "%x\r\n", (unsigned)red); + snprintf(at, avail, "%x\r\n", (unsigned)red); + r = strlen(at); if(verb >= 3) {printf("chunk len %x\n", (unsigned)red); fflush(stdout);} at += r; @@ -458,17 +469,20 @@ provide_file_chunked(SSL* ssl, char* fname) memmove(at, tmpbuf, red); at += red; avail -= red; - r = snprintf(at, avail, "\r\n"); + snprintf(at, avail, "\r\n"); + r = strlen(at); at += r; avail -= r; } if(in && feof(in) && red != 0) { - r = snprintf(at, avail, "0\r\n"); + snprintf(at, avail, "0\r\n"); + r = strlen(at); at += r; avail -= r; } if(!in || feof(in)) { - r = snprintf(at, avail, "\r\n"); + snprintf(at, avail, "\r\n"); + r = strlen(at); at += r; avail -= r; } diff --git a/testcode/replay.c b/testcode/replay.c index 2ce647da1197..ce050ed0ad15 100644 --- a/testcode/replay.c +++ b/testcode/replay.c @@ -792,15 +792,15 @@ macro_expand(rbtree_t* store, struct replay_runtime* runtime, char** text) /* check for functions */ if(strcmp(buf, "time") == 0) { - snprintf(buf, sizeof(buf), "%u", (unsigned)runtime->now_secs); + snprintf(buf, sizeof(buf), "%lld", (long long)runtime->now_secs); *text += len; return strdup(buf); } else if(strcmp(buf, "timeout") == 0) { - uint32_t res = 0; + time_t res = 0; struct fake_timer* t = first_timer(runtime); - if(t && (uint32_t)t->tv.tv_sec >= runtime->now_secs) - res = (uint32_t)t->tv.tv_sec - runtime->now_secs; - snprintf(buf, sizeof(buf), "%u", (unsigned)res); + if(t && (time_t)t->tv.tv_sec >= runtime->now_secs) + res = (time_t)t->tv.tv_sec - runtime->now_secs; + snprintf(buf, sizeof(buf), "%lld", (long long)res); *text += len; return strdup(buf); } else if(strncmp(buf, "ctime ", 6) == 0 || diff --git a/testcode/replay.h b/testcode/replay.h index 049db4e800b5..beac3ce839d2 100644 --- a/testcode/replay.h +++ b/testcode/replay.h @@ -293,7 +293,7 @@ struct replay_runtime { struct infra_cache* infra; /** the current time in seconds */ - uint32_t now_secs; + time_t now_secs; /** the current time in microseconds */ struct timeval now_tv; diff --git a/testcode/streamtcp.1 b/testcode/streamtcp.1 new file mode 100644 index 000000000000..7c738d9d278c --- /dev/null +++ b/testcode/streamtcp.1 @@ -0,0 +1,66 @@ +.TH "unbound\-streamtcp" "1" "Mar 21, 2013" "NLnet Labs" "unbound" +.\" +.\" unbound-streamtcp.1 -- unbound DNS lookup utility +.\" +.SH "NAME" +.LP +.B unbound\-streamtcp +\- unbound DNS lookup utility +.SH "SYNOPSIS" +.LP +.B unbound\-streamtcp +.RB [ \-unsh ] +.RB [ \-f +.IR ipaddr[@port] ] +.I name +.I type +.I class +.SH "DESCRIPTION" +.LP +.B unbound\-streamtcp +sends a DNS Query of the given \fBtype\fR and \fBclass\fR for the given \fBname\fR +to the DNS server over TCP and displays the response. +.P +If the server to query is not given using the \fB\-f\fR option then localhost +(127.0.0.1) is used. More queries can be given on one commandline, they +are resolved in sequence. +.P +The available options are: +.TP +.I name +This name is resolved (looked up in the DNS). +.TP +.I type +Specify the type of data to lookup. +.TP +.I class +Specify the class to lookup for. +.TP +.B \-u +Use UDP instead of TCP. No retries are attempted. +.TP +.B \-n +Do not wait for the answer. +.TP +.B \-s +Use SSL. +.TP +.B \-h +Print program usage. +.TP +.B \-f \fIipaddr[@port] +Specify the server to send the queries to. If not specified localhost (127.0.0.1) is used. +.SH "EXAMPLES" +.LP +Some examples of use. +.P +$ unbound\-streamtcp www.example.com A IN +.P +$ unbound\-streamtcp \-f 192.168.1.1 www.example.com SOA IN +.P +$ unbound\-streamtcp \-f 192.168.1.1@1234 153.1.168.192.in\-addr.arpa. PTR IN +.SH "EXIT CODE" +The unbound\-streamtcp program exits with status code 1 on error, +0 on no error. +.SH "AUTHOR" +This manual page was written by Tomas Hozza <thozza@redhat.com>. diff --git a/testcode/streamtcp.c b/testcode/streamtcp.c index dbdf1408c1d5..06a18e4cfafb 100644 --- a/testcode/streamtcp.c +++ b/testcode/streamtcp.c @@ -121,9 +121,9 @@ write_q(int fd, int udp, SSL* ssl, ldns_buffer* buf, uint16_t id, exit(1); } qinfo.qname = memdup(ldns_rdf_data(rdf), ldns_rdf_size(rdf)); + if(!qinfo.qname) fatal_exit("out of memory"); (void)dname_count_size_labels(qinfo.qname, &qinfo.qname_len); ldns_rdf_deep_free(rdf); - if(!qinfo.qname) fatal_exit("out of memory"); /* qtype and qclass */ qinfo.qtype = ldns_get_rr_type_by_name(strtype); diff --git a/testcode/unitmain.c b/testcode/unitmain.c index 122f09b86149..be4bed95eeb2 100644 --- a/testcode/unitmain.c +++ b/testcode/unitmain.c @@ -411,7 +411,7 @@ rtt_test(void) /* lookup and get key and data structs easily */ static struct infra_data* infra_lookup_host(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* zone, - size_t zonelen, int wr, uint32_t now, struct infra_key** k) + size_t zonelen, int wr, time_t now, struct infra_key** k) { struct infra_data* d; struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen, @@ -436,7 +436,7 @@ infra_test(void) size_t zonelen = 13; struct infra_cache* slab; struct config_file* cfg = config_create(); - uint32_t now = 0; + time_t now = 0; uint8_t edns_lame; int vs, to; struct infra_key* k; diff --git a/testcode/unitmsgparse.c b/testcode/unitmsgparse.c index 434239507b47..72f9b63a6e09 100644 --- a/testcode/unitmsgparse.c +++ b/testcode/unitmsgparse.c @@ -258,7 +258,7 @@ checkformerr(ldns_buffer* pkt) /** performance test message encoding */ static void perf_encode(struct query_info* qi, struct reply_info* rep, uint16_t id, - uint16_t flags, ldns_buffer* out, uint32_t timenow, + uint16_t flags, ldns_buffer* out, time_t timenow, struct edns_data* edns) { static int num = 0; @@ -299,7 +299,7 @@ perftestpkt(ldns_buffer* pkt, struct alloc_cache* alloc, ldns_buffer* out, int ret; uint16_t id; uint16_t flags; - uint32_t timenow = 0; + time_t timenow = 0; struct regional* region = regional_create(); struct edns_data edns; diff --git a/testcode/unitneg.c b/testcode/unitneg.c index e18aefc34b67..686ad0086362 100644 --- a/testcode/unitneg.c +++ b/testcode/unitneg.c @@ -195,7 +195,7 @@ static void add_item(struct val_neg_cache* neg) struct packed_rrset_data rd; struct ub_packed_rrset_key nsec; size_t rr_len; - uint32_t rr_ttl; + time_t rr_ttl; uint8_t* rr_data; char* zname = get_random_zone(); char* from, *to; diff --git a/testcode/unitverify.c b/testcode/unitverify.c index d3fbf25f5312..d2d268dfdf2d 100644 --- a/testcode/unitverify.c +++ b/testcode/unitverify.c @@ -301,7 +301,7 @@ verifytest_file(const char* fname, const char* at_date) struct entry* list = read_datafile(fname, 1); struct module_env env; struct val_env ve; - uint32_t now = time(NULL); + time_t now = time(NULL); if(!list) fatal_exit("could not read %s: %s", fname, strerror(errno)); @@ -422,7 +422,7 @@ nsec3_hash_test_entry(struct entry* e, rbtree_t* ct, struct query_info qinfo; struct reply_info* rep = NULL; struct ub_packed_rrset_key* answer, *nsec3; - struct nsec3_cached_hash* hash; + struct nsec3_cached_hash* hash = NULL; int ret; uint8_t* qname; |