2 This file is part of GNUnet.
3 Copyright (C) 2019 GNUnet e.V.
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
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file transport/transport-testing2.h
23 * @brief functions and structures related to testing-tng
24 * @author Christian Grothoff
25 * @author Julius Bünger
28 #include "gnunet_util_lib.h"
29 #include "gnunet_ats_transport_service.h"
30 #include "transport.h"
34 * @brief Handle to a transport communicator
36 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle;
40 * @brief Queue of a communicator and some context
42 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue;
46 * @brief Handle/Context to a single transmission
48 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission;
52 * @brief Function signature for callbacks that are called when new
53 * communicators become available
56 * @param tc_h Communicator handle
57 * @param cc Characteristics of communicator
58 * @param address_prefix Prefix of the address
61 (*GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback)(void *cls,
63 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
66 GNUNET_TRANSPORT_CommunicatorCharacteristics
68 char *address_prefix);
72 * @brief Receive information about the address of a communicator.
75 * @param tc_h Communicator handle
76 * @param address Address represented as string
77 * @param expiration Expiration
79 * @param nt Network Type
82 (*GNUNET_TRANSPORT_TESTING_AddAddressCallback)(void *cls,
84 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
87 struct GNUNET_TIME_Relative
90 enum GNUNET_NetworkType nt);
94 * @brief Get informed about the success of a queue request.
97 * @param tc_h Communicator handle
98 * @param will_try #GNUNET_YES if communicator will try to create queue
101 (*GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback)(void *cls,
103 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
109 * @brief Handle opening of queue
112 * @param tc_h Communicator handle
113 * @param tc_queue Handle to newly opened queue
116 (*GNUNET_TRANSPORT_TESTING_AddQueueCallback)(void *cls,
118 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
121 GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
126 * @brief Handle an incoming message
129 * @param tc_h Handle to the receiving communicator
130 * @param msg Received message
133 (*GNUNET_TRANSPORT_TESTING_IncomingMessageCallback)(void *cls,
135 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
138 GNUNET_MessageHeader *msg);
142 * @brief Start communicator part of transport service and communicator
144 * @param service_name Name of the service
145 * @param cfg Configuration handle
146 * @param communicator_available Callback that is called when a new
147 * communicator becomes available
148 * @param add_address_cb Callback handling new addresses
149 * @param queue_create_reply_cb Callback handling success of queue requests
150 * @param add_queue_cb Callback handling freshly created queues
151 * @param incoming_message_cb Callback handling incoming messages
152 * @param cb_cls Closure to @p communicator_available
154 * @return Handle to the communicator duo
156 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
157 GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
158 const char *service_name,
159 const char *binary_name,
160 const char *cfg_filename,
161 GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback
162 communicator_available_cb,
163 GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb,
164 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
165 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
166 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb,
171 * @brief Instruct communicator to open a queue
173 * @param tc_h Handle to communicator which shall open queue
174 * @param peer_id Towards which peer
175 * @param address For which address
178 GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (struct
179 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
184 const char *address);
188 * @brief Instruct communicator to send data
190 * @param tc_queue The queue to use for sending
191 * @param payload Data to send
192 * @param payload_size Size of the payload
194 * @return Handle to the transmission
196 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *
197 GNUNET_TRANSPORT_TESTING_transport_communicator_send (struct
198 GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
201 size_t payload_size /*,
202 GNUNET_TRANSPORT_TESTING_SuccessStatus cb,