mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-01-05 14:29:37 -05:00
use constants for bitflags.
git-svn-id: file:///svn/unbound/trunk@214 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
b777a38e0d
commit
290f94369f
4 changed files with 19 additions and 7 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,16 @@
|
|||
#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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue