Skip to content

DNSServer message header format #812

@gustavofbreunig

Description

@gustavofbreunig

I'm working with the DNSServer library located in https://github.com/esp8266/Arduino/blob/esp8266/hardware/esp8266com/esp8266/libraries/DNSServer/src/DNSServer.h

There is a struct called DNSHeader, It reflects the UDP DNS packet header:

struct DNSHeader
{
  uint16_t ID;               // identification number
  unsigned char RD : 1;      // recursion desired
  unsigned char TC : 1;      // truncated message
  unsigned char AA : 1;      // authoritive answer
  unsigned char OPCode : 4;  // message_type
  unsigned char QR : 1;      // query/response flag
  unsigned char RCode : 4;   // response code
  unsigned char Z : 3;       // its z! reserved
  unsigned char RA : 1;      // recursion available
  uint16_t QDCount;          // number of question entries
  uint16_t ANCount;          // number of answer entries
  uint16_t NSCount;          // number of authority entries
  uint16_t ARCount;          // number of resource entries
};

I'm looking in various places and the fields are different, every documentation says something like:

Image of DNS
source: http://www.tcpipguide.com/free/t_DNSMessageHeaderandQuestionSectionFormat.htm

I'm not a C++ expert, but looks like the struct isn't in the correct order (right after the ID, the correct is QR Flag, not the RD), but the library works great, so I'm missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions