Skip to content

Commit 42e1f5a

Browse files
authored
Merge pull request #39 from CopernicaMarketingSoftware/optional-recursion
the "recursion desired" bit can now be switched on and off
2 parents be1de05 + e57b102 commit 42e1f5a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

include/dnscpp/bits.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* passing such bits
88
*
99
* @author Emiel Bruijntjes <[email protected]>
10-
* @copyright 2020 Copernica BV
10+
* @copyright 2020 - 2023 Copernica BV
1111
*/
1212

1313
/**
@@ -37,6 +37,7 @@ namespace DNS {
3737
const int BIT_AD = 1;
3838
const int BIT_CD = 2;
3939
const int BIT_DO = 4;
40+
const int BIT_RD = 8;
4041

4142
/**
4243
* Class definition
@@ -59,10 +60,10 @@ class Bits
5960

6061
public:
6162
/**
62-
* Constructor
63+
* Constructor - default behavior is to enable recursion
6364
* @param value
6465
*/
65-
Bits(int value = 0) : _value(value) {}
66+
Bits(int value = BIT_RD) : _value(value) {}
6667

6768
/**
6869
* Destructor
@@ -76,6 +77,7 @@ class Bits
7677
bool AD() const { return _value & BIT_AD; }
7778
bool CD() const { return _value & BIT_CD; }
7879
bool DO() const { return _value & BIT_DO; }
80+
bool RD() const { return _value & BIT_RD; }
7981

8082
/**
8183
* Get access to the bits in long notation
@@ -84,6 +86,7 @@ class Bits
8486
bool authentic() const { return AD(); }
8587
bool checkingdisabled() const { return CD(); }
8688
bool dnssec() const { return DO(); }
89+
bool recursion() const { return RD(); }
8790

8891
/**
8992
* Setters
@@ -92,6 +95,7 @@ class Bits
9295
void AD(bool value) { value ? add(BIT_AD) : del(BIT_AD); }
9396
void CD(bool value) { value ? add(BIT_CD) : del(BIT_CD); }
9497
void DO(bool value) { value ? add(BIT_DO) : del(BIT_DO); }
98+
void RD(bool value) { value ? add(BIT_RD) : del(BIT_RD); }
9599

96100
/**
97101
* Setters, long notation
@@ -100,6 +104,7 @@ class Bits
100104
void authentic(bool value) { AD(value); }
101105
void checkingdisabled(bool value) { CD(value); }
102106
void dnssec(bool value) { DO(value); }
107+
void recursion(bool value) { RD(value); }
103108

104109
};
105110

src/query.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Implementation file for the Query class
55
*
66
* @author Emiel Bruijntjes <[email protected]>
7-
* @copyright 2020 Copernica BV
7+
* @copyright 2020 - 2023 Copernica BV
88
*/
99

1010
/**
@@ -56,8 +56,8 @@ Query::Query(int op, const char *dname, int type, const Bits &bits, const unsign
5656
// store the opcode
5757
header->opcode = op;
5858

59-
// the default behavior is to ask for recursion
60-
header->rd = 1;
59+
// bit to ask for a recursive lookup
60+
header->rd = bits.RD();
6161

6262
// bits to ask for the server to include verify info, or to avoid verification by the server
6363
header->ad = bits.AD();

0 commit comments

Comments
 (0)