Menu

DNS client response flag byte order

spiras
2023-08-01
2023-08-03
  • spiras

    spiras - 2023-08-01

    Hello, I'm creating this topic after another post about a DNS problem, https://sourceforge.net/p/fnet/discussion/920346/thread/0748178cb3/#ad76

    Now I'm seeing a different problem: all messages rejected by the client in fnet_dns.c
    function _fnet_dns_poll , case FNET_DNS_STATE_RX:
    when checking the "is response" flag in header->flags, the received message contains a correct response value (bytes 0x81 and 0x00 equal to 0x8100) but the machine evaluates the value as 0x0081 so the check always fails.
    This started recently as we received many complains by customers about the device failing to resolve urls;
    very strange, since we have been using this code for years without any problem.
    Anyway, adding fnet_htons to the evaluation of header->flags fixes the problem. I am puzzled; any idea?
    Thanks and greetings

     
  • Andrej Butok

    Andrej Butok - 2023-08-02

    Hi,

    Agree, this is the bug.
    But do not add fnet_htons().
    The right code should be (fnet_stack\service\dns\fnet_dns.c, line 421):

    && ((header->flags & FNET_HTONS(FNET_DNS_HEADER_FLAGS_QR)) == FNET_HTONS(FNET_DNS_HEADER_FLAGS_QR)) /* Is response.*/

    Please confirm, that it works for you.

    Thank you,
    Andrej Butok

     
  • spiras

    spiras - 2023-08-03

    Yes, it works for me.
    Thank you

     

Log in to post a comment.