captive: Get MAC address of a device without calling arp

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2017-04-25 12:52:29 +01:00
parent 966971e589
commit dbfd2622f5
2 changed files with 23 additions and 6 deletions

View File

@@ -374,6 +374,26 @@ sub wifi_get_signal_level($) {
return $signal_level;
}
sub get_hardware_address($) {
my $ip_address = shift;
my $ret;
open(FILE, "/proc/net/arp") or die("Could not read ARP table");
while (<FILE>) {
my ($ip_addr, $hwtype, $flags, $hwaddr, $mask, $device) = split(/\s+/, $_);
if ($ip_addr eq $ip_address) {
$ret = $hwaddr;
last;
}
}
close(FILE);
return $ret;
}
1;
# Remove the next line to enable the testsuite