diff options
Diffstat (limited to 'src/transport/test_transport_api_manipulation_cfg.c')
-rw-r--r-- | src/transport/test_transport_api_manipulation_cfg.c | 85 |
1 files changed, 52 insertions, 33 deletions
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 | ||