aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r--src/transport/test_transport_api.c44
1 files changed, 9 insertions, 35 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index 7ce02c757..8cf8daf5e 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -84,20 +84,12 @@ end ()
84} 84}
85 85
86 86
87/**
88 * Function called by the transport for each received message.
89 *
90 * @param cls closure
91 * @param latency estimated latency for communicating with the
92 * given peer
93 * @param peer (claimed) identity of the other peer
94 * @param message the message
95 */
96static void 87static void
97notify_receive (void *cls, 88notify_receive (void *cls,
98 struct GNUNET_TIME_Relative latency,
99 const struct GNUNET_PeerIdentity *peer, 89 const struct GNUNET_PeerIdentity *peer,
100 const struct GNUNET_MessageHeader *message) 90 const struct GNUNET_MessageHeader *message,
91 struct GNUNET_TIME_Relative latency,
92 uint32_t distance)
101{ 93{
102 GNUNET_assert (ok == 7); 94 GNUNET_assert (ok == 7);
103 OKPP; 95 OKPP;
@@ -110,19 +102,11 @@ notify_receive (void *cls,
110} 102}
111 103
112 104
113/**
114 * Function called to notify transport users that another
115 * peer connected to us.
116 *
117 * @param cls closure
118 * @param transport the transport service handle
119 * @param peer the peer that disconnected
120 * @param latency current latency of the connection
121 */
122static void 105static void
123notify_connect (void *cls, 106notify_connect (void *cls,
124 const struct GNUNET_PeerIdentity *peer, 107 const struct GNUNET_PeerIdentity *peer,
125 struct GNUNET_TIME_Relative latency) 108 struct GNUNET_TIME_Relative latency,
109 uint32_t distance)
126{ 110{
127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 111 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
128 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); 112 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
@@ -131,14 +115,6 @@ notify_connect (void *cls,
131} 115}
132 116
133 117
134/**
135 * Function called to notify transport users that another
136 * peer disconnected from us.
137 *
138 * @param cls closure
139 * @param transport the transport service handle
140 * @param peer the peer that disconnected
141 */
142static void 118static void
143notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 119notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
144{ 120{
@@ -187,12 +163,11 @@ notify_ready (void *cls, size_t size, void *buf)
187 163
188static void 164static void
189exchange_hello_last (void *cls, 165exchange_hello_last (void *cls,
190 struct GNUNET_TIME_Relative latency,
191 const struct GNUNET_PeerIdentity *peer,
192 const struct GNUNET_MessageHeader *message) 166 const struct GNUNET_MessageHeader *message)
193{ 167{
194 struct PeerContext *me = cls; 168 struct PeerContext *me = cls;
195 169
170 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, me);
196 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 171 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
197 "Exchanging HELLO with peer (%p)!\n", cls); 172 "Exchanging HELLO with peer (%p)!\n", cls);
198 GNUNET_assert (ok >= 3); 173 GNUNET_assert (ok >= 3);
@@ -214,12 +189,11 @@ exchange_hello_last (void *cls,
214 189
215static void 190static void
216exchange_hello (void *cls, 191exchange_hello (void *cls,
217 struct GNUNET_TIME_Relative latency,
218 const struct GNUNET_PeerIdentity *peer,
219 const struct GNUNET_MessageHeader *message) 192 const struct GNUNET_MessageHeader *message)
220{ 193{
221 struct PeerContext *me = cls; 194 struct PeerContext *me = cls;
222 195
196 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
224 "Exchanging HELLO with peer (%p)!\n", cls); 198 "Exchanging HELLO with peer (%p)!\n", cls);
225 GNUNET_assert (ok >= 2); 199 GNUNET_assert (ok >= 2);
@@ -228,7 +202,7 @@ exchange_hello (void *cls,
228 GNUNET_assert (GNUNET_OK == 202 GNUNET_assert (GNUNET_OK ==
229 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) 203 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
230 message, &me->id)); 204 message, &me->id));
231 GNUNET_TRANSPORT_get_hello (p2.th, TIMEOUT, &exchange_hello_last, &p2); 205 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
232} 206}
233 207
234static void 208static void
@@ -272,7 +246,7 @@ run (void *cls,
272 246
273 setup_peer (&p1, "test_transport_api_peer1.conf"); 247 setup_peer (&p1, "test_transport_api_peer1.conf");
274 setup_peer (&p2, "test_transport_api_peer2.conf"); 248 setup_peer (&p2, "test_transport_api_peer2.conf");
275 GNUNET_TRANSPORT_get_hello (p1.th, TIMEOUT, &exchange_hello, &p1); 249 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
276} 250}
277 251
278 252