diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/Makefile.am | 1 | ||||
-rw-r--r-- | src/transport/gnunet-communicator-unix.c | 34 | ||||
-rw-r--r-- | src/transport/test_communicator_unix.c | 212 | ||||
-rw-r--r-- | src/transport/transport-testing2.c | 22 | ||||
-rw-r--r-- | src/transport/transport-testing2.h | 2 |
5 files changed, 155 insertions, 116 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index ae77899a0..a5b9aaaa8 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -786,6 +786,7 @@ test_communicator_unix_SOURCES = \ | |||
786 | test_communicator_unix.c | 786 | test_communicator_unix.c |
787 | test_communicator_unix_LDADD = \ | 787 | test_communicator_unix_LDADD = \ |
788 | libgnunettransporttesting2.la \ | 788 | libgnunettransporttesting2.la \ |
789 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
789 | $(top_builddir)/src/util/libgnunetutil.la | 790 | $(top_builddir)/src/util/libgnunetutil.la |
790 | 791 | ||
791 | test_plugin_unix_SOURCES = \ | 792 | test_plugin_unix_SOURCES = \ |
diff --git a/src/transport/gnunet-communicator-unix.c b/src/transport/gnunet-communicator-unix.c index 58a144ecb..404bcfb7f 100644 --- a/src/transport/gnunet-communicator-unix.c +++ b/src/transport/gnunet-communicator-unix.c | |||
@@ -114,7 +114,7 @@ struct Queue | |||
114 | * Message currently scheduled for transmission, non-NULL if and only | 114 | * Message currently scheduled for transmission, non-NULL if and only |
115 | * if this queue is in the #queue_head DLL. | 115 | * if this queue is in the #queue_head DLL. |
116 | */ | 116 | */ |
117 | const struct GNUNET_MessageHeader *msg; | 117 | struct UNIXMessage *msg; |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * Message queue we are providing for the #ch. | 120 | * Message queue we are providing for the #ch. |
@@ -142,6 +142,10 @@ struct Queue | |||
142 | struct GNUNET_SCHEDULER_Task *timeout_task; | 142 | struct GNUNET_SCHEDULER_Task *timeout_task; |
143 | }; | 143 | }; |
144 | 144 | ||
145 | /** | ||
146 | * My Peer Identity | ||
147 | */ | ||
148 | static struct GNUNET_PeerIdentity my_identity; | ||
145 | 149 | ||
146 | /** | 150 | /** |
147 | * ID of read task | 151 | * ID of read task |
@@ -357,7 +361,7 @@ lookup_queue_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) | |||
357 | struct LookupCtx *lctx = cls; | 361 | struct LookupCtx *lctx = cls; |
358 | struct Queue *queue = value; | 362 | struct Queue *queue = value; |
359 | 363 | ||
360 | if ((queue->address_len = lctx->un_len) && | 364 | if ((queue->address_len == lctx->un_len) && |
361 | (0 == memcmp (lctx->un, queue->address, queue->address_len))) | 365 | (0 == memcmp (lctx->un, queue->address, queue->address_len))) |
362 | { | 366 | { |
363 | lctx->res = queue; | 367 | lctx->res = queue; |
@@ -383,6 +387,7 @@ lookup_queue (const struct GNUNET_PeerIdentity *peer, | |||
383 | 387 | ||
384 | lctx.un = un; | 388 | lctx.un = un; |
385 | lctx.un_len = un_len; | 389 | lctx.un_len = un_len; |
390 | lctx.res = NULL; | ||
386 | GNUNET_CONTAINER_multipeermap_get_multiple (queue_map, | 391 | GNUNET_CONTAINER_multipeermap_get_multiple (queue_map, |
387 | peer, | 392 | peer, |
388 | &lookup_queue_it, | 393 | &lookup_queue_it, |
@@ -401,7 +406,7 @@ static void | |||
401 | select_write_cb (void *cls) | 406 | select_write_cb (void *cls) |
402 | { | 407 | { |
403 | struct Queue *queue = queue_tail; | 408 | struct Queue *queue = queue_tail; |
404 | const struct GNUNET_MessageHeader *msg = queue->msg; | 409 | const struct GNUNET_MessageHeader *msg = &queue->msg->header; |
405 | size_t msg_size = ntohs (msg->size); | 410 | size_t msg_size = ntohs (msg->size); |
406 | ssize_t sent; | 411 | ssize_t sent; |
407 | 412 | ||
@@ -514,10 +519,15 @@ mq_send (struct GNUNET_MQ_Handle *mq, | |||
514 | void *impl_state) | 519 | void *impl_state) |
515 | { | 520 | { |
516 | struct Queue *queue = impl_state; | 521 | struct Queue *queue = impl_state; |
522 | size_t msize = ntohs (msg->size); | ||
517 | 523 | ||
518 | GNUNET_assert (mq == queue->mq); | 524 | GNUNET_assert (mq == queue->mq); |
519 | GNUNET_assert (NULL == queue->msg); | 525 | GNUNET_assert (NULL == queue->msg); |
520 | queue->msg = msg; | 526 | //Convert to UNIXMessage |
527 | queue->msg = GNUNET_malloc (msize + sizeof (struct UNIXMessage)); | ||
528 | queue->msg->header.size = htons(msize + sizeof (struct UNIXMessage)); | ||
529 | queue->msg->sender = my_identity; | ||
530 | memcpy (&queue->msg[1], msg, msize); | ||
521 | GNUNET_CONTAINER_DLL_insert (queue_head, queue_tail, queue); | 531 | GNUNET_CONTAINER_DLL_insert (queue_head, queue_tail, queue); |
522 | GNUNET_assert (NULL != unix_sock); | 532 | GNUNET_assert (NULL != unix_sock); |
523 | if (NULL == write_task) | 533 | if (NULL == write_task) |
@@ -747,6 +757,9 @@ select_read_cb (void *cls) | |||
747 | msize = ntohs (msg->header.size); | 757 | msize = ntohs (msg->header.size); |
748 | if ((msize < sizeof(struct UNIXMessage)) || (msize > ret)) | 758 | if ((msize < sizeof(struct UNIXMessage)) || (msize > ret)) |
749 | { | 759 | { |
760 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
761 | "Wrong message size: %d bytes\n", | ||
762 | msize); | ||
750 | GNUNET_break_op (0); | 763 | GNUNET_break_op (0); |
751 | return; | 764 | return; |
752 | } | 765 | } |
@@ -974,9 +987,22 @@ run (void *cls, | |||
974 | struct sockaddr_un *un; | 987 | struct sockaddr_un *un; |
975 | socklen_t un_len; | 988 | socklen_t un_len; |
976 | char *my_addr; | 989 | char *my_addr; |
990 | struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key; | ||
977 | 991 | ||
978 | (void) cls; | 992 | (void) cls; |
979 | 993 | ||
994 | my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg); | ||
995 | if (NULL == my_private_key) | ||
996 | { | ||
997 | GNUNET_log ( | ||
998 | GNUNET_ERROR_TYPE_ERROR, | ||
999 | _ ( | ||
1000 | "UNIX communicator is lacking key configuration settings. Exiting.\n")); | ||
1001 | GNUNET_SCHEDULER_shutdown (); | ||
1002 | return; | ||
1003 | } | ||
1004 | GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, &my_identity.public_key); | ||
1005 | |||
980 | if (GNUNET_OK != | 1006 | if (GNUNET_OK != |
981 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 1007 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
982 | COMMUNICATOR_CONFIG_SECTION, | 1008 | COMMUNICATOR_CONFIG_SECTION, |
diff --git a/src/transport/test_communicator_unix.c b/src/transport/test_communicator_unix.c index db355c93e..83ab1ea26 100644 --- a/src/transport/test_communicator_unix.c +++ b/src/transport/test_communicator_unix.c | |||
@@ -1,33 +1,34 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2019 GNUnet e.V. | 3 | Copyright (C) 2019 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file transport/test_communicator_unix.c | 22 | * @file transport/test_communicator_unix.c |
23 | * @brief test the unix communicator | 23 | * @brief test the unix communicator |
24 | * @author Julius Bünger | 24 | * @author Julius Bünger |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "transport-testing2.h" | 28 | #include "transport-testing2.h" |
29 | #include "gnunet_ats_transport_service.h" | 29 | #include "gnunet_ats_transport_service.h" |
30 | #include "gnunet_signatures.h" | 30 | #include "gnunet_signatures.h" |
31 | #include "gnunet_testing_lib.h" | ||
31 | #include "transport.h" | 32 | #include "transport.h" |
32 | 33 | ||
33 | #include <inttypes.h> | 34 | #include <inttypes.h> |
@@ -41,9 +42,17 @@ | |||
41 | 42 | ||
42 | static struct GNUNET_PeerIdentity peer_id[NUM_PEERS]; | 43 | static struct GNUNET_PeerIdentity peer_id[NUM_PEERS]; |
43 | 44 | ||
45 | static char *communicator_binary; | ||
46 | |||
44 | static struct | 47 | static struct |
45 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_hs[NUM_PEERS]; | 48 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_hs[NUM_PEERS]; |
46 | 49 | ||
50 | static struct GNUNET_CONFIGURATION_Handle *cfg_peers[NUM_PEERS]; | ||
51 | |||
52 | static char **cfg_peers_name; | ||
53 | |||
54 | static int ret; | ||
55 | |||
47 | // static char *addresses[NUM_PEERS]; | 56 | // static char *addresses[NUM_PEERS]; |
48 | 57 | ||
49 | 58 | ||
@@ -53,7 +62,6 @@ GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_hs[NUM_PEERS]; | |||
53 | // static char payload[] = "TEST PAYLOAD"; | 62 | // static char payload[] = "TEST PAYLOAD"; |
54 | static uint32_t payload = 42; | 63 | static uint32_t payload = 42; |
55 | 64 | ||
56 | |||
57 | static void | 65 | static void |
58 | communicator_available_cb (void *cls, | 66 | communicator_available_cb (void *cls, |
59 | struct | 67 | struct |
@@ -62,7 +70,7 @@ communicator_available_cb (void *cls, | |||
62 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, | 70 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, |
63 | char *address_prefix) | 71 | char *address_prefix) |
64 | { | 72 | { |
65 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 73 | LOG (GNUNET_ERROR_TYPE_INFO, |
66 | "Communicator available. (cc: %u, prefix: %s)\n", | 74 | "Communicator available. (cc: %u, prefix: %s)\n", |
67 | cc, | 75 | cc, |
68 | address_prefix); | 76 | address_prefix); |
@@ -85,9 +93,12 @@ add_address_cb (void *cls, | |||
85 | aid, | 93 | aid, |
86 | nt); | 94 | nt); |
87 | // addresses[1] = GNUNET_strdup (address); | 95 | // addresses[1] = GNUNET_strdup (address); |
88 | GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[0], | 96 | if (0 == strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) |
89 | &peer_id[1], | 97 | GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[0], |
90 | address); | 98 | &peer_id[ |
99 | NUM_PEERS | ||
100 | - 1], | ||
101 | address); | ||
91 | } | 102 | } |
92 | 103 | ||
93 | 104 | ||
@@ -156,11 +167,20 @@ void | |||
156 | incoming_message_cb (void *cls, | 167 | incoming_message_cb (void *cls, |
157 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | 168 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle |
158 | *tc_h, | 169 | *tc_h, |
159 | const struct GNUNET_MessageHeader *msg) | 170 | const struct GNUNET_TRANSPORT_IncomingMessage *msg) |
160 | { | 171 | { |
172 | char *payload_ptr; | ||
173 | if (0 != strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) | ||
174 | return; // TODO? | ||
175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
176 | "%s received data (%lu bytes payload)\n", | ||
177 | (char*) cls, | ||
178 | ntohs (msg->header.size) - sizeof (struct GNUNET_TRANSPORT_IncomingMessage)); | ||
179 | payload_ptr = (char*)&msg[1] + sizeof (struct GNUNET_MessageHeader); | ||
180 | ret = memcmp (payload_ptr, &payload, sizeof (payload)); | ||
181 | GNUNET_SCHEDULER_shutdown (); | ||
161 | } | 182 | } |
162 | 183 | ||
163 | |||
164 | /** | 184 | /** |
165 | * @brief Main function called by the scheduler | 185 | * @brief Main function called by the scheduler |
166 | * | 186 | * |
@@ -169,28 +189,19 @@ incoming_message_cb (void *cls, | |||
169 | static void | 189 | static void |
170 | run (void *cls) | 190 | run (void *cls) |
171 | { | 191 | { |
172 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 192 | for (int i = 0; i < NUM_PEERS; i++) |
173 | 193 | { | |
174 | tc_hs[0] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( | 194 | tc_hs[i] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( |
175 | "transport", | 195 | "transport", |
176 | "gnunet-communicator-unix", | 196 | communicator_binary, |
177 | "test_communicator_1.conf", | 197 | cfg_peers_name[i], |
178 | &communicator_available_cb, | 198 | &communicator_available_cb, |
179 | NULL, | 199 | &add_address_cb, |
180 | &queue_create_reply_cb, | 200 | &queue_create_reply_cb, |
181 | &add_queue_cb, | 201 | &add_queue_cb, |
182 | NULL, | 202 | &incoming_message_cb, |
183 | NULL); /* cls */ | 203 | cfg_peers_name[i]); /* cls */ |
184 | tc_hs[1] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( | 204 | } |
185 | "transport", | ||
186 | "gnunet-communicator-unix", | ||
187 | "test_communicator_2.conf", | ||
188 | &communicator_available_cb, | ||
189 | &add_address_cb, | ||
190 | NULL, | ||
191 | &add_queue_cb, | ||
192 | NULL, | ||
193 | NULL); /* cls */ | ||
194 | } | 205 | } |
195 | 206 | ||
196 | 207 | ||
@@ -198,81 +209,72 @@ int | |||
198 | main (int argc, | 209 | main (int argc, |
199 | char *const *argv) | 210 | char *const *argv) |
200 | { | 211 | { |
201 | char *cfg_filename; | 212 | struct GNUNET_CRYPTO_EddsaPrivateKey *private_key; |
202 | char *opt_cfg_filename; | 213 | char *communicator_name; |
203 | const char *xdg; | 214 | char *cfg_peer; |
204 | char *loglev; | 215 | ret = 1; |
205 | char *logfile; | 216 | |
206 | struct GNUNET_CONFIGURATION_Handle *cfg; | 217 | communicator_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); |
207 | 218 | GNUNET_asprintf (&communicator_binary, "gnunet-communicator-%s", | |
208 | struct GNUNET_GETOPT_CommandLineOption service_options[] = { | 219 | communicator_name); |
209 | GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename), | 220 | cfg_peers_name = GNUNET_malloc (sizeof(char*) * NUM_PEERS); |
210 | GNUNET_GETOPT_option_help (NULL), | 221 | if (GNUNET_OK != GNUNET_log_setup ("test_communicator", |
211 | GNUNET_GETOPT_option_loglevel (&loglev), | 222 | "DEBUG", |
212 | GNUNET_GETOPT_option_logfile (&logfile), | 223 | "test_communicator.log")) |
213 | GNUNET_GETOPT_OPTION_END | ||
214 | }; | ||
215 | |||
216 | if (GNUNET_OK != GNUNET_log_setup ("test_communicator_unix", | ||
217 | loglev, | ||
218 | logfile)) | ||
219 | { | 224 | { |
225 | fprintf (stderr, "Unable to setup log\n"); | ||
220 | GNUNET_break (0); | 226 | GNUNET_break (0); |
221 | return GNUNET_SYSERR; | 227 | return 2; |
222 | } | ||
223 | |||
224 | xdg = getenv ("XDG_CONFIG_HOME"); | ||
225 | if (NULL != xdg) | ||
226 | GNUNET_asprintf (&cfg_filename, | ||
227 | "%s%s%s", | ||
228 | xdg, | ||
229 | DIR_SEPARATOR_STR, | ||
230 | GNUNET_OS_project_data_get ()->config_file); | ||
231 | else | ||
232 | cfg_filename = GNUNET_strdup ( | ||
233 | GNUNET_OS_project_data_get ()->user_config_file); | ||
234 | cfg = GNUNET_CONFIGURATION_create (); | ||
235 | if (NULL != opt_cfg_filename) | ||
236 | { | ||
237 | if ((GNUNET_YES != | ||
238 | GNUNET_DISK_file_test (opt_cfg_filename)) || | ||
239 | (GNUNET_SYSERR == | ||
240 | GNUNET_CONFIGURATION_load (cfg, | ||
241 | opt_cfg_filename))) | ||
242 | { | ||
243 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
244 | _ ("Malformed configuration file `%s', exit ...\n"), | ||
245 | opt_cfg_filename); | ||
246 | return GNUNET_SYSERR; | ||
247 | } | ||
248 | } | 228 | } |
249 | else | 229 | for (int i = 0; i < NUM_PEERS; i++) |
250 | { | 230 | { |
231 | GNUNET_asprintf ((&cfg_peer), | ||
232 | "test_communicator_%s_peer%u.conf", | ||
233 | communicator_name, i + 1); | ||
234 | cfg_peers_name[i] = cfg_peer; | ||
235 | cfg_peers[i] = GNUNET_CONFIGURATION_create (); | ||
251 | if (GNUNET_YES == | 236 | if (GNUNET_YES == |
252 | GNUNET_DISK_file_test (cfg_filename)) | 237 | GNUNET_DISK_file_test (cfg_peers_name[i])) |
253 | { | 238 | { |
254 | if (GNUNET_SYSERR == | 239 | if (GNUNET_SYSERR == |
255 | GNUNET_CONFIGURATION_load (cfg, | 240 | GNUNET_CONFIGURATION_load (cfg_peers[i], |
256 | cfg_filename)) | 241 | cfg_peers_name[i])) |
257 | { | 242 | { |
258 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 243 | fprintf (stderr, |
259 | _ ("Malformed configuration file `%s', exit ...\n"), | 244 | "Malformed configuration file `%s', exiting ...\n", |
260 | cfg_filename); | 245 | cfg_peers_name[i]); |
261 | return GNUNET_SYSERR; | 246 | return 1; |
262 | } | 247 | } |
263 | } | 248 | } |
264 | else | 249 | else |
265 | { | 250 | { |
266 | if (GNUNET_SYSERR == | 251 | if (GNUNET_SYSERR == |
267 | GNUNET_CONFIGURATION_load (cfg, | 252 | GNUNET_CONFIGURATION_load (cfg_peers[i], |
268 | NULL)) | 253 | NULL)) |
269 | { | 254 | { |
270 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 255 | fprintf (stderr, |
271 | _ ("Malformed configuration, exit ...\n")); | 256 | "Configuration file %s does not exist, exiting ...\n", |
272 | return GNUNET_SYSERR; | 257 | cfg_peers_name[i]); |
258 | return 1; | ||
273 | } | 259 | } |
274 | } | 260 | } |
261 | private_key = | ||
262 | GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg_peers[i]); | ||
263 | if (NULL == private_key) | ||
264 | { | ||
265 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
266 | "Unable to get peer ID\n"); | ||
267 | return 1; | ||
268 | } | ||
269 | GNUNET_CRYPTO_eddsa_key_get_public (private_key, | ||
270 | &peer_id[i].public_key); | ||
271 | GNUNET_free (private_key); | ||
272 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
273 | "Identity of peer %u is %s\n", | ||
274 | i, GNUNET_i2s_full (&peer_id[i])); | ||
275 | } | 275 | } |
276 | fprintf (stderr, "Starting test...\n"); | ||
276 | GNUNET_SCHEDULER_run (&run, | 277 | GNUNET_SCHEDULER_run (&run, |
277 | cfg); | 278 | NULL); |
279 | return ret; | ||
278 | } | 280 | } |
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 7204d26da..b354f7c2a 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -306,14 +306,14 @@ handle_add_address (void *cls, | |||
306 | { | 306 | { |
307 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | 307 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
308 | uint16_t size; | 308 | uint16_t size; |
309 | |||
310 | size = ntohs (msg->header.size) - sizeof(*msg); | 309 | size = ntohs (msg->header.size) - sizeof(*msg); |
311 | if (0 == size) | 310 | if (0 == size) |
312 | return; /* receive-only communicator */ | 311 | return; /* receive-only communicator */ |
312 | LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size); | ||
313 | tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]); | 313 | tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]); |
314 | if (NULL != tc_h->add_address_cb) | 314 | if (NULL != tc_h->add_address_cb) |
315 | { | 315 | { |
316 | LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available()\n"); | 316 | LOG (GNUNET_ERROR_TYPE_DEBUG, "calling add_address_cb()\n"); |
317 | tc_h->add_address_cb (tc_h->cb_cls, | 317 | tc_h->add_address_cb (tc_h->cb_cls, |
318 | tc_h, | 318 | tc_h, |
319 | tc_h->c_address, | 319 | tc_h->c_address, |
@@ -366,7 +366,7 @@ handle_incoming_msg (void *cls, | |||
366 | { | 366 | { |
367 | tc_h->incoming_msg_cb (tc_h->cb_cls, | 367 | tc_h->incoming_msg_cb (tc_h->cb_cls, |
368 | tc_h, | 368 | tc_h, |
369 | (const struct GNUNET_MessageHeader *) msg); | 369 | msg); |
370 | } | 370 | } |
371 | else | 371 | else |
372 | { | 372 | { |
@@ -452,9 +452,19 @@ handle_add_queue_message (void *cls, | |||
452 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue; | 452 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue; |
453 | 453 | ||
454 | tc_queue = tc_h->queue_head; | 454 | tc_queue = tc_h->queue_head; |
455 | while (tc_queue->qid != msg->qid) | 455 | if (NULL != tc_queue) |
456 | { | 456 | { |
457 | tc_queue = tc_queue->next; | 457 | while (tc_queue->qid != msg->qid) |
458 | { | ||
459 | tc_queue = tc_queue->next; | ||
460 | } | ||
461 | } else { | ||
462 | tc_queue = | ||
463 | GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue); | ||
464 | tc_queue->tc_h = tc_h; | ||
465 | tc_queue->qid = msg->qid; | ||
466 | tc_queue->peer_id = msg->receiver; | ||
467 | GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue); | ||
458 | } | 468 | } |
459 | GNUNET_assert (tc_queue->qid == msg->qid); | 469 | GNUNET_assert (tc_queue->qid == msg->qid); |
460 | GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver)); | 470 | GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver)); |
@@ -663,7 +673,7 @@ communicator_start ( | |||
663 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!"); | 673 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!"); |
664 | return; | 674 | return; |
665 | } | 675 | } |
666 | LOG (GNUNET_ERROR_TYPE_DEBUG, "started communicator\n"); | 676 | LOG (GNUNET_ERROR_TYPE_INFO, "started communicator\n"); |
667 | GNUNET_free (binary); | 677 | GNUNET_free (binary); |
668 | /* TODO */ GNUNET_SCHEDULER_add_shutdown (&shutdown_communicator, | 678 | /* TODO */ GNUNET_SCHEDULER_add_shutdown (&shutdown_communicator, |
669 | tc_h->c_proc); | 679 | tc_h->c_proc); |
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h index b136be125..49e4791aa 100644 --- a/src/transport/transport-testing2.h +++ b/src/transport/transport-testing2.h | |||
@@ -135,7 +135,7 @@ typedef void | |||
135 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | 135 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle |
136 | *tc_h, | 136 | *tc_h, |
137 | const struct | 137 | const struct |
138 | GNUNET_MessageHeader *msg); | 138 | GNUNET_TRANSPORT_IncomingMessage *msg); |
139 | 139 | ||
140 | 140 | ||
141 | /** | 141 | /** |