コード例 #1
0
ファイル: table_iterator.c プロジェクト: AllardJ/Tomato
/** registers a table after attaching it to a table_iterator helper */
int
netsnmp_register_table_iterator(netsnmp_handler_registration *reginfo,
                                netsnmp_iterator_info *iinfo)
{
    netsnmp_inject_handler(reginfo,
                           netsnmp_get_table_iterator_handler(iinfo));
    if (!iinfo)
        return SNMPERR_GENERR;

#ifndef NOT_SERIALIZED
    netsnmp_inject_handler(reginfo, netsnmp_get_serialize_handler());
#endif
    return netsnmp_register_table(reginfo, iinfo->table_reginfo);
}
コード例 #2
0
int
netsnmp_register_scalar_group(netsnmp_handler_registration *reginfo,
                              oid first, oid last)
{
    reginfo->rootoid = realloc(reginfo->rootoid,
                              (reginfo->rootoid_len+2) * sizeof(oid) );
    reginfo->rootoid[ reginfo->rootoid_len   ] = 0;
    reginfo->rootoid[ reginfo->rootoid_len+1 ] = 0;

    netsnmp_inject_handler(reginfo, netsnmp_get_instance_handler());
    netsnmp_inject_handler(reginfo, netsnmp_get_scalar_handler());
    netsnmp_inject_handler(reginfo, netsnmp_get_scalar_group_handler(first, last));
    return netsnmp_register_serialize(reginfo);
}
コード例 #3
0
ファイル: scalar.c プロジェクト: sjz6578/net-snmp-5.1.4.2
int
netsnmp_register_scalar(netsnmp_handler_registration *reginfo)
{
    /*
     * Extend the registered OID with space for the instance subid
     * (but don't extend the length just yet!)
     */
    reginfo->rootoid = realloc(reginfo->rootoid,
                              (reginfo->rootoid_len+1) * sizeof(oid) );
    reginfo->rootoid[ reginfo->rootoid_len ] = 0;

    netsnmp_inject_handler(reginfo, netsnmp_get_instance_handler());
    netsnmp_inject_handler(reginfo, netsnmp_get_scalar_handler());
    return netsnmp_register_serialize(reginfo);
}
コード例 #4
0
/** Initialize the dot11WtpKeyConfigTable table by defining its contents and how it's structured */
void
initialize_table_dot11WtpKeyConfigTable(void)
{
    static oid dot11WtpKeyConfigTable_oid[128] = {0};
    size_t dot11WtpKeyConfigTable_oid_len   = 0;
	mad_dev_oid(dot11WtpKeyConfigTable_oid,WTPKEYCONFIGTABLE,&dot11WtpKeyConfigTable_oid_len,enterprise_pvivate_oid);
    netsnmp_handler_registration    *reg;
    netsnmp_iterator_info           *iinfo;
    netsnmp_table_registration_info *table_info;

    reg = netsnmp_create_handler_registration(
              "dot11WtpKeyConfigTable",     dot11WtpKeyConfigTable_handler,
              dot11WtpKeyConfigTable_oid, dot11WtpKeyConfigTable_oid_len,
              HANDLER_CAN_RWRITE
              );

    table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
    netsnmp_table_helper_add_indexes(table_info,
                           ASN_INTEGER,  /* index: CipherKeyIndex */
                           0);
    table_info->min_column = WTPKEYCONFMIN;
    table_info->max_column = WTPKEYCONFMAX;
    
    iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );
    iinfo->get_first_data_point = dot11WtpKeyConfigTable_get_first_data_point;
    iinfo->get_next_data_point  = dot11WtpKeyConfigTable_get_next_data_point;
    iinfo->table_reginfo        = table_info;
    
    netsnmp_register_table_iterator( reg, iinfo );
	netsnmp_inject_handler(reg,netsnmp_get_cache_handler(DOT1DTPFDBTABLE_CACHE_TIMEOUT,dot11WtpKeyConfigTable_load, dot11WtpKeyConfigTable_removeEntry,
							dot11WtpKeyConfigTable_oid, dot11WtpKeyConfigTable_oid_len));

    /* Initialise the contents of the table here */
}
コード例 #5
0
ファイル: table_tdata.c プロジェクト: 274914765/C
/** registers a tdata-based MIB table */
int
netsnmp_tdata_register (netsnmp_handler_registration * reginfo,
                        netsnmp_tdata * table, netsnmp_table_registration_info * table_info)
{
    netsnmp_inject_handler (reginfo, netsnmp_get_tdata_handler (table));
    return netsnmp_container_table_register (reginfo, table_info, table->container, TABLE_CONTAINER_KEY_NETSNMP_INDEX);
}
コード例 #6
0
ファイル: snmp_mib.c プロジェクト: prak5192/C_Project
/** Initializes the snmp module */
void
init_snmp_mib(void)
{
    DEBUGMSGTL(("snmp", "Initializing\n"));

    netsnmp_register_scalar_group(
      netsnmp_create_handler_registration(
	"mibII/snmp", handle_snmp, snmp_oid, OID_LENGTH(snmp_oid),
	HANDLER_CAN_RONLY), 1, 32);
    {
        const oid snmpEnableAuthenTraps_oid[] = { 1, 3, 6, 1, 2, 1, 11, 30, 0 };
	static netsnmp_watcher_info enableauthen_info;
        netsnmp_handler_registration *reg =
            netsnmp_create_update_handler_registration(
                "mibII/snmpEnableAuthenTraps",
                snmpEnableAuthenTraps_oid,
                OID_LENGTH(snmpEnableAuthenTraps_oid),
                HANDLER_CAN_RWRITE, &snmp_enableauthentrapsset);
        netsnmp_inject_handler(reg, netsnmp_get_truthvalue());
        netsnmp_register_watched_instance(
            reg,
            netsnmp_init_watcher_info(
		&enableauthen_info,
                &snmp_enableauthentraps, sizeof(snmp_enableauthentraps),
                ASN_INTEGER, WATCHER_FIXED_SIZE));
    }

#ifdef USING_MIBII_SYSTEM_MIB_MODULE
    if (++system_module_count == 3)
        REGISTER_SYSOR_TABLE(system_module_oid, system_module_oid_len,
                             "The MIB module for SNMPv2 entities");
#endif
    snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
                           snmp_enableauthentraps_store, NULL);
}
コード例 #7
0
ファイル: instance.c プロジェクト: OPSF/uClinux
static
netsnmp_handler_registration *
get_reg(const char *name,
        const char *ourname,
        const oid * reg_oid, size_t reg_oid_len,
        void *it,
        int modes,
        Netsnmp_Node_Handler * scalarh, Netsnmp_Node_Handler * subhandler,
        const char *contextName)
{
    netsnmp_handler_registration *myreg;
    netsnmp_mib_handler *myhandler;

    if (subhandler) {
        myreg =
            netsnmp_create_handler_registration(name,
                                                subhandler,
                                                reg_oid, reg_oid_len,
                                                modes);
        myhandler = netsnmp_create_handler(ourname, scalarh);
        myhandler->myvoid = (void *) it;
        netsnmp_inject_handler(myreg, myhandler);
    } else {
        myreg =
            netsnmp_create_handler_registration(name,
                                                scalarh,
                                                reg_oid, reg_oid_len,
                                                modes);
        myreg->handler->myvoid = (void *) it;
    }
    if (contextName)
        myreg->contextName = strdup(contextName);
    return myreg;
}
コード例 #8
0
/** Initialize the dot11WtpWirelessCapStatTable table by defining its contents and how it's structured */
void
initialize_table_dot11WtpWirelessCapStatTable(void)
{
    static oid dot11WtpWirelessCapStatTable_oid[128] = {0};
    size_t dot11WtpWirelessCapStatTable_oid_len   = 0;	
	mad_dev_oid(dot11WtpWirelessCapStatTable_oid,WTPCAPSTATTABLE,&dot11WtpWirelessCapStatTable_oid_len,enterprise_pvivate_oid);
    netsnmp_handler_registration    *reg;
    netsnmp_iterator_info           *iinfo;
    netsnmp_table_registration_info *table_info;

    reg = netsnmp_create_handler_registration(
              "dot11WtpWirelessCapStatTable",     dot11WtpWirelessCapStatTable_handler,
              dot11WtpWirelessCapStatTable_oid, dot11WtpWirelessCapStatTable_oid_len,
              HANDLER_CAN_RONLY
              );

    table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
    netsnmp_table_helper_add_indexes(table_info,
                           ASN_OCTET_STR,  /* index: wtpMacAddr */
                           ASN_INTEGER,  /* index: wtpWirelessIfIndex */
                           0);
    table_info->min_column = WTPCAPSTATTABLE_MIN_COLUMN;
    table_info->max_column = WTPCAPSTATTABLE_MAX_COLUMN;
    
    iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );
    iinfo->get_first_data_point = dot11WtpWirelessCapStatTable_get_first_data_point;
    iinfo->get_next_data_point  = dot11WtpWirelessCapStatTable_get_next_data_point;
    iinfo->table_reginfo        = table_info;
    
    netsnmp_register_table_iterator( reg, iinfo );
	netsnmp_inject_handler(reg,netsnmp_get_cache_handler(DOT1DTPFDBTABLE_CACHE_TIMEOUT,dot11WtpWirelessCapStatTable_load, dot11WtpWirelessCapStatTable_removeEntry,dot11WtpWirelessCapStatTable_oid, dot11WtpWirelessCapStatTable_oid_len));
    /* Initialise the contents of the table here */
}
コード例 #9
0
/** Initialize the dot11QosWirelessTable table by defining its contents and how it's structured */
void
initialize_table_dot11QosWirelessTable(void)
{
    static oid dot11QosWirelessTable_oid[128] = {0};
    size_t dot11QosWirelessTable_oid_len   = 0;	
	mad_dev_oid(dot11QosWirelessTable_oid,QOSWIRELESSTABLE,&dot11QosWirelessTable_oid_len,enterprise_pvivate_oid);
    netsnmp_handler_registration    *reg;
    netsnmp_iterator_info           *iinfo;
    netsnmp_table_registration_info *table_info;

    reg = netsnmp_create_handler_registration(
              "dot11QosWirelessTable",     dot11QosWirelessTable_handler,
              dot11QosWirelessTable_oid, dot11QosWirelessTable_oid_len,
              HANDLER_CAN_RWRITE
              );

    table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
    netsnmp_table_helper_add_indexes(table_info,
                           ASN_INTEGER,  /* index: globalWtpID */
                           ASN_INTEGER,  /* index: RadioLocalID */
                           ASN_INTEGER,  /* index: QosType */
                           0);
    table_info->min_column = QOSWIRELESSMIN;
    table_info->max_column = QOSWIRELESSMAX;
    
    iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );
    iinfo->get_first_data_point = dot11QosWirelessTable_get_first_data_point;
    iinfo->get_next_data_point  = dot11QosWirelessTable_get_next_data_point;
    iinfo->table_reginfo        = table_info;
    
    netsnmp_register_table_iterator( reg, iinfo );
    
	netsnmp_inject_handler(reg,netsnmp_get_cache_handler(DOT1DTPFDBTABLE_CACHE_TIMEOUT,dot11QosWirelessTable_load, dot11QosWirelessTable_removeEntry,dot11QosWirelessTable_oid, dot11QosWirelessTable_oid_len));
    /* Initialise the contents of the table here */
}
コード例 #10
0
ファイル: table_data.c プロジェクト: Undrizzle/apps
/** registers a handler as a read-only data table
 *  If table_info != NULL, it registers it as a normal table too. */
int
netsnmp_register_read_only_table_data(netsnmp_handler_registration *reginfo,
                                      netsnmp_table_data *table,
                                      netsnmp_table_registration_info *table_info)
{
    netsnmp_inject_handler(reginfo, netsnmp_get_read_only_handler());
    return netsnmp_register_table_data(reginfo, table, table_info);
}
コード例 #11
0
ファイル: instance.c プロジェクト: OPSF/uClinux
/**
 * This function registers an instance helper handler, which is a way of 
 * registering an exact OID such that GENEXT requests are handled entirely
 * by the helper. First need to inject it into the calling chain of the 
 * handler defined by the netsnmp_handler_registration struct, reginfo.  
 * The new handler is injected at the top of the list and will be the new
 * handler to be called first.  This function also injects a serialize 
 * handler before actually calling netsnmp_register_handle, registering 
 * reginfo.
 *
 * @param reginfo a handler registration structure which could get created
 *                using netsnmp_create_handler_registration.  Used to register
 *                an instance helper handler.
 *
 * @return
 *      MIB_REGISTERED_OK is returned if the registration was a success.
 *	Failures are MIB_REGISTRATION_FAILED and MIB_DUPLICATE_REGISTRATION.
 */
int
netsnmp_register_instance(netsnmp_handler_registration *reginfo)
{
    netsnmp_mib_handler *handler = netsnmp_get_instance_handler();
    handler->flags |= MIB_HANDLER_INSTANCE;
    netsnmp_inject_handler(reginfo, handler);
    return netsnmp_register_serialize(reginfo);
}
コード例 #12
0
ファイル: table_array.c プロジェクト: 274914765/C
int
netsnmp_table_array_register (netsnmp_handler_registration * reginfo,
                              netsnmp_table_registration_info * tabreg,
                              netsnmp_table_array_callbacks * cb, netsnmp_container * container, int group_rows)
{
    netsnmp_inject_handler (reginfo, netsnmp_create_handler (reginfo->handlerName, netsnmp_table_array_helper_handler));
    return netsnmp_table_container_register (reginfo, tabreg, cb, container, group_rows);
}
コード例 #13
0
int
netsnmp_register_statistic_handler(netsnmp_handler_registration *reginfo,
                                   oid start, int begin, int end)
{
    netsnmp_inject_handler(reginfo,
                           netsnmp_get_statistic_handler(begin - start));
    return netsnmp_register_scalar_group(reginfo, start, start + (end - begin));
}
コード例 #14
0
ファイル: watcher.c プロジェクト: olegto/osx-project-1
int
netsnmp_watched_timestamp_register(netsnmp_mib_handler *whandler,
                                   netsnmp_handler_registration *reginfo,
                                   marker_t timestamp)
{
    whandler->myvoid = (void *)timestamp;
    netsnmp_inject_handler(reginfo, whandler);
    return netsnmp_register_scalar(reginfo);   /* XXX - or instance? */
}
コード例 #15
0
ファイル: ip.c プロジェクト: sjz6578/net-snmp-5.1.4.2
void
init_ip(void)
{
    netsnmp_handler_registration *reginfo;

    /*
     * register ourselves with the agent as a group of scalars...
     */
    DEBUGMSGTL(("mibII/ip", "Initialising IP group\n"));
    reginfo = netsnmp_create_handler_registration("ip", ip_handler,
                            ip_oid, OID_LENGTH(ip_oid), HANDLER_CAN_RONLY);
    netsnmp_register_scalar_group(reginfo, IPFORWARDING, IPROUTEDISCARDS);

    /*
     * .... with a local cache
     *    (except for HP-UX 11, which extracts objects individually)
     */
#ifndef hpux11
    netsnmp_inject_handler( reginfo,
		    netsnmp_get_cache_handler(IP_STATS_CACHE_TIMEOUT,
			   		ip_load, ip_free,
					ip_oid, OID_LENGTH(ip_oid)));
#endif

    /*
     * register (using the old-style API) to handle the IP tables
     */
    REGISTER_MIB("mibII/ipaddr",  ipaddr_variables,
                       variable1, ipaddr_variables_oid);
    REGISTER_MIB("mibII/iproute", iproute_variables,
                       variable1, iproute_variables_oid);
    REGISTER_MIB("mibII/ipmedia", ipmedia_variables,
                       variable1, ipmedia_variables_oid);
    if (++ip_module_count == 2)
        REGISTER_SYSOR_ENTRY(ip_module_oid,
                             "The MIB module for managing IP and ICMP implementations");


    /*
     * for speed optimization, we call this now to do the lookup 
     */
#ifdef IPSTAT_SYMBOL
    auto_nlist(IPSTAT_SYMBOL, 0, 0);
#endif
#ifdef IP_FORWARDING_SYMBOL
    auto_nlist(IP_FORWARDING_SYMBOL, 0, 0);
#endif
#ifdef TCP_TTL_SYMBOL
    auto_nlist(TCP_TTL_SYMBOL, 0, 0);
#endif
#ifdef MIB_IPCOUNTER_SYMBOL
    auto_nlist(MIB_IPCOUNTER_SYMBOL, 0, 0);
#endif
#ifdef solaris2
    init_kernel_sunos5();
#endif
}
コード例 #16
0
ファイル: sctpScalars.c プロジェクト: 274914765/C
/** Initializes the sctp_scalars module */
void init_sctpScalars (void)
{
    netsnmp_handler_registration *reginfo_stats;

    netsnmp_handler_registration *reginfo_params;

    int rc;

    DEBUGMSGTL (("sctp:scalars:init", "Initializing\n"));

    reginfo_stats =
        netsnmp_create_handler_registration ("sctpStats",
                                             sctp_stats_handler,
                                             sctp_stats_oid, OID_LENGTH (sctp_stats_oid), HANDLER_CAN_RONLY);
    if (!reginfo_stats)
        return;

    rc = netsnmp_register_scalar_group (reginfo_stats, SCTP_CURRESTAB, SCTP_DISCONTINUITYTIME);
    if (rc != SNMPERR_SUCCESS)
        return;

    netsnmp_inject_handler (reginfo_stats,
                            netsnmp_get_cache_handler
                            (SCTP_STATS_CACHE_TIMEOUT,
                             netsnmp_access_sctp_stats_load,
                             netsnmp_access_sctp_stats_free, sctp_stats_oid, OID_LENGTH (sctp_stats_oid)));


    reginfo_params =
        netsnmp_create_handler_registration ("sctpParams",
                                             sctp_params_handler,
                                             sctp_params_oid, OID_LENGTH (sctp_params_oid), HANDLER_CAN_RONLY);
    if (!reginfo_params)
        return;

    rc = netsnmp_register_scalar_group (reginfo_params, SCTP_RTOALGORITHM, SCTP_MAXINITRETR);
    if (!rc)
        return;
    netsnmp_inject_handler (reginfo_params,
                            netsnmp_get_cache_handler
                            (SCTP_PARAMS_CACHE_TIMEOUT,
                             netsnmp_access_sctp_params_load,
                             netsnmp_access_sctp_params_free, sctp_params_oid, OID_LENGTH (sctp_params_oid)));
}
コード例 #17
0
ファイル: mgPIDECMTable.c プロジェクト: MrLukass/dvbsnmp
/** Initializes the mgPIDECMTable module */
void
init_mgPIDECMTable(void) {

    /* here we initialize all the tables we're planning on supporting */
    /* create the table structure itself */
    table_set = netsnmp_create_table_data_set("mgPIDECMTable");

    netsnmp_mib_handler *cache_handler;

    /* comment this out or delete if you don't support creation of new rows */
    table_set->allow_creation = 1;

    /***************************************************
     * Adding indexes
     */
    DEBUGMSGTL(("initialize_table_mgPIDECMTable",
            "adding indexes to table mgPIDECMTable\n"));
    netsnmp_table_set_add_indexes(table_set,
            ASN_INTEGER, /* index: mgPIDECMInputNumber */
            ASN_INTEGER, /* index: mgPIDECMServiceNumber */
            ASN_INTEGER, /* index: mgPIDECMPID */
            0);

    DEBUGMSGTL(("initialize_table_mgPIDECMTable",
            "adding column types to table mgPIDECMTable\n"));
    netsnmp_table_set_multi_add_default_row(table_set,
            COLUMN_MGPIDECMINPUTNUMBER, ASN_INTEGER, 0,
            NULL, 0,
            COLUMN_MGPIDECMSERVICENUMBER, ASN_INTEGER, 0,
            NULL, 0,
            COLUMN_MGPIDECMPID, ASN_INTEGER, 0,
            NULL, 0,
            COLUMN_MGPIDECMCAPID, ASN_INTEGER, 0,
            NULL, 0,
            COLUMN_MGPIDECMCASYSTEMID, ASN_INTEGER, 0,
            NULL, 0,
            0);

    /* registering the table with the master agent */
    /* note: if you don't need a subhandler to deal with any aspects
       of the request, change mgPIDECMTable_handler to "NULL" */
    netsnmp_handler_registration *reginfo = netsnmp_create_handler_registration("mgPIDECMTable", NULL,
            mgPIDECMTable_oid,
            OID_LENGTH(mgPIDECMTable_oid),
            HANDLER_CAN_RWRITE);
    netsnmp_register_table_data_set(reginfo, table_set, NULL);

    DEBUGMSGTL(("mgPIDECMTable", "Done initalizing mgPIDECMTable module\n"));

    cache_handler = netsnmp_get_cache_handler(LONGCACHETIMEOUT, /* how long a cache is valid for */
            cache_load, /* a pointer to the cache loading function */
            cache_free, /* a pointer to the cache freeing function */
            mgPIDECMTable_oid, OID_LENGTH(mgPIDECMTable_oid)); /* the OID of the registration point */

    netsnmp_inject_handler(reginfo, cache_handler);
}
コード例 #18
0
ファイル: tcpTable.c プロジェクト: DYFeng/infinidb
void
init_tcpTable(void)
{
    netsnmp_table_registration_info *table_info;
    netsnmp_iterator_info           *iinfo;
    netsnmp_handler_registration    *reginfo;

    DEBUGMSGTL(("mibII/tcpTable", "Initialising TCP Table\n"));
    /*
     * Create the table data structure, and define the indexing....
     */
    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
    if (!table_info) {
        return;
    }
    netsnmp_table_helper_add_indexes(table_info, ASN_IPADDRESS,
                                                 ASN_INTEGER,
                                                 ASN_IPADDRESS,
                                                 ASN_INTEGER, 0);
    table_info->min_column = TCPCONNSTATE;
    table_info->max_column = TCPCONNREMOTEPORT;


    /*
     * .... and iteration information ....
     */
    iinfo      = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
    if (!iinfo) {
        return;
    }
    iinfo->get_first_data_point = tcpTable_first_entry;
    iinfo->get_next_data_point  = tcpTable_next_entry;
    iinfo->table_reginfo        = table_info;
#if defined(WIN32) || defined(solaris2)
    iinfo->flags               |= NETSNMP_ITERATOR_FLAG_SORTED;
#endif /* WIN32 || solaris2 */


    /*
     * .... and register the table with the agent.
     */
    reginfo = netsnmp_create_handler_registration("tcpTable",
            tcpTable_handler,
            tcpTable_oid, OID_LENGTH(tcpTable_oid),
            HANDLER_CAN_RONLY),
    netsnmp_register_table_iterator(reginfo, iinfo);

    /*
     * .... with a local cache
     *    (except for Solaris, which uses a different approach)
     */
    netsnmp_inject_handler( reginfo,
		    netsnmp_get_cache_handler(TCP_STATS_CACHE_TIMEOUT,
			   		tcpTable_load, tcpTable_free,
					tcpTable_oid, OID_LENGTH(tcpTable_oid)));
}
コード例 #19
0
ファイル: cache_handler.cpp プロジェクト: duniansampa/SigLog
int
netsnmp_cache_handler_register(netsnmp_handler_registration * reginfo,
                               netsnmp_cache* cache)
{
    netsnmp_mib_handler *handler = NULL;
    handler = netsnmp_cache_handler_get(cache);

    netsnmp_inject_handler(reginfo, handler);
    return netsnmp_register_handler(reginfo);
}
コード例 #20
0
ファイル: watcher.c プロジェクト: olegto/osx-project-1
int
netsnmp_register_watched_scalar(netsnmp_handler_registration *reginfo,
                                  netsnmp_watcher_info         *watchinfo)
{
    netsnmp_mib_handler *whandler;

    whandler         = netsnmp_get_watcher_handler();
    whandler->myvoid = (void *)watchinfo;

    netsnmp_inject_handler(reginfo, whandler);
    return netsnmp_register_scalar(reginfo);
}
コード例 #21
0
ファイル: udpTable.c プロジェクト: smx-smx/dsl-n55u
void
init_udpTable(void)
{
    netsnmp_table_registration_info *table_info;
    netsnmp_iterator_info           *iinfo;
    netsnmp_handler_registration    *reginfo;

    DEBUGMSGTL(("mibII/udpTable", "Initialising UDP Table\n"));
    /*
     * Create the table data structure, and define the indexing....
     */
    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
    if (!table_info) {
        return;
    }
    netsnmp_table_helper_add_indexes(table_info, ASN_IPADDRESS,
                                     ASN_INTEGER, 0);
    table_info->min_column = UDPLOCALADDRESS;
    table_info->max_column = UDPLOCALPORT;


    /*
     * .... and iteration information ....
     */
    iinfo      = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
    if (!iinfo) {
        return;
    }
    iinfo->get_first_data_point = udpTable_first_entry;
    iinfo->get_next_data_point  = udpTable_next_entry;
    iinfo->table_reginfo        = table_info;
#if defined (WIN32) || defined (cygwin)
    iinfo->flags               |= NETSNMP_ITERATOR_FLAG_SORTED;
#endif /* WIN32 || cygwin */


    /*
     * .... and register the table with the agent.
     */
    reginfo = netsnmp_create_handler_registration("udpTable",
              udpTable_handler,
              udpTable_oid, OID_LENGTH(udpTable_oid),
              HANDLER_CAN_RONLY),
              netsnmp_register_table_iterator(reginfo, iinfo);

    /*
     * .... with a local cache
     */
    netsnmp_inject_handler( reginfo,
                            netsnmp_get_cache_handler(UDP_STATS_CACHE_TIMEOUT,
                                    udpTable_load, udpTable_free,
                                    udpTable_oid, OID_LENGTH(udpTable_oid)));
}
コード例 #22
0
ファイル: instance.c プロジェクト: fenner/net-snmp
static
netsnmp_handler_registration *
get_reg(const char *name,
        const char *ourname,
        const oid * reg_oid, size_t reg_oid_len,
        netsnmp_num_file_instance *it,
        int modes,
        Netsnmp_Node_Handler * scalarh, Netsnmp_Node_Handler * subhandler,
        const char *contextName)
{
    netsnmp_handler_registration *myreg;
    netsnmp_mib_handler *myhandler;

    if (subhandler) {
        myreg =
            netsnmp_create_handler_registration(name, subhandler, reg_oid,
                                                reg_oid_len, modes);
        if (!myreg)
            return NULL;
        myhandler = netsnmp_create_handler(ourname, scalarh);
        if (!myhandler) {
            netsnmp_handler_registration_free(myreg);
            return NULL;
        }
        myhandler->myvoid = it;
	myhandler->data_clone = (void*(*)(void*))netsnmp_num_file_instance_ref;
	myhandler->data_free = (void(*)(void*))netsnmp_num_file_instance_deref;
        if (netsnmp_inject_handler(myreg, myhandler) != SNMPERR_SUCCESS) {
            netsnmp_handler_free(myhandler);
            netsnmp_handler_registration_free(myreg);
            return NULL;
        }
    } else {
        myreg = netsnmp_create_handler_registration(name, scalarh, reg_oid,
                                                    reg_oid_len, modes);
        if (!myreg)
            return NULL;
        myreg->handler->myvoid = it;
	myreg->handler->data_clone
	    = (void *(*)(void *))netsnmp_num_file_instance_ref;
	myreg->handler->data_free
	    = (void (*)(void *))netsnmp_num_file_instance_deref;
    }
    if (contextName) {
        myreg->contextName = strdup(contextName);
        if (!myreg->contextName) {
            netsnmp_handler_registration_free(myreg);
            return NULL;
        }
    }

    return myreg;
}
コード例 #23
0
ファイル: table_iterator.c プロジェクト: 274914765/C
/** 
 * Creates and registers a table iterator helper handler calling 
 * netsnmp_create_handler with a handler name set to TABLE_ITERATOR_NAME 
 * and access method, netsnmp_table_iterator_helper_handler.
 *
 * If NOT_SERIALIZED is not defined the function injects the serialize
 * handler into the calling chain prior to calling netsnmp_register_table.
 *
 * @param reginfo is a pointer to a netsnmp_handler_registration struct
 *
 * @param iinfo A pointer to a netsnmp_iterator_info struct. If the flag
 * NETSNMP_HANDLER_OWNS_IINFO is not set in iinfo->flags, the caller remains
 * the owner of this structure. And if the flag NETSNMP_HANDLER_OWNS_IINFO is
 * set in iinfo->flags, ownership of this data structure is passed to the
 * handler.
 *
 * @return MIB_REGISTERED_OK is returned if the registration was a success.
 *    Failures are MIB_REGISTRATION_FAILED, MIB_DUPLICATE_REGISTRATION.
 *    If iinfo is NULL, SNMPERR_GENERR is returned.
 *
 */
int netsnmp_register_table_iterator (netsnmp_handler_registration * reginfo, netsnmp_iterator_info * iinfo)
{
#ifndef NETSNMP_FEATURE_REMOVE_STASH_CACHE
    reginfo->modes |= HANDLER_CAN_STASH;
#endif                            /* NETSNMP_FEATURE_REMOVE_STASH_CACHE */
    netsnmp_inject_handler (reginfo, netsnmp_get_table_iterator_handler (iinfo));
    if (!iinfo)
        return SNMPERR_GENERR;
    if (!iinfo->indexes && iinfo->table_reginfo && iinfo->table_reginfo->indexes)
        iinfo->indexes = snmp_clone_varbind (iinfo->table_reginfo->indexes);

    return netsnmp_register_table (reginfo, iinfo->table_reginfo);
}
コード例 #24
0
ファイル: instance.c プロジェクト: fenner/net-snmp
/**
 * This function injects a "read only" handler into the handler chain 
 * prior to serializing/registering the handler.
 *
 * The only purpose of this "read only" handler is to return an
 * appropriate error for any requests passed to it in a SET mode.
 * Inserting it into your handler chain will ensure you're never
 * asked to perform a SET request so you can ignore those error
 * conditions.
 *
 * @param reginfo a handler registration structure which could get created
 *                using netsnmp_create_handler_registration.  Used to register
 *                a read only instance helper handler.
 *
 * @return
 *      MIB_REGISTERED_OK is returned if the registration was a success.
 *	Failures are MIB_REGISTRATION_FAILED and MIB_DUPLICATE_REGISTRATION.
 */
int
netsnmp_register_read_only_instance(netsnmp_handler_registration *reginfo)
{
    netsnmp_mib_handler *h1, *h2;
    if (!reginfo)
        return MIB_REGISTRATION_FAILED;

    h1 = netsnmp_get_instance_handler();
    h2 = netsnmp_get_read_only_handler();
    if (h1 && h2 && netsnmp_inject_handler(reginfo, h1) == SNMPERR_SUCCESS) {
        h1 = NULL;
        if (netsnmp_inject_handler(reginfo, h2) == SNMPERR_SUCCESS)
            return netsnmp_register_serialize(reginfo);
    }

    snmp_log(LOG_ERR, "failed to register read only instance\n");
    netsnmp_handler_free(h1);
    netsnmp_handler_free(h2);
    netsnmp_handler_registration_free(reginfo);

   return MIB_REGISTRATION_FAILED;
}
コード例 #25
0
ファイル: cache_handler.cpp プロジェクト: duniansampa/SigLog
int
netsnmp_register_cache_handler(netsnmp_handler_registration * reginfo,
                               int timeout, NetsnmpCacheLoad * load_hook,
                               NetsnmpCacheFree * free_hook)
{
    netsnmp_mib_handler *handler = NULL;
    handler = netsnmp_get_cache_handler(timeout, load_hook, free_hook,
                                        reginfo->rootoid,
                                        reginfo->rootoid_len);

    netsnmp_inject_handler(reginfo, handler);
    return netsnmp_register_handler(reginfo);
}
コード例 #26
0
ファイル: watcher.c プロジェクト: olegto/osx-project-1
int
netsnmp_register_watched_spinlock(netsnmp_handler_registration *reginfo,
                                   int *spinlock)
{
    netsnmp_mib_handler  *whandler;
    netsnmp_watcher_info *winfo;

    whandler         = netsnmp_get_watched_spinlock_handler();
    whandler->myvoid = (void *)spinlock;
    winfo            = netsnmp_create_watcher_info((void *)spinlock,
		           sizeof(int), ASN_INTEGER, WATCHER_FIXED_SIZE);
    netsnmp_inject_handler(reginfo, whandler);
    return netsnmp_register_watched_scalar(reginfo, winfo);
}
コード例 #27
0
ファイル: table_dataset.c プロジェクト: a5216652166/rcp100
/** register a given data_set at a given oid (specified in the
    netsnmp_handler_registration pointer).  The
    reginfo->handler->access_method *may* be null if the call doesn't
    ever want to be called for SNMP operations.
*/
int
netsnmp_register_table_data_set(netsnmp_handler_registration *reginfo,
                                netsnmp_table_data_set *data_set,
                                netsnmp_table_registration_info *table_info)
{
    int ret;

    if (NULL == table_info) {
        /*
         * allocate the table if one wasn't allocated 
         */
        table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
        if (table_info == NULL)
            return SNMP_ERR_GENERR;
    }

    if (NULL == table_info->indexes && data_set->table->indexes_template) {
        /*
         * copy the indexes in 
         */
        table_info->indexes =
            snmp_clone_varbind(data_set->table->indexes_template);
    }

    if ((!table_info->min_column || !table_info->max_column) &&
        (data_set->default_row)) {
        /*
         * determine min/max columns 
         */
        unsigned int    mincol = 0xffffffff, maxcol = 0;
        netsnmp_table_data_set_storage *row;

        for (row = data_set->default_row; row; row = row->next) {
            mincol = SNMP_MIN(mincol, row->column);
            maxcol = SNMP_MAX(maxcol, row->column);
        }
        if (!table_info->min_column)
            table_info->min_column = mincol;
        if (!table_info->max_column)
            table_info->max_column = maxcol;
    }

    netsnmp_inject_handler(reginfo,
                           netsnmp_get_table_data_set_handler(data_set));
    ret = netsnmp_register_table_data(reginfo, data_set->table,
                                       table_info);
    if (reginfo->handler)
        netsnmp_handler_owns_table_info(reginfo->handler->next);
    return ret;
}
コード例 #28
0
/** 
 * Creates and registers a table iterator helper handler calling 
 * netsnmp_create_handler with a handler name set to TABLE_ITERATOR_NAME 
 * and access method, netsnmp_table_iterator_helper_handler.
 *
 * If NOT_SERIALIZED is not defined the function injects the serialize
 * handler into the calling chain prior to calling netsnmp_register_table.
 *
 * @param reginfo is a pointer to a netsnmp_handler_registration struct
 *
 * @param iinfo is a pointer to a netsnmp_iterator_info struct
 *
 * @return MIB_REGISTERED_OK is returned if the registration was a success.
 *	Failures are MIB_REGISTRATION_FAILED, MIB_DUPLICATE_REGISTRATION.
 *	If iinfo is NULL, SNMPERR_GENERR is returned.
 *
 */
int
netsnmp_register_table_iterator(netsnmp_handler_registration *reginfo,
                                netsnmp_iterator_info *iinfo)
{
    reginfo->modes |= HANDLER_CAN_STASH;
    netsnmp_inject_handler(reginfo,
                           netsnmp_get_table_iterator_handler(iinfo));
    if (!iinfo)
        return SNMPERR_GENERR;
    if (!iinfo->indexes && iinfo->table_reginfo &&
                           iinfo->table_reginfo->indexes )
        iinfo->indexes = snmp_clone_varbind( iinfo->table_reginfo->indexes );

    return netsnmp_register_table(reginfo, iinfo->table_reginfo);
}
コード例 #29
0
ファイル: instance.c プロジェクト: fenner/net-snmp
/**
 * This function registers an instance helper handler, which is a way of 
 * registering an exact OID such that GENEXT requests are handled entirely
 * by the helper. First need to inject it into the calling chain of the 
 * handler defined by the netsnmp_handler_registration struct, reginfo.  
 * The new handler is injected at the top of the list and will be the new
 * handler to be called first.  This function also injects a serialize 
 * handler before actually calling netsnmp_register_handle, registering 
 * reginfo.
 *
 * @param reginfo a handler registration structure which could get created
 *                using netsnmp_create_handler_registration.  Used to register
 *                an instance helper handler.
 *
 * @return
 *      MIB_REGISTERED_OK is returned if the registration was a success.
 *	Failures are MIB_REGISTRATION_FAILED and MIB_DUPLICATE_REGISTRATION.
 */
int
netsnmp_register_instance(netsnmp_handler_registration *reginfo)
{
    netsnmp_mib_handler *handler = netsnmp_get_instance_handler();
    if (handler) {
        handler->flags |= MIB_HANDLER_INSTANCE;
        if (netsnmp_inject_handler(reginfo, handler) == SNMPERR_SUCCESS)
            return netsnmp_register_serialize(reginfo);
    }

    snmp_log(LOG_ERR, "failed to register instance\n");
    netsnmp_handler_free(handler);
    netsnmp_handler_registration_free(reginfo);

    return MIB_REGISTRATION_FAILED;
}
コード例 #30
0
ファイル: tcp.cpp プロジェクト: duniansampa/SigLog
void
init_tcp(void)
{
    netsnmp_handler_registration *reginfo;
    int rc;

    /*
     * register ourselves with the agent as a group of scalars...
     */
    DEBUGMSGTL(("mibII/tcpScalar", "Initialising TCP scalar group\n"));
    reginfo = netsnmp_create_handler_registration("tcp", tcp_handler,
		    tcp_oid, OID_LENGTH(tcp_oid), HANDLER_CAN_RONLY);
    rc = netsnmp_register_scalar_group(reginfo, TCPRTOALGORITHM, TCPOUTRSTS);
    if (rc != SNMPERR_SUCCESS)
        return;

    /*
     * .... with a local cache
     *    (except for HP-UX 11, which extracts objects individually)
     */
#ifndef hpux11
    netsnmp_inject_handler( reginfo,
		    netsnmp_get_cache_handler(TCP_STATS_CACHE_TIMEOUT,
			   		tcp_load, tcp_free,
					tcp_oid, OID_LENGTH(tcp_oid)));
#endif

    REGISTER_SYSOR_ENTRY(tcp_module_oid,
                         "The MIB module for managing TCP implementations");

#if !defined(_USE_FIRST_PROTOCOL)
#ifdef TCPSTAT_SYMBOL
    auto_nlist(TCPSTAT_SYMBOL, 0, 0);
#endif
#ifdef TCP_SYMBOL
    auto_nlist(TCP_SYMBOL, 0, 0);
#endif
#ifdef freebsd4
    hz = sysconf(_SC_CLK_TCK);  /* get ticks/s from system */
#endif
#ifdef solaris2
    init_kernel_sunos5();
#endif
#endif
}