Project

Library is fully self contained. This means that it does not depend on any classes or libraries, other then available as part of the .Net framework version 2. Encryption functionality is implemented using System.Security.Cryptography name space. I have decided to use .NET provided crypto to avoid having to worry about international distribution of the library. In other words, if your .NET distribution supports System.Security.Cryptography namespace with MD5, SHA-1, DES, Rijndael and TripleDES classes, you are good to go.

Project is in Beta release. Basic testing of library functionality has been completed and all components are fully operational. Major work now is to do the deep testing. I am hoping to get assistance from the users of the library so if you find any issues, send me a note to dev [at] snmpsharpnet [dot] com.

To re-assure anybody concerned that web site is hosted on a dot com domain, this project is open source and will remain open source and free to all. I have setup a dot com domain because it was $5 cheaper and, let's face it, I'm not made of money :)

Big thanks to Java developers of SNMP libraries joeSNMP, snmp4j, and Westhawk SNMP where I got a lot of ideas and solutions without which this project would not be possible.

Change Log

Mar/29 2011 - version 0.8.6

  • Speed up authentication/privacy operations in SNMPv3 (discovered and solution suggested by Pavel Tatarinov):
    • added new authenticateIncomingMsg method to AuthenticationMD5 and AuthenticationSHA1 that accepts pre-generated authKey
    • added new authenticate method to AuthenticationMD5 and AuthenticationSHA1 that accepts pre-generated authKey
    • cleanup: removed authenticateOutgoingMsg(...) method from AuthenticationMD5 and AuthenticationSHA1 (not used)
    • cleanup: removed authenticateMessage(...) method from AuthenticateMD5 and AuthenticateSHA1 (not used)
    • added new UserSecurityModel.IsAuthentic(...) and UserSecurityModel.Authenticate(...) overrides that accepts pre-generated authentication key
    • added SnmpV3Packet methods GenerateAuthenticationKey() and GeneratePrivacyKey() methods to simplify key generation
    • added SnmpV3Packet encode/decode methods that accept pre-generated privacy and authentication keys
    • fixed key generationa and extending in SnmpV3Packet.decode() to instead call IPrivacyProtocol.PasswordToKey(...) method
    • added PrivacyKey and AuthenticationKey properties to SecureAgentParameters class for get/set access of cached key values
    • added SecureAgentParameters.BuildCachedSecurityKeys() method to generate cached privacy/authentication key values and store them in the class
    • added SecureAgentParameters.HasCachedKeys property. Returns true if required priv and auth cached keys is present
    • added SecureAgentParameters.ResetKeys() method to clear auth and priv keys without impacting the rest of the values
    • updated UdpTarget.Request method to use cached auth/priv key values if they are available
    • updated UdpTarget.RequestAsync and UdpTarget.AsyncResponse to use cached auth/priv keys if available
  • bugfix 3232436 - phase 1 (thanks jcanady):
    • implemented 2 phase discovery process in UdpTarget.Discovery(...) method. Async method 2 phase discovery support is still outstanding

Feb/19 2011 - version 0.8.5

  • improvement 3155967 (thanks anonymous):
    • changed VbCollection copy constructor now takes IEnumerable as first param instead of VbCollection
  • Changed VbCollection.Set(VbCollection second) to VbCollection.Set(IEnumerable second)
  • added VbCollection.Set(IEnumerable) method
  • added OctetString.Clear() method
  • added MutableByte.Clear() method
  • added convenience classes to SecureAgentParameters, noAuthNoPriv(), authNoPriv nad authPriv, to allow for quick and easy way to add security information after discovery is completed

Dec/16 2010 - version 0.8.4

  • fixed bug in SecureAgentParameters.ValidateIncomingPacket() method that incorrectly checked PduType.Response PDUs instead of PduType.Report

Nov/30 2010 - version 0.8.3

  • changed SnmpAuthenticationException accessibility to public
  • changed SnmpInvalidPduTypeException accessibility to public
  • changed SnmpInvalidVersionException accessibility to public
  • changed SnmpPrivacyException accessibility to public

Nov/13 2010 - version 0.8.2

  • bufix 3106337 (thanks anonymous):
    • fix type conversion in Oid/OctetString/Pdu.GetEnumerator method

Nov/5 2010 - version 0.8.1

  • bugfix 3102654 (thanks agutzeit):
    • TimeTicks operator TimeSpan() cast TimeTick value to Int64 earlier in the calculations to avoid overflow

Oct/24 2010 - version 0.8.0

  • bugfix 3065736 (thanks bratmn):
    • UdpTransport.ReceiveBegin now monitors all exceptions generated by BeginReceiveFrom method
    • UdpTransport.SendToCallback() now returns on exception instead of trying to receive data
  • UdpTransport.ReceiveBegin no longer initiates the retry timer on BeginReceiveFrom exception
  • Added support for InterNetworkV6 address family to UdpTransport class
  • changed UdpTransport constructor to receive useIPv6 parameter
  • added UdpTransport.SupportsIPv6 static property. This is a for dummies shortcut to Socket.OSSupportsIPv6 method
  • Moved socket initialization code from the UdpTransport constructor to private method UdpTransport.initSocket
  • Added base class socket re-initialization to UdpTarget.Address property when address family changes (change IPv4 <-> IPv6)
  • Updated UdpTarget constructor call to the base class (UdpTransport) constructor with a correct address family flag for the requested peer address
  • bugfix 3078149 (from anonymous):
    • fixed 'no source check' setting check in UdpTransport.Request
  • changed response peer check from string based comparison to IPEndPoint.Equals() comparison
  • Speed up authentication/privacy operations in SNMPv3 (discovered and solution suggested by Pavel Tatarinov):
    • added new authenticateIncomingMsg method to AuthenticationMD5 and AuthenticationSHA1 that accepts pre-generated authKey
    • added new authenticate method to AuthenticationMD5 and AuthenticationSHA1 that accepts pre-generated authKey
    • cleanup: removed authenticateOutgoingMsg(...) method from AuthenticationMD5 and AuthenticationSHA1 (not used)
    • cleanup: removed authenticateMessage(...) method from AuthenticateMD5 and AuthenticateSHA1 (not used)
    • added new UserSecurityModel.IsAuthentic(...) override that accepts pre-generated authentication key
    • added SnmpV3Packet methods GenerateAuthenticationKey() and GeneratePrivacyKey() methods to simplify key generation
    • added SnmpV3Packet encode/decode methods that accept pre-generated privacy and authentication keys
    • fixed key generationa and extending in SnmpV3Packet.decode() to instead call IPrivacyProtocol.PasswordToKey(...) method
    • added PrivacyKey and AuthenticationKey properties to SecureAgentParameters class for get/set access of cached key values
    • added SecureAgentParameters.BuildCachedSecurityKeys() method to generate cached privacy/authentication key values and store them in the class
    • added SecureAgentParameters.HasCachedKeys property. Returns true if required priv and auth cached keys is present
    • updated UdpTarget.Request method to use cached key values if they are available
    • updated UdpTarget.RequestAsync and UdpTarget.AsyncResponse to use cached auth/priv keys if available

Sep/08 2010 - version 0.7.9

  • added AgentParameters.DisableReplySourceCheck flag that disables checking of host IP/port information on received replies. By default set to false
  • renamed property TimeTicks.Milisecond to correct spelling TimeTicks.Milliseconds
  • added IEnumerator implementation to Oid class
  • added IEnumerator implementation to OctetString class
  • Add IpAddress.Set(System.Net.IPAddress) method to match available constructors
  • replaced IpAddress.CompareTo(IPAddress) and IpAddress.CompareTo(IpAddress) with generic IpAddress.CompareTo(object) which accepts IPAddress, IpAddress, OctetString, byte[] or UInt32 argument for comparison
  • changed IpAddress.Equals(object) to process comparison with same types as IpAddress.CompareTo()
  • changed EthernetAddress constructors to call base class (OctetString) constructor during intialization and cut down on duplication of code
  • fixed OctetString.Append(string) added check for zero length string argument
  • fixed Pdu.Pdu(PduType) constructor to set MaxRepeaters to 100 and NonRepeaters to 0 if PduType == PduType.GetBulk
  • fixed Pdu.GetBulkPdu(VbCollection) to set MaxRepeaters to 100 for consistency with other methods initializing GetBulk PDUs
  • bugfix 3061831 (thanks hckling): fixed UInteger32 constructors with arguments to correctly set data type

May/16 2010 - version 0.7.8

  • Changed IpAddress.NetworkMask() to use byte arrays instead of string values (small speed improvement)
  • bufix 3001092 (thanks james-goddard) in UdpTransport.RetryAsyncRequest causing 1 retry more then specified to be made on async requests
  • fixed errors with Pdu.Clone() that made it impossible to clone PDU of type GetBulk
  • added Pdu.GetHashCode() and Pdu.Equals() overrides
  • Pdu class: added index accessors to VarBind collection (convenience only)
  • Pdu class: added enumeration support for VarBind collection (convenience only)
  • VbCollection class: added OidArray() method for easy retrieval of the Vb Oid values as an array
  • Oid: implemented IComparable interface. Needed if you intend to sort Oid arrays
  • fixed Oid.Compare(Oid) to check for argument null

Apr/21 2010 - version 0.7.7.1

  • bugfix 2989409 (thanks mpecenka) in Oid.Compare causing invalid comparisons results and errors in Oid.IsRootOf()

Apr/19 2010 - version 0.7.7

  • fixed Oid integer array set to null handling
  • Oid with integer array of null or length less then 2 values is encoded as SMI valid 0.0 oid
  • bugfix 2988215 (thanks mpecenka): fixed OctetStr.IsHex detection of 0x00 byte at the end of the string

Apr/14 2010 - version 0.7.6

  • added SimpleSnmp.Valid check in SimpleSnmp.Walk method
  • added SuppressExceptions flag to SimpleSnmp class enabling exception forwarding (instead of just ignoring them). Default is true (suppress exceptions).
  • added protocol version check to SimpleSnmp.Walk(SnmpVersion, string) method
  • added SnmpErrorStatusException class for use with SimpleSnmp to communicate Snmp Status/Index PDU errors returned by agent
  • bugfix id 2954095 (thanks bratmn):
    • SnmpException.OidValueTypeChanged static int exception errorCode. Thrown in SimpleSnmp when same Oid value was retrieved more then once as part of a single operation and returned value has a different type from previously retrieved values.
  • added SnmpException.InvalidOid static int exception errorCode. Thrown when rootOid passed to SimpleSnmp.Walk is invalid
  • added check if parameter is null in UInteger32.Equals
  • Modified checking if parameters are null in UInteger32 static operator==
  • bugfix id 2963357 (thanks bratmn):
    • changed UInteger32 static operator != from using UInteger32 to operator == to avoid null parameter exceptions
  • simplified OctetString operator != to call operator == and return negative result instead to repeating the processing. Mostly for easier maintenance
  • changes added greater and less then operators to UInteger32
  • simplified Integer32 operator != to call operator == and return negative result instead to repeating the processing. Mostly for easier maintenance
  • added Pdu.ToString(), SnmpV1Packet.ToString() and SnmpV2Packet.ToString() methods
  • modified Vb.ToString() output to include value type
  • improvement (bug report: 2987091) Oid class handling of null (zero length) values:
    • fixed Oid.decode() to be able to decode Oid values of length 0 (this is invalid based on the standard but still could happen)
    • fixed Oid.ToString() to return "0.0" string when Oid value is null
    • fixed Oid.ToString(int[],...) methods to handle null parameter
    • fixed Oid.GetChildIdentifiers() method to handle null parameters
    • fixed Oid.this[int] to handle null class value
    • fixed Oid.Add(int) to add value to a null Oid value of the class
    • fixed Oid.Add(int[]) to add values to a null Oid value of the class
    • fixed null parameter checking in Oid.operator+(Oid,int[])
    • fixed null parameter checking in Oid.operator+(Oid,string)
    • fixed null parameter checking in Oid.operator+(Oid,Oid)
    • fixed null parameter checking in Oid.operator+(Oid,int)
    • fixed null parameter checking in Oid.operator> and Oid.operator<
    • fixed null parameter checking in IpAddress.CompareTo
    • fixed null parameter checking in Integer32.CompareTo(Integer32)

Jan/21 2010 - version 0.7.5

  • fixed: socket error 10054 now throws SnmpNetworkException in UdpTransport.Request method
  • added ICloneable to all AsnType child classes that didn't have it
  • added IComparable interface implementation to OctetString class
  • implemented error handling in UdpTransport async methods. Now legitimate errors will result in request being aborted (same as blocking requests) with appropriate error code returned in the callback
  • added VbCollection.ContainsOid(Oid) method
  • added VbCollection index access to variable bindings using Oid class and string representation of oid (this(string oid))
  • removed unnecessary byte array allocation in MutableByte.Append(byte) method
  • removed unused MutableByte class allocation from Pdu.encode() method
  • added a check for a correct sequence type at the start of an SNMP packet in SnmpPacket.GetProtocolVersion() and SnmpPacket.decode() methods (SnmpDecodingException thrown)
  • added sequence type check when parsing global message data sequence in SnmpV3Packet.decode() method
  • removed unused versionHeaderLength variable in SnmpV3Packet.encode method
  • removed unused variable byteCount from Privacy3DES.Encrypt method
  • removed unused asnBuf variable from Counter64.decode method
  • removed unused oldOffset variable from Oid.decode method
  • removed unused oldOffset variable from Sequence.decode method
  • removed unused AgentParameter assignments from UdpTarget.AsyncResponse method
  • added sequence type check in SnmpV3Packet.GetUSM method
  • added exception XML documentation to SnmpV3Packet.GetUSM method
  • removed unused preVersionLength variable in SnmpV3Packet.encode method
  • removed unused asnBuf variable from Counter64.decode() method
  • implemented IDisposeable interface in UdpTransport class and changed UdpTransport.Close() into UdpTransport.Dispose() method
  • added IDisposeable interface to UdpTarget class. Implementation Dispose() method is inherited from the UdpTransport class
  • fixed Pdu.Reset() method request id value increment to handle value rollover to avoid integer overflow
  • Thanks to bug report by Martin:
    • fixed bug in SnmpSimple request methods (Get, GetNext, GetBulk, Walk, Set) that could result in a UdpTarget.Close being called on an underfined UdpTarget class

Sep/20 2009 - version 0.7.4

  • bug fix in Pdu.encode() that failed to add sysUpTime and trapObjectID to VbList with 0 items in SNMPv2 TRAPs/INFORMs. Thanks to Michal Narwojsz for report and fix.

Aug/5 2009 - version 0.7.3

  • Thanks to mmangels for bug report:
    • reverted to using Array.Copy from Buffer.BlockCopy to fix newly introduced bug (no performance benefit from Buffer.BlockCopy)

Aug/2 2009 - version 0.7.2

  • in SecureAgentParameters removed _version variable since ony a single version is supported there is no need for a variable
  • added OctetString.SetRef and OctetString.OctetString(byte[], bool) to allow setting class value to parameter reference
  • replaced all calls to Array.Copy with Buffer.BlockCopy to improve speed
  • fixed a bug in OctetString.ToString() that tried to do ASCII print on hex strings
  • added OctetString.IsHex property (get only)

Jun/14 2009 - version 0.7.1

  • changed Oid._data from private to protected
  • changed Oid.GetData() from internal to protected
  • changed OctetString._data from internal to protected
  • changed Integer32._data from internal to protected
  • removed Integer32.Integer32(ref Int32) constructor. There is no need for it
  • changed UInteger32._data from internal to protected
  • changed UInteger64._data from internal to protected
  • added Opaque.Opaque(string) constructor to match parent constructor OctetString.OctetString(string)
  • added Gauge32.Gauge32(UInt32) constructor
  • added Oid.IsNull property. Oid null is an empty Oid (shouldn't happen) or 0.0 value. This is a shortcut to check for both conditions
  • fixed lexographical compare in Oid.Compare(...) methods. Previously, longest method was always greater which is not correct
  • added Oid.CompareExact(int[]) and Oid.CompareExact(Oid) methods for exact Oid comparison (not lexographical)
  • changed Oid.Equals to use CompareExact method instead of Compare
  • fixed retry count in UdpTransport. Retry count of 0 should result in 1 request instead of 2 prior to fix
  • fixed IP address parsing in SimpleSnmp.Resolve(). Now it happens only once :)
  • added IpAddress.IsIP(string) method
  • fixed SnmpV3Packet constructors so that class ScopedPdu is never null (most of class methods assume it is not)
  • Thanks to bug reports, improvements and fixes by Pavel Tatarinov:
    • fixed negative array length in Oid.GetChildIdentifiers
    • set context engine id and name in SecureAgentParameters.UpdateDiscoveryValues
    • fixed OctetString.Equals to return true if both class value and parameter are null arrays
    • removed duplicate setting of context engine id and name in UdpTarget.Request
    • added SnmpV3Packet(SecureAgentParameters) and SnmpV3Packet(SecureAgentParameters,ScopedPdu) constructors
    • added PduErrorStatus enumeration. Pdu and ScopedPdu classes continue to use Int32 for ErrorStatus to avoid dependency on the enumeration that, over time, might become out of date and break class operation. Use the enumeration with a cast.

May/23 2009 - version 0.7.0

  • Privacy protocol TripleDES implemented (class Privacy3DES)

May/12 2009 - version 0.6.0

  • changed IAuthenticationDigest.getDigestLength to IAuthenticationDigest.DigestLength
  • added HMACSHA1.Clear() to AuthenticationSHA1 class to release allocated resources prior to method return
  • added IAuthenticationDigest.CalculateHash() method (implemented in AuthenticationMD5 and AuthenticationSHA1)
  • Privacy protocol AES-192 implementation (class PrivacyAES192)
  • Privacy protocol AES-256 implementation (class PrivacyAES256)

Apr/11 2009 - version 0.5.2

  • changed Pdu.Type from byte constants in SnmpConstants to PduType enum to avoid mistakes
  • changed TrapPdu.encode to use VbList.encode instead of encoding individual Vb entries in a loop
  • added TrapAgent helper class for simplified sending of Traps
  • added offset check in AsnType.ParseLength that now throws OverflowException when end of buffer is reached
  • added [Serializable] flag to all the Type classes
  • reordered operations in Null.decode so parsed ASN.1 type is checked before field length
  • removed Opaque.ToString(). Base class OctetString.ToString() and OctetString.ToHexString are adequate.
  • bugfix: Integer32.decode() BER decoding of negative numbers fixed
  • improved Integer32.encode() method
  • changed TrapPdu properties Generic, Specific and TimeStamp to return native data types (Int32 and UInt32) instead of library specific Integer32 and TimeStamp class references
  • added VbCollection.Add(VbCollection) method to easily append contents of one collection to another
  • changed TrapPdu.Set(AsnType) to TrapPdu.Set(TrapPdu)
  • changed TrapPdu.Enterprise property from get/set to get only returning Oid object reference
  • changed Pdu.encode to use private variables and not properties when encoding internal values
  • removed generating a random Pdu.RequestId in SnmpV2Packet.encode because it is already done in Pdu.encode
  • changed Oid.Set(AsnType) to Oid.Set(Oid). Didn't make sense to keep AsnType parameter when only Oid type is processed
  • removed Pdu.Reset() call from Pdu.SetVbList() and replaced it with VbCollection.Clear()
  • renamed SnmpV1Packet.SnmpCommunity, SnmpV1TrapPacket.SnmpCommunity and SnmpV2Packet.SnmpCommunity property to Community
  • changed SnmpV1Packet.decode, SnmpV1TrapPacket.decode and encode, SnmpV2Packet.decode methods from using Community property to using _snmpCommunity protected variable
  • changed Oid.encode to allow encoding of 0 length Oid values
  • changed Pdu class to set NonRepeaters to zero and MaxRepetitions to 100 when type is changed to GetBulk
  • added SnmpInvalidPduTypeException when trying to access Pdu properties ErrorStatus and ErrorIndex in GetBulk Pdu Types

Mar/29 2009 - version 0.5.1

Bugfix release.

  • Pdu.Reset() setting RequestId value to 0 had unintended consequences. Changed to increment existing requestId by 1
  • UInteger32.operator == StackOverflowException fixed
  • Integer32.operator == StackOverflowException fixed

Added greater then and less then operators to Oid and Counter64 classes.

Mar/17 2009 - version 0.5.0

Version 0.5.0 is a major release with all SNMP operations functional and at beta level. Following changes are included in this release:

  • SimpleSnmp class created with Get, GetNext, Set, GetBulk methods making it easy to use SNMP in C#
    • first version of the class = only basic testing completed
    • all methods are blocking. At this time async calls can only be made using UdpTarget.AsyncRequest method
    • all network calls are made using UdpTransport class methods
  • added SnmpConstants.INFORM to Pdu and SnmpV2Packet classes for proper handling of INFORM packets
  • removed Socket.Shutdown() call from UdpTransport.Dispose() method to avoid SocketException under MONO
  • added SnmpConstants.REPORT to allowed Pdu types to access TrapSysUpTime and TrapObjectID. Needed to encode RESPONSE packet for INFORMs.
  • added helper methods SnmpV2Packet.BuildInformResponse() and a static SnmpV2Packet.BuildInformResponse(SnmpV2Packet)
    • makes it easier to create RESPONSE to INFORM packets
    • static method takes a INFORM packet parsed into SnmpV2Packet and generates a correct response class
    • member method calls the static method with 'this' parameter referencing itself
  • removed commented out SNMPV1, SNMPV2 and SNMPV3 static variables from SnmpConstants
  • SnmpV3Packet.Discovery() method removed setting of user name to "initial" and change it to null (0 len) value
  • Changed IAgentParameters.Version to SnmpVersion type from Int32 (associated changes in AgentParameters and SecureAgentParameters classes)
  • Renamed SnmpPacket.ProtocolVersion property to SnmpPacket.Version and changed type from Integer32 to SnmpVersion
  • Changed SnmpV3Packet.MessageId property type from Integer32 to Int32 and from get only to get/set
  • Changed SnmpV3Packet.MaxMessageSize property type from Integer32 to Int32 and from get only to get/set
  • Changed UserSecurityModel.EngineBoots prop type from Integer32 to Int32 and from get to get/set
  • Changed UserSecurityModel.EngineTime prop type from Integer32 to Int32 and from get to get/set
  • Changed inheritance of SnmpV2Packet from SnmpV1Packet to SnmpPacket for more flexibility in the future
  • Removed IDisposable interface from UdpTransport. Replaced with Close() method for direct user access to socket closing and class destructor as a last resort resouce cleanup
  • Removed 3rd party code from Oid encode, decode, Parse, GetHashCode and ToString methods
  • removed 3rd party code from Integer32 encode and decode methods
  • removed 3rd party code from UInteger32 encode and decode methods
  • removed SnmpAgentException class - unused
  • removed SnmpUnmatchedRequestIdException - unused
  • removed SnmpUnmatchedMessageIdException - unused
  • removed SnmpMessageTimeWindowException - unused
  • removed SnmpInvalidSecurityModelException - unused
  • removed SnmpIndexOutOfRangeException - unused
  • removed SnmpInvalidUsernameException - unused
  • removed SnmpSecurityException - unused
  • removed debugging commands
  • cleaned up encode/decode methods in UInteger64
  • removed 3rd party code from AsnType.BuildLength and AsnType.ParseLength
  • removed unneccessary helper Integer32 variable creation in Pdu.encode (for encoding _requestId, _errorStatus and _errorIndex values)
  • moved methods GetSyntaxObject(string name) and GetSyntaxObject(byte asnType) from Pdu to SnmpConstants class
  • deleted 3rd party code function SnmpConstants.SetBytesFromInt()
  • changed VbCollection inheritance from Collection to AsnType and implemented VarBind encode/decode as part of the class
  • removed SnmpRequestTimedOutException. Replaced with SnmpException with ErrorCode member set to RequestTimedOut value
  • changed SecureAgentParameters.ValidateIncomingPacket from return value bool to exception based error reporting. See documentation for details of exceptions being thrown
  • updated TrapPdu to use VbCollection.decode instead of internally decoding VarBinds
  • added ToHexString method to OctetString
  • added SnmpV3Packet.GetUSM method to allow look-ahead into V2TRAP and INFORM packets to allow authentication and unecryption of SNMPv3 packets
  • fixed bug in Integer32 encoding of positive values with most significant bit in most significant byte set to 1
  • added comparison routines to Counter64 class
  • implemented IComparable interface in Counter64 class
  • added explicit cast of Counter64 class value to UInt64
  • changed implicit cast of Integer32 to UInt32 value to explicit cast
  • added operator + and - to Integer32, UInteger32 and Counter64 classes
  • created IpAddress.Increment(uint) method
  • added IpAddress(UInt32) constructor and IpAddress.Set(UInt32) method
  • added Diff(first,second) static method to Counter32 and Counter64 classes to make calculating the difference between two counter objects with counter roll-over taken into account easier
  • added Oid.Reset() method
  • fixed Pdu.Reset() method. Added reseting ErrorStatus, ErrorIndex, TrapObjectID, TrapTimeStamp and RequestId values.
  • removed Pdu.GetRequestId(). Integer32 class has a GetRandom() method that provides identical functionality.
  • fixed Pdu.Clone() to include all values in the copy
  • renamed SnmpV3Packet.Discovery to DiscoveryRequest()
  • added SnmpV3Packet.DiscoveryResponse helper. Easier way to build disovery replies required for SNMPv3 INFORM handling
  • added SnmpPacket properties: IsRequest, IsResponse, IsNotification, IsReport. Each is available in inherited classes SnmpV1Packet, SnmpV2Packet, SnmpV1TrapPacket and SnmpV3Packet
  • added a null parameter check to OctetString implicit operator byte[] - bug
  • fixed a bug in SnmpV3Packet.BuildInformResponse where authentication and privacy information was not set in the response
  • fixed incorrect initialization of _community variable in AgentParameters.AgentParameters(SnmpVersion,OcetetString) - thanks PanBo

Feb/22 2009 - version 0.4.3

Found issues in encoding/decoding of SNMP version 1 TRAP packets - FIXED

SNMP version 2 traps require sysUpTime and trapObjectID.0 variables to be the first variables in the Pdu. Helper variables added to the Pdu class to make V2TRAP data handling easier. Stand by, example coming soon...

Feb/10 2009 - version 0.4.2

Fixed major bug in 0.4.1 version.

Feb/8 2009 - version 0.4.1 - MAJOR BUG - DO NOT USE

Major bug in packet encoding/decoding introduced in this version. SNMP version 2 does not work!!!

New version released. Async functionality tested with numerous fixes.

Changed SNMP version definitions from static variables in SnmpConstants class to enumeration SnmpVersion. This eliminates the need for protocol version checking when receiving user input.

Feb/1 2009 - version 0.4.0

I have put together a new alpha release version 0.4. Entire package has been changed to accommodate protocol version 3 operations.

Here are some of the things that are new and their status:

  • New packet classes created for each protocol version: SnmpV1Packet, SnmpV2Packet, and SnmpV3Packet
    • Derived from SnmpPacket class
    • Handle all packet handling operations (encode, decode, authenticate, encrypt/decrypt)
  • UdpTransport class to handle SNMP over Internet Protocol version 4 using UDP
    • There is some indication that I will need IPv6 SNMP support some time in the future so a method to implement different transports is handy
    • Handles only base protocol operations. Basically, just a SendTo operation with retry capability
    • Blocking operation has been tested
    • Async operation has not been tested at all - use at own risk
  • UdpTarget inherits from UdpTransport
    • Needed to allow passing and updating of security information (specifically, engine boots and time) between requests
  • IAgentParameter interface and derived classes
    • Developed specifically for SNMP version 3 support
    • Each request to the same agent requires agent information (engine id, boots, time) and security information
    • It is easier to make each subsequent request if required information is stored outside the packet class and applied when needed
    • Allows for information from each reply to be stored and ready for the next request
  • SNMP version 3 authentication
    • MD5 and SHA-1 digests have been implemented.
    • Limited testing done against net-snmp agent implementation (version 5.4.2.1), Cisco and HP ProCurve agents
  • SNMP version 3 privacy
    • DES
      • Implemented using Cryptography API. Only tested with .NET framework version 2.0 and above
      • A lot of testing done against net-snmp agent (version 5.4.2.1)
      • Very limited testing done against Cisco and HP ProCurve agents
    • AES-128
      • Implemented using Cryptography API Rijndael class. There are some differences between AES-128 standard and Rijndael which I I have implemented correctly.
      • Tested against net-snmp agent (5.4.2.1)
    • Other privacy protocols
      • AES-192 and AES-256
        • Untested implementation is included in the class library and marked 'internal'
        • Full testing will be done when I find an agent that supports the protocols
      • TripleDES
        • Implementation using Cryptography API implementation didn't work when testing with a Cisco agent
        • Custom implementation of outside CBC DES/EDE crypto using Crypto API DES class started
        • Not tested as working against any agents. In library marked 'internal'
  • IpAddress class has been extended to support, what I consider, important IP address management functions (see documentation for details)

Current plan for the library releases is: unless major bugs are found which require me to release a fix release in the 0.4 sub-version train, I will be focusing on writing applications using the library and fixing bugs and functionality as work progresses. If library works without major issues, first beta release will be out in the next month or so.

After library moves to beta release, no further changes to the library API will be made. I might still add functionality but existing classes, methods and properties will remain in place and will maintain full backward compatibility. This will be the point when library is usable for outside projects.

Feature Support

FeatureCompletion level
Ver 1Ver 2cVer 3
Get request Beta Beta Beta
Get-next request Beta Beta Beta
Set request Beta Beta Beta
Get-bulk request n/a Beta Beta
TRAP Beta n/a n/a
V2TRAP n/a Beta Beta
noAuthNoPriv n/a n/a Beta
authNoPriv n/a n/a Beta
authPriv n/a n/a Beta
Authentication MD-5 n/a n/a Beta
Authentication SHA-1 n/a n/a Beta
Privacy DES n/a n/a Beta
Privacy AES-128 n/a n/a Beta
Privacy AES-192 n/a n/a Beta
Privacy AES-256 n/a n/a Beta
Privacy TripleDES n/a n/a Beta
Inform notification n/a Beta Beta
Report notification n/a n/a Beta

License

		   GNU LESSER GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. 
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.


  This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

  0. Additional Definitions. 

  As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

  "The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

  An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

  A "Combined Work" is a work produced by combining or linking an
Application with the Library.  The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

  The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

  The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

  1. Exception to Section 3 of the GNU GPL.

  You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

  2. Conveying Modified Versions.

  If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

   a) under this License, provided that you make a good faith effort to
   ensure that, in the event an Application does not supply the
   function or data, the facility still operates, and performs
   whatever part of its purpose remains meaningful, or

   b) under the GNU GPL, with none of the additional permissions of
   this License applicable to that copy.

  3. Object Code Incorporating Material from Library Header Files.

  The object code form of an Application may incorporate material from
a header file that is part of the Library.  You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

   a) Give prominent notice with each copy of the object code that the
   Library is used in it and that the Library and its use are
   covered by this License.

   b) Accompany the object code with a copy of the GNU GPL and this license
   document.

  4. Combined Works.

  You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

   a) Give prominent notice with each copy of the Combined Work that
   the Library is used in it and that the Library and its use are
   covered by this License.

   b) Accompany the Combined Work with a copy of the GNU GPL and this license
   document.

   c) For a Combined Work that displays copyright notices during
   execution, include the copyright notice for the Library among
   these notices, as well as a reference directing the user to the
   copies of the GNU GPL and this license document.

   d) Do one of the following:

       0) Convey the Minimal Corresponding Source under the terms of this
       License, and the Corresponding Application Code in a form
       suitable for, and under terms that permit, the user to
       recombine or relink the Application with a modified version of
       the Linked Version to produce a modified Combined Work, in the
       manner specified by section 6 of the GNU GPL for conveying
       Corresponding Source.

       1) Use a suitable shared library mechanism for linking with the
       Library.  A suitable mechanism is one that (a) uses at run time
       a copy of the Library already present on the user's computer
       system, and (b) will operate properly with a modified version
       of the Library that is interface-compatible with the Linked
       Version. 

   e) Provide Installation Information, but only if you would otherwise
   be required to provide such information under section 6 of the
   GNU GPL, and only to the extent that such information is
   necessary to install and execute a modified version of the
   Combined Work produced by recombining or relinking the
   Application with a modified version of the Linked Version. (If
   you use option 4d0, the Installation Information must accompany
   the Minimal Corresponding Source and Corresponding Application
   Code. If you use option 4d1, you must provide the Installation
   Information in the manner specified by section 6 of the GNU GPL
   for conveying Corresponding Source.)

  5. Combined Libraries.

  You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

   a) Accompany the combined library with a copy of the same work based
   on the Library, uncombined with any other library facilities,
   conveyed under the terms of this License.

   b) Give prominent notice with the combined library that part of it
   is a work based on the Library, and explaining where to find the
   accompanying uncombined form of the same work.

  6. Revised Versions of the GNU Lesser General Public License.

  The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

  Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

  If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

Old version documentation

TODO