/** * @internal * Initialize the table ipv6InterfaceTable * (Define its contents and how it's structured) */ void _ipv6InterfaceTable_initialize_interface(ipv6InterfaceTable_registration * reg_ptr, u_long flags) { netsnmp_baby_steps_access_methods *access_multiplexer = &ipv6InterfaceTable_if_ctx.access_multiplexer; netsnmp_table_registration_info *tbl_info = &ipv6InterfaceTable_if_ctx.tbl_info; netsnmp_handler_registration *reginfo; netsnmp_mib_handler *handler; int mfd_modes = 0; DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_initialize_interface", "called\n")); /************************************************* * * save interface context for ipv6InterfaceTable */ /* * Setting up the table's definition */ netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, /** index: ipv6InterfaceIfIndex */ 0); /* * Define the minimum and maximum accessible columns. This * optimizes retrieval. */ tbl_info->min_column = IPV6INTERFACETABLE_MIN_COL; tbl_info->max_column = IPV6INTERFACETABLE_MAX_COL; /* * save users context */ ipv6InterfaceTable_if_ctx.user_ctx = reg_ptr; /* * call data access initialization code */ ipv6InterfaceTable_init_data(reg_ptr); /* * set up the container */ _ipv6InterfaceTable_container_init(&ipv6InterfaceTable_if_ctx); if (NULL == ipv6InterfaceTable_if_ctx.container) { snmp_log(LOG_ERR, "could not initialize container for ipv6InterfaceTable\n"); return; } /* * access_multiplexer: REQUIRED wrapper for get request handling */ access_multiplexer->object_lookup = _mfd_ipv6InterfaceTable_object_lookup; access_multiplexer->get_values = _mfd_ipv6InterfaceTable_get_values; /* * no wrappers yet */ access_multiplexer->pre_request = _mfd_ipv6InterfaceTable_pre_request; access_multiplexer->post_request = _mfd_ipv6InterfaceTable_post_request; #ifndef NETSNMP_DISABLE_SET_SUPPORT /* * REQUIRED wrappers for set request handling */ access_multiplexer->object_syntax_checks = _mfd_ipv6InterfaceTable_check_objects; access_multiplexer->undo_setup = _mfd_ipv6InterfaceTable_undo_setup; access_multiplexer->undo_cleanup = _mfd_ipv6InterfaceTable_undo_cleanup; access_multiplexer->set_values = _mfd_ipv6InterfaceTable_set_values; access_multiplexer->undo_sets = _mfd_ipv6InterfaceTable_undo_values; /* * no wrappers yet */ access_multiplexer->commit = _mfd_ipv6InterfaceTable_commit; access_multiplexer->undo_commit = _mfd_ipv6InterfaceTable_undo_commit; access_multiplexer->irreversible_commit = _mfd_ipv6InterfaceTable_irreversible_commit; #endif /************************************************* * * Create a registration, save our reg data, register table. */ DEBUGMSGTL(("ipv6InterfaceTable:init_ipv6InterfaceTable", "Registering ipv6InterfaceTable as a mibs-for-dummies table.\n")); handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); reginfo = netsnmp_handler_registration_create("ipv6InterfaceTable", handler, ipv6InterfaceTable_oid, ipv6InterfaceTable_oid_size, HANDLER_CAN_BABY_STEP | #ifndef NETSNMP_DISABLE_SET_SUPPORT HANDLER_CAN_RWRITE #else HANDLER_CAN_RONLY #endif /* NETSNMP_DISABLE_SET_SUPPORT */ ); if (NULL == reginfo) { snmp_log(LOG_ERR, "error registering table ipv6InterfaceTable\n"); return; } reginfo->my_reg_void = &ipv6InterfaceTable_if_ctx; /************************************************* * * set up baby steps handler, create it and inject it */ if (access_multiplexer->object_lookup) mfd_modes |= BABY_STEP_OBJECT_LOOKUP; if (access_multiplexer->pre_request) mfd_modes |= BABY_STEP_PRE_REQUEST; if (access_multiplexer->post_request) mfd_modes |= BABY_STEP_POST_REQUEST; #ifndef NETSNMP_DISABLE_SET_SUPPORT if (access_multiplexer->set_values) mfd_modes |= BABY_STEP_SET_VALUES; if (access_multiplexer->irreversible_commit) mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; if (access_multiplexer->object_syntax_checks) mfd_modes |= BABY_STEP_CHECK_OBJECT; if (access_multiplexer->undo_setup) mfd_modes |= BABY_STEP_UNDO_SETUP; if (access_multiplexer->undo_cleanup) mfd_modes |= BABY_STEP_UNDO_CLEANUP; if (access_multiplexer->undo_sets) mfd_modes |= BABY_STEP_UNDO_SETS; if (access_multiplexer->row_creation) mfd_modes |= BABY_STEP_ROW_CREATE; if (access_multiplexer->consistency_checks) mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; if (access_multiplexer->commit) mfd_modes |= BABY_STEP_COMMIT; if (access_multiplexer->undo_commit) mfd_modes |= BABY_STEP_UNDO_COMMIT; #endif handler = netsnmp_baby_steps_handler_get(mfd_modes); netsnmp_inject_handler(reginfo, handler); /************************************************* * * inject row_merge helper with prefix rootoid_len + 2 (entry.col) */ handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); netsnmp_inject_handler(reginfo, handler); /************************************************* * * inject container_table helper */ handler = netsnmp_container_table_handler_get(tbl_info, ipv6InterfaceTable_if_ctx. container, TABLE_CONTAINER_KEY_NETSNMP_INDEX); netsnmp_inject_handler(reginfo, handler); /* * register table */ netsnmp_register_table(reginfo, tbl_info); /* * register LastChanged */ { oid lc_oid[] = { IPV6INTERFACETABLELASTCHANGE_OID }; netsnmp_register_watched_scalar2(netsnmp_create_handler_registration ("ipv6TableLastChanged", NULL, lc_oid, OID_LENGTH(lc_oid), HANDLER_CAN_RONLY), netsnmp_create_watcher_info((void *) &ipv6InterfaceTable_if_ctx. last_changed, sizeof (u_long), ASN_TIMETICKS, WATCHER_FIXED_SIZE)); } } /* _ipv6InterfaceTable_initialize_interface */
void init_snmpTlstmCertToTSNTable_context(const char *contextName) { oid reg_oid[] = { SNMP_TLS_TM_CERT_TABLE }; const size_t reg_oid_len = OID_LENGTH(reg_oid); netsnmp_handler_registration *reg; netsnmp_table_registration_info *info; netsnmp_cache *cache; netsnmp_watcher_info *watcher; const char *mib_map_help = MAP_MIB_CONFIG_TOKEN " table persistence (internal use)"; DEBUGMSGTL(("tlstmCertToSN:init", "initializing table tlstmCertToTSNTable\n")); reg = netsnmp_create_handler_registration ("tlstmCertToTSNTable", tlstmCertToTSNTable_handler, reg_oid, reg_oid_len, HANDLER_CAN_RWRITE); if (NULL == reg) { snmp_log(LOG_ERR, "error creating handler registration for tlstmCertToSN\n"); return; } if (NULL != contextName) reg->contextName = strdup(contextName); _table = netsnmp_tdata_create_table("tlstmCertToTSNTable", 0); if (NULL == _table) { snmp_log(LOG_ERR, "error creating tdata table for tlstmCertToTSNTable\n"); return; } info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); if (NULL == info) { snmp_log(LOG_ERR, "error creating table info for tlstmCertToTSNTable\n"); netsnmp_tdata_delete_table(_table); _table = NULL; return; } netsnmp_table_helper_add_indexes(info, /* index: tlstmCertToTSNID */ ASN_UNSIGNED, 0); info->min_column = SNMPTLSTMCERTTOTSN_TABLE_MIN_COL; info->max_column = SNMPTLSTMCERTTOTSN_TABLE_MAX_COL; /* * cache init */ cache = netsnmp_cache_create(30, (NetsnmpCacheLoad*)_cache_load, (NetsnmpCacheFree*)_cache_free, reg_oid, reg_oid_len); if (NULL == cache) { snmp_log(LOG_ERR,"error creating cache for tlstmCertToTSNTable\n"); netsnmp_tdata_delete_table(_table); _table = NULL; return; } cache->magic = (void *)_table; cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; netsnmp_tdata_register(reg, _table, info); if (cache) netsnmp_inject_handler_before( reg, netsnmp_cache_handler_get(cache), "table_container"); /* * register scalars */ reg_oid[10] = 1; reg = netsnmp_create_handler_registration("snmpTlstmCertToTSNCount", _count_handler, reg_oid, OID_LENGTH(reg_oid), HANDLER_CAN_RONLY); if (NULL == reg) snmp_log(LOG_ERR, "could not create handler for snmpTlstmCertToTSNCount\n"); else { if (NULL != contextName) reg->contextName = strdup(contextName); netsnmp_register_scalar(reg); if (cache) netsnmp_inject_handler_before(reg, netsnmp_cache_handler_get(cache), "table_container"); } reg_oid[10] = 2; reg = netsnmp_create_handler_registration( "snmpTlstmCertToTSNTableLastChanged", NULL, reg_oid, OID_LENGTH(reg_oid), HANDLER_CAN_RONLY); watcher = netsnmp_create_watcher_info((void*)&_last_changed, sizeof(_last_changed), ASN_TIMETICKS, WATCHER_FIXED_SIZE); if ((NULL == reg) || (NULL == watcher)) snmp_log(LOG_ERR, "could not create handler for snmpTlstmCertToTSNCount\n"); else { if (NULL != contextName) reg->contextName = strdup(contextName); netsnmp_register_watched_scalar2(reg, watcher); } /* * persistence */ register_config_handler(NULL, MAP_MIB_CONFIG_TOKEN, _parse_mib_maps, NULL, mib_map_help); if (snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA, _save_maps, NULL) != SNMP_ERR_NOERROR) snmp_log(LOG_ERR, "error registering for STORE_DATA callback " "for certToTSN\n"); }