aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/test_communicator_unix.c55
-rw-r--r--src/transport/transport-testing2.c70
-rw-r--r--src/transport/transport-testing2.h87
3 files changed, 195 insertions, 17 deletions
diff --git a/src/transport/test_communicator_unix.c b/src/transport/test_communicator_unix.c
index 459af116a..0fdbe4b99 100644
--- a/src/transport/test_communicator_unix.c
+++ b/src/transport/test_communicator_unix.c
@@ -85,20 +85,42 @@ add_address_cb (void *cls,
85} 85}
86 86
87 87
88/**
89 * @brief Callback that informs whether the requested queue will be
90 * established
91 *
92 * Implements #GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback.
93 *
94 * @param cls Closure - unused
95 * @param tc_h Communicator handle - unused
96 * @param will_try #GNUNET_YES if queue will be established
97 * #GNUNET_NO if queue will not be established (bogous address)
98 */
88static void 99static void
89queue_create_reply_cb (void *cls, 100queue_create_reply_cb (void *cls,
90 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, 101 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
91 int success) 102 int will_try)
92{ 103{
93 if (GNUNET_YES == success) 104 if (GNUNET_YES == will_try)
94 LOG (GNUNET_ERROR_TYPE_DEBUG, 105 LOG (GNUNET_ERROR_TYPE_DEBUG,
95 "Got Queue!\n"); 106 "Queue will be established!\n");
96 else 107 else
97 LOG (GNUNET_ERROR_TYPE_DEBUG, 108 LOG (GNUNET_ERROR_TYPE_WARNING,
98 "Failed getting queue!\n"); 109 "Queue won't be established (bougus address?)!\n");
99} 110}
100 111
101 112
113/**
114 * @brief Handle opening of queue
115 *
116 * Issues sending of test data
117 *
118 * Implements #GNUNET_TRANSPORT_TESTING_AddQueueCallback
119 *
120 * @param cls Closure
121 * @param tc_h Communicator handle
122 * @param tc_queue Handle to newly opened queue
123 */
102static void 124static void
103add_queue_cb (void *cls, 125add_queue_cb (void *cls,
104 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, 126 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
@@ -112,6 +134,28 @@ add_queue_cb (void *cls,
112} 134}
113 135
114 136
137/**
138 * @brief Handle an incoming message
139 *
140 * Implements #GNUNET_TRANSPORT_TESTING_IncomingMessageCallback
141
142 * @param cls Closure
143 * @param tc_h Handle to the receiving communicator
144 * @param msg Received message
145 */
146void
147incoming_message_cb (void *cls,
148 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
149 const struct GNUNET_MessageHeader *msg)
150{
151}
152
153
154/**
155 * @brief Main function called by the scheduler
156 *
157 * @param cls Closure - Handle to configuration
158 */
115static void 159static void
116run (void *cls) 160run (void *cls)
117{ 161{
@@ -125,6 +169,7 @@ run (void *cls)
125 NULL, 169 NULL,
126 &queue_create_reply_cb, 170 &queue_create_reply_cb,
127 &add_queue_cb, 171 &add_queue_cb,
172 NULL,
128 NULL); /* cls */ 173 NULL); /* cls */
129 tc_hs[1] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( 174 tc_hs[1] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
130 "transport", 175 "transport",
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,
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h
index 83d98baab..fbc1927d9 100644
--- a/src/transport/transport-testing2.h
+++ b/src/transport/transport-testing2.h
@@ -20,7 +20,7 @@
20 20
21/** 21/**
22 * @file transport/transport-testing2.h 22 * @file transport/transport-testing2.h
23 * @brief functions related to testing-tng 23 * @brief functions and structures related to testing-tng
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Julius Bünger 25 * @author Julius Bünger
26 */ 26 */
@@ -30,17 +30,32 @@
30#include "transport.h" 30#include "transport.h"
31 31
32 32
33/**
34 * @brief Handle to a transport communicator
35 */
33struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle; 36struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle;
34 37
38
39/**
40 * @brief Queue of a communicator and some context
41 */
35struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue; 42struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue;
36 43
44
45/**
46 * @brief Handle/Context to a single transmission
47 */
37struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission; 48struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission;
38 49
50
39/** 51/**
40 * @brief Function signature for callbacks that are called when new communicators become available 52 * @brief Function signature for callbacks that are called when new
53 * communicators become available
41 * 54 *
42 * @param Closure 55 * @param cls Closure
43 * @param msg Message 56 * @param tc_h Communicator handle
57 * @param cc Characteristics of communicator
58 * @param address_prefix Prefix of the address
44 */ 59 */
45typedef void 60typedef void
46(*GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback)(void *cls, 61(*GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback)(void *cls,
@@ -49,6 +64,16 @@ typedef void
49 char *address_prefix); 64 char *address_prefix);
50 65
51 66
67/**
68 * @brief Receive information about the address of a communicator.
69 *
70 * @param cls Closure
71 * @param tc_h Communicator handle
72 * @param address Address represented as string
73 * @param expiration Expiration
74 * @param aid Aid
75 * @param nt Network Type
76 */
52typedef void 77typedef void
53(*GNUNET_TRANSPORT_TESTING_AddAddressCallback)(void *cls, 78(*GNUNET_TRANSPORT_TESTING_AddAddressCallback)(void *cls,
54 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, 79 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
@@ -58,12 +83,26 @@ typedef void
58 enum GNUNET_NetworkType nt); 83 enum GNUNET_NetworkType nt);
59 84
60 85
86/**
87 * @brief Get informed about the success of a queue request.
88 *
89 * @param cls Closure
90 * @param tc_h Communicator handle
91 * @param will_try #GNUNET_YES if communicator will try to create queue
92 */
61typedef void 93typedef void
62(*GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback)(void *cls, 94(*GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback)(void *cls,
63 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, 95 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
64 int will_try); 96 int will_try);
65 97
66 98
99/**
100 * @brief Handle opening of queue
101 *
102 * @param cls Closure
103 * @param tc_h Communicator handle
104 * @param tc_queue Handle to newly opened queue
105 */
67typedef void 106typedef void
68(*GNUNET_TRANSPORT_TESTING_AddQueueCallback)(void *cls, 107(*GNUNET_TRANSPORT_TESTING_AddQueueCallback)(void *cls,
69 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, 108 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
@@ -71,33 +110,69 @@ typedef void
71 110
72 111
73/** 112/**
113 * @brief Handle an incoming message
114 *
115 * @param cls Closure
116 * @param tc_h Handle to the receiving communicator
117 * @param msg Received message
118 */
119typedef void
120(*GNUNET_TRANSPORT_TESTING_IncomingMessageCallback)(void *cls,
121 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
122 const struct GNUNET_MessageHeader *msg);
123
124
125/**
74 * @brief Start communicator part of transport service and communicator 126 * @brief Start communicator part of transport service and communicator
75 * 127 *
76 * @param service_name Name of the service 128 * @param service_name Name of the service
77 * @param cfg Configuration handle 129 * @param cfg Configuration handle
78 * @param communicator_available Callback that is called when a new 130 * @param communicator_available Callback that is called when a new
79 * communicator becomes available 131 * communicator becomes available
132 * @param add_address_cb Callback handling new addresses
133 * @param queue_create_reply_cb Callback handling success of queue requests
134 * @param add_queue_cb Callback handling freshly created queues
135 * @param incoming_message_cb Callback handling incoming messages
80 * @param cb_cls Closure to @p communicator_available 136 * @param cb_cls Closure to @p communicator_available
81 * 137 *
82 * @return Handle to the communicator duo 138 * @return Handle to the communicator duo
83 */ 139 */
84struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * 140struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
85GNUNET_TRANSPORT_TESTING_transport_communicator_service_start 141GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
86 (const char *service_name, 142 const char *service_name,
87 const char *binary_name, 143 const char *binary_name,
88 const char *cfg_filename, 144 const char *cfg_filename,
89 GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb, 145 GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb,
90 GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb, 146 GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb,
91 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb, 147 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
92 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb, 148 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
149 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb,
93 void *cb_cls); 150 void *cb_cls);
94 151
152
153/**
154 * @brief Instruct communicator to open a queue
155 *
156 * @param tc_h Handle to communicator which shall open queue
157 * @param peer_id Towards which peer
158 * @param address For which address
159 */
95void 160void
96GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue 161GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue
97 (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, 162 (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
98 const struct GNUNET_PeerIdentity *peer_id, 163 const struct GNUNET_PeerIdentity *peer_id,
99 const char *address); 164 const char *address);
100 165
166
167/**
168 * @brief Instruct communicator to send data
169 *
170 * @param tc_queue The queue to use for sending
171 * @param payload Data to send
172 * @param payload_size Size of the payload
173 *
174 * @return Handle to the transmission
175 */
101struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission * 176struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *
102GNUNET_TRANSPORT_TESTING_transport_communicator_send 177GNUNET_TRANSPORT_TESTING_transport_communicator_send
103 (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue, 178 (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue,