GNUnet  0.11.x
Data Structures | Macros | Functions
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...


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


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


#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)

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;
78  GNUNET_free (sss);
79 }
#define GNUNET_free(ptr)
Wrapper around free.
Struct to hold information for callbacks.

References GNUNET_free.

◆ send_simple_cb()

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

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;
93  "Sending simple test message\n");
95  env = GNUNET_MQ_msg_extra (test,
96  1000 - sizeof(*test),
98  test->num = htonl (sss->num);
99  memset (&test[1],
100  sss->num,
101  1000 - sizeof(*test));
103  env);
104  return GNUNET_OK;
105 }
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.
Definition: gnunet_common.h:95
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:355
#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:52
Handle to a message queue.
Definition: mq.c:86
uint32_t num
Monotonically increasing counter throughout the test.
uint32_t num
Number globally identifying the node.
Message type used by GNUNET_TRANSPORT_TESTING_simple_send().
#define LOG(kind,...)
Generic logging shortcut.


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 

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

Definition at line 113 of file transport_api_cmd_send_simple.c.

115 {
116  struct SendSimpleState *sss = cls;
117  const struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
118  const struct GNUNET_TESTING_Command *peer1_cmd;
119  // struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
120  struct GNUNET_HashCode hc;
121  struct GNUNET_TESTING_NodeConnection *node_connections_head;
122  struct GNUNET_PeerIdentity *peer;
123  struct GNUNET_CRYPTO_EddsaPublicKey public_key;
124  uint32_t num;
125  struct GNUNET_TESTING_NodeConnection *pos_connection;
126  const struct GNUNET_TESTING_Command *system_cmd;
127  const struct GNUNET_TESTING_System *tl_system;
130  sss->start_peer_label);
132  &connected_peers_map);
135  sss->create_label);
137  &tl_system);
139  node_connections_head = GNUNET_TESTING_get_connections (sss->num,
140  sss->topology);
144  connected_peers_map, send_simple_cb,
145  sss);
146  /*for (int i = 0; i < 1; i++)
147  {
148  for (pos_connection = node_connections_head; NULL != pos_connection;
149  pos_connection = pos_connection->next)
150  {
151  num = GNUNET_TESTING_calculate_num (pos_connection, sss->topology);
152  peer = GNUNET_TESTING_get_pub_key (num, tl_system);
153  public_key = peer->public_key;
154  GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc);
156  memcpy (key,
157  &hc,
158  sizeof (*key));
159  mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
160  key);
161  env = GNUNET_MQ_msg_extra (test,
162  1000 - sizeof(*test),
164  test->num = htonl (sss->num);
165  memset (&test[1],
166  sss->num,
167  1000 - sizeof(*test));
168  GNUNET_MQ_send (mq,
169  env);
170  }
171  }*/
173  // GNUNET_free (key);
175 }
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.
struct GNUNET_TESTING_NodeConnection * GNUNET_TESTING_get_connections(unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology)
Get the connections to other nodes for a specific node.
Definition: testing.c:2097
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_test_system(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_System **ret)
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
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.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
A 512-bit hashcode.
The identity of the host (wraps the signing key of the peer).
A command to be run by the interpreter.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testing.c:103
const char * create_label
Label of the cmd which started the test system.
struct GNUNET_TESTING_NetjailTopology * topology
The topology we get the connected nodes from.
const char * start_peer_label
Label of the cmd to start a peer.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_connected_peers_map(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_CONTAINER_MultiShortmap **ret)
static int send_simple_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)

References SendSimpleState::create_label, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_TESTING_get_connections(), GNUNET_TESTING_get_trait_test_system(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TRANSPORT_get_trait_connected_peers_map(), is, SendSimpleState::num, peer, send_simple_cb(), SendSimpleState::start_peer_label, and SendSimpleState::topology.

Here is the call 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.

labelname for command.
start_peer_labelLabel of the cmd to start a peer.
start_peer_labelLabel of the cmd which started the test system.
numNumber globally identifying the node.
Thetopology for the test setup.

Definition at line 113 of file transport_api_cmd_send_simple.c.

195 {
196  struct SendSimpleState *sss;
198  sss = GNUNET_new (struct SendSimpleState);
199  sss->num = num;
201  sss->create_label = create_label;
202  sss->topology = topology;
204  struct GNUNET_TESTING_Command cmd = {
205  .cls = sss,
206  .label = label,
207  .run = &send_simple_run,
208  .cleanup = &send_simple_cleanup
209  };
211  return cmd;
212 }
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
const char * label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
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.