]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Support serving APL records pointing to fe80:: on macOS 9580/head
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Fri, 2 Oct 2020 10:35:43 +0000 (12:35 +0200)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Fri, 2 Oct 2020 10:35:43 +0000 (12:35 +0200)
pdns/iputils.hh
pdns/test-dnsrecords_cc.cc

index 1283921d7f6e8eb34f0e1dfb8d1dd859cb1744f6..06ce5f2c5e1920eadff2be6bf0b0ba1b5fafc12a 100644 (file)
@@ -274,6 +274,18 @@ union ComboAddress {
       return "invalid "+string(gai_strerror(retval));
   }
 
+  //! Ignores any interface specifiers possibly available in the sockaddr data.
+  string toStringNoInterface() const
+  {
+    char host[1024];
+    if(sin4.sin_family == AF_INET && (nullptr != inet_ntop(sin4.sin_family, &sin4.sin_addr, host, sizeof(host))))
+      return string(host);
+    else if(sin4.sin_family == AF_INET6 && (nullptr != inet_ntop(sin4.sin_family, &sin6.sin6_addr, host, sizeof(host))))
+      return string(host);
+    else
+      return "invalid "+stringerror();
+  }
+
   string toStringWithPort() const
   {
     if(sin4.sin_family==AF_INET)
@@ -539,12 +551,12 @@ public:
 
   string toString() const
   {
-    return d_network.toString()+"/"+std::to_string((unsigned int)d_bits);
+    return d_network.toStringNoInterface()+"/"+std::to_string((unsigned int)d_bits);
   }
 
   string toStringNoMask() const
   {
-    return d_network.toString();
+    return d_network.toStringNoInterface();
   }
 
   const ComboAddress& getNetwork() const
index 61243956859f132b708c7fc2c2f9d709c25cc395..06fa638490fdcd9bfeca2f566e1c36334edf4101 100644 (file)
@@ -143,11 +143,13 @@ BOOST_AUTO_TEST_CASE(test_record_types) {
      (CASE_S(QType::APL,"2:20::/16", "\x00\x02\x10\x02\x00\x20"))
      (CASE_S(QType::APL,"2:2000::/8", "\x00\x02\x08\x01\x20"))
      (CASE_S(QType::APL,"2:fe00::/8", "\x00\x02\x08\x01\xfe"))
+     (CASE_S(QType::APL,"2:fe80::/16", "\x00\x02\x10\x02\xfe\x80"))
      (CASE_S(QType::APL,"2:2001:db8::/32", "\x00\x02\x20\x04\x20\x01\x0d\xb8"))
      (CASE_S(QType::APL,"2:2001:db8::/30", "\x00\x02\x1e\x04\x20\x01\x0d\xb8"))
      (CASE_S(QType::APL,"2:2001::1/128", "\x00\x02\x80\x10\x20\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"))
      (CASE_S(QType::APL,"!2:2001::1/128", "\x00\x02\x80\x90\x20\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"))
      (CASE_S(QType::APL,"2:2001:db8:5678:9910:8bc:3359:b2e8:720e/128", "\x00\x02\x80\x10\x20\x01\x0d\xb8\x56\x78\x99\x10\x08\xbc\x33\x59\xb2\xe8\x72\x0e"))
+     (CASE_S(QType::APL,"2:fe80:1234:5678:9910:8bc:3359:b2e8:720e/128", "\x00\x02\x80\x10\xfe\x80\x12\x34\x56\x78\x99\x10\x08\xbc\x33\x59\xb2\xe8\x72\x0e"))
      (CASE_S(QType::APL,"2:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128","\x00\x02\x80\x10\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"))
      (CASE_S(QType::APL,"", ""))
      (CASE_S(QType::APL,"1:10.0.0.0/32 1:10.1.1.1/32", "\x00\x01\x20\x01\x0a\x00\x01\x20\x04\x0a\x01\x01\x01"))