lextudio / sharpsnmplib

Sharp SNMP Library- Open Source SNMP for .NET
https://sharpsnmp.com
MIT License
356 stars 152 forks source link

8 Bit Data #247

Closed lextudio-support closed 3 hours ago

lextudio-support commented 3 hours ago

Hi I try to get the MAC address from a switch . When I use an standalone MIB-Browser I get the correct MAC "74:44:01:72:E2:37". Now I do "$getmac=Invoke-SNMPget $line.IP $OID" And then in the debugger: [DBG]: PS C:\BackupNetworkDevices\test>> $getmac.Data tDr?7

Now "tDr?7" translates to 74:44:01:72:3F:37 (same result when I convert $getmac.Data to a byte-array)

Can it be, that the dll has trouble with 8-Bit values (0xE2)? Or am I doing something wrong here?

Thanks for looking into this... Regards Thomas

Original Reported Date: 2013-10-06T04:16:27.813-07:00 Planned For Release: Original CodePlex ID: 7258

lextudio-support commented 3 hours ago

Copied from CodePlex without authors:

You must dive deep enough to see what's the cause of this problem.

You should not call .Data if you want the bytes, as "74 44 01 72 E2 37" in this case is converted to tDr?7, where ? is used to represent a char that failed the conversion. Thus, when you again try to get the bytes from this string, you get the wrong bytes. The data loss occurs when ? char appears, not later in the process.

It is not an issue of #SNMP, but an issue of how you use the library. Please access the underlying bytes of OctetString via GetRaw method directly.

Original Posted Date: 2013-10-06T20:15:45.673-07:00

lextudio-support commented 3 hours ago

Copied from CodePlex without authors:

Of course you are right. Thank you for putting my nose in the right direction. Regards Thomas

Original Posted Date: 2013-10-14T01:14:01.473-07:00

lextudio-support commented 3 hours ago

Original Closed Date: 2013-10-06T20:15:54.533-07:00