NAME
Net::Packet::Utils - useful subroutines used in Net::Packet
SYNOPSIS
# 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";
DESCRIPTION
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.
SUBROUTINES
- getHostIpv4Addr (scalar)
-
Tries to resolve hostname passed as an argument. Returns its IP address.
- getHostIpv4Addrs (scalar)
-
Tries to resolve hostname passed as an argument. Returns an array of IP addresses.
- getHostIpv6Addr (scalar)
-
Tries to resolve hostname passed as an argument. Returns its IPv6 address.
- inetAton (scalar)
-
Returns numeric value of IP address passed as an argument.
- inetNtoa (scalar)
-
Returns IP address of numeric value passed as an argument.
- inet6Aton (scalar)
-
Returns numeric value of IPv6 address passed as an argument.
- inet6Ntoa (scalar)
-
Returns IPv6 address of numeric value passed as an argument.
- getRandomHighPort
-
Returns a port number for direct use as source in a TCP or UDP header (that is a port between 1025 and 65535).
- getRandom32bitsInt
-
Returns a random integer of 32 bits in length.
- getRandom16bitsInt
-
Returns a random integer of 16 bits in length.
- convertMac (scalar)
-
Converts a MAC address from network format to human format.
- unpackIntFromNet (scalar, scalar, scalar, scalar, scalar)
-
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.
- packIntToNet (scalar, scalar, scalar, scalar)
-
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.
- inetChecksum (scalar)
-
Compute the INET checksum used in various layers.
- explodePorts
- explodeIps
-
See SYNOPSIS.
- getGatewayIp [ (scalar) ]
-
Returns the gateway IP address for IP address passed as a parameter. If none provided, returns the default gateway IP address.
- getGatewayMac (scalar)
-
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.
- getIpMac (scalar)
-
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.
- debugDeviceList
-
If you have problem under Windows concerning network interfaces, please send me the output of this method.
AUTHOR
Patrice <GomoR> Auffret
COPYRIGHT AND LICENSE
Copyright (c) 2004-2015, Patrice <GomoR> Auffret
You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.