]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add getTKEYRecord
authorAki Tuomi <cmouse@cmouse.fi>
Wed, 18 Feb 2015 19:22:57 +0000 (21:22 +0200)
committerAki Tuomi <cmouse@cmouse.fi>
Mon, 9 Mar 2015 19:43:46 +0000 (21:43 +0200)
pdns/dnspacket.cc
pdns/dnspacket.hh

index 67b6c3f4bf76a07e11c36a9892724073150e856f..c6a8e5f200b0c9b12b59f6ceccfc05100ab9bcba 100644 (file)
@@ -478,6 +478,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.
index 62405d880f96b8009200a565a338c8fcce14b3ba..84574be3dd2fdab98fb101c9b2e7a263a4e696ef 100644 (file)
@@ -148,7 +148,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;