]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - config/cfgroot/network-functions.pl
captive: Get MAC address of a device without calling arp
[people/pmueller/ipfire-2.x.git] / config / cfgroot / network-functions.pl
index 66f1ed554ab12041c31cc0b3163f9e1c8a75710f..93b8190305abb93a7d29e0c8a117e22d7e46b6e9 100644 (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