trehn / hnmp

High-level Python SNMP library
ISC License
49 stars 16 forks source link

Issue with MAC address return #17

Open deveshmanish opened 4 years ago

deveshmanish commented 4 years ago

The current implementation does not return the correct mac address. In my scenario the MAC address returned is in Hex-String format. It throws a

TypeError: 'str' object cannot be interpreted as an integer

Which is correct since the mac_address function uses ":".join([hex(c).lstrip("0x").zfill(2) for c in string]) which is correct since hex(c) expects an integer not a string. I tried bypassing the function all together but that too doesn't return the expected output. The mac address seems to be encoded.

Is there a way to get the actual value returned by the SNMP get/walk? In my own implementation of mac_address the correct address is returned by the following code: ':'.join(mac[i:i + 2] for i in range(2, 12, 2)) But this too won't work unless the actual raw value or value.prettyPrint() is passed to it.

trehn commented 2 years ago

Can you provide an example repr() or the returned value? Ideally from PySNMP as well.