]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
API tweaks in response to reviews
authorOtto <otto.moerbeek@open-xchange.com>
Wed, 8 Dec 2021 12:03:39 +0000 (13:03 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Wed, 8 Dec 2021 12:03:39 +0000 (13:03 +0100)
pdns/lua-recursor4-ffi.hh
pdns/lua-recursor4.cc
regression-tests.recursor-dnssec/test_Lua.py

index 5b78b416271d97e1f171b8c47e7b98a9304792fc..95c93c0fc7a2a4088897e6de8fb70d786f301dd1 100644 (file)
@@ -59,6 +59,7 @@ extern "C"
   typedef struct pdns_ffi_record
   {
     const char* name;
+    size_t name_len;
     const char* content;
     size_t content_len;
     uint32_t ttl;
@@ -114,8 +115,10 @@ extern "C"
   typedef struct pdns_postresolve_ffi_handle pdns_postresolve_ffi_handle_t;
 
   const char* pdns_postresolve_ffi_handle_get_qname(pdns_postresolve_ffi_handle_t* ref) __attribute__((visibility("default")));
+  void pdns_postresolve_ffi_handle_get_qname_raw(pdns_postresolve_ffi_handle_t* ref, const char** qname, size_t* qnameSize) __attribute__((visibility("default")));
   uint16_t pdns_postresolve_ffi_handle_get_qtype(const pdns_postresolve_ffi_handle_t* ref) __attribute__((visibility("default")));
   uint16_t pdns_postresolve_ffi_handle_get_rcode(const pdns_postresolve_ffi_handle_t* ref) __attribute__((visibility("default")));
+  void pdns_postresolve_ffi_handle_set_rcode(const pdns_postresolve_ffi_handle_t* ref, uint16_t rcode) __attribute__((visibility("default")));
   pdns_policy_kind_t pdns_postresolve_ffi_handle_get_appliedpolicy_kind(const pdns_postresolve_ffi_handle_t* ref) __attribute__((visibility("default")));
   void pdns_postresolve_ffi_handle_set_appliedpolicy_kind(pdns_postresolve_ffi_handle_t* ref, pdns_policy_kind_t kind) __attribute__((visibility("default")));
   bool pdns_postresolve_ffi_handle_get_record(pdns_postresolve_ffi_handle_t* ref, unsigned int i, pdns_ffi_record_t* record, bool raw) __attribute__((visibility("default")));
@@ -125,3 +128,5 @@ extern "C"
   const char* pdns_postresolve_ffi_handle_get_authip(pdns_postresolve_ffi_handle_t* ref) __attribute__((visibility("default")));
   void pdns_postresolve_ffi_handle_get_authip_raw(pdns_postresolve_ffi_handle_t* ref, const void** addr, size_t* addrSize) __attribute__((visibility("default")));
 }
+
+#undef PDNS_VISIBILITY
index 95b7a45f34bf3c6c99e3db29e45b9afae08b2a24..0d1a745df80ff49eeabccc210b2709880bcaa75e 100644 (file)
@@ -1070,6 +1070,13 @@ const char* pdns_postresolve_ffi_handle_get_qname(pdns_postresolve_ffi_handle_t*
   return str->c_str();
 }
 
+void pdns_postresolve_ffi_handle_get_qname_raw(pdns_postresolve_ffi_handle_t* ref, const char** qname, size_t* qnameSize)
+{
+  const auto& storage = ref->handle.d_dq.qname.getStorage();
+  *qname = storage.data();
+  *qnameSize = storage.size();
+}
+
 uint16_t pdns_postresolve_ffi_handle_get_qtype(const pdns_postresolve_ffi_handle_t* ref)
 {
   return ref->handle.d_dq.qtype;
@@ -1080,6 +1087,11 @@ uint16_t pdns_postresolve_ffi_handle_get_rcode(const pdns_postresolve_ffi_handle
   return ref->handle.d_dq.rcode;
 }
 
+void pdns_postresolve_ffi_handle_set_rcode(const pdns_postresolve_ffi_handle_t* ref, uint16_t rcode)
+{
+  ref->handle.d_dq.rcode = rcode;
+}
+
 pdns_policy_kind_t pdns_postresolve_ffi_handle_get_appliedpolicy_kind(const pdns_postresolve_ffi_handle_t* ref)
 {
   return static_cast<pdns_policy_kind_t>(ref->handle.d_dq.appliedPolicy->d_kind);
@@ -1097,7 +1109,15 @@ bool pdns_postresolve_ffi_handle_get_record(pdns_postresolve_ffi_handle_t* ref,
   }
   try {
     DNSRecord& r = ref->handle.d_dq.currentRecords->at(i);
-    record->name = ref->insert(r.d_name.toStringNoDot())->c_str();
+    if (raw) {
+      const auto& storage = r.d_name.getStorage();
+      record->name = storage.data();
+      record->name_len = storage.size();
+    } else {
+      std::string name = r.d_name.toStringNoDot();
+      record->name_len = name.size();
+      record->name = ref->insert(std::move(name))->c_str();
+    }
     if (raw) {
       auto content = ref->insert(r.d_content->serialize(r.d_name, true));
       record->content = content->data();
index efbae0d958d6c27e7182a7b6ee7982c0a5301ccd..13081f051bd00c110ddb7890a085606d32a5eb2b 100644 (file)
@@ -795,16 +795,19 @@ ffi.cdef[[
 
   typedef struct pdns_ffi_record {
     const char* name;
+    size_t name_len;
     const char* content;
-    const size_t content_len;
+    size_t content_len;
     uint32_t ttl;
     pdns_record_place_t place;
     uint16_t type;
   } pdns_ffi_record_t;
 
   const char* pdns_postresolve_ffi_handle_get_qname(pdns_postresolve_ffi_handle_t* ref);
+  const char* pdns_postresolve_ffi_handle_get_qname_raw(pdns_postresolve_ffi_handle_t* ref, const char** name, size_t* len);
   uint16_t pdns_postresolve_ffi_handle_get_qtype(const pdns_postresolve_ffi_handle_t* ref);
   uint16_t pdns_postresolve_ffi_handle_get_rcode(const pdns_postresolve_ffi_handle_t* ref);
+  void pdns_postresolve_ffi_handle_set_rcode(const pdns_postresolve_ffi_handle_t* ref, uint16_t rcode);
   void pdns_postresolve_ffi_handle_set_appliedpolicy_kind(pdns_postresolve_ffi_handle_t* ref, pdns_policy_kind_t kind);
   bool pdns_postresolve_ffi_handle_get_record(pdns_postresolve_ffi_handle_t* ref, unsigned int i, pdns_ffi_record_t *record, bool raw);
   bool pdns_postresolve_ffi_handle_set_record(pdns_postresolve_ffi_handle_t* ref, unsigned int i, const char* content, size_t contentLen, bool raw);