diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
commit | 83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch) | |
tree | d0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/transport/test_transport_api.c | |
parent | 28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff) | |
download | gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip |
curly wars / auto-indentation
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r-- | src/transport/test_transport_api.c | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 6b6cc0c0e..47686f8d9 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c | |||
@@ -74,7 +74,7 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | |||
74 | 74 | ||
75 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 75 | struct GNUNET_TRANSPORT_TransmitHandle *th; |
76 | 76 | ||
77 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 77 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
78 | 78 | ||
79 | char *cfg_file_p1; | 79 | char *cfg_file_p1; |
80 | 80 | ||
@@ -140,10 +140,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
140 | static void | 140 | static void |
141 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 141 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
142 | const struct GNUNET_MessageHeader *message, | 142 | const struct GNUNET_MessageHeader *message, |
143 | const struct GNUNET_ATS_Information *ats, | 143 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
144 | uint32_t ats_count) | ||
145 | { | 144 | { |
146 | struct PeerContext * p = cls; | 145 | struct PeerContext *p = cls; |
147 | struct PeerContext *t = NULL; | 146 | struct PeerContext *t = NULL; |
148 | 147 | ||
149 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) | 148 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) |
@@ -152,11 +151,12 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
152 | t = p2; | 151 | t = p2; |
153 | GNUNET_assert (t != NULL); | 152 | GNUNET_assert (t != NULL); |
154 | 153 | ||
155 | char * ps = strdup (GNUNET_i2s(&p->id)); | 154 | char *ps = strdup (GNUNET_i2s (&p->id)); |
156 | 155 | ||
157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
158 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", | 157 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", |
159 | p->no, ps, ntohs (message->type), ntohs (message->size), t->no, GNUNET_i2s (&t->id)); | 158 | p->no, ps, ntohs (message->type), ntohs (message->size), t->no, |
159 | GNUNET_i2s (&t->id)); | ||
160 | 160 | ||
161 | if ((MTYPE == ntohs (message->type)) && | 161 | if ((MTYPE == ntohs (message->type)) && |
162 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) | 162 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) |
@@ -200,13 +200,12 @@ notify_ready (void *cls, size_t size, void *buf) | |||
200 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | 200 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); |
201 | hdr->type = htons (MTYPE); | 201 | hdr->type = htons (MTYPE); |
202 | } | 202 | } |
203 | char * ps = strdup (GNUNET_i2s(&p2->id)); | 203 | char *ps = strdup (GNUNET_i2s (&p2->id)); |
204 | |||
204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
205 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | 206 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", |
206 | p2->no, | 207 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, |
207 | ps, | 208 | GNUNET_i2s (&p->id)); |
208 | ntohs (hdr->type), | ||
209 | ntohs (hdr->size), p->no, GNUNET_i2s (&p->id)); | ||
210 | GNUNET_free (ps); | 209 | GNUNET_free (ps); |
211 | return sizeof (struct GNUNET_MessageHeader); | 210 | return sizeof (struct GNUNET_MessageHeader); |
212 | } | 211 | } |
@@ -219,11 +218,11 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
219 | 218 | ||
220 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 219 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
221 | return; | 220 | return; |
222 | char * receiver_s = strdup(GNUNET_i2s (&p1->id)); | 221 | char *receiver_s = strdup (GNUNET_i2s (&p1->id)); |
222 | |||
223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
224 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", | 224 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", |
225 | p2->no, | 225 | p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s); |
226 | GNUNET_i2s (&p2->id), p1->no, receiver_s); | ||
227 | GNUNET_free (receiver_s); | 226 | GNUNET_free (receiver_s); |
228 | 227 | ||
229 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, 0, | 228 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, 0, |
@@ -234,10 +233,10 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
234 | 233 | ||
235 | static void | 234 | static void |
236 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 235 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
237 | const struct GNUNET_ATS_Information *ats, | 236 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
238 | uint32_t ats_count) | ||
239 | { | 237 | { |
240 | static int c; | 238 | static int c; |
239 | |||
241 | c++; | 240 | c++; |
242 | struct PeerContext *p = cls; | 241 | struct PeerContext *p = cls; |
243 | struct PeerContext *t = NULL; | 242 | struct PeerContext *t = NULL; |
@@ -246,11 +245,12 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
246 | t = p1; | 245 | t = p1; |
247 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) | 246 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) |
248 | t = p2; | 247 | t = p2; |
249 | GNUNET_assert (t!=NULL); | 248 | GNUNET_assert (t != NULL); |
249 | |||
250 | char *ps = strdup (GNUNET_i2s (&p->id)); | ||
250 | 251 | ||
251 | char * ps = strdup (GNUNET_i2s(&p->id)); | 252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", | 253 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, |
253 | p->no, ps, | ||
254 | t->no, GNUNET_i2s (peer)); | 254 | t->no, GNUNET_i2s (peer)); |
255 | GNUNET_free (ps); | 255 | GNUNET_free (ps); |
256 | } | 256 | } |
@@ -260,9 +260,11 @@ static void | |||
260 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 260 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
261 | { | 261 | { |
262 | struct PeerContext *p = cls; | 262 | struct PeerContext *p = cls; |
263 | char * ps = strdup (GNUNET_i2s(&p->id)); | 263 | char *ps = strdup (GNUNET_i2s (&p->id)); |
264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", | 264 | |
265 | p->no, ps, GNUNET_i2s (peer)); | 265 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
266 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps, | ||
267 | GNUNET_i2s (peer)); | ||
266 | 268 | ||
267 | if (th != NULL) | 269 | if (th != NULL) |
268 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 270 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
@@ -276,8 +278,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
276 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); | 278 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); |
277 | 279 | ||
278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", | 280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", |
279 | p1->no, p1_c, | 281 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); |
280 | p2->no, GNUNET_i2s (&p2->id)); | ||
281 | GNUNET_free (p1_c); | 282 | GNUNET_free (p1_c); |
282 | 283 | ||
283 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 284 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
@@ -285,23 +286,24 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
285 | 286 | ||
286 | 287 | ||
287 | 288 | ||
288 | void start_cb (struct PeerContext * p, | 289 | void |
289 | void *cls) | 290 | start_cb (struct PeerContext *p, void *cls) |
290 | { | 291 | { |
291 | static int started; | 292 | static int started; |
293 | |||
292 | started++; | 294 | started++; |
293 | 295 | ||
294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
295 | p->no, | 297 | GNUNET_i2s (&p->id)); |
296 | GNUNET_i2s (&p->id)); | ||
297 | 298 | ||
298 | if (started != 2) | 299 | if (started != 2) |
299 | return; | 300 | return; |
300 | 301 | ||
301 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); | 302 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); |
302 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", | 303 | |
303 | p1->no, sender_c, | 304 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
304 | p2->no, GNUNET_i2s (&p2->id)); | 305 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", |
306 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | ||
305 | 307 | ||
306 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 308 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, |
307 | NULL); | 309 | NULL); |
@@ -315,17 +317,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
315 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 317 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
316 | 318 | ||
317 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 319 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, |
318 | ¬ify_receive, | 320 | ¬ify_receive, ¬ify_connect, |
319 | ¬ify_connect, | 321 | ¬ify_disconnect, &start_cb, |
320 | ¬ify_disconnect, | 322 | NULL); |
321 | &start_cb, | ||
322 | NULL); | ||
323 | 323 | ||
324 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 324 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, |
325 | ¬ify_receive, | 325 | ¬ify_receive, ¬ify_connect, |
326 | ¬ify_connect, | 326 | ¬ify_disconnect, &start_cb, |
327 | ¬ify_disconnect, | ||
328 | &start_cb, | ||
329 | NULL); | 327 | NULL); |
330 | 328 | ||
331 | if ((p1 == NULL) || (p2 == NULL)) | 329 | if ((p1 == NULL) || (p2 == NULL)) |