]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Factor out the code to compute the EDNS Error code
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 9 May 2025 10:29:40 +0000 (12:29 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 4 Sep 2025 09:05:16 +0000 (11:05 +0200)
pdns/dnsrecords.hh
pdns/recursordist/lwres.cc

index da1c8cb8d7d3e71257346675fd8201bcef213b33..4dc32d6aad90f096d049d302db6576dff0ad87da 100644 (file)
@@ -1301,6 +1301,10 @@ struct EDNSOpts
   uint8_t d_extRCode, d_version;
 
   [[nodiscard]] vector<pair<uint16_t, string>>::const_iterator getFirstOption(uint16_t optionCode) const;
+  [[nodiscard]] uint16_t getCombinedERCode(uint8_t rcode) const
+  {
+    return (static_cast<uint16_t>(d_extRCode) << 4) | rcode;
+  }
 };
 //! Convenience function that fills out EDNS0 options, and returns true if there are any
 
index 6903ddc00b35851bef207b30f943efa6181acf03..234c865773e2ef2663014f9d649892e331bae53c 100644 (file)
@@ -497,7 +497,7 @@ static std::pair<bool, LWResult::Result> incomingCookie(const OptLog& log, const
         }
         found->setSupport(CookieEntry::Support::Supported, now.tv_sec);
         // check extended error code
-        uint16_t ercode = (edo.d_extRCode << 4) | lwr.d_rcode;
+        uint16_t ercode = edo.getCombinedERCode(lwr.d_rcode);
         if (ercode == ERCode::BADCOOKIE) {
           lwr.d_validpacket = true;
           ++t_Counters.at(rec::Counter::cookieRetry);