From c76a729788c448d1b167bbe642c8d8f2e0d4d92a Mon Sep 17 00:00:00 2001 From: Martin Wasley Date: Sun, 10 May 2020 09:22:46 +0100 Subject: [PATCH] Update util.inc Pull real pd from interface_pdinfo file. Add reusable function for obtaining ISP PD Info and PD length --- src/etc/inc/util.inc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index 92183e79661..aaa141bf640 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -397,7 +397,22 @@ function gen_subnetv6_max($ipaddr, $bits) return $result; } - +/* returns ISP assigned PD Info */ +function get_isp_pdinfo($if, $type = 'full') +{ + $realif = get_real_interface($if); + if(file_exists("/tmp/{$realif}_pdinfo")) { + $file_pdinfo = file_get_contents("/tmp/{$realif}_pdinfo"); + $pdinfo = explode('/',$file_pdinfo); + if($type != 'len') { + return $file_pdinfo; + } else { + return $pdinfo[1]; + } + } else { + return false; + } +} /* returns the calculated bit length of the prefix delegation from a WAN interface */ function calculate_ipv6_delegation_length($if) { @@ -424,7 +439,10 @@ function calculate_ipv6_delegation_length($if) break; case 'dhcp6': $dhcp6cfg = $config['interfaces'][$if]; - if (is_numeric($dhcp6cfg['dhcp6-ia-pd-len'])) { + if(get_isp_pdinfo($if) != false) + { + $pdlen = get_isp_pdinfo($if, $type = 'len'); + } else if (is_numeric($dhcp6cfg['dhcp6-ia-pd-len'])) { $pdlen = $dhcp6cfg['dhcp6-ia-pd-len']; } break;