diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/core/test_core_api.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/core/test_core_api.c')
-rw-r--r-- | src/core/test_core_api.c | 82 |
1 files changed, 35 insertions, 47 deletions
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index b5e93a8a2..28805a372 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c | |||
@@ -150,8 +150,7 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
150 | 150 | ||
151 | 151 | ||
152 | static void | 152 | static void |
153 | connect_notify (void *cls, | 153 | connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, |
154 | const struct GNUNET_PeerIdentity *peer, | ||
155 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 154 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
156 | { | 155 | { |
157 | struct PeerContext *pc = cls; | 156 | struct PeerContext *pc = cls; |
@@ -173,15 +172,13 @@ connect_notify (void *cls, | |||
173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
174 | "Asking core (1) for transmission to peer `%4s'\n", | 173 | "Asking core (1) for transmission to peer `%4s'\n", |
175 | GNUNET_i2s (&p2.id)); | 174 | GNUNET_i2s (&p2.id)); |
176 | if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch, | 175 | if (NULL == |
177 | GNUNET_YES, | 176 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_YES, 0, |
178 | 0, | 177 | GNUNET_TIME_relative_multiply |
179 | GNUNET_TIME_relative_multiply | 178 | (GNUNET_TIME_UNIT_SECONDS, 45), |
180 | (GNUNET_TIME_UNIT_SECONDS, | 179 | &p2.id, |
181 | 45), &p2.id, | 180 | sizeof (struct GNUNET_MessageHeader), |
182 | sizeof (struct | 181 | &transmit_ready, &p1)) |
183 | GNUNET_MessageHeader), | ||
184 | &transmit_ready, &p1)) | ||
185 | { | 182 | { |
186 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
187 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | 184 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", |
@@ -199,14 +196,13 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
199 | if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) | 196 | if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) |
200 | return; | 197 | return; |
201 | pc->connect_status = 0; | 198 | pc->connect_status = 0; |
202 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 199 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted connection to `%4s' cut\n", |
203 | "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); | 200 | GNUNET_i2s (peer)); |
204 | } | 201 | } |
205 | 202 | ||
206 | 203 | ||
207 | static int | 204 | static int |
208 | inbound_notify (void *cls, | 205 | inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, |
209 | const struct GNUNET_PeerIdentity *other, | ||
210 | const struct GNUNET_MessageHeader *message, | 206 | const struct GNUNET_MessageHeader *message, |
211 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 207 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
212 | { | 208 | { |
@@ -217,8 +213,7 @@ inbound_notify (void *cls, | |||
217 | 213 | ||
218 | 214 | ||
219 | static int | 215 | static int |
220 | outbound_notify (void *cls, | 216 | outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, |
221 | const struct GNUNET_PeerIdentity *other, | ||
222 | const struct GNUNET_MessageHeader *message, | 217 | const struct GNUNET_MessageHeader *message, |
223 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 218 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
224 | { | 219 | { |
@@ -231,13 +226,12 @@ outbound_notify (void *cls, | |||
231 | 226 | ||
232 | 227 | ||
233 | static int | 228 | static int |
234 | process_mtype (void *cls, | 229 | process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, |
235 | const struct GNUNET_PeerIdentity *peer, | ||
236 | const struct GNUNET_MessageHeader *message, | 230 | const struct GNUNET_MessageHeader *message, |
237 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 231 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
238 | { | 232 | { |
239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 233 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving message from `%4s'.\n", |
240 | "Receiving message from `%4s'.\n", GNUNET_i2s (peer)); | 234 | GNUNET_i2s (peer)); |
241 | GNUNET_assert (ok == 5); | 235 | GNUNET_assert (ok == 5); |
242 | OKPP; | 236 | OKPP; |
243 | GNUNET_SCHEDULER_cancel (err_task); | 237 | GNUNET_SCHEDULER_cancel (err_task); |
@@ -260,8 +254,9 @@ connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
260 | con_task = GNUNET_SCHEDULER_NO_TASK; | 254 | con_task = GNUNET_SCHEDULER_NO_TASK; |
261 | return; | 255 | return; |
262 | } | 256 | } |
263 | con_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 257 | con_task = |
264 | &connect_task, NULL); | 258 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &connect_task, |
259 | NULL); | ||
265 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
266 | "Asking core (1) to connect to peer `%4s'\n", | 261 | "Asking core (1) to connect to peer `%4s'\n", |
267 | GNUNET_i2s (&p2.id)); | 262 | GNUNET_i2s (&p2.id)); |
@@ -269,15 +264,13 @@ connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
269 | } | 264 | } |
270 | 265 | ||
271 | static void | 266 | static void |
272 | init_notify (void *cls, | 267 | init_notify (void *cls, struct GNUNET_CORE_Handle *server, |
273 | struct GNUNET_CORE_Handle *server, | ||
274 | const struct GNUNET_PeerIdentity *my_identity, | 268 | const struct GNUNET_PeerIdentity *my_identity, |
275 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | 269 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) |
276 | { | 270 | { |
277 | struct PeerContext *p = cls; | 271 | struct PeerContext *p = cls; |
278 | 272 | ||
279 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core connection to `%4s' established\n", |
280 | "Core connection to `%4s' established\n", | ||
281 | GNUNET_i2s (my_identity)); | 274 | GNUNET_i2s (my_identity)); |
282 | GNUNET_assert (server != NULL); | 275 | GNUNET_assert (server != NULL); |
283 | p->id = *my_identity; | 276 | p->id = *my_identity; |
@@ -287,15 +280,11 @@ init_notify (void *cls, | |||
287 | GNUNET_assert (ok == 2); | 280 | GNUNET_assert (ok == 2); |
288 | OKPP; | 281 | OKPP; |
289 | /* connect p2 */ | 282 | /* connect p2 */ |
290 | p2.ch = GNUNET_CORE_connect (p2.cfg, 1, | 283 | p2.ch = |
291 | &p2, | 284 | GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, |
292 | &init_notify, | 285 | &disconnect_notify, NULL, &inbound_notify, |
293 | &connect_notify, | 286 | GNUNET_YES, &outbound_notify, GNUNET_YES, |
294 | &disconnect_notify, | 287 | handlers); |
295 | NULL, | ||
296 | &inbound_notify, | ||
297 | GNUNET_YES, | ||
298 | &outbound_notify, GNUNET_YES, handlers); | ||
299 | } | 288 | } |
300 | else | 289 | else |
301 | { | 290 | { |
@@ -312,12 +301,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
312 | { | 301 | { |
313 | p->cfg = GNUNET_CONFIGURATION_create (); | 302 | p->cfg = GNUNET_CONFIGURATION_create (); |
314 | #if START_ARM | 303 | #if START_ARM |
315 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | 304 | p->arm_proc = |
316 | "gnunet-service-arm", | 305 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
306 | "gnunet-service-arm", | ||
317 | #if VERBOSE | 307 | #if VERBOSE |
318 | "-L", "DEBUG", | 308 | "-L", "DEBUG", |
319 | #endif | 309 | #endif |
320 | "-c", cfgname, NULL); | 310 | "-c", cfgname, NULL); |
321 | #endif | 311 | #endif |
322 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 312 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
323 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); | 313 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); |
@@ -327,9 +317,8 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
327 | 317 | ||
328 | 318 | ||
329 | static void | 319 | static void |
330 | run (void *cls, | 320 | run (void *cls, char *const *args, const char *cfgfile, |
331 | char *const *args, | 321 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
332 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
333 | { | 322 | { |
334 | GNUNET_assert (ok == 1); | 323 | GNUNET_assert (ok == 1); |
335 | OKPP; | 324 | OKPP; |
@@ -353,8 +342,7 @@ stop_arm (struct PeerContext *p) | |||
353 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 342 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
354 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | 343 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) |
355 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | 344 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); |
356 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 345 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", |
357 | "ARM process %u stopped\n", | ||
358 | GNUNET_OS_process_get_pid (p->arm_proc)); | 346 | GNUNET_OS_process_get_pid (p->arm_proc)); |
359 | GNUNET_OS_process_close (p->arm_proc); | 347 | GNUNET_OS_process_close (p->arm_proc); |
360 | p->arm_proc = NULL; | 348 | p->arm_proc = NULL; |
@@ -377,8 +365,8 @@ check () | |||
377 | GNUNET_GETOPT_OPTION_END | 365 | GNUNET_GETOPT_OPTION_END |
378 | }; | 366 | }; |
379 | ok = 1; | 367 | ok = 1; |
380 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 368 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
381 | argv, "test-core-api", "nohelp", options, &run, &ok); | 369 | "test-core-api", "nohelp", options, &run, &ok); |
382 | stop_arm (&p1); | 370 | stop_arm (&p1); |
383 | stop_arm (&p2); | 371 | stop_arm (&p2); |
384 | return ok; | 372 | return ok; |