www.pudn.com > SnmpExpriment1.rar > Snmp.h


// Snmp1.h: interface for the CSnmp class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_SNMP1_H__CA06E5D7_9923_4E40_8D50_2BE119C4C9D0__INCLUDED_) 
#define AFX_SNMP1_H__CA06E5D7_9923_4E40_8D50_2BE119C4C9D0__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
#include "winsnmp.h" 
#include "stdafx.h" 
 
/*The WinSNMP communications functions provide an interface between  
the calling WinSNMP manager application and the Microsoft WinSNMP implementation.  
The implementation handles communication between the application and other management entities 
*/ 
 
class CSnmp   
{ 
public: 
	CSnmp(); 
	~CSnmp(); 
	 
private: 
	smiLPUINT32 nMajorVersion,nMinorVersion,nLevel,nTranslateMode; 
	smiLPUINT32 nRetransmitMode; 
	HSNMP_SESSION session;// handle to the WinSNMP session  
	CString strErr;		  //store the error information 
	HSNMP_PDU m_hpdu;     // handle to the PDU  
	HSNMP_VBL m_hvbl;     // handle to the variable bindings list  
 
public: 
	int nCount; 
	BOOL sessionID; 
	 
 
public: 
	CreateSession(HWND hWnd,UINT wMsg);//建立会话 
	Send(LPCSTR address,const char* community/*,HSNMP_PDU pdu*/);//发送SNMP包 
	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  
		); 
	CreateVbl(LPCSTR name,smiLPVALUE pvalue); 
	Register(); 
	Receive(LPTSTR *name,smiLPVALUE *value); 
	SetVbl(LPCSTR name);	 
	CloseSnmp();//关闭SNMP会话 
}; 
 
#endif // !defined(AFX_SNMP1_H__CA06E5D7_9923_4E40_8D50_2BE119C4C9D0__INCLUDED_)