Net::Libdnet::Route - high level API to access libdnet route_* functions


Net-Libdnet documentation Contained in the Net-Libdnet distribution.

Index


Code Index:

NAME

Top

Net::Libdnet::Route - high level API to access libdnet route_* functions

SYNOPSIS

Top

XXX

DESCRIPTION

Top

XXX

METHODS

Top

new
get
add
delete
loop

AUTHOR

Top

Patrice <GomoR> Auffret

COPYRIGHT AND LICENSE

Top


Net-Libdnet documentation Contained in the Net-Libdnet distribution.

#
# $Id: Route.pm 31 2011-01-12 12:52:47Z gomor $
#
package Net::Libdnet::Route;
use strict; use warnings;

use base qw(Class::Gomor::Array);

our @AS  = qw(
   _handle
);
__PACKAGE__->cgBuildIndices;
__PACKAGE__->cgBuildAccessorsScalar(\@AS);

use Net::Libdnet qw(:route);

sub new {
   my $self   = shift->SUPER::new(@_);
   my $handle = dnet_route_open() or die("Route::new: unable to open");
   $self->_handle($handle);
   $self;
}

sub add {
   my $self    = shift;
   my ($dst, $gateway) = @_;
   dnet_route_add($self->_handle, {route_dst => $dst, route_gw => $gateway});
}

sub delete {
   my $self    = shift;
   my ($dst, $gateway) = @_;
   dnet_route_delete($self->_handle, {route_dst => $dst, route_gw => $gateway});
}

sub get {
   my $self  = shift,
   my ($dst) = @_;
   my $h = dnet_route_get($self->_handle, {route_dst => $dst});
   return $h->{route_gw} if $h;
   undef;
}

sub loop {
   my $self         = shift;
   my ($sub, $data) = @_;
   dnet_route_loop($self->_handle, $sub, $data || \'');
}

sub DESTROY {
   my $self = shift;
   defined($self->_handle) && dnet_route_close($self->_handle);
}

1;

__END__