Receiving
ret=SnmpRecvMsg (hSession, & amp; HSrcAgent, & amp; HDstAgent, & amp; HContext, & amp; HRecvPDU);
Ret=SnmpGetPduData (hRecvPDU, & amp; PduType, & amp; RequestId, & amp; The status, & amp; The index, & amp; HRecvVbl);
Processing and reply
count=SnmpCountVbl (hRecvVbl);
I=SNMP_SYNTAX_INT;
for(i=1; i<=count; I++)
{
Ret=SnmpGetVb (hRecvVbl, I, & amp; The name, & amp; Value);
if(ret !=SNMPAPI_SUCCESS)
{
Printf (" Error: % d \ n ", SnmpGetLastError (hSession));
continue;
}
Ret=SnmpOidToStr (& amp; Name, sizeof (buffer), buffer);
If (ret==SNMPAPI_FAILURE)
{
Printf (" Error1: % d \ n ", SnmpGetLastError (hSession));
continue;
}
Type: name: printf (" % s % d \ n ", buffer, the value. The syntax).
If (value. The syntax==SNMP_SYNTAX_INT)
{
Printf (" \ n Value: % d ", Value, Value, sNumber);
}
}
SmiOCTETS obj.
HSNMP_VBL HVBL;
HSNMP_PDU pdu.
Obj. Len=strlen (community);
Obj. PTR=(smiLPBYTE) community;
HContext=SnmpStrToContext (hSession, & amp; Obj);
HVBL=SnmpCreateVbl (hSession, NULL, NULL);
Ret=SnmpStrToOid (". 1.3.6.1.2.1.25.2.2.0 ", & amp; Name);
Ret=SnmpSetVb (HVBL, 0, & amp; The name, NULL);
Pdu=SnmpCreatePdu (hSession, SNMP_PDU_RESPONSE, 0, 0, 0, HVBL);
Ret=SnmpSendMsg (hSession hDstAgent, hSrcAgent, hContext, pdu);
CodePudding user response:
caught?CodePudding user response: