Net::Packet::Target - an object for all network related stuff
use Net::Packet::Target; # Create multiple targets, with multiple port my $t1 = Net::Packet::Target->new; $t1->ip('www.google.com'); $t1->portRange('21,22,25,70-90'); $t1->protocol('tcp'); print $t1->isMultiple."\n"; for my $port ($t1->portList) { print $t1->ip.' do stuff for port '.$port."\n"; } # Create multiple targets, with only one port my $t2 = Net::Packet::Target->new; $t2->ipRange('127.0.0.1-10'); $t2->port(22); $t2->protocol('tcp'); print $t2->isMultiple."\n"; for my $ip ($t2->ipList) { print $t2->port.'/'.$t2->protocol.' do stuff for IPv4 '.$ip."\n"; } # Create a single target my $t3 = Net::Packet::Target->new; $t3->ip('127.0.0.1'); $t3->port(22); $t3->protocol('tcp'); print $t3->isMultiple."\n"; print $t3->port.':'.$t3->protocol.' do stuff for IPv4 '.$t3->ip."\n";
A Net::Packet::Target object can be used to describe one target, or multiple targets. They are mainly used when you use some automated tasks you which to use on a range of IPs/ports.
To describe multiple targets, you simply enter an IP range, or a port range, or the two. To describe a single target, you enter one IP address, and one port. You can also avoid totally ports, or avoid totally IPs, you do what you want.
It also handles IP name resolution for IPv4 and IPv6, if available.
These 4 attributes store respectively the target mac address, port, protocol to use for port, and the hostname.
These 3 attributes store respectively an IPv4 address list, an IPv6 address list, and a port list. All this as array references. When called without parameter, they return an array.
Object constructor. There are no default values, due to the nature of this object.
Because a Net::Packet::Target object can be used to describe one target, or multiple ones, we must have a way to know that. This method is used to answer the question. Returns 1 if the object is composed of either multiple IPs, or multiple ports, 0 otherwise.
Will take as a parameter an IPv4 address, or a hostname. Without argument, returns the stored value.
Same as previous, for IPv6.
Will take as a parameter an IPv4 address range. The format is for example: 127.0.0.1-254, or 127.0-10.1.50-70. It will store the result in ipList attribute, to be easily used in a for loop.
Same as previous, but for port ranges. The format is for example: 1-1024, 500-600,100-110. It will store the result in portList attribute, to be easily used ina for loop.
Net::Packet
Patrice <GomoR> Auffret
Copyright (c) 2006, Patrice <GomoR> Auffret
You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.
To install Net::Packet::Target, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Packet::Target
CPAN shell
perl -MCPAN -e shell install Net::Packet::Target
For more information on module installation, please visit the detailed CPAN module installation guide.