diff options
author | lukehamburg <luke.hamburg@gmail.com> | 2017-02-06 11:01:42 -0500 |
---|---|---|
committer | lukehamburg <luke.hamburg@gmail.com> | 2017-02-06 11:01:42 -0500 |
commit | 478e89190a295b48d221ddf2f683cac6f02d7012 (patch) | |
tree | 4587a01c73d6f8fdf0ed788793652b3a8289097d /src/usr | |
parent | 07850c918106ef7bf56db9d895f413966d719b36 (diff) | |
download | pfsense-478e89190a295b48d221ddf2f683cac6f02d7012.zip pfsense-478e89190a295b48d221ddf2f683cac6f02d7012.tar.gz |
enhancements to services_dhcp_edit.php
- added ndp call to get MAC addr if remote client is connected via IPv6
- automatically hide `Copy MAC` button if arp/ndp returns null
- switch to exec() instead of backticks for calls to arp
- uses builtin is_ipaddr() function from util.inc
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/local/www/services_dhcp_edit.php | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/usr/local/www/services_dhcp_edit.php b/src/usr/local/www/services_dhcp_edit.php index c347630..9b5df91 100644 --- a/src/usr/local/www/services_dhcp_edit.php +++ b/src/usr/local/www/services_dhcp_edit.php @@ -385,8 +385,19 @@ if ($_POST) { // Get our MAC address $ip = $_SERVER['REMOTE_ADDR']; -$mymac = `/usr/sbin/arp -an | grep '('{$ip}')' | cut -d" " -f4`; -$mymac = str_replace("\n", "", $mymac); + +switch (is_ipaddr($ip)) { + case 4: + $mymac = exec("/usr/sbin/arp -an | grep '('{$ip}')' | head -n 1 | cut -d' ' -f4"); + $mymac = str_replace("\n", "", $mymac); + break; + case 6: + $mymac = exec("/usr/sbin/ndp -na | /usr/bin/grep '{$ip}' | /usr/bin/head -n 1 | /usr/bin/awk '{ print $2 }'"); + $mymac = str_replace("\n", "", $mymac); + break; + default: + unset($mymac); +} $iflist = get_configured_interface_with_descr(); $ifname = ''; @@ -415,7 +426,6 @@ $macaddress = new Form_Input( $pconfig['mac'], ['placeholder' => 'xx:xx:xx:xx:xx:xx'] ); - $btnmymac = new Form_Button( 'btnmymac', 'Copy My MAC', @@ -424,10 +434,11 @@ $btnmymac = new Form_Button( ); $btnmymac->setAttribute('type','button')->removeClass('btn-primary')->addClass('btn-success btn-sm'); - $group = new Form_Group('MAC Address'); $group->add($macaddress); -$group->add($btnmymac); +if (!empty($mymac)) { + $group->add($btnmymac); +} $group->setHelp('MAC address (6 hex octets separated by colons)'); $section->add($group); |