Skip to content

Commit 0b7e766

Browse files
committed
Add getTKEYRecord
1 parent 8b582f6 commit 0b7e766

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

pdns/dnspacket.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,27 @@ bool DNSPacket::getTSIGDetails(TSIGRecordContent* trc, string* keyname, string*
474474
return true;
475475
}
476476

477+
bool DNSPacket::getTKEYRecord(TKEYRecordContent *tr, string *keyname) const
478+
{
479+
MOADNSParser mdp(d_rawpacket);
480+
bool gotit=false;
481+
482+
for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) {
483+
if (gotit) {
484+
L<<Logger::Error<<"More than one TKEY record found in query"<<endl;
485+
return false;
486+
}
487+
488+
if(i->first.d_type == QType::TKEY) {
489+
*tr = *boost::dynamic_pointer_cast<TKEYRecordContent>(i->first.d_content);
490+
*keyname = i->first.d_label;
491+
gotit=true;
492+
}
493+
}
494+
495+
return gotit;
496+
}
497+
477498
/** This function takes data from the network, possibly received with recvfrom, and parses
478499
it into our class. Results of calling this function multiple times on one packet are
479500
unknown. Returns -1 if the packet cannot be parsed.

pdns/dnspacket.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ public:
149149

150150
bool getTSIGDetails(TSIGRecordContent* tr, string* keyname, string* message) const;
151151
void setTSIGDetails(const TSIGRecordContent& tr, const string& keyname, const string& secret, const string& previous, bool timersonly=false);
152-
152+
bool getTKEYRecord(TKEYRecordContent* tr, string* keyname) const;
153+
153154
vector<DNSResourceRecord>& getRRS() { return d_rrs; }
154155
TSIGRecordContent d_trc;
155156
static bool s_doEDNSSubnetProcessing;

0 commit comments

Comments
 (0)