Net::Packet::Utils - useful subroutines used in Net::Packet
# Load all subroutines use Net::Packet::Utils qw(:all); # Load only specific subroutines use Net::Packet::Utils qw(explodeIps explodePorts); my @ips = explodeIps('192.168.0.1-254,192.168.1.1'); my @ports = explodePorts('1-1024,6000'); print "@ips\n"; print "@ports\n";
This module is not object oriented, it just implements some utilities used accros Net::Packet framework. They may be useful in other modules too, so here lies their descriptions.
Tries to resolve hostname passed as an argument. Returns its IP address.
Tries to resolve hostname passed as an argument. Returns an array of IP addresses.
Tries to resolve hostname passed as an argument. Returns its IPv6 address.
Returns numeric value of IP address passed as an argument.
Returns IP address of numeric value passed as an argument.
Returns numeric value of IPv6 address passed as an argument.
Returns IPv6 address of numeric value passed as an argument.
Returns a port number for direct use as source in a TCP or UDP header (that is a port between 1025 and 65535).
Returns a random integer of 32 bits in length.
Returns a random integer of 16 bits in length.
Converts a MAC address from network format to human format.
Almost used internally, to convert network bits to integers. First argument is what to convert, second is an unpack format, third the offset of first argument where bits to get begins, the fourth are padding bits to achieve the length we need, and the last is the number of bits to get from offset argument.
Almost used internally, to convert integers to network bits. First argument is what to convert, second is a pack format, third the offset where to store the first argument, and the last the number of bits the integer will be once packed.
Compute the INET checksum used in various layers.
Returns the gateway IP address for IP address passed as a parameter. If none provided, returns the default gateway IP address.
Returns the gateway MAC address of specified gateway IP address. It first looks up from ARP cache table, then tries an ARP lookup if none was found, and adds it to ARP cache table.
Returns the MAC address of specified IP address. It first looks up from ARP cache table. If nothing is found, it checks to see if the specified IP address is on the same subnet. If not, it returns the gateway MAC address, otherwise does an ARP lookup. Then, the ARP cache table is updated if an ARP resolution has been necessary.
If you have problem under Windows concerning network interfaces, please send me the output of this method.
Patrice <GomoR> Auffret
Copyright (c) 2004-2009, Patrice <GomoR> Auffret
You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.