]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
iputils.hh: ComboAddress: Add getBits()
authorStephan Bosch <stephan.bosch@open-xchange.com>
Mon, 30 Sep 2019 08:30:24 +0000 (10:30 +0200)
committerStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 11 Feb 2020 01:01:47 +0000 (02:01 +0100)
pdns/iputils.hh

index 9d09df18299904b772734956fd0ddb6297d6a23e..f0c360bcb45d220261ae177b09468f5d772c7339 100644 (file)
@@ -317,6 +317,15 @@ union ComboAddress {
     memset(&sin6, 0, sizeof(sin6));
   }
 
+  //! Get the total number of address bits (either 32 or 128 depending on IP version)
+  uint8_t getBits() const
+  {
+    if (isIPv4())
+      return 32;
+    if (isIPv6())
+      return 128;
+    return 0;
+  }
 };
 
 /** This exception is thrown by the Netmask class and by extension by the NetmaskGroup class */