已经写好mib文件,并且用mib2c编译成.c和.h文件。我安装的是net-snmp-5.4.1开发包。现在如何将我的mib编译到代理中,使snmpd代理支持我的mib定义的节点?谢谢指点,麻烦提出具体的操作。
解决方案 »
- 在VC编译器下程序运行有声音,但是在Debug下的打开.exe文件就没有声音?
- 同一工程下两个文件之间通信
- EVC(wince)如何开发不规则窗体(请成功过的朋友指教)?
- 怎样用VC开发一个上传文件时 显示上传进度的进度条
- 成都凉水井变温泉!!!
- vc或vb如何同java程序交换数据?
- system and winexec and shellexec(ex)又遇到无法理解的难题????
- delphi中调用com 为什么会出现“不支持此接口”的错误!
- 不好意思,再问一个问题?\n在程序中用SQLConfigDatasource(...)注册了一个用户数据源,并确认返回1,即注册成功,进控制面板看也有数据源名,却不见路径,如何判断确实注册成功?\n另外如何在程序中检测是否有相同的数据源已经注册?能枚举吗?
- 请问再学习COM或COM+还有用吗?
- 关于在toolbar中显示图标的问题
- 如何使用WMI编写DLL访问硬件信息(开发环境VC++6.0)
目前编译过的.c .h文件我按照readme.win32所述放在了netsnmplibs目录下,修改相关conf文件,重新编译该动态库和snmpd执行文件.然后运行snmpd后,另起cmd,执行相关snmpget 请求自定义mib节点信息的操作,代理可以接收到相关的请求.
现在就是不知道如何在.c文件的框架中加入自己的代码.以下是编译过的.h文件:
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $
*/
#ifndef BRITBBE_H
#define BRITBBE_H/* function declarations */
void init_BritBBE(void);
Netsnmp_Node_Handler handle_BitSyn;#endif /* BRITBBE_H */
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $
*/
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $
*/#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "BritBBE.h"
/** Initializes the BritBBE module */
void
init_BritBBE(void)
{
static oid BitSyn_oid[] = { 1,3,6,1,4,1,1,1 };
static oid FrmSyn_oid[] = { 1,3,6,1,4,1,1,2 };
DEBUGMSGTL(("BritBBE", "Initializing\n"));
netsnmp_register_scalar(
netsnmp_create_handler_registration("BitSyn", handle_BitSyn,
BitSyn_oid, OID_LENGTH(BitSyn_oid),
HANDLER_CAN_RONLY
));
}int
handle_BitSyn(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
/* We are never called for a GETNEXT if it's registered as a
"instance", as it's "magically" handled for us. */ /* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode) { case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
(u_char *) /* XXX: a pointer to the scalar's data */,
/* XXX: the length of the data in bytes */);
break;
default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_BitSyn\n", reqinfo->mode );
return SNMP_ERR_GENERR;
} return SNMP_ERR_NOERROR;
}哪位可以对这些代码解读一下?我需要如何接收请求并分析,然后根据分析结果返回请求即发送响应?
谢谢,交流交流.