Code

- Added Library Net::Arp and remove code not working on OpensSuse
authoropensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8>
Sat, 27 Mar 2010 22:30:08 +0000 (22:30 +0000)
committeropensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8>
Sat, 27 Mar 2010 22:30:08 +0000 (22:30 +0000)
- Closes #802

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17312 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/modules/GosaPackages.pm

index 835eaa520108a5015b9238290436f1cf3b3df8e4..1760c0e1519cd9f66d05e25e89e14b78d63b4b23 100644 (file)
@@ -12,6 +12,7 @@ use XML::Simple;
 use File::Spec;
 use Data::Dumper;
 use MIME::Base64;
+use Net::ARP;
 
 my $event_dir = "/usr/lib/gosa-si/server/GosaPackages";
 use lib "/usr/lib/gosa-si/server/GosaPackages";
@@ -73,29 +74,16 @@ sub get_module_info {
 sub get_mac {
     my $ifreq= shift;
     my $result;
-    if ($ifreq && length($ifreq) > 0) { 
+    if ($ifreq && length($ifreq) > 0) {
         if($ifreq eq "all") {
             $result = "00:00:00:00:00:00";
         } else {
-            my $SIOCGIFHWADDR= 0x8927;     # man 2 ioctl_list
-
                 # A configured MAC Address should always override a guessed value
                 if ($gosa_mac_address and length($gosa_mac_address) > 0) {
                     $result= $gosa_mac_address;
                 }
 
-            socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
-                or die "socket: $!";
-
-            if(ioctl SOCKET, $SIOCGIFHWADDR, $ifreq) {
-                my ($if, $mac)= unpack 'h36 H12', $ifreq;
-
-                if (length($mac) > 0) {
-                    $mac=~ m/^([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/;
-                    $mac= sprintf("%s:%s:%s:%s:%s:%s", $1, $2, $3, $4, $5, $6);
-                    $result = $mac;
-                }
-            }
+          $result = Net::ARP::get_mac($ifreq);
         }
     }
     return $result;