Skip to content

Commit

Permalink
Fix AAAA DNS record type in log messages
Browse files Browse the repository at this point in the history
Was printing "PTR" instead of "AAAA" in some instances.
  • Loading branch information
tedjp committed May 3, 2012
1 parent 2a12012 commit 0601c74
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions dnsdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ desc_lookup(const struct desc *desc, uint16_t value)
return descbuf;
}

const char *
dns_type_str(uint16_t type)
{
return desc_lookup(rrtype_desc, type);
}

void
dumphex(const void *buf, size_t len)
{
Expand Down
2 changes: 2 additions & 0 deletions dnsdebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ void dumphex(const void *buf, size_t len);
void dumprr(const struct dns_rr *rr, const char *name);
/* Prints content of an DNS message (advances message pointer) */
void dumpmsg(struct dns_msg *msg);
/* Returns a human-readable DNS record type string. */
const char *dns_type_str(uint16_t type);

extern int dumpdebug;

Expand Down
12 changes: 5 additions & 7 deletions dnsupdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,10 +1426,8 @@ main(int argc, char **argv)
}

if (verbose > 1)
fprintf(stderr, "starting attempt to register %s %s\n",
utype == DNS_TYPE_A ? "A" :
utype == DNS_TYPE_AAAA ? "AAAA" :
"PTR", name);
fprintf(stderr, "starting attempt to register %s %s\n",
dns_type_str(utype), name);

/*
* Step 2: Figure out which nameserver to update against
Expand Down Expand Up @@ -1555,7 +1553,7 @@ main(int argc, char **argv)
fprintf(stderr, "attempting %s update %s %s\n",
secure ? "secure" : "unsecure",
name,
utype == DNS_TYPE_A ? "A" : "PTR");
dns_type_str(utype));

if (secure) {
ret = gss_update(vas_ctx, local_id, s, server, name,
Expand All @@ -1576,7 +1574,7 @@ main(int argc, char **argv)
security_level == SECURITY_ONLY_UNSECURE || secure))
fprintf(stderr, "%s %s update %s: %s\n", server,
secure ? "secure" : "unsecure",
utype == DNS_TYPE_A ? "A" : "PTR",
dns_type_str(utype),
dns_rcode_name(ret));
}
dnstcp_close(&s);
Expand All @@ -1588,7 +1586,7 @@ main(int argc, char **argv)
if (verbose)
fprintf(stderr, "update of %s %s %s\n",
name,
utype == DNS_TYPE_A ? "A" : "PTR",
dns_type_str(utype),
(ret == 0) ? "succeeded" : "failed");
list_free(ns_list);
}
Expand Down

0 comments on commit 0601c74

Please sign in to comment.