1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| int main(int argc, char* argv[])
{
SnmpVarBindList snmpVarList;
AsnInteger errorStatus,errorIndex;
LPSNMP_MGR_SESSION session;
char resultat[MAX_PATH];
//Initialisation snmpVarList
snmpVarList.list = NULL;
snmpVarList.len = 1;
snmpVarList.list = (SnmpVarBind *)realloc(snmpVarList.list, sizeof(SnmpVarBind) *snmpVarList.len);
//Ouverture de Session
session = SnmpMgrOpen("192.168.2.82","public",1000,3);
if (session!=0)
{
SnmpMgrStrToOid(".1.3.6.1.4.1.11.2.14.11.5.1.10.6.1.2.0.38.241.99.134.128",&snmpVarList.list->name);
//Envoi de la requete
if (SnmpMgrRequest(session,SNMP_PDU_GET,&snmpVarList,&errorStatus,&errorIndex)!=0)
{
if (errorStatus==SNMP_ERRORSTATUS_NOERROR)
{
SnmpUtilPrintAsnAny(&snmpVarList.list->value);
}
}
//Fermeture de la session
SnmpMgrClose(session);
system("PAUSE");
}
return 0;
} |