/** 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 */ }
/** 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 */ }
/** 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 */ }
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 }
/** 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))); }
/** 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); }
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))); }
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))); }
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); }
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 }
int netsnmp_register_cache_handler(netsnmp_handler_registration * reginfo, int timeout, NetsnmpCacheLoad * load_hook, NetsnmpCacheFree * free_hook) { netsnmp_mib_handler *handler; if (NULL == reginfo) { snmp_log(LOG_ERR, "bad param in netsnmp_cache_handler_register\n"); netsnmp_handler_registration_free(reginfo); return MIB_REGISTRATION_FAILED; } handler = netsnmp_get_cache_handler(timeout, load_hook, free_hook, reginfo->rootoid, reginfo->rootoid_len); return _cache_handler_register(reginfo, handler); }
void init_udp(void) { netsnmp_handler_registration *reginfo; int rc; /* * register ourselves with the agent as a group of scalars... */ DEBUGMSGTL(("mibII/udpScalar", "Initialising UDP scalar group\n")); reginfo = netsnmp_create_handler_registration("udp", udp_handler, udp_oid, OID_LENGTH(udp_oid), HANDLER_CAN_RONLY); rc = netsnmp_register_scalar_group(reginfo, UDPINDATAGRAMS, UDPOUTDATAGRAMS); 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(UDP_STATS_CACHE_TIMEOUT, udp_load, udp_free, udp_oid, OID_LENGTH(udp_oid))); #endif REGISTER_SYSOR_ENTRY(udp_module_oid, "The MIB module for managing UDP implementations"); #if !defined(_USE_PERFSTAT_PROTOCOL) #ifdef UDPSTAT_SYMBOL auto_nlist(UDPSTAT_SYMBOL, 0, 0); #endif #ifdef UDB_SYMBOL auto_nlist(UDB_SYMBOL, 0, 0); #endif #ifdef solaris2 init_kernel_sunos5(); #endif #endif }
void init_subagent(switch_memory_pool_t *pool) { static oid identity_oid[] = { 1,3,6,1,4,1,27880,1,1 }; static oid systemStats_oid[] = { 1,3,6,1,4,1,27880,1,2 }; static oid channelList_oid[] = { 1,3,6,1,4,1,27880,1,9 }; DEBUGMSGTL(("init_subagent", "mod_snmp subagent initializing\n")); netsnmp_register_scalar_group(netsnmp_create_handler_registration("identity", handle_identity, identity_oid, OID_LENGTH(identity_oid), HANDLER_CAN_RONLY), 1, 2); netsnmp_register_scalar_group(netsnmp_create_handler_registration("systemStats", handle_systemStats, systemStats_oid, OID_LENGTH(systemStats_oid), HANDLER_CAN_RONLY), 1, 11); ch_table_info = switch_core_alloc(pool, sizeof(netsnmp_table_registration_info)); netsnmp_table_helper_add_indexes(ch_table_info, ASN_INTEGER, 0); ch_table_info->min_column = CH_INDEX; ch_table_info->max_column = CH_WRITE_BITRATE; ch_table = netsnmp_tdata_create_table("channelList", 0); ch_reginfo = netsnmp_create_handler_registration("channelList", handle_channelList, channelList_oid, OID_LENGTH(channelList_oid), HANDLER_CAN_RONLY); netsnmp_tdata_register(ch_reginfo, ch_table, ch_table_info); netsnmp_inject_handler(ch_reginfo, netsnmp_get_cache_handler(5, channelList_load, channelList_free, channelList_oid, OID_LENGTH(channelList_oid))); }
/** Initialize the dot11VlanAbilityTable table by defining its contents and how it's structured */ void initialize_table_dot11VlanAbilityTable(void) { static oid dot11VlanAbilityTable_oid[128] = {0}; size_t dot11VlanAbilityTable_oid_len = 0; mad_dev_oid(dot11VlanAbilityTable_oid,VLANABILITYTABLE,&dot11VlanAbilityTable_oid_len,enterprise_pvivate_oid); netsnmp_handler_registration *reg; netsnmp_iterator_info *iinfo; netsnmp_table_registration_info *table_info; reg = netsnmp_create_handler_registration( "dot11VlanAbilityTable", dot11VlanAbilityTable_handler, dot11VlanAbilityTable_oid, dot11VlanAbilityTable_oid_len, HANDLER_CAN_RWRITE ); table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info ); netsnmp_table_helper_add_indexes(table_info, ASN_OCTET_STR, /* index: wtpCurrID */ ASN_INTEGER, /* index: wlanCurrID */ 0); table_info->min_column = VLANABILITITY_MIN; table_info->max_column = VLANABITLITY_MAX; iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info ); iinfo->get_first_data_point = dot11VlanAbilityTable_get_first_data_point; iinfo->get_next_data_point = dot11VlanAbilityTable_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,dot11VlanAbilityTable_load, dot11VlanAbilityTable_removeEntry, dot11VlanAbilityTable_oid, dot11VlanAbilityTable_oid_len)); /* Initialise the contents of the table here */ }
void init_icmp(void) { netsnmp_handler_registration *reginfo; /* * register ourselves with the agent as a group of scalars... */ DEBUGMSGTL(("mibII/icmp", "Initialising ICMP group\n")); reginfo = netsnmp_create_handler_registration("icmp", icmp_handler, icmp_oid, OID_LENGTH(icmp_oid), HANDLER_CAN_RONLY); netsnmp_register_scalar_group(reginfo, ICMPINMSGS, ICMPOUTADDRMASKREPS); /* * .... with a local cache * (except for HP-UX 11, which extracts objects individually) */ #ifndef hpux11 netsnmp_inject_handler( reginfo, netsnmp_get_cache_handler(ICMP_STATS_CACHE_TIMEOUT, icmp_load, icmp_free, icmp_oid, OID_LENGTH(icmp_oid))); #endif #ifdef USING_MIBII_IP_MODULE if (++ip_module_count == 2) REGISTER_SYSOR_TABLE(ip_module_oid, ip_module_oid_len, "The MIB module for managing IP and ICMP implementations"); #endif #ifdef ICMPSTAT_SYMBOL auto_nlist(ICMPSTAT_SYMBOL, 0, 0); #endif #ifdef solaris2 init_kernel_sunos5(); #endif }
void init_icmp(void) { netsnmp_handler_registration *reginfo; netsnmp_handler_registration *msg_stats_reginfo; netsnmp_iterator_info *iinfo; netsnmp_iterator_info *msg_stats_iinfo; netsnmp_table_registration_info *table_info; netsnmp_table_registration_info *msg_stats_table_info; /* * register ourselves with the agent as a group of scalars... */ DEBUGMSGTL(("mibII/icmp", "Initialising ICMP group\n")); reginfo = netsnmp_create_handler_registration("icmp", icmp_handler, icmp_oid, OID_LENGTH(icmp_oid), HANDLER_CAN_RONLY); netsnmp_register_scalar_group(reginfo, ICMPINMSGS, ICMPOUTADDRMASKREPS); /* * .... with a local cache * (except for HP-UX 11, which extracts objects individually) */ #ifndef hpux11 netsnmp_inject_handler( reginfo, netsnmp_get_cache_handler(ICMP_STATS_CACHE_TIMEOUT, icmp_load, icmp_free, icmp_oid, OID_LENGTH(icmp_oid))); #endif #ifdef linux /* register icmpStatsTable */ reginfo = netsnmp_create_handler_registration("icmpStatsTable", icmp_stats_table_handler, icmp_stats_tbl_oid, OID_LENGTH(icmp_stats_tbl_oid), HANDLER_CAN_RONLY); table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); if (!table_info) { return; } netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, 0); table_info->min_column = ICMP_STAT_INMSG; table_info->max_column = ICMP_STAT_OUTERR; iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info); if (!iinfo) { return; } iinfo->get_first_data_point = icmp_stats_first_entry; iinfo->get_next_data_point = icmp_stats_next_entry; iinfo->table_reginfo = table_info; netsnmp_register_table_iterator(reginfo, iinfo); /* register icmpMsgStatsTable */ msg_stats_reginfo = netsnmp_create_handler_registration("icmpMsgStatsTable", icmp_msg_stats_table_handler, icmp_msg_stats_tbl_oid, OID_LENGTH(icmp_msg_stats_tbl_oid), HANDLER_CAN_RONLY); msg_stats_table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); if (!msg_stats_table_info) { return; } netsnmp_table_helper_add_indexes(msg_stats_table_info, ASN_INTEGER, ASN_INTEGER, 0); msg_stats_table_info->min_column = ICMP_MSG_STAT_IN_PKTS; msg_stats_table_info->max_column = ICMP_MSG_STAT_OUT_PKTS; msg_stats_iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info); if (!msg_stats_iinfo) { return; } msg_stats_iinfo->get_first_data_point = icmp_msg_stats_first_entry; msg_stats_iinfo->get_next_data_point = icmp_msg_stats_next_entry; msg_stats_iinfo->table_reginfo = msg_stats_table_info; netsnmp_register_table_iterator(msg_stats_reginfo, msg_stats_iinfo); netsnmp_inject_handler( msg_stats_reginfo, netsnmp_get_cache_handler(ICMP_STATS_CACHE_TIMEOUT, icmp_load, icmp_free, icmp_msg_stats_tbl_oid, OID_LENGTH(icmp_msg_stats_tbl_oid))); #ifndef hpux11 netsnmp_inject_handler( reginfo, netsnmp_get_cache_handler(ICMP_STATS_CACHE_TIMEOUT, icmp_load, icmp_free, icmp_stats_tbl_oid, OID_LENGTH(icmp_stats_tbl_oid))); #endif /* ! hpux11 */ #endif /* linux */ #ifdef USING_MIBII_IP_MODULE if (++ip_module_count == 2) REGISTER_SYSOR_TABLE(ip_module_oid, ip_module_oid_len, "The MIB module for managing IP and ICMP implementations"); #endif #if !defined(_USE_PERFSTAT_PROTOCOL) #ifdef ICMPSTAT_SYMBOL auto_nlist(ICMPSTAT_SYMBOL, 0, 0); #endif #ifdef solaris2 init_kernel_sunos5(); #endif #endif }
/** Initialize the LHANodeTable table by defining its contents and how it's structured */ void initialize_table_LHANodeTable(void) { static oid LHANodeTable_oid[] = {1,3,6,1,4,1,4682,2}; netsnmp_table_registration_info *table_info; netsnmp_handler_registration *my_handler; netsnmp_iterator_info *iinfo; /** create the table registration information structures */ table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info); /** if your table is read only, it's easiest to change the HANDLER_CAN_RWRITE definition below to HANDLER_CAN_RONLY */ my_handler = netsnmp_create_handler_registration("LHANodeTable", LHANodeTable_handler, LHANodeTable_oid, OID_LENGTH(LHANodeTable_oid), HANDLER_CAN_RONLY); if (!my_handler || !table_info || !iinfo) { snmp_log(LOG_ERR, "malloc failed in initialize_table_LHANodeTable"); SNMP_FREE(iinfo); SNMP_FREE(table_info); return; /* Serious error. */ } /*************************************************** * Setting up the table's definition */ netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, /* index: LHANodeIndex */ 0); /** Define the minimum and maximum accessible columns. This optimizes retrival. */ table_info->min_column = 2; table_info->max_column = 6; /* iterator access routines */ iinfo->get_first_data_point = LHANodeTable_get_first_data_point; iinfo->get_next_data_point = LHANodeTable_get_next_data_point; /** tie the two structures together */ iinfo->table_reginfo = table_info; /*************************************************** * registering the table with the master agent */ DEBUGMSGTL(("initialize_table_LHANodeTable", "Registering table LHANodeTable as a table iterator\n")); netsnmp_register_table_iterator(my_handler, iinfo); /* * .... with a local cache */ netsnmp_inject_handler(my_handler, netsnmp_get_cache_handler(snmp_cache_time_out, LHANodeTable_load, LHANodeTable_free, LHANodeTable_oid, OID_LENGTH(LHANodeTable_oid))); }