/[smecontribs]/rpms/smeserver-dhcpmanager/contribs10/smeserver-dhcpmanager-2.0.4-Yet-more-changes-for-SM2-panels.patch
ViewVC logotype

Diff of /rpms/smeserver-dhcpmanager/contribs10/smeserver-dhcpmanager-2.0.4-Yet-more-changes-for-SM2-panels.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

Revision 1.5 by brianr, Sat Jan 20 17:11:30 2024 UTC Revision 1.7 by brianr, Mon Jan 22 20:02:27 2024 UTC
# Line 1  Line 1 
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-20 17:01: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");
# Line 68  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 68  diff -urN smeserver-dhcpmanager-2.0.4.ol
68       return "ok";       return "ok";
69   }   }
70    
71  @@ -391,6 +391,118 @@  @@ -391,6 +391,169 @@
72       return @leases;       return @leases;
73   }   }
74    
# Line 144  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 144  diff -urN smeserver-dhcpmanager-2.0.4.ol
144  +      $binoct = dec2bin($_);  +      $binoct = dec2bin($_);
145  +      $binmask = $binmask . substr $binoct, -8;  +      $binmask = $binmask . substr $binoct, -8;
146  +    }  +    }
147  +  +
148  +    # let's count the 1s  +    # let's count the 1s
149  +    @bits = split (//,$binmask);  +    @bits = split (//,$binmask);
150  +    foreach (@bits) {  +    foreach (@bits) {
# Line 152  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 152  diff -urN smeserver-dhcpmanager-2.0.4.ol
152  +        $bitcount++;  +        $bitcount++;
153  +      }  +      }
154  +    }  +    }
 +  
155  +    my $cidr = $network . "/" . $bitcount;  +    my $cidr = $network . "/" . $bitcount;
156  +    return $cidr;  +    return $cidr;
157  +}  +}
158  +  +
159    +sub get_mac_address {
160    +       # From the leases file
161    +    my ($ip, $file) = @_;
162    +    open(my $fh, '<', $file) or die "Could not open file '$file' $!";
163    +    my $mac_address = undef;
164    +    my $lease_block;
165    +    while(my $line = <$fh>) {
166    +        if($line =~ /lease $ip {/ .. $line =~ /}/) {
167    +            $lease_block .= $line;
168    +            if($line =~ /}/) {
169    +                if($lease_block =~ /hardware ethernet (\S+);/) {
170    +                    $mac_address = $1;
171    +                    last;
172    +                } else {
173    +                    $lease_block = '';
174    +                }
175    +            }
176    +        }
177    +    }
178    +    close $fh;
179    +    return $mac_address;
180    +}
181    +
182    +sub  trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
183    +
184    +sub get_mac_address_by_ping {
185    +    my ($ip) = trim(@_);
186    +    # Ping the IP to ensure it's in the ARP table
187    +    my $ping_result = `ping -c 1 -W 1 $ip`;
188    +    #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
191    +        my $mac_result = `nmap -PR -sn $ip`;
192    +        #return "*$arp_result *$ip*";
193    +        # If found, return the MAC address
194    +        #if ($arp_result =~ m/.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) {
195    +               if ($mac_result =~ /MAC Address: (..:..:..:..:..:..) /) {
196    +            return $1;
197    +        } else { return "mac not in nmap result";}
198    +    } else { return "no ping";}
199    +    return undef;
200    +}
201    +
202    +
203    +
204  +sub Scan_Local_Network ($) {            +sub Scan_Local_Network ($) {          
205  +      +  
206  +        my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');  +        my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');
207  +        my $mask = $nmap_sme->get_value('LocalNetmask');  +        my $mask = $nmap_sme->get_value('LocalNetmask');
208  +        my $network = $nmap_sme->get_prop('InternalInterface','Network');  +        my $network = $nmap_sme->get_prop('InternalInterface','Network');
# Line 173  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 217  diff -urN smeserver-dhcpmanager-2.0.4.ol
217  +                               /bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/  /g'`;  +                               /bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/  /g'`;
218  +        +      
219  +    my @extracted_output;  +    my @extracted_output;
220    +    my $leasefile = "/var/lib/dhcpd/dhcpd.leases";
221  +    foreach my $line (@nmap_output) {  +    foreach my $line (@nmap_output) {
222  +        if ($line =~ m/Scan report for ([\w\.-]+) \(([\d\.\:]+)\)/) {  +        if ($line =~ m/Scan report for ([\w\.-]+) \(([\d\.\:]+)\)/) {
223  +            my %pair = ('Network' => $1, 'ip' => $2);  # $1 => PC Name, $2 => IP Address  +                       my $ip = $2;
224  +            push @extracted_output, \%pair;  +                       my $mac = get_mac_address($ip,$leasefile);
225  +        }  +                       if (!$mac){
226    +                               $mac = get_mac_address_by_ping($ip);
227    +                       }
228    +#                      if (!$mac) {$mac = "unknown";}
229    +                       my %pair = ('Network' => $1, 'ip' => $ip, 'mac' => $mac);  # $1 => PC Name, $2 => IP Address
230    +                       push @extracted_output, \%pair;
231    +       }
232  +    }  +    }
233  +    return \@extracted_output;  +    return \@extracted_output;
234  +}  +}
# Line 187  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 238  diff -urN smeserver-dhcpmanager-2.0.4.ol
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 +648,4 @@  @@ -536,4 +699,4 @@
242    
243   1;   1;
244    
# Line 452  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 503  diff -urN smeserver-dhcpmanager-2.0.4.ol
503  +</div>  +</div>
504  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep
505  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep       1970-01-01 01:00:00.000000000 +0100  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep       1970-01-01 01:00:00.000000000 +0100
506  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep   2024-01-20 17:08:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep   2024-01-20 17:30:00.000000000 +0000
507  @@ -0,0 +1,58 @@  @@ -0,0 +1,63 @@
508  +<div id='dhcpd-scan'>  +<div id='dhcpd-scan'>
509  +       <table><tr><td>  +       <table><tr><td>
510  +       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork1()", id=>"scanNetwork1"  +       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork1()", id=>"scanNetwork1"
# Line 474  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 525  diff -urN smeserver-dhcpmanager-2.0.4.ol
525  +                       <th class='sme-border'>  +                       <th class='sme-border'>
526  +                               %=l 'dhcpd_IP'  +                               %=l 'dhcpd_IP'
527  +                       </th>  +                       </th>
528    +                       <th class='sme-border'>
529    +                               %=l 'dhcpd_MAC_ADDRESS'
530    +                       </th>
531    +
532  +               </tr>  +               </tr>
533  +               </thead>  +               </thead>
534  +               <tbody>  +               <tbody>
# Line 481  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 536  diff -urN smeserver-dhcpmanager-2.0.4.ol
536  +        <tr>  +        <tr>
537  +                       %= t td => (class => 'sme-border') => $ip->{Network}  +                       %= t td => (class => 'sme-border') => $ip->{Network}
538  +                       %= t td => (class => 'sme-border') => $ip->{ip}  +                       %= t td => (class => 'sme-border') => $ip->{ip}
539    +                       %= t td => (class => 'sme-border') => $ip->{mac}
540  +               </tr>  +               </tr>
541  +               %}  +               %}
542  +               </tbody>  +               </tbody>


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed