Net-Routing
view release on metacpan or search on metacpan
lib/Net/Routing.pm view on Meta::CPAN
#
# $Id: Routing.pm,v 717225574cff 2015/11/12 08:46:57 gomor $
#
package Net::Routing;
use strict;
use warnings;
our $VERSION = '0.44';
use base qw(Class::Gomor::Hash);
our @AS = qw(
path
lc_all
target
family
_target_type
_routing_module
_routes
);
__PACKAGE__->cgBuildAccessorsScalar(\@AS);
use Net::CIDR;
use Net::IPv4Addr;
use Net::IPv6Addr;
our $_routing_module;
our $Error;
use constant NR_TARGET_ALL => 'all';
use constant NR_TARGET_DEFAULT => 'default';
use constant NR_FAMILY_INET4 => 'inet4';
use constant NR_FAMILY_INET6 => 'inet6';
use constant NR_DEFAULT_ROUTE4 => '0.0.0.0/0';
use constant NR_DEFAULT_ROUTE6 => '::/0';
use constant NR_LOCAL_ROUTE4 => '0.0.0.0';
use constant NR_LOCAL_ROUTE6 => '::';
use constant _TARGET_TYPE_ALL => 'all';
use constant _TARGET_TYPE_DEFAULT => 'default';
use constant _TARGET_TYPE_IPv4 => 'ipv4';
use constant _TARGET_TYPE_IPv6 => 'ipv6';
use constant _TARGET_TYPE_INTERFACE => 'interface';
our %EXPORT_TAGS = (
constants => [qw(
NR_TARGET_ALL
NR_TARGET_DEFAULT
NR_FAMILY_INET4
NR_FAMILY_INET6
NR_DEFAULT_ROUTE4
NR_DEFAULT_ROUTE6
NR_LOCAL_ROUTE4
NR_LOCAL_ROUTE6
)],
);
our @EXPORT_OK = (
'$Error',
@{$EXPORT_TAGS{constants}},
);
BEGIN {
if ($^O eq 'linux') {
return $_routing_module = "Net::Routing::Linux";
}
elsif ($^O eq 'freebsd') {
return $_routing_module = "Net::Routing::FreeBSD";
}
elsif ($^O eq 'netbsd') {
return $_routing_module = "Net::Routing::NetBSD";
}
elsif ($^O eq 'darwin') {
return $_routing_module = "Net::Routing::Darwin";
}
#elsif ($^O eq 'MSWin32') {
# return $_routing_module = "Net::Routing::MSWin32";
#}
#elsif ($^O eq 'openbsd') {
# return $_routing_module = "Net::Routing::OpenBSD";
#}
die("[-] Net::Routing: Operating System not supported: $^O\n");
}
sub new {
my $self = shift->SUPER::new(
path => [ qw(/bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin) ],
lc_all => 'en_GB.UTF-8',
target => NR_TARGET_ALL(),
family => NR_FAMILY_INET4(),
@_,
);
( run in 1.229 second using v1.01-cache-2.11-cpan-140bd7fdf52 )