void sim_db_update_plugin_sid (SimDatabase *database, SimDirective *directive, SimUuid *uuid) { SimPluginSid *plugin_sid = NULL; gchar *query; g_return_if_fail (SIM_IS_DATABASE (database)); g_return_if_fail (SIM_IS_DIRECTIVE (directive)); g_return_if_fail (SIM_IS_UUID (uuid)); plugin_sid = sim_plugin_sid_new_from_data (SIM_PLUGIN_ID_DIRECTIVE, sim_directive_get_id (directive), 1, sim_directive_get_priority (directive), sim_directive_get_name (directive)); query = sim_plugin_sid_get_insert_clause (plugin_sid, uuid); ossim_debug ("%s: %s", __func__, query); sim_database_execute_no_query (database, query); g_object_unref (plugin_sid); g_free (query); }
void sim_debug_print_backlogs_data (GPtrArray * backlogs, GIOChannel *channel) { guint i; SimDirective *backlog; gchar * timestamp, *buff; SimRule *rule; for (i = 0; i < backlogs->len; i++) { backlog = (SimDirective*) g_ptr_array_index (backlogs, i); g_io_channel_write_chars(channel,"===========================================================\n",-1,NULL,NULL); buff = g_strdup_printf("Directive_id=%d\n", sim_directive_get_id(backlog)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); buff = g_strdup_printf("Backlog_id=%s\n", sim_directive_get_backlog_id_str(backlog)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); buff = g_strdup_printf("Directive Name=%s\n", sim_directive_get_name(backlog)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); buff = g_strdup_printf("Priority=%d\n", sim_directive_get_priority(backlog)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); buff = g_strdup_printf("Matched=%d\n", sim_directive_backlog_get_matched(backlog)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); buff = g_strdup_printf("Is time out=%d\n", sim_directive_backlog_time_out(backlog)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); timestamp = g_new0 (gchar, 26); time_t backlog_timelast = sim_directive_get_time_last(backlog); strftime (timestamp, TIMEBUF_SIZE, "%Y-%m-%d %H:%M:%S", localtime ((time_t*)&backlog_timelast)); buff = g_strdup_printf("time_last=%s\n", timestamp); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(timestamp); g_free(buff); timestamp = g_new0 (gchar, 26); time_t backlog_timeout = backlog_timelast + sim_directive_get_time_out(backlog); strftime (timestamp, TIMEBUF_SIZE, "%Y-%m-%d %H:%M:%S", localtime ((time_t*)&backlog_timeout)); buff = g_strdup_printf("time_out=%s\n", timestamp); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(timestamp); g_free(buff); rule = sim_directive_get_root_rule (backlog); if(rule) { g_io_channel_write_chars(channel,"Current Rule:\n",-1,NULL,NULL); buff = g_strdup_printf("\t name=%s\n", sim_rule_get_name(rule)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); buff = g_strdup_printf("\t level=%d\n", sim_rule_get_level(rule)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); buff = g_strdup_printf("\t reliability=%d\n", sim_rule_get_reliability(rule)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); timestamp = g_new0 (gchar, 26); time_t rule_timelast = sim_rule_get_time_last(rule); strftime (timestamp, TIMEBUF_SIZE, "%Y-%m-%d %H:%M:%S", localtime ((time_t*)&rule_timelast)); buff = g_strdup_printf("\ttime_last=%s\n", timestamp); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(timestamp); g_free(buff); timestamp = g_new0 (gchar, 26); time_t rule_timeout = rule_timelast + sim_rule_get_time_out(rule); strftime (timestamp, TIMEBUF_SIZE, "%Y-%m-%d %H:%M:%S", localtime ((time_t*)&rule_timeout)); buff = g_strdup_printf("\ttime_out=%s\n", timestamp); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(timestamp); g_free(buff); buff = g_strdup_printf("\toccurence=%d\n", sim_rule_get_occurrence(rule)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); buff = g_strdup_printf("\tplugins_sid=%d\n", sim_rule_get_plugin_sid(rule)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); // TODO: with taxonomy we can have multiple plugin ids or ANY buff = g_strdup_printf("\tplugind_id=%d\n", sim_rule_get_plugin_id(rule)); g_io_channel_write_chars(channel,buff,-1,NULL,NULL); g_free(buff); } } }