diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-08-12 04:28:53 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-08-12 04:28:53 +0000 |
commit | 5434646c91cc203f4113018503b06ada292060d4 (patch) | |
tree | 172e672d2040ebf16c05d772a8655c169acc8389 /src/transport/transport-testing.c | |
parent | 202d53014183b98b27cdc88fef11b5f9f6b97f00 (diff) | |
download | gnunet-5434646c91cc203f4113018503b06ada292060d4.tar.gz gnunet-5434646c91cc203f4113018503b06ada292060d4.zip |
documentation
Diffstat (limited to 'src/transport/transport-testing.c')
-rw-r--r-- | src/transport/transport-testing.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index 24e4e8797..16e7a1e25 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -41,10 +41,10 @@ struct ConnectingContext | |||
41 | }; | 41 | }; |
42 | 42 | ||
43 | static void | 43 | static void |
44 | exchange_hello_last (void *cls, | 44 | exchange_hello_last (void *cb_cls, |
45 | const struct GNUNET_MessageHeader *message); | 45 | const struct GNUNET_MessageHeader *message); |
46 | static void | 46 | static void |
47 | exchange_hello (void *cls, | 47 | exchange_hello (void *cb_cls, |
48 | const struct GNUNET_MessageHeader *message); | 48 | const struct GNUNET_MessageHeader *message); |
49 | 49 | ||
50 | static void | 50 | static void |
@@ -120,10 +120,10 @@ notify_receive (void *cls, | |||
120 | 120 | ||
121 | 121 | ||
122 | static void | 122 | static void |
123 | exchange_hello_last (void *cls, | 123 | exchange_hello_last (void *cb_cls, |
124 | const struct GNUNET_MessageHeader *message) | 124 | const struct GNUNET_MessageHeader *message) |
125 | { | 125 | { |
126 | struct ConnectingContext * cc = cls; | 126 | struct ConnectingContext * cc = cb_cls; |
127 | struct PeerContext *me = cc->p2; | 127 | struct PeerContext *me = cc->p2; |
128 | //struct PeerContext *p1 = cc->p1; | 128 | //struct PeerContext *p1 = cc->p1; |
129 | 129 | ||
@@ -140,10 +140,10 @@ exchange_hello_last (void *cls, | |||
140 | 140 | ||
141 | 141 | ||
142 | static void | 142 | static void |
143 | exchange_hello (void *cls, | 143 | exchange_hello (void *cb_cls, |
144 | const struct GNUNET_MessageHeader *message) | 144 | const struct GNUNET_MessageHeader *message) |
145 | { | 145 | { |
146 | struct ConnectingContext * cc = cls; | 146 | struct ConnectingContext * cc = cb_cls; |
147 | struct PeerContext *me = cc->p1; | 147 | struct PeerContext *me = cc->p1; |
148 | //struct PeerContext *p2 = cc->p2; | 148 | //struct PeerContext *p2 = cc->p2; |
149 | 149 | ||
@@ -183,6 +183,15 @@ try_connect (void *cls, | |||
183 | cc); | 183 | cc); |
184 | } | 184 | } |
185 | 185 | ||
186 | |||
187 | /** | ||
188 | * Start a peer with the given configuration | ||
189 | * @param rec receive callback | ||
190 | * @param nc connect callback | ||
191 | * @param nd disconnect callback | ||
192 | * @param cb_cls closure for callback | ||
193 | * @return the peer context | ||
194 | */ | ||
186 | struct PeerContext * | 195 | struct PeerContext * |
187 | GNUNET_TRANSPORT_TESTING_start_peer (const char * cfgname, | 196 | GNUNET_TRANSPORT_TESTING_start_peer (const char * cfgname, |
188 | GNUNET_TRANSPORT_ReceiveCallback rec, | 197 | GNUNET_TRANSPORT_ReceiveCallback rec, |
@@ -222,6 +231,10 @@ GNUNET_TRANSPORT_TESTING_start_peer (const char * cfgname, | |||
222 | return p; | 231 | return p; |
223 | } | 232 | } |
224 | 233 | ||
234 | /** | ||
235 | * shutdown the given peer | ||
236 | * @param p the peer | ||
237 | */ | ||
225 | void | 238 | void |
226 | GNUNET_TRANSPORT_TESTING_stop_peer (struct PeerContext * p) | 239 | GNUNET_TRANSPORT_TESTING_stop_peer (struct PeerContext * p) |
227 | { | 240 | { |
@@ -245,11 +258,20 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct PeerContext * p) | |||
245 | GNUNET_free (p); | 258 | GNUNET_free (p); |
246 | } | 259 | } |
247 | 260 | ||
261 | /** | ||
262 | * Connect the two given peers and call the callback when both peers report the | ||
263 | * inbound connect. Remarks: start_peer's notify_connect callback can be called | ||
264 | * before. | ||
265 | * @param p1 peer 1 | ||
266 | * @param p2 peer 2 | ||
267 | * @param cb the callback to call | ||
268 | * @param cb_cls callback cls | ||
269 | */ | ||
248 | void | 270 | void |
249 | GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext * p1, | 271 | GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext * p1, |
250 | struct PeerContext * p2, | 272 | struct PeerContext * p2, |
251 | GNUNET_TRANSPORT_TESTING_connect_cb cb, | 273 | GNUNET_TRANSPORT_TESTING_connect_cb cb, |
252 | void * cls) | 274 | void * cb_cls) |
253 | { | 275 | { |
254 | struct ConnectingContext * cc = GNUNET_malloc (sizeof (struct ConnectingContext)); | 276 | struct ConnectingContext * cc = GNUNET_malloc (sizeof (struct ConnectingContext)); |
255 | 277 | ||
@@ -260,7 +282,7 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext * p1, | |||
260 | cc->p2 = p2; | 282 | cc->p2 = p2; |
261 | 283 | ||
262 | cc->cb = cb; | 284 | cc->cb = cb; |
263 | cc->cb_cls = cls; | 285 | cc->cb_cls = cb_cls; |
264 | 286 | ||
265 | cc->th_p1 = GNUNET_TRANSPORT_connect(cc->p1->cfg, NULL, | 287 | cc->th_p1 = GNUNET_TRANSPORT_connect(cc->p1->cfg, NULL, |
266 | cc, | 288 | cc, |