diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_mesh_service.h | 2 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 91 | ||||
-rw-r--r-- | src/mesh/mesh.h | 6 | ||||
-rw-r--r-- | src/mesh/mesh_api.c | 2 |
4 files changed, 92 insertions, 9 deletions
diff --git a/src/include/gnunet_mesh_service.h b/src/include/gnunet_mesh_service.h index 36dbafb86..1677c714c 100644 --- a/src/include/gnunet_mesh_service.h +++ b/src/include/gnunet_mesh_service.h | |||
@@ -213,7 +213,7 @@ GNUNET_MESH_peer_request_connect_any (struct GNUNET_MESH_Handle *h, | |||
213 | * | 213 | * |
214 | * @param h mesh handle | 214 | * @param h mesh handle |
215 | * @param timeout how long to try to establish a connection | 215 | * @param timeout how long to try to establish a connection |
216 | * @param num_peers length of the peers arrray | 216 | * @param num_peers length of the peers array |
217 | * @param peers list of candidates to connect to | 217 | * @param peers list of candidates to connect to |
218 | * @param connect_handler function to call on successful connect (or timeout); | 218 | * @param connect_handler function to call on successful connect (or timeout); |
219 | * will be called for EACH of the peers in the list and | 219 | * will be called for EACH of the peers in the list and |
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 */ |
diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h index 57778a352..085f3ef4d 100644 --- a/src/mesh/mesh.h +++ b/src/mesh/mesh.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #ifndef MESH_H_ | 27 | #ifndef MESH_H_ |
28 | #define MESH_H_ | 28 | #define MESH_H_ |
29 | #include <stdint.h> | 29 | #include <stdint.h> |
30 | #include "gnunet_common.h" | ||
30 | 31 | ||
31 | /** | 32 | /** |
32 | * Message for mesh path management | 33 | * Message for mesh path management |
@@ -81,6 +82,11 @@ struct GNUNET_MESH_Data | |||
81 | uint32_t tid; | 82 | uint32_t tid; |
82 | 83 | ||
83 | /** | 84 | /** |
85 | * FIXME Some form of authentication | ||
86 | */ | ||
87 | uint32_t token; | ||
88 | |||
89 | /** | ||
84 | * Size of payload | 90 | * Size of payload |
85 | * FIXME uint16 enough? | 91 | * FIXME uint16 enough? |
86 | */ | 92 | */ |
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 3421e2c6f..f714d32bb 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c | |||
@@ -469,7 +469,7 @@ GNUNET_MESH_connect (const struct | |||
469 | ret->connected_peers.tail = NULL; | 469 | ret->connected_peers.tail = NULL; |
470 | ret->cleaner = cleaner; | 470 | ret->cleaner = cleaner; |
471 | ret->cls = cls; | 471 | ret->cls = cls; |
472 | 472 | ||
473 | const struct GNUNET_MESH_MessageHandler *it; | 473 | const struct GNUNET_MESH_MessageHandler *it; |
474 | unsigned int len = 1; | 474 | unsigned int len = 1; |
475 | for (it = handlers; it->callback != NULL; it++) | 475 | for (it = handlers; it->callback != NULL; it++) |