GNUnet  0.11.x
Data Structures | Functions
testing_api_cmd_send_peer_ready.c File Reference

cmd to send a helper message if peer is ready. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "testing_cmds.h"
Include dependency graph for testing_api_cmd_send_peer_ready.c:

Go to the source code of this file.

Data Structures

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

Functions

static enum GNUNET_GenericReturnValue send_peer_ready_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 Trait function of this cmd does nothing. More...
 
static void send_peer_ready_cleanup (void *cls)
 The cleanup function of this cmd frees resources the cmd allocated. More...
 
static void send_peer_ready_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED message to the master loop. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_send_peer_ready (const char *label, TESTING_CMD_HELPER_write_cb write_message)
 Create command. More...
 

Detailed Description

cmd to send a helper message if peer is ready.

Author
t3sserakt

Definition in file testing_api_cmd_send_peer_ready.c.

Function Documentation

◆ send_peer_ready_traits()

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

Trait function of this cmd does nothing.

Definition at line 1 of file testing_api_cmd_send_peer_ready.c.

61 {
62  return GNUNET_NO;
63 }
@ GNUNET_NO
Definition: gnunet_common.h:94

◆ send_peer_ready_cleanup()

static void send_peer_ready_cleanup ( void *  cls)
static

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

Definition at line 71 of file testing_api_cmd_send_peer_ready.c.

72 {
73  struct SendPeerReadyState *sprs = cls;
74 
75  GNUNET_free (sprs->reply);
76  GNUNET_free (sprs);
77 }
#define GNUNET_free(ptr)
Wrapper around free.
Struct to hold information for callbacks.
struct GNUNET_CMDS_PEER_STARTED * reply
The message send back to the master loop.

References GNUNET_free, and SendPeerReadyState::reply.

◆ send_peer_ready_run()

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

This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED message to the master loop.

Definition at line 85 of file testing_api_cmd_send_peer_ready.c.

87 {
88  struct SendPeerReadyState *sprs = cls;
89  struct GNUNET_CMDS_PEER_STARTED *reply;
90  size_t msg_length;
91 
92  msg_length = sizeof(struct GNUNET_CMDS_PEER_STARTED);
93  reply = GNUNET_new (struct GNUNET_CMDS_PEER_STARTED);
95  reply->header.size = htons ((uint16_t) msg_length);
96  sprs->reply = reply;
97  sprs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
98 }
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED.
Definition: testing_cmds.h:69
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
TESTING_CMD_HELPER_write_cb write_message
Callback to write messages to the master loop.

References GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED, GNUNET_new, GNUNET_CMDS_PEER_STARTED::header, SendPeerReadyState::reply, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and SendPeerReadyState::write_message.

◆ GNUNET_TESTING_cmd_send_peer_ready()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_send_peer_ready ( const char *  label,
TESTING_CMD_HELPER_write_cb  write_message 
)

Create command.

Parameters
labelname for command.
write_messageCallback to write messages to the master loop.
Returns
command.

Definition at line 85 of file testing_api_cmd_send_peer_ready.c.

111 {
112  struct SendPeerReadyState *sprs;
113 
114  sprs = GNUNET_new (struct SendPeerReadyState);
116  {
117  struct GNUNET_TESTING_Command cmd = {
118  .cls = sprs,
119  .label = label,
120  .run = &send_peer_ready_run,
121  .cleanup = &send_peer_ready_cleanup,
122  .traits = &send_peer_ready_traits
123  };
124 
125  return cmd;
126  }
127 }
static int write_message(uint16_t message_type, const char *data, size_t data_length)
Write message to the master process.
A command to be run by the interpreter.
const char * label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
static void send_peer_ready_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED message to the master loop.
static void send_peer_ready_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
static enum GNUNET_GenericReturnValue send_peer_ready_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.