The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Libnet - Perl interface to libnet

VERSION

Version 0.01_03

SYNOPSIS

This module provides a Perl interface to Libnet, a library that allows the high level creation of network packets. The library contains several utility routines to help with this.

    use Net::Libnet;

    my $l = libnet_init(LIBNET_LINK) || die libnet_error();

    $l->getdevice();  # prints ethernet devive (i.e. eth0)

    my $MACAddr = $l->get_hwaddr() || diag libnet_error();

    # print the MAC Address, IP Address, and Hostname
    printf "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", @$MACAddr;
    my $addr = $l->get_ipaddr4() || die libnet_error();
    print "IP Address:  " . get_ip_from_ipaddr4($addr);
    print "Hostname:  " . get_hostname_from_ipaddr4($addr);
    ...

EXPORT

libnet_init() and libnet_error() are exported by default. Several constants used for the injection type for libnet_init() are exported as well.

EXPORTED FUNCTIONS

$libnet = libnet_init($injection_type [, $device])

This function returns an initialize Net::Libnet::Libnet object. The device is optional. If one is not provided, libnet_init() will choose a device. If errors occur, undef is returned and the error message can be retrieved by calling libnet_error().

$error = libnet_error()

This function returns a string containing the last error message generated.

Net::Libnet::IPv4 FUNCTIONS

$ip_addr_string = $ip->get_ip_addr()

This function will return a dotted ip address as a string from byte-ordered IP address passed in.

$hostname_string = $ip->get_hostname()

This function will return the hostname for the byte-ordered IP address passed in or the dotted ip address as a string if the hostname cannot be resolved.

Net::Libnet::Libnet FUNCTIONS

$device = $l->getdevice()

This function rturns the device used by libnet_init().

my $MACAddr = $l->get_hwaddr() || diag libnet_error()

This function returns an array reference containing the integer values for the hardware address (i.e. the MAC address) in separate entries in the array. If errors occur during this function, the error can be retrieved using libnet_error().

my ip = $l->get_ipaddr4

This method returns a Net::Libnet::IPv4 object.

NOTES

The current release is the first release of this module, and it is a very incomplete implementation. I'm working under the "Release Early and Often" philosophy. If part of Libnet that you need is missing and you'd like to see earlier, let me know and I'll bump that up the list.

Also, most Libnet functions can only be run by root users. This includes the test scripts used to test this module.

AUTHOR

Steve Peters, <steve@fisharerojo.org>

BUGS

Please report any bugs or feature requests to bug-net-libnet@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

Libnet|http://www.packetfactory.net/libnet/

COPYRIGHT & LICENSE

Copyright 2004 Steve Peters, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.