Code

- Added library Net::Arp and corrected function to make it work
authoropensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8>
Sat, 27 Mar 2010 19:40:01 +0000 (19:40 +0000)
committeropensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8>
Sat, 27 Mar 2010 19:40:01 +0000 (19:40 +0000)
- OpenSuse Closes #799

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

gosa-si/gosa-si-client
gosa-si/modules/GosaSupportDaemon.pm

index 992dda4c3cbadf1065374365ae6bae7b9d7520ad..9417ecb16a6d00b29de1ad71887647951b0a405d 100755 (executable)
@@ -37,6 +37,7 @@ use MIME::Base64;
 use XML::Simple;
 use File::Basename;
 use File::Spec;
+use Net::ARP;
 use Fcntl;
 
 # Workaround: need pure perl to make it work with UTF-8 :-(
@@ -297,25 +298,12 @@ sub get_mac {
                                $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 ($client_mac_address and length($client_mac_address) > 0 and not($client_mac_address eq "00:00:00:00:00:00")) {
                                $result= $client_mac_address;
                        }
                        else {
-                               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);
                        }
                }
        }
index 197a09cc6e0625771a61e0302786c786642cffaf..8d3caad0a4452ca9dafedff61cc99c4bcfa8402c 100644 (file)
@@ -803,7 +803,7 @@ sub get_local_ip_for_remote_ip {
 sub get_mac_for_interface {
        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 {