Greetings gentlemen!
What I need is to create SNMP agent for monitoring our software systems.
I’m using "winsnmp" for writing my SNMP Extension Agent in Visual C++. The output is x64 DLL, which is registered in Windows registry, loaded by "SNMP Service" and properly executed. My SNMP agent is able to handle "SNMP_PDU_GET","SNMP_PDU_GETNEXT", "SNMP_PDU_SET" requests as well as generate SNMP Traps.
Things are great so far, everything is working great.
But now I need to handle complex data type "sequence" which is presented as "AsnSequence" type or "ASN_SEQUENCE" type constant in "winsnmp". The requirement is to reply
to SNMP manager with table, containing multiple records. The table has specific structure, here’s the sample MIB fragment:
hrTestTable OBJECT-TYPE SYNTAX SEQUENCE OF HrTestEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION"sequence" ::= { BMS_ibm_wsmq 3 } hrTestEntry OBJECT-TYPE SYNTAX HrTestEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION"Table row" INDEX { hrTestIndex } ::= { hrTestTable 1 } HrTestEntry ::= SEQUENCE { hrTestIndex Integer32, hrTestType AutonomousType, hrTestDescr DisplayString } hrTestIndex OBJECT-TYPE SYNTAX Integer32 (1..2147483647) MAX-ACCESS read-only STATUS current DESCRIPTION"indexColumn1" ::= { hrTestEntry 1 } hrTestType OBJECT-TYPE SYNTAX AutonomousType MAX-ACCESS read-only STATUS current DESCRIPTION"column1" ::= { hrTestEntry 2 } hrTestDescr OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION"column2" ::= { hrTestEntry 3 }
Once entire table is requested by SNMP manager, the agent receives "SNMP_PDU_GETNEXT" request:
BOOL SNMP_FUNC_TYPE SnmpExtensionQuery(BYTE operation, SnmpVarBindList *variableBindings, AsnInteger32 *errorStatus, AsnInteger32 *errorIndex) {… for (unsigned int index = 0; index < variableBindings->len; index++) { *errorStatus = SNMP_ERRORSTATUS_NOERROR; switch (operation) {… case SNMP_PDU_GETNEXT: … *errorStatus = GET_SEQUENCE(&variableBindings->list[index]);… … }; …
Variable
"&variableBindings->list[index].name" points to "hrTestIndex" at "index=0"
"&variableBindings->list[index].name" points to "hrTestType" at "index=1
"&variableBindings->list[index].name" points to "hrTestDescr" at "index=2"
For all these cases "&variableBindings->list[index].value. asnType" is "ASN_NULL"
I suspect, that producing response "&variableBindings->list[index].value.asnType" has to initialized with "ASN_SEQUENCE" and "&variableBindings->list[index].value.asnValue.sequence" should be initialized
with "AsnSequence"
So, am I right? How do I initialize instance of "AsnSequence" and fill it with data then?
Thanks.
nya-nya!