From: Chris Hofstaedtler Date: Fri, 2 Oct 2020 10:35:43 +0000 (+0200) Subject: Support serving APL records pointing to fe80:: on macOS X-Git-Tag: auth-4.4.0-alpha2~53^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f5afee4dc7a850e3fc080db46866cd08d0bb5191;p=thirdparty%2Fpdns.git Support serving APL records pointing to fe80:: on macOS --- diff --git a/pdns/iputils.hh b/pdns/iputils.hh index 1283921d7f..06ce5f2c5e 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -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 diff --git a/pdns/test-dnsrecords_cc.cc b/pdns/test-dnsrecords_cc.cc index 6124395685..06fa638490 100644 --- a/pdns/test-dnsrecords_cc.cc +++ b/pdns/test-dnsrecords_cc.cc @@ -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"))