]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
global: Normalize isIpv6 to isIPv6
authorAki Tuomi <cmouse@cmouse.fi>
Sun, 20 Oct 2019 10:07:48 +0000 (13:07 +0300)
committerAki Tuomi <cmouse@cmouse.fi>
Wed, 27 Nov 2019 10:39:20 +0000 (12:39 +0200)
modules/geoipbackend/geoipbackend.cc
pdns/iputils.hh
pdns/lua-base4.cc
pdns/syncres.cc
pdns/test-iputils_hh.cc

index b56d16f5d9279827e9b013beecef1d4632dd4de0..d3f7d900f6c3eca5de2d5c1e9ac7fcba31ac244c 100644 (file)
@@ -193,9 +193,9 @@ void GeoIPBackend::initialize() {
           } else {
             Netmask nm{net->first.as<string>()};
             nmt.insert(nm).second.swap(value);
-            if (nm.isIpv6() == true && netmask6 < nm.getBits())
+            if (nm.isIPv6() == true && netmask6 < nm.getBits())
               netmask6 = nm.getBits();
-            if (nm.isIpv6() == false && netmask4 < nm.getBits())
+            if (nm.isIPv6() == false && netmask4 < nm.getBits())
               netmask4 = nm.getBits();
           }
         }
@@ -321,7 +321,7 @@ bool GeoIPBackend::lookup_static(const GeoIPDomain &dom, const DNSName &search,
       if (qtype != QType::ANY && rr.qtype != qtype) continue;
 
       if (rr.has_weight) {
-        gl.netmask = (addr.isIpv6()?128:32);
+        gl.netmask = (addr.isIPv6()?128:32);
         int comp = cumul_probabilities[rr.qtype.getCode()];
         cumul_probabilities[rr.qtype.getCode()] += rr.weight;
         if (rr.weight == 0 || probability_rnd < comp || probability_rnd > (comp + rr.weight))
@@ -389,13 +389,13 @@ void GeoIPBackend::lookup(const QType &qtype, const DNSName& qdomain, int zoneId
     tmp_gl.netmask = 0;
     // get netmask from geoip backend
     if (queryGeoIP(addr, GeoIPInterface::Name, tmp_gl) == "unknown") {
-      if (addr.isIpv6())
+      if (addr.isIPv6())
         gl.netmask = target->second.netmask6;
       else
         gl.netmask = target->second.netmask4;
     }
   } else {
-    if (addr.isIpv6())
+    if (addr.isIPv6())
       gl.netmask = target->second.netmask6;
     else
       gl.netmask = target->second.netmask4;
@@ -452,37 +452,37 @@ static string queryGeoIP(const Netmask& addr, GeoIPInterface::GeoIPQueryAttribut
 
     switch(attribute) {
     case GeoIPInterface::ASn:
-      if (addr.isIpv6()) found = gi->queryASnumV6(val, gl, ip);
+      if (addr.isIPv6()) found = gi->queryASnumV6(val, gl, ip);
       else found =gi->queryASnum(val, gl, ip);
       break;
     case GeoIPInterface::Name:
-      if (addr.isIpv6()) found = gi->queryNameV6(val, gl, ip);
+      if (addr.isIPv6()) found = gi->queryNameV6(val, gl, ip);
       else found = gi->queryName(val, gl, ip);
       break;
     case GeoIPInterface::Continent:
-      if (addr.isIpv6()) found = gi->queryContinentV6(val, gl, ip);
+      if (addr.isIPv6()) found = gi->queryContinentV6(val, gl, ip);
       else found = gi->queryContinent(val, gl, ip);
       break;
     case GeoIPInterface::Region:
-      if (addr.isIpv6()) found = gi->queryRegionV6(val, gl, ip);
+      if (addr.isIPv6()) found = gi->queryRegionV6(val, gl, ip);
       else found = gi->queryRegion(val, gl, ip);
       break;
     case GeoIPInterface::Country:
-      if (addr.isIpv6()) found = gi->queryCountryV6(val, gl, ip);
+      if (addr.isIPv6()) found = gi->queryCountryV6(val, gl, ip);
       else found = gi->queryCountry(val, gl, ip);
       break;
     case GeoIPInterface::Country2:
-      if (addr.isIpv6()) found = gi->queryCountry2V6(val, gl, ip);
+      if (addr.isIPv6()) found = gi->queryCountry2V6(val, gl, ip);
       else found = gi->queryCountry2(val, gl, ip);
       break;
     case GeoIPInterface::City:
-      if (addr.isIpv6()) found = gi->queryCityV6(val, gl, ip);
+      if (addr.isIPv6()) found = gi->queryCityV6(val, gl, ip);
       else found = gi->queryCity(val, gl, ip);
       break;
     case GeoIPInterface::Location:
       double lat=0, lon=0;
       boost::optional<int> alt, prec;
-      if (addr.isIpv6()) found = gi->queryLocationV6(gl, ip, lat, lon, alt, prec);
+      if (addr.isIPv6()) found = gi->queryLocationV6(gl, ip, lat, lon, alt, prec);
       else found = gi->queryLocation(gl, ip, lat, lon, alt, prec);
       val = std::to_string(lat)+" "+std::to_string(lon);
       break;
@@ -494,7 +494,7 @@ static string queryGeoIP(const Netmask& addr, GeoIPInterface::GeoIPQueryAttribut
     break;
   }
 
-  if (ret == "unknown") gl.netmask = (addr.isIpv6()?128:32); // prevent caching
+  if (ret == "unknown") gl.netmask = (addr.isIPv6()?128:32); // prevent caching
   return ret;
 }
 
@@ -524,7 +524,7 @@ bool queryGeoLocation(const Netmask& addr, GeoIPNetmask& gl, double& lat, double
 {
   for(auto const& gi: s_geoip_files) {
     string val;
-    if (addr.isIpv6()) {
+    if (addr.isIPv6()) {
       if (gi->queryLocationV6(gl, addr.toStringNoMask(), lat, lon, alt, prec))
         return true;
      } else if (gi->queryLocation(gl, addr.toStringNoMask(), lat, lon, alt, prec))
@@ -554,7 +554,7 @@ string GeoIPBackend::format2str(string sformat, const Netmask& addr, GeoIPNetmas
     } else if (!sformat.compare(cur,3,"%cc")) {
       rep = queryGeoIP(addr, GeoIPInterface::Country2, tmp_gl);
     } else if (!sformat.compare(cur,3,"%af")) {
-      rep = (addr.isIpv6()?"v6":"v4");
+      rep = (addr.isIPv6()?"v6":"v4");
     } else if (!sformat.compare(cur,3,"%as")) {
       rep = queryGeoIP(addr, GeoIPInterface::ASn, tmp_gl);
     } else if (!sformat.compare(cur,3,"%re")) {
@@ -607,44 +607,44 @@ string GeoIPBackend::format2str(string sformat, const Netmask& addr, GeoIPNetmas
       nrep = 4;
     } else if (!sformat.compare(cur,3,"%hh")) {
       rep = boost::str(boost::format("%02d") % gtm.tm_hour);
-      tmp_gl.netmask = (addr.isIpv6()?128:32);
+      tmp_gl.netmask = (addr.isIPv6()?128:32);
     } else if (!sformat.compare(cur,3,"%yy")) {
       rep = boost::str(boost::format("%02d") % (gtm.tm_year + 1900));
-      tmp_gl.netmask = (addr.isIpv6()?128:32);
+      tmp_gl.netmask = (addr.isIPv6()?128:32);
     } else if (!sformat.compare(cur,3,"%dd")) {
       rep = boost::str(boost::format("%02d") % (gtm.tm_yday + 1));
-      tmp_gl.netmask = (addr.isIpv6()?128:32);
+      tmp_gl.netmask = (addr.isIPv6()?128:32);
     } else if (!sformat.compare(cur,4,"%wds")) {
       nrep=4;
       rep = GeoIP_WEEKDAYS[gtm.tm_wday];
-      tmp_gl.netmask = (addr.isIpv6()?128:32);
+      tmp_gl.netmask = (addr.isIPv6()?128:32);
     } else if (!sformat.compare(cur,4,"%mos")) {
       nrep=4;
       rep = GeoIP_MONTHS[gtm.tm_mon];
-      tmp_gl.netmask = (addr.isIpv6()?128:32);
+      tmp_gl.netmask = (addr.isIPv6()?128:32);
     } else if (!sformat.compare(cur,3,"%wd")) {
       rep = boost::str(boost::format("%02d") % (gtm.tm_wday + 1));
-      tmp_gl.netmask = (addr.isIpv6()?128:32);
+      tmp_gl.netmask = (addr.isIPv6()?128:32);
     } else if (!sformat.compare(cur,3,"%mo")) {
       rep = boost::str(boost::format("%02d") % (gtm.tm_mon + 1));
-      tmp_gl.netmask = (addr.isIpv6()?128:32);
+      tmp_gl.netmask = (addr.isIPv6()?128:32);
     } else if (!sformat.compare(cur,4,"%ip6")) {
       nrep = 4;
-      if (addr.isIpv6())
+      if (addr.isIPv6())
         rep = addr.toStringNoMask();
       else
         rep = "";
-      tmp_gl.netmask = (addr.isIpv6()?128:32);
+      tmp_gl.netmask = (addr.isIPv6()?128:32);
     } else if (!sformat.compare(cur,4,"%ip4")) {
       nrep = 4;
-      if (!addr.isIpv6())
+      if (!addr.isIPv6())
         rep = addr.toStringNoMask();
       else
         rep = "";
-      tmp_gl.netmask = (addr.isIpv6()?128:32);
+      tmp_gl.netmask = (addr.isIPv6()?128:32);
     } else if (!sformat.compare(cur,3,"%ip")) {
       rep = addr.toStringNoMask();
-      tmp_gl.netmask = (addr.isIpv6()?128:32);
+      tmp_gl.netmask = (addr.isIPv6()?128:32);
     } else if (!sformat.compare(cur,2,"%%")) {
       last = cur + 2; continue;
     } else {
index c5d978b343b09423dc76620de62f16cc3d60816e..32cd32f77c8b8d2006ccc7e553c46b13491d5f6a 100644 (file)
@@ -478,7 +478,7 @@ public:
     if(isIpv4()) {
       result.sin4.sin_addr.s_addr = htonl(ntohl(result.sin4.sin_addr.s_addr) & d_mask);
     }
-    else if(isIpv6()) {
+    else if(isIPv6()) {
       size_t idx;
       uint8_t bytes=d_bits/8;
       uint8_t *us=(uint8_t*) &result.sin6.sin6_addr.s6_addr;
@@ -499,7 +499,7 @@ public:
   {
     return d_bits;
   }
-  bool isIpv6() const 
+  bool isIPv6() const
   {
     return d_network.sin6.sin6_family == AF_INET6;
   }
index 85790d5d7c2092a90326eacb23c9518c49d0f9d7..e6bdd9842c4129710e13cadb93b18c82deb2b2ef 100644 (file)
@@ -166,7 +166,8 @@ void BaseLua4::prepareContext() {
   d_lw->registerFunction<ComboAddress(Netmask::*)()>("getNetwork", [](const Netmask& nm) { return nm.getNetwork(); } ); // const reference makes this necessary
   d_lw->registerFunction<ComboAddress(Netmask::*)()>("getMaskedNetwork", [](const Netmask& nm) { return nm.getMaskedNetwork(); } );
   d_lw->registerFunction("isIpv4", &Netmask::isIpv4);
-  d_lw->registerFunction("isIpv6", &Netmask::isIpv6);
+  d_lw->registerFunction("isIpv6", &Netmask::isIPv6);
+  d_lw->registerFunction("isIPv6", &Netmask::isIPv6);
   d_lw->registerFunction("getBits", &Netmask::getBits);
   d_lw->registerFunction("toString", &Netmask::toString);
   d_lw->registerFunction("empty", &Netmask::empty);
index 4dc7740151de3199f0ecaa52c6d98e8a6125b160..457fabdf650f3fda8d3dc33ae719ecf3b5de27c2 100644 (file)
@@ -2785,7 +2785,7 @@ RCode::rcodes_ SyncRes::updateCacheFromRecords(unsigned int depth, LWResult& lwr
         // If ednsmask is relevant, we do not want to cache if the scope prefix length is large and TTL is small
         if (SyncRes::s_ecscachelimitttl > 0) {
           bool manyMaskBits = (ednsmask->isIpv4() && ednsmask->getBits() > SyncRes::s_ecsipv4cachelimit) ||
-            (ednsmask->isIpv6() && ednsmask->getBits() > SyncRes::s_ecsipv6cachelimit);
+            (ednsmask->isIPv6() && ednsmask->getBits() > SyncRes::s_ecsipv6cachelimit);
 
           if (manyMaskBits) {
             uint32_t minttl = UINT32_MAX;
index fc882c9587abdbdfbd2ddec53ec00a7fa929e5fb..97b5ccb48ee8e4ac648b39912f1cffb5b655ac33 100644 (file)
@@ -178,14 +178,14 @@ BOOST_AUTO_TEST_CASE(test_Netmask) {
   BOOST_CHECK(nm.match(local));
   BOOST_CHECK(!nm.match(remote));
   BOOST_CHECK(nm.isIpv4());
-  BOOST_CHECK(!nm.isIpv6());
+  BOOST_CHECK(!nm.isIPv6());
 
   Netmask nm6("fe80::92fb:a6ff:fe4a:51da/64");
   BOOST_CHECK(nm6.getBits() == 64);
   BOOST_CHECK(nm6.match("fe80::92fb:a6ff:fe4a:51db"));
   BOOST_CHECK(!nm6.match("fe81::92fb:a6ff:fe4a:51db"));
   BOOST_CHECK(!nm6.isIpv4());
-  BOOST_CHECK(nm6.isIpv6());
+  BOOST_CHECK(nm6.isIPv6());
 
   Netmask nmp("130.161.252.29/32");
   BOOST_CHECK(nmp.match(remote));