GNUnet 0.21.2
transport_api_cmd_send_simple.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_netjail_lib.h"
#include "transport-testing2.h"
#include "transport-testing-cmds.h"
Include dependency graph for transport_api_cmd_send_simple.c:

Go to the source code of this file.

Data Structures

struct  SendSimpleState
 Struct to hold information for callbacks. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log (kind, __VA_ARGS__)
 Generic logging shortcut. More...
 

Functions

static void send_simple_cleanup (void *cls)
 The cleanup function of this cmd frees resources the cmd allocated. More...
 
static int send_simple_cb (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
 
static void send_simple_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 The run method of this cmd will send a simple message to the connected peers. More...
 
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. More...
 

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log (kind, __VA_ARGS__)

Generic logging shortcut.

Definition at line 36 of file transport_api_cmd_send_simple.c.

Function Documentation

◆ send_simple_cleanup()

static void send_simple_cleanup ( void *  cls)
static

The cleanup function of this cmd frees resources the cmd allocated.

Definition at line 74 of file transport_api_cmd_send_simple.c.

75{
76 struct SendSimpleState *sss = cls;
77
78 GNUNET_free (sss);
79}
#define GNUNET_free(ptr)
Wrapper around free.
Struct to hold information for callbacks.

References GNUNET_free.

Referenced by GNUNET_TRANSPORT_cmd_send_simple().

Here is the caller graph for this function:

◆ send_simple_cb()

static int send_simple_cb ( void *  cls,
const struct GNUNET_ShortHashCode key,
void *  value 
)
static

Definition at line 83 of file transport_api_cmd_send_simple.c.

86{
87 struct SendSimpleState *sss = cls;
88 struct GNUNET_MQ_Handle *mq = value;
89 struct GNUNET_MQ_Envelope *env;
91
93 "Sending simple test message with mq %p\n",
94 mq);
95
97 1000 - sizeof(*test),
99 test->num = htonl (sss->num);
100 memset (&test[1],
101 sss->num,
102 1000 - sizeof(*test));
104 env);
105 return GNUNET_OK;
106}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static char * value
Value of the record to add/remove.
@ GNUNET_OK
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
Handle to a message queue.
Definition: mq.c:87
uint32_t num
Monotonically increasing counter throughout the test.
uint32_t num
Number globally identifying the node.
#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
Message type used by GNUNET_TRANSPORT_TESTING_simple_send().
#define LOG(kind,...)
Generic logging shortcut.

References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_OK, GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, LOG, mq, GNUNET_TRANSPORT_TESTING_TestMessage::num, SendSimpleState::num, and value.

Referenced by send_simple_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_simple_run()

static void send_simple_run ( void *  cls,
struct GNUNET_TESTING_Interpreter is 
)
static

The run method of this cmd will send a simple message to the connected peers.

Definition at line 114 of file transport_api_cmd_send_simple.c.

116{
117 struct SendSimpleState *sss = cls;
118 const struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
119 const struct GNUNET_TESTING_Command *peer1_cmd;
120 const struct GNUNET_TESTING_Command *system_cmd;
121 const struct GNUNET_TESTBED_System *tl_system;
122
124 sss->start_peer_label);
126 &connected_peers_map);
127
129 sss->create_label);
130 GNUNET_TESTING_get_trait_test_system (system_cmd,
131 &tl_system);
132
135 connected_peers_map, send_simple_cb,
136 sss);
137}
static struct GNUNET_TESTING_Interpreter * is
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_TESTING_get_trait_connected_peers_map(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_CONTAINER_MultiShortmap **ret)
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
Internal representation of the hash map.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testbed.c:54
A command to be run by the interpreter.
const char * create_label
Label of the cmd which started the test system.
const char * start_peer_label
Label of the cmd to start a peer.
static int send_simple_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)

References SendSimpleState::create_label, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TRANSPORT_TESTING_get_trait_connected_peers_map(), is, send_simple_cb(), and SendSimpleState::start_peer_label.

Referenced by GNUNET_TRANSPORT_cmd_send_simple().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_cmd_send_simple()

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.

Parameters
labelname for command.
start_peer_labelLabel of the cmd to start a peer.
create_labelLabel of the cmd which started the test system.
numNumber globally identifying the node.
topologyThe topology for the test setup.
Returns
command.

Definition at line 141 of file transport_api_cmd_send_simple.c.

147{
148 struct SendSimpleState *sss;
149
150 sss = GNUNET_new (struct SendSimpleState);
151 sss->num = num;
154 sss->topology = topology;
155
156 return GNUNET_TESTING_command_new (sss,
157 label,
160 NULL);
161}
#define GNUNET_TESTING_command_new(cls, label, run, cleanup, traits)
Create a new command.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TESTING_NetjailTopology * topology
The topology we get the connected nodes from.
static void send_simple_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will send a simple message to the connected peers.
static void send_simple_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.

References SendSimpleState::create_label, GNUNET_new, GNUNET_TESTING_command_new, SendSimpleState::num, send_simple_cleanup(), send_simple_run(), SendSimpleState::start_peer_label, and SendSimpleState::topology.

Here is the call graph for this function: