From 20c33d950715cf0091429fe6268c0d2a8a344a49 Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Mon, 30 Sep 2019 10:30:24 +0200 Subject: [PATCH] iputils.hh: ComboAddress: Add getBits() --- pdns/iputils.hh | 9 +++++++++ 1 file changed, 9 insertions(+) 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 */ -- 2.47.2