| NetworkInfo-Discovery documentation | Contained in the NetworkInfo-Discovery distribution. |
NetworkInfo::Discovery::Detect - Super Class for all detection modules
See NetworkInfo::Discovery::(Sniff|Traceroute|Scan)
for examples.
NetworkInfo::Discovery::Detect is set up to be the super class of all the detection modules. It sets up the methods for setting and getting the discovered information about interfaces, gateways, and subnets.
just set up lists for holding interfaces, subnets, and gateways
this needs to be implemented in the subclass. it should do what ever it does to detect interfaces, gateways, or subnets adding them to our lists by using the add_* methods below.
returns a list of hash references for interfaces, gateways, or subnets.
adds the hash ref to the list of interfaces, gateways, or subnets.
Tom Scanlan <tscanlan@they.gotdns.org>
Please send any bugs to Tom Scanlan <tscanlan@they.gotdns.org>
| NetworkInfo-Discovery documentation | Contained in the NetworkInfo-Discovery distribution. |
package NetworkInfo::Discovery::Detect; use strict; use warnings;
sub new { my $proto = shift; my %args = @_; my $err; my $class = ref($proto) || $proto; my $self = {}; bless ($self, $class); #set defaults $self->{'interfacelist'} = []; $self->{'gwlist'} = []; $self->{'subnetlist'} = []; # for all args, see if we can autoload them foreach my $attr (keys %args) { if ($self->can($attr) ) { $self->$attr( $args{$attr} ); } else { print "error calling $class->$attr ( $args{$attr} ) : no method $attr \n"; } } return $self; }
sub do_it { }
sub get_interfaces { my $self = shift; return @{$self->{'interfacelist'}}; } sub get_gateways { my $self = shift; return @{$self->{'gwlist'}}; } sub get_subnets { my $self = shift; return @{$self->{'subnetlist'}}; }
sub add_interface { my $self = shift; while (@_) { push (@{$self->{'interfacelist'}}, shift); } } sub add_gateway { my $self = shift; while (@_) { push (@{$self->{'gwlist'}}, shift); } } sub add_subnet { my $self = shift; while (@_) { push (@{$self->{'subnetlist'}}, shift); } }
1;