+3774. [func] When using "request-nsid", log the NSID value in
+ printable form as well as hex. [RT #20864]
+
3773. [func] "host", "nslookup" and "nsupdate" now have
options to print the version number and exit.
[RT #26057]
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id$ */
-
/*! \file */
#include <config.h>
+#include <ctype.h>
#include <isc/log.h>
#include <isc/platform.h>
static const char hex[17] = "0123456789abcdef";
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
isc_uint16_t buflen, i;
- unsigned char *p, *buf, *nsid;
+ unsigned char *p, *buf, *pbuf, *nsid;
/* Allocate buffer for storing hex version of the NSID */
buflen = (isc_uint16_t)nsid_len * 2 + 1;
buf = isc_mem_get(mctx, buflen);
if (buf == NULL)
return;
+ pbuf = isc_mem_get(mctx, nsid_len);
+ if (pbuf == NULL)
+ goto cleanup;
/* Convert to hex */
p = buf;
nsid = isc_buffer_current(opt);
for (i = 0; i < nsid_len; i++) {
- *p++ = hex[(nsid[0] >> 4) & 0xf];
- *p++ = hex[nsid[0] & 0xf];
- nsid++;
+ *p++ = hex[(nsid[i] >> 4) & 0xf];
+ *p++ = hex[nsid[i] & 0xf];
+ }
+ *p = '\0';
+
+ /* Make printable version */
+ p = pbuf;
+ for (i = 0; i < nsid_len; i++) {
+ if (isprint(nsid[i]))
+ *p++ = nsid[i];
+ else
+ *p++ = '.';
}
*p = '\0';
sizeof(addrbuf));
isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_RESOLVER, level,
- "received NSID '%s' from %s", buf, addrbuf);
-
- /* Clean up */
+ "received NSID %s (\"%s\") from %s", buf, pbuf, addrbuf);
+ cleanup:
isc_mem_put(mctx, buf, buflen);
- return;
}
static isc_boolean_t