Net::Packet::Env - environment object used for frame capture/injection
use Net::Packet::Env qw($Env); # Get default values from system my $env = Net::Packet::Env->new; # Get values from a specific device my $env2 = Net::Packet::Env->new(dev => 'vmnet1'); print "dev: ", $env->dev, "\n"; print "mac: ", $env->mac, "\n"; print "ip : ", $env->ip, "\n" if $env->ip; print "ip6: ", $env->ip6, "\n" if $env->ip6;
Basically, this module is used to tell where to inject a frame, and Net::Packet::Frame default behaviour regarding auto creation of Net::Packet::Desc and Net::Packet::Dump objects.
The device on which frames will be injected.
The IPv4 address of dev. It will be used by default for all created frames.
The IPv6 address of dev. It will be used by default for all created frames.
The MAC address of dev. It will be used by default for all created frames.
The subnet address of dev. It will be set automatically.
The gateway IP address of dev. It is set automatically under all platforms.
The gateway MAC address of dev. It will not be set automatically. Due to the implementation of ARP lookup within Net::Packet, we can't do it within this module. It is done within Net::Packet::DescL3 under Windows, to automatically build the layer 2 header.
The Net::Packet::Desc object used to inject frames to network.
The Net::Packet::Dump object used to receive frames from network.
This attribute controls Net::Packet::Frame behaviour regarding Net::Packet::Desc autocreation. If set to 0, when a Net::Packet::Frame is created for the first time, a Net::Packet::Desc object will be created if none has been set in desc attribute for default $Env object. Setting it to 1 avoids this behaviour.
Same as above, but for Net::Packet::Dump object.
This attribute controls Net::Packet::Desc behaviour regarding global $Env autosetting behaviour. If set to 0, when a Net::Packet::Desc is created for the first time, the created Net::Packet::Desc object will have a pointer to it stored in desc attribute of $Env default object. Setting it to 1 avoids this behaviour.
Same as abose, but for Net::Packet::Dump object.
The environment debug directive. Set it to a number greater than 0 to increase the level of debug messages. Up to 3, default 0.
Object constructor. You can pass attributes that will overwrite default ones. Default values:
debug: 0
noFrameAutoDesc: 0
noFrameAutoDump: 0
noDescAutoSet: 0
noDumpAutoSet: 0
dev: if not user provided, default interface is used, by calling getDevInfo method. If user provided, all ip, ip6 and mac attributes will be used for that dev.
ip: if not user provided, default interface IP is used, by calling getIp method. If user provided, it is overwritten by the user.
ip6: if not user provided, default interface IPv6 is used, by calling getIp6 method. If user provided, it is overwritten by the user.
mac: if not user provided, default interface MAC is used, by calling getMac method. If user provided, it is overwritten by the user.
By default, network device to use is the one used by default gateway. If you provide an IP address as a parameter, the interface used will be the one which have direct access to this IP address.
Will set internal attributes for network interface passed as a parameter. Those internal attributes are used to get IP, IPv6 and MAC attributes.
This is a helper method. You pass an IP address as a parameter, and all attributes for elected network interface will be updated (dev, ip, ip6, mac, subnet, gatewayIp).
Returns network interface, by looking at internal attribute.
Returns MAC address, by looking at internal attribute.
Returns subnet address, by looking at internal attribute.
Returns IP address, by looking at internal attribute.
Returns IPv6 address, by looking at internal attribute.
Patrice <GomoR> Auffret
Copyright (c) 2004-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.
NetPacket, Net::RawIP, Net::RawSock
To install Net::Packet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Packet
CPAN shell
perl -MCPAN -e shell install Net::Packet
For more information on module installation, please visit the detailed CPAN module installation guide.