"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Ocsinventory/Agent/Backend/OS/MacOS/Networks.pm" between
Ocsinventory-Unix-Agent-2.6.1.tar.gz and Ocsinventory-Unix-Agent-2.8.0.tar.gz

About: Ocsinventory-Agent is a Linux agent for OCS Inventory NG.

Networks.pm  (Ocsinventory-Unix-Agent-2.6.1):Networks.pm  (Ocsinventory-Unix-Agent-2.8.0)
skipping to change at line 78 skipping to change at line 78
my $common = $params->{common}; my $common = $params->{common};
my $description; my $description;
my $ipaddress; my $ipaddress;
my $ipgateway; my $ipgateway;
my $ipmask; my $ipmask;
my $ipsubnet; my $ipsubnet;
my $macaddr; my $macaddr;
my $status; my $status;
my $type; my $type;
my $speed;
# Looking for the gateway # Looking for the gateway
# 'route show' doesn't work on FreeBSD so we use netstat # 'route show' doesn't work on FreeBSD so we use netstat
# XXX IPV4 only # XXX IPV4 only
for(`netstat -nr -f inet`){ for(`netstat -nr -f inet`){
$ipgateway=$1 if /^default\s+(\S+)/i; $ipgateway=$1 if /^default\s+(\S+)/i;
} }
my @ifconfig = `ifconfig -a`; # -a option required on *BSD my @ifconfig = `ifconfig -a`; # -a option required on *BSD
skipping to change at line 109 skipping to change at line 110
foreach $description (@list) { foreach $description (@list) {
$ipaddress = $ipmask = $macaddr = $status = $type = undef; $ipaddress = $ipmask = $macaddr = $status = $type = undef;
# search interface infos # search interface infos
@ifconfig = `ifconfig $description`; @ifconfig = `ifconfig $description`;
foreach (@ifconfig){ foreach (@ifconfig){
$ipaddress = $1 if /inet (\S+)/i; $ipaddress = $1 if /inet (\S+)/i;
$ipmask = $1 if /netmask\s+(\S+)/i; $ipmask = $1 if /netmask\s+(\S+)/i;
$macaddr = $2 if /(address:|ether|lladdr)\s+(\S+)/i; $macaddr = $2 if /(address:|ether|lladdr)\s+(\S+)/i;
$status = 1 if /status:\s+active/i; $status = 1 if /status:\s+active/i;
$type = $1 if /media:\s+(\S+)/i; $type = $1 if /media:\s+(\S+)/i;
$speed = $1 if /media:\s+(\S+)\s+(\S+)/i && ! /supported media:/;
if ($speed =~ /autoselect/i) {
$speed = $2 if /media:\s+(\S+)\s+(\S+)/i && ! /supported media:/;
$speed .= " $3" if /media:\s+(\S+)\s+(\S+)\s+(\S+)/i && ! /support
ed media:/;
} else {
$speed .= " $2" if /media:\s+(\S+)\s+(\S+)/i && ! /supported media
:/;
}
} }
if ($status != 1) {
$speed = "";
} else {
$speed =~ s/\(|\)|\<|\>|baseTX|baseT|,flow-control//g;
$speed =~ s/1000 /1 Gb\/s /g;
$speed =~ s/100 /100 Mb\/s /g;
$speed =~ s/10 /10 Mb\/s /g;
$speed =~ s/full-duplex/FDX/g;
$speed =~ s/half-duplex/HDX/g;
}
my $binip = &ip_iptobin ($ipaddress ,4); my $binip = &ip_iptobin ($ipaddress ,4);
# In BSD, netmask is given in hex form # In BSD, netmask is given in hex form
my $binmask = sprintf("%b", oct($ipmask)); my $binmask = sprintf("%b", oct($ipmask));
my $binsubnet = $binip & $binmask; my $binsubnet = $binip & $binmask;
$ipsubnet = ip_bintoip($binsubnet,4); $ipsubnet = ip_bintoip($binsubnet,4);
my $mask = ip_bintoip($binmask,4); my $mask = ip_bintoip($binmask,4);
$common->addNetwork({ $common->addNetwork({
DESCRIPTION => $description, DESCRIPTION => $description,
IPADDRESS => ($status?$ipaddress:undef), IPADDRESS => ($status?$ipaddress:undef),
IPDHCP => _ipdhcp($description), IPDHCP => _ipdhcp($description),
IPGATEWAY => ($status?$ipgateway:undef), IPGATEWAY => ($status?$ipgateway:undef),
IPMASK => ($status?$mask:undef), IPMASK => ($status?$mask:undef),
IPSUBNET => ($status?$ipsubnet:undef), IPSUBNET => ($status?$ipsubnet:undef),
MACADDR => $macaddr, MACADDR => $macaddr,
STATUS => ($status?"Up":"Down"), STATUS => ($status?"Up":"Down"),
TYPE => ($status?$type:undef) TYPE => ($status?$type:undef),
SPEED => $speed,
}); });
} }
} }
1; 1;
 End of changes. 5 change blocks. 
3 lines changed or deleted 23 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)