aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport-testing2.c')
-rw-r--r--src/transport/transport-testing2.c70
1 files changed, 64 insertions, 6 deletions
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index ff8e15719..fc7ae2df6 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -38,6 +38,9 @@
38#define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__) 38#define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__)
39 39
40 40
41/**
42 * @brief Handle to a transport communicator
43 */
41struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle 44struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
42{ 45{
43 /** 46 /**
@@ -97,12 +100,12 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
97 char *c_address; 100 char *c_address;
98 101
99 /** 102 /**
100 * @brief Head of the queues 103 * @brief Head of the DLL of queues associated with this communicator
101 */ 104 */
102 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_head; 105 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_head;
103 106
104 /** 107 /**
105 * @brief Tail of the queues 108 * @brief Tail of the DLL of queues associated with this communicator
106 */ 109 */
107 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_tail; 110 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_tail;
108 111
@@ -129,12 +132,20 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
129 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb; 132 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb;
130 133
131 /** 134 /**
135 * @brief Callback called when a new communicator connects
136 */
137 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb;
138
139 /**
132 * @brief Closure to the callback 140 * @brief Closure to the callback
133 */ 141 */
134 void *cb_cls; 142 void *cb_cls;
135}; 143};
136 144
137 145
146/**
147 * @brief Queue of a communicator and some context
148 */
138struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue 149struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
139{ 150{
140 /** 151 /**
@@ -143,7 +154,11 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
143 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h; 154 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h;
144 155
145 /** 156 /**
146 * @brief Task to request the opening of a view 157 * @brief Envelope to a message that requests the opening of the queue.
158 *
159 * If the client already requests queue(s), but the communicator is not yet
160 * connected, we cannot send the request to open the queue. Save it until the
161 * communicator becomes available and send it then.
147 */ 162 */
148 struct GNUNET_MQ_Envelope *open_queue_env; 163 struct GNUNET_MQ_Envelope *open_queue_env;
149 164
@@ -189,6 +204,9 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
189}; 204};
190 205
191 206
207/**
208 * @brief Handle/Context to a single transmission
209 */
192struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission 210struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission
193{ 211{
194}; 212};
@@ -221,7 +239,9 @@ check_communicator_available (
221/** 239/**
222 * @brief Handle new communicator 240 * @brief Handle new communicator
223 * 241 *
224 * @param cls Closure 242 * Store characteristics of communicator, call respective client callback.
243 *
244 * @param cls Closure - communicator handle
225 * @param msg Message struct 245 * @param msg Message struct
226 */ 246 */
227static void 247static void
@@ -272,6 +292,14 @@ check_add_address (void *cls,
272} 292}
273 293
274 294
295/**
296 * @brief The communicator informs about an address.
297 *
298 * Store address and call client callback.
299 *
300 * @param cls Closure - communicator handle
301 * @param msg Message
302 */
275static void 303static void
276handle_add_address (void *cls, 304handle_add_address (void *cls,
277 const struct GNUNET_TRANSPORT_AddAddressMessage *msg) 305 const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
@@ -311,6 +339,15 @@ handle_queue_create_ok (void *cls,
311} 339}
312 340
313 341
342/**
343 * @brief Communicator informs that it wont try establishing requested queue.
344 *
345 * It will not do so probably because the address is bougus (see comment to
346 * #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL)
347 *
348 * @param cls Closure - communicator handle
349 * @param msg Message
350 */
314static void 351static void
315handle_queue_create_fail ( 352handle_queue_create_fail (
316 void *cls, 353 void *cls,
@@ -342,9 +379,11 @@ check_add_queue_message (void *cls,
342 379
343 380
344/** 381/**
345 * @brief Handle new communicator 382 * @brief Handle new queue
346 * 383 *
347 * @param cls Closure 384 * Store context and call client callback.
385 *
386 * @param cls Closure - communicator handle
348 * @param msg Message struct 387 * @param msg Message struct
349 */ 388 */
350static void 389static void
@@ -409,10 +448,13 @@ connect_cb (void *cls,
409 448
410 if (NULL == tc_h->queue_head) 449 if (NULL == tc_h->queue_head)
411 return tc_h; 450 return tc_h;
451 /* Iterate over queues. They are yet to be opened. Request opening. */
412 while (NULL != (tc_queue_iter = tc_h->queue_head)) 452 while (NULL != (tc_queue_iter = tc_h->queue_head))
413 { 453 {
414 if (NULL == tc_queue_iter->open_queue_env) 454 if (NULL == tc_queue_iter->open_queue_env)
415 continue; 455 continue;
456 /* Send the previously created mq envelope to request the creation of the
457 * queue. */
416 GNUNET_MQ_send (tc_h->c_mq, tc_queue_iter->open_queue_env); 458 GNUNET_MQ_send (tc_h->c_mq, tc_queue_iter->open_queue_env);
417 tc_queue_iter->open_queue_env = NULL; 459 tc_queue_iter->open_queue_env = NULL;
418 } 460 }
@@ -626,6 +668,13 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
626} 668}
627 669
628 670
671/**
672 * @brief Instruct communicator to open a queue
673 *
674 * @param tc_h Handle to communicator which shall open queue
675 * @param peer_id Towards which peer
676 * @param address For which address
677 */
629void 678void
630GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue ( 679GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (
631 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, 680 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
@@ -670,6 +719,15 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (
670} 719}
671 720
672 721
722/**
723 * @brief Instruct communicator to send data
724 *
725 * @param tc_queue The queue to use for sending
726 * @param payload Data to send
727 * @param payload_size Size of the payload
728 *
729 * @return Handle to the transmission
730 */
673struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission * 731struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *
674GNUNET_TRANSPORT_TESTING_transport_communicator_send 732GNUNET_TRANSPORT_TESTING_transport_communicator_send
675 (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue, 733 (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue,