aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_cmd_send_peer_ready.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api_cmd_send_peer_ready.c')
-rw-r--r--src/testbed/testbed_api_cmd_send_peer_ready.c103
1 files changed, 0 insertions, 103 deletions
diff --git a/src/testbed/testbed_api_cmd_send_peer_ready.c b/src/testbed/testbed_api_cmd_send_peer_ready.c
deleted file mode 100644
index 987f0853e..000000000
--- a/src/testbed/testbed_api_cmd_send_peer_ready.c
+++ /dev/null
@@ -1,103 +0,0 @@
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
21/**
22 * @file testing_api_cmd_send_peer_ready.c
23 * @brief cmd to send a helper message if peer is ready.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29#include "testbed_helper.h"
30
31
32struct SendPeerReadyState
33{
34 TESTING_CMD_HELPER_write_cb write_message;
35
36 struct GNUNET_CMDS_PEER_STARTED *reply;
37};
38
39
40static int
41send_peer_ready_traits (void *cls,
42 const void **ret,
43 const char *trait,
44 unsigned int index)
45{
46 return GNUNET_OK;
47}
48
49
50static void
51send_peer_ready_cleanup (void *cls,
52 const struct GNUNET_TESTING_Command *cmd)
53{
54 struct SendPeerReadyState *sprs = cls;
55
56 GNUNET_free (sprs->reply);
57 GNUNET_free (sprs);
58}
59
60
61static void
62send_peer_ready_run (void *cls,
63 const struct GNUNET_TESTING_Command *cmd,
64 struct GNUNET_TESTING_Interpreter *is)
65{
66 struct SendPeerReadyState *sprs = cls;
67 struct GNUNET_CMDS_PEER_STARTED *reply;
68 size_t msg_length;
69
70 msg_length = sizeof(struct GNUNET_CMDS_PEER_STARTED);
71 reply = GNUNET_new (struct GNUNET_CMDS_PEER_STARTED);
72 reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED);
73 reply->header.size = htons ((uint16_t) msg_length);
74 sprs->reply = reply;
75 sprs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
76}
77
78
79/**
80 * Create command.
81 *
82 * @param label name for command.
83 * @return command.
84 */
85struct GNUNET_TESTING_Command
86GNUNET_TESTING_cmd_send_peer_ready (const char *label,
87 TESTING_CMD_HELPER_write_cb write_message)
88{
89 struct SendPeerReadyState *sprs;
90
91 sprs = GNUNET_new (struct SendPeerReadyState);
92 sprs->write_message = write_message;
93
94 struct GNUNET_TESTING_Command cmd = {
95 .cls = sprs,
96 .label = label,
97 .run = &send_peer_ready_run,
98 .cleanup = &send_peer_ready_cleanup,
99 .traits = &send_peer_ready_traits
100 };
101
102 return cmd;
103}