"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Ocsinventory/Agent/Backend/OS/Linux/Network/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 40 skipping to change at line 40
my @files; my @files;
foreach my $directory (@directories) { foreach my $directory (@directories) {
next unless -d $directory; next unless -d $directory;
foreach my $pattern (@patterns) { foreach my $pattern (@patterns) {
push @files, push @files,
grep { -s $_ } grep { -s $_ }
glob("$directory/$pattern"); glob("$directory/$pattern");
} }
} }
return unless @files; return unless @files;
@files = @files =
map {$_->[0]} map {$_->[0]}
sort {$a->[1]->ctime()<=>$b->[1]->ctime()} sort {$a->[1]->ctime()<=>$b->[1]->ctime()}
map {[$_,stat($_)]} map {[$_,stat($_)]}
@files; @files;
return $files[-1]; return $files[-1];
} }
sub _ipdhcp { sub _ipdhcp {
my $if = shift; my $if = shift;
my $path; my $path;
my $dhcp; my $dhcp;
my $ipdhcp; my $ipdhcp;
my $leasepath; my $leasepath;
if( $leasepath = getLeaseFile($if) ) { $leasepath = getLeaseFile($if);
if ( $leasepath and $leasepath =~ /internal/ ) {
if (open DHCP, $leasepath) {
while(<DHCP>) {
if (/SERVER_ADDRESS=(\d{1,3}(?:\.\d{1,3}){3})/) {
$ipdhcp=$1;
}
}
close DHCP or warn;
} else {
warn ("Can't open $leasepath\n");
}
} elsif( $leasepath ) {
if (open DHCP, $leasepath) { if (open DHCP, $leasepath) {
my $lease; my $lease;
while(<DHCP>){ while(<DHCP>){
$lease = 1 if(/lease\s*{/i); $lease = 1 if(/lease\s*{/i);
$lease = 0 if(/^\s*}\s*$/); $lease = 0 if(/^\s*}\s*$/);
#Interface name #Interface name
if ($lease) { #inside a lease section if ($lease) { #inside a lease section
if (/interface\s+"(.+?)"\s*/){ if (/interface\s+"(.+?)"\s*/){
$dhcp = ($1 =~ /^$if$/); $dhcp = ($1 =~ /^$if$/);
} }
skipping to change at line 195 skipping to change at line 209
IPSUBNET => $ipsubnet, IPSUBNET => $ipsubnet,
MACADDR => $macaddr, MACADDR => $macaddr,
PCISLOT => $pcislot, PCISLOT => $pcislot,
STATUS => $status?"Up":"Down", STATUS => $status?"Up":"Down",
TYPE => $type, TYPE => $type,
SPEED => $bitrate, SPEED => $bitrate,
SSID => $ssid, SSID => $ssid,
BSSID => $bssid, BSSID => $bssid,
IEEE => $version, IEEE => $version,
MODE => $mode, MODE => $mode,
MTU => $mtu,
}); });
} else { } else {
$common->addNetwork({ $common->addNetwork({
DESCRIPTION => $description, DESCRIPTION => $description,
DRIVER => $driver, DRIVER => $driver,
IPADDRESS => $ipaddress, IPADDRESS => $ipaddress,
IPDHCP => _ipdhcp($description), IPDHCP => _ipdhcp($description),
IPGATEWAY => $ipgateway, IPGATEWAY => $ipgateway,
IPMASK => $ipmask, IPMASK => $ipmask,
IPSUBNET => $ipsubnet, IPSUBNET => $ipsubnet,
skipping to change at line 222 skipping to change at line 237
MTU => $mtu, MTU => $mtu,
}); });
} }
} }
if ($description && $ipaddress6) { if ($description && $ipaddress6) {
if ($type eq "Wifi") { if ($type eq "Wifi") {
$common->addNetwork({ $common->addNetwork({
DESCRIPTION => $description, DESCRIPTION => $description,
DRIVER => $driver, DRIVER => $driver,
IPADDRESS => $ipaddress6, IPADDRESS => $ipaddress6,
IPDHCP => _ipdhcp($description), IPDHCP => undef,
IPGATEWAY => $ipgateway6, IPGATEWAY => $ipgateway6,
IPMASK => $ipmask6, IPMASK => $ipmask6,
IPSUBNET => $ipsubnet6, IPSUBNET => $ipsubnet6,
MACADDR => $macaddr, MACADDR => $macaddr,
PCISLOT => $pcislot, PCISLOT => $pcislot,
STATUS => $status?"Up":"Down", STATUS => $status?"Up":"Down",
TYPE => $type, TYPE => $type,
SPEED => $bitrate, SPEED => $bitrate,
SSID => $ssid, SSID => $ssid,
BSSID => $bssid, BSSID => $bssid,
IEEE => $version, IEEE => $version,
MODE => $mode, MODE => $mode,
MTU => $mtu,
}); });
} else { } else {
$common->addNetwork({ $common->addNetwork({
DESCRIPTION => $description, DESCRIPTION => $description,
DRIVER => $driver, DRIVER => $driver,
IPADDRESS => $ipaddress6, IPADDRESS => $ipaddress6,
IPDHCP => _ipdhcp($description),
IPGATEWAY => $ipgateway6, IPGATEWAY => $ipgateway6,
IPDHCP => undef,
IPMASK => $ipmask6, IPMASK => $ipmask6,
IPSUBNET => $ipsubnet6, IPSUBNET => $ipsubnet6,
MACADDR => $macaddr, MACADDR => $macaddr,
PCISLOT => $pcislot, PCISLOT => $pcislot,
STATUS => $status?"Up":"Down", STATUS => $status?"Up":"Down",
TYPE => $type, TYPE => $type,
DUPLEX => $duplex?"Full":"Half", DUPLEX => $duplex?"Full":"Half",
SPEED => $speed, SPEED => $speed,
MTU => $mtu, MTU => $mtu,
VIRTUALDEV => $virtualdev, VIRTUALDEV => $virtualdev,
skipping to change at line 271 skipping to change at line 287
DRIVER => $driver, DRIVER => $driver,
MACADDR => $macaddr, MACADDR => $macaddr,
PCISLOT => $pcislot, PCISLOT => $pcislot,
STATUS => $status?"Up":"Down", STATUS => $status?"Up":"Down",
TYPE => $type, TYPE => $type,
SPEED => $bitrate, SPEED => $bitrate,
SSID => $ssid, SSID => $ssid,
BSSID => $bssid, BSSID => $bssid,
IEEE => $version, IEEE => $version,
MODE => $mode, MODE => $mode,
MTU => $mtu,
}); });
} else { } else {
$common->addNetwork({ $common->addNetwork({
DESCRIPTION => $description, DESCRIPTION => $description,
DRIVER => $driver, DRIVER => $driver,
MACADDR => $macaddr, MACADDR => $macaddr,
PCISLOT => $pcislot, PCISLOT => $pcislot,
STATUS => $status?"Up":"Down", STATUS => $status?"Up":"Down",
TYPE => $type, TYPE => $type,
VIRTUALDEV => $virtualdev, VIRTUALDEV => $virtualdev,
skipping to change at line 767 skipping to change at line 784
} elsif (ip_is_ipv6($prefix)) { } elsif (ip_is_ipv6($prefix)) {
foreach my $line (`route -6n`){ foreach my $line (`route -6n`){
next if $line =~ /^2002/; next if $line =~ /^2002/;
$route = $1 if $line =~ /^(.*)\/.*/; $route = $1 if $line =~ /^(.*)\/.*/;
} }
} }
return $route; return $route;
} }
1; 1;
__END__
=head1 NAME =head1 NAME
OCSInventory::Agent::Backend::OS::Linux::Network::Networks - Network-related fun ctions OCSInventory::Agent::Backend::OS::Linux::Network::Networks - Network-related fun ctions
=head1 DESCRIPTION =head1 DESCRIPTION
This module retrieves network informations. This module retrieves network informations.
=head1 FUNCTIONS =head1 FUNCTIONS
=head2 getSpeed =head2 getSpeed
Returns the speed of the card. Returns the speed of the card.
=head2 getDuplex =head2 getDuplex
Returns duplex state of the card. Returns duplex state of the card.
=head2 getMTU =head2 getMTU
Returns the mtu of the card. Returns the mtu of the card.
=head2 getStatus =head2 getStatus
Returns the status of the card. Returns the status of the card.
=head2 getMAC =head2 getMAC
Returns the mac address. Returns the mac address.
=head2 getSubnetAddress($address, $mask) =head2 getSubnetAddress($address, $mask)
Returns the subnet address for IPv4. Returns the subnet address for IPv4.
=head2 getSubnetAddressIPv6($address, $mask) =head2 getSubnetAddressIPv6($address, $mask)
Returns the subnet address for IPv6. Returns the subnet address for IPv6.
=head2 getIPNetmask($prefix) =head2 getIPNetmask($prefix)
Returns the network mask for IPv4. Returns the network mask for IPv4.
=head2 getIPNetmaskV6($prefix) =head2 getIPNetmaskV6($prefix)
Returns the network mask for IPv6. Returns the network mask for IPv6.
=head2 getslaves =head2 getslaves
Returns if card has a bonding. Returns if card has a bonding.
=head2 getIPRoute =head2 getIPRoute
Returns the gateway defined int he ip config. Returns the gateway defined int he ip config.
=head2 getRouteIfconfig =head2 getRouteIfconfig
Returns the gateway defined in the ip config. Returns the gateway defined in the ip config.
=back
 End of changes. 38 change blocks. 
4 lines changed or deleted 48 lines changed or added

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