From: Stephan Bosch Date: Mon, 30 Sep 2019 08:30:24 +0000 (+0200) Subject: iputils.hh: ComboAddress: Add getBits() X-Git-Tag: auth-4.3.0-beta2~20^2~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20c33d950715cf0091429fe6268c0d2a8a344a49;p=thirdparty%2Fpdns.git iputils.hh: ComboAddress: Add getBits() --- diff --git a/pdns/iputils.hh b/pdns/iputils.hh index 9d09df1829..f0c360bcb4 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -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 */