summaryrefslogtreecommitdiffstats
path: root/contrib/bind9/lib/export/samples/sample.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind9/lib/export/samples/sample.c')
-rw-r--r--contrib/bind9/lib/export/samples/sample.c24
1 files changed, 15 insertions, 9 deletions
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