diff options
Diffstat (limited to 'src/testbed/testbed_api_cmd_send_peer_ready.c')
-rw-r--r-- | src/testbed/testbed_api_cmd_send_peer_ready.c | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/src/testbed/testbed_api_cmd_send_peer_ready.c b/src/testbed/testbed_api_cmd_send_peer_ready.c new file mode 100644 index 000000000..8a82b23a8 --- /dev/null +++ b/src/testbed/testbed_api_cmd_send_peer_ready.c | |||
@@ -0,0 +1,102 @@ | |||
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 | |||
30 | |||
31 | struct SendPeerReadyState | ||
32 | { | ||
33 | TESTBED_CMD_HELPER_write_cb write_message; | ||
34 | |||
35 | struct GNUNET_CMDS_PEER_STARTED *reply; | ||
36 | }; | ||
37 | |||
38 | |||
39 | static int | ||
40 | send_peer_ready_traits (void *cls, | ||
41 | const void **ret, | ||
42 | const char *trait, | ||
43 | unsigned int index) | ||
44 | { | ||
45 | return GNUNET_OK; | ||
46 | } | ||
47 | |||
48 | |||
49 | static void | ||
50 | send_peer_ready_cleanup (void *cls, | ||
51 | const struct GNUNET_TESTING_Command *cmd) | ||
52 | { | ||
53 | struct SendPeerReadyState *sprs = cls; | ||
54 | |||
55 | GNUNET_free (sprs->reply); | ||
56 | GNUNET_free (sprs); | ||
57 | } | ||
58 | |||
59 | |||
60 | static void | ||
61 | send_peer_ready_run (void *cls, | ||
62 | const struct GNUNET_TESTING_Command *cmd, | ||
63 | struct GNUNET_TESTING_Interpreter *is) | ||
64 | { | ||
65 | /*struct SendPeerReadyState *sprs = cls; | ||
66 | struct GNUNET_CMDS_PEER_STARTED *reply; | ||
67 | size_t msg_length; | ||
68 | |||
69 | msg_length = sizeof(struct GNUNET_CMDS_PEER_STARTED); | ||
70 | reply = GNUNET_new (struct GNUNET_CMDS_PEER_STARTED); | ||
71 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED); | ||
72 | reply->header.size = htons ((uint16_t) msg_length); | ||
73 | sprs->reply = reply; | ||
74 | sprs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);*/ | ||
75 | } | ||
76 | |||
77 | |||
78 | /** | ||
79 | * Create command. | ||
80 | * | ||
81 | * @param label name for command. | ||
82 | * @return command. | ||
83 | */ | ||
84 | struct GNUNET_TESTING_Command | ||
85 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | ||
86 | TESTBED_CMD_HELPER_write_cb write_message) | ||
87 | { | ||
88 | struct SendPeerReadyState *sprs; | ||
89 | |||
90 | sprs = GNUNET_new (struct SendPeerReadyState); | ||
91 | sprs->write_message = write_message; | ||
92 | |||
93 | struct GNUNET_TESTING_Command cmd = { | ||
94 | .cls = sprs, | ||
95 | .label = label, | ||
96 | .run = &send_peer_ready_run, | ||
97 | .cleanup = &send_peer_ready_cleanup, | ||
98 | .traits = &send_peer_ready_traits | ||
99 | }; | ||
100 | |||
101 | return cmd; | ||
102 | } | ||