1 |
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 |
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 |
2 |
--- 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.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2023-12-19 09:44:56.678590486 +0000 |
3 |
+++ 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 |
4 |
@@ -140,12 +140,12 @@ |
@@ -140,12 +140,12 @@ |
5 |
my $c = shift; |
my $c = shift; |
6 |
my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE"); |
my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE"); |
68 |
return "ok"; |
return "ok"; |
69 |
} |
} |
70 |
|
|
71 |
@@ -391,6 +391,167 @@ |
@@ -391,6 +391,169 @@ |
72 |
return @leases; |
return @leases; |
73 |
} |
} |
74 |
|
|
185 |
+ my ($ip) = trim(@_); |
+ my ($ip) = trim(@_); |
186 |
+ # Ping the IP to ensure it's in the ARP table |
+ # Ping the IP to ensure it's in the ARP table |
187 |
+ my $ping_result = `ping -c 1 -W 1 $ip`; |
+ my $ping_result = `ping -c 1 -W 1 $ip`; |
188 |
+ if($ping_result =~ /1 packets transmitted, 1 received/) { |
+ #return $ping_result; |
189 |
|
+ if($ping_result =~ m/1 packets transmitted, 1 received/) { |
190 |
+ # Fetch the ARP table and find the line with the IP address |
+ # Fetch the ARP table and find the line with the IP address |
191 |
+ my $arp_result = `arp -an | grep "\($ip)"`; |
+ my $mac_result = `nmap -PR -sn $ip`; |
192 |
|
+ #return "*$arp_result *$ip*"; |
193 |
+ # If found, return the MAC address |
+ # If found, return the MAC address |
194 |
+ return $arp_result; |
+ #if ($arp_result =~ m/.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) { |
195 |
+ if ($arp_result =~ /.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) { |
+ if ($mac_result =~ /MAC Address: (..:..:..:..:..:..) /) { |
196 |
+ return $1; |
+ return $1; |
197 |
+ } else { return "not in arp table"} |
+ } else { return "mac not in nmap result";} |
198 |
+ } else { return "no ping"} |
+ } else { return "no ping";} |
199 |
+ return undef; |
+ return undef; |
200 |
+} |
+} |
201 |
+ |
+ |
225 |
+ if (!$mac){ |
+ if (!$mac){ |
226 |
+ $mac = get_mac_address_by_ping($ip); |
+ $mac = get_mac_address_by_ping($ip); |
227 |
+ } |
+ } |
228 |
+ if (!$mac) {$mac = "unknown";} |
+# if (!$mac) {$mac = "unknown";} |
229 |
+ my %pair = ('Network' => $1, 'ip' => $ip, 'mac' => $mac); # $1 => PC Name, $2 => IP Address |
+ my %pair = ('Network' => $1, 'ip' => $ip, 'mac' => $mac); # $1 => PC Name, $2 => IP Address |
230 |
+ push @extracted_output, \%pair; |
+ push @extracted_output, \%pair; |
231 |
+ } |
+ } |
238 |
#========================================================================= |
#========================================================================= |
239 |
# Procedure qui charge le dhcpd.conf |
# Procedure qui charge le dhcpd.conf |
240 |
# retourne un tableau contenant les informations |
# retourne un tableau contenant les informations |
241 |
@@ -536,4 +697,4 @@ |
@@ -536,4 +699,4 @@ |
242 |
|
|
243 |
1; |
1; |
244 |
|
|