/* * Copyright (C) 2008 Groundwork Open Source * Written by Daniel Emmanuel Feinsmith * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301, USA. * * File: bronx_route.h * Author: root * * Created on October 18, 2007, 1:13 PM */ #ifndef _BRONX_ROUTE_H #define _BRONX_ROUTE_H #ifdef __cplusplus extern "C" { #endif /* * Route Types */ #define BRONX_ROUTE_TYPE_BRONX 1 #define BRONX_ROUTE_TYPE_XML 2 #define BRONX_ROUTE_TYPE_FILE 3 /* * Filter Types */ #define BRONX_FILTER_TYPE_PLUGIN 1 #define BRONX_FILTER_TYPE_PERF 2 #define BRONX_FILTER_TYPE_BOTH 3 /* * Various macros */ #define BRONX_ROUTE_CONFIG_PATH_MAX 256 #define BRONX_ROUTE_CONFIG_FN_MAX 32 #define BRONX_ROUTE_CONFIG_ADDR_MAX 32 /* * Our route structure */ typedef struct { // Global for all route types: char route_name[BRONX_ROUTE_CONFIG_FN_MAX]; int route_type; int filter_type; int backup; time_t last_time_check; time_t last_reconnect_attempt_time; int is_connected; // For bronx and xml types: char address[BRONX_ROUTE_CONFIG_ADDR_MAX]; int port; unsigned int aggregation_frequency; // In seconds. unsigned int aggregation_entries; // In queue entries. apr_socket_t *client_socket; // // Database Functionality // sqlite3 *database; int database_dirty; apr_thread_mutex_t *database_mutex; // For file type: char output_pathname[BRONX_ROUTE_CONFIG_PATH_MAX]; FILE *fp; // Aggregation Queue: apr_thread_mutex_t *aggregation_queue_mutex; apr_queue_t *aggregation_queue; // Memory Pool: apr_pool_t *pool; } route_definition; typedef struct { route_definition *route; void *value; } exec_args_container; /* * External functions */ apr_status_t route_message(route_definition *, message *); apr_status_t route_marshalled_message(route_definition *, char *, int); apr_status_t route_message_tcp(route_definition *route, char *marshalled_msg); apr_status_t route_message_file(route_definition *route, char *marshalled_msg); apr_status_t aggregation_queue_init(route_definition *route); apr_status_t route_message_to_all_routes(message *msg); apr_status_t marshall_and_route_all_in_queue(route_definition *route); apr_status_t marshall_and_route(route_definition *route, message *msg); apr_status_t marshall_xml_and_route_all_in_queue(route_definition *route); // Various Externs: extern int add_message_to_database(route_definition *route, char *msg); #ifdef __cplusplus } #endif #endif /* _BRONX_ROUTE_H */