Bonjour,j'ai trouvé un problème dans l'utilisation des fonctions SNMP en particulier dans l'appel de ces fonctions un message d'erreur apparaît:"error C2059: erreur de syntaxe : '__stdcall'".
En fait, je veux utiliser le protocole SNMPet voilà ce que j'ai fait:
//snmp_pdu.h

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
 
#pragma once
#include "mgmtapi.h"
#include "winsnmp.h"
#include "snmp.h"
#include <iostream>
#include <string>
class snmp_pdu
{
private:LPSTR lpAgentAddress;
LPSTR lpAgentCommunity;
int ntimeout;int nretries;
RFC1157VarBindList variableBindings;
public:snmp_pdu(LPSTR,LPSTR);
LPSNMP_MGR_SESSION ouvrir_session();
SNMPAPI_STATUS get_variable(LPSNMP_MGR_SESSION);
int obtenir_oid(char*string);
~snmp_pdu(void);
};
//snmp_pdu.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
34
35
36
37
38
39
 
 
#include "StdAfx.h"
#include "snmp_pdu.h"
#using <mscorlib.dll>
#define WINAPI __stdcall
snmp_pdu::snmp_pdu(LPSTR lpAgentAddress1,LPSTR lpAgentCommunity1){
lpAgentAddress=(LPSTR)SNMP_malloc(strlen(lpAgentAddress1));
strcpy(lpAgentAddress,lpAgentAddress1);
lpAgentCommunity1=(LPSTR)SNMP_malloc(strlen(lpAgentCommunity1));   strcpy(lpAgentCommunity,lpAgentCommunity1);
ntimeout=NULL;
nretries=NULL;
//ntimeout=WINAPI::SnmpGetTimeout(lpAgentAddress,NULL,NULL);
//nretries=WINAPI::SnmpGetRetry(lpAgentAddress,NULL,NULL);
variableBindings.list=NULL;
variableBindings.len=0;
}
LPSNMP_MGR_SESSION snmp_pdu::ouvrir_session()
{
LPSNMP_MGR_SESSION session;
if((session==WINAPI::SnmpMgrOpen(lpAgentAddress,lpAgentCommunity,ntimeout,nretries)==NULL))return NULL;
return session;
}
snmp_pdu::obtenir_oid(char *string)
{
AsnObjectIdentifier reqObject;
if(!WINAPI::SnmpMgrStrToOid(string,&reqObject))return 1;
else{variableBindings.len++;
if((variableBindings.list==(RFC1157VarBind *)SNMP_realloc(variableBindings.list,sizeof(RFC1157VarBind) * variableBindings.len)==NULL))return 1;
variableBindings.list[variableBindings.len-1].name=reqObject;variableBindings.list[variableBindings.len-1].value.asnType=ASN_NULL;
}
return 0;
}
snmp_pdu::~snmp_pdu()
{
delete(lpAgentAddress);
delete(lpAgentCommunity);
delete(&variableBindings);
}
Merci d'avance.