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;
51 * @brief Function signature for callbacks that are called when new
52 * backchannel message arrived
55 * @param msg Backchannel message
56 * @param pid Target peer
58 typedef struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
59 (*GNUNET_TRANSPORT_TESTING_BackchannelCallback)(void *cls,
60 struct GNUNET_MessageHeader *msg,
61 struct GNUNET_PeerIdentity *pid);
65 * @brief Function signature for callbacks that are called when new
66 * communicators become available
69 * @param tc_h Communicator handle
70 * @param cc Characteristics of communicator
71 * @param address_prefix Prefix of the address
74 (*GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback)(void *cls,
76 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
79 GNUNET_TRANSPORT_CommunicatorCharacteristics
81 char *address_prefix);
85 * @brief Receive information about the address of a communicator.
88 * @param tc_h Communicator handle
89 * @param address Address represented as string
90 * @param expiration Expiration
92 * @param nt Network Type
95 (*GNUNET_TRANSPORT_TESTING_AddAddressCallback)(void *cls,
97 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
100 struct GNUNET_TIME_Relative
103 enum GNUNET_NetworkType nt);
107 * @brief Get informed about the success of a queue request.
110 * @param tc_h Communicator handle
111 * @param will_try #GNUNET_YES if communicator will try to create queue
114 (*GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback)(void *cls,
116 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
122 * @brief Handle opening of queue
125 * @param tc_h Communicator handle
126 * @param tc_queue Handle to newly opened queue
129 (*GNUNET_TRANSPORT_TESTING_AddQueueCallback)(void *cls,
131 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
134 GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
139 * @brief Handle an incoming message
142 * @param tc_h Handle to the receiving communicator
143 * @param msg Received message
146 (*GNUNET_TRANSPORT_TESTING_IncomingMessageCallback)(void *cls,
148 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
155 * @brief Start communicator part of transport service and communicator
157 * @param service_name Name of the service
158 * @param cfg Configuration handle
159 * @param communicator_available Callback that is called when a new
160 * communicator becomes available
161 * @param add_address_cb Callback handling new addresses
162 * @param queue_create_reply_cb Callback handling success of queue requests
163 * @param add_queue_cb Callback handling freshly created queues
164 * @param incoming_message_cb Callback handling incoming messages
165 * @param cb_cls Closure to @p communicator_available
167 * @return Handle to the communicator duo
169 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
170 GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
171 const char *service_name,
172 const char *binary_name,
173 const char *cfg_filename,
174 GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback
175 communicator_available_cb,
176 GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb,
177 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
178 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
179 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb,
180 GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb,
185 * @brief Instruct communicator to open a queue
187 * @param tc_h Handle to communicator which shall open queue
188 * @param peer_id Towards which peer
189 * @param address For which address
192 GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (struct
193 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
198 const char *address);
202 * @brief Instruct communicator to send data
204 * @param tc_queue The queue to use for sending
205 * @param payload Data to send
206 * @param payload_size Size of the payload
208 * @return Handle to the transmission
210 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *
211 GNUNET_TRANSPORT_TESTING_transport_communicator_send (struct
212 GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
215 size_t payload_size);