-
Notifications
You must be signed in to change notification settings - Fork 10
/
Snmp.h
91 lines (72 loc) · 2.68 KB
/
Snmp.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#pragma once
#include <snmp.h>
#include "iphlpapi.h" // Requires the platform SDK
#include "PerfData.h"
#define MAX_INTERFACES 64
class CSnmp {
typedef BOOL (WINAPI *pSnmpExtensionInit)(
IN DWORD dwTimeZeroReference,
OUT HANDLE *hPollForTrapEvent,
OUT AsnObjectIdentifier *supportedView);
typedef BOOL (WINAPI *pSnmpExtensionTrap)(
OUT AsnObjectIdentifier *enterprise,
OUT AsnInteger *genericTrap,
OUT AsnInteger *specificTrap,
OUT AsnTimeticks *timeStamp,
OUT RFC1157VarBindList *variableBindings);
typedef BOOL (WINAPI *pSnmpExtensionQuery)(
IN BYTE requestType,
IN OUT RFC1157VarBindList *variableBindings,
OUT AsnInteger *errorStatus,
OUT AsnInteger *errorIndex);
typedef BOOL (WINAPI *pSnmpExtensionInitEx)(
OUT AsnObjectIdentifier *supportedView);
typedef LPVOID (CALLBACK *SUALLOC)(UINT);
typedef VOID (CALLBACK *SUFREE)(LPVOID);
typedef DWORD (WINAPI *fpGetNumberOfInterfaces)(LPDWORD);
typedef DWORD (WINAPI *fpGetIfEntry)(LPVOID);
typedef DWORD (WINAPI *fpGetInterfaceInfo)(PIP_INTERFACE_INFO, LPDWORD);
typedef int (WINAPI *pSnmpUtilOidFree)(AsnObjectIdentifier *pOid);
typedef int (WINAPI *pSnmpUtilVarBindFree)(SnmpVarBind *pVb);
typedef int (WINAPI *pSnmpUtilOidNCmp)(AsnObjectIdentifier *pOid1,
AsnObjectIdentifier *pOid2,
UINT nSubIds);
typedef int (WINAPI *pSnmpUtilOidCpy)(AsnObjectIdentifier *pOidDst,
AsnObjectIdentifier *pOidSrc);
public:
CSnmp();
~CSnmp();
private:
HINSTANCE m_hInst, m_hInstIpHlp;
pSnmpExtensionInit m_fpExtensionInit;
pSnmpExtensionQuery m_fpExtensionQuery;
fpGetIfEntry m_fpGetIfEntry;
fpGetNumberOfInterfaces m_fpGetNumberOfInterfaces;
fpGetInterfaceInfo m_fpGetInterfaceInfo;
pSnmpUtilOidFree m_fpSnmpUtilOidFree;
pSnmpUtilVarBindFree m_fpSnmpUtilVarBindFree;
pSnmpUtilOidNCmp m_fpSnmpUtilOidNCmp;
pSnmpUtilOidCpy m_fpSnmpUtilOidCpy;
HINSTANCE m_hInstSnmp;
DWORD m_dwInterfaces;
bool m_bUseGetInterfaceInfo;
SUALLOC m_fpSnmpUtilMemAlloc;
SUFREE m_fpSnmpUtilMemFree;
RFC1157VarBindList *m_pvarBindList;
bool m_bUse_iphlpapi;
DWORD m_dwInterfaceArray[MAX_INTERFACES];
CPerfData perfdata;
// Overloaded functions to accommodate Win95
LPVOID SnmpUtilMemAlloc(UINT nSize);
void SnmpUtilMemFree(LPVOID pMem);
public:
bool Init();
bool GetReceivedAndSentOctets(DWORD &pRecv, DWORD &pSent);
void GetInterfaceDescriptions(CStringArray *sArray, CUIntArray *nAdapter);
private:
void GetReceivedAndSentOctets_9x(DWORD &pRecv, DWORD &pSent);
bool GetReceivedAndSentOctets_IPHelper(DWORD &pReceived, DWORD &pSent);
void GetInterfaces();
void ShowSystemError(int nID);
bool CheckNT();
};