1

I am trying to get OID value (in string format) from Snmp device by using Lextm.SharpSnmpLib.Messaging. it is displaying correctly for normal OID values, but while converting for Mac address containing('-') it does not converts properly and displays "\u0000 k???" any conversion recommendations, here is the code attached.

IList<Variable> result = Messenger.Get(VersionCode.V1,
                         new IPEndPoint(IPAddress.Parse(sIpAddress), 
                         objSNMPv1Setting.Port),
                         new OctetString(objSNMPv1Setting.CommunityName), 
                         lstOid.Select(x => new Variable(new ObjectIdentifier(x))).ToList(),
                         objSNMPv1Setting.Timeout);

foreach (var o in result)
{            
    dictResponce.Add(o.Id.ToString(), o.Data.ToString());         
}

OID Value : ABC

o.Data.ToString() = ABC

OID Value :00-20-6B-93-EC-81

o.Data.ToString() = \u0000 k???

Expected

OID Value :00-20-6B-93-EC-81

o.Data.ToString() = 00-20-6B-93-EC-81
  • Strings that start with "\u0000" are empty strings. Looks like that library does not expect failure, probably just not tested well enough. Just file a bug report with the author. – Hans Passant Jun 04 '19 at 14:09
  • It is by design. Decoding the actual type of an object requires the MIB documents, and that's only covered by #SNMP Pro, https://github.com/lextudio/sharpsnmppro-samples/blob/release_2.0/Tests.NUnit/Mib/Tests/ObjectRegistryTestFixture.cs#L363 as the test case reveals, with MIB documents parsed, the decoder can format the information correctly. – Lex Li Jun 04 '19 at 16:08

0 Answers0