| Net-Libdnet documentation | Contained in the Net-Libdnet distribution. |
Net::Libdnet::Eth - high level API to access libdnet eth_* functions
use Net::Libdnet::Eth; my $h = Net::Libdnet::Eth->new(device => 'eth0');
This modules is a higher level abstraction for libdnet eth_* functions.
Returns an object to eth layer on success, undef otherwise. You MUST give a network interface to use for sending.
Returns the hardware address associated with used network interface. Returns undef on error.
Sets the hardware address specified by scalar of used network interface. Returns undef on error.
Sends the raw data specified by scalar to the network interface. Returns the number of bytes sent on sucess, undef on error.
Patrice <GomoR> Auffret
You may distribute this module under the terms of the BSD license. See LICENSE file in the source distribution archive.
Copyright (c) 2008-2011, Patrice <GomoR> Auffret
| Net-Libdnet documentation | Contained in the Net-Libdnet distribution. |
# # $Id: Eth.pm 31 2011-01-12 12:52:47Z gomor $ # package Net::Libdnet::Eth; use strict; use warnings; use base qw(Class::Gomor::Array); our @AS = qw( device _handle ); __PACKAGE__->cgBuildIndices; __PACKAGE__->cgBuildAccessorsScalar(\@AS); use Net::Libdnet qw(:eth); sub new { my $self = shift->SUPER::new(@_); my $handle = dnet_eth_open($self->device) or return; $self->_handle($handle); $self; } sub get { my $self = shift; dnet_eth_get($self->_handle); } sub set { my $self = shift; my ($addr) = @_; dnet_eth_set($self->_handle, $addr); } sub send { my $self = shift; my ($buf) = @_; dnet_eth_send($self->_handle, $buf, length($buf)); } sub DESTROY { my $self = shift; defined($self->_handle) && dnet_eth_close($self->_handle); } 1; __END__