From 31b151809d04c40fd915c129d28cc9b440a0eabe Mon Sep 17 00:00:00 2001 From: jim-p Date: Thu, 3 Mar 2016 17:16:38 -0500 Subject: Move NTP access restrictions to their own tab and add the ability to craft custom restrictions for arbitrary networks. Fixes #4463 --- src/etc/inc/util.inc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/etc/inc/util.inc') diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index e1f5c80..e74dc64 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -425,6 +425,16 @@ function gen_subnet_mask($bits) { return long2ip(gen_subnet_mask_long($bits)); } +/* Convert a prefix length to an IPv6 address-like mask notation. Very rare but at least ntp needs it. See #4463 */ +function gen_subnet_mask_v6($bits) { + /* Binary representation of the prefix length */ + $bin = str_repeat('1', $bits); + /* Pad right with zeroes to reach the full address length */ + $bin = str_pad($bin, 128, '0', STR_PAD_RIGHT); + /* Convert back to an IPv6 address style notation */ + return Net_IPv6::_bin2Ip($bin); +} + /* Convert long int to IPv4 address Returns '' if not valid IPv4 (including if any bits >32 are non-zero) */ function long2ip32($ip) { -- cgit v1.1