So far it works only for SNMPv1 and SNMP v2c ... I will try to add support for SNMPv3 in the future
If you want to test this UDF please download the au3 file. Because of some long lines the code display will truncate many of the lines and that will show on the script if you use copy-paste.
A long time ago I've made a "promise" to ptrex that I will share my findings on SNMP. Now I do have some findings
I did a little work on this UDF; I know there is more to SNMP than included in this UDF; there are still parts to be added and information.
I provide this UDF "as is"; I will work to improve it in the future and I will try to help others as much as possible.
A big credit for this goes to @ptrex; I've used some of his work in writing this UDF and the example.
Credit goes also to @nobur for fixing version 1.7.3
I know that there might be some bugs but only the feedback can help me discover them.
[03/10/2008] Finally I've got the code to work 100% correct on all my tests. I have redone quite a significant bit of the code and added a couple more functions.
[30/12/2008] UDF code rewritten. ... not easy but I had to do it in order to add support for Multiple OIDs and packet lenghts of 256 and over.
Still compatible with SNMP v1 and SNMP v2c ; maybe in the future I will be able to work a little more on it.
UDF and example script updated.
[10/03/2009] Important changes again:
- added support for GetBulk requests (get a large amount of OID contents returned in the same packet) The amount of OIDs returned can be specified as a parameter. It can work with a large amount of OIDs but I recommend using it for 50-60 OIDs (some OID can be very long and it might reach and go over all array limits in the udf); anyway - you can play with the global variables (array dimension) in the udf and see the results.
For 50 OIDs it is safe
- Changed the return of function _ShowSNMPReceived -> the $SNMP_Received array is still there (it has an "educational" value and it is still built but it is never returned) but the function now returns another array $SNMP_Util which has only OID and clear values inside -> easier to work with this array.
- Updated example script: 4 different requests in the same script
[30/03/2009]
Bug fix: OID numbers above 16384 were incorrectly decoded - changed "_SNMPExtractOID" function to correct this bug. (thanks Sjee)
[02/04/2009]
Bug fix: Fixed the encoding of OID numbers over 128
[26/08/2010]
SNMP_UDF v 1.4 released:
Fixed: SetRequest is now working - by error I have assumed that it works :> and it wasn't - thanks GSM
Still no hope for SNMP v3 (sorry)
[31/08/2010]
SNMP_UDF v 1.4.1 released:
Bug Fix: wrong value returned for OID -> thanks GSM again
[09/09/2010]
It seems that I forgot a debugging MsgBox inside the UDF - fixed that
[01/10/2010]
SNMP_UDF v 1.5 released:
Completely re-written the UDF. Minor change in $SNMP_Util structure (error code is now held in $SNMP_Util[0][1])
- fixed many issues with SetRequest and Bulk querries
- I didn't have much time to test it so there might be errors (please let me know)
[04/10/2010]
Fixed an error (a function was missing from UDF) - thanks @AleksanderWalesa
SNMP_UDF v 1.5:
- SNMP version supported: v1, v2c
- Data types returned (in clear): counter, gauge, string, integer, IP Address, OID, Time Ticks
- returns an array with the following: Request Id, Error Index, Error, Data Type, Data Length, Data Value and Data Value in "clear" form
- the returned array has many more information; you can see effectively the structure of SMNP packet
- Multiple OIDs support; you can build packets using up to 8 OIDs by passing an array of OIDs as parameter (one request for 8 OIDs) and decode packets having even more OIDs
- support for "long" packets
- support for GetBulk requests
- support for SetRequest
[01/04/2011]
Removed support for OID Arrays; there wasn't enough value in this feature - it was only complicating the UDF and debugging. Packets are generated fast enough so the performance loss will be minimum.
SNMP_UDF v 1.5.1:
- removed support for OID arrays
[29/08/2011]
This update is very useful if you have ever used $SNMP_Received array (declared to have "educational purpose") or if you will work with enterprise-specific OIDs if you didn't, you won't notice any difference.
This UDF works 100% on non-enterprise specific OID's - when it comes to these, some other rules may apply - this is the purpose of this update.
Added a new element in $SNMP_Received array - the new element is a string with all PDU's elements delimited by "|" (data type|length|OID|data type|length|util data)
This was necessary to offer more flexibility because some enterprise-specific have different decoding rules. Having the raw data in a delimited string will help you "customize" how it is decoded.
SNMP_UDF v 1.6:
- added a new element in $SNMP_Received
[30/08/2011]
Minor bug fix - v1.6 was giving errors ... bad array handling :|
Fixed that in 1.6.1
I cannot get the "full editor" to work so - check the last post for the new updated version.
I will remove the link to 1.6 for now.
[02/11/2011]
New version 1.6.2
Added Error control - when the querry returns an error - it will display an associated error message and will exit - no more crashes.
[07/11/2011] - New version SNMP_UDF v 1.7
Completely rewritten - no more arrays used to build/decode SNMP packets - now using strings only. I guess a dramatical speed increase can be noticed.
I didn't test it fully so if there are any bugs - please let me know and I will fix them.
[13/01/2012] - New (minor) version SNMP_UDF v 1.7.1
I had to change it a little bit to make it work with AutoIt 3.3.8.0
StringLen was buggy and I had to fix all script lines involving this function.
[16/01/2012] - New (minor) version SNMP_UDF v 1.7.2
I can't remember what I have fixed in this but it was definitely fixing something
[27/06/2012] - Another New (minor) version SNMP_UDF v 1.7.3
A bug in the _SysObjIDToHexString function was affecting encoding big numbers and another one affecting OIDs returned.
[17/10/2012] - Another New (minor) version SNMP_UDF v 1.7.4
A bug about null value corrected by @nobur
@nobur posted a SNMP Walk function http://www.autoitscript.com/forum/topic/81687-snmp-udf-for-snmpv1-and-snmpv2c/page__st__120#entry1002619
Thanks nobur
To DO:
- add support for SNMP v3
Latest versions attached.
Attached files:
snmp_UDF-v1.7.4.au3 21.64K
362 downloads
snmp_packetgen_1.7.4.au3 1.79K
264 downloads
snmp_packetgen_write_1.7.4.au3 2.29K
218 downloads
Edited by enaiman, 16 October 2012 - 11:03 PM.





