GNUnet 0.22.2
testing_messenger_cmd_start_service.c File Reference
Include dependency graph for testing_messenger_cmd_start_service.c:

Go to the source code of this file.

Functions

static void on_message_cb (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Contact *recipient, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags)
 
static void start_service_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 
static void start_service_cleanup (void *cls)
 
static enum GNUNET_GenericReturnValue start_service_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 
struct GNUNET_TESTING_Command GNUNET_MESSENGER_cmd_start_service (const char *label, const char *peer_label, const char *system_label, struct GNUNET_MESSENGER_TestStageTopology *topology, unsigned int peer_index)
 

Function Documentation

◆ on_message_cb()

static void on_message_cb ( void *  cls,
struct GNUNET_MESSENGER_Room room,
const struct GNUNET_MESSENGER_Contact sender,
const struct GNUNET_MESSENGER_Contact recipient,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash,
enum GNUNET_MESSENGER_MessageFlags  flags 
)
static

Definition at line 34 of file testing_messenger_cmd_start_service.c.

41{
42 struct GNUNET_MESSENGER_StartServiceState *sss = cls;
43
46
48 if (! rs)
49 {
51 "Testing library failed to find room state\n");
53 return;
54 }
55
57 return;
58
60 &(message->body.peer.peer)
61 ,
62 NULL,
64 {
66 "Testing library failed to register peer identity as found door\n");
68 return;
69 }
70}
struct GNUNET_HashCode key
The key used in the DHT.
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE
If a value with the given key exists, replace it.
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_ERROR_TYPE_ERROR
const struct GNUNET_HashCode * GNUNET_MESSENGER_room_get_key(const struct GNUNET_MESSENGER_Room *room)
Get the key of a given room.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
A 512-bit hashcode.
struct GNUNET_MESSENGER_MessagePeer peer
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_PeerIdentity peer
The peer identity of the sender opening a room.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_CONTAINER_MultiPeerMap * doors
struct GNUNET_TESTING_Interpreter * is
struct GNUNET_CONTAINER_MultiHashMap * rooms

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_RoomState::doors, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_room_get_key(), GNUNET_OK, GNUNET_TESTING_interpreter_fail(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_StartServiceState::is, key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageBody::peer, and GNUNET_MESSENGER_StartServiceState::rooms.

Referenced by start_service_run().

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

◆ start_service_run()

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

Definition at line 74 of file testing_messenger_cmd_start_service.c.

76{
77 struct GNUNET_MESSENGER_StartServiceState *sss = cls;
78
79 sss->is = is;
80
81 const struct GNUNET_TESTING_Command *peer_cmd;
83 sss->peer_label);
84
85 const struct GNUNET_TESTING_StartPeerState *sps;
87
88 const struct GNUNET_TESTING_Command *system_cmd;
90 sss->system_label);
91
92 const struct GNUNET_TESTING_System *tl_system;
93 GNUNET_TESTING_get_trait_test_system (system_cmd,
94 &tl_system);
95
96 sss->tl_system = tl_system;
97
98 sss->msg = GNUNET_MESSENGER_connect (sps->cfg, NULL, NULL, on_message_cb,
99 sss);
100 if (! sss->msg)
101 {
103 "Testing library failed to connect to messenger service\n");
105 return;
106 }
107
110}
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_state(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_StartPeerState **ret)
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
@ GNUNET_NO
struct GNUNET_MESSENGER_Handle * GNUNET_MESSENGER_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, const struct GNUNET_CRYPTO_PrivateKey *key, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls)
Set up a handle for the messenger related functions and connects to all necessary services.
struct GNUNET_MESSENGER_Handle * msg
struct GNUNET_MESSENGER_TestStageTopology * topology
const struct GNUNET_TESTING_System * tl_system
A command to be run by the interpreter.
Handle for a peer controlled via ARM.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer's configuration.
static void on_message_cb(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Contact *recipient, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags)

References GNUNET_TESTING_StartPeerState::cfg, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MESSENGER_connect(), GNUNET_NO, GNUNET_TESTING_interpreter_fail(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TRANSPORT_TESTING_get_trait_state(), is, GNUNET_MESSENGER_StartServiceState::is, GNUNET_MESSENGER_StartServiceState::msg, on_message_cb(), GNUNET_MESSENGER_StartServiceState::peer_label, GNUNET_MESSENGER_StartServiceState::rooms, GNUNET_MESSENGER_TestStageTopology::stage_amount, GNUNET_MESSENGER_StartServiceState::system_label, GNUNET_MESSENGER_StartServiceState::tl_system, and GNUNET_MESSENGER_StartServiceState::topology.

Referenced by GNUNET_MESSENGER_cmd_start_service().

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

◆ start_service_cleanup()

static void start_service_cleanup ( void *  cls)
static

Definition at line 114 of file testing_messenger_cmd_start_service.c.

115{
116 struct GNUNET_MESSENGER_StartServiceState *sss = cls;
117
119 GNUNET_free (sss->peer_label);
120 GNUNET_free (sss);
121}
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_free, GNUNET_MESSENGER_StartServiceState::peer_label, and GNUNET_MESSENGER_StartServiceState::system_label.

Referenced by GNUNET_MESSENGER_cmd_start_service().

Here is the caller graph for this function:

◆ start_service_traits()

static enum GNUNET_GenericReturnValue start_service_traits ( void *  cls,
const void **  ret,
const char *  trait,
unsigned int  index 
)
static

Definition at line 125 of file testing_messenger_cmd_start_service.c.

129{
130 struct GNUNET_MESSENGER_StartServiceState *sss = cls;
131
132 struct GNUNET_TESTING_Trait traits[] = {
135 };
136
138 ret,
139 trait,
140 index);
141}
static int ret
Final status code.
Definition: gnunet-arm.c:93
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" of traits array.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Obtain value of a trait from a command.
struct GNUNET_TESTING_Trait GNUNET_MESSENGER_make_trait_state(struct GNUNET_MESSENGER_StartServiceState *value)
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
unsigned int index
Index number associated with the trait.
static enum GNUNET_GenericReturnValue traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.

References GNUNET_MESSENGER_make_trait_state(), GNUNET_TESTING_get_trait(), GNUNET_TESTING_trait_end(), GNUNET_TESTING_Trait::index, ret, and traits().

Referenced by GNUNET_MESSENGER_cmd_start_service().

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

◆ GNUNET_MESSENGER_cmd_start_service()

struct GNUNET_TESTING_Command GNUNET_MESSENGER_cmd_start_service ( const char *  label,
const char *  peer_label,
const char *  system_label,
struct GNUNET_MESSENGER_TestStageTopology topology,
unsigned int  peer_index 
)

Definition at line 145 of file testing_messenger_cmd_start_service.c.

151{
153
157 sss->topology = topology;
158
159 sss->is = NULL;
160 sss->tl_system = NULL;
161 sss->msg = NULL;
162 sss->rooms = NULL;
163 sss->peer_index = peer_index;
164 sss->stage_index = 0;
165
166 return GNUNET_TESTING_command_new (sss,
167 label,
171}
#define GNUNET_TESTING_command_new(cls, label, run, cleanup, traits)
Create a new command.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static enum GNUNET_GenericReturnValue start_service_traits(void *cls, const void **ret, const char *trait, unsigned int index)
static void start_service_cleanup(void *cls)
static void start_service_run(void *cls, struct GNUNET_TESTING_Interpreter *is)

References GNUNET_new, GNUNET_strdup, GNUNET_TESTING_command_new, GNUNET_MESSENGER_StartServiceState::is, GNUNET_MESSENGER_StartServiceState::msg, GNUNET_MESSENGER_StartServiceState::peer_index, GNUNET_MESSENGER_StartServiceState::peer_label, GNUNET_MESSENGER_StartServiceState::rooms, GNUNET_MESSENGER_StartServiceState::stage_index, start_service_cleanup(), start_service_run(), start_service_traits(), GNUNET_MESSENGER_StartServiceState::system_label, GNUNET_MESSENGER_StartServiceState::tl_system, and GNUNET_MESSENGER_StartServiceState::topology.

Here is the call graph for this function: