]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
use constants for bitflags.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 3 Apr 2007 09:29:09 +0000 (09:29 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 3 Apr 2007 09:29:09 +0000 (09:29 +0000)
git-svn-id: file:///svn/unbound/trunk@214 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/worker.c
doc/Changelog
util/data/msgreply.c
util/net_help.h

index 0007e16180b0255c806b4bac61880a77dbb3f42c..431881bbf3caf3d21d8cd00d1fd171d216328d37 100644 (file)
@@ -102,8 +102,8 @@ replyerror(int r, struct work_query* w)
        
        ldns_buffer_clear(buf);
        ldns_buffer_write(buf, &w->query_id, sizeof(uint16_t));
-       flags = (uint16_t)(0x8000 | r); /* QR and retcode*/
-       flags |= (w->query_flags & 0x0100); /* copy RD bit */
+       flags = (uint16_t)(BIT_QR | r); /* QR and retcode*/
+       flags |= (w->query_flags & (BIT_RD|BIT_CD)); /* copy RD and CD bit */
        ldns_buffer_write_u16(buf, flags);
        flags = 1;
        ldns_buffer_write_u16(buf, flags);
index 72d9bfa59a9058aa5082e7a7ca65e0a7636f2cce..e562f6c08a8305fb7f5cff26d9ef37011ddc8ae7 100644 (file)
@@ -3,6 +3,7 @@
          in netevent (which is there to please lint) can be correct.
          The type on several OSes ranges from int, int32, uint32, size_t.
          Detects unsigned or signed using math trick.
+       - constants for DNS flags. 
 
 2 April 2007: Wouter
        - check sizes of udp received messages, not too short.
index 17cb1907ca3fad826205aec04ef38048242a1306..9d3974148e374f46c321e276b4048bf10b430ba2 100644 (file)
@@ -44,6 +44,7 @@
 #include "util/storage/lookup3.h"
 #include "util/log.h"
 #include "util/netevent.h"
+#include "util/net_help.h"
 
 /** determine length of a dname in buffer, no compression pointers allowed. */
 size_t
@@ -202,8 +203,8 @@ reply_info_answer(struct reply_info* rep, uint16_t qflags,
        uint16_t flags;
        ldns_buffer_clear(buffer);
        ldns_buffer_skip(buffer, 2); /* ID */
-       flags = rep->flags | (qflags & 0x0100); /* copy RD bit */
-       log_assert(flags & 0x8000); /* QR bit must be on in our replies */
+       flags = rep->flags | (qflags & BIT_RD); /* copy RD bit */
+       log_assert(flags & BIT_QR); /* QR bit must be on in our replies */
        ldns_buffer_write_u16(buffer, flags);
        ldns_buffer_write(buffer, rep->reply, rep->replysize);
        ldns_buffer_flip(buffer);
@@ -220,12 +221,12 @@ reply_info_answer_iov(struct reply_info* rep, uint16_t qid,
        iov[1].iov_len = sizeof(uint16_t);
        if(!cached) {
                /* original flags, copy RD bit from query. */
-               qflags = rep->flags | (qflags & 0x0100); 
+               qflags = rep->flags | (qflags & BIT_RD); 
        } else {
                /* remove AA bit, copy RD and CD bits from query. */
-               qflags = (rep->flags & ~0x0400) | (qflags & 0x0110); 
+               qflags = (rep->flags & ~BIT_AA) | (qflags & (BIT_RD|BIT_CD)); 
        }
-       log_assert(qflags & 0x8000); /* QR bit must be on in our replies */
+       log_assert(qflags & BIT_QR); /* QR bit must be on in our replies */
        qflags = htons(qflags);
        iov[2].iov_base = &qflags;
        iov[2].iov_len = sizeof(uint16_t);
index 6ea82ba2a259b5578996550104aedd1762f79968..f5d9c8037719cde6206bc1a2459f22a85af520e4 100644 (file)
 #ifndef NET_HELP_H
 #define NET_HELP_H
 
+/** DNS constants for uint16_t style flag manipulation. host byteorder. */
+/** AA flag */
+#define BIT_AA 0x0400
+/** RD flag */
+#define BIT_RD 0x0100
+/** CD flag */
+#define BIT_CD 0x0010
+/** QR flag */
+#define BIT_QR 0x8000
+
 /**
  * See if string is ip4 or ip6.
  * @param str: IP specification.