diff options
-rw-r--r-- | src/transport/plugin_transport_http_common.c | 18 | ||||
-rw-r--r-- | src/transport/test_quota_compliance.c | 34 | ||||
-rw-r--r-- | src/transport/test_transport_api_bidirectional_connect.c | 87 | ||||
-rw-r--r-- | src/transport/test_transport_api_blacklisting.c | 43 | ||||
-rw-r--r-- | src/transport/test_transport_api_manipulation_cfg.c | 85 | ||||
-rw-r--r-- | src/transport/test_transport_api_manipulation_recv_tcp.c | 124 | ||||
-rw-r--r-- | src/transport/test_transport_api_manipulation_send_tcp.c | 105 | ||||
-rw-r--r-- | src/transport/test_transport_api_monitor_peers.c | 28 | ||||
-rw-r--r-- | src/transport/test_transport_api_monitor_validation.c | 49 | ||||
-rw-r--r-- | src/transport/test_transport_api_restart_1peer.c | 37 |
10 files changed, 379 insertions, 231 deletions
diff --git a/src/transport/plugin_transport_http_common.c b/src/transport/plugin_transport_http_common.c index 13f01f713..9c0e93a37 100644 --- a/src/transport/plugin_transport_http_common.c +++ b/src/transport/plugin_transport_http_common.c | |||
@@ -567,7 +567,7 @@ http_common_plugin_address_to_url (void *cls, | |||
567 | GNUNET_break(0); | 567 | GNUNET_break(0); |
568 | return NULL; | 568 | return NULL; |
569 | } | 569 | } |
570 | if (0 >= addrlen) | 570 | if (0 == addrlen) |
571 | { | 571 | { |
572 | GNUNET_break(0); | 572 | GNUNET_break(0); |
573 | return NULL; | 573 | return NULL; |
@@ -611,14 +611,14 @@ http_common_plugin_address_to_string (const char *plugin, | |||
611 | 611 | ||
612 | GNUNET_assert(NULL != plugin); | 612 | GNUNET_assert(NULL != plugin); |
613 | if (NULL == addr) | 613 | if (NULL == addr) |
614 | return NULL ; | 614 | return NULL; |
615 | if (0 == addrlen) | 615 | if (0 == addrlen) |
616 | return NULL ; | 616 | return NULL; |
617 | if (addrlen != http_common_address_get_size (address)) | 617 | if (addrlen != http_common_address_get_size (address)) |
618 | return NULL ; | 618 | return NULL; |
619 | addr_str = (char *) &address[1]; | 619 | addr_str = (char *) &address[1]; |
620 | if (addr_str[ntohl (address->urlen) - 1] != '\0') | 620 | if (addr_str[ntohl (address->urlen) - 1] != '\0') |
621 | return NULL ; | 621 | return NULL; |
622 | GNUNET_asprintf (&res, "%s.%u.%s", plugin, ntohl (address->options), | 622 | GNUNET_asprintf (&res, "%s.%u.%s", plugin, ntohl (address->options), |
623 | &address[1]); | 623 | &address[1]); |
624 | if (strlen (res) + 1 < 500) | 624 | if (strlen (res) + 1 < 500) |
@@ -629,7 +629,7 @@ http_common_plugin_address_to_string (const char *plugin, | |||
629 | } | 629 | } |
630 | GNUNET_break(0); | 630 | GNUNET_break(0); |
631 | GNUNET_free(res); | 631 | GNUNET_free(res); |
632 | return NULL ; | 632 | return NULL; |
633 | } | 633 | } |
634 | 634 | ||
635 | /** | 635 | /** |
@@ -772,7 +772,7 @@ http_common_socket_from_address (const void *addr, | |||
772 | GNUNET_break (0); | 772 | GNUNET_break (0); |
773 | return NULL; | 773 | return NULL; |
774 | } | 774 | } |
775 | if (0 >= addrlen) | 775 | if (0 == addrlen) |
776 | { | 776 | { |
777 | GNUNET_break (0); | 777 | GNUNET_break (0); |
778 | return NULL; | 778 | return NULL; |
@@ -868,14 +868,14 @@ http_common_cmp_addresses (const void *addr1, | |||
868 | 868 | ||
869 | if (NULL == a1) | 869 | if (NULL == a1) |
870 | return GNUNET_SYSERR; | 870 | return GNUNET_SYSERR; |
871 | if (0 >= addrlen1) | 871 | if (0 == addrlen1) |
872 | return GNUNET_SYSERR; | 872 | return GNUNET_SYSERR; |
873 | if (a1[addrlen1 - 1] != '\0') | 873 | if (a1[addrlen1 - 1] != '\0') |
874 | return GNUNET_SYSERR; | 874 | return GNUNET_SYSERR; |
875 | 875 | ||
876 | if (NULL == a2) | 876 | if (NULL == a2) |
877 | return GNUNET_SYSERR; | 877 | return GNUNET_SYSERR; |
878 | if (0 >= addrlen2) | 878 | if (0 == addrlen2) |
879 | return GNUNET_SYSERR; | 879 | return GNUNET_SYSERR; |
880 | if (a2[addrlen2 - 1] != '\0') | 880 | if (a2[addrlen2 - 1] != '\0') |
881 | return GNUNET_SYSERR; | 881 | return GNUNET_SYSERR; |
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index b53bda514..d01d335f8 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -209,23 +209,29 @@ get_size (unsigned int iter) | |||
209 | 209 | ||
210 | 210 | ||
211 | static void | 211 | static void |
212 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 212 | notify_receive (void *cls, |
213 | const struct GNUNET_PeerIdentity *peer, | ||
213 | const struct GNUNET_MessageHeader *message) | 214 | const struct GNUNET_MessageHeader *message) |
214 | { | 215 | { |
215 | const struct TestMessage *hdr; | 216 | const struct TestMessage *hdr; |
217 | struct PeerContext *p = cls; | ||
216 | 218 | ||
217 | hdr = (const struct TestMessage *) message; | 219 | hdr = (const struct TestMessage *) message; |
218 | if (MTYPE != ntohs (message->type)) | 220 | if (MTYPE != ntohs (message->type)) |
219 | return; | 221 | return; |
220 | 222 | ||
221 | struct PeerContext *p = cls; | 223 | { |
222 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 224 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
223 | 225 | ||
224 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 226 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
225 | "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", | 227 | "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", |
226 | p->no, ps, ntohl (hdr->num), ntohs (message->size), | 228 | p->no, |
227 | GNUNET_i2s (peer)); | 229 | ps, |
228 | GNUNET_free (ps); | 230 | ntohl (hdr->num), |
231 | ntohs (message->size), | ||
232 | GNUNET_i2s (peer)); | ||
233 | GNUNET_free (ps); | ||
234 | } | ||
229 | } | 235 | } |
230 | 236 | ||
231 | 237 | ||
@@ -315,8 +321,10 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
315 | 321 | ||
316 | struct PeerContext *p = cls; | 322 | struct PeerContext *p = cls; |
317 | 323 | ||
318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n", | 324 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
319 | p->no, GNUNET_i2s (peer)); | 325 | "Peer %u (`%4s') connected to us!\n", |
326 | p->no, | ||
327 | GNUNET_i2s (peer)); | ||
320 | } | 328 | } |
321 | 329 | ||
322 | 330 | ||
@@ -325,7 +333,9 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
325 | { | 333 | { |
326 | struct PeerContext *p = cls; | 334 | struct PeerContext *p = cls; |
327 | 335 | ||
328 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", p->no, | 336 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
337 | "Peer %u (`%4s') disconnected!\n", | ||
338 | p->no, | ||
329 | GNUNET_i2s (peer)); | 339 | GNUNET_i2s (peer)); |
330 | if (th != NULL) | 340 | if (th != NULL) |
331 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 341 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
diff --git a/src/transport/test_transport_api_bidirectional_connect.c b/src/transport/test_transport_api_bidirectional_connect.c index 5c9ae36fe..f7f284a9a 100644 --- a/src/transport/test_transport_api_bidirectional_connect.c +++ b/src/transport/test_transport_api_bidirectional_connect.c | |||
@@ -185,20 +185,24 @@ notify_ready (void *cls, size_t size, void *buf) | |||
185 | } | 185 | } |
186 | 186 | ||
187 | GNUNET_assert (size >= 256); | 187 | GNUNET_assert (size >= 256); |
188 | hdr = buf; | ||
189 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | ||
190 | hdr->type = htons (MTYPE); | ||
188 | 191 | ||
189 | if (buf != NULL) | ||
190 | { | 192 | { |
191 | hdr = buf; | 193 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
192 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | 194 | |
193 | hdr->type = htons (MTYPE); | 195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
196 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
197 | p2->no, | ||
198 | ps, | ||
199 | ntohs (hdr->type), | ||
200 | ntohs (hdr->size), | ||
201 | p->no, | ||
202 | GNUNET_i2s (&p->id)); | ||
203 | GNUNET_free (ps); | ||
194 | } | 204 | } |
195 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); | ||
196 | 205 | ||
197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
198 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
199 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | ||
200 | GNUNET_i2s (&p->id)); | ||
201 | GNUNET_free (ps); | ||
202 | return sizeof (struct GNUNET_MessageHeader); | 206 | return sizeof (struct GNUNET_MessageHeader); |
203 | } | 207 | } |
204 | 208 | ||
@@ -229,7 +233,6 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
229 | static int c; | 233 | static int c; |
230 | 234 | ||
231 | c++; | 235 | c++; |
232 | GNUNET_assert (NULL != cls); | ||
233 | struct PeerContext *p = cls; | 236 | struct PeerContext *p = cls; |
234 | struct PeerContext *t = NULL; | 237 | struct PeerContext *t = NULL; |
235 | 238 | ||
@@ -239,12 +242,17 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
239 | t = p2; | 242 | t = p2; |
240 | GNUNET_assert (t != NULL); | 243 | GNUNET_assert (t != NULL); |
241 | 244 | ||
242 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 245 | { |
243 | 246 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | |
244 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 247 | |
245 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, | 248 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
246 | t->no, GNUNET_i2s (peer)); | 249 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", |
247 | GNUNET_free (ps); | 250 | p->no, |
251 | ps, | ||
252 | t->no, | ||
253 | GNUNET_i2s (peer)); | ||
254 | GNUNET_free (ps); | ||
255 | } | ||
248 | } | 256 | } |
249 | 257 | ||
250 | 258 | ||
@@ -252,14 +260,17 @@ static void | |||
252 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 260 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
253 | { | 261 | { |
254 | struct PeerContext *p = cls; | 262 | struct PeerContext *p = cls; |
255 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
256 | |||
257 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
258 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", | ||
259 | p->no, ps, | ||
260 | GNUNET_i2s (peer)); | ||
261 | GNUNET_free (ps); | ||
262 | 263 | ||
264 | { | ||
265 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
266 | |||
267 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
268 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", | ||
269 | p->no, | ||
270 | ps, | ||
271 | GNUNET_i2s (peer)); | ||
272 | GNUNET_free (ps); | ||
273 | } | ||
263 | if (NULL != send_task) | 274 | if (NULL != send_task) |
264 | { | 275 | { |
265 | GNUNET_SCHEDULER_cancel(send_task); | 276 | GNUNET_SCHEDULER_cancel(send_task); |
@@ -277,7 +288,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
277 | static void | 288 | static void |
278 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 289 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
279 | { | 290 | { |
280 | static int connected = GNUNET_NO; | 291 | static int connected = GNUNET_NO; |
292 | |||
281 | if ((cls == cc1) && (NULL != cc2)) | 293 | if ((cls == cc1) && (NULL != cc2)) |
282 | { | 294 | { |
283 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2); | 295 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2); |
@@ -290,14 +302,23 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
290 | cc2 = NULL; | 302 | cc2 = NULL; |
291 | 303 | ||
292 | if (connected > 0) | 304 | if (connected > 0) |
293 | return; | 305 | return; |
294 | connected ++; | 306 | connected++; |
295 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 307 | |
296 | 308 | { | |
297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", | 309 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
298 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); | 310 | |
299 | GNUNET_free (p1_c); | 311 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
300 | send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL); | 312 | "Peers connected: %u (%s) <-> %u (%s)\n", |
313 | p1->no, | ||
314 | p1_c, | ||
315 | p2->no, | ||
316 | GNUNET_i2s (&p2->id)); | ||
317 | GNUNET_free (p1_c); | ||
318 | } | ||
319 | send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
320 | &sendtask, | ||
321 | NULL); | ||
301 | } | 322 | } |
302 | 323 | ||
303 | 324 | ||
diff --git a/src/transport/test_transport_api_blacklisting.c b/src/transport/test_transport_api_blacklisting.c index 9c3a0c460..f2265028f 100644 --- a/src/transport/test_transport_api_blacklisting.c +++ b/src/transport/test_transport_api_blacklisting.c | |||
@@ -236,24 +236,28 @@ notify_ready (void *cls, size_t size, void *buf) | |||
236 | } | 236 | } |
237 | 237 | ||
238 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); | 238 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); |
239 | hdr = buf; | ||
240 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
241 | hdr->type = htons (TEST_MESSAGE_TYPE); | ||
239 | 242 | ||
240 | if (buf != NULL) | ||
241 | { | 243 | { |
242 | hdr = buf; | 244 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
243 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
244 | hdr->type = htons (TEST_MESSAGE_TYPE); | ||
245 | } | ||
246 | 245 | ||
247 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); | 246 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
248 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 247 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", |
249 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | 248 | p2->no, |
250 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | 249 | ps, |
251 | GNUNET_i2s (&p->id)); | 250 | ntohs (hdr->type), |
252 | GNUNET_free (ps); | 251 | ntohs (hdr->size), |
252 | p->no, | ||
253 | GNUNET_i2s (&p->id)); | ||
254 | GNUNET_free (ps); | ||
255 | } | ||
253 | 256 | ||
254 | return TEST_MESSAGE_SIZE; | 257 | return TEST_MESSAGE_SIZE; |
255 | } | 258 | } |
256 | 259 | ||
260 | |||
257 | static void | 261 | static void |
258 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 262 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
259 | { | 263 | { |
@@ -291,12 +295,17 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
291 | t = p2; | 295 | t = p2; |
292 | GNUNET_assert (t != NULL); | 296 | GNUNET_assert (t != NULL); |
293 | 297 | ||
294 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 298 | { |
295 | 299 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | |
296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 300 | |
297 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, | 301 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
298 | t->no, GNUNET_i2s (peer)); | 302 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", |
299 | GNUNET_free (ps); | 303 | p->no, |
304 | ps, | ||
305 | t->no, | ||
306 | GNUNET_i2s (peer)); | ||
307 | GNUNET_free (ps); | ||
308 | } | ||
300 | } | 309 | } |
301 | 310 | ||
302 | 311 | ||
diff --git a/src/transport/test_transport_api_manipulation_cfg.c b/src/transport/test_transport_api_manipulation_cfg.c index 41ad7f68f..ce968a497 100644 --- a/src/transport/test_transport_api_manipulation_cfg.c +++ b/src/transport/test_transport_api_manipulation_cfg.c | |||
@@ -107,6 +107,7 @@ end () | |||
107 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 107 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); |
108 | } | 108 | } |
109 | 109 | ||
110 | |||
110 | static void | 111 | static void |
111 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 112 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
112 | { | 113 | { |
@@ -180,26 +181,31 @@ notify_request_ready (void *cls, size_t size, void *buf) | |||
180 | } | 181 | } |
181 | 182 | ||
182 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); | 183 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); |
183 | if (buf != NULL) | 184 | memset (buf, '\0', TEST_MESSAGE_SIZE); |
185 | hdr = buf; | ||
186 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
187 | hdr->type = htons (TEST_REQUEST_MESSAGE_TYPE); | ||
188 | |||
184 | { | 189 | { |
185 | memset (buf, '\0', TEST_MESSAGE_SIZE); | 190 | char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
186 | hdr = buf; | 191 | |
187 | hdr->size = htons (TEST_MESSAGE_SIZE); | 192 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
188 | hdr->type = htons (TEST_REQUEST_MESSAGE_TYPE); | 193 | "Sending request message from peer %u (`%4s') with type %u and size %u bytes to peer %u (`%4s')\n", |
194 | p1->no, ps, | ||
195 | ntohs (hdr->type), | ||
196 | ntohs (hdr->size), | ||
197 | p->no, | ||
198 | GNUNET_i2s (&p->id)); | ||
199 | GNUNET_free (ps); | ||
189 | } | 200 | } |
190 | 201 | ||
191 | char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id)); | ||
192 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
193 | "Sending request message from peer %u (`%4s') with type %u and size %u bytes to peer %u (`%4s')\n", | ||
194 | p1->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | ||
195 | GNUNET_i2s (&p->id)); | ||
196 | GNUNET_free (ps); | ||
197 | return TEST_MESSAGE_SIZE; | 202 | return TEST_MESSAGE_SIZE; |
198 | } | 203 | } |
199 | 204 | ||
200 | 205 | ||
201 | static void | 206 | static void |
202 | sendtask_request_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 207 | sendtask_request_task (void *cls, |
208 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
203 | { | 209 | { |
204 | send_task = NULL; | 210 | send_task = NULL; |
205 | 211 | ||
@@ -240,42 +246,55 @@ notify_response_ready (void *cls, size_t size, void *buf) | |||
240 | } | 246 | } |
241 | 247 | ||
242 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); | 248 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); |
243 | if (buf != NULL) | 249 | memset (buf, '\0', TEST_MESSAGE_SIZE); |
250 | hdr = buf; | ||
251 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
252 | hdr->type = htons (TEST_RESPONSE_MESSAGE_TYPE); | ||
253 | |||
244 | { | 254 | { |
245 | memset (buf, '\0', TEST_MESSAGE_SIZE); | 255 | char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
246 | hdr = buf; | 256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
247 | hdr->size = htons (TEST_MESSAGE_SIZE); | 257 | "Sending response message from peer %u (`%4s') with type %u and size %u bytes to peer %u (`%4s')\n", |
248 | hdr->type = htons (TEST_RESPONSE_MESSAGE_TYPE); | 258 | p1->no, |
259 | ps, | ||
260 | ntohs (hdr->type), | ||
261 | ntohs (hdr->size), | ||
262 | p->no, | ||
263 | GNUNET_i2s (&p->id)); | ||
264 | GNUNET_free (ps); | ||
249 | } | 265 | } |
250 | 266 | ||
251 | char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id)); | ||
252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
253 | "Sending response message from peer %u (`%4s') with type %u and size %u bytes to peer %u (`%4s')\n", | ||
254 | p1->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | ||
255 | GNUNET_i2s (&p->id)); | ||
256 | GNUNET_free (ps); | ||
257 | |||
258 | return TEST_MESSAGE_SIZE; | 267 | return TEST_MESSAGE_SIZE; |
259 | } | 268 | } |
260 | 269 | ||
270 | |||
261 | static void | 271 | static void |
262 | sendtask_response_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 272 | sendtask_response_task (void *cls, |
273 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
263 | { | 274 | { |
264 | send_task = NULL; | 275 | send_task = NULL; |
265 | 276 | ||
266 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 277 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
267 | return; | 278 | return; |
268 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 279 | { |
280 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | ||
269 | 281 | ||
270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 282 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
271 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", | 283 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", |
272 | p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s); | 284 | p2->no, |
273 | GNUNET_free (receiver_s); | 285 | GNUNET_i2s (&p2->id), |
286 | p1->no, | ||
287 | receiver_s); | ||
288 | GNUNET_free (receiver_s); | ||
289 | } | ||
274 | 290 | ||
275 | s_sending = GNUNET_YES; | 291 | s_sending = GNUNET_YES; |
276 | start_response = GNUNET_TIME_absolute_get(); | 292 | start_response = GNUNET_TIME_absolute_get(); |
277 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, TEST_MESSAGE_SIZE, | 293 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, |
278 | TIMEOUT_TRANSMIT, ¬ify_response_ready, | 294 | &p1->id, |
295 | TEST_MESSAGE_SIZE, | ||
296 | TIMEOUT_TRANSMIT, | ||
297 | ¬ify_response_ready, | ||
279 | p1); | 298 | p1); |
280 | } | 299 | } |
281 | 300 | ||
diff --git a/src/transport/test_transport_api_manipulation_recv_tcp.c b/src/transport/test_transport_api_manipulation_recv_tcp.c index 8a820fa16..48e0fe418 100644 --- a/src/transport/test_transport_api_manipulation_recv_tcp.c +++ b/src/transport/test_transport_api_manipulation_recv_tcp.c | |||
@@ -264,27 +264,32 @@ notify_ready (void *cls, size_t size, void *buf) | |||
264 | } | 264 | } |
265 | 265 | ||
266 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); | 266 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); |
267 | if (buf != NULL) | 267 | memset (buf, '\0', TEST_MESSAGE_SIZE); |
268 | hdr = buf; | ||
269 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
270 | hdr->type = htons (TEST_MESSAGE_TYPE); | ||
271 | |||
268 | { | 272 | { |
269 | memset (buf, '\0', TEST_MESSAGE_SIZE); | 273 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
270 | hdr = buf; | ||
271 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
272 | hdr->type = htons (TEST_MESSAGE_TYPE); | ||
273 | } | ||
274 | 274 | ||
275 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); | 275 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
276 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 276 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", |
277 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | 277 | p2->no, |
278 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | 278 | ps, |
279 | GNUNET_i2s (&p->id)); | 279 | ntohs (hdr->type), |
280 | GNUNET_free (ps); | 280 | ntohs (hdr->size), |
281 | p->no, | ||
282 | GNUNET_i2s (&p->id)); | ||
283 | GNUNET_free (ps); | ||
284 | } | ||
281 | 285 | ||
282 | return TEST_MESSAGE_SIZE; | 286 | return TEST_MESSAGE_SIZE; |
283 | } | 287 | } |
284 | 288 | ||
285 | 289 | ||
286 | static void | 290 | static void |
287 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 291 | sendtask (void *cls, |
292 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
288 | { | 293 | { |
289 | send_task = NULL; | 294 | send_task = NULL; |
290 | 295 | ||
@@ -300,22 +305,26 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
300 | 305 | ||
301 | if (0 == messages_recv) | 306 | if (0 == messages_recv) |
302 | { | 307 | { |
303 | start_normal = GNUNET_TIME_absolute_get(); | 308 | start_normal = GNUNET_TIME_absolute_get(); |
304 | } | 309 | } |
305 | if (1 == messages_recv) | 310 | if (1 == messages_recv) |
306 | { | 311 | { |
307 | start_delayed = GNUNET_TIME_absolute_get(); | 312 | start_delayed = GNUNET_TIME_absolute_get(); |
308 | } | 313 | } |
309 | 314 | ||
310 | s_sending = GNUNET_YES; | 315 | s_sending = GNUNET_YES; |
311 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, TEST_MESSAGE_SIZE, | 316 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, |
312 | TIMEOUT_TRANSMIT, ¬ify_ready, | 317 | &p1->id, |
318 | TEST_MESSAGE_SIZE, | ||
319 | TIMEOUT_TRANSMIT, | ||
320 | ¬ify_ready, | ||
313 | p1); | 321 | p1); |
314 | } | 322 | } |
315 | 323 | ||
316 | 324 | ||
317 | static void | 325 | static void |
318 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 326 | notify_connect (void *cls, |
327 | const struct GNUNET_PeerIdentity *peer) | ||
319 | { | 328 | { |
320 | static int c; | 329 | static int c; |
321 | 330 | ||
@@ -329,42 +338,63 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
329 | t = p2; | 338 | t = p2; |
330 | GNUNET_assert (t != NULL); | 339 | GNUNET_assert (t != NULL); |
331 | 340 | ||
332 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 341 | { |
342 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
333 | 343 | ||
334 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
335 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, | 345 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", |
336 | t->no, GNUNET_i2s (peer)); | 346 | p->no, |
337 | GNUNET_free (ps); | 347 | ps, |
348 | t->no, | ||
349 | GNUNET_i2s (peer)); | ||
350 | GNUNET_free (ps); | ||
351 | } | ||
338 | } | 352 | } |
339 | 353 | ||
340 | 354 | ||
341 | static void | 355 | static void |
342 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 356 | notify_disconnect (void *cls, |
357 | const struct GNUNET_PeerIdentity *peer) | ||
343 | { | 358 | { |
344 | struct PeerContext *p = cls; | 359 | struct PeerContext *p = cls; |
345 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
346 | 360 | ||
347 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 361 | { |
348 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps, | 362 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
349 | GNUNET_i2s (peer)); | ||
350 | 363 | ||
351 | GNUNET_free (ps); | 364 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
365 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", | ||
366 | p->no, | ||
367 | ps, | ||
368 | GNUNET_i2s (peer)); | ||
369 | GNUNET_free (ps); | ||
370 | } | ||
352 | 371 | ||
353 | if (th != NULL) | 372 | if (th != NULL) |
373 | { | ||
354 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 374 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
355 | th = NULL; | 375 | th = NULL; |
376 | } | ||
356 | } | 377 | } |
357 | 378 | ||
358 | 379 | ||
359 | static void | 380 | static void |
360 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 381 | testing_connect_cb (struct PeerContext *p1, |
382 | struct PeerContext *p2, | ||
383 | void *cls) | ||
361 | { | 384 | { |
362 | cc = NULL; | 385 | cc = NULL; |
363 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | ||
364 | 386 | ||
365 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", | 387 | { |
366 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); | 388 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
367 | GNUNET_free (p1_c); | 389 | |
390 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
391 | "Peers connected: %u (%s) <-> %u (%s)\n", | ||
392 | p1->no, | ||
393 | p1_c, | ||
394 | p2->no, | ||
395 | GNUNET_i2s (&p2->id)); | ||
396 | GNUNET_free (p1_c); | ||
397 | } | ||
368 | 398 | ||
369 | s_connected = GNUNET_YES; | 399 | s_connected = GNUNET_YES; |
370 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 400 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
@@ -377,21 +407,31 @@ start_cb (struct PeerContext *p, void *cls) | |||
377 | static int started; | 407 | static int started; |
378 | started++; | 408 | started++; |
379 | 409 | ||
380 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, | 410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
411 | "Peer %u (`%s') started\n", | ||
412 | p->no, | ||
381 | GNUNET_i2s (&p->id)); | 413 | GNUNET_i2s (&p->id)); |
382 | 414 | ||
383 | if (started != 2) | 415 | if (started != 2) |
384 | return; | 416 | return; |
385 | else | 417 | else |
386 | s_started = GNUNET_YES; | 418 | s_started = GNUNET_YES; |
387 | char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 419 | { |
420 | char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | ||
388 | 421 | ||
389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 422 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
390 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", | 423 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", |
391 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | 424 | p1->no, |
392 | GNUNET_free (sender_c); | 425 | sender_c, |
426 | p2->no, | ||
427 | GNUNET_i2s (&p2->id)); | ||
428 | GNUNET_free (sender_c); | ||
429 | } | ||
393 | 430 | ||
394 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 431 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, |
432 | p1, | ||
433 | p2, | ||
434 | &testing_connect_cb, | ||
395 | NULL); | 435 | NULL); |
396 | 436 | ||
397 | } | 437 | } |
diff --git a/src/transport/test_transport_api_manipulation_send_tcp.c b/src/transport/test_transport_api_manipulation_send_tcp.c index 0a52556ab..a1f9055ea 100644 --- a/src/transport/test_transport_api_manipulation_send_tcp.c +++ b/src/transport/test_transport_api_manipulation_send_tcp.c | |||
@@ -85,6 +85,7 @@ static struct GNUNET_TIME_Relative dur_normal; | |||
85 | static struct GNUNET_TIME_Absolute start_delayed; | 85 | static struct GNUNET_TIME_Absolute start_delayed; |
86 | static struct GNUNET_TIME_Relative dur_delayed; | 86 | static struct GNUNET_TIME_Relative dur_delayed; |
87 | 87 | ||
88 | |||
88 | static void | 89 | static void |
89 | end () | 90 | end () |
90 | { | 91 | { |
@@ -104,6 +105,7 @@ end () | |||
104 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 105 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); |
105 | } | 106 | } |
106 | 107 | ||
108 | |||
107 | static void | 109 | static void |
108 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 110 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
109 | { | 111 | { |
@@ -160,6 +162,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
160 | static void | 162 | static void |
161 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 163 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
162 | 164 | ||
165 | |||
163 | static void | 166 | static void |
164 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 167 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
165 | const struct GNUNET_MessageHeader *message) | 168 | const struct GNUNET_MessageHeader *message) |
@@ -173,13 +176,19 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
173 | t = p2; | 176 | t = p2; |
174 | GNUNET_assert (t != NULL); | 177 | GNUNET_assert (t != NULL); |
175 | 178 | ||
176 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 179 | { |
180 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
177 | 181 | ||
178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
179 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", | 183 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", |
180 | p->no, ps, ntohs (message->type), ntohs (message->size), t->no, | 184 | p->no, |
181 | GNUNET_i2s (&t->id)); | 185 | ps, |
182 | GNUNET_free (ps); | 186 | ntohs (message->type), |
187 | ntohs (message->size), | ||
188 | t->no, | ||
189 | GNUNET_i2s (&t->id)); | ||
190 | GNUNET_free (ps); | ||
191 | } | ||
183 | 192 | ||
184 | if ((TEST_MESSAGE_TYPE == ntohs (message->type)) && | 193 | if ((TEST_MESSAGE_TYPE == ntohs (message->type)) && |
185 | (TEST_MESSAGE_SIZE == ntohs (message->size))) | 194 | (TEST_MESSAGE_SIZE == ntohs (message->size))) |
@@ -252,21 +261,24 @@ notify_ready (void *cls, size_t size, void *buf) | |||
252 | } | 261 | } |
253 | 262 | ||
254 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); | 263 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); |
255 | if (buf != NULL) | 264 | memset (buf, '\0', TEST_MESSAGE_SIZE); |
265 | hdr = buf; | ||
266 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
267 | hdr->type = htons (TEST_MESSAGE_TYPE); | ||
268 | |||
256 | { | 269 | { |
257 | memset (buf, '\0', TEST_MESSAGE_SIZE); | 270 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
258 | hdr = buf; | 271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
259 | hdr->size = htons (TEST_MESSAGE_SIZE); | 272 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", |
260 | hdr->type = htons (TEST_MESSAGE_TYPE); | 273 | p2->no, |
274 | ps, | ||
275 | ntohs (hdr->type), | ||
276 | ntohs (hdr->size), | ||
277 | p->no, | ||
278 | GNUNET_i2s (&p->id)); | ||
279 | GNUNET_free (ps); | ||
261 | } | 280 | } |
262 | 281 | ||
263 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); | ||
264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
265 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
266 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | ||
267 | GNUNET_i2s (&p->id)); | ||
268 | GNUNET_free (ps); | ||
269 | |||
270 | return TEST_MESSAGE_SIZE; | 282 | return TEST_MESSAGE_SIZE; |
271 | } | 283 | } |
272 | 284 | ||
@@ -291,7 +303,6 @@ sendtask (void *cls, | |||
291 | receiver_s); | 303 | receiver_s); |
292 | GNUNET_free (receiver_s); | 304 | GNUNET_free (receiver_s); |
293 | 305 | ||
294 | |||
295 | if (0 == messages_recv) | 306 | if (0 == messages_recv) |
296 | { | 307 | { |
297 | start_normal = GNUNET_TIME_absolute_get (); | 308 | start_normal = GNUNET_TIME_absolute_get (); |
@@ -325,23 +336,27 @@ static void | |||
325 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 336 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) |
326 | { | 337 | { |
327 | static int c; | 338 | static int c; |
328 | |||
329 | c++; | ||
330 | struct PeerContext *p = cls; | 339 | struct PeerContext *p = cls; |
331 | struct PeerContext *t = NULL; | 340 | struct PeerContext *t = NULL; |
332 | 341 | ||
342 | c++; | ||
333 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) | 343 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) |
334 | t = p1; | 344 | t = p1; |
335 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) | 345 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) |
336 | t = p2; | 346 | t = p2; |
337 | GNUNET_assert (t != NULL); | 347 | GNUNET_assert (t != NULL); |
338 | 348 | ||
339 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 349 | { |
350 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
340 | 351 | ||
341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 352 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
342 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, | 353 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", |
343 | t->no, GNUNET_i2s (peer)); | 354 | p->no, |
344 | GNUNET_free (ps); | 355 | ps, |
356 | t->no, | ||
357 | GNUNET_i2s (peer)); | ||
358 | GNUNET_free (ps); | ||
359 | } | ||
345 | } | 360 | } |
346 | 361 | ||
347 | 362 | ||
@@ -349,17 +364,23 @@ static void | |||
349 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 364 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
350 | { | 365 | { |
351 | struct PeerContext *p = cls; | 366 | struct PeerContext *p = cls; |
352 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | ||
353 | 367 | ||
354 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 368 | { |
355 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps, | 369 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
356 | GNUNET_i2s (peer)); | ||
357 | 370 | ||
358 | GNUNET_free (ps); | 371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
372 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", | ||
373 | p->no, | ||
374 | ps, | ||
375 | GNUNET_i2s (peer)); | ||
376 | GNUNET_free (ps); | ||
377 | } | ||
359 | 378 | ||
360 | if (th != NULL) | 379 | if (th != NULL) |
380 | { | ||
361 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 381 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
362 | th = NULL; | 382 | th = NULL; |
383 | } | ||
363 | } | 384 | } |
364 | 385 | ||
365 | 386 | ||
@@ -367,12 +388,18 @@ static void | |||
367 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 388 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
368 | { | 389 | { |
369 | cc = NULL; | 390 | cc = NULL; |
370 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | ||
371 | 391 | ||
372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 392 | { |
373 | "Peers connected: %u (%s) <-> %u (%s)\n", | 393 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
374 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); | 394 | |
375 | GNUNET_free (p1_c); | 395 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
396 | "Peers connected: %u (%s) <-> %u (%s)\n", | ||
397 | p1->no, | ||
398 | p1_c, | ||
399 | p2->no, | ||
400 | GNUNET_i2s (&p2->id)); | ||
401 | GNUNET_free (p1_c); | ||
402 | } | ||
376 | 403 | ||
377 | s_connected = GNUNET_YES; | 404 | s_connected = GNUNET_YES; |
378 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 405 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
@@ -385,7 +412,9 @@ start_cb (struct PeerContext *p, void *cls) | |||
385 | static int started; | 412 | static int started; |
386 | started++; | 413 | started++; |
387 | 414 | ||
388 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, | 415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
416 | "Peer %u (`%s') started\n", | ||
417 | p->no, | ||
389 | GNUNET_i2s (&p->id)); | 418 | GNUNET_i2s (&p->id)); |
390 | 419 | ||
391 | if (started != 2) | 420 | if (started != 2) |
diff --git a/src/transport/test_transport_api_monitor_peers.c b/src/transport/test_transport_api_monitor_peers.c index 8cd952cc5..38884f7d5 100644 --- a/src/transport/test_transport_api_monitor_peers.c +++ b/src/transport/test_transport_api_monitor_peers.c | |||
@@ -237,21 +237,25 @@ notify_ready (void *cls, size_t size, void *buf) | |||
237 | } | 237 | } |
238 | 238 | ||
239 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); | 239 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); |
240 | if (buf != NULL) | 240 | memset (buf, '\0', TEST_MESSAGE_SIZE); |
241 | hdr = buf; | ||
242 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
243 | hdr->type = htons (TEST_MESSAGE_TYPE); | ||
244 | |||
241 | { | 245 | { |
242 | memset (buf, '\0', TEST_MESSAGE_SIZE); | 246 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
243 | hdr = buf; | 247 | |
244 | hdr->size = htons (TEST_MESSAGE_SIZE); | 248 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
245 | hdr->type = htons (TEST_MESSAGE_TYPE); | 249 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", |
250 | p2->no, | ||
251 | ps, | ||
252 | ntohs (hdr->type), | ||
253 | ntohs (hdr->size), | ||
254 | p->no, | ||
255 | GNUNET_i2s (&p->id)); | ||
256 | GNUNET_free (ps); | ||
246 | } | 257 | } |
247 | 258 | ||
248 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); | ||
249 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
250 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
251 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | ||
252 | GNUNET_i2s (&p->id)); | ||
253 | GNUNET_free (ps); | ||
254 | |||
255 | return TEST_MESSAGE_SIZE; | 259 | return TEST_MESSAGE_SIZE; |
256 | } | 260 | } |
257 | 261 | ||
diff --git a/src/transport/test_transport_api_monitor_validation.c b/src/transport/test_transport_api_monitor_validation.c index 76fa66949..ac7a1805b 100644 --- a/src/transport/test_transport_api_monitor_validation.c +++ b/src/transport/test_transport_api_monitor_validation.c | |||
@@ -229,40 +229,45 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
229 | 229 | ||
230 | 230 | ||
231 | static size_t | 231 | static size_t |
232 | notify_ready (void *cls, size_t size, void *buf) | 232 | notify_ready (void *cls, |
233 | size_t size, | ||
234 | void *buf) | ||
233 | { | 235 | { |
234 | struct PeerContext *p = cls; | 236 | struct PeerContext *p = cls; |
235 | struct GNUNET_MessageHeader *hdr; | 237 | struct GNUNET_MessageHeader *hdr; |
236 | 238 | ||
237 | th = NULL; | 239 | th = NULL; |
238 | 240 | if (NULL == buf) | |
239 | if (buf == NULL) | ||
240 | { | 241 | { |
241 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 242 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
242 | "Timeout occurred while waiting for transmit_ready\n"); | 243 | "Timeout occurred while waiting for transmit_ready\n"); |
243 | if (NULL != die_task) | 244 | if (NULL != die_task) |
244 | GNUNET_SCHEDULER_cancel (die_task); | 245 | GNUNET_SCHEDULER_cancel (die_task); |
245 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 246 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, |
247 | NULL); | ||
246 | ok = 42; | 248 | ok = 42; |
247 | return 0; | 249 | return 0; |
248 | } | 250 | } |
249 | 251 | ||
250 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); | 252 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); |
251 | if (buf != NULL) | 253 | memset (buf, '\0', TEST_MESSAGE_SIZE); |
254 | hdr = buf; | ||
255 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
256 | hdr->type = htons (TEST_MESSAGE_TYPE); | ||
257 | |||
252 | { | 258 | { |
253 | memset (buf, '\0', TEST_MESSAGE_SIZE); | 259 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
254 | hdr = buf; | 260 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
255 | hdr->size = htons (TEST_MESSAGE_SIZE); | 261 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", |
256 | hdr->type = htons (TEST_MESSAGE_TYPE); | 262 | p2->no, |
263 | ps, | ||
264 | ntohs (hdr->type), | ||
265 | ntohs (hdr->size), | ||
266 | p->no, | ||
267 | GNUNET_i2s (&p->id)); | ||
268 | GNUNET_free (ps); | ||
257 | } | 269 | } |
258 | 270 | ||
259 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); | ||
260 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
261 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
262 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | ||
263 | GNUNET_i2s (&p->id)); | ||
264 | GNUNET_free (ps); | ||
265 | |||
266 | return TEST_MESSAGE_SIZE; | 271 | return TEST_MESSAGE_SIZE; |
267 | } | 272 | } |
268 | 273 | ||
@@ -290,9 +295,13 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
290 | static void | 295 | static void |
291 | done () | 296 | done () |
292 | { | 297 | { |
293 | if ((GNUNET_YES == p1_c) && (GNUNET_YES == p2_c) && p1_c_notify && p2_c_notify) | 298 | if ( (GNUNET_YES == p1_c) && |
299 | (GNUNET_YES == p2_c) && | ||
300 | p1_c_notify && | ||
301 | p2_c_notify) | ||
294 | { | 302 | { |
295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Both peers state to be connected\n"); | 303 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
304 | "Both peers state to be connected\n"); | ||
296 | ok = 0; | 305 | ok = 0; |
297 | end(); | 306 | end(); |
298 | } | 307 | } |
@@ -403,7 +412,7 @@ monitor1_cb (void *cls, | |||
403 | 412 | ||
404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 413 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
405 | "Monitor 1: %s %s %s\n", | 414 | "Monitor 1: %s %s %s\n", |
406 | GNUNET_i2s (&address->peer), | 415 | GNUNET_i2s (&address->peer), |
407 | GNUNET_TRANSPORT_vs2s (state), | 416 | GNUNET_TRANSPORT_vs2s (state), |
408 | GNUNET_STRINGS_absolute_time_to_string(valid_until)); | 417 | GNUNET_STRINGS_absolute_time_to_string(valid_until)); |
409 | if (0 == memcmp (&address->peer, | 418 | if (0 == memcmp (&address->peer, |
@@ -427,7 +436,7 @@ monitor2_cb (void *cls, | |||
427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
428 | "Monitor 2: %s %s %s\n", | 437 | "Monitor 2: %s %s %s\n", |
429 | GNUNET_i2s (&address->peer), | 438 | GNUNET_i2s (&address->peer), |
430 | GNUNET_TRANSPORT_vs2s(state), | 439 | GNUNET_TRANSPORT_vs2s(state), |
431 | GNUNET_STRINGS_absolute_time_to_string(valid_until)); | 440 | GNUNET_STRINGS_absolute_time_to_string(valid_until)); |
432 | if (0 == memcmp (&address->peer, | 441 | if (0 == memcmp (&address->peer, |
433 | &p1->id, | 442 | &p1->id, |
diff --git a/src/transport/test_transport_api_restart_1peer.c b/src/transport/test_transport_api_restart_1peer.c index 2c4382e9c..86eb299ef 100644 --- a/src/transport/test_transport_api_restart_1peer.c +++ b/src/transport/test_transport_api_restart_1peer.c | |||
@@ -225,7 +225,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
225 | 225 | ||
226 | th = NULL; | 226 | th = NULL; |
227 | 227 | ||
228 | if (buf == NULL) | 228 | if (NULL == buf) |
229 | { | 229 | { |
230 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 230 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
231 | "Timeout occurred while waiting for transmit_ready\n"); | 231 | "Timeout occurred while waiting for transmit_ready\n"); |
@@ -237,20 +237,23 @@ notify_ready (void *cls, size_t size, void *buf) | |||
237 | } | 237 | } |
238 | 238 | ||
239 | GNUNET_assert (size >= 256); | 239 | GNUNET_assert (size >= 256); |
240 | hdr = buf; | ||
241 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | ||
242 | hdr->type = htons (MTYPE); | ||
240 | 243 | ||
241 | if (buf != NULL) | ||
242 | { | 244 | { |
243 | hdr = buf; | 245 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
244 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | 246 | |
245 | hdr->type = htons (MTYPE); | 247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
248 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
249 | p2->no, | ||
250 | ps, | ||
251 | ntohs (hdr->type), | ||
252 | ntohs (hdr->size), | ||
253 | p->no, | ||
254 | GNUNET_i2s (&p->id)); | ||
255 | GNUNET_free (ps); | ||
246 | } | 256 | } |
247 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); | ||
248 | |||
249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
250 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
251 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | ||
252 | GNUNET_i2s (&p->id)); | ||
253 | GNUNET_free (ps); | ||
254 | return sizeof (struct GNUNET_MessageHeader); | 257 | return sizeof (struct GNUNET_MessageHeader); |
255 | } | 258 | } |
256 | 259 | ||
@@ -269,14 +272,18 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
269 | p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s); | 272 | p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s); |
270 | GNUNET_free (receiver_s); | 273 | GNUNET_free (receiver_s); |
271 | 274 | ||
272 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, | 275 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, |
273 | TIMEOUT_TRANSMIT, ¬ify_ready, | 276 | &p1->id, |
277 | 256, | ||
278 | TIMEOUT_TRANSMIT, | ||
279 | ¬ify_ready, | ||
274 | p1); | 280 | p1); |
275 | } | 281 | } |
276 | 282 | ||
277 | 283 | ||
278 | static void | 284 | static void |
279 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 285 | notify_connect (void *cls, |
286 | const struct GNUNET_PeerIdentity *peer) | ||
280 | { | 287 | { |
281 | static int c; | 288 | static int c; |
282 | 289 | ||