Net::Packet::VLAN - 802.1Q layer 3 object
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;
This modules implements the encoding and decoding of the Virtual LAN/802.1Q layer.
See also Net::Packet::Layer and Net::Packet::Layer3 for other attributes and methods.
The priority field.
The cfi field. It is only one bit long, so set it to 0 or 1.
VLAN tag id. You'll love it.
Which type the next encapsulated layer is.
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.
Object constructor. You can pass attributes that will overwrite default ones. Default values:
Packs all attributes into a raw format, in order to inject to network. Returns 1 on success, undef otherwise.
Unpacks raw data from network and stores attributes into the object. Returns 1 on success, undef otherwise.
Load them: use Net::Packet::Consts qw(:vlan);
Various supported encapsulated frame types.
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.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 118:
Non-ASCII character seen before =encoding in '# Load'. Assuming ISO8859-1