Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiwan dhcp6c - dhcpdv6 changes #4102

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/etc/inc/plugins.inc.d/dhcpd.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1291,8 +1291,9 @@ function dhcpd_dhcp6_configure($verbose = false, $blacklist = array())
$dhcpdv6cfg[$ifname]['range']['to'] = Net_IPv6::compress(implode(':', $ifcfgipv6arr));

/* with enough room we can add dhcp6 prefix delegation */
$pdlen = calculate_ipv6_delegation_length($config['interfaces'][$ifname]['track6-interface']);
if ($pdlen > 2) {
$pdlen = calculate_ipv6_delegation_length($config['interfaces'][$ifname]['track6-interface'],'len');
if ($pdlen > 48) {
$pdlen = $pdlen-48;
$pdlenmax = $pdlen;
$pdlenhalf = $pdlenmax - 1;
$pdlenmin = 64 - ceil($pdlenhalf / 4);
Expand Down
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
12 changes: 9 additions & 3 deletions src/www/services_dhcpv6.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ function reconfigure_dhcpd()
$prefix_array[6] = '0';
$prefix_array[7] = '0';
$wifprefix = Net_IPv6::compress(implode(':', $prefix_array));
$pdlen = calculate_ipv6_delegation_length($config['interfaces'][$if]['track6-interface']) - 1;
$pdlen = calculate_ipv6_delegation_length($config['interfaces'][$if]['track6-interface']);
$pdinfo = get_isp_pdinfo($config['interfaces'][$if]['track6-interface']);

}

?>
Expand Down Expand Up @@ -462,8 +464,12 @@ function show_netboot_config() {
</tr>
<?php if ($pdlen >= 0): ?>
<tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Available prefix delegation size");?></td>
<td><?= 64 - $pdlen ?></td>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("ISP Assigned PD/Size");?></td>
<td><?=$pdinfo ?></td>
</tr>
<tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Maximum prefix delegation size");?></td>
<td><?= $pdlen+1 ?></td>
</tr>
<?php endif ?>
<?php endif ?>
Expand Down