diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-03-11 03:39:47 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-03-11 03:39:47 +0000 |
commit | 69d9f80b83053162a38a292fc8a024acb6a463a9 (patch) | |
tree | d8668cdb5c158e4c11b35a193ea19025af2c39d7 /src/mesh/gnunet-service-mesh.c | |
parent | e87e273ce5f864e20fcca02c34bef72de4fc00bd (diff) | |
download | gnunet-69d9f80b83053162a38a292fc8a024acb6a463a9.tar.gz gnunet-69d9f80b83053162a38a292fc8a024acb6a463a9.zip |
Added more data structures and functions to build the skeleton of mesh
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 91 |
1 files changed, 84 insertions, 7 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index bdfd1a3ac..449b8984c 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -25,6 +25,10 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <stdint.h> | 27 | #include <stdint.h> |
28 | #include "gnunet_common.h" | ||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_core_service.h" | ||
31 | #include <netinet/in.h> | ||
28 | 32 | ||
29 | /** | 33 | /** |
30 | * All the states a peer participating in a tunnel can be in. | 34 | * All the states a peer participating in a tunnel can be in. |
@@ -136,6 +140,11 @@ struct MESH_tunnel | |||
136 | uint32_t speed_max; | 140 | uint32_t speed_max; |
137 | 141 | ||
138 | /** | 142 | /** |
143 | * Last time the tunnel was used | ||
144 | */ | ||
145 | struct GNUNET_TIME_Absolute timestamp; | ||
146 | |||
147 | /** | ||
139 | * Peers in the tunnel, for future optimizations | 148 | * Peers in the tunnel, for future optimizations |
140 | */ | 149 | */ |
141 | struct PeerInfo *peers; | 150 | struct PeerInfo *peers; |
@@ -172,7 +181,76 @@ struct Clients | |||
172 | int fixme; | 181 | int fixme; |
173 | }; | 182 | }; |
174 | 183 | ||
184 | /** | ||
185 | * Handler for requests of creating new path | ||
186 | * | ||
187 | * @param cls closure | ||
188 | * @param client the client this message is from | ||
189 | * @param message the message received | ||
190 | */ | ||
191 | static void | ||
192 | handle_mesh_path_create (void *cls, | ||
193 | struct GNUNET_SERVER_Client *client, | ||
194 | const struct GNUNET_MessageHeader *message) | ||
195 | { | ||
196 | return; | ||
197 | } | ||
175 | 198 | ||
199 | /** | ||
200 | * Handler for client disconnection | ||
201 | * | ||
202 | * @param cls closure | ||
203 | * @param client identification of the client; NULL | ||
204 | * for the last call when the server is destroyed | ||
205 | */ | ||
206 | static void | ||
207 | handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | ||
208 | { | ||
209 | /* Remove client from list, delete all timers and queues associated */ | ||
210 | return; | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * Core handler for mesh network traffic | ||
215 | * | ||
216 | * @param cls closure | ||
217 | * @param message message | ||
218 | * @param peer peer identity this notification is about | ||
219 | * @param atsi performance data | ||
220 | * | ||
221 | */ | ||
222 | static int | ||
223 | handle_mesh_network_traffic (void *cls, | ||
224 | const struct GNUNET_PeerIdentity *peer, | ||
225 | const struct GNUNET_MessageHeader *message, | ||
226 | const struct GNUNET_TRANSPORT_ATS_Information | ||
227 | *atsi) | ||
228 | { | ||
229 | if(GNUNET_MESSAGE_TYPE_MESH_DATA_GO == ntohs(message->type)) { | ||
230 | /* Retransmit to next in path of tunnel identified by message */ | ||
231 | return 0; | ||
232 | } else { /* GNUNET_MESSAGE_TYPE_MESH_DATA_BACK */ | ||
233 | /* Retransmit to previous in path of tunnel identified by message */ | ||
234 | return 0; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | /** | ||
239 | * Functions to handle messages from core | ||
240 | */ | ||
241 | static struct GNUNET_CORE_MessageHandler core_handlers[] = { | ||
242 | {&handle_mesh_network_traffic, GNUNET_MESSAGE_TYPE_MESH_DATA_GO, 0}, | ||
243 | {&handle_mesh_network_traffic, GNUNET_MESSAGE_TYPE_MESH_DATA_BACK, 0}, | ||
244 | {NULL, 0, 0} | ||
245 | }; | ||
246 | |||
247 | /** | ||
248 | * Functions to handle messages from clients | ||
249 | */ | ||
250 | static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { | ||
251 | {&handle_mesh_path_create, NULL, GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, 0}, | ||
252 | {NULL, NULL, 0, 0} | ||
253 | }; | ||
176 | 254 | ||
177 | /** | 255 | /** |
178 | * Process mesh requests. FIXME NON FUNCTIONAL, COPIED FROM DHT!! | 256 | * Process mesh requests. FIXME NON FUNCTIONAL, COPIED FROM DHT!! |
@@ -189,17 +267,16 @@ run (void *cls, | |||
189 | struct GNUNET_TIME_Relative next_send_time; | 267 | struct GNUNET_TIME_Relative next_send_time; |
190 | unsigned long long temp_config_num; | 268 | unsigned long long temp_config_num; |
191 | char *converge_modifier_buf; | 269 | char *converge_modifier_buf; |
270 | GNUNET_CORE_Handle *coreAPI; | ||
192 | 271 | ||
193 | cfg = c; | ||
194 | datacache = GNUNET_DATACACHE_create (cfg, "dhtcache"); | ||
195 | GNUNET_SERVER_add_handlers (server, plugin_handlers); | 272 | GNUNET_SERVER_add_handlers (server, plugin_handlers); |
196 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); | 273 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); |
197 | coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */ | 274 | coreAPI = GNUNET_CORE_connect (c, /* Main configuration */ |
198 | DEFAULT_CORE_QUEUE_SIZE, /* queue size */ | 275 | 32, /* queue size */ |
199 | NULL, /* Closure passed to DHT functions */ | 276 | NULL, /* Closure passed to DHT functions */ |
200 | &core_init, /* Call core_init once connected */ | 277 | NULL, /* Call core_init once connected */ |
201 | &handle_core_connect, /* Handle connects */ | 278 | NULL, /* Handle connects */ |
202 | &handle_core_disconnect, /* remove peers on disconnects */ | 279 | NULL, /* remove peers on disconnects */ |
203 | NULL, /* Do we care about "status" updates? */ | 280 | NULL, /* Do we care about "status" updates? */ |
204 | NULL, /* Don't want notified about all incoming messages */ | 281 | NULL, /* Don't want notified about all incoming messages */ |
205 | GNUNET_NO, /* For header only inbound notification */ | 282 | GNUNET_NO, /* For header only inbound notification */ |