Permalink
Browse files

Add getTKEYRecord

  • Loading branch information...
1 parent 8b582f6 commit 0b7e766dfca385b83ba19c34a1747c19d44dff8b @cmouse cmouse committed with cmouse Feb 18, 2015
Showing with 23 additions and 1 deletion.
  1. +21 −0 pdns/dnspacket.cc
  2. +2 −1 pdns/dnspacket.hh
View
@@ -474,6 +474,27 @@ bool DNSPacket::getTSIGDetails(TSIGRecordContent* trc, string* keyname, string*
return true;
}
+bool DNSPacket::getTKEYRecord(TKEYRecordContent *tr, string *keyname) const
+{
+ MOADNSParser mdp(d_rawpacket);
+ bool gotit=false;
+
+ for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) {
+ if (gotit) {
+ L<<Logger::Error<<"More than one TKEY record found in query"<<endl;
+ return false;
+ }
+
+ if(i->first.d_type == QType::TKEY) {
+ *tr = *boost::dynamic_pointer_cast<TKEYRecordContent>(i->first.d_content);
+ *keyname = i->first.d_label;
+ gotit=true;
+ }
+ }
+
+ return gotit;
+}
+
/** This function takes data from the network, possibly received with recvfrom, and parses
it into our class. Results of calling this function multiple times on one packet are
unknown. Returns -1 if the packet cannot be parsed.
View
@@ -149,7 +149,8 @@ public:
bool getTSIGDetails(TSIGRecordContent* tr, string* keyname, string* message) const;
void setTSIGDetails(const TSIGRecordContent& tr, const string& keyname, const string& secret, const string& previous, bool timersonly=false);
-
+ bool getTKEYRecord(TKEYRecordContent* tr, string* keyname) const;
+
vector<DNSResourceRecord>& getRRS() { return d_rrs; }
TSIGRecordContent d_trc;
static bool s_doEDNSSubnetProcessing;

0 comments on commit 0b7e766

Please sign in to comment.