From 18407772d86818c2fe98649510ffc16acef96ccc Mon Sep 17 00:00:00 2001
From: Libor Peltan <libor.peltan@nic.cz>
Date: Fri, 7 Apr 2017 18:12:55 +0200
Subject: [PATCH] kdig: checking QR bit on response

---
 src/utils/kdig/kdig_exec.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/utils/kdig/kdig_exec.c b/src/utils/kdig/kdig_exec.c
index 422c31b903..a0252b57b0 100644
--- a/src/utils/kdig/kdig_exec.c
+++ b/src/utils/kdig/kdig_exec.c
@@ -450,6 +450,13 @@ static bool check_reply_id(const knot_pkt_t *reply,
 	return true;
 }
 
+static void check_reply_qr(const knot_pkt_t *reply)
+{
+	if (!knot_wire_get_qr(reply->wire)) {
+		WARN("response QR bit not set\n");
+	}
+}
+
 static void check_reply_question(const knot_pkt_t *reply,
                                  const knot_pkt_t *query)
 {
@@ -648,6 +655,9 @@ static int process_query_packet(const knot_pkt_t      *query,
 	// Check for question sections equality.
 	check_reply_question(reply, query);
 
+	// Check QR bit
+	check_reply_qr(reply);
+
 	// Print reply packet.
 	print_packet(reply, net, in_len, time_diff_ms(&t_query, &t_end), 0,
 	             true, style);
@@ -884,6 +894,8 @@ static int process_xfr_packet(const knot_pkt_t      *query,
 			return 0;
 		}
 
+		check_reply_qr(reply);
+
 		// The first message has a special treatment.
 		if (msg_count == 0) {
 			// Verify 1. signature if a key was specified.
-- 
GitLab