/* \summary: Domain Name System (DNS) printer */
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
#include <string.h>
blabel_print(netdissect_options *ndo,
const u_char *cp)
{
- int bitlen, slen, b;
+ u_int bitlen, slen, b;
const u_char *bitp, *lim;
- char tc;
+ uint8_t tc;
if (!ND_TTEST_1(cp))
return(NULL);
bitp++;
ND_PRINT("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b)));
}
- ND_PRINT("/%d]", bitlen);
+ ND_PRINT("/%u]", bitlen);
return lim;
trunc:
- ND_PRINT(".../%d]", bitlen);
+ ND_PRINT(".../%u]", bitlen);
return NULL;
}
return(-1);
i = EXTRACT_U_1(cp);
if ((i & INDIR_MASK) == EDNS0_MASK) {
- int bitlen, elt;
+ u_int bitlen, elt;
if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) {
ND_PRINT("<ELT %d>", elt);
return(-1);
u_int i, l;
const u_char *rp = NULL;
int compress = 0;
- int elt;
+ u_int elt;
u_int offset, max_offset;
if ((l = labellen(ndo, cp)) == (u_int)-1)
break;
default:
/* unknown ELT */
- ND_PRINT("<ELT %d>", elt);
+ ND_PRINT("<ELT %u>", elt);
return(NULL);
}
} else {
- if (fn_printn(ndo, cp, l, ndo->ndo_snapend))
+ if (nd_printn(ndo, cp, l, ndo->ndo_snapend))
return(NULL);
}
return (NULL);
i = EXTRACT_U_1(cp);
cp++;
- if (fn_printn(ndo, cp, i, ndo->ndo_snapend))
+ if (nd_printn(ndo, cp, i, ndo->ndo_snapend))
return (NULL);
return (cp + i);
}
/* print the qtype */
i = EXTRACT_BE_U_2(cp);
cp += 2;
- ND_PRINT(" %s", tok2str(ns_type2str, "Type%d", i));
+ ND_PRINT(" %s", tok2str(ns_type2str, "Type%u", i));
/* print the qclass (if it's not IN) */
i = EXTRACT_BE_U_2(cp);
cp += 2;
else
class = i;
if (class != C_IN)
- ND_PRINT(" %s", tok2str(ns_class2str, "(Class %d)", class));
+ ND_PRINT(" %s", tok2str(ns_class2str, "(Class %u)", class));
if (is_mdns) {
ND_PRINT(i & C_QU ? " (QU)" : " (QM)");
}
else
class = i;
if (class != C_IN && typ != T_OPT)
- ND_PRINT(" %s", tok2str(ns_class2str, "(Class %d)", class));
+ ND_PRINT(" %s", tok2str(ns_class2str, "(Class %u)", class));
if (is_mdns) {
if (i & C_CACHE_FLUSH)
ND_PRINT(" (Cache flush)");
rp = cp + len;
- ND_PRINT(" %s", tok2str(ns_type2str, "Type%d", typ));
+ ND_PRINT(" %s", tok2str(ns_type2str, "Type%u", typ));
if (rp > ndo->ndo_snapend)
return(NULL);
switch (typ) {
case T_A:
- if (!ND_TTEST_LEN(cp, sizeof(struct in_addr)))
+ if (!ND_TTEST_LEN(cp, sizeof(nd_ipv4)))
return(NULL);
- ND_PRINT(" %s", intoa(htonl(EXTRACT_BE_U_4(cp))));
+ ND_PRINT(" %s", intoa(EXTRACT_IPV4_TO_NETWORK_ORDER(cp)));
break;
case T_NS:
return(NULL);
if (ns_nprint(ndo, cp + 2, bp) == NULL)
return(NULL);
- ND_PRINT(" %d", EXTRACT_BE_U_2(cp));
+ ND_PRINT(" %u", EXTRACT_BE_U_2(cp));
break;
case T_TXT:
return(NULL);
if (ns_nprint(ndo, cp + 6, bp) == NULL)
return(NULL);
- ND_PRINT(":%d %d %d", EXTRACT_BE_U_2(cp + 4),
+ ND_PRINT(":%u %u %u", EXTRACT_BE_U_2(cp + 4),
EXTRACT_BE_U_2(cp), EXTRACT_BE_U_2(cp + 2));
break;
{
char ntop_buf[INET6_ADDRSTRLEN];
- if (!ND_TTEST_LEN(cp, sizeof(struct in6_addr)))
+ if (!ND_TTEST_LEN(cp, sizeof(nd_ipv6)))
return(NULL);
ND_PRINT(" %s",
addrtostr6(cp, ntop_buf, sizeof(ntop_buf)));
case T_UNSPECA: /* One long string */
if (!ND_TTEST_LEN(cp, len))
return(NULL);
- if (fn_printn(ndo, cp, len, ndo->ndo_snapend))
+ if (nd_printn(ndo, cp, len, ndo->ndo_snapend))
return(NULL);
break;
const u_char *cp;
uint16_t b2;
+ ndo->ndo_protocol = "domain";
np = (const dns_header_t *)bp;
ND_TCHECK_SIZE(np);
flags = EXTRACT_BE_U_2(np->flags);
if (DNS_QR(flags)) {
/* this is a response */
- ND_PRINT("%d%s%s%s%s%s%s",
+ ND_PRINT("%u%s%s%s%s%s%s",
EXTRACT_BE_U_2(np->id),
ns_ops[DNS_OPCODE(flags)],
ns_resp[DNS_RCODE(flags)],
}
else {
/* this is a request */
- ND_PRINT("%d%s%s%s", EXTRACT_BE_U_2(np->id), ns_ops[DNS_OPCODE(flags)],
+ ND_PRINT("%u%s%s%s", EXTRACT_BE_U_2(np->id), ns_ops[DNS_OPCODE(flags)],
DNS_RD(flags) ? "+" : "",
DNS_CD(flags) ? "%" : "");
goto trunc;
}
}
- ND_PRINT(" (%d)", length);
+ ND_PRINT(" (%u)", length);
return;
trunc:
- ND_PRINT("[|domain]");
+ nd_print_trunc(ndo);
}