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

NAME

Net::Packet::VLAN - 802.1Q layer 3 object

SYNOPSIS

   use Net::Packet qw($Env);
   use Net::Packet::VLAN;

   # Load needed constants
   use Net::Packet::Consts qw(:ipv4 :eth);

   # In order to avoid autocreation of Desc and Dump objects
   # Because VLAN is particuliar, we must do it manually
   use Net::Packet::DescL2;
   use Net::Packet::Dump;

   Net::Packet::DescL2->new;
   Net::Packet::Dump->new(filter => 'vlan');

   # Another thing to note, do not send VLAN frames in a 
   # vlan interface, it would be encapsulated another time ;)
   # Instead, send it to the parent interface

   # So, we will play an echo-request inside a vlan
   use Net::Packet::Frame;
   use Net::Packet::IPv4;
   use Net::Packet::ICMPv4;
   my $echo = Net::Packet::Frame->new(
      l3 => Net::Packet::IPv4->new(
         src      => $vlanSrcIp,
         dst      => $vlanDstIp,
         protocol => NP_IPv4_PROTOCOL_ICMPv4,
         doChecksum => 1, # Because system will not do it,
                          # at least under FreeBSD
         noFixLen   => 1, # Well, FreeBSD needs fixing, but not 
                          # when frames are injected into VLANs ;)
      ),
      l4 => Net::Packet::ICMPv4->new,
   );

   # Frame to inject is built, time to encapsulate it into a VLAN frame
   use Net::Packet::ETH;
   my $frame = Net::Packet::Frame->new(
      l2 => Net::Packet::ETH->new(
         dst  => $vlanDstMac,
         type => NP_ETH_TYPE_VLAN,
      ),
      l3 => Net::Packet::VLAN->new(
         frame => $echo,
      ),
   );

   # Done !
   print $frame->l3->print, "\n";
   print $frame->l3->frame->l3->print, "\n";
   print $frame->l3->frame->l4->print, "\n";
   $frame->send;

DESCRIPTION

This modules implements the encoding and decoding of the Virtual LAN/802.1Q layer.

Details: http://standards.ieee.org/getieee802/802.1.html

See also Net::Packet::Layer and Net::Packet::Layer3 for other attributes and methods.

ATTRIBUTES

priority

The priority field.

cfi

The cfi field. It is only one bit long, so set it to 0 or 1.

id

VLAN tag id. You'll love it.

type

Which type the next encapsulated layer is.

frame

This is a Net::Packet::Frame object, built it like any other such frame. Just to mention that you should use doChecksum attribute if you put in a Net::Packet::IPv4 layer, and maybe the noFixLen attribute also.

METHODS

new

Object constructor. You can pass attributes that will overwrite default ones. Default values:

priority: 0

cfi: 0

id: 0

type: NP_VLAN_TYPE_IPv4

pack

Packs all attributes into a raw format, in order to inject to network. Returns 1 on success, undef otherwise.

unpack

Unpacks raw data from network and stores attributes into the object. Returns 1 on success, undef otherwise.

CONSTANTS

Load them: use Net::Packet::Consts qw(:vlan);

NP_VLAN_TYPE_ARP
NP_VLAN_TYPE_IPv4
NP_VLAN_TYPE_IPv6

Various supported encapsulated frame types.

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

1 POD Error

The following errors were encountered while parsing the POD:

Around line 118:

Non-ASCII character seen before =encoding in '# Load'. Assuming CP1252