summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2016-03-02 07:01:25 +0545
committerPhil Davis <phil.davis@inf.org>2016-03-02 07:01:25 +0545
commitc48401e7f5fb02123cdaf58035c08534b73d6597 (patch)
tree7c8c8872cec86717feaacf89f9a4efa690b37f64
parentdc60c81618e8f97bcd5dfe0bfa190c60c9efac9f (diff)
downloadpfsense-c48401e7f5fb02123cdaf58035c08534b73d6597.zip
pfsense-c48401e7f5fb02123cdaf58035c08534b73d6597.tar.gz
Add code to handle DHCP leases in multiple pools
1) Add code from RELENG_2_2 https://github.com/pfsense/pfsense/commit/cf3aff59edfa4b101d69ddd694a59fdc580d2299 that checks for leases that are in pools other than the ordinary first pool. This code has been missed from the bootstrap conversion. 2) Make the leases per interface/pool work properly. The counter $dlsc did not get incremented much anyway, because of break statements in the previous code. I have made it key $dhcp_leases_subnet_counter by the interface and starting IP of the pool - this is a unique identifier of each pool, so the counter for it can be reliably incremented as leases are considered in any order. 3) Sort $dhcp_leases_subnet_counter before displaying the counter data - that way the displayed data is always nicely ordered by interface name and then increasing pool start IP, regardless of the order that the leases happened to be found.
-rw-r--r--src/usr/local/www/status_dhcp_leases.php32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/usr/local/www/status_dhcp_leases.php b/src/usr/local/www/status_dhcp_leases.php
index 4d0a5c0..48d7b33 100644
--- a/src/usr/local/www/status_dhcp_leases.php
+++ b/src/usr/local/www/status_dhcp_leases.php
@@ -406,21 +406,36 @@ foreach ($leases as $data):
}
if ($data['act'] != $static_string) {
- $dlsc=0;
foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) {
if (!is_array($dhcpifconf['range'])) {
continue;
}
if (is_inrange_v4($data['ip'], $dhcpifconf['range']['from'], $dhcpifconf['range']['to'])) {
$data['if'] = $dhcpif;
- $dhcp_leases_subnet_counter[$dlsc]['dhcpif'] = $dhcpif;
- $dhcp_leases_subnet_counter[$dlsc]['from'] = $dhcpifconf['range']['from'];
- $dhcp_leases_subnet_counter[$dlsc]['to'] = $dhcpifconf['range']['to'];
- $dhcp_leases_subnet_counter[$dlsc]['count'] = $dhcp_leases_subnet_counter[$dlsc]['count']+1;
+ $dlskey = $dhcpif . "-" . $dhcpifconf['range']['from'];
+ $dhcp_leases_subnet_counter[$dlskey]['dhcpif'] = $dhcpif;
+ $dhcp_leases_subnet_counter[$dlskey]['from'] = $dhcpifconf['range']['from'];
+ $dhcp_leases_subnet_counter[$dlskey]['to'] = $dhcpifconf['range']['to'];
+ $dhcp_leases_subnet_counter[$dlskey]['count'] += 1;
break;
}
- $dlsc++;
+ // Check if the IP is in the range of any DHCP pools
+ if (is_array($dhcpifconf['pool'])) {
+ foreach ($dhcpifconf['pool'] as $dhcppool) {
+ if (is_array($dhcppool['range'])) {
+ if (is_inrange_v4($data['ip'], $dhcppool['range']['from'], $dhcppool['range']['to'])) {
+ $data['if'] = $dhcpif;
+ $dlskey = $dhcpif . "-" . $dhcppool['range']['from'];
+ $dhcp_leases_subnet_counter[$dlskey]['dhcpif'] = $dhcpif;
+ $dhcp_leases_subnet_counter[$dlskey]['from'] = $dhcppool['range']['from'];
+ $dhcp_leases_subnet_counter[$dlskey]['to'] = $dhcppool['range']['to'];
+ $dhcp_leases_subnet_counter[$dlskey]['count'] += 1;
+ break 2;
+ }
+ }
+ }
+ }
}
}
@@ -483,7 +498,10 @@ foreach ($leases as $data):
</tr>
</thead>
<tbody>
-<?php foreach ($dhcp_leases_subnet_counter as $listcounters):?>
+<?php
+ ksort($dhcp_leases_subnet_counter);
+ foreach ($dhcp_leases_subnet_counter as $listcounters):
+?>
<tr>
<td><?=$iflist[$listcounters['dhcpif']]?></td>
<td><?=$listcounters['from']?></td>
OpenPOWER on IntegriCloud