dessert_internal.h

00001 /******************************************************************************
00002  Copyright 2009, The DES-SERT Team, Freie Universitaet Berlin (FUB).
00003  All rights reserved.
00004 
00005  These sources were originally developed by Philipp Schmidt
00006  at Freie Universitaet Berlin (http://www.fu-berlin.de/),
00007  Computer Systems and Telematics / Distributed, Embedded Systems (DES) group
00008  (http://cst.mi.fu-berlin.de/, http://www.des-testbed.net/)
00009  ------------------------------------------------------------------------------
00010  This program is free software: you can redistribute it and/or modify it under
00011  the terms of the GNU General Public License as published by the Free Software
00012  Foundation, either version 3 of the License, or (at your option) any later
00013  version.
00014 
00015  This program is distributed in the hope that it will be useful, but WITHOUT
00016  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License along with
00020  this program. If not, see http://www.gnu.org/licenses/ .
00021  ------------------------------------------------------------------------------
00022  For further information and questions please use the web site
00023         http://www.des-testbed.net/
00024 *******************************************************************************/
00025 
00026 #ifndef DESSERT_INTERNAL_H
00027 #define DESSERT_INTERNAL_H
00028 
00029 /* load needed libs - quite dirty */
00030 #include <stdlib.h>
00031 #include <stdio.h>
00032 #include <fcntl.h>
00033 #include <string.h>
00034 #include <stdarg.h>
00035 #include <unistd.h>
00036 #include <errno.h>
00037 #include <pthread.h>
00038 #include <syslog.h>
00039 #include <sys/socket.h>
00040 #include <sys/ioctl.h>
00041 #include <sys/sysctl.h>
00042 #include <net/route.h>
00043 #include <arpa/inet.h>
00044 #include <netinet/in.h>
00045 #include <libcli.h>
00046 #include <net-snmp/net-snmp-config.h>
00047 #include <net-snmp/net-snmp-includes.h>
00048 #include <net-snmp/agent/net-snmp-agent-includes.h>
00049 #include <utlist.h>
00050 
00051 
00052 #include "dessertObjects.h"
00053 #include "dessertMeshifTable.h"
00054 #include "dessertSysifTable.h"
00055 #include "dessertAppStatsTable.h"
00056 #include "dessertAppParamsTable.h"
00057 
00058 /******************************************************************************
00059  *
00060  * INTERNAL / PRIVATE
00061  *
00062  * C O R E
00063  *
00064  ******************************************************************************/
00065 
00067 #define _DESSERT_STATUS_DAEMON   0x1
00068 
00070 extern int         _dessert_status;
00071 
00072 dessert_frameid_t _dessert_newframeid(void);
00073 
00074 int _dessert_cli_cmd_shutdown(struct cli_def *cli, char *command, char *argv[], int argc);
00075 
00076 /******************************************************************************
00077  *
00078  * INTERNAL / PRIVATE
00079  *
00080  * C L I - C O M M A N D   L I N E   I N T E R F A C E
00081  *
00082  ******************************************************************************/
00083 
00084 int _dessert_cli_init(void);
00085 
00086 /******************************************************************************
00087  *
00088  * INTERNAL / PRIVATE
00089  *
00090  * L O G   F A C I L I T Y
00091  *
00092  ******************************************************************************/
00093 
00095 #define DESSERT_LOGLINE_MAX 1024
00096 
00098 extern FILE *dessert_logfd;
00099 
00100 int _dessert_cli_cmd_logging(struct cli_def *cli, char *command, char *argv[], int argc);
00101 int _dessert_cli_logging_file(struct cli_def *cli, char *command, char *argv[], int argc);
00102 int _dessert_cli_no_logging_file(struct cli_def *cli, char *command, char *argv[], int argc);
00103 int _dessert_cli_logging_ringbuffer(struct cli_def *cli, char *command, char *argv[], int argc);
00104 int _dessert_cli_no_logging_ringbuffer(struct cli_def *cli, char *command, char *argv[], int argc);
00105 
00106 /******************************************************************************
00107  *
00108  * INTERNAL / PRIVATE
00109  *
00110  * M E S H - I N T E R F A C E S
00111  *
00112  ******************************************************************************/
00113 
00115 typedef struct dessert_meshrxcbe {
00117     dessert_meshrxcb_t *c;
00119     int prio;
00121     struct dessert_meshrxcbe *next;
00122 } dessert_meshrxcbe_t;
00123 
00124 int _dessert_meshif_gethwaddr(dessert_meshif_t *meshif);
00125 int _dessert_meshrxcb_runall(dessert_msg_t* msg_in, size_t len, dessert_msg_proc_t *proc_in, const dessert_meshif_t *meshif, dessert_frameid_t id);
00126 
00127 /******************************************************************************
00128  *
00129  * INTERNAL / PRIVATE
00130  *
00131  * S Y S - I N T E R F A C E S
00132  *
00133  ******************************************************************************/
00134 
00136 typedef struct dessert_sysrxcbe {
00138     dessert_sysrxcb_t *c;
00140     int prio;
00142     struct dessert_sysrxcbe *next;
00143 } dessert_sysrxcbe_t;
00144 
00145 extern dessert_sysif_t *_dessert_sysif;
00146 
00147 /******************************************************************************
00148  *
00149  * INTERNAL / PRIVATE
00150  *
00151  * M E S S A G E   H A N D L I N G
00152  *
00153  ******************************************************************************/
00154 
00156 #define DESSERT_MSGLEN sizeof(struct dessert_msg)
00157 
00159 #define DESSERT_MSGPROCLEN sizeof(struct dessert_msg_proc)
00160 
00162 #define DESSERT_MAXFRAMEBUFLEN DESSERT_MAXFRAMELEN
00163 
00164 /******************************************************************************
00165  *
00166  * INTERNAL / PRIVATE
00167  *
00168  * P E R I O D I C   T A S K S
00169  *
00170  ******************************************************************************/
00171 
00172 void _dessert_periodic_init(void);
00173 
00174 /******************************************************************************
00175  *
00176  * INTERNAL / PRIVATE
00177  *
00178  * NET - S N M P // A G E N T _ X
00179  *
00180  ******************************************************************************/
00181 
00182 /******************************************************************************
00183  * #defines
00184  ******************************************************************************/
00185 
00186 #define AGENT "dessertAGENTX"
00187 
00188 #define DESSERT_AGENTX_SYSIFTABLE_CACHE_TIMEOUT     10
00189 #define DESSERT_AGENTX_MESHIFTABLE_CACHE_TIMEOUT    10
00190 #define DESSERT_AGENTX_APPSTATSTABLE_CACHE_TIMEOUT  10
00191 #define DESSERT_AGENTX_APPPARAMTABLE_CACHE_TIMEOUT   1
00192 
00193 /******************************************************************************
00194  * globals
00195  ******************************************************************************/
00196 
00197 extern pthread_rwlock_t _dessert_appstats_cblist_lock;
00198 extern dessert_agentx_appstats_cb_entry_t *_dessert_appstats_cblist;
00199 
00200 extern pthread_rwlock_t _dessert_appparams_cblist_lock;
00201 extern dessert_agentx_appparams_cb_entry_t *_dessert_appparams_cblist;
00202 
00203 /******************************************************************************
00204  * functions
00205  ******************************************************************************/
00206 int _dessert_agentx_appstats_harvest_callbacks(dessert_agentx_appstats_t **appstats_list);
00207 void _dessert_agentx_appstats_free(dessert_agentx_appstats_t *appstat);
00208 void _dessert_agentx_appstats_free_list(dessert_agentx_appstats_t **appstats_list);
00209 
00210 int _dessert_agentx_appparams_harvest_callbacks(dessert_agentx_appparams_t **appparams_list);
00211 void _dessert_agentx_appparams_free(dessert_agentx_appparams_t *appparam);
00212 void _dessert_agentx_appparams_free_list(dessert_agentx_appparams_t **appparams_list);
00213 dessert_agentx_appparamscb_set_t *_dessert_agentx_appparams_getsettercbforindex(int index);
00214 
00215 void _dessert_agentx_init_subagent(void);
00216 void dessert_agentx_stop_subagent(void);
00217 
00218 
00219 #endif /* DESSERT_INTERNAL_H */