From 3c5841ace39ae37f76a25f9cbe4c2617f714e3a0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 15 Aug 2023 17:57:17 -0700 Subject: [PATCH] tst_qdnslookup: fix the location of the opcode in the header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were reading the wrong byte with the wrong shift count. 4.1.1. Header section format The header contains the following fields: 1 1 1 1 1 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ID | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |QR| Opcode |AA|TC|RD|RA| Z | RCODE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | QDCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ANCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | NSCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ARCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ This diagram is big-endian, so bit 0 is the MSB. Change-Id: I964c2b1e6b834feb9710fffd177bb72110bb77e7 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Fabian Kosmale (cherry picked from commit 19673b6cf949dce5d0cd8efa4ad6f91c9f26f06f) Reviewed-by: Thiago Macieira --- tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp index f14f6f2c0e2..3745fe35e92 100644 --- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp +++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp @@ -542,7 +542,7 @@ void tst_QDnsLookup::setNameserverLoopback() QByteArray data = dgram.data(); QCOMPARE_GT(data.size(), HeaderSize); - quint8 opcode = (quint8(data.at(3)) >> 4) & 0xF; + quint8 opcode = (quint8(data.at(2)) >> 3) & 0xF; QCOMPARE(opcode, 0); // standard query // send an NXDOMAIN reply to release the lookup thread