DNS requests (using the internal resolver) are corrupted since commit
e2f84977165a ("BUG/MINOR: dns: fix DNS header definition").

Fix it by defining the struct in network byte order, while complying
with RFC 2535, section 6.1.

First reported by Eduard Vopicka on discourse.

This must be backported to 1.6 (1.6.5 is affected).
---
 include/types/dns.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/types/dns.h b/include/types/dns.h
index 98adc98..50636fd 100644
--- a/include/types/dns.h
+++ b/include/types/dns.h
@@ -63,16 +63,16 @@
 /* DNS request or response header structure */
 struct dns_header {
        unsigned short  id:16;          /* identifier */
-       unsigned char   qr :1;          /* query/response 0: query, 1: response 
*/
-       unsigned char   opcode :4;      /* operation code */
-       unsigned char   aa :1;          /* authoritative answer 0: no, 1: yes */
-       unsigned char   tc :1;          /* truncation 0:no, 1: yes */
        unsigned char   rd :1;          /* recursion desired 0: no, 1: yes */
-       unsigned char   ra :1;          /* recursion available 0: no, 1: yes */
-       unsigned char   z :1;           /* not used */
-       unsigned char   ad :1;          /* authentic data */
-       unsigned char   cd :1;          /* checking disabled */
+       unsigned char   tc :1;          /* truncation 0:no, 1: yes */
+       unsigned char   aa :1;          /* authoritative answer 0: no, 1: yes */
+       unsigned char   opcode :4;      /* operation code */
+       unsigned char   qr :1;          /* query/response 0: query, 1: response 
*/
        unsigned char   rcode :4;       /* response code */
+       unsigned char   cd :1;          /* checking disabled */
+       unsigned char   ad :1;          /* authentic data */
+       unsigned char   z :1;           /* not used */
+       unsigned char   ra :1;          /* recursion available 0: no, 1: yes */
        unsigned short  qdcount :16;    /* question count */
        unsigned short  ancount :16;    /* answer count */
        unsigned short  nscount :16;    /* authority count */
-- 
1.9.1


Reply via email to