Commit 31cbcff2 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) move calculate_ipv6_delegation_length() to util.inc and change dependencies

parent 51c3f922
......@@ -25,38 +25,3 @@
RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/* Returns the calculated bit length of the prefix delegation from the WAN interface */
/* DHCP-PD is variable, calculate from the prefix-len on the WAN interface */
/* 6rd is variable, calculate from 64 - (v6 prefixlen - (32 - v4 prefixlen)) */
/* 6to4 is 16 bits, e.g. 65535 */
function calculate_ipv6_delegation_length($if) {
global $config;
if(!isset($config['interfaces'][$if]) || !is_array($config['interfaces'][$if])) {
return false;
} elseif (!isset($config['interfaces'][$if]['ipaddrv6'])) {
return 0;
}
switch($config['interfaces'][$if]['ipaddrv6']) {
case "6to4":
$pdlen = 16;
break;
case "6rd":
$rd6cfg = $config['interfaces'][$if];
$rd6plen = explode("/", $rd6cfg['prefix-6rd']);
$pdlen = (64 - ($rd6plen[1] + (32 - $rd6cfg['prefix-6rd-v4plen'])));
break;
case "dhcp6":
$dhcp6cfg = $config['interfaces'][$if];
$pdlen = $dhcp6cfg['dhcp6-ia-pd-len'];
break;
default:
$pdlen = 0;
break;
}
return $pdlen;
}
......@@ -170,6 +170,39 @@ function gen_subnetv6_max($ipaddr, $bits)
return (inet_ntop($inet_end));
}
/* Returns the calculated bit length of the prefix delegation from the WAN interface */
/* DHCP-PD is variable, calculate from the prefix-len on the WAN interface */
/* 6rd is variable, calculate from 64 - (v6 prefixlen - (32 - v4 prefixlen)) */
/* 6to4 is 16 bits, e.g. 65535 */
function calculate_ipv6_delegation_length($if) {
global $config;
if(!isset($config['interfaces'][$if]) || !is_array($config['interfaces'][$if])) {
return false;
} elseif (!isset($config['interfaces'][$if]['ipaddrv6'])) {
return 0;
}
switch($config['interfaces'][$if]['ipaddrv6']) {
case "6to4":
$pdlen = 16;
break;
case "6rd":
$rd6cfg = $config['interfaces'][$if];
$rd6plen = explode("/", $rd6cfg['prefix-6rd']);
$pdlen = (64 - ($rd6plen[1] + (32 - $rd6cfg['prefix-6rd-v4plen'])));
break;
case "dhcp6":
$dhcp6cfg = $config['interfaces'][$if];
$pdlen = $dhcp6cfg['dhcp6-ia-pd-len'];
break;
default:
$pdlen = 0;
break;
}
return $pdlen;
}
/* returns a subnet mask (long given a bit count) */
function gen_subnet_mask_long($bits)
{
......
......@@ -34,6 +34,7 @@ require_once("interfaces.inc");
require_once("filter.inc");
require_once("system.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("services.inc");
require_once("plugins.inc");
......
......@@ -33,7 +33,8 @@ require_once("guiconfig.inc");
require_once("system.inc");
require_once("interfaces.inc");
require_once("plugins.inc");
require_once 'services.inc';
require_once("services.inc");
require_once("util.inc");
/* expects $logfile to point to the system path */
/* expects $logclog to be true or false */
......
......@@ -33,6 +33,7 @@ require_once("services.inc");
require_once("system.inc");
require_once("unbound.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("interfaces.inc");
/*
......
......@@ -33,6 +33,7 @@ require_once("filter.inc");
require_once("system.inc");
require_once("unbound.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("interfaces.inc");
require_once("services.inc");
......
......@@ -33,6 +33,7 @@ require_once("filter.inc");
require_once("services.inc");
require_once("system.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("unbound.inc");
if (empty($config['dnsmasq']['hosts']) || !is_array($config['dnsmasq']['hosts'])) {
......
......@@ -31,6 +31,7 @@ require_once("guiconfig.inc");
require_once("system.inc");
require_once("services.inc");
require_once("interfaces.inc");
require_once("util.inc");
require_once("pfsense-utils.inc");
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_dnsmasq.php');
......
......@@ -30,6 +30,7 @@
require_once("guiconfig.inc");
require_once("system.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("services.inc");
require_once("interfaces.inc");
......
......@@ -32,6 +32,7 @@ require_once("unbound.inc");
require_once("services.inc");
require_once("system.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("interfaces.inc");
if (empty($config['unbound']) || !is_array($config['unbound'])) {
......
......@@ -31,6 +31,7 @@ require_once("guiconfig.inc");
require_once("unbound.inc");
require_once("system.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("services.inc");
require_once("interfaces.inc");
......
......@@ -31,6 +31,7 @@ require_once("guiconfig.inc");
require_once("unbound.inc");
require_once("system.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("services.inc");
if(empty($config['unbound']) || !is_array($config['unbound'])) {
......
......@@ -33,6 +33,7 @@ require_once("unbound.inc");
require_once("services.inc");
require_once("system.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("interfaces.inc");
if (empty($config['unbound']) || !is_array($config['unbound'])) {
......
......@@ -33,6 +33,7 @@ require_once("config.inc");
require_once("services.inc");
require_once("pfsense-utils.inc");
require_once("interfaces.inc");
require_once("util.inc");
function leasecmp($a, $b)
{
......
......@@ -31,6 +31,7 @@
require_once("guiconfig.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("interfaces.inc");
require_once("services.inc");
......
......@@ -34,6 +34,7 @@ require_once("filter.inc");
require_once("system.inc");
require_once("unbound.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("services.inc");
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
......
......@@ -35,6 +35,7 @@ require_once("ipsec.inc");
require_once("vslb.inc");
require_once("system.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("services.inc");
require_once("interfaces.inc");
......
......@@ -32,6 +32,7 @@ require_once("filter.inc");
require_once("system.inc");
require_once("unbound.inc");
require_once("pfsense-utils.inc");
require_once("util.inc");
require_once("interfaces.inc");
require_once("services.inc");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment