Skip to content

Commit

Permalink
Update util.inc
Browse files Browse the repository at this point in the history
Pull real pd from interface_pdinfo file.
Add reusable function for obtaining ISP PD Info and PD  length
  • Loading branch information
Martin Wasley committed May 10, 2020
1 parent f274499 commit c76a729
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/etc/inc/util.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down

0 comments on commit c76a729

Please sign in to comment.