GNUnet  0.19.3
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_ng_lib.h"
30 #include "gnunet_testing_plugin.h"
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 
122  char *cfgname;
123 
128 
133 
137  struct GNUNET_PeerIdentity id;
138 
143 
148 
153 
158 
163 
167  char *hello;
168 
172  size_t hello_size;
173 
178 
182  unsigned int no;
183 
189 
194 
199 
204 };
205 
206 struct TestState
207 {
213 
218 
223  char *testdir;
224 
229  char *cfgname;
230 
235 };
236 
237 
253  const char *system_label,
254  uint32_t no,
255  const char *node_ip,
257  const char *cfgname,
260  unsigned int broadcast);
261 
262 
265  const char *start_label);
266 
267 
281  const char *label,
282  const char *start_peer_label,
283  const char *create_label,
284  uint32_t num,
286  unsigned int additional_connects);
287 
288 
301  const char *start_peer_label,
302  const char *create_label,
303  uint32_t num,
305  topology);
306 
307 
322  const char *start_peer_label,
323  const char *create_label,
324  uint32_t num,
325  unsigned int node_n,
326  unsigned int namespace_n,
328  topology);
329 
330 
335 #define GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT(name,type) \
336  enum GNUNET_GenericReturnValue \
337  GNUNET_TRANSPORT_get_trait_ ## name ( \
338  const struct GNUNET_TESTING_Command *cmd, \
339  type **ret); \
340  struct GNUNET_TESTING_Trait \
341  GNUNET_TRANSPORT_make_trait_ ## name ( \
342  type * value);
343 
344 
349 #define GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT(name,type) \
350  enum GNUNET_GenericReturnValue \
351  GNUNET_TRANSPORT_get_trait_ ## name ( \
352  const struct GNUNET_TESTING_Command *cmd, \
353  type **ret) \
354  { \
355  if (NULL == cmd->traits) return GNUNET_SYSERR; \
356  return cmd->traits (cmd->cls, \
357  (const void **) ret, \
358  GNUNET_S (name), \
359  0); \
360  } \
361  struct GNUNET_TESTING_Trait \
362  GNUNET_TRANSPORT_make_trait_ ## name ( \
363  type * value) \
364  { \
365  struct GNUNET_TESTING_Trait ret = { \
366  .trait_name = GNUNET_S (name), \
367  .ptr = (const void *) value \
368  }; \
369  return ret; \
370  }
371 
372 
376 #define GNUNET_TRANSPORT_SIMPLE_TRAITS(op) \
377  op (peer_id, const struct GNUNET_PeerIdentity) \
378  op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
379  op (hello_size, const size_t) \
380  op (hello, const char) \
381  op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
382  op (connect_peer_state, const struct ConnectPeersState) \
383  op (state, const struct StartPeerState) \
384  op (broadcast, const enum GNUNET_GenericReturnValue)
385 
387 
388 
389 #endif
390 /* end of transport_testing.h */
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_TESTING_Interpreter * is
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.
void(* GNUNET_TESTING_cmd_helper_finish_cb)()
Callback function which writes a message from the helper process running on a netjail node to the mas...
void(* GNUNET_TESTING_cmd_helper_write_cb)(struct GNUNET_MessageHeader *message, size_t msg_length)
Callback function to write messages from the helper process running on a netjail node to the master p...
GNUNET_GenericReturnValue
Named constants for return values.
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:136
State each asynchronous command must have in its closure.
A command to be run by the interpreter.
char label[127+1]
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:195
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testing.c:122
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
A map with struct GNUNET_MQ_Handle values for each peer this peer is connected to.
struct GNUNET_TESTING_Peer * peer
struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
GNUNET_TRANSPORT_notify_connect_cb notify_connect
Callback which is called on neighbour connect events.
char * system_label
The label of the command which was started by calling GNUNET_TESTING_cmd_system_create.
size_t hello_size
Hello size.
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
char * cfgname
GNUnet configuration file used to start a peer.
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
const struct GNUNET_TESTING_System * tl_system
Test setup for this peer.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
char * cfgname
The name for the configuration file of the specific node.
GNUNET_TESTING_cmd_helper_write_cb write_message
Callback to write messages to the master loop.
GNUNET_TESTING_cmd_helper_finish_cb finished_cb
Callback to notify the helper test case has finished.
char * testdir
The name for a specific test environment directory.
struct GNUNET_TESTING_NetjailTopology * topology
The complete topology information.
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_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_start_peer(const char *label, const char *system_label, uint32_t no, const 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_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.