void init_notification_log(void) { static oid my_nlmStatsGlobalNotificationsLogged_oid[] = { 1, 3, 6, 1, 2, 1, 92, 1, 2, 1, 0 }; static oid my_nlmStatsGlobalNotificationsBumped_oid[] = { 1, 3, 6, 1, 2, 1, 92, 1, 2, 2, 0 }; static oid my_nlmConfigGlobalEntryLimit_oid[] = { 1, 3, 6, 1, 2, 1, 92, 1, 1, 1, 0 }; static oid my_nlmConfigGlobalAgeOut_oid[] = { 1, 3, 6, 1, 2, 1, 92, 1, 1, 2, 0 }; /* * static variables */ netsnmp_register_read_only_counter32_instance ("nlmStatsGlobalNotificationsLogged", my_nlmStatsGlobalNotificationsLogged_oid, OID_LENGTH(my_nlmStatsGlobalNotificationsLogged_oid), &num_received, NULL); netsnmp_register_read_only_counter32_instance ("nlmStatsGlobalNotificationsBumped", my_nlmStatsGlobalNotificationsBumped_oid, OID_LENGTH(my_nlmStatsGlobalNotificationsBumped_oid), &num_deleted, NULL); netsnmp_register_ulong_instance("nlmConfigGlobalEntryLimit", my_nlmConfigGlobalEntryLimit_oid, OID_LENGTH (my_nlmConfigGlobalEntryLimit_oid), &max_logged, notification_log_config_handler); netsnmp_register_ulong_instance("nlmConfigGlobalAgeOut", my_nlmConfigGlobalAgeOut_oid, OID_LENGTH (my_nlmConfigGlobalAgeOut_oid), &max_age, notification_log_config_handler); /* * tables */ initialize_table_nlmLogTable(); initialize_table_nlmLogVariableTable(); /* * disable flag */ netsnmp_ds_register_config(ASN_BOOLEAN, "snmptrapd", "dontRetainLogs", NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_APP_DONT_LOG); }
void init_testhandler(void) { /* * we're registering at .1.2.3.4 */ netsnmp_handler_registration *my_test; netsnmp_table_registration_info *table_info; u_long ind1; netsnmp_table_data *table; netsnmp_table_data_set *table_set; netsnmp_table_row *row; DEBUGMSGTL(("testhandler", "initializing\n")); /* * basic handler test */ netsnmp_register_handler(netsnmp_create_handler_registration ("myTest", my_test_handler, my_test_oid, 4, HANDLER_CAN_RONLY)); /* * instance handler test */ netsnmp_register_instance(netsnmp_create_handler_registration ("myInstance", my_test_instance_handler, my_instance_oid, 5, HANDLER_CAN_RWRITE)); netsnmp_register_ulong_instance("myulong", my_data_ulong_instance, 4, &my_ulong, NULL); /* * table helper test */ my_test = netsnmp_create_handler_registration("myTable", my_test_table_handler, my_table_oid, 4, HANDLER_CAN_RONLY); if (!my_test) return; table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); if (table_info == NULL) return; netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, ASN_INTEGER, 0); table_info->min_column = 3; table_info->max_column = 3; netsnmp_register_table(my_test, table_info); /* * data table helper test */ /* * we'll construct a simple table here with two indexes: an * integer and a string (why not). It'll contain only one * column so the data pointer is merely the data in that * column. */ table = netsnmp_create_table_data("data_table_test"); netsnmp_table_data_add_index(table, ASN_INTEGER); netsnmp_table_data_add_index(table, ASN_OCTET_STR); /* * 1 partridge in a pear tree */ row = netsnmp_create_table_data_row(); ind1 = 1; netsnmp_table_row_add_index(row, ASN_INTEGER, &ind1, sizeof(ind1)); netsnmp_table_row_add_index(row, ASN_OCTET_STR, "partridge", strlen("partridge")); row->data = (void *) "pear tree"; netsnmp_table_data_add_row(table, row); /* * 2 turtle doves */ row = netsnmp_create_table_data_row(); ind1 = 2; netsnmp_table_row_add_index(row, ASN_INTEGER, &ind1, sizeof(ind1)); netsnmp_table_row_add_index(row, ASN_OCTET_STR, "turtle", strlen("turtle")); row->data = (void *) "doves"; netsnmp_table_data_add_row(table, row); /* * we're going to register it as a normal table too, so we get the * automatically parsed column and index information */ table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); if (table_info == NULL) return; netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, ASN_OCTET_STR, 0); table_info->min_column = 3; table_info->max_column = 3; netsnmp_register_read_only_table_data (netsnmp_create_handler_registration ("12days", my_data_table_handler, my_data_table_oid, 4, HANDLER_CAN_RONLY), table, table_info); }