NetworkInfo::Discovery::Detect - Super Class for all detection modules


NetworkInfo-Discovery documentation Contained in the NetworkInfo-Discovery distribution.

Index


Code Index:

NAME

Top

NetworkInfo::Discovery::Detect - Super Class for all detection modules

SYNOPSIS

Top

    See NetworkInfo::Discovery::(Sniff|Traceroute|Scan)
    for examples.

DESCRIPTION

Top

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.

METHODS

Top

new

just set up lists for holding interfaces, subnets, and gateways

do_it

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.

get_interfaces
get_gateways
get_subnets

returns a list of hash references for interfaces, gateways, or subnets.

add_interface ($hashref)
add_gateway ($hashref)
add_subnet ($hashref)

adds the hash ref to the list of interfaces, gateways, or subnets.

AUTHOR

Top

Tom Scanlan <tscanlan@they.gotdns.org>

SEE ALSO

Top

NetworkInfo::Discovery::Sniff

NetworkInfo::Discovery::Traceroute

NetworkInfo::Discovery::Scan

BUGS

Top

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;