Snmp.h
上传用户:yfy060102
上传日期:2021-05-22
资源大小:60k
文件大小:2k
- #if !defined(AFX_SNMP1_H__25A74F53_3E27_496B_AF07_6745A77B07B8__INCLUDED_)
- #define AFX_SNMP1_H__25A74F53_3E27_496B_AF07_6745A77B07B8__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- // Snmp1.h : header file
- #include "stdafx.h"
- #include "winsnmp.h"
- #include <afxmt.h>
- class CSnmp
- {
- public:
- CSnmp();
- ~CSnmp();
-
- private:
- smiUINT32 nMajorVersion,nMinorVersion,nLevel,nTranslateMode;
- smiUINT32 nRetransmitMode;
- HSNMP_SESSION m_hSession;
- CString strErr;
- int state;
- HSNMP_PDU m_hpdu;
- HSNMP_VBL m_hvbl;
- protected:
- CEvent m_Event; //Event for blocking read
- static SNMPAPI_STATUS CALLBACK SnmpCallback(
- HSNMP_SESSION hSession, // handle to the WinSNMP m_hSession
- HWND hWnd, // handle to the notification window
- UINT wMsg, // window notification message number
- WPARAM wParam, // type of notification
- LPARAM lParam, // request identifier of PDU
- LPVOID lpClientData); // optional application-defined data
- public:
- smiINT PDU_type;
- smiINT32 request_id;
- smiINT error_status;
- smiINT error_index;
- CString strSrcEntity;
- CString strDstEntity;
- CString m_community;
- int nCount;
- CString m_strOid[10]; //存放当前的请求OID,和响应的OID
- smiVALUE m_value[10]; //存放相应包中与OID相应的值
- CString m_strValue[10]; //将相应的值转换为字符串并存放在这里
- public:
- BOOL IsCreated();
- BOOL WaitForResponse();
- void ReInitial();
- void ReportError(DWORD dwError);
- BOOL CreateSession();
- BOOL Send(LPCSTR address/*,const char* community,HSNMP_PDU pdu*/);
- BOOL CreatePdu(
- smiINT PDU_type, // PDU type
- smiINT32 request_id, // PDU request identifier
- smiINT error_status, // PDU error status, unless type is SNMP_PDU_GETBULK
- smiINT error_index // PDU error index, unless type is SNMP_PDU_GETBULK
- //HSNMP_VBL varbindlist // handle to the variable bindings list
- );
- BOOL CreateVbl(LPCSTR name,smiLPVALUE pvalue);
- BOOL Register();
- BOOL Receive();
- BOOL Receive(CString name[],smiVALUE value[]);
- BOOL SetVbl(LPCSTR name,smiLPCVALUE value);
- };
- /////////////////////////////////////////////////////////////////////////////
- //{{AFX_INSERT_LOCATION}}
- // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
- #endif // !defined(AFX_SNMP1_H__25A74F53_3E27_496B_AF07_6745A77B07B8__INCLUDED_)