tst_qdnslookup: fix the location of the opcode in the header

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 <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
bb10
Thiago Macieira 2023-08-15 17:57:17 -07:00
parent fd96e11bb1
commit 19673b6cf9
1 changed files with 1 additions and 1 deletions

View File

@ -545,7 +545,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