--- rpms/smeserver-dhcpmanager/contribs10/smeserver-dhcpmanager-2.0.4-Yet-more-changes-for-SM2-panels.patch 2024/01/21 16:59:03 1.6 +++ rpms/smeserver-dhcpmanager/contribs10/smeserver-dhcpmanager-2.0.4-Yet-more-changes-for-SM2-panels.patch 2024/01/22 20:02:27 1.7 @@ -1,6 +1,6 @@ diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2023-12-19 09:44:56.678590486 +0000 -+++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2024-01-21 16:53:00.000000000 +0000 ++++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2024-01-22 19:57:00.000000000 +0000 @@ -140,12 +140,12 @@ my $c = shift; my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE"); @@ -68,7 +68,7 @@ diff -urN smeserver-dhcpmanager-2.0.4.ol return "ok"; } -@@ -391,6 +391,167 @@ +@@ -391,6 +391,169 @@ return @leases; } @@ -185,15 +185,17 @@ diff -urN smeserver-dhcpmanager-2.0.4.ol + my ($ip) = trim(@_); + # Ping the IP to ensure it's in the ARP table + my $ping_result = `ping -c 1 -W 1 $ip`; -+ if($ping_result =~ /1 packets transmitted, 1 received/) { ++ #return $ping_result; ++ if($ping_result =~ m/1 packets transmitted, 1 received/) { + # Fetch the ARP table and find the line with the IP address -+ my $arp_result = `arp -an | grep "\($ip)"`; ++ my $mac_result = `nmap -PR -sn $ip`; ++ #return "*$arp_result *$ip*"; + # If found, return the MAC address -+ return $arp_result; -+ if ($arp_result =~ /.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) { ++ #if ($arp_result =~ m/.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) { ++ if ($mac_result =~ /MAC Address: (..:..:..:..:..:..) /) { + return $1; -+ } else { return "not in arp table"} -+ } else { return "no ping"} ++ } else { return "mac not in nmap result";} ++ } else { return "no ping";} + return undef; +} + @@ -223,7 +225,7 @@ diff -urN smeserver-dhcpmanager-2.0.4.ol + if (!$mac){ + $mac = get_mac_address_by_ping($ip); + } -+ if (!$mac) {$mac = "unknown";} ++# if (!$mac) {$mac = "unknown";} + my %pair = ('Network' => $1, 'ip' => $ip, 'mac' => $mac); # $1 => PC Name, $2 => IP Address + push @extracted_output, \%pair; + } @@ -236,7 +238,7 @@ diff -urN smeserver-dhcpmanager-2.0.4.ol #========================================================================= # Procedure qui charge le dhcpd.conf # retourne un tableau contenant les informations -@@ -536,4 +697,4 @@ +@@ -536,4 +699,4 @@ 1;