diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-07-03 14:06:02 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-07-03 14:06:02 +0000 |
commit | e68aa2bf46213e33bf1bc07a335df8aeb5ac01c3 (patch) | |
tree | 7935770db2280f5b3c95b4d081e67f2a06dd2a6d /src/include | |
parent | dc09ce9982904298e0ef97c91f7bf9218f1b0046 (diff) | |
download | gnunet-e68aa2bf46213e33bf1bc07a335df8aeb5ac01c3.tar.gz gnunet-e68aa2bf46213e33bf1bc07a335df8aeb5ac01c3.zip |
moved common sensor functionality to a util lib
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_protocols.h | 5 | ||||
-rw-r--r-- | src/include/gnunet_sensor_service.h | 157 | ||||
-rw-r--r-- | src/include/gnunet_sensor_util_lib.h | 215 |
3 files changed, 225 insertions, 152 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 371115ada..06e906622 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -2421,6 +2421,11 @@ extern "C" | |||
2421 | */ | 2421 | */ |
2422 | #define GNUNET_MESSAGE_TYPE_SENSOR_END 803 | 2422 | #define GNUNET_MESSAGE_TYPE_SENSOR_END 803 |
2423 | 2423 | ||
2424 | /** | ||
2425 | * Message carrying a single sensor reading | ||
2426 | */ | ||
2427 | #define GNUNET_MESSAGE_TYPE_SENSOR_READING 804 | ||
2428 | |||
2424 | 2429 | ||
2425 | /******************************************************************************* | 2430 | /******************************************************************************* |
2426 | * PEERSTORE message types | 2431 | * PEERSTORE message types |
diff --git a/src/include/gnunet_sensor_service.h b/src/include/gnunet_sensor_service.h index 1bfed345a..f81248b28 100644 --- a/src/include/gnunet_sensor_service.h +++ b/src/include/gnunet_sensor_service.h | |||
@@ -44,158 +44,6 @@ extern "C" | |||
44 | struct GNUNET_SENSOR_Handle; | 44 | struct GNUNET_SENSOR_Handle; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Structure containing sensor definition | ||
48 | */ | ||
49 | struct SensorInfo | ||
50 | { | ||
51 | |||
52 | /** | ||
53 | * The configuration handle | ||
54 | * carrying sensor information | ||
55 | */ | ||
56 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
57 | |||
58 | /* | ||
59 | * Sensor name | ||
60 | */ | ||
61 | char *name; | ||
62 | |||
63 | /* | ||
64 | * Path to definition file | ||
65 | */ | ||
66 | char *def_file; | ||
67 | |||
68 | /* | ||
69 | * First part of version number | ||
70 | */ | ||
71 | uint16_t version_major; | ||
72 | |||
73 | /* | ||
74 | * Second part of version number | ||
75 | */ | ||
76 | uint16_t version_minor; | ||
77 | |||
78 | /* | ||
79 | * Sensor description | ||
80 | */ | ||
81 | char *description; | ||
82 | |||
83 | /* | ||
84 | * Sensor currently enabled | ||
85 | */ | ||
86 | int enabled; | ||
87 | |||
88 | /* | ||
89 | * Category under which the sensor falls (e.g. tcp, datastore) | ||
90 | */ | ||
91 | char *category; | ||
92 | |||
93 | /* | ||
94 | * When does the sensor become active | ||
95 | */ | ||
96 | struct GNUNET_TIME_Absolute *start_time; | ||
97 | |||
98 | /* | ||
99 | * When does the sensor expire | ||
100 | */ | ||
101 | struct GNUNET_TIME_Absolute *end_time; | ||
102 | |||
103 | /* | ||
104 | * Time interval to collect sensor information (e.g. every 1 min) | ||
105 | */ | ||
106 | struct GNUNET_TIME_Relative interval; | ||
107 | |||
108 | /* | ||
109 | * Lifetime of an information sample after which it is deleted from storage | ||
110 | * If not supplied, will default to the interval value | ||
111 | */ | ||
112 | struct GNUNET_TIME_Relative lifetime; | ||
113 | |||
114 | /* | ||
115 | * A set of required peer capabilities for the sensor to collect meaningful information (e.g. ipv6) | ||
116 | */ | ||
117 | char *capabilities; | ||
118 | |||
119 | /* | ||
120 | * Either "gnunet-statistics" or external "process" | ||
121 | */ | ||
122 | char *source; | ||
123 | |||
124 | /* | ||
125 | * Name of the GNUnet service that is the source for the gnunet-statistics entry | ||
126 | */ | ||
127 | char *gnunet_stat_service; | ||
128 | |||
129 | /* | ||
130 | * Name of the gnunet-statistics entry | ||
131 | */ | ||
132 | char *gnunet_stat_name; | ||
133 | |||
134 | /** | ||
135 | * Handle to statistics get request (OR GNUNET_SCHEDULER_NO_TASK) | ||
136 | */ | ||
137 | struct GNUNET_STATISTICS_GetHandle *gnunet_stat_get_handle; | ||
138 | |||
139 | /* | ||
140 | * Name of the external process to be executed | ||
141 | */ | ||
142 | char *ext_process; | ||
143 | |||
144 | /* | ||
145 | * Arguments to be passed to the external process | ||
146 | */ | ||
147 | char *ext_args; | ||
148 | |||
149 | /* | ||
150 | * Handle to the external process | ||
151 | */ | ||
152 | struct GNUNET_OS_CommandHandle *ext_cmd; | ||
153 | |||
154 | /* | ||
155 | * Did we already receive a value | ||
156 | * from the currently running external | ||
157 | * proccess ? #GNUNET_YES / #GNUNET_NO | ||
158 | */ | ||
159 | int ext_cmd_value_received; | ||
160 | |||
161 | /* | ||
162 | * The output datatype to be expected | ||
163 | */ | ||
164 | char *expected_datatype; | ||
165 | |||
166 | /* | ||
167 | * Peer-identity of peer running collection point | ||
168 | */ | ||
169 | struct GNUNET_PeerIdentity *collection_point; | ||
170 | |||
171 | /* | ||
172 | * Time interval to send sensor information to collection point (e.g. every 30 mins) | ||
173 | */ | ||
174 | struct GNUNET_TIME_Relative collection_interval; | ||
175 | |||
176 | /* | ||
177 | * Flag specifying if value is to be communicated to the p2p network | ||
178 | */ | ||
179 | int p2p_report; | ||
180 | |||
181 | /* | ||
182 | * Time interval to communicate value to the p2p network | ||
183 | */ | ||
184 | struct GNUNET_TIME_Relative p2p_interval; | ||
185 | |||
186 | /* | ||
187 | * Execution task (OR GNUNET_SCHEDULER_NO_TASK) | ||
188 | */ | ||
189 | GNUNET_SCHEDULER_TaskIdentifier execution_task; | ||
190 | |||
191 | /* | ||
192 | * Is the sensor being executed | ||
193 | */ | ||
194 | int running; | ||
195 | |||
196 | }; | ||
197 | |||
198 | /** | ||
199 | * Structure containing brief info about sensor | 47 | * Structure containing brief info about sensor |
200 | */ | 48 | */ |
201 | struct SensorInfoShort | 49 | struct SensorInfoShort |
@@ -233,6 +81,11 @@ struct GNUNET_SENSOR_Reading | |||
233 | { | 81 | { |
234 | 82 | ||
235 | /** | 83 | /** |
84 | * GNUNET general message header | ||
85 | */ | ||
86 | struct GNUNET_MessageHeader *header; | ||
87 | |||
88 | /** | ||
236 | * Size of the sensor name value, allocated | 89 | * Size of the sensor name value, allocated |
237 | * at position 0 after this struct | 90 | * at position 0 after this struct |
238 | */ | 91 | */ |
diff --git a/src/include/gnunet_sensor_util_lib.h b/src/include/gnunet_sensor_util_lib.h new file mode 100644 index 000000000..15fb61b4c --- /dev/null +++ b/src/include/gnunet_sensor_util_lib.h | |||
@@ -0,0 +1,215 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file sensor/sensor_util_lib.c | ||
23 | * @brief senor utilities | ||
24 | * @author Omar Tarabai | ||
25 | */ | ||
26 | |||
27 | #ifndef GNUNET_SENSOR_UTIL_LIB_H | ||
28 | #define GNUNET_SENSOR_UTIL_LIB_H | ||
29 | |||
30 | #ifdef __cplusplus | ||
31 | extern "C" | ||
32 | { | ||
33 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
34 | } | ||
35 | #endif | ||
36 | #endif | ||
37 | |||
38 | /** | ||
39 | * Structure containing sensor definition | ||
40 | */ | ||
41 | struct SensorInfo | ||
42 | { | ||
43 | |||
44 | /** | ||
45 | * The configuration handle | ||
46 | * carrying sensor information | ||
47 | */ | ||
48 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
49 | |||
50 | /* | ||
51 | * Sensor name | ||
52 | */ | ||
53 | char *name; | ||
54 | |||
55 | /* | ||
56 | * Path to definition file | ||
57 | */ | ||
58 | char *def_file; | ||
59 | |||
60 | /* | ||
61 | * First part of version number | ||
62 | */ | ||
63 | uint16_t version_major; | ||
64 | |||
65 | /* | ||
66 | * Second part of version number | ||
67 | */ | ||
68 | uint16_t version_minor; | ||
69 | |||
70 | /* | ||
71 | * Sensor description | ||
72 | */ | ||
73 | char *description; | ||
74 | |||
75 | /* | ||
76 | * Sensor currently enabled | ||
77 | */ | ||
78 | int enabled; | ||
79 | |||
80 | /* | ||
81 | * Category under which the sensor falls (e.g. tcp, datastore) | ||
82 | */ | ||
83 | char *category; | ||
84 | |||
85 | /* | ||
86 | * When does the sensor become active | ||
87 | */ | ||
88 | struct GNUNET_TIME_Absolute *start_time; | ||
89 | |||
90 | /* | ||
91 | * When does the sensor expire | ||
92 | */ | ||
93 | struct GNUNET_TIME_Absolute *end_time; | ||
94 | |||
95 | /* | ||
96 | * Time interval to collect sensor information (e.g. every 1 min) | ||
97 | */ | ||
98 | struct GNUNET_TIME_Relative interval; | ||
99 | |||
100 | /* | ||
101 | * Lifetime of an information sample after which it is deleted from storage | ||
102 | * If not supplied, will default to the interval value | ||
103 | */ | ||
104 | struct GNUNET_TIME_Relative lifetime; | ||
105 | |||
106 | /* | ||
107 | * A set of required peer capabilities for the sensor to collect meaningful information (e.g. ipv6) | ||
108 | */ | ||
109 | char *capabilities; | ||
110 | |||
111 | /* | ||
112 | * Either "gnunet-statistics" or external "process" | ||
113 | */ | ||
114 | char *source; | ||
115 | |||
116 | /* | ||
117 | * Name of the GNUnet service that is the source for the gnunet-statistics entry | ||
118 | */ | ||
119 | char *gnunet_stat_service; | ||
120 | |||
121 | /* | ||
122 | * Name of the gnunet-statistics entry | ||
123 | */ | ||
124 | char *gnunet_stat_name; | ||
125 | |||
126 | /** | ||
127 | * Handle to statistics get request (OR GNUNET_SCHEDULER_NO_TASK) | ||
128 | */ | ||
129 | struct GNUNET_STATISTICS_GetHandle *gnunet_stat_get_handle; | ||
130 | |||
131 | /* | ||
132 | * Name of the external process to be executed | ||
133 | */ | ||
134 | char *ext_process; | ||
135 | |||
136 | /* | ||
137 | * Arguments to be passed to the external process | ||
138 | */ | ||
139 | char *ext_args; | ||
140 | |||
141 | /* | ||
142 | * Handle to the external process | ||
143 | */ | ||
144 | struct GNUNET_OS_CommandHandle *ext_cmd; | ||
145 | |||
146 | /* | ||
147 | * Did we already receive a value | ||
148 | * from the currently running external | ||
149 | * proccess ? #GNUNET_YES / #GNUNET_NO | ||
150 | */ | ||
151 | int ext_cmd_value_received; | ||
152 | |||
153 | /* | ||
154 | * The output datatype to be expected | ||
155 | */ | ||
156 | char *expected_datatype; | ||
157 | |||
158 | /* | ||
159 | * Peer-identity of peer running collection point | ||
160 | */ | ||
161 | struct GNUNET_PeerIdentity *collection_point; | ||
162 | |||
163 | /* | ||
164 | * Time interval to send sensor information to collection point (e.g. every 30 mins) | ||
165 | */ | ||
166 | struct GNUNET_TIME_Relative collection_interval; | ||
167 | |||
168 | /* | ||
169 | * Flag specifying if value is to be communicated to the p2p network | ||
170 | */ | ||
171 | int p2p_report; | ||
172 | |||
173 | /* | ||
174 | * Time interval to communicate value to the p2p network | ||
175 | */ | ||
176 | struct GNUNET_TIME_Relative p2p_interval; | ||
177 | |||
178 | /* | ||
179 | * Execution task (OR GNUNET_SCHEDULER_NO_TASK) | ||
180 | */ | ||
181 | GNUNET_SCHEDULER_TaskIdentifier execution_task; | ||
182 | |||
183 | /* | ||
184 | * Is the sensor being executed | ||
185 | */ | ||
186 | int running; | ||
187 | |||
188 | }; | ||
189 | |||
190 | /** | ||
191 | * Reads sensor definitions from local data files | ||
192 | * | ||
193 | * @return a multihashmap of loaded sensors | ||
194 | */ | ||
195 | struct GNUNET_CONTAINER_MultiHashMap * | ||
196 | GNUNET_SENSOR_load_all_sensors (); | ||
197 | |||
198 | /* | ||
199 | * Get path to the directory containing the sensor definition files | ||
200 | * | ||
201 | * @return sensor files directory | ||
202 | */ | ||
203 | char * | ||
204 | GNUNET_SENSOR_get_sensor_dir (); | ||
205 | |||
206 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
207 | { | ||
208 | #endif | ||
209 | #ifdef __cplusplus | ||
210 | } | ||
211 | #endif | ||
212 | |||
213 | /* ifndef GNUNET_SENSOR_UTIL_LIB_H */ | ||
214 | #endif | ||
215 | /* end of gnunet_sensor_util_lib.h */ | ||