REST/NAMESTORE: rework API
[oweals/gnunet.git] / src / transport / transport-testing2.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2019 GNUnet e.V.
4
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.
9
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.
14
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/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21 /**
22  * @file transport/transport-testing2.h
23  * @brief functions related to testing-tng
24  * @author Christian Grothoff
25  * @author Julius Bünger
26  */
27 #include "platform.h"
28 #include "gnunet_util_lib.h"
29 #include "gnunet_ats_transport_service.h"
30 #include "transport.h"
31
32
33 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle;
34
35 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue;
36
37 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission;
38
39 /**
40  * @brief Function signature for callbacks that are called when new communicators become available
41  *
42  * @param Closure
43  * @param msg Message
44  */
45 typedef void
46 (*GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback)(void *cls,
47       struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
48       enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc,
49       char *address_prefix);
50
51
52 typedef void
53 (*GNUNET_TRANSPORT_TESTING_AddAddressCallback)(void *cls,
54       struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
55       const char *address,
56       struct GNUNET_TIME_Relative expiration,
57       uint32_t aid,
58       enum GNUNET_NetworkType nt);
59
60
61 typedef void
62 (*GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback)(void *cls,
63     struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
64     int will_try);
65
66
67 typedef void
68 (*GNUNET_TRANSPORT_TESTING_AddQueueCallback)(void *cls,
69     struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
70     struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue);
71
72
73 /**
74  * @brief Start communicator part of transport service and communicator
75  *
76  * @param service_name Name of the service
77  * @param cfg Configuration handle
78  * @param communicator_available Callback that is called when a new
79  * communicator becomes available
80  * @param cb_cls Closure to @p communicator_available
81  *
82  * @return Handle to the communicator duo
83  */
84 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
85 GNUNET_TRANSPORT_TESTING_transport_communicator_service_start
86   (const char *service_name,
87    const char *cfg_filename,
88    GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb,
89    GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb,
90    GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
91    GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
92    void *cb_cls);
93
94 void
95 GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue
96   (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
97    const struct GNUNET_PeerIdentity *peer_id,
98    const char *address);
99
100 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *
101 GNUNET_TRANSPORT_TESTING_transport_communicator_send
102   (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue,
103    const void *payload,
104    size_t payload_size/*,
105    GNUNET_TRANSPORT_TESTING_SuccessStatus cb,
106    void *cb_cls*/);
107