diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-01 09:25:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-01 09:25:06 +0000 |
commit | 941a901163d150d701e12d9b0b85cbb582c114b6 (patch) | |
tree | c7be2d9c2bdaf3278c515df9e2106bf396c78afd | |
parent | 1e72e368fc1026b2afe5094891c2e41edf211877 (diff) | |
download | gnunet-941a901163d150d701e12d9b0b85cbb582c114b6.tar.gz gnunet-941a901163d150d701e12d9b0b85cbb582c114b6.zip |
-messing up experimentation some more, towards using egos instead of peer identities
3 files changed, 833 insertions, 830 deletions
diff --git a/src/experimentation/gnunet-daemon-experimentation.h b/src/experimentation/gnunet-daemon-experimentation.h index 838d06b69..cfcedcd13 100644 --- a/src/experimentation/gnunet-daemon-experimentation.h +++ b/src/experimentation/gnunet-daemon-experimentation.h | |||
@@ -51,39 +51,33 @@ | |||
51 | */ | 51 | */ |
52 | extern struct GNUNET_STATISTICS_Handle *GED_stats; | 52 | extern struct GNUNET_STATISTICS_Handle *GED_stats; |
53 | 53 | ||
54 | |||
55 | /** | 54 | /** |
56 | * Configuration handle shared between components | 55 | * Configuration handle shared between components |
57 | */ | 56 | */ |
58 | extern struct GNUNET_CONFIGURATION_Handle *GED_cfg; | 57 | extern struct GNUNET_CONFIGURATION_Handle *GED_cfg; |
59 | 58 | ||
60 | |||
61 | /** | 59 | /** |
62 | * Capability value shared between components | 60 | * Capability value shared between components |
63 | */ | 61 | */ |
64 | extern uint32_t GSE_node_capabilities; | 62 | extern uint32_t GSE_node_capabilities; |
65 | 63 | ||
66 | 64 | ||
67 | extern uint32_t GSE_my_issuer_count; | ||
68 | |||
69 | extern struct Experimentation_Issuer *GSE_my_issuer; | ||
70 | |||
71 | /** | 65 | /** |
72 | * Capabilities a node has or an experiment requires | 66 | * Capabilities a node has or an experiment requires |
73 | */ | 67 | */ |
74 | enum GNUNET_EXPERIMENTATION_capabilities | 68 | enum GNUNET_EXPERIMENTATION_capabilities |
75 | { | 69 | { |
76 | NONE = 0, | 70 | NONE = 0, |
77 | PLUGIN_TCP = 1, | 71 | PLUGIN_TCP = 1, |
78 | PLUGIN_UDP = 2, | 72 | PLUGIN_UDP = 2, |
79 | PLUGIN_UNIX = 4, | 73 | PLUGIN_UNIX = 4, |
80 | PLUGIN_HTTP_CLIENT = 8, | 74 | PLUGIN_HTTP_CLIENT = 8, |
81 | PLUGIN_HTTP_SERVER = 16, | 75 | PLUGIN_HTTP_SERVER = 16, |
82 | PLUGIN_HTTPS_CLIENT = 32, | 76 | PLUGIN_HTTPS_CLIENT = 32, |
83 | PLUGIN_HTTPS_SERVER = 64, | 77 | PLUGIN_HTTPS_SERVER = 64, |
84 | PLUGIN_WLAN = 128, | 78 | PLUGIN_WLAN = 128, |
85 | HAVE_IPV6 = 256, | 79 | HAVE_IPV6 = 256, |
86 | BEHIND_NAT = 512 | 80 | BEHIND_NAT = 512 |
87 | }; | 81 | }; |
88 | 82 | ||
89 | 83 | ||
@@ -92,42 +86,58 @@ enum GNUNET_EXPERIMENTATION_capabilities | |||
92 | */ | 86 | */ |
93 | struct Experiment | 87 | struct Experiment |
94 | { | 88 | { |
95 | /* Header */ | 89 | /* Header */ |
96 | /* ----------------- */ | 90 | /* ----------------- */ |
97 | char *name; | 91 | char *name; |
98 | 92 | ||
99 | /* Experiment issuer */ | 93 | /** |
100 | struct GNUNET_PeerIdentity issuer; | 94 | * Experiment issuer |
101 | 95 | */ | |
102 | /* Experiment version as timestamp of creation */ | 96 | struct GNUNET_CRYPTO_EccPublicSignKey issuer; |
103 | struct GNUNET_TIME_Absolute version; | 97 | |
104 | 98 | /** | |
105 | /* Description */ | 99 | * Experiment version as timestamp of creation |
106 | char *description; | 100 | */ |
107 | 101 | struct GNUNET_TIME_Absolute version; | |
108 | /* Required capabilities */ | 102 | |
109 | uint32_t required_capabilities; | 103 | /** |
110 | 104 | * Description | |
111 | /* Experiment timing */ | 105 | */ |
112 | /* ----------------- */ | 106 | char *description; |
113 | 107 | ||
114 | /* When to start experiment */ | 108 | /** |
115 | struct GNUNET_TIME_Absolute start; | 109 | * Required capabilities |
116 | 110 | */ | |
117 | /* When to end experiment */ | 111 | uint32_t required_capabilities; |
118 | struct GNUNET_TIME_Absolute stop; | 112 | |
119 | 113 | /* Experiment timing */ | |
120 | /* How often to run experiment */ | 114 | /* ----------------- */ |
121 | struct GNUNET_TIME_Relative frequency; | 115 | |
122 | 116 | /** | |
123 | /* How long to run each execution */ | 117 | * When to start experiment |
124 | struct GNUNET_TIME_Relative duration; | 118 | */ |
125 | 119 | struct GNUNET_TIME_Absolute start; | |
126 | 120 | ||
127 | /* Experiment itself */ | 121 | /** |
128 | /* ----------------- */ | 122 | * When to end experiment |
129 | 123 | */ | |
130 | /* TBD */ | 124 | struct GNUNET_TIME_Absolute stop; |
125 | |||
126 | /** | ||
127 | * How often to run experiment | ||
128 | */ | ||
129 | struct GNUNET_TIME_Relative frequency; | ||
130 | |||
131 | /** | ||
132 | * How long to run each execution | ||
133 | */ | ||
134 | struct GNUNET_TIME_Relative duration; | ||
135 | |||
136 | |||
137 | /* Experiment itself */ | ||
138 | /* ----------------- */ | ||
139 | |||
140 | /* TBD */ | ||
131 | }; | 141 | }; |
132 | 142 | ||
133 | 143 | ||
@@ -136,44 +146,36 @@ struct Experiment | |||
136 | */ | 146 | */ |
137 | struct Node | 147 | struct Node |
138 | { | 148 | { |
139 | /** | 149 | /** |
140 | * Peer id | 150 | * Peer id |
141 | */ | 151 | */ |
142 | struct GNUNET_PeerIdentity id; | 152 | struct GNUNET_PeerIdentity id; |
143 | 153 | ||
144 | /** | 154 | /** |
145 | * Task for response timeout | 155 | * Task for response timeout |
146 | */ | 156 | */ |
147 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 157 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; |
148 | 158 | ||
149 | /** | 159 | /** |
150 | * Core transmission handle | 160 | * Core transmission handle |
151 | */ | 161 | */ |
152 | struct GNUNET_CORE_TransmitHandle *cth; | 162 | struct GNUNET_CORE_TransmitHandle *cth; |
153 | 163 | ||
154 | /** | 164 | /** |
155 | * Node capabilities | 165 | * Node capabilities |
156 | */ | 166 | */ |
157 | uint32_t capabilities; | 167 | uint32_t capabilities; |
158 | 168 | ||
159 | /* Experiment version as timestamp of creation */ | 169 | /** |
160 | struct GNUNET_TIME_Absolute version; | 170 | * Experiment version as timestamp of creation |
161 | 171 | */ | |
162 | uint32_t issuer_count; | 172 | struct GNUNET_TIME_Absolute version; |
163 | 173 | ||
164 | /** | 174 | struct NodeComCtx *e_req_head; |
165 | * Array of fssuer ids | 175 | |
166 | */ | 176 | struct NodeComCtx *e_req_tail; |
167 | struct GNUNET_PeerIdentity *issuer_id; | ||
168 | |||
169 | struct NodeComCtx *e_req_head; | ||
170 | struct NodeComCtx *e_req_tail; | ||
171 | }; | 177 | }; |
172 | 178 | ||
173 | struct Experimentation_Issuer | ||
174 | { | ||
175 | struct GNUNET_PeerIdentity issuer_id; | ||
176 | }; | ||
177 | 179 | ||
178 | GNUNET_NETWORK_STRUCT_BEGIN | 180 | GNUNET_NETWORK_STRUCT_BEGIN |
179 | 181 | ||
@@ -182,86 +184,117 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
182 | * Used to detect experimentation capability | 184 | * Used to detect experimentation capability |
183 | * | 185 | * |
184 | * This struct is followed by issuer identities: | 186 | * This struct is followed by issuer identities: |
185 | * (issuer_count * struct Experimentation_Request_Issuer) | 187 | * (issuer_count * struct GNUNET_CRYPTO_EccPublicSignKey) |
186 | * | 188 | * |
187 | */ | 189 | */ |
188 | struct Experimentation_Request | 190 | struct Experimentation_Request |
189 | { | 191 | { |
190 | struct GNUNET_MessageHeader msg; | 192 | struct GNUNET_MessageHeader msg; |
191 | 193 | ||
192 | uint32_t capabilities; | 194 | uint32_t capabilities GNUNET_PACKED; |
193 | 195 | ||
194 | uint32_t issuer_count; | 196 | uint32_t issuer_count GNUNET_PACKED; |
195 | }; | 197 | }; |
196 | 198 | ||
199 | |||
197 | /** | 200 | /** |
198 | * Experimentation response message | 201 | * Experimentation response message |
199 | * Sent if peer is running the daemon | 202 | * Sent if peer is running the daemon |
200 | * | 203 | * |
201 | * This struct is followed by issuer identities: | 204 | * This struct is followed by issuer identities: |
202 | * (issuer_count * struct Experimentation_Request_Issuer) | 205 | * (issuer_count * struct GNUNET_CRYPTO_EccPublicSignKey) |
203 | */ | 206 | */ |
204 | struct Experimentation_Response | 207 | struct Experimentation_Response |
205 | { | 208 | { |
206 | struct GNUNET_MessageHeader msg; | 209 | struct GNUNET_MessageHeader msg; |
210 | |||
211 | uint32_t capabilities GNUNET_PACKED; | ||
212 | |||
213 | uint32_t issuer_count GNUNET_PACKED; | ||
214 | }; | ||
207 | 215 | ||
208 | uint32_t capabilities; | ||
209 | 216 | ||
210 | uint32_t issuer_count; | 217 | /** |
218 | * Struct to store information about an experiment issuer | ||
219 | */ | ||
220 | struct Issuer | ||
221 | { | ||
222 | struct GNUNET_CRYPTO_EccPublicSignKey pubkey; | ||
211 | }; | 223 | }; |
212 | 224 | ||
213 | 225 | ||
214 | /** | 226 | /** |
227 | * Hashmap containing valid experiment issuers | ||
228 | * (the key is the hash of the respective public key, | ||
229 | * the values are of type `struct Issuer'). | ||
230 | */ | ||
231 | struct GNUNET_CONTAINER_MultiHashMap *valid_issuers; | ||
232 | |||
233 | /** | ||
215 | * Experiment start message | 234 | * Experiment start message |
216 | * | 235 | * |
217 | * struct is followed by string with length len_name | 236 | * struct is followed by string with length len_name |
218 | */ | 237 | */ |
219 | struct GED_start_message | 238 | struct GED_start_message |
220 | { | 239 | { |
221 | struct GNUNET_MessageHeader header; | 240 | struct GNUNET_MessageHeader header; |
222 | 241 | ||
223 | /** | 242 | /** |
224 | * String length of experiment name following the struct | 243 | * String length of experiment name following the struct |
225 | */ | 244 | */ |
226 | uint32_t len_name; | 245 | uint32_t len_name GNUNET_PACKED; |
227 | 246 | ||
228 | /* Experiment issuer */ | 247 | /** |
229 | struct GNUNET_PeerIdentity issuer; | 248 | * Experiment issuer |
230 | 249 | */ | |
231 | /* Experiment version as timestamp of creation */ | 250 | struct GNUNET_CRYPTO_EccPublicSignKey issuer; |
232 | struct GNUNET_TIME_AbsoluteNBO version_nbo; | 251 | |
252 | /** | ||
253 | * Experiment version as timestamp of creation | ||
254 | */ | ||
255 | struct GNUNET_TIME_AbsoluteNBO version_nbo; | ||
233 | }; | 256 | }; |
234 | 257 | ||
258 | |||
235 | struct GED_start_ack_message | 259 | struct GED_start_ack_message |
236 | { | 260 | { |
237 | struct GNUNET_MessageHeader header; | 261 | struct GNUNET_MessageHeader header; |
238 | 262 | ||
239 | /** | 263 | /** |
240 | * String length of experiment name following the struct | 264 | * String length of experiment name following the struct |
241 | */ | 265 | */ |
242 | uint32_t len_name; | 266 | uint32_t len_name GNUNET_PACKED; |
243 | 267 | ||
244 | /* Experiment issuer */ | 268 | /** |
245 | struct GNUNET_PeerIdentity issuer; | 269 | * Experiment issuer |
246 | 270 | */ | |
247 | /* Experiment version as timestamp of creation */ | 271 | struct GNUNET_CRYPTO_EccPublicSignKey issuer; |
248 | struct GNUNET_TIME_AbsoluteNBO version_nbo; | 272 | |
273 | /** | ||
274 | * Experiment version as timestamp of creation | ||
275 | */ | ||
276 | struct GNUNET_TIME_AbsoluteNBO version_nbo; | ||
249 | }; | 277 | }; |
250 | 278 | ||
279 | |||
251 | struct GED_stop_message | 280 | struct GED_stop_message |
252 | { | 281 | { |
253 | struct GNUNET_MessageHeader header; | 282 | struct GNUNET_MessageHeader header; |
254 | 283 | ||
255 | /** | 284 | /** |
256 | * String length of experiment name following the struct | 285 | * String length of experiment name following the struct |
257 | */ | 286 | */ |
258 | uint32_t len_name; | 287 | uint32_t len_name GNUNET_PACKED; |
259 | 288 | ||
260 | /* Experiment issuer */ | 289 | /** |
261 | struct GNUNET_PeerIdentity issuer; | 290 | * Experiment issuer |
262 | 291 | */ | |
263 | /* Experiment version as timestamp of creation */ | 292 | struct GNUNET_CRYPTO_EccPublicSignKey issuer; |
264 | struct GNUNET_TIME_AbsoluteNBO version_nbo; | 293 | |
294 | /** | ||
295 | * Experiment version as timestamp of creation | ||
296 | */ | ||
297 | struct GNUNET_TIME_AbsoluteNBO version_nbo; | ||
265 | }; | 298 | }; |
266 | 299 | ||
267 | GNUNET_NETWORK_STRUCT_END | 300 | GNUNET_NETWORK_STRUCT_END |
@@ -270,13 +303,15 @@ GNUNET_NETWORK_STRUCT_END | |||
270 | int | 303 | int |
271 | GED_nodes_rts (struct Node *n); | 304 | GED_nodes_rts (struct Node *n); |
272 | 305 | ||
306 | |||
273 | int | 307 | int |
274 | GED_nodes_send_start (struct Node *n, struct Experiment *e); | 308 | GED_nodes_send_start (struct Node *n, struct Experiment *e); |
275 | 309 | ||
310 | |||
276 | /** | 311 | /** |
277 | * Confirm a experiment START with a node | 312 | * Confirm a experiment START with a node |
278 | * | 313 | * |
279 | * @return GNUNET_NO if core was busy with sending, GNUNET_OK otherwise | 314 | * @return #GNUNET_NO if core was busy with sending, #GNUNET_OK otherwise |
280 | */ | 315 | */ |
281 | int | 316 | int |
282 | GED_nodes_send_start_ack (struct Node *n, struct Experiment *e); | 317 | GED_nodes_send_start_ack (struct Node *n, struct Experiment *e); |
@@ -285,14 +320,14 @@ GED_nodes_send_start_ack (struct Node *n, struct Experiment *e); | |||
285 | * Start the nodes management | 320 | * Start the nodes management |
286 | */ | 321 | */ |
287 | void | 322 | void |
288 | GED_nodes_start (); | 323 | GED_nodes_start (void); |
289 | 324 | ||
290 | 325 | ||
291 | /** | 326 | /** |
292 | * Stop the nodes management | 327 | * Stop the nodes management |
293 | */ | 328 | */ |
294 | void | 329 | void |
295 | GED_nodes_stop (); | 330 | GED_nodes_stop (void); |
296 | 331 | ||
297 | 332 | ||
298 | /** | 333 | /** |
@@ -310,7 +345,7 @@ GED_capability_to_str (uint32_t cap); | |||
310 | * | 345 | * |
311 | * @param have bitstring containing the provided capabilities | 346 | * @param have bitstring containing the provided capabilities |
312 | * @param desired bitstring containing the desired capabilities\ | 347 | * @param desired bitstring containing the desired capabilities\ |
313 | * @return GNUNET_YES or GNUNET_NO | 348 | * @return #GNUNET_YES or #GNUNET_NO |
314 | */ | 349 | */ |
315 | int | 350 | int |
316 | GED_capabilities_have (uint32_t have, uint32_t desired); | 351 | GED_capabilities_have (uint32_t have, uint32_t desired); |
@@ -320,23 +355,23 @@ GED_capabilities_have (uint32_t have, uint32_t desired); | |||
320 | * Start the detecting capabilities | 355 | * Start the detecting capabilities |
321 | */ | 356 | */ |
322 | void | 357 | void |
323 | GED_capabilities_start (); | 358 | GED_capabilities_start (void); |
324 | 359 | ||
325 | 360 | ||
326 | /** | 361 | /** |
327 | * Stop the detecting capabilities | 362 | * Stop the detecting capabilities |
328 | */ | 363 | */ |
329 | void | 364 | void |
330 | GED_capabilities_stop (); | 365 | GED_capabilities_stop (void); |
331 | 366 | ||
332 | 367 | ||
333 | /** | 368 | /** |
334 | * Start experiments management | 369 | * Start experiments management |
335 | * | 370 | * |
336 | * @return GNUNET_YES or GNUNET_NO | 371 | * @return #GNUNET_YES or #GNUNET_NO |
337 | */ | 372 | */ |
338 | int | 373 | int |
339 | GED_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID); | 374 | GED_experiments_issuer_accepted (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer_ID); |
340 | 375 | ||
341 | 376 | ||
342 | /* | 377 | /* |
@@ -348,33 +383,36 @@ GED_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID); | |||
348 | * @return the experiment or NULL if not found | 383 | * @return the experiment or NULL if not found |
349 | */ | 384 | */ |
350 | struct Experiment * | 385 | struct Experiment * |
351 | GED_experiments_find (const struct GNUNET_PeerIdentity *issuer, | 386 | GED_experiments_find (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer, |
352 | const char *name, | 387 | const char *name, |
353 | const struct GNUNET_TIME_Absolute version); | 388 | const struct GNUNET_TIME_Absolute version); |
354 | 389 | ||
355 | 390 | ||
356 | typedef void (*GNUNET_EXPERIMENTATION_experiments_get_cb) (struct Node *n, struct Experiment *e); | 391 | typedef void (*GNUNET_EXPERIMENTATION_experiments_get_cb) (struct Node *n, |
392 | struct Experiment *e); | ||
357 | 393 | ||
358 | 394 | ||
359 | void | 395 | void |
360 | GED_experiments_get (struct Node *n, | 396 | GED_experiments_get (struct Node *n, |
361 | struct GNUNET_PeerIdentity *issuer, | 397 | struct GNUNET_CRYPTO_EccPublicSignKey *issuer, |
362 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb); | 398 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb); |
399 | |||
363 | 400 | ||
364 | /** | 401 | /** |
365 | * Start experiments management | 402 | * Start experiments management |
366 | * | 403 | * |
367 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 404 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
368 | */ | 405 | */ |
369 | int | 406 | int |
370 | GED_experiments_start (); | 407 | GED_experiments_start (void); |
371 | 408 | ||
372 | 409 | ||
373 | /** | 410 | /** |
374 | * Stop experiments management | 411 | * Stop experiments management |
375 | */ | 412 | */ |
376 | void | 413 | void |
377 | GED_experiments_stop (); | 414 | GED_experiments_stop (void); |
415 | |||
378 | 416 | ||
379 | /** | 417 | /** |
380 | * Handle a START message from a remote node | 418 | * Handle a START message from a remote node |
@@ -395,6 +433,7 @@ GED_scheduler_handle_start (struct Node *n, struct Experiment *e); | |||
395 | void | 433 | void |
396 | GED_scheduler_handle_start_ack (struct Node *n, struct Experiment *e); | 434 | GED_scheduler_handle_start_ack (struct Node *n, struct Experiment *e); |
397 | 435 | ||
436 | |||
398 | /** | 437 | /** |
399 | * Handle a STOP message from a remote node | 438 | * Handle a STOP message from a remote node |
400 | * | 439 | * |
@@ -410,38 +449,40 @@ GED_scheduler_handle_stop (struct Node *n, struct Experiment *e); | |||
410 | * | 449 | * |
411 | * @param n the node | 450 | * @param n the node |
412 | * @param e the experiment | 451 | * @param e the experiment |
413 | * @param outbound are we initiator (GNUNET_YES) or client (GNUNET_NO)? | 452 | * @param outbound are we initiator (#GNUNET_YES) or client (#GNUNET_NO)? |
414 | */ | 453 | */ |
415 | void | 454 | void |
416 | GED_scheduler_add (struct Node *n, struct Experiment *e, int outbound); | 455 | GED_scheduler_add (struct Node *n, |
456 | struct Experiment *e, | ||
457 | int outbound); | ||
458 | |||
417 | 459 | ||
418 | /** | 460 | /** |
419 | * Start the scheduler component | 461 | * Start the scheduler component |
420 | */ | 462 | */ |
421 | void | 463 | void |
422 | GED_scheduler_start (); | 464 | GED_scheduler_start (void); |
423 | 465 | ||
424 | 466 | ||
425 | /** | 467 | /** |
426 | * Stop the scheduler component | 468 | * Stop the scheduler component |
427 | */ | 469 | */ |
428 | void | 470 | void |
429 | GED_scheduler_stop (); | 471 | GED_scheduler_stop (void); |
430 | 472 | ||
431 | 473 | ||
432 | /** | 474 | /** |
433 | * Start the storage component | 475 | * Start the storage component |
434 | */ | 476 | */ |
435 | void | 477 | void |
436 | GED_storage_start (); | 478 | GED_storage_start (void); |
437 | |||
438 | 479 | ||
439 | 480 | ||
440 | /** | 481 | /** |
441 | * Stop the storage component | 482 | * Stop the storage component |
442 | */ | 483 | */ |
443 | void | 484 | void |
444 | GED_storage_stop (); | 485 | GED_storage_stop (void); |
445 | 486 | ||
446 | 487 | ||
447 | /* end of gnunet-daemon-experimentation.h */ | 488 | /* end of gnunet-daemon-experimentation.h */ |
diff --git a/src/experimentation/gnunet-daemon-experimentation_experiments.c b/src/experimentation/gnunet-daemon-experimentation_experiments.c index d0dda1b1b..3c00b72ab 100644 --- a/src/experimentation/gnunet-daemon-experimentation_experiments.c +++ b/src/experimentation/gnunet-daemon-experimentation_experiments.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2012,2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -32,18 +32,9 @@ | |||
32 | 32 | ||
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Struct to store information about an experiment issuer | 35 | * Hashmap containing valid experiment issuers. |
36 | */ | 36 | */ |
37 | struct Issuer | 37 | struct GNUNET_CONTAINER_MultiHashMap *valid_issuers; |
38 | { | ||
39 | struct GNUNET_CRYPTO_EccPublicSignKey pubkey; | ||
40 | }; | ||
41 | |||
42 | |||
43 | /** | ||
44 | * Hashmap containing valid experiment issuer | ||
45 | */ | ||
46 | static struct GNUNET_CONTAINER_MultiHashMap *valid_issuers; | ||
47 | 38 | ||
48 | /** | 39 | /** |
49 | * Hashmap containing valid experiments | 40 | * Hashmap containing valid experiments |
@@ -51,22 +42,12 @@ static struct GNUNET_CONTAINER_MultiHashMap *valid_issuers; | |||
51 | static struct GNUNET_CONTAINER_MultiHashMap *experiments; | 42 | static struct GNUNET_CONTAINER_MultiHashMap *experiments; |
52 | 43 | ||
53 | 44 | ||
54 | static uint32_t GSE_my_issuer_count; | ||
55 | |||
56 | /** | ||
57 | * Valid experiment issuer for this daemon | ||
58 | * | ||
59 | * Array Experimentation_Issuer with GSE_my_issuer_count elements | ||
60 | */ | ||
61 | static struct Experimentation_Issuer *GSE_my_issuer; | ||
62 | |||
63 | |||
64 | /** | 45 | /** |
65 | * Verify experiment signature | 46 | * Verify experiment signature |
66 | * | 47 | * |
67 | * @param i issuer | 48 | * @param i issuer |
68 | * @param e experiment | 49 | * @param e experiment |
69 | * @return GNUNET_OK or GNUNET_SYSERR | 50 | * @return #GNUNET_OK or #GNUNET_SYSERR |
70 | */ | 51 | */ |
71 | static int | 52 | static int |
72 | experiment_verify (struct Issuer *i, struct Experiment *e) | 53 | experiment_verify (struct Issuer *i, struct Experiment *e) |
@@ -110,70 +91,51 @@ free_issuer (void *cls, | |||
110 | { | 91 | { |
111 | struct Issuer *i = value; | 92 | struct Issuer *i = value; |
112 | 93 | ||
113 | GNUNET_break (0 == GNUNET_CONTAINER_multihashmap_remove (valid_issuers, key, value)); | 94 | GNUNET_break (0 == GNUNET_CONTAINER_multihashmap_remove (valid_issuers, |
95 | key, | ||
96 | i)); | ||
114 | GNUNET_free (i); | 97 | GNUNET_free (i); |
115 | return GNUNET_OK; | 98 | return GNUNET_OK; |
116 | } | 99 | } |
117 | 100 | ||
118 | 101 | ||
119 | static int | ||
120 | create_issuer (void *cls, | ||
121 | const struct GNUNET_HashCode * key, | ||
122 | void *value) | ||
123 | { | ||
124 | static int i = 0; | ||
125 | |||
126 | GNUNET_assert (i < GSE_my_issuer_count); | ||
127 | GSE_my_issuer[i].issuer_id.hashPubKey = *key; | ||
128 | |||
129 | i++; | ||
130 | return GNUNET_OK; | ||
131 | } | ||
132 | |||
133 | |||
134 | |||
135 | /** | 102 | /** |
136 | * Is peer a valid issuer | 103 | * Is peer a valid issuer |
137 | * | 104 | * |
138 | * @return GNUNET_YES or GNUNET_NO | 105 | * @return #GNUNET_YES or #GNUNET_NO |
139 | */ | 106 | */ |
140 | int | 107 | int |
141 | GED_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID) | 108 | GED_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_id) |
142 | { | 109 | { |
143 | if (GNUNET_CONTAINER_multihashmap_contains (valid_issuers, &issuer_ID->hashPubKey)) | 110 | struct GNUNET_HashCode hash; |
111 | |||
112 | GNUNET_CRYPTO_hash (issuer_id, sizeof (struct GNUNET_PeerIdentity), &hash); | ||
113 | if (GNUNET_CONTAINER_multihashmap_contains (valid_issuers, &hash)) | ||
144 | return GNUNET_YES; | 114 | return GNUNET_YES; |
145 | else | 115 | return GNUNET_NO; |
146 | return GNUNET_NO; | ||
147 | } | 116 | } |
148 | 117 | ||
149 | 118 | ||
150 | struct FindCtx | 119 | /** |
151 | { | 120 | * Get the key under which the given experiment is stored in the |
152 | const char *name; | 121 | * experiment map. |
153 | struct GNUNET_TIME_Absolute version; | 122 | */ |
154 | struct Experiment *res; | 123 | static void |
155 | }; | 124 | get_experment_key (const struct GNUNET_PeerIdentity *issuer, |
156 | 125 | const char *name, | |
157 | 126 | const struct GNUNET_TIME_Absolute version, | |
158 | static int | 127 | struct GNUNET_HashCode *key) |
159 | find_it (void *cls, | ||
160 | const struct GNUNET_HashCode * key, | ||
161 | void *value) | ||
162 | { | 128 | { |
163 | struct FindCtx *find_ctx = cls; | 129 | GNUNET_assert (GNUNET_YES == |
164 | struct Experiment *e = (struct Experiment *) value; | 130 | GNUNET_CRYPTO_kdf (key, sizeof (struct GNUNET_HashCode), |
165 | 131 | issuer, sizeof (struct GNUNET_PeerIdentity), | |
166 | if (0 != strcmp(e->name, find_ctx->name)) | 132 | name, strlen (name), |
167 | return GNUNET_OK; | 133 | &version, sizeof (version), |
168 | if (e->version.abs_value_us != find_ctx->version.abs_value_us) | 134 | NULL, 0)); |
169 | return GNUNET_OK; | ||
170 | |||
171 | find_ctx->res = e; | ||
172 | return GNUNET_NO; | ||
173 | } | 135 | } |
174 | 136 | ||
175 | 137 | ||
176 | /* | 138 | /** |
177 | * Find an experiment based on issuer name and version | 139 | * Find an experiment based on issuer name and version |
178 | * | 140 | * |
179 | * @param issuer the issuer | 141 | * @param issuer the issuer |
@@ -186,43 +148,46 @@ GED_experiments_find (const struct GNUNET_PeerIdentity *issuer, | |||
186 | const char *name, | 148 | const char *name, |
187 | const struct GNUNET_TIME_Absolute version) | 149 | const struct GNUNET_TIME_Absolute version) |
188 | { | 150 | { |
189 | struct FindCtx find_ctx; | 151 | struct GNUENT_HashCode hc; |
190 | |||
191 | find_ctx.name = name; | ||
192 | find_ctx.version = version; | ||
193 | find_ctx.res = NULL; | ||
194 | 152 | ||
195 | GNUNET_CONTAINER_multihashmap_get_multiple (experiments, | 153 | get_experiment_key (issuer, |
196 | &issuer->hashPubKey, | 154 | name, |
197 | &find_it, &find_ctx); | 155 | version, |
198 | return find_ctx.res; | 156 | &hc); |
157 | return GNUNET_CONTAINER_multihashmap_get (experiments, | ||
158 | &hc); | ||
199 | } | 159 | } |
200 | 160 | ||
201 | 161 | ||
202 | struct GetCtx | 162 | struct GetCtx |
203 | { | 163 | { |
204 | struct Node *n; | 164 | struct Node *n; |
165 | |||
205 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb; | 166 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb; |
167 | |||
168 | struct GNUNET_CRYPTO_EccPublicSignKey *issuer; | ||
206 | }; | 169 | }; |
207 | 170 | ||
208 | 171 | ||
209 | static int | 172 | static int |
210 | get_it (void *cls, | 173 | get_it (void *cls, |
211 | const struct GNUNET_HashCode * key, | 174 | const struct GNUNET_HashCode *key, |
212 | void *value) | 175 | void *value) |
213 | { | 176 | { |
214 | struct GetCtx *get_ctx = cls; | 177 | struct GetCtx *get_ctx = cls; |
215 | struct Experiment *e = value; | 178 | struct Experiment *e = value; |
216 | 179 | ||
217 | get_ctx->get_cb (get_ctx->n, e); | 180 | if (0 == memcmp (e->issuer, |
218 | 181 | get_ctx->issuer, | |
182 | sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)) | ||
183 | get_ctx->get_cb (get_ctx->n, e); | ||
219 | return GNUNET_OK; | 184 | return GNUNET_OK; |
220 | } | 185 | } |
221 | 186 | ||
222 | 187 | ||
223 | void | 188 | void |
224 | GED_experiments_get (struct Node *n, | 189 | GED_experiments_get (struct Node *n, |
225 | struct GNUNET_PeerIdentity *issuer, | 190 | struct GNUNET_CRYPTO_EccPublicSignKey *issuer, |
226 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb) | 191 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb) |
227 | { | 192 | { |
228 | struct GetCtx get_ctx; | 193 | struct GetCtx get_ctx; |
@@ -230,14 +195,12 @@ GED_experiments_get (struct Node *n, | |||
230 | GNUNET_assert (NULL != n); | 195 | GNUNET_assert (NULL != n); |
231 | GNUNET_assert (NULL != experiments); | 196 | GNUNET_assert (NULL != experiments); |
232 | GNUNET_assert (NULL != get_cb); | 197 | GNUNET_assert (NULL != get_cb); |
233 | |||
234 | get_ctx.n = n; | 198 | get_ctx.n = n; |
235 | get_ctx.get_cb = get_cb; | 199 | get_ctx.get_cb = get_cb; |
236 | 200 | get_ctx.issuer = issuer; | |
237 | GNUNET_CONTAINER_multihashmap_get_multiple (experiments, | 201 | GNUNET_CONTAINER_multihashmap_iterate (experiments, |
238 | &issuer->hashPubKey, &get_it, &get_ctx); | 202 | &get_it, &get_ctx); |
239 | 203 | get_cb (n, NULL); // FIXME: ugly, end is easily signalled as we return: synchronous API! | |
240 | get_cb (n, NULL); | ||
241 | } | 204 | } |
242 | 205 | ||
243 | 206 | ||
@@ -247,7 +210,7 @@ GED_experiments_get (struct Node *n, | |||
247 | int | 210 | int |
248 | GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i, | 211 | GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i, |
249 | const char *name, | 212 | const char *name, |
250 | struct GNUNET_PeerIdentity issuer_id, | 213 | const struct GNUNET_CRYPTO_EccPublicKey *issuer_id, |
251 | struct GNUNET_TIME_Absolute version, | 214 | struct GNUNET_TIME_Absolute version, |
252 | char *description, | 215 | char *description, |
253 | uint32_t required_capabilities, | 216 | uint32_t required_capabilities, |
@@ -440,10 +403,14 @@ GED_experiments_start () | |||
440 | 403 | ||
441 | /* Load valid issuer */ | 404 | /* Load valid issuer */ |
442 | if (GNUNET_SYSERR == | 405 | if (GNUNET_SYSERR == |
443 | GNUNET_CONFIGURATION_get_value_string (GED_cfg, "EXPERIMENTATION", "ISSUERS", &issuers)) | 406 | GNUNET_CONFIGURATION_get_value_string (GED_cfg, |
407 | "EXPERIMENTATION", | ||
408 | "ISSUERS", | ||
409 | &issuers)) | ||
444 | { | 410 | { |
445 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 411 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
446 | _("No valid experiment issuers configured! Set value to peer id of issuer! Exit...\n")); | 412 | _("No valid experiment issuers configured! Set value to public keys of issuers! Exiting.\n")); |
413 | GED_experiments_stop (); | ||
447 | return GNUNET_SYSERR; | 414 | return GNUNET_SYSERR; |
448 | } | 415 | } |
449 | 416 | ||
@@ -454,30 +421,26 @@ GED_experiments_start () | |||
454 | strlen (pos), | 421 | strlen (pos), |
455 | &issuer_ID)) | 422 | &issuer_ID)) |
456 | { | 423 | { |
457 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 424 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
458 | _("Invalid value `%s'\n"), | 425 | "EXPERIMENTATION", |
459 | pos); | 426 | "ISSUERS" |
460 | } | 427 | _("Invalid value for public key\n")); |
461 | else | 428 | GED_experiments_stop (); |
462 | { | 429 | return GNUNET_SYSERR; |
463 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
464 | "`%s' is a valid issuer \n", | ||
465 | GNUNET_i2s (&issuer_ID)); | ||
466 | i = GNUNET_new (struct Issuer); | ||
467 | i->pubkey = issuer_ID; | ||
468 | GNUNET_CRYPTO_hash( &issuer_ID, sizeof (issuer_ID), &hash); | ||
469 | GNUNET_CONTAINER_multihashmap_put (valid_issuers, | ||
470 | &hash, | ||
471 | i, | ||
472 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
473 | } | 430 | } |
431 | i = GNUNET_new (struct Issuer); | ||
432 | i->pubkey = issuer_ID; | ||
433 | GNUNET_CRYPTO_hash( &issuer_ID, sizeof (issuer_ID), &hash); | ||
434 | GNUNET_CONTAINER_multihashmap_put (valid_issuers, | ||
435 | &hash, | ||
436 | i, | ||
437 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
474 | } | 438 | } |
475 | GNUNET_free (issuers); | 439 | GNUNET_free (issuers); |
476 | |||
477 | if (0 == GNUNET_CONTAINER_multihashmap_size (valid_issuers)) | 440 | if (0 == GNUNET_CONTAINER_multihashmap_size (valid_issuers)) |
478 | { | 441 | { |
479 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 442 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
480 | _("No valid experiment issuers configured! Set value to peer id of issuer! Exit...\n")); | 443 | _("No valid experiment issuers configured! Set value to public keys of issuers! Exiting.\n")); |
481 | GED_experiments_stop (); | 444 | GED_experiments_stop (); |
482 | return GNUNET_SYSERR; | 445 | return GNUNET_SYSERR; |
483 | } | 446 | } |
@@ -485,41 +448,7 @@ GED_experiments_start () | |||
485 | "# issuer", | 448 | "# issuer", |
486 | GNUNET_CONTAINER_multihashmap_size (valid_issuers), | 449 | GNUNET_CONTAINER_multihashmap_size (valid_issuers), |
487 | GNUNET_NO); | 450 | GNUNET_NO); |
488 | if (GNUNET_OK == | 451 | |
489 | GNUNET_CONFIGURATION_get_value_string (GED_cfg, | ||
490 | "EXPERIMENTATION", | ||
491 | "PUBKEY", | ||
492 | &pubkey)) | ||
493 | { | ||
494 | if (GNUNET_OK != | ||
495 | GNUNET_CRYPTO_ecc_public_sign_key_from_string (pubkey, strlen (pubkey), &pub)) | ||
496 | { | ||
497 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
498 | _("Invalid public key `%s'\n"), | ||
499 | pubkey); | ||
500 | GED_experiments_stop (); | ||
501 | return GNUNET_SYSERR; | ||
502 | } | ||
503 | GNUNET_CRYPTO_hash( &pub, sizeof (pub), &hash); | ||
504 | if (NULL != (i = GNUNET_CONTAINER_multihashmap_get (valid_issuers, &hash))) | ||
505 | { | ||
506 | i->pubkey = pub; | ||
507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Found issuer for public key `%s'\n"), pubkey); | ||
508 | } | ||
509 | else | ||
510 | { | ||
511 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No issuer for public key `%s'\n"), pubkey); | ||
512 | } | ||
513 | GNUNET_free (pubkey); | ||
514 | } | ||
515 | |||
516 | GSE_my_issuer_count = GNUNET_CONTAINER_multihashmap_size (valid_issuers); | ||
517 | GSE_my_issuer = GNUNET_malloc (GSE_my_issuer_count * sizeof (struct Experimentation_Issuer)); | ||
518 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &create_issuer, GSE_my_issuer); | ||
519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
520 | "Daemon has %u issuers\n", | ||
521 | GSE_my_issuer_count); | ||
522 | |||
523 | experiments = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | 452 | experiments = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); |
524 | /* Load experiments from file */ | 453 | /* Load experiments from file */ |
525 | if (GNUNET_SYSERR == | 454 | if (GNUNET_SYSERR == |
@@ -548,12 +477,6 @@ GED_experiments_start () | |||
548 | void | 477 | void |
549 | GED_experiments_stop () | 478 | GED_experiments_stop () |
550 | { | 479 | { |
551 | if (NULL != GSE_my_issuer) | ||
552 | { | ||
553 | GNUNET_free (GSE_my_issuer); | ||
554 | GSE_my_issuer = NULL; | ||
555 | GSE_my_issuer_count = 0; | ||
556 | } | ||
557 | if (NULL != valid_issuers) | 480 | if (NULL != valid_issuers) |
558 | { | 481 | { |
559 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &free_issuer, NULL); | 482 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &free_issuer, NULL); |
diff --git a/src/experimentation/gnunet-daemon-experimentation_nodes.c b/src/experimentation/gnunet-daemon-experimentation_nodes.c index cf278c3ec..2c8a0418e 100644 --- a/src/experimentation/gnunet-daemon-experimentation_nodes.c +++ b/src/experimentation/gnunet-daemon-experimentation_nodes.c | |||
@@ -62,15 +62,15 @@ static struct GNUNET_CONTAINER_MultiPeerMap *nodes_inactive; | |||
62 | 62 | ||
63 | struct NodeComCtx | 63 | struct NodeComCtx |
64 | { | 64 | { |
65 | struct NodeComCtx *prev; | 65 | struct NodeComCtx *prev; |
66 | struct NodeComCtx *next; | 66 | struct NodeComCtx *next; |
67 | 67 | ||
68 | struct Node *n; | 68 | struct Node *n; |
69 | struct Experiment *e; | 69 | struct Experiment *e; |
70 | 70 | ||
71 | size_t size; | 71 | size_t size; |
72 | GNUNET_CONNECTION_TransmitReadyNotify notify; | 72 | GNUNET_CONNECTION_TransmitReadyNotify notify; |
73 | void *notify_cls; | 73 | void *notify_cls; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | 76 | ||
@@ -82,27 +82,26 @@ struct NodeComCtx | |||
82 | static void | 82 | static void |
83 | update_stats (struct GNUNET_CONTAINER_MultiPeerMap *m) | 83 | update_stats (struct GNUNET_CONTAINER_MultiPeerMap *m) |
84 | { | 84 | { |
85 | GNUNET_assert (NULL != m); | 85 | GNUNET_assert (NULL != m); |
86 | GNUNET_assert (NULL != GED_stats); | 86 | GNUNET_assert (NULL != GED_stats); |
87 | |||
88 | if (m == nodes_active) | ||
89 | { | ||
90 | GNUNET_STATISTICS_set (GED_stats, "# nodes active", | ||
91 | GNUNET_CONTAINER_multipeermap_size(m), GNUNET_NO); | ||
92 | } | ||
93 | else if (m == nodes_inactive) | ||
94 | { | ||
95 | GNUNET_STATISTICS_set (GED_stats, "# nodes inactive", | ||
96 | GNUNET_CONTAINER_multipeermap_size(m), GNUNET_NO); | ||
97 | } | ||
98 | else if (m == nodes_requested) | ||
99 | { | ||
100 | GNUNET_STATISTICS_set (GED_stats, "# nodes requested", | ||
101 | GNUNET_CONTAINER_multipeermap_size(m), GNUNET_NO); | ||
102 | } | ||
103 | else | ||
104 | GNUNET_break (0); | ||
105 | 87 | ||
88 | if (m == nodes_active) | ||
89 | { | ||
90 | GNUNET_STATISTICS_set (GED_stats, "# nodes active", | ||
91 | GNUNET_CONTAINER_multipeermap_size(m), GNUNET_NO); | ||
92 | } | ||
93 | else if (m == nodes_inactive) | ||
94 | { | ||
95 | GNUNET_STATISTICS_set (GED_stats, "# nodes inactive", | ||
96 | GNUNET_CONTAINER_multipeermap_size(m), GNUNET_NO); | ||
97 | } | ||
98 | else if (m == nodes_requested) | ||
99 | { | ||
100 | GNUNET_STATISTICS_set (GED_stats, "# nodes requested", | ||
101 | GNUNET_CONTAINER_multipeermap_size(m), GNUNET_NO); | ||
102 | } | ||
103 | else | ||
104 | GNUNET_break (0); | ||
106 | } | 105 | } |
107 | 106 | ||
108 | 107 | ||
@@ -119,36 +118,33 @@ cleanup_node (void *cls, | |||
119 | const struct GNUNET_PeerIdentity * key, | 118 | const struct GNUNET_PeerIdentity * key, |
120 | void *value) | 119 | void *value) |
121 | { | 120 | { |
122 | struct Node *n; | 121 | struct Node *n; |
123 | struct NodeComCtx *e_cur; | 122 | struct NodeComCtx *e_cur; |
124 | struct NodeComCtx *e_next; | 123 | struct NodeComCtx *e_next; |
125 | struct GNUNET_CONTAINER_MultiPeerMap *cur = cls; | 124 | struct GNUNET_CONTAINER_MultiPeerMap *cur = cls; |
126 | 125 | ||
127 | n = value; | 126 | n = value; |
128 | if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) | 127 | if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) |
129 | { | 128 | { |
130 | GNUNET_SCHEDULER_cancel (n->timeout_task); | 129 | GNUNET_SCHEDULER_cancel (n->timeout_task); |
131 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 130 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
132 | } | 131 | } |
133 | 132 | ||
134 | if (NULL != n->cth) | 133 | if (NULL != n->cth) |
135 | { | 134 | { |
136 | GNUNET_CORE_notify_transmit_ready_cancel (n->cth); | 135 | GNUNET_CORE_notify_transmit_ready_cancel (n->cth); |
137 | n->cth = NULL; | 136 | n->cth = NULL; |
138 | } | 137 | } |
139 | e_next = n->e_req_head; | 138 | e_next = n->e_req_head; |
140 | while (NULL != (e_cur = e_next)) | 139 | while (NULL != (e_cur = e_next)) |
141 | { | 140 | { |
142 | e_next = e_cur->next; | 141 | e_next = e_cur->next; |
143 | GNUNET_CONTAINER_DLL_remove (n->e_req_head, n->e_req_tail, e_cur); | 142 | GNUNET_CONTAINER_DLL_remove (n->e_req_head, n->e_req_tail, e_cur); |
144 | GNUNET_free (e_cur); | 143 | GNUNET_free (e_cur); |
145 | } | 144 | } |
146 | 145 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_remove (cur, key, value)); | |
147 | GNUNET_free_non_null (n->issuer_id); | 146 | GNUNET_free (value); |
148 | 147 | return GNUNET_OK; | |
149 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_remove (cur, key, value)); | ||
150 | GNUNET_free (value); | ||
151 | return GNUNET_OK; | ||
152 | } | 148 | } |
153 | 149 | ||
154 | 150 | ||
@@ -189,40 +185,41 @@ schedule_transmisson (struct NodeComCtx *e_ctx); | |||
189 | static size_t | 185 | static size_t |
190 | transmit_read_wrapper (void *cls, size_t bufsize, void *buf) | 186 | transmit_read_wrapper (void *cls, size_t bufsize, void *buf) |
191 | { | 187 | { |
192 | struct NodeComCtx *e_ctx = cls; | 188 | struct NodeComCtx *e_ctx = cls; |
193 | struct NodeComCtx *next = NULL; | 189 | struct NodeComCtx *next; |
194 | 190 | ||
195 | size_t res = e_ctx->notify (e_ctx->notify_cls, bufsize, buf); | 191 | size_t res = e_ctx->notify (e_ctx->notify_cls, bufsize, buf); |
196 | e_ctx->n->cth = NULL; | 192 | e_ctx->n->cth = NULL; |
197 | 193 | ||
198 | GNUNET_CONTAINER_DLL_remove (e_ctx->n->e_req_head, e_ctx->n->e_req_tail, e_ctx); | 194 | GNUNET_CONTAINER_DLL_remove (e_ctx->n->e_req_head, e_ctx->n->e_req_tail, e_ctx); |
199 | next = e_ctx->n->e_req_head; | 195 | next = e_ctx->n->e_req_head; |
200 | GNUNET_free (e_ctx); | 196 | GNUNET_free (e_ctx); |
201 | 197 | ||
202 | if (NULL != next) | 198 | if (NULL != next) |
203 | { | 199 | { |
204 | /* Schedule next message */ | 200 | /* Schedule next message */ |
205 | schedule_transmisson (next); | 201 | schedule_transmisson (next); |
206 | } | 202 | } |
207 | return res; | 203 | return res; |
208 | } | 204 | } |
209 | 205 | ||
210 | 206 | ||
211 | static void | 207 | static void |
212 | schedule_transmisson (struct NodeComCtx *e_ctx) | 208 | schedule_transmisson (struct NodeComCtx *e_ctx) |
213 | { | 209 | { |
214 | if (NULL != e_ctx->n->cth) | 210 | if (NULL != e_ctx->n->cth) |
215 | return; | 211 | return; |
216 | 212 | ||
217 | e_ctx->n->cth = GNUNET_CORE_notify_transmit_ready (ch, GNUNET_NO, 0, FAST_TIMEOUT, | 213 | e_ctx->n->cth = GNUNET_CORE_notify_transmit_ready (ch, GNUNET_NO, 0, FAST_TIMEOUT, |
218 | &e_ctx->n->id, e_ctx->size, transmit_read_wrapper, e_ctx); | 214 | &e_ctx->n->id, e_ctx->size, |
219 | if (NULL == e_ctx->n->cth) | 215 | transmit_read_wrapper, e_ctx); |
220 | { | 216 | if (NULL == e_ctx->n->cth) |
221 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Cannot send message to peer `%s' for experiment `%s'\n"), | 217 | { |
222 | GNUNET_i2s(&e_ctx->n->id), e_ctx->e->name); | 218 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
223 | GNUNET_free (e_ctx); | 219 | _("Cannot send message to peer `%s' for experiment `%s'\n"), |
224 | } | 220 | GNUNET_i2s(&e_ctx->n->id), e_ctx->e->name); |
225 | 221 | GNUNET_free (e_ctx); | |
222 | } | ||
226 | } | 223 | } |
227 | 224 | ||
228 | 225 | ||
@@ -235,20 +232,34 @@ schedule_transmisson (struct NodeComCtx *e_ctx) | |||
235 | static void | 232 | static void |
236 | remove_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 233 | remove_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
237 | { | 234 | { |
238 | struct Node *n = cls; | 235 | struct Node *n = cls; |
236 | |||
237 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
238 | "Removing request for peer %s due to timeout\n", | ||
239 | GNUNET_i2s (&n->id)); | ||
240 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (nodes_requested, &n->id)) | ||
241 | { | ||
242 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_remove (nodes_requested, &n->id, n)); | ||
243 | update_stats (nodes_requested); | ||
244 | GNUNET_CONTAINER_multipeermap_put (nodes_inactive, &n->id, n, | ||
245 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
246 | update_stats (nodes_inactive); | ||
247 | } | ||
248 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; | ||
249 | } | ||
239 | 250 | ||
240 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing request for peer %s due to timeout\n", | ||
241 | GNUNET_i2s (&n->id)); | ||
242 | 251 | ||
243 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (nodes_requested, &n->id)) | 252 | static int |
244 | { | 253 | append_public_key (void *cls, |
245 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_remove (nodes_requested, &n->id, n)); | 254 | const struct GNUNET_HashCode *key, |
246 | update_stats (nodes_requested); | 255 | void *value) |
247 | GNUNET_CONTAINER_multipeermap_put (nodes_inactive, &n->id, n, | 256 | { |
248 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 257 | struct GNUNET_CRYPTO_EccPublicSignKey **issuers = cls; |
249 | update_stats (nodes_inactive); | 258 | struct Issuer *issuer = value; |
250 | } | 259 | |
251 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 260 | *issuers[0] = issuer->pubkey; |
261 | *issuers = &((*issuers)[1]); | ||
262 | return GNUNET_OK; | ||
252 | } | 263 | } |
253 | 264 | ||
254 | 265 | ||
@@ -265,33 +276,37 @@ send_experimentation_request_cb (void *cls, size_t bufsize, void *buf) | |||
265 | { | 276 | { |
266 | struct Node *n = cls; | 277 | struct Node *n = cls; |
267 | struct Experimentation_Request msg; | 278 | struct Experimentation_Request msg; |
279 | unsigned int my_issuer_count = GNUNET_CONTAINER_multihashmap_size (valid_issuers); | ||
268 | size_t msg_size = sizeof (msg); | 280 | size_t msg_size = sizeof (msg); |
269 | size_t ri_size = sizeof (struct Experimentation_Issuer) * GSE_my_issuer_count; | 281 | size_t ri_size = sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) * my_issuer_count; |
270 | size_t total_size = msg_size + ri_size; | 282 | size_t total_size = msg_size + ri_size; |
283 | struct GNUNET_CRYPTO_EccPublicSignKey *issuers; | ||
271 | 284 | ||
272 | n->cth = NULL; | 285 | n->cth = NULL; |
273 | if (NULL == buf) | 286 | if (NULL == buf) |
274 | { | 287 | { |
275 | /* client disconnected */ | 288 | /* client disconnected */ |
276 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected\n"); | 289 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
290 | "Client disconnected\n"); | ||
277 | if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) | 291 | if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) |
278 | GNUNET_SCHEDULER_cancel (n->timeout_task); | 292 | GNUNET_SCHEDULER_cancel (n->timeout_task); |
279 | GNUNET_SCHEDULER_add_now (&remove_request, n); | 293 | GNUNET_SCHEDULER_add_now (&remove_request, n); |
280 | return 0; | 294 | return 0; |
281 | } | 295 | } |
282 | memset (buf, '\0', bufsize); | ||
283 | GNUNET_assert (bufsize >= total_size); | 296 | GNUNET_assert (bufsize >= total_size); |
284 | 297 | msg.msg.size = htons (total_size); | |
285 | msg.msg.size = htons (total_size); | 298 | msg.msg.type = htons (GNUNET_MESSAGE_TYPE_EXPERIMENTATION_REQUEST); |
286 | msg.msg.type = htons (GNUNET_MESSAGE_TYPE_EXPERIMENTATION_REQUEST); | 299 | msg.capabilities = htonl (GSE_node_capabilities); |
287 | msg.capabilities = htonl (GSE_node_capabilities); | 300 | msg.issuer_count = htonl (my_issuer_count); |
288 | msg.issuer_count = htonl (GSE_my_issuer_count); | 301 | memcpy (buf, &msg, msg_size); |
289 | memcpy (buf, &msg, msg_size); | 302 | issuers = (struct GNUNET_CRYPTO_EccPublicSignKey *) buf + msg_size; |
290 | memcpy (&((char *) buf)[msg_size], GSE_my_issuer, ri_size); | 303 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, |
291 | 304 | &append_public_key, | |
292 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Sending experimentation request to peer %s\n"), | 305 | &issuers); |
293 | GNUNET_i2s (&n->id)); | 306 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
294 | return total_size; | 307 | _("Sending experimentation request to peer %s\n"), |
308 | GNUNET_i2s (&n->id)); | ||
309 | return total_size; | ||
295 | } | 310 | } |
296 | 311 | ||
297 | 312 | ||
@@ -303,32 +318,33 @@ send_experimentation_request_cb (void *cls, size_t bufsize, void *buf) | |||
303 | static void | 318 | static void |
304 | send_experimentation_request (const struct GNUNET_PeerIdentity *peer) | 319 | send_experimentation_request (const struct GNUNET_PeerIdentity *peer) |
305 | { | 320 | { |
306 | struct Node *n; | 321 | struct Node *n; |
307 | struct NodeComCtx *e_ctx; | 322 | struct NodeComCtx *e_ctx; |
308 | size_t size; | 323 | size_t size; |
309 | size_t c_issuers; | 324 | size_t c_issuers; |
310 | 325 | ||
311 | c_issuers = GSE_my_issuer_count; | 326 | c_issuers = GNUNET_CONTAINER_multihashmap_size (valid_issuers); |
312 | 327 | size = sizeof (struct Experimentation_Request) + | |
313 | size = sizeof (struct Experimentation_Request) + | 328 | c_issuers * sizeof (struct GNUNET_CRYPTO_EccPublicSignKey); |
314 | c_issuers * sizeof (struct Experimentation_Issuer); | 329 | n = GNUNET_new (struct Node); |
315 | n = GNUNET_malloc (sizeof (struct Node)); | 330 | n->id = *peer; |
316 | n->id = *peer; | 331 | n->timeout_task = GNUNET_SCHEDULER_add_delayed (EXP_RESPONSE_TIMEOUT, &remove_request, n); |
317 | n->timeout_task = GNUNET_SCHEDULER_add_delayed (EXP_RESPONSE_TIMEOUT, &remove_request, n); | 332 | n->capabilities = NONE; |
318 | n->capabilities = NONE; | 333 | |
319 | 334 | e_ctx = GNUNET_new (struct NodeComCtx); | |
320 | e_ctx = GNUNET_malloc (sizeof (struct NodeComCtx)); | 335 | e_ctx->n = n; |
321 | e_ctx->n = n; | 336 | e_ctx->e = NULL; |
322 | e_ctx->e = NULL; | 337 | e_ctx->size = size; |
323 | e_ctx->size = size; | 338 | e_ctx->notify = &send_experimentation_request_cb; |
324 | e_ctx->notify = &send_experimentation_request_cb; | 339 | e_ctx->notify_cls = n; |
325 | e_ctx->notify_cls = n; | 340 | GNUNET_CONTAINER_DLL_insert_tail(n->e_req_head, n->e_req_tail, e_ctx); |
326 | GNUNET_CONTAINER_DLL_insert_tail(n->e_req_head, n->e_req_tail, e_ctx); | 341 | schedule_transmisson (e_ctx); |
327 | schedule_transmisson (e_ctx); | 342 | |
328 | 343 | GNUNET_assert (GNUNET_OK == | |
329 | GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (nodes_requested, | 344 | GNUNET_CONTAINER_multipeermap_put (nodes_requested, |
330 | peer, n, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); | 345 | peer, n, |
331 | update_stats (nodes_requested); | 346 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); |
347 | update_stats (nodes_requested); | ||
332 | } | 348 | } |
333 | 349 | ||
334 | 350 | ||
@@ -340,73 +356,81 @@ send_experimentation_request (const struct GNUNET_PeerIdentity *peer) | |||
340 | * @param buf the buffer to copy to | 356 | * @param buf the buffer to copy to |
341 | * @return bytes passed | 357 | * @return bytes passed |
342 | */ | 358 | */ |
343 | size_t send_response_cb (void *cls, size_t bufsize, void *buf) | 359 | static size_t |
360 | send_response_cb (void *cls, size_t bufsize, void *buf) | ||
344 | { | 361 | { |
345 | struct Node *n = cls; | 362 | struct Node *n = cls; |
346 | struct Experimentation_Response msg; | 363 | struct Experimentation_Response msg; |
347 | size_t ri_size = GSE_my_issuer_count * sizeof (struct Experimentation_Issuer); | 364 | size_t c_issuers = GNUNET_CONTAINER_multihashmap_size (valid_issuers); |
348 | size_t msg_size = sizeof (msg); | 365 | size_t ri_size = c_issuers * sizeof (struct GNUNET_CRYPTO_EccPublicSignKey); |
349 | size_t total_size = msg_size + ri_size; | 366 | size_t msg_size = sizeof (msg); |
350 | 367 | size_t total_size = msg_size + ri_size; | |
351 | n->cth = NULL; | 368 | struct GNUNET_CRYPTO_EccPublicSignKey *issuers; |
369 | |||
370 | n->cth = NULL; | ||
352 | if (buf == NULL) | 371 | if (buf == NULL) |
353 | { | 372 | { |
354 | /* client disconnected */ | 373 | /* client disconnected */ |
355 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected\n"); | 374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
375 | "Client disconnected\n"); | ||
356 | return 0; | 376 | return 0; |
357 | } | 377 | } |
358 | GNUNET_assert (bufsize >= total_size); | 378 | GNUNET_assert (bufsize >= total_size); |
359 | 379 | ||
360 | msg.msg.size = htons (total_size); | 380 | msg.msg.size = htons (total_size); |
361 | msg.msg.type = htons (GNUNET_MESSAGE_TYPE_EXPERIMENTATION_RESPONSE); | 381 | msg.msg.type = htons (GNUNET_MESSAGE_TYPE_EXPERIMENTATION_RESPONSE); |
362 | msg.capabilities = htonl (GSE_node_capabilities); | 382 | msg.capabilities = htonl (GSE_node_capabilities); |
363 | msg.issuer_count = htonl (GSE_my_issuer_count); | 383 | msg.issuer_count = htonl (c_issuers); |
364 | memcpy (buf, &msg, msg_size); | 384 | memcpy (buf, &msg, msg_size); |
365 | memcpy (&((char *) buf)[msg_size], GSE_my_issuer, ri_size); | 385 | issuers = (struct GNUNET_CRYPTO_EccPublicSignKey *) buf + msg_size; |
366 | 386 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, | |
367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending response to peer %s\n", | 387 | &append_public_key, |
368 | GNUNET_i2s (&n->id)); | 388 | &issuers); |
369 | return total_size; | 389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
390 | "Sending response to peer %s\n", | ||
391 | GNUNET_i2s (&n->id)); | ||
392 | return total_size; | ||
370 | } | 393 | } |
371 | 394 | ||
372 | 395 | ||
373 | static void | 396 | static void |
374 | get_experiments_cb (struct Node *n, struct Experiment *e) | 397 | get_experiments_cb (struct Node *n, struct Experiment *e) |
375 | { | 398 | { |
376 | static int counter = 0; | 399 | static int counter = 0; |
377 | if (NULL == e) | 400 | if (NULL == e) |
378 | return; /* Done */ | 401 | return; /* Done */ |
379 | 402 | ||
380 | /* Tell the scheduler to add a node with an experiment */ | 403 | /* Tell the scheduler to add a node with an experiment */ |
381 | GED_scheduler_add (n, e, GNUNET_YES); | 404 | GED_scheduler_add (n, e, GNUNET_YES); |
382 | counter ++; | 405 | counter ++; |
383 | } | 406 | } |
384 | 407 | ||
408 | |||
385 | struct Node * | 409 | struct Node * |
386 | get_node (const struct GNUNET_PeerIdentity *id) | 410 | get_node (const struct GNUNET_PeerIdentity *id) |
387 | { | 411 | { |
388 | struct Node * res; | 412 | struct Node * res; |
389 | struct Node * tmp; | 413 | struct Node * tmp; |
390 | 414 | ||
391 | res = NULL; | 415 | res = NULL; |
392 | tmp = NULL; | 416 | tmp = NULL; |
393 | tmp = GNUNET_CONTAINER_multipeermap_get (nodes_active, id); | 417 | tmp = GNUNET_CONTAINER_multipeermap_get (nodes_active, id); |
394 | if (res == NULL) | 418 | if (res == NULL) |
395 | res = tmp; | 419 | res = tmp; |
396 | 420 | ||
397 | tmp = GNUNET_CONTAINER_multipeermap_get (nodes_inactive, id); | 421 | tmp = GNUNET_CONTAINER_multipeermap_get (nodes_inactive, id); |
398 | if (res == NULL) | 422 | if (res == NULL) |
399 | res = tmp; | 423 | res = tmp; |
400 | else | 424 | else |
401 | GNUNET_break (0); /* Multiple instances */ | 425 | GNUNET_break (0); /* Multiple instances */ |
402 | 426 | ||
403 | tmp = GNUNET_CONTAINER_multipeermap_get (nodes_requested, id); | 427 | tmp = GNUNET_CONTAINER_multipeermap_get (nodes_requested, id); |
404 | if (res == NULL) | 428 | if (res == NULL) |
405 | res = tmp; | 429 | res = tmp; |
406 | else | 430 | else |
407 | GNUNET_break (0); /* Multiple instances */ | 431 | GNUNET_break (0); /* Multiple instances */ |
408 | 432 | ||
409 | return res; | 433 | return res; |
410 | } | 434 | } |
411 | 435 | ||
412 | 436 | ||
@@ -415,20 +439,22 @@ get_node (const struct GNUNET_PeerIdentity *id) | |||
415 | * | 439 | * |
416 | * @param n the node | 440 | * @param n the node |
417 | */ | 441 | */ |
418 | static void node_make_active (struct Node *n) | 442 | static void |
443 | node_make_active (struct Node *n) | ||
419 | { | 444 | { |
420 | int c1; | 445 | int c1; |
421 | GNUNET_CONTAINER_multipeermap_put (nodes_active, | ||
422 | &n->id, n, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
423 | update_stats (nodes_active); | ||
424 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Added peer `%s' as active node\n"), | ||
425 | GNUNET_i2s (&n->id)); | ||
426 | /* Request experiments for this node to start them */ | ||
427 | for (c1 = 0; c1 < n->issuer_count; c1++) | ||
428 | { | ||
429 | 446 | ||
430 | GED_experiments_get (n, &n->issuer_id[c1], &get_experiments_cb); | 447 | GNUNET_CONTAINER_multipeermap_put (nodes_active, |
431 | } | 448 | &n->id, n, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
449 | update_stats (nodes_active); | ||
450 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
451 | _("Added peer `%s' as active node\n"), | ||
452 | GNUNET_i2s (&n->id)); | ||
453 | /* Request experiments for this node to start them */ | ||
454 | for (c1 = 0; c1 < n->issuer_count; c1++) | ||
455 | { | ||
456 | GED_experiments_get (n, &n->issuer_id[c1], &get_experiments_cb); | ||
457 | } | ||
432 | } | 458 | } |
433 | 459 | ||
434 | 460 | ||
@@ -438,100 +464,102 @@ static void node_make_active (struct Node *n) | |||
438 | * @param peer the source | 464 | * @param peer the source |
439 | * @param message the message | 465 | * @param message the message |
440 | */ | 466 | */ |
441 | static void handle_request (const struct GNUNET_PeerIdentity *peer, | 467 | static void |
442 | const struct GNUNET_MessageHeader *message) | 468 | handle_request (const struct GNUNET_PeerIdentity *peer, |
469 | const struct GNUNET_MessageHeader *message) | ||
443 | { | 470 | { |
444 | struct Node *n; | 471 | struct Node *n; |
445 | struct NodeComCtx *e_ctx; | 472 | struct NodeComCtx *e_ctx; |
446 | struct Experimentation_Request *rm = (struct Experimentation_Request *) message; | 473 | const struct Experimentation_Request *rm = (const struct Experimentation_Request *) message; |
447 | struct Experimentation_Issuer *rmi = (struct Experimentation_Issuer *) &rm[1]; | 474 | const struct Experimentation_Issuer *rmi = (const struct Experimentation_Issuer *) &rm[1]; |
448 | int c1; | 475 | int c1; |
449 | int c2; | 476 | int c2; |
450 | uint32_t ic; | 477 | uint32_t ic; |
451 | uint32_t ic_accepted; | 478 | uint32_t ic_accepted; |
452 | int make_active; | 479 | int make_active; |
453 | 480 | ||
454 | if (ntohs (message->size) < sizeof (struct Experimentation_Request)) | 481 | if (ntohs (message->size) < sizeof (struct Experimentation_Request)) |
455 | { | 482 | { |
456 | GNUNET_break (0); | 483 | GNUNET_break (0); |
457 | return; | 484 | return; |
458 | } | 485 | } |
459 | ic = ntohl (rm->issuer_count); | 486 | ic = ntohl (rm->issuer_count); |
460 | if (ntohs (message->size) != sizeof (struct Experimentation_Request) + ic * sizeof (struct Experimentation_Issuer)) | 487 | if (ntohs (message->size) != sizeof (struct Experimentation_Request) + ic * sizeof (struct Experimentation_Issuer)) |
461 | { | 488 | { |
462 | GNUNET_break (0); | 489 | GNUNET_break (0); |
463 | return; | 490 | return; |
464 | } | 491 | } |
465 | 492 | ||
466 | make_active = GNUNET_NO; | 493 | make_active = GNUNET_NO; |
467 | if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_active, peer))) | 494 | if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_active, peer))) |
468 | { | 495 | { |
469 | /* Nothing to do */ | 496 | /* Nothing to do */ |
470 | } | 497 | } |
471 | else if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_requested, peer))) | 498 | else if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_requested, peer))) |
472 | { | 499 | { |
473 | GNUNET_CONTAINER_multipeermap_remove (nodes_requested, peer, n); | 500 | GNUNET_CONTAINER_multipeermap_remove (nodes_requested, peer, n); |
474 | if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) | 501 | if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) |
475 | { | 502 | { |
476 | GNUNET_SCHEDULER_cancel (n->timeout_task); | 503 | GNUNET_SCHEDULER_cancel (n->timeout_task); |
477 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 504 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
478 | } | 505 | } |
479 | update_stats (nodes_requested); | 506 | update_stats (nodes_requested); |
480 | make_active = GNUNET_YES; | 507 | make_active = GNUNET_YES; |
481 | } | 508 | } |
482 | else if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_inactive, peer))) | 509 | else if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_inactive, peer))) |
483 | { | 510 | { |
484 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_remove (nodes_inactive, peer, n)); | 511 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_remove (nodes_inactive, peer, n)); |
485 | update_stats (nodes_inactive); | 512 | update_stats (nodes_inactive); |
486 | make_active = GNUNET_YES; | 513 | make_active = GNUNET_YES; |
487 | } | 514 | } |
488 | else | 515 | else |
489 | { | 516 | { |
490 | /* Create new node */ | 517 | /* Create new node */ |
491 | n = GNUNET_malloc (sizeof (struct Node)); | 518 | n = GNUNET_new (struct Node); |
492 | n->id = *peer; | 519 | n->id = *peer; |
493 | n->capabilities = NONE; | 520 | n->capabilities = NONE; |
494 | make_active = GNUNET_YES; | 521 | make_active = GNUNET_YES; |
495 | } | 522 | } |
496 | 523 | ||
497 | /* Update node */ | 524 | /* Update node */ |
498 | n->capabilities = ntohl (rm->capabilities); | 525 | n->capabilities = ntohl (rm->capabilities); |
499 | 526 | ||
500 | /* Filter accepted issuer */ | 527 | /* Filter accepted issuer */ |
501 | ic_accepted = 0; | 528 | ic_accepted = 0; |
502 | for (c1 = 0; c1 < ic; c1++) | 529 | for (c1 = 0; c1 < ic; c1++) |
503 | { | 530 | { |
504 | if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id)) | 531 | if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id)) |
505 | ic_accepted ++; | 532 | ic_accepted ++; |
506 | } | 533 | } |
507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Request from peer `%s' with %u issuers, we accepted %u issuer \n", | 534 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
508 | GNUNET_i2s (peer), ic, ic_accepted); | 535 | "Request from peer `%s' with %u issuers, we accepted %u issuer \n", |
509 | GNUNET_free_non_null (n->issuer_id); | 536 | GNUNET_i2s (peer), ic, ic_accepted); |
510 | n->issuer_id = GNUNET_malloc (ic_accepted * sizeof (struct GNUNET_PeerIdentity)); | 537 | GNUNET_free_non_null (n->issuer_id); |
511 | c2 = 0; | 538 | n->issuer_id = GNUNET_malloc (ic_accepted * sizeof (struct GNUNET_PeerIdentity)); |
512 | for (c1 = 0; c1 < ic; c1++) | 539 | c2 = 0; |
513 | { | 540 | for (c1 = 0; c1 < ic; c1++) |
514 | if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id)) | 541 | { |
515 | { | 542 | if (GNUNET_YES == GED_experiments_issuer_accepted (&rmi[c1].issuer_id)) |
516 | n->issuer_id[c2] = rmi[c1].issuer_id; | 543 | { |
517 | c2 ++; | 544 | n->issuer_id[c2] = rmi[c1].issuer_id; |
518 | } | 545 | c2 ++; |
519 | } | 546 | } |
520 | n->issuer_count = ic_accepted; | 547 | } |
521 | 548 | n->issuer_count = ic_accepted; | |
522 | if (GNUNET_YES == make_active) | 549 | |
523 | node_make_active (n); | 550 | if (GNUNET_YES == make_active) |
524 | 551 | node_make_active (n); | |
525 | /* Send response */ | 552 | |
526 | e_ctx = GNUNET_malloc (sizeof (struct NodeComCtx)); | 553 | /* Send response */ |
527 | e_ctx->n = n; | 554 | e_ctx = GNUNET_new (struct NodeComCtx); |
528 | e_ctx->e = NULL; | 555 | e_ctx->n = n; |
529 | e_ctx->size = sizeof (struct Experimentation_Response) + GSE_my_issuer_count * sizeof (struct Experimentation_Issuer); | 556 | e_ctx->e = NULL; |
530 | e_ctx->notify = &send_response_cb; | 557 | e_ctx->size = sizeof (struct Experimentation_Response) + GSE_my_issuer_count * sizeof (struct Experimentation_Issuer); |
531 | e_ctx->notify_cls = n; | 558 | e_ctx->notify = &send_response_cb; |
532 | 559 | e_ctx->notify_cls = n; | |
533 | GNUNET_CONTAINER_DLL_insert_tail(n->e_req_head, n->e_req_tail, e_ctx); | 560 | |
534 | schedule_transmisson (e_ctx); | 561 | GNUNET_CONTAINER_DLL_insert_tail(n->e_req_head, n->e_req_tail, e_ctx); |
562 | schedule_transmisson (e_ctx); | ||
535 | } | 563 | } |
536 | 564 | ||
537 | 565 | ||
@@ -542,239 +570,244 @@ static void handle_request (const struct GNUNET_PeerIdentity *peer, | |||
542 | * @param message the message | 570 | * @param message the message |
543 | */ | 571 | */ |
544 | static void handle_response (const struct GNUNET_PeerIdentity *peer, | 572 | static void handle_response (const struct GNUNET_PeerIdentity *peer, |
545 | const struct GNUNET_MessageHeader *message) | 573 | const struct GNUNET_MessageHeader *message) |
546 | { | 574 | { |
547 | struct Node *n; | 575 | struct Node *n; |
548 | struct Experimentation_Response *rm = (struct Experimentation_Response *) message; | 576 | const struct Experimentation_Response *rm = (const struct Experimentation_Response *) message; |
549 | struct Experimentation_Issuer *rmi = (struct Experimentation_Issuer *) &rm[1]; | 577 | const struct Experimentation_Issuer *rmi = (const struct Experimentation_Issuer *) &rm[1]; |
550 | uint32_t ic; | 578 | uint32_t ic; |
551 | uint32_t ic_accepted; | 579 | uint32_t ic_accepted; |
552 | int make_active; | 580 | int make_active; |
553 | unsigned int c1; | 581 | unsigned int c1; |
554 | unsigned int c2; | 582 | unsigned int c2; |
555 | 583 | ||
556 | if (ntohs (message->size) < sizeof (struct Experimentation_Response)) | 584 | if (ntohs (message->size) < sizeof (struct Experimentation_Response)) |
557 | { | 585 | { |
558 | GNUNET_break (0); | 586 | GNUNET_break (0); |
559 | return; | 587 | return; |
560 | } | 588 | } |
561 | ic = ntohl (rm->issuer_count); | 589 | ic = ntohl (rm->issuer_count); |
562 | if (ntohs (message->size) != sizeof (struct Experimentation_Response) + ic * sizeof (struct Experimentation_Issuer)) | 590 | if (ntohs (message->size) != sizeof (struct Experimentation_Response) + ic * sizeof (struct Experimentation_Issuer)) |
563 | { | 591 | { |
564 | GNUNET_break (0); | 592 | GNUNET_break (0); |
565 | return; | 593 | return; |
566 | } | 594 | } |
567 | 595 | ||
568 | make_active = GNUNET_NO; | 596 | make_active = GNUNET_NO; |
569 | if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_active, peer))) | 597 | if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_active, peer))) |
570 | { | 598 | { |
571 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %s from %s peer `%s'\n", | 599 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
572 | "RESPONSE", "active", GNUNET_i2s (peer)); | 600 | "Received %s from %s peer `%s'\n", |
573 | } | 601 | "RESPONSE", "active", GNUNET_i2s (peer)); |
574 | else if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_requested, peer))) | 602 | } |
575 | { | 603 | else if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_requested, peer))) |
576 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %s from %s peer `%s'\n", | 604 | { |
577 | "RESPONSE", "requested", GNUNET_i2s (peer)); | 605 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %s from %s peer `%s'\n", |
578 | GNUNET_CONTAINER_multipeermap_remove (nodes_requested, peer, n); | 606 | "RESPONSE", "requested", GNUNET_i2s (peer)); |
579 | if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) | 607 | GNUNET_CONTAINER_multipeermap_remove (nodes_requested, peer, n); |
580 | { | 608 | if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) |
581 | GNUNET_SCHEDULER_cancel (n->timeout_task); | 609 | { |
582 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 610 | GNUNET_SCHEDULER_cancel (n->timeout_task); |
583 | } | 611 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
584 | update_stats (nodes_requested); | 612 | } |
585 | make_active = GNUNET_YES; | 613 | update_stats (nodes_requested); |
586 | } | 614 | make_active = GNUNET_YES; |
587 | else if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_inactive, peer))) | 615 | } |
588 | { | 616 | else if (NULL != (n = GNUNET_CONTAINER_multipeermap_get (nodes_inactive, peer))) |
589 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %s from peer `%s'\n", | 617 | { |
590 | "RESPONSE", "inactive", GNUNET_i2s (peer)); | 618 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
591 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_remove (nodes_inactive, peer, n)); | 619 | "Received %s from peer `%s'\n", |
592 | update_stats (nodes_inactive); | 620 | "RESPONSE", "inactive", GNUNET_i2s (peer)); |
593 | make_active = GNUNET_YES; | 621 | GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_remove (nodes_inactive, peer, n)); |
594 | } | 622 | update_stats (nodes_inactive); |
595 | else | 623 | make_active = GNUNET_YES; |
596 | { | 624 | } |
597 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %s from %s peer `%s'\n", | 625 | else |
598 | "RESPONSE", "unknown", GNUNET_i2s (peer)); | 626 | { |
599 | return; | 627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %s from %s peer `%s'\n", |
600 | } | 628 | "RESPONSE", "unknown", GNUNET_i2s (peer)); |
601 | 629 | return; | |
602 | /* Update */ | 630 | } |
603 | n->capabilities = ntohl (rm->capabilities); | 631 | |
604 | 632 | /* Update */ | |
605 | /* Filter accepted issuer */ | 633 | n->capabilities = ntohl (rm->capabilities); |
606 | ic_accepted = 0; | 634 | |
607 | for (c1 = 0; c1 < ic; c1++) | 635 | /* Filter accepted issuer */ |
608 | { | 636 | ic_accepted = 0; |
609 | if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id)) | 637 | for (c1 = 0; c1 < ic; c1++) |
610 | ic_accepted ++; | 638 | { |
611 | } | 639 | if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id)) |
612 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Response from peer `%s' with %u issuers, we accepted %u issuer \n", | 640 | ic_accepted ++; |
613 | GNUNET_i2s (peer), ic, ic_accepted); | 641 | } |
614 | GNUNET_free_non_null (n->issuer_id); | 642 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
615 | n->issuer_id = GNUNET_malloc (ic_accepted * sizeof (struct GNUNET_PeerIdentity)); | 643 | "Response from peer `%s' with %u issuers, we accepted %u issuer \n", |
616 | c2 = 0; | 644 | GNUNET_i2s (peer), ic, ic_accepted); |
617 | for (c1 = 0; c1 < ic; c1++) | 645 | GNUNET_free_non_null (n->issuer_id); |
618 | { | 646 | n->issuer_id = GNUNET_malloc (ic_accepted * sizeof (struct GNUNET_PeerIdentity)); |
619 | if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id)) | 647 | c2 = 0; |
620 | { | 648 | for (c1 = 0; c1 < ic; c1++) |
621 | n->issuer_id[c2] = rmi[c1].issuer_id; | 649 | { |
622 | c2 ++; | 650 | if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id)) |
623 | } | 651 | { |
624 | } | 652 | n->issuer_id[c2] = rmi[c1].issuer_id; |
625 | n->issuer_count = ic_accepted; | 653 | c2 ++; |
626 | 654 | } | |
627 | if (GNUNET_YES == make_active) | 655 | } |
628 | node_make_active (n); | 656 | n->issuer_count = ic_accepted; |
657 | |||
658 | if (GNUNET_YES == make_active) | ||
659 | node_make_active (n); | ||
629 | } | 660 | } |
630 | 661 | ||
662 | |||
631 | /** | 663 | /** |
632 | * Handle a response | 664 | * Handle a response |
633 | * | 665 | * |
634 | * @param peer the source | 666 | * @param peer the source |
635 | * @param message the message | 667 | * @param message the message |
636 | */ | 668 | */ |
637 | static void handle_start (const struct GNUNET_PeerIdentity *peer, | 669 | static void |
638 | const struct GNUNET_MessageHeader *message) | 670 | handle_start (const struct GNUNET_PeerIdentity *peer, |
671 | const struct GNUNET_MessageHeader *message) | ||
639 | { | 672 | { |
640 | uint16_t size; | 673 | uint16_t size; |
641 | uint32_t name_len; | 674 | uint32_t name_len; |
642 | const struct GED_start_message *msg; | 675 | const struct GED_start_message *msg; |
643 | const char *name; | 676 | const char *name; |
644 | struct Node *n; | 677 | struct Node *n; |
645 | struct Experiment *e; | 678 | struct Experiment *e; |
646 | 679 | ||
647 | if (NULL == peer) | 680 | if (NULL == peer) |
648 | { | 681 | { |
649 | GNUNET_break (0); | 682 | GNUNET_break (0); |
650 | return; | 683 | return; |
651 | } | 684 | } |
652 | if (NULL == message) | 685 | if (NULL == message) |
653 | { | 686 | { |
654 | GNUNET_break (0); | 687 | GNUNET_break (0); |
655 | return; | 688 | return; |
656 | } | 689 | } |
657 | 690 | ||
658 | size = ntohs (message->size); | 691 | size = ntohs (message->size); |
659 | if (size < sizeof (struct GED_start_message)) | 692 | if (size < sizeof (struct GED_start_message)) |
660 | { | 693 | { |
661 | GNUNET_break (0); | 694 | GNUNET_break (0); |
662 | return; | 695 | return; |
663 | } | 696 | } |
664 | msg = (const struct GED_start_message *) message; | 697 | msg = (const struct GED_start_message *) message; |
665 | name_len = ntohl (msg->len_name); | 698 | name_len = ntohl (msg->len_name); |
666 | if (size != sizeof (struct GED_start_message) + name_len) | 699 | if (size != sizeof (struct GED_start_message) + name_len) |
667 | { | 700 | { |
668 | GNUNET_break (0); | 701 | GNUNET_break (0); |
669 | return; | 702 | return; |
670 | } | 703 | } |
671 | 704 | ||
672 | n = get_node (peer); | 705 | n = get_node (peer); |
673 | if (NULL == n) | 706 | if (NULL == n) |
674 | { | 707 | { |
675 | GNUNET_break (0); | 708 | GNUNET_break (0); |
676 | return; | 709 | return; |
677 | } | 710 | } |
678 | name = (const char *) &msg[1]; | 711 | name = (const char *) &msg[1]; |
679 | if (name[name_len-1] != '\0') | 712 | if (name[name_len-1] != '\0') |
680 | { | 713 | { |
681 | GNUNET_break (0); | 714 | GNUNET_break (0); |
682 | return; | 715 | return; |
683 | } | 716 | } |
684 | 717 | if (name_len != strlen (name) + 1) | |
685 | if (name_len != strlen (name) + 1) | 718 | { |
686 | { | 719 | GNUNET_break (0); |
687 | GNUNET_break (0); | 720 | return; |
688 | return; | 721 | } |
689 | } | 722 | e = GED_experiments_find (&msg->issuer, name, GNUNET_TIME_absolute_ntoh(msg->version_nbo)); |
690 | 723 | if (NULL == e) | |
691 | e = GED_experiments_find (&msg->issuer, name, GNUNET_TIME_absolute_ntoh(msg->version_nbo)); | 724 | { |
692 | if (NULL == e) | 725 | GNUNET_break (0); |
693 | { | 726 | return; |
694 | GNUNET_break (0); | 727 | } |
695 | return; | 728 | GED_scheduler_handle_start (n, e); |
696 | } | ||
697 | |||
698 | GED_scheduler_handle_start (n, e); | ||
699 | } | 729 | } |
700 | 730 | ||
731 | |||
701 | /** | 732 | /** |
702 | * Handle a response | 733 | * Handle a response |
703 | * | 734 | * |
704 | * @param peer the source | 735 | * @param peer the source |
705 | * @param message the message | 736 | * @param message the message |
706 | */ | 737 | */ |
707 | static void handle_start_ack (const struct GNUNET_PeerIdentity *peer, | 738 | static void |
708 | const struct GNUNET_MessageHeader *message) | 739 | handle_start_ack (const struct GNUNET_PeerIdentity *peer, |
740 | const struct GNUNET_MessageHeader *message) | ||
709 | { | 741 | { |
710 | uint16_t size; | 742 | uint16_t size; |
711 | uint32_t name_len; | 743 | uint32_t name_len; |
712 | const struct GED_start_ack_message *msg; | 744 | const struct GED_start_ack_message *msg; |
713 | const char *name; | 745 | const char *name; |
714 | struct Node *n; | 746 | struct Node *n; |
715 | struct Experiment *e; | 747 | struct Experiment *e; |
716 | 748 | ||
717 | if (NULL == peer) | 749 | if (NULL == peer) |
718 | { | 750 | { |
719 | GNUNET_break (0); | 751 | GNUNET_break (0); |
720 | return; | 752 | return; |
721 | } | 753 | } |
722 | if (NULL == message) | 754 | if (NULL == message) |
723 | { | 755 | { |
724 | GNUNET_break (0); | 756 | GNUNET_break (0); |
725 | return; | 757 | return; |
726 | } | 758 | } |
727 | 759 | ||
728 | size = ntohs (message->size); | 760 | size = ntohs (message->size); |
729 | if (size < sizeof (struct GED_start_ack_message)) | 761 | if (size < sizeof (struct GED_start_ack_message)) |
730 | { | 762 | { |
731 | GNUNET_break (0); | 763 | GNUNET_break (0); |
732 | return; | 764 | return; |
733 | } | 765 | } |
734 | msg = (const struct GED_start_ack_message *) message; | 766 | msg = (const struct GED_start_ack_message *) message; |
735 | name_len = ntohl (msg->len_name); | 767 | name_len = ntohl (msg->len_name); |
736 | if (size != sizeof (struct GED_start_message) + name_len) | 768 | if (size != sizeof (struct GED_start_message) + name_len) |
737 | { | 769 | { |
738 | GNUNET_break (0); | 770 | GNUNET_break (0); |
739 | return; | 771 | return; |
740 | } | 772 | } |
741 | 773 | ||
742 | n = get_node (peer); | 774 | n = get_node (peer); |
743 | if (NULL == n) | 775 | if (NULL == n) |
744 | { | 776 | { |
745 | GNUNET_break (0); | 777 | GNUNET_break (0); |
746 | return; | 778 | return; |
747 | } | 779 | } |
748 | name = (const char *) &msg[1]; | 780 | name = (const char *) &msg[1]; |
749 | if (name[name_len-1] != '\0') | 781 | if (name[name_len-1] != '\0') |
750 | { | 782 | { |
751 | GNUNET_break (0); | 783 | GNUNET_break (0); |
752 | return; | 784 | return; |
753 | } | 785 | } |
754 | 786 | if (name_len != strlen (name) + 1) | |
755 | if (name_len != strlen (name) + 1) | 787 | { |
756 | { | 788 | GNUNET_break (0); |
757 | GNUNET_break (0); | 789 | return; |
758 | return; | 790 | } |
759 | } | 791 | |
760 | 792 | e = GED_experiments_find (&msg->issuer, name, GNUNET_TIME_absolute_ntoh(msg->version_nbo)); | |
761 | e = GED_experiments_find (&msg->issuer, name, GNUNET_TIME_absolute_ntoh(msg->version_nbo)); | 793 | if (NULL == e) |
762 | if (NULL == e) | 794 | { |
763 | { | 795 | GNUNET_break (0); |
764 | GNUNET_break (0); | 796 | return; |
765 | return; | 797 | } |
766 | } | 798 | GED_scheduler_handle_start_ack (n, e); |
767 | GED_scheduler_handle_start_ack (n, e); | ||
768 | } | 799 | } |
769 | 800 | ||
801 | |||
770 | /** | 802 | /** |
771 | * Handle a response | 803 | * Handle a response |
772 | * | 804 | * |
773 | * @param peer the source | 805 | * @param peer the source |
774 | * @param message the message | 806 | * @param message the message |
775 | */ | 807 | */ |
776 | static void handle_stop (const struct GNUNET_PeerIdentity *peer, | 808 | static void |
777 | const struct GNUNET_MessageHeader *message) | 809 | handle_stop (const struct GNUNET_PeerIdentity *peer, |
810 | const struct GNUNET_MessageHeader *message) | ||
778 | { | 811 | { |
779 | uint16_t size; | 812 | uint16_t size; |
780 | uint32_t name_len; | 813 | uint32_t name_len; |
@@ -836,31 +869,33 @@ static void handle_stop (const struct GNUNET_PeerIdentity *peer, | |||
836 | GED_scheduler_handle_stop (n, e); | 869 | GED_scheduler_handle_stop (n, e); |
837 | } | 870 | } |
838 | 871 | ||
872 | |||
839 | /** | 873 | /** |
840 | * Method called whenever a given peer connects. | 874 | * Method called whenever a given peer connects. |
841 | * | 875 | * |
842 | * @param cls closure | 876 | * @param cls closure |
843 | * @param peer peer identity this notification is about | 877 | * @param peer peer identity this notification is about |
844 | */ | 878 | */ |
845 | void core_connect_handler (void *cls, | 879 | static void |
846 | const struct GNUNET_PeerIdentity *peer) | 880 | core_connect_handler (void *cls, |
881 | const struct GNUNET_PeerIdentity *peer) | ||
847 | { | 882 | { |
848 | if (GNUNET_YES == is_me(peer)) | 883 | if (GNUNET_YES == is_me(peer)) |
849 | return; | 884 | return; |
850 | 885 | ||
851 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connected to peer %s\n"), | 886 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connected to peer %s\n"), |
852 | GNUNET_i2s (peer)); | 887 | GNUNET_i2s (peer)); |
853 | 888 | ||
854 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (nodes_requested, peer)) | 889 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (nodes_requested, peer)) |
855 | return; /* We already sent a request */ | 890 | return; /* We already sent a request */ |
856 | 891 | ||
857 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (nodes_active, peer)) | 892 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (nodes_active, peer)) |
858 | return; /* This peer is known as active */ | 893 | return; /* This peer is known as active */ |
859 | 894 | ||
860 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (nodes_inactive, peer)) | 895 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (nodes_inactive, peer)) |
861 | return; /* This peer is known as inactive */ | 896 | return; /* This peer is known as inactive */ |
862 | 897 | ||
863 | send_experimentation_request (peer); | 898 | send_experimentation_request (peer); |
864 | } | 899 | } |
865 | 900 | ||
866 | 901 | ||
@@ -870,8 +905,9 @@ void core_connect_handler (void *cls, | |||
870 | * @param cls closure | 905 | * @param cls closure |
871 | * @param peer peer identity this notification is about | 906 | * @param peer peer identity this notification is about |
872 | */ | 907 | */ |
873 | void core_disconnect_handler (void *cls, | 908 | static void |
874 | const struct GNUNET_PeerIdentity * peer) | 909 | core_disconnect_handler (void *cls, |
910 | const struct GNUNET_PeerIdentity * peer) | ||
875 | { | 911 | { |
876 | struct Node *n; | 912 | struct Node *n; |
877 | if (GNUNET_YES == is_me(peer)) | 913 | if (GNUNET_YES == is_me(peer)) |
@@ -901,8 +937,8 @@ void core_disconnect_handler (void *cls, | |||
901 | */ | 937 | */ |
902 | static int | 938 | static int |
903 | core_receive_handler (void *cls, | 939 | core_receive_handler (void *cls, |
904 | const struct GNUNET_PeerIdentity *other, | 940 | const struct GNUNET_PeerIdentity *other, |
905 | const struct GNUNET_MessageHeader *message) | 941 | const struct GNUNET_MessageHeader *message) |
906 | { | 942 | { |
907 | if (ntohs (message->size) < sizeof (struct GNUNET_MessageHeader)) | 943 | if (ntohs (message->size) < sizeof (struct GNUNET_MessageHeader)) |
908 | { | 944 | { |
@@ -934,7 +970,8 @@ core_receive_handler (void *cls, | |||
934 | } | 970 | } |
935 | 971 | ||
936 | 972 | ||
937 | size_t node_experiment_start_cb (void *cls, size_t bufsize, void *buf) | 973 | static size_t |
974 | node_experiment_start_cb (void *cls, size_t bufsize, void *buf) | ||
938 | { | 975 | { |
939 | struct NodeComCtx *e_ctx = cls; | 976 | struct NodeComCtx *e_ctx = cls; |
940 | struct GED_start_message *msg; | 977 | struct GED_start_message *msg; |
@@ -960,7 +997,9 @@ size_t node_experiment_start_cb (void *cls, size_t bufsize, void *buf) | |||
960 | return size; | 997 | return size; |
961 | } | 998 | } |
962 | 999 | ||
963 | size_t node_experiment_start_ack_cb (void *cls, size_t bufsize, void *buf) | 1000 | |
1001 | static size_t | ||
1002 | node_experiment_start_ack_cb (void *cls, size_t bufsize, void *buf) | ||
964 | { | 1003 | { |
965 | struct NodeComCtx *e_ctx = cls; | 1004 | struct NodeComCtx *e_ctx = cls; |
966 | struct GED_start_ack_message *msg; | 1005 | struct GED_start_ack_message *msg; |