summaryrefslogtreecommitdiffstats
path: root/contrib/bind9/lib/export/samples
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind9/lib/export/samples')
-rw-r--r--contrib/bind9/lib/export/samples/Makefile.in5
-rw-r--r--contrib/bind9/lib/export/samples/nsprobe.c28
-rw-r--r--contrib/bind9/lib/export/samples/sample-async.c4
-rw-r--r--contrib/bind9/lib/export/samples/sample-gai.c6
-rw-r--r--contrib/bind9/lib/export/samples/sample-request.c12
-rw-r--r--contrib/bind9/lib/export/samples/sample-update.c6
-rw-r--r--contrib/bind9/lib/export/samples/sample.c24
7 files changed, 46 insertions, 39 deletions
diff --git a/contrib/bind9/lib/export/samples/Makefile.in b/contrib/bind9/lib/export/samples/Makefile.in
index cdc66b1..194aaeb 100644
--- a/contrib/bind9/lib/export/samples/Makefile.in
+++ b/contrib/bind9/lib/export/samples/Makefile.in
@@ -1,4 +1,4 @@
-# Copyright (C) 2009, 2012 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2009, 2012, 2013 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -25,7 +25,8 @@ export_srcdir = @top_srcdir@/lib/export
CINCLUDES = -I${srcdir}/include -I../dns/include \
-I${export_srcdir}/isc/include \
${DNS_INCLUDES} ${ISC_INCLUDES} \
- -I${top_srcdir}/lib/irs/include
+ -I${top_srcdir}/lib/irs/include \
+ -I../../irs/include
CDEFINES =
CWARNINGS =
diff --git a/contrib/bind9/lib/export/samples/nsprobe.c b/contrib/bind9/lib/export/samples/nsprobe.c
index 869b194..1d7ed3b 100644
--- a/contrib/bind9/lib/export/samples/nsprobe.c
+++ b/contrib/bind9/lib/export/samples/nsprobe.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2012 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2009-2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -282,8 +282,6 @@ make_querymessage(dns_message_t *message, dns_name_t *qname0,
dns_message_puttempname(message, &qname);
if (qrdataset != NULL)
dns_message_puttemprdataset(message, &qrdataset);
- if (message != NULL)
- dns_message_destroy(&message);
return (result);
}
@@ -293,7 +291,7 @@ make_querymessage(dns_message_t *message, dns_name_t *qname0,
static inline void
increment_entry(unsigned long *entryp) {
(*entryp)++;
- INSIST(*entryp != 0); /* check overflow */
+ INSIST(*entryp != 0U); /* check overflow */
}
static void
@@ -392,57 +390,57 @@ update_stat(struct probe_trans *trans) {
}
/* Update per domain statistics */
- if (local_stat.ignore > 0) {
+ if (local_stat.ignore > 0U) {
if (verbose_level > 0)
printf("%s:ignore\n", trans->domain);
increment_entry(&domain_stat.ignore);
err_count++;
}
- if (local_stat.nxdomain > 0) {
+ if (local_stat.nxdomain > 0U) {
if (verbose_level > 0)
printf("%s:nxdomain\n", trans->domain);
increment_entry(&domain_stat.nxdomain);
err_count++;
}
- if (local_stat.othererr > 0) {
+ if (local_stat.othererr > 0U) {
if (verbose_level > 0)
printf("%s:othererr\n", trans->domain);
increment_entry(&domain_stat.othererr);
err_count++;
}
- if (local_stat.multiplesoa > 0) {
+ if (local_stat.multiplesoa > 0U) {
if (verbose_level > 0)
printf("%s:multiplesoa\n", trans->domain);
increment_entry(&domain_stat.multiplesoa);
err_count++;
}
- if (local_stat.multiplecname > 0) {
+ if (local_stat.multiplecname > 0U) {
if (verbose_level > 0)
printf("%s:multiplecname\n", trans->domain);
increment_entry(&domain_stat.multiplecname);
err_count++;
}
- if (local_stat.brokenanswer > 0) {
+ if (local_stat.brokenanswer > 0U) {
if (verbose_level > 0)
printf("%s:brokenanswer\n", trans->domain);
increment_entry(&domain_stat.brokenanswer);
err_count++;
}
- if (local_stat.lame > 0) {
+ if (local_stat.lame > 0U) {
if (verbose_level > 0)
printf("%s:lame\n", trans->domain);
increment_entry(&domain_stat.lame);
err_count++;
}
- if (err_count > 1)
+ if (err_count > 1U)
increment_entry(&multiple_error_domains);
/*
* We regard the domain as valid if and only if no authoritative server
* has a problem and at least one server is known to be valid.
*/
- if (local_stat.valid > 0 && err_count == 0) {
+ if (local_stat.valid > 0U && err_count == 0U) {
if (verbose_level > 1)
printf("%s:valid\n", trans->domain);
increment_entry(&domain_stat.valid);
@@ -452,7 +450,7 @@ update_stat(struct probe_trans *trans) {
* If the domain has no available server or all servers have the
* 'unknown' result, the domain's result is also regarded as unknown.
*/
- if (local_stat.valid == 0 && err_count == 0) {
+ if (local_stat.valid == 0U && err_count == 0U) {
if (verbose_level > 1)
printf("%s:unknown\n", trans->domain);
increment_entry(&domain_stat.unknown);
@@ -1218,5 +1216,5 @@ main(int argc, char *argv[]) {
isc_app_ctxfinish(actx);
ctxs_destroy(&mctx, &actx, &taskmgr, &socketmgr, &timermgr);
- exit(0);
+ return (0);
}
diff --git a/contrib/bind9/lib/export/samples/sample-async.c b/contrib/bind9/lib/export/samples/sample-async.c
index e646e79..a70dd47 100644
--- a/contrib/bind9/lib/export/samples/sample-async.c
+++ b/contrib/bind9/lib/export/samples/sample-async.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2009, 2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -398,5 +398,5 @@ main(int argc, char *argv[]) {
isc_app_ctxfinish(query_actx);
ctxs_destroy(&mctx, &query_actx, &taskmgr, &socketmgr, &timermgr);
- exit(0);
+ return (0);
}
diff --git a/contrib/bind9/lib/export/samples/sample-gai.c b/contrib/bind9/lib/export/samples/sample-gai.c
index 6dc4014..243d07a 100644
--- a/contrib/bind9/lib/export/samples/sample-gai.c
+++ b/contrib/bind9/lib/export/samples/sample-gai.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2009, 2012, 2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -61,7 +61,7 @@ do_gai(int family, char *hostname) {
}
}
- freeaddrinfo(res);
+ freeaddrinfo(res0);
}
int
@@ -73,5 +73,5 @@ main(int argc, char *argv[]) {
do_gai(AF_INET6, argv[1]);
do_gai(AF_UNSPEC, argv[1]);
- exit(0);
+ return (0);
}
diff --git a/contrib/bind9/lib/export/samples/sample-request.c b/contrib/bind9/lib/export/samples/sample-request.c
index d5d2312..07baf39 100644
--- a/contrib/bind9/lib/export/samples/sample-request.c
+++ b/contrib/bind9/lib/export/samples/sample-request.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2009, 2012, 2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -77,9 +77,12 @@ make_querymessage(dns_message_t *message, const char *namestr,
isc_buffer_t b;
size_t namelen;
+ REQUIRE(message != NULL);
+ REQUIRE(namestr != NULL);
+
/* Construct qname */
namelen = strlen(namestr);
- isc_buffer_init(&b, namestr, namelen);
+ isc_buffer_constinit(&b, namestr, namelen);
isc_buffer_add(&b, namelen);
dns_fixedname_init(&fixedqname);
qname0 = dns_fixedname_name(&fixedqname);
@@ -115,8 +118,7 @@ make_querymessage(dns_message_t *message, const char *namestr,
dns_message_puttempname(message, &qname);
if (qrdataset != NULL)
dns_message_puttemprdataset(message, &qrdataset);
- if (message != NULL)
- dns_message_destroy(&message);
+ dns_message_destroy(&message);
return (result);
}
@@ -259,5 +261,5 @@ main(int argc, char *argv[]) {
dns_client_destroy(&client);
dns_lib_shutdown();
- exit(0);
+ return (0);
}
diff --git a/contrib/bind9/lib/export/samples/sample-update.c b/contrib/bind9/lib/export/samples/sample-update.c
index e54d154..2c35baa 100644
--- a/contrib/bind9/lib/export/samples/sample-update.c
+++ b/contrib/bind9/lib/export/samples/sample-update.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2010 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2009, 2010, 2012, 2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -305,7 +305,7 @@ main(int argc, char *argv[]) {
dns_client_destroy(&client);
dns_lib_shutdown();
- exit(0);
+ return (0);
}
/*
@@ -372,7 +372,7 @@ parse_name(char **cmdlinep, dns_name_t *name) {
isc_buffer_t source;
word = nsu_strsep(cmdlinep, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not read owner name\n");
exit(1);
}
diff --git a/contrib/bind9/lib/export/samples/sample.c b/contrib/bind9/lib/export/samples/sample.c
index 7fc6a30..b121a0d 100644
--- a/contrib/bind9/lib/export/samples/sample.c
+++ b/contrib/bind9/lib/export/samples/sample.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2009, 2012, 2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -172,7 +172,9 @@ set_key(dns_client_t *client, char *keynamestr, char *keystr,
}
static void
-addserver(dns_client_t *client, const char *addrstr, const char *namespace) {
+addserver(dns_client_t *client, const char *addrstr, const char *port,
+ const char *namespace)
+{
struct addrinfo hints, *res;
int gai_error;
isc_sockaddr_t sa;
@@ -188,7 +190,7 @@ addserver(dns_client_t *client, const char *addrstr, const char *namespace) {
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
hints.ai_flags = AI_NUMERICHOST;
- gai_error = getaddrinfo(addrstr, "53", &hints, &res);
+ gai_error = getaddrinfo(addrstr, port, &hints, &res);
if (gai_error != 0) {
fprintf(stderr, "getaddrinfo failed: %s\n",
gai_strerror(gai_error));
@@ -196,15 +198,15 @@ addserver(dns_client_t *client, const char *addrstr, const char *namespace) {
}
INSIST(res->ai_addrlen <= sizeof(sa.type));
memcpy(&sa.type, res->ai_addr, res->ai_addrlen);
- freeaddrinfo(res);
sa.length = res->ai_addrlen;
+ freeaddrinfo(res);
ISC_LINK_INIT(&sa, link);
ISC_LIST_INIT(servers);
ISC_LIST_APPEND(servers, &sa, link);
if (namespace != NULL) {
namelen = strlen(namespace);
- isc_buffer_init(&b, namespace, namelen);
+ isc_buffer_constinit(&b, namespace, namelen);
isc_buffer_add(&b, namelen);
dns_fixedname_init(&fname);
name = dns_fixedname_name(&fname);
@@ -245,8 +247,9 @@ main(int argc, char *argv[]) {
isc_mem_t *keymctx = NULL;
unsigned int clientopt, resopt;
isc_boolean_t is_sep = ISC_FALSE;
+ const char *port = "53";
- while ((ch = getopt(argc, argv, "a:es:t:k:K:")) != -1) {
+ while ((ch = getopt(argc, argv, "a:es:t:k:K:p:")) != -1) {
switch (ch) {
case 't':
tr.base = optarg;
@@ -279,6 +282,9 @@ main(int argc, char *argv[]) {
case 'K':
keystr = optarg;
break;
+ case 'p':
+ port = optarg;
+ break;
default:
usage();
}
@@ -318,11 +324,11 @@ main(int argc, char *argv[]) {
}
/* Set the nameserver */
- addserver(client, argv[0], NULL);
+ addserver(client, argv[0], port, NULL);
/* Set the alternate nameserver (when specified) */
if (altserver != NULL)
- addserver(client, altserveraddr, altservername);
+ addserver(client, altserveraddr, port, altservername);
/* Install DNSSEC key (if given) */
if (keynamestr != NULL) {
@@ -374,5 +380,5 @@ main(int argc, char *argv[]) {
isc_mem_destroy(&keymctx);
dns_lib_shutdown();
- exit(0);
+ return (0);
}
OpenPOWER on IntegriCloud