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

NAME

Net::Packet::Env - environment object used for frame capture/injection

SYNOPSIS

   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;

DESCRIPTION

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.

ATTRIBUTES

dev

The device on which frames will be injected.

ip

The IPv4 address of dev. It will be used by default for all created frames.

ip6

The IPv6 address of dev. It will be used by default for all created frames.

mac

The MAC address of dev. It will be used by default for all created frames.

subnet

The subnet address of dev. It will be set automatically.

gatewayIp

The gateway IP address of dev. It is set automatically under all platforms.

gatewayMac

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.

desc

The Net::Packet::Desc object used to inject frames to network.

dump

The Net::Packet::Dump object used to receive frames from network.

noFrameAutoDesc

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.

noFrameAutoDump

Same as above, but for Net::Packet::Dump object.

noDescAutoSet

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.

noDumpAutoSet

Same as abose, but for Net::Packet::Dump object.

debug

The environment debug directive. Set it to a number greater than 0 to increase the level of debug messages. Up to 3, default 0.

METHODS

new

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.

getDevInfo [ (scalar) ]

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.

getDevInfoFor (scalar)

Will set internal attributes for network interface passed as a parameter. Those internal attributes are used to get IP, IPv6 and MAC attributes.

updateDevInfo (scalar)

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).

getDev

Returns network interface, by looking at internal attribute.

getMac

Returns MAC address, by looking at internal attribute.

getSubnet

Returns subnet address, by looking at internal attribute.

getIp

Returns IP address, by looking at internal attribute.

getIp6

Returns IPv6 address, by looking at internal attribute.

AUTHOR

Patrice <GomoR> Auffret

COPYRIGHT AND LICENSE

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.

RELATED MODULES

NetPacket, Net::RawIP, Net::RawSock