GNUnet  0.11.x
transport-testing-cmds.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2021 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 
27 #ifndef TRANSPORT_TESTING_CMDS_H
28 #define TRANSPORT_TESTING_CMDS_H
29 #include "gnunet_testing_lib.h"
30 
31 
32 typedef void *
33 (*GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
34  const struct GNUNET_PeerIdentity *peer);
35 
41 {
46 
48 
53 
54  // Label of the cmd which started the test system.
55  const char *create_label;
56 
61  uint32_t num;
62 
67  const char *start_peer_label;
68 
73 
78 
80 
84  unsigned int con_num;
85 
89  unsigned int additional_connects;
90 
94  unsigned int con_num_notified;
95 
100 };
101 
103 {
108 
112  char *node_ip;
113 
118 
119  const char *cfgname;
120 
125 
127 
131  struct GNUNET_PeerIdentity id;
132 
137 
142 
147 
152 
157 
161  char *hello;
162 
166  size_t hello_size;
167 
168  char *m;
169 
170  char *n;
171 
172  char *local_m;
173 
174  const char *system_label;
175 
179  unsigned int no;
180 
182 
184 
186 
191 };
192 
193 
210  const char *system_label,
211  uint32_t no,
212  char *node_ip,
214  const char *cfgname,
217  unsigned int broadcast);
218 
219 
222  const char *start_label);
223 
224 
238  const char *label,
239  const char *start_peer_label,
240  const char *create_label,
241  uint32_t num,
243  unsigned int additional_connects);
244 
245 
258  const char *start_peer_label,
259  const char *create_label,
260  uint32_t num,
262  topology);
263 
264 
279  const char *start_peer_label,
280  const char *create_label,
281  uint32_t num,
282  unsigned int node_n,
283  unsigned int namespace_n,
285  topology);
286 
287 
292 #define GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT(name,type) \
293  enum GNUNET_GenericReturnValue \
294  GNUNET_TRANSPORT_get_trait_ ## name ( \
295  const struct GNUNET_TESTING_Command *cmd, \
296  type **ret); \
297  struct GNUNET_TESTING_Trait \
298  GNUNET_TRANSPORT_make_trait_ ## name ( \
299  type * value);
300 
301 
306 #define GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT(name,type) \
307  enum GNUNET_GenericReturnValue \
308  GNUNET_TRANSPORT_get_trait_ ## name ( \
309  const struct GNUNET_TESTING_Command *cmd, \
310  type **ret) \
311  { \
312  if (NULL == cmd->traits) return GNUNET_SYSERR; \
313  return cmd->traits (cmd->cls, \
314  (const void **) ret, \
315  GNUNET_S (name), \
316  0); \
317  } \
318  struct GNUNET_TESTING_Trait \
319  GNUNET_TRANSPORT_make_trait_ ## name ( \
320  type * value) \
321  { \
322  struct GNUNET_TESTING_Trait ret = { \
323  .trait_name = GNUNET_S (name), \
324  .ptr = (const void *) value \
325  }; \
326  return ret; \
327  }
328 
329 
333 #define GNUNET_TRANSPORT_SIMPLE_TRAITS(op) \
334  op (peer_id, const struct GNUNET_PeerIdentity) \
335  op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
336  op (hello_size, const size_t) \
337  op (hello, const char) \
338  op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
339  op (connect_peer_state, const struct ConnectPeersState) \
340  op (state, const struct StartPeerState) \
341  op (broadcast, const enum GNUNET_GenericReturnValue)
342 
344 
345 
346 #endif
347 /* end of transport_testing.h */
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *m)
Function called to notify transport users that another peer connected to us.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
Struct to store information needed in callbacks.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
unsigned int con_num
Number of connections.
uint32_t num
Number globally identifying the node.
unsigned int additional_connects_notified
Number of additional connects this cmd will wait for not triggered by this cmd we already have a noti...
struct GNUNET_TESTING_Interpreter * is
struct GNUNET_TESTING_NodeConnection * node_connections_head
Connections to other peers.
struct GNUNET_TESTING_NetjailTopology * topology
The topology of the test setup.
const struct GNUNET_TESTING_System * tl_system
The testing system of this node.
unsigned int con_num_notified
Number of connections we already have a notification for.
GNUNET_TRANSPORT_notify_connect_cb notify_connect
const char * start_peer_label
Label of the cmd to start a peer.
unsigned int additional_connects
Number of additional connects this cmd will wait for not triggered by this cmd.
Internal representation of the hash map.
Message handler for a specific message type.
Handle to the PEERSTORE service.
Definition: peerstore_api.c:41
Context for a iterate request.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition: scheduler.c:135
State each asynchronous command must have in its closure.
A command to be run by the interpreter.
const char * label
Label for the command.
Global state of the interpreter, used by a command to access information about other commands.
unsigned int additional_connects
Additional connects we do expect, beside the connects which are configured in the topology.
Handle for a GNUnet peer controlled by testing.
Definition: testing.c:176
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testing.c:103
Handle to the TRANSPORT subsystem for application management.
Handle for the transport service (includes all of the state for the transport service).
unsigned int no
An unique number to identify the peer.
struct GNUNET_PeerIdentity id
Peer identity.
char * node_ip
The ip of a node.
enum GNUNET_GenericReturnValue broadcast
Flag indicating, if udp broadcast should be switched on.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer's configuration.
struct GNUNET_PEERSTORE_Handle * ph
Peer's PEERSTORE Handle.
struct GNUNET_SCHEDULER_Task * rh_task
Hello get task.
struct GNUNET_PEERSTORE_IterateContext * pic
Peer's transport get hello handle to retrieve peer's HELLO message.
struct GNUNET_CONTAINER_MultiShortmap * connected_peers_map
struct GNUNET_TESTING_Peer * peer
GNUNET_TRANSPORT_notify_connect_cb notify_connect
size_t hello_size
Hello size.
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
const struct GNUNET_TESTING_System * tl_system
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
void *(* GNUNET_TRANSPORT_notify_connect_cb)(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_PeerIdentity *peer)
#define GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT(name, type)
Create headers for a trait with name name for statically allocated data of type type.
#define GNUNET_TRANSPORT_SIMPLE_TRAITS(op)
Call op on all simple traits.
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_stop_peer(const char *label, const char *start_label)
Create command.
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_backchannel_check(const char *label, const char *start_peer_label, const char *create_label, uint32_t num, unsigned int node_n, unsigned int namespace_n, struct GNUNET_TESTING_NetjailTopology *topology)
Create command.
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_start_peer(const char *label, const char *system_label, uint32_t no, char *node_ip, struct GNUNET_MQ_MessageHandler *handlers, const char *cfgname, GNUNET_TRANSPORT_notify_connect_cb notify_connect, unsigned int broadcast)
Create command.
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_send_simple(const char *label, const char *start_peer_label, const char *create_label, uint32_t num, struct GNUNET_TESTING_NetjailTopology *topology)
Create command.
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_connect_peers(const char *label, const char *start_peer_label, const char *create_label, uint32_t num, struct GNUNET_TESTING_NetjailTopology *topology, unsigned int additional_connects)
Create command.