Net::Frame::Layer::SNMP - Simple Network Management Protocol layer object
use Net::Frame::Simple; use Net::Frame::Layer::SNMP qw(:consts); my $snmp = Net::Frame::Layer::SNMP->new( version => NF_SNMP_VERSION_2, community => 'public', requestId => getRandom16bitsInt(), errorStatus => 0, errorIndex => 0, varbindlist => [], ); # # Read a raw layer # my $layer = Net::Frame::Layer::SNMP->new(raw => $raw); print $layer->print."\n"; print 'PAYLOAD: '.unpack('H*', $layer->payload)."\n" if $layer->payload;
This modules implements the encoding and decoding of the SNMP layer.
See also Net::Frame::Layer for other attributes and methods.
SNMP version. This module supports version 1 and version 2(c).
SNMP community string.
SNMP fields for Get, GetNext, Response, Set, Inform, V2Trap and Report PDU types.
SNMP fields for Trap PDU type.
SNMP fields for GetBulk PDU type.
Variable bindings list.
The following are inherited attributes. See Net::Frame::Layer for more information.
Object constructor. You can pass attributes that will overwrite default ones. Synonymous with Get. See SYNOPSIS for default values.
my $snmp = Net::Frame::Layer::SNMP->Get( version => NF_SNMP_VERSION_2, community => 'public', requestId => getRandom16bitsInt(), errorStatus => 0, errorIndex => 0, varbindlist => [], );
my $snmp = Net::Frame::Layer::SNMP->GetNext( version => NF_SNMP_VERSION_2, community => 'public', requestId => getRandom16bitsInt(), errorStatus => 0, errorIndex => 0, varbindlist => [], );
my $snmp = Net::Frame::Layer::SNMP->Response( version => NF_SNMP_VERSION_2, community => 'public', requestId => getRandom16bitsInt(), errorStatus => 0, errorIndex => 0, varbindlist => [], );
my $snmp = Net::Frame::Layer::SNMP->Set( version => NF_SNMP_VERSION_2, community => 'public', requestId => getRandom16bitsInt(), errorStatus => 0, errorIndex => 0, varbindlist => [], );
my $snmp = Net::Frame::Layer::SNMP->Trap( version => NF_SNMP_VERSION_1, community => 'public', entOid => '1.3.6.1.4.1.50000', agentAddr => '127.0.0.1', genericTrap => NF_SNMP_GENERICTRAP_ENTERPRISESPECIFIC, specificTrap => 1, timeticks => time(), varbindlist => [], );
my $snmp = Net::Frame::Layer::SNMP->GetBulk( version => NF_SNMP_VERSION_2, community => 'public', requestId => getRandom16bitsInt(), nonRepeaters => 0, maxRepetitions => 0, varbindlist => [], );
my $snmp = Net::Frame::Layer::SNMP->Inform( version => NF_SNMP_VERSION_2, community => 'public', requestId => getRandom16bitsInt(), errorStatus => 0, errorIndex => 0, varbindlist => [], );
my $snmp = Net::Frame::Layer::SNMP->V2Trap( version => NF_SNMP_VERSION_2, community => 'public', requestId => getRandom16bitsInt(), errorStatus => 0, errorIndex => 0, varbindlist => [], );
my $snmp = Net::Frame::Layer::SNMP->Report( version => NF_SNMP_VERSION_2, community => 'public', requestId => getRandom16bitsInt(), errorStatus => 0, errorIndex => 0, varbindlist => [], );
Object constructors for SNMP PDU types.
These two methods are basically used to increase the speed when using recv method from Net::Frame::Simple. Usually, you write them when you need to write match method.
This method is mostly used internally. You pass a Net::Frame::Layer::SNMP layer as a parameter, and it returns true if this is a response corresponding for the request, or returns false if not.
The following are inherited methods. Some of them may be overriden in this layer, and some others may not be meaningful in this layer. See Net::Frame::Layer for more information.
Load them: use Net::Frame::Layer::SNMP qw(:subs);
my $varbind = Net::Frame::Layer::SNMP->varbinds( oid => '1.3.6.1.4.1.50000', type => NF_SNMP_VARBINDTYPE_INTEGER, value => 1, );
Creates variable bindings.
my @varbinds = Net::Frame::Layer::SNMP->v2trap_varbinds( timeticks => time(), oid => '1.3.6.1.4.1.50000' );
Creates the first two variable bindings for SNMPv2 traps.
Load them: use Net::Frame::Layer::SNMP qw(:consts);
SNMP versions.
SNMP PDU types.
SNMP version 1 generic trap types.
SNMP variable binding types.
All OIDs must be entered in numerical format.
Net::Frame::Layer
For a non Net::Frame::Layer SNMP solution in Perl, Net::SNMP.
Michael Vincent
Copyright (c) 2013, Michael Vincent
You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.
To install Net::Frame::Layer::SNMP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Frame::Layer::SNMP
CPAN shell
perl -MCPAN -e shell install Net::Frame::Layer::SNMP
For more information on module installation, please visit the detailed CPAN module installation guide.