aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_barrier.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_barrier.c')
-rw-r--r--src/testing/testing_api_cmd_barrier.c58
1 files changed, 4 insertions, 54 deletions
diff --git a/src/testing/testing_api_cmd_barrier.c b/src/testing/testing_api_cmd_barrier.c
index 7e4e67dea..bc4f79eb6 100644
--- a/src/testing/testing_api_cmd_barrier.c
+++ b/src/testing/testing_api_cmd_barrier.c
@@ -43,16 +43,7 @@ struct BarrierState
43 const char *label; 43 const char *label;
44}; 44};
45 45
46 46// FIXME Unused function
47/**
48 * Send Message to master loop that cmds being attached to a barrier.
49 *
50 * @param is The interpreter loop.
51 * @param barrier_name The name of the barrier to advance.
52 * @param subnet_number The number of the subnet.
53 * @param node_number The node to inform.
54 * @param write_message Callback to write messages to the master loop.
55 */
56void 47void
57GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is, 48GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is,
58 char *barrier_name, 49 char *barrier_name,
@@ -78,40 +69,6 @@ GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is,
78} 69}
79 70
80 71
81/**
82 * Send Message to netjail nodes that a barrier can be advanced.
83 *
84 * @param is The interpreter loop.
85 * @param barrier_name The name of the barrier to advance.
86 * @param global_node_number The global number of the node to inform.
87 */
88void
89GNUNET_TESTING_send_barrier_advance (struct GNUNET_TESTING_Interpreter *is,
90 const char *barrier_name,
91 unsigned int global_node_number)
92{
93 struct CommandBarrierAdvanced *adm = GNUNET_new (struct
94 CommandBarrierAdvanced);
95 size_t msg_length = sizeof(struct CommandBarrierAdvanced);
96 size_t name_len;
97
98 name_len = strlen (barrier_name) + 1;
99 adm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED);
100 adm->header.size = htons ((uint16_t) msg_length);
101 memcpy (&adm[1], barrier_name, name_len);
102 GNUNET_TESTING_send_message_to_netjail (is,
103 global_node_number,
104 &adm->header);
105 GNUNET_free (adm);
106}
107
108
109/**
110 * Can we advance the barrier?
111 *
112 * @param barrier The barrier in question.
113 * @return GNUNET_YES if we can advance the barrier, GNUNET_NO if not.
114 */
115unsigned int 72unsigned int
116GNUNET_TESTING_can_barrier_advance (struct GNUNET_TESTING_Barrier *barrier) 73GNUNET_TESTING_can_barrier_advance (struct GNUNET_TESTING_Barrier *barrier)
117{ 74{
@@ -186,18 +143,11 @@ barrier_run (void *cls,
186{ 143{
187 struct BarrierState *brs = cls; 144 struct BarrierState *brs = cls;
188 145
189 GNUNET_TESTING_interpreter_add_barrier (is, brs->barrier); 146 TST_interpreter_add_barrier (is, brs->barrier);
190} 147}
191 148
192/**
193 * Getting a node from a map by global node number.
194 *
195 * @param nodes The map.
196 * @param node_number The global node number.
197 * @return The node.
198 */
199struct GNUNET_TESTING_NetjailNode * 149struct GNUNET_TESTING_NetjailNode *
200GNUNET_TESTING_barrier_get_node (struct GNUNET_CONTAINER_MultiShortmap *nodes, 150GNUNET_TESTING_barrier_get_node (struct GNUNET_TESTING_Barrier *barrier,
201 unsigned int node_number) 151 unsigned int node_number)
202{ 152{
203 struct GNUNET_HashCode hc; 153 struct GNUNET_HashCode hc;
@@ -207,7 +157,7 @@ GNUNET_TESTING_barrier_get_node (struct GNUNET_CONTAINER_MultiShortmap *nodes,
207 memcpy (&key, 157 memcpy (&key,
208 &hc, 158 &hc,
209 sizeof (key)); 159 sizeof (key));
210 return GNUNET_CONTAINER_multishortmap_get (nodes, &key); 160 return GNUNET_CONTAINER_multishortmap_get (barrier->nodes, &key);
211} 161}
212 162
213 163