summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlukehamburg <luke.hamburg@gmail.com>2017-02-09 00:59:23 -0500
committerlukehamburg <luke.hamburg@gmail.com>2017-02-09 00:59:23 -0500
commitc516cb287a78f7b05459e7fcba410f443d8eb8af (patch)
tree1fa3467f294c08f2ca52dcff4545e77b0cab642d
parent6c2f093000b05285546e81dd1a578fc9b573b72b (diff)
downloadpfsense-c516cb287a78f7b05459e7fcba410f443d8eb8af.zip
pfsense-c516cb287a78f7b05459e7fcba410f443d8eb8af.tar.gz
4th attempt!
- Reworked based on recent comments from @rbgarga
-rw-r--r--src/etc/inc/util.inc10
-rw-r--r--src/usr/local/www/services_dhcp_edit.php2
2 files changed, 8 insertions, 4 deletions
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc
index f5bb4ef..f2bce2c 100644
--- a/src/etc/inc/util.inc
+++ b/src/etc/inc/util.inc
@@ -1812,16 +1812,20 @@ function alias_expand_urltable($name) {
}
/* obtain MAC address given an IP address by looking at the ARP/NDP table */
-function arp_get_mac_by_ip($ip) {
+function arp_get_mac_by_ip($ip, $do_ping = false) {
unset($macaddr);
$retval = 1;
switch (is_ipaddr($ip)) {
case 4:
- mwexec("/sbin/ping -c 1 -t 1 " . escapeshellarg($ip), true);
+ if ($do_ping === true) {
+ mwexec("/sbin/ping -c 1 -t 1 " . escapeshellarg($ip), true);
+ }
$macaddr = exec("/usr/sbin/arp -n " . escapeshellarg($ip) . " | /usr/bin/awk '{print $4}'", $output, $retval);
break;
case 6:
- mwexec("/sbin/ping6 -c 1 -X 1 " . escapeshellarg($ip), true);
+ if ($do_ping === true) {
+ mwexec("/sbin/ping6 -c 1 -X 1 " . escapeshellarg($ip), true);
+ }
$macaddr = exec("/usr/sbin/ndp -n " . escapeshellarg($ip) . " | /usr/bin/awk '{print $2}'", $output, $retval);
break;
}
diff --git a/src/usr/local/www/services_dhcp_edit.php b/src/usr/local/www/services_dhcp_edit.php
index cd45b90..ce8852f 100644
--- a/src/usr/local/www/services_dhcp_edit.php
+++ b/src/usr/local/www/services_dhcp_edit.php
@@ -385,7 +385,7 @@ if ($_POST) {
// Get our MAC address
$ip = $_SERVER['REMOTE_ADDR'];
-$mymac = arp_get_mac_by_ip($ip);
+$mymac = arp_get_mac_by_ip($ip, false);
$iflist = get_configured_interface_with_descr();
$ifname = '';
OpenPOWER on IntegriCloud