Commit 9c992c6a authored by Franco Fichtner's avatar Franco Fichtner

dhcp: interface column for leases; closes #860

Getting crowded...

(cherry picked from commit ce942771)
parent a38c6aeb
...@@ -74,6 +74,7 @@ function remove_duplicate($array, $field) ...@@ -74,6 +74,7 @@ function remove_duplicate($array, $field)
return $new; return $new;
} }
$interfaces = legacy_config_get_interfaces(array('virtual' => false));
$leasesfile = services_dhcpd_leasesfile(); $leasesfile = services_dhcpd_leasesfile();
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
...@@ -226,7 +227,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -226,7 +227,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
asort($pools); asort($pools);
} }
foreach (legacy_config_get_interfaces(array("virtual" => false)) as $ifname => $ifarr) { foreach ($interfaces as $ifname => $ifarr) {
if (isset($config['dhcpd'][$ifname]['staticmap'])) { if (isset($config['dhcpd'][$ifname]['staticmap'])) {
foreach($config['dhcpd'][$ifname]['staticmap'] as $static) { foreach($config['dhcpd'][$ifname]['staticmap'] as $static) {
$slease = array(); $slease = array();
...@@ -355,6 +356,7 @@ include("head.inc");?> ...@@ -355,6 +356,7 @@ include("head.inc");?>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<td class="act_sort" data-field="if"><?=gettext("Interface"); ?></td>
<td class="act_sort" data-field="ip"><?=gettext("IP address"); ?></td> <td class="act_sort" data-field="ip"><?=gettext("IP address"); ?></td>
<td class="act_sort" data-field="mac"><?=gettext("MAC address"); ?></td> <td class="act_sort" data-field="mac"><?=gettext("MAC address"); ?></td>
<td class="act_sort" data-field="hostname"><?=gettext("Hostname"); ?></td> <td class="act_sort" data-field="hostname"><?=gettext("Hostname"); ?></td>
...@@ -386,6 +388,7 @@ include("head.inc");?> ...@@ -386,6 +388,7 @@ include("head.inc");?>
if(is_array($dhcpifconf['staticmap'])) { if(is_array($dhcpifconf['staticmap'])) {
foreach ($dhcpifconf['staticmap'] as $staticent) { foreach ($dhcpifconf['staticmap'] as $staticent) {
if ($data['ip'] == $staticent['ipaddr']) { if ($data['ip'] == $staticent['ipaddr']) {
$data['int'] = htmlspecialchars($interfaces[$dhcpif]['descr']);
$data['if'] = $dhcpif; $data['if'] = $dhcpif;
break; break;
} }
...@@ -402,6 +405,7 @@ include("head.inc");?> ...@@ -402,6 +405,7 @@ include("head.inc");?>
continue; continue;
} }
if (($lip >= ip2ulong($dhcpifconf['range']['from'])) && ($lip <= ip2ulong($dhcpifconf['range']['to']))) { if (($lip >= ip2ulong($dhcpifconf['range']['from'])) && ($lip <= ip2ulong($dhcpifconf['range']['to']))) {
$data['int'] = htmlspecialchars($interfaces[$dhcpif]['descr']);
$data['if'] = $dhcpif; $data['if'] = $dhcpif;
break; break;
} }
...@@ -410,6 +414,7 @@ include("head.inc");?> ...@@ -410,6 +414,7 @@ include("head.inc");?>
$mac_hi = strtoupper($data['mac'][0] . $data['mac'][1] . $data['mac'][3] . $data['mac'][4] . $data['mac'][6] . $data['mac'][7]); $mac_hi = strtoupper($data['mac'][0] . $data['mac'][1] . $data['mac'][3] . $data['mac'][4] . $data['mac'][6] . $data['mac'][7]);
?> ?>
<tr> <tr>
<td><?=$data['int'];?></td>
<td><?=$data['ip'];?></td> <td><?=$data['ip'];?></td>
<td> <td>
<a href="services_wol.php?if=<?=$data['if'];?>&amp;mac=<?=$data['mac'];?>" title="<?=gettext("send Wake on LAN packet to this MAC address");?>"> <a href="services_wol.php?if=<?=$data['if'];?>&amp;mac=<?=$data['mac'];?>" title="<?=gettext("send Wake on LAN packet to this MAC address");?>">
......
...@@ -96,6 +96,7 @@ function parse_duid($duid_string) { ...@@ -96,6 +96,7 @@ function parse_duid($duid_string) {
return array($iaid, $duid); return array($iaid, $duid);
} }
$interfaces = legacy_config_get_interfaces(array('virtual' => false));
$leasesfile = services_dhcpdv6_leasesfile(); $leasesfile = services_dhcpdv6_leasesfile();
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
...@@ -291,7 +292,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -291,7 +292,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
asort($pools); asort($pools);
} }
foreach (legacy_config_get_interfaces(array("virtual" => false)) as $ifname => $ifarr) { foreach ($interfaces as $ifname => $ifarr) {
if (isset($config['dhcpdv6'][$ifname]['staticmap'])) { if (isset($config['dhcpdv6'][$ifname]['staticmap'])) {
foreach($config['dhcpdv6'][$ifname]['staticmap'] as $static) { foreach($config['dhcpdv6'][$ifname]['staticmap'] as $static) {
$slease = array(); $slease = array();
...@@ -426,6 +427,7 @@ endif;?> ...@@ -426,6 +427,7 @@ endif;?>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th><?=gettext("Interface"); ?></td>
<th><?=gettext("IPv6 address"); ?></th> <th><?=gettext("IPv6 address"); ?></th>
<th><?=gettext("IAID"); ?></th> <th><?=gettext("IAID"); ?></th>
<th><?=gettext("DUID"); ?></th> <th><?=gettext("DUID"); ?></th>
...@@ -447,6 +449,7 @@ endif;?> ...@@ -447,6 +449,7 @@ endif;?>
if (is_array($dhcpifconf['staticmap'])) { if (is_array($dhcpifconf['staticmap'])) {
foreach ($dhcpifconf['staticmap'] as $staticent) { foreach ($dhcpifconf['staticmap'] as $staticent) {
if ($data['ip'] == $staticent['ipaddr']) { if ($data['ip'] == $staticent['ipaddr']) {
$data['int'] = htmlspecialchars($interfaces[$dhcpif]['descr']);
$data['if'] = $dhcpif; $data['if'] = $dhcpif;
break; break;
} }
...@@ -459,9 +462,11 @@ endif;?> ...@@ -459,9 +462,11 @@ endif;?>
} }
} else { } else {
$data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip'])); $data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip']));
$data['int'] = htmlspecialchars($interfaces[$data['if']]['descr']);
} }
?> ?>
<tr> <tr>
<td><?=$data['int'];?></td>
<td><?=$data['ip'];?></td> <td><?=$data['ip'];?></td>
<td><?=$data['iaid'];?></td> <td><?=$data['iaid'];?></td>
<td><?=$data['duid'];?></td> <td><?=$data['duid'];?></td>
......
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