GNUnet  0.11.x
testing_api_cmd_send_peer_ready.c
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 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_testing_ng_lib.h"
29 #include "testbed_api.h"
30 #include "testbed_helper.h"
31 
32 
33 struct SendPeerReadyState
34 {
36 
38 };
39 
40 
41 static int
43  const void **ret,
44  const char *trait,
45  unsigned int index)
46 {
47  return GNUNET_OK;
48 }
49 
50 
51 static void
53  const struct GNUNET_TESTING_Command *cmd)
54 {
55  struct SendPeerReadyState *sprs = cls;
56 
57  GNUNET_free (sprs->reply);
58  GNUNET_free (sprs);
59 }
60 
61 
62 static void
64  const struct GNUNET_TESTING_Command *cmd,
66 {
67  struct SendPeerReadyState *sprs = cls;
69  size_t msg_length;
70 
71  msg_length = sizeof(struct GNUNET_CMDS_HelperInit);// GNUNET_CMDS_PEER_STARTED);
72  reply = GNUNET_new (struct GNUNET_CMDS_PEER_STARTED);
74  reply->header.size = htons ((uint16_t) msg_length);
75  sprs->reply = reply;
76  sprs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
77 }
78 
79 
89 {
90  struct SendPeerReadyState *sprs;
91 
92  sprs = GNUNET_new (struct SendPeerReadyState);
94 
95  struct GNUNET_TESTING_Command cmd = {
96  .cls = sprs,
97  .label = label,
98  .run = &send_peer_ready_run,
99  .cleanup = &send_peer_ready_cleanup,
100  .traits = &send_peer_ready_traits
101  };
102 
103  return cmd;
104 }
void(* TESTBED_CMD_HELPER_write_cb)(struct GNUNET_MessageHeader *message, size_t msg_length)
const char * label
Label for the command.
TESTBED_CMD_HELPER_write_cb write_message
A command to be run by the interpreter.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void send_peer_ready_cleanup(void *cls, const struct GNUNET_TESTING_Command *cmd)
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
static int send_peer_ready_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Initialization message for gnunet-cmds-testbed to start cmd binary.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
Global state of the interpreter, used by a command to access information about other commands...
Definition: testing.h:34
static void send_peer_ready_run(void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
struct GNUNET_TESTING_Interpreter * is
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED.
Interface for functions internally exported from testbed_api.c.
void * cls
Closure for all commands with command-specific context information.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_send_peer_ready(const char *label, TESTBED_CMD_HELPER_write_cb write_message)
Create command.
Header for all communications.
Message formats for communication between testbed api and gnunet-helper-testbed process.
struct GNUNET_CMDS_PEER_STARTED * reply
#define GNUNET_free(ptr)
Wrapper around free.