aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/shibari_log_answer.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-12-10 11:48:01 +0000
committerLaurent Bercot <ska@appnovation.com>2023-12-10 11:48:01 +0000
commitb8d0f83e6cea9640a7ee4402c163ad812237355d (patch)
tree57a64ac8aa0e98c40db8c36e96e7379490e44dbf /src/common/shibari_log_answer.c
downloadshibari-b8d0f83e6cea9640a7ee4402c163ad812237355d.tar.gz
Initial commit
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/common/shibari_log_answer.c')
-rw-r--r--src/common/shibari_log_answer.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/common/shibari_log_answer.c b/src/common/shibari_log_answer.c
new file mode 100644
index 0000000..f34cee5
--- /dev/null
+++ b/src/common/shibari_log_answer.c
@@ -0,0 +1,36 @@
+/* ISC license. */
+
+#include <skalibs/uint16.h>
+#include <skalibs/strerr.h>
+
+#include <s6-dns/s6dns-message.h>
+
+#include <shibari/util.h>
+#include <shibari/log.h>
+
+void shibari_log_answer (uint32_t v, s6dns_message_header_t const *hdr, uint16_t len)
+{
+ if (v < 2) return ;
+ if (hdr->rcode)
+ {
+ char fmtr[UINT16_FMT] ;
+ fmtr[uint16_fmt(fmtr, hdr->rcode)] = 0 ;
+ strerr_warni4x("answer ", fmtr, " ", shibari_util_rcode_str(hdr->rcode)) ;
+ }
+ else
+ {
+ size_t pos = 0 ;
+ char fmt[UINT16_FMT << 2] ;
+ char fmtl[UINT16_FMT] ;
+ pos += uint16_fmt(fmt + pos, hdr->counts.qd) ;
+ fmt[pos++] = '+' ;
+ pos += uint16_fmt(fmt + pos, hdr->counts.an) ;
+ fmt[pos++] = '+' ;
+ pos += uint16_fmt(fmt + pos, hdr->counts.ns) ;
+ fmt[pos++] = '+' ;
+ pos += uint16_fmt(fmt + pos, hdr->counts.qd) ;
+ fmt[pos] = 0 ;
+ fmtl[uint16_fmt(fmtl, len)] = 0 ;
+ strerr_warni5x("answer 0 noerror ", fmt, " len ", fmtl, hdr->tc ? " tc" : "") ;
+ }
+}