有大佬注释下代码吗?特别是有关snmp的
源码如下:
CMibBrowserView::OnGet()
{
HTREEITEM hNode; MibNode* pNodeData;
CString ipadd,community,oidstr; m_ipadd.GetWindowText(ipadd); if(m_ipadd.IsBlank())
{
AfxMessageBox("IP 地址错误!"); return ;
}
m_ipadd.GetWindowText(ipadd); m_community.GetWindowText(community); m_oid.GetWindowText(oidstr); ipadd+=":161";
Snmp::socket_startup();
UdpAddress address((LPCTSTR)ipadd); Oid oid((LPCTSTR)oidstr); snmp_version version=version1;
int status;
Snmp snmp(status, 0, false); Pdu pdu;
Vb vb; vb.set_oid(oid); pdu += vb;
CTarget ctarget(address); ctarget.set_version(version); ctarget.set_retry(1); ctarget.set_timeout(100);
ctarget.set_readcommunity((LPCTSTR)community); SnmpTarget *target;
target = &ctarget;
status = snmp.get(pdu, *target);
if (status == SNMP_CLASS_SUCCESS)
{
pdu.get_vb(vb,0);
CString reply_oid=vb.get_printable_oid(); CString reply_value=vb.get_printable_value(); hNode=SearchNode(reply_oid);
if (hNode!=NULL)
{
pNodeData=(MibNode*)m_tree.GetItemData(hNode); reply_oid.Replace((LPCTSTR)pNodeData->POid,
(LPCTSTR)m_tree.GetItemText(hNode)); if (pNodeData->PInteger!=NULL)
{
POSITION index=pNodeData->PInteger->Find(reply_value); if (index!=NULL)
{
pNodeData->PInteger->GetNext(index); reply_value=pNodeData->PInteger->GetNext(index);
}
}
}
if (m_list.GetItemCount()>0) m_list.DeleteAllItems();
int row=m_list.InsertItem(1,reply_oid); m_list.SetItemText(row,1,reply_value);
}
Snmp::socket_cleanup();
CMainFrame *pF=(CMainFrame *)AfxGetMainWnd(); int num=m_list.GetItemCount(); oidstr.Format("%d",num);
oidstr="共取回 "+oidstr+" 个对象"; pF->m_wndStatusBar.SetPaneText(0,oidstr);
}