用agent++写的snmp代理程序


本程序是用agnt++写的代理端程序,包括get,set请求,和trap发送过程。
资源截图
代码片段和文件信息
// Agent.cpp : Defines the class behaviors for the application.
//

#include “stdafx.h“
#include “Agent.h“

#include “MainFrm.h“
#include “pcap.h“
#include “SNMPAgent.h“

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAgentApp

BEGIN_MESSAGE_MAP(CAgentApp CWinApp)
//{{AFX_MSG_MAP(CAgentApp)
ON_COMMAND(ID_APP_ABOUT OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
//    DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAgentApp construction

CAgentApp::CAgentApp()
{
// TODO: add construction code here
// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CAgentApp object

//全局变量及原型说明
CRITICAL_SECTION g_lock; //同步资源锁
pcap_t * g_fp = NULL;
CSNMPAgent *g_agent = new CSNMPAgent;
UINT StartCapture(LPVOID pParam);
void packet_handler(u_char *pParamconst struct pcap_pkthdr *header
const u_char *pkt_data);
//UINT Analyse(UINT data_length const UCHAR *packet_data);
int AnalysePackage(UINT len const UCHAR *package);

CAgentApp theApp;
int GetConfig();

/////////////////////////////////////////////////////////////////////////////
// CAgentApp initialization

BOOL CAgentApp::InitInstance()
{
AfxEnableControlContainer();

// Standard initialization
// If you are not using these features and wish to reduce the size
//  of your final executable you should remove from the following
//  the specific initialization routines you do not need.

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T(“Local AppWizard-Generated Applications“));


// To create the main window this code creates a new frame window
// object and then sets it as the application‘s main window object.

CMainframe* pframe = new CMainframe;
m_pMainWnd = pframe;

// create and load the frame with its resources

pframe->Loadframe(IDR_MAINframe
WS_OVERLAPPEDWINDOW | FWS_ADDTOtitle NULL
NULL);

// The one and only window has been initialized so show and update it.
//pframe->ShowWindow(SW_SHOW);
pframe->ShowWindow(SW_MINIMIZE);
pframe->UpdateWindow();

//启动监听
LoadAdapter();
GetConfig();

InitializeCriticalSection(&g_lock);

return TRUE;
}

int CAgentApp::ExitInstance() 
{
// TODO: Add your specialized code here and/or call the base class
DeleteCritic

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     目录          0  2006-04-02 11:47  AgentDebug

     文件       4012  2005-11-30 14:43  Agentincludewinpcapittypes.h

     文件       2133  2005-11-30 14:43  Agentincludewinpcapucket_lookup.h

     文件       2113  2005-11-30 14:43  Agentincludewinpcapcount_packets.h

     文件       3963  2005-11-30 14:43  AgentincludewinpcapDevioctl.h

     文件        833  2005-11-30 14:43  AgentincludewinpcapGnuc.h

     文件       5752  2005-11-30 14:43  Agentincludewinpcapip6_misc.h

     文件       4140  2005-11-30 14:43  Agentincludewinpcapmemory_t.h

     文件       2185  2005-11-30 14:43  Agentincludewinpcap
ormal_lookup.h

     文件      48556  2005-11-30 14:43  AgentincludewinpcapNtddndis.h

     文件       1292  2005-11-30 14:43  AgentincludewinpcapNtddpack.h

     文件      21642  2005-11-30 14:43  AgentincludewinpcapPacket32.h

     文件      22732  2005-11-30 14:43  Agentincludewinpcappcap-bpf.h

     文件      13101  2005-11-30 14:43  Agentincludewinpcappcap-int.h

     文件       2292  2005-11-30 14:43  Agentincludewinpcappcap-stdinc.h

     文件      11559  2005-11-30 14:43  Agentincludewinpcappcap.h

     文件      35625  2005-11-30 14:43  Agentincludewinpcappthread.h

     文件      13813  2005-11-30 14:43  Agentincludewinpcap
emote-ext.h

     文件       4726  2005-11-30 14:43  Agentincludewinpcapsched.h

     文件       4265  2005-11-30 14:43  Agentincludewinpcapsemaphore.h

     文件       2969  2005-11-30 14:43  Agentincludewinpcap cp_session.h

     文件      10659  2005-11-30 14:43  Agentincludewinpcap ime_calls.h

     文件       6060  2005-11-30 14:43  Agentincludewinpcap me.h

     文件       3364  2005-11-30 14:43  AgentincludewinpcapWin32-Extensions.h

    ..AD...         0  2006-04-02 11:47  Agentincludewinpcap

     文件      20084  2005-11-30 14:43  Agentincludesnmp_ppaddress.h

     文件      17835  2005-11-30 14:43  Agentincludesnmp_ppasn1.h

     文件      20460  2005-11-30 14:43  Agentincludesnmp_ppauth_priv.h

     文件       3580  2005-11-30 14:43  Agentincludesnmp_ppcollect.h

     文件       7438  2005-11-30 14:43  Agentincludesnmp_ppcollect1.h

............此处省略121个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)