已经写好mib文件,并且用mib2c编译成.c和.h文件。我安装的是net-snmp-5.4.1开发包。现在如何将我的mib编译到代理中,使snmpd代理支持我的mib定义的节点?谢谢指点,麻烦提出具体的操作。

解决方案 »

  1.   

    http://bibu.blogchina.com/inc/net_snmp_doc.htm#_Toc116812020我这里还有个mib开发包,邮箱给我,我可以发给你
      

  2.   

    谢谢你的一直大力支持, .
    目前编译过的.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 $
     */
      

  3.   

    以下是编译过的.c文件:
    /*
     * 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;
    }哪位可以对这些代码解读一下?我需要如何接收请求并分析,然后根据分析结果返回请求即发送响应?
    谢谢,交流交流.