From an snmptrap we get an octetstring with the ip address as hex binary digits i.e. 127.0.0.1 would be 4 bytes the first having 127 as value then two zero bytes and the last byte being 1.
In the console this will show up as the ascii equivalent of those characters (i.e. usually garbage unless something printable like 65 which would show up as 'A'). What we actually would like is that it would just show as the ip address.
I looked through the ASL manual but could not find a function to (what in other languages is usually called ord() ) of a character. The only function I could find was hextToString but that just displays the string above with any non-ascii removed.
Unfortunately there isn't an easy straight forward method to convert the Binary data from a string into numbers. The only way to accomplish this is via ASL. I will get you an example script.
I already have an ASL script hooked up to the event but couldn't figure out how to get the underlying numbers from the string. Looking through the ASL manual I didn't find anything else than using substring to get one char, but can't think of way to change that into a number.
Sorry, for the late reply (I was off for a few weeks). Thank you for your script, I studied it (good learning material :-) ) however it seems to turn a string with binary number like '10100010' into a decimal.
My problem is unfortunately that from a trap we get a string where the characters themselves are the decimals so in C++ it would be
RaghuBT
1 Message
2108
0
Posted October 19th, 2016 05:00
Hi Ron,
I think you can use the utility functions of SM_System::SM-System. This object is readily available to ASL.
You can use bitwise operators along with byte conversions to extract all the octets of string.
byteToString byteval
stringToByte str
bitOr v1 v2
bitComplement v
bitRUShift v b
bitRRotate v b
Regards,
Raghu