aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport-testing.h')
-rw-r--r--src/transport/transport-testing.h104
1 files changed, 55 insertions, 49 deletions
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h
index 0e84ac236..dcac29185 100644
--- a/src/transport/transport-testing.h
+++ b/src/transport/transport-testing.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2006, 2009 Christian Grothoff (and other contributing authors) 3 Copyright (C) 2006, 2009, 2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -31,7 +31,7 @@
31#include "gnunet_testing_lib.h" 31#include "gnunet_testing_lib.h"
32 32
33 33
34#define GNUNET_TRANSPORT_TESTING_ConnectRequest void * 34struct GNUNET_TRANSPORT_TESTING_ConnectRequest;
35 35
36 36
37/** 37/**
@@ -43,16 +43,18 @@ struct PeerContext;
43 * Callback when two peers are connected and both have called the connect callback 43 * Callback when two peers are connected and both have called the connect callback
44 * to notify clients about a new peer 44 * to notify clients about a new peer
45 */ 45 */
46typedef void (*GNUNET_TRANSPORT_TESTING_start_cb) (struct PeerContext * p, 46typedef void
47 void *cls); 47(*GNUNET_TRANSPORT_TESTING_start_cb) (struct PeerContext *p,
48 void *cls);
48 49
49/** 50/**
50 * Callback when two peers are connected and both have called the connect callback 51 * Callback when two peers are connected and both have called the connect callback
51 * to notify clients about a new peer 52 * to notify clients about a new peer
52 */ 53 */
53typedef void (*GNUNET_TRANSPORT_TESTING_connect_cb) (struct PeerContext * p1, 54typedef void
54 struct PeerContext * p2, 55(*GNUNET_TRANSPORT_TESTING_connect_cb) (struct PeerContext *p1,
55 void *cls); 56 struct PeerContext *p2,
57 void *cls);
56 58
57 59
58/** 60/**
@@ -147,13 +149,13 @@ struct PeerContext
147}; 149};
148 150
149 151
150struct ConnectingContext 152struct GNUNET_TRANSPORT_TESTING_ConnectRequest
151{ 153{
152 struct ConnectingContext *next; 154 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *next;
153 struct ConnectingContext *prev; 155 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *prev;
154 struct PeerContext *p1; 156 struct PeerContext *p1;
155 struct PeerContext *p2; 157 struct PeerContext *p2;
156 struct GNUNET_SCHEDULER_Task * tct; 158 struct GNUNET_SCHEDULER_Task *tct;
157 GNUNET_TRANSPORT_TESTING_connect_cb cb; 159 GNUNET_TRANSPORT_TESTING_connect_cb cb;
158 void *cb_cls; 160 void *cb_cls;
159 struct GNUNET_TRANSPORT_Handle *th_p1; 161 struct GNUNET_TRANSPORT_Handle *th_p1;
@@ -172,12 +174,12 @@ struct GNUNET_TRANSPORT_TESTING_handle
172 /** 174 /**
173 * head DLL of connect contexts 175 * head DLL of connect contexts
174 */ 176 */
175 struct ConnectingContext *cc_head; 177 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_head;
176 178
177 /** 179 /**
178 * head DLL of connect contexts 180 * head DLL of connect contexts
179 */ 181 */
180 struct ConnectingContext *cc_tail; 182 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_tail;
181 183
182 /** 184 /**
183 * head DLL of peers 185 * head DLL of peers
@@ -192,20 +194,22 @@ struct GNUNET_TRANSPORT_TESTING_handle
192 194
193 195
194/** 196/**
195* Start a peer with the given configuration 197 * Start a peer with the given configuration
196* @param tth the testing handle 198 *
197* @param cfgname configuration file 199 * @param tth the testing handle
198* @param peer_id the peer_id 200 * @param cfgname configuration file
199* @param rec receive callback 201 * @param peer_id the peer_id
200* @param nc connect callback 202 * @param rec receive callback
201* @param nd disconnect callback 203 * @param nc connect callback
202* @param start_cb start callback 204 * @param nd disconnect callback
203* @param cb_cls closure for callback 205 * @param start_cb start callback
204* @return the peer context 206 * @param cb_cls closure for callback
205*/ 207 * @return the peer context
208 */
206struct PeerContext * 209struct PeerContext *
207GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle 210GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
208 *tth, const char *cfgname, int peer_id, 211 const char *cfgname,
212 int peer_id,
209 GNUNET_TRANSPORT_ReceiveCallback rec, 213 GNUNET_TRANSPORT_ReceiveCallback rec,
210 GNUNET_TRANSPORT_NotifyConnect nc, 214 GNUNET_TRANSPORT_NotifyConnect nc,
211 GNUNET_TRANSPORT_NotifyDisconnect nd, 215 GNUNET_TRANSPORT_NotifyDisconnect nd,
@@ -215,30 +219,32 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
215 219
216/** 220/**
217 * shutdown the given peer 221 * shutdown the given peer
222 *
218 * @param tth the testing handle 223 * @param tth the testing handle
219 * @param p the peer 224 * @param p the peer
220 */ 225 */
221
222void 226void
223GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, 227GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
224 struct PeerContext *pc); 228 struct PeerContext *pc);
225 229
226 230
227/** 231/**
228* Restart the given peer 232 * Restart the given peer
229* @param tth testing handle 233 *
230* @param p the peer 234 * @param tth testing handle
231* @param cfgname the cfg file used to restart 235 * @param p the peer
232* @param restart_cb restart callback 236 * @param cfgname the cfg file used to restart
233* @param cb_cls callback closure 237 * @param restart_cb restart callback
234* @return GNUNET_OK in success otherwise GNUNET_SYSERR 238 * @param cb_cls callback closure
235*/ 239 * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR
240 */
236int 241int
237GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle 242GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
238 *tth, struct PeerContext *p, 243 struct PeerContext *p,
239 const char *cfgname, 244 const char *cfgname,
240 GNUNET_TRANSPORT_TESTING_start_cb 245 GNUNET_TRANSPORT_TESTING_start_cb restart_cb,
241 restart_cb, void *cb_cls); 246 void *cb_cls);
247
242 248
243/** 249/**
244 * Connect the given peers and call the callback when both peers report the 250 * Connect the given peers and call the callback when both peers report the
@@ -252,25 +258,23 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle
252 * @param cls callback cls 258 * @param cls callback cls
253 * @return a connect request handle 259 * @return a connect request handle
254 */ 260 */
255GNUNET_TRANSPORT_TESTING_ConnectRequest 261struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
256GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth, 262GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth,
257 struct PeerContext *p1, 263 struct PeerContext *p1,
258 struct PeerContext *p2, 264 struct PeerContext *p2,
259 GNUNET_TRANSPORT_TESTING_connect_cb cb, 265 GNUNET_TRANSPORT_TESTING_connect_cb cb,
260 void *cls); 266 void *cls);
261 267
268
262/** 269/**
263 * Cancel the request to connect two peers 270 * Cancel the request to connect two peers
264 * Tou MUST cancel the request if you stop the peers before the peers connected succesfully 271 * Tou MUST cancel the request if you stop the peers before the peers connected succesfully
265 * @param tth testing 272 * @param tth testing
266 * @param ccr a connect request handle 273 * @param cc a connect request handle
267 */ 274 */
268void 275void
269GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct 276GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth,
270 GNUNET_TRANSPORT_TESTING_handle 277 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc);
271 *tth,
272 GNUNET_TRANSPORT_TESTING_ConnectRequest
273 ccr);
274 278
275/** 279/**
276 * Clean up the transport testing 280 * Clean up the transport testing
@@ -284,7 +288,7 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth);
284 * @return transport testing handle 288 * @return transport testing handle
285 */ 289 */
286struct GNUNET_TRANSPORT_TESTING_handle * 290struct GNUNET_TRANSPORT_TESTING_handle *
287GNUNET_TRANSPORT_TESTING_init (); 291GNUNET_TRANSPORT_TESTING_init (void);
288 292
289/* 293/*
290 * Some utility functions 294 * Some utility functions
@@ -296,7 +300,8 @@ GNUNET_TRANSPORT_TESTING_init ();
296 * @param dest where to store result 300 * @param dest where to store result
297 */ 301 */
298void 302void
299GNUNET_TRANSPORT_TESTING_get_test_name (const char *file, char **dest); 303GNUNET_TRANSPORT_TESTING_get_test_name (const char *file,
304 char **dest);
300 305
301/** 306/**
302 * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and 307 * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
@@ -307,7 +312,8 @@ GNUNET_TRANSPORT_TESTING_get_test_name (const char *file, char **dest);
307 * @param count peer number 312 * @param count peer number
308 */ 313 */
309void 314void
310GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, char **dest, 315GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
316 char **dest,
311 int count); 317 int count);
312 318
313 319