Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

C<NetPacket::SpanningTree>
Assemble and disassemble IEEE 802.1D Spanning Tree protocol packets.

C<NetPacket::SpanningTree> - Assemble and disassemble IEEE 802.1D Spanning Tree protocol packets.


NAME

NetPacket::SpanningTree - Assemble and disassemble IEEE 802.1D Spanning Tree protocol packets.


SYNOPSIS


 use NetPacket::LLC;

 use NetPacket::SpanningTree;

 $llc_data = NetPacket::Ethernet->strip($raw_packet);

 $st_data = NetPacket::LLC->strip($llc_data);

 $st_obj = NetPacket::SpanningTree->decode($st_data);


DESCRIPTION

NetPacket::SpanningTree provides a set of routines for assembling and disassembling packets using the IEEE standard Spanning Tree Protocol. Spanning Tree is a layer 2 protocol defined by the IEEE 802.1D specification.

Methods

NetPacket::SpanningTree->decode([ST DATA])
Decode the spanning tree packet data and return an object containing instance data. This method will probably decode garbage input, but it won't mean much.

NetPacket::SpanningTree->encode($st_hash)
Encode the hash into a raw data stream that may be appended to LLC data, then to an ethernet packet. This allows the user to create his/her own Spanning Tree protocol packet and subsequently send it out on the wire (though sending on the wire isn't a function of this application).

Functions

NetPacket::SpanningTree->strip([ST DATA])
Strip the spanning tree data from the packet, and return any underlying data. This returns undef since there is no ``data'' per say included in the spanning tree packet.

Instance data

The instance data contains in the hash returned by the encode and decode methodsof the NetPacket::SpanningTree module contain the following fields. Note, please refer to the IEEE spec for a description of these fields. They are not described in detail here unless relevant to encoding. When available, values not suppiled will be set to IEEE 802.1D defaults.

max_age



=item message_age
bpdu_flags

    A single octet, representing the topology change flag (TC) (LSB) and the

    topology change notification acknowledgement (TCA) (MSB).  This parameter

    is contructed when encoding, please refer to the TC and TCA items to set 

    the appropriate bits.

 

=item bridge_mac

    This (along with bridge_priority) is used to build the bridge_id when encoding.
bpdu_type
topology_change
bridge_priority

    This (along with bridge_mac) is used to build the bridge_id when encoding.
topology_change_ack
protocol_version

    This value should always be 0, defaults to 0.  Note, this value also

    contains the message type (which is also always 0).
forward_delay
hello_time
port_num
root_priority

    This (along with root_mac) is used to build the root_id when encoding.
root_path_cost
protocol_id

    This value should always be 0, defaults to 0.
root_mac

    This (along with root_priority) is used to build the root_id when encoding.
port_priority

    This (along with port_num) is used to build the port_id when encoding.
root_id
port_id
bridge_id

Exports

exportable
st_strip

tags
The following tags group together related exportable items.
:strip
Import the strip function st_strip

:ALL
All the above exportable items


EXAMPLE

The following is a script that listens on device ``eth1'' for spanning tree packets. It then decodes the packets, re-encodes them, and verifies that the both the original and re-encoded data are identical.

#!/usr/bin/perl -w # # Perl script to verify that LACP packet intervals are correct # # #

use strict; use Net::PcapUtils; use NetPacket::Ethernet; use NetPacket::LLC; use NetPacket::SpanningTree;

{ my $iface = ``eth1''; my $errmsg = Net::PcapUtils::loop(\&process_pkt, DEV => $iface ); if (defined $errmsg) { die ``$errmsg\n''; } }

sub process_pkt { my ($arg, $hdr, $pkt) = @_; my $eth_obj = NetPacket::Ethernet->decode($pkt);


    if ((defined $eth_obj->{length}) && 

        ($eth_obj->{dest_mac} =~ m/^0180c200000/)) { # Spanning Tree protocol

        my $llc_obj = NetPacket::LLC->decode($eth_obj->{data});

        my $st_obj = NetPacket::SpanningTree->decode($llc_obj->{data});

        verifyEncoding($st_obj);

        my $newdata = NetPacket::SpanningTree->encode($st_obj);

        return;

    }

 }

# # Decode a packet and compare it to a hash of data to be encoded. # # Input is a hash of data to be encoded. The subroutine encodes and # subsequently decodes the data and verifies the data matches. #

sub verifyEncoding { my ($st_obj) = @_; my $newdata = NetPacket::SpanningTree->encode($st_obj); my $st_obj1 = NetPacket::SpanningTree->decode($newdata); foreach my $key (keys %$st_obj) { if ($key =~ m/data/i) { next; } if ($key =~ m/frame/i) { next; } if ($key =~ m/_parent/i) { next; } if ($st_obj->{$key} eq $st_obj1->{$key}) { print ``$key is identical ($st_obj1->{$key})\n''; } else { print ``$key is $st_obj->{$key} before $st_obj1->{$key} after\n''; } } }


TODO

Better documentation
Clean up some code.


SEE ALSO

NetPacket::LLC

    Module to decode LLC packets (Logical Link Control)
NetPacket::Ethernet

    Module to decode Ethernet Packets
Net::RawIP

    Module to send encoded data out.
Net::PcapUtils

    Utility module to be used for packet capture.

    

=back


COPYRIGHT

Copyright (c) 2002 Chander Ganesan.

This package is free software and is provided ``as is'' without express or implied warranty. It may be used, redistributed and/or modified under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html)

This software and all associated data and documentation ('Software') is available free of charge. You may make copies of the Software but you must include all of this notice on any copy.

The Software was developed for research purposes does not warrant that it is error free or fit for any purpose. The author disclaims any liability for all claims, expenses, losses, damages and costs any user may incur as a result of using, copying or modifying the Software.


AUTHOR

Chander Ganesan <cganesan@cpan.org

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy