diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-10-05 11:51:57 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-10-05 11:51:57 +0000 |
commit | 90f4f1c9760a5ab8b5279e1dd4a7e2e219e446be (patch) | |
tree | 5025962b642ac8025194fee372da460778fe80e7 /src/transport/test_transport_api.c | |
parent | 8c5b6d1916b08b890002b4ee971cbfbec15d4749 (diff) | |
download | gnunet-90f4f1c9760a5ab8b5279e1dd4a7e2e219e446be.tar.gz gnunet-90f4f1c9760a5ab8b5279e1dd4a7e2e219e446be.zip |
more beautification
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r-- | src/transport/test_transport_api.c | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 033577a21..6f858d084 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include "transport.h" | 37 | #include "transport.h" |
38 | #include "transport-testing.h" | 38 | #include "transport-testing.h" |
39 | 39 | ||
40 | #define VERBOSE GNUNET_EXTRA_LOGGING | 40 | #define VERBOSE GNUNET_YES |
41 | 41 | ||
42 | #define VERBOSE_ARM GNUNET_EXTRA_LOGGING | 42 | #define VERBOSE_ARM GNUNET_EXTRA_LOGGING |
43 | 43 | ||
@@ -140,9 +140,11 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
140 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 140 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
141 | uint32_t ats_count) | 141 | uint32_t ats_count) |
142 | { | 142 | { |
143 | struct PeerContext * p = cls; | ||
144 | |||
143 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
144 | "Received message of type %d from peer %s!\n", | 146 | "Received message of type %d from peer %u (`%4s')!\n", |
145 | ntohs (message->type), GNUNET_i2s (peer)); | 147 | ntohs (message->type), p->no, GNUNET_i2s (peer)); |
146 | 148 | ||
147 | if ((MTYPE == ntohs (message->type)) && | 149 | if ((MTYPE == ntohs (message->type)) && |
148 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) | 150 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) |
@@ -179,8 +181,8 @@ notify_ready (void *cls, size_t size, void *buf) | |||
179 | } | 181 | } |
180 | 182 | ||
181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
182 | "Transmitting message with %u bytes to peer %s\n", | 184 | "Transmitting message with %u bytes to peer %u (%4s)\n", |
183 | sizeof (struct GNUNET_MessageHeader), GNUNET_i2s (&p->id)); | 185 | sizeof (struct GNUNET_MessageHeader), p->no, GNUNET_i2s (&p->id)); |
184 | GNUNET_assert (size >= 256); | 186 | GNUNET_assert (size >= 256); |
185 | 187 | ||
186 | if (buf != NULL) | 188 | if (buf != NULL) |
@@ -198,18 +200,23 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
198 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 200 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
199 | uint32_t ats_count) | 201 | uint32_t ats_count) |
200 | { | 202 | { |
201 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", | 203 | struct PeerContext *p = cls; |
202 | GNUNET_i2s (peer), cls); | 204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n", |
205 | p->no, GNUNET_i2s (peer)); | ||
203 | } | 206 | } |
204 | 207 | ||
205 | 208 | ||
206 | static void | 209 | static void |
207 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 210 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
208 | { | 211 | { |
209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n", | 212 | struct PeerContext *p = cls; |
210 | GNUNET_i2s (peer), cls); | 213 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", |
214 | p->no, GNUNET_i2s (peer)); | ||
211 | } | 215 | } |
212 | 216 | ||
217 | struct PeerContext * sender; | ||
218 | struct PeerContext * receiver; | ||
219 | |||
213 | static void | 220 | static void |
214 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 221 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
215 | { | 222 | { |
@@ -217,10 +224,16 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
217 | 224 | ||
218 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 225 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
219 | return; | 226 | return; |
227 | char * receiver_s = strdup(GNUNET_i2s (&receiver->id)); | ||
228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
229 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", | ||
230 | sender->no, | ||
231 | GNUNET_i2s (&sender->id), receiver->no, receiver_s); | ||
232 | GNUNET_free (receiver_s); | ||
220 | 233 | ||
221 | th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, &p2->id, 256, 0, | 234 | th = GNUNET_TRANSPORT_notify_transmit_ready (sender->th, &receiver->id, 256, 0, |
222 | TIMEOUT_TRANSMIT, ¬ify_ready, | 235 | TIMEOUT_TRANSMIT, ¬ify_ready, |
223 | &p1); | 236 | receiver); |
224 | } | 237 | } |
225 | 238 | ||
226 | static void | 239 | static void |
@@ -229,8 +242,9 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
229 | cc = NULL; | 242 | cc = NULL; |
230 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); | 243 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); |
231 | 244 | ||
232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c, | 245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", |
233 | GNUNET_i2s (&p2->id)); | 246 | p1->no, p1_c, |
247 | p2->no, GNUNET_i2s (&p2->id)); | ||
234 | GNUNET_free (p1_c); | 248 | GNUNET_free (p1_c); |
235 | 249 | ||
236 | // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG! | 250 | // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG! |
@@ -247,10 +261,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
247 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, ¬ify_receive, | 261 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, ¬ify_receive, |
248 | ¬ify_connect, ¬ify_disconnect, | 262 | ¬ify_connect, ¬ify_disconnect, |
249 | NULL); | 263 | NULL); |
264 | p1->no = 1; | ||
250 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, ¬ify_receive, | 265 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, ¬ify_receive, |
251 | ¬ify_connect, ¬ify_disconnect, | 266 | ¬ify_connect, ¬ify_disconnect, |
252 | NULL); | 267 | NULL); |
253 | 268 | p2->no = 2; | |
254 | if ((p1 == NULL) || (p2 == NULL)) | 269 | if ((p1 == NULL) || (p2 == NULL)) |
255 | { | 270 | { |
256 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n"); | 271 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n"); |
@@ -260,6 +275,22 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
260 | return; | 275 | return; |
261 | } | 276 | } |
262 | 277 | ||
278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file `%s'\n", | ||
279 | p1->no, | ||
280 | GNUNET_i2s (&p1->id), cfg_file_p1); | ||
281 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file `%s'\n", | ||
282 | p2->no, | ||
283 | GNUNET_i2s (&p2->id), cfg_file_p2); | ||
284 | |||
285 | sender = p2; | ||
286 | receiver = p1; | ||
287 | |||
288 | char *sender_c = strdup (GNUNET_i2s (&sender->id)); | ||
289 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test triest to send from %u (%s) -> peer %u (%s)\n", | ||
290 | sender->no, sender_c, | ||
291 | receiver->no, GNUNET_i2s (&receiver->id)); | ||
292 | |||
293 | |||
263 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, | 294 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, |
264 | NULL); | 295 | NULL); |
265 | } | 296 | } |