SNMP version 3 packet implementation class.
Namespace:
SnmpSharpNetAssembly: SnmpSharpNet (in SnmpSharpNet.dll) Version: 0.5.0.0 (0.5.0.0)
Syntax
| C# | Visual Basic | Visual C++ |
public class SnmpV3Packet : SnmpPacket
Public Class SnmpV3Packet _ Inherits SnmpPacket
public ref class SnmpV3Packet : public SnmpPacket
Members
| All Members | Constructors | Properties | Methods |
| Member | Description | |
|---|---|---|
| SnmpV3Packet()()() |
Standard constructor.
| |
| SnmpV3Packet(ScopedPdu) |
Standard constructor. Sets internal ScopedPdu class to the argument supplied instance of the
class. This is a good cheat that will allow you direct access to the internal ScopedPdu class
since it is not cloned by assigned to the internal variable.
| |
| authNoPriv(array<Byte>[]()[], array<Byte>[]()[], AuthenticationDigests) |
Set class security to enabled authentication and no privacy. To perform authentication,
authentication password needs to be supplied and authentication protocol to be used
to perform authentication.
This method does not initialize the packet user name. Use SNMPV3Packet.SecurityName
method to set the security name (also called user name) for this request.
| |
| authPriv(array<Byte>[]()[], array<Byte>[]()[], AuthenticationDigests, array<Byte>[]()[], PrivacyProtocols) |
Set packet security to authentication enabled and privacy protection enabled (SNMP v3 mode authPriv)
| |
| BuildInformResponse()()() |
Build SNMP RESPONSE packet for the received INFORM packet.
| |
| BuildInformResponse(SnmpV3Packet) |
Build SNMP RESPONSE packet for the INFORM packet class.
| |
| decode(array<Byte>[]()[], Int32) |
Decode SNMP version 3 packet. This method will perform authentication check and decode privacy protected ScopedPdu. This method will
not check for the timeliness of the packet, correct engine boot value or engine id because it does not have a reference to the engine time prior to this call.
(Overrides SnmpPacket..::.decode(array<Byte>[]()[], Int32).) | |
| DiscoveryRequest()()() |
Build an SNMP version 3 packet suitable for use in discovery process.
| |
| DiscoveryResponse(Int32, Int32, OctetString, Int32, Int32, Int32) |
Build SNMP discovery response packet.
| |
| encode()()() |
Encode SNMP version 3 packet
(Overrides SnmpPacket..::.encode()()().) | |
| encode(MutableByte) |
Wrap BER encoded SNMP information contained in the parameter MutableByte class.
Information in the parameter is prepended by the SNMP version field and wrapped in a sequence header.
Derived classes call this method to finalize SNMP packet encoding.
(Inherited from SnmpPacket.) | |
| Equals(Object) | (Inherited from Object.) | |
| GetHashCode()()() |
Serves as a hash function for a particular type.
(Inherited from Object.) | |
| GetType()()() |
Gets the Type of the current instance.
(Inherited from Object.) | |
| GetUSM(array<Byte>[]()[], Int32) |
"Look-ahead" decode of SNMP packet header including USM information
| |
| IsDiscoveryPacket |
Packet is a discovery request
| |
| IsNotification |
Packet is a notification
(Inherited from SnmpPacket.) | |
| IsReport |
Packet is a report
(Inherited from SnmpPacket.) | |
| IsReportable |
Get or set SNMP version 3 packet Reportable flag in the message flags section. By default this value is set to true.
| |
| IsRequest |
Packet is a request
(Inherited from SnmpPacket.) | |
| IsResponse |
Packet is a response
(Inherited from SnmpPacket.) | |
| MaxMessageSize |
Get maximum message size to be sent to the agent in the request.
| |
| MessageId |
Get SNMP version 3 message id object.
| |
| MsgFlags |
Message flags interface. Allows you to directly set or clear SNMP version 3 header flags field.
Available flags are MsgFlags.Authentication, MsgFlags.Privacy and MsgFlags.Reportable.
Please be careful how you use this property. After setting authentication or privacy parameters to true,
you will need to update UserSecurityModel authentication and privacy types to the correct
values otherwise encoding/decoding will not work.
| |
| NoAuthNoPriv()()() |
Set class security to no authentication and no privacy. User name is set to "initial" (suitable for
SNMP version 3 discovery process). Change username before using if discovery is not being performed.
| |
| NoAuthNoPriv(array<Byte>[]()[]) |
Set class security to no authentication and no privacy with the specific user name.
| |
| Pdu |
Override base class implementation. Returns class ScopedPdu cast as Pdu
(Overrides SnmpPacket..::.Pdu.) | |
| ScopedPdu |
Access packet ScopedPdu class.
| |
| SetEngineId(array<Byte>[]()[]) |
Set authoritative engine id
| |
| SetEngineTime(Int32, Int32) |
Set engine time and boots values
| |
| ToString()()() | (Inherited from Object.) | |
| USM |
Get UserSecurityModel class reference.
| |
| Version |
SNMP Protocol version
(Inherited from SnmpPacket.) |
Remarks
Available packet classes are:
CopyC#
Example, SNMP version 3 noAuthNoPriv encoding:
CopyC#
Example, SNMP version 3 authNoPriv using MD5 authentication packet encoding:
CopyC#
Example, SNMP version 3 authPriv using MD5 authentication and DES encryption packet encoding:
CopyC#
When decoding SNMP version 3 packets, SnmpV3Packet class needs to be initialized with the same values
security values as a request does. This includes, authoritative engine id, engine boots and engine time,
if authentication is used, authentication digest and password and for encryption, password and privacy
protocol used. Without these parameters packet class will not be able to verify the incoming packet and
responses will be discarded even if they are valid.
- SnmpV1Packet
- SnmpV1TrapPacket
- SnmpV2Packet
- SnmpV3Packet
SnmpV1Packet packetv1 = new SnmpV1Packet(); packetv1.SnmpCommunity.Set("public"); packetv1.Pdu.Set(mypdu); byte[] berpacket = packetv1.encode();
SnmpV3Packet packetv3 = new SnmpV3Packet(); packetv3.noAuthNoPriv("myusername"); packetv3.SetEngineTime(engineTime, engineBoots); // See SNMPv3 discovery process for details packetv3.SetEngineId(engineId); // See SNMPv3 discovery process for details packetv3.IsReportable = true; packetv3.Pdu.Set(mypdu); byte[] berpacket = packetv3.encode();
SnmpV3Packet packetv3 = new SnmpV3Packet(); packetv3.authNoPriv("myusername", "myAuthenticationPassword", AuthenticationDigests.MD5); packetv3.SetEngineTime(engineTime, engineBoots); // See SNMPv3 discovery process for details packetv3.SetEngineId(engineId); // See SNMPv3 discovery process for details packetv3.IsReportable = true; packetv3.Pdu.Set(mypdu); byte[] berpacket = packetv3.encode();
SnmpV3Packet packetv3 = new SnmpV3Packet(); packetv3.authPriv("myusername", "myAuthenticationPassword", AuthenticationDigests.MD5, "myPrivacyPassword", PrivacyProtocols.DES); packetv3.SetEngineTime(engineTime, engineBoots); // See SNMPv3 discovery process for details packetv3.SetEngineId(engineId); // See SNMPv3 discovery process for details packetv3.IsReportable = true; packetv3.Pdu.Set(mypdu); byte[] berpacket = packetv3.encode();