aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-01-21 20:09:42 +0000
committerChristian Grothoff <christian@grothoff.org>2010-01-21 20:09:42 +0000
commitc669897781ee561d3d8aed70fb5ee447505556d9 (patch)
tree02c35b3e5c55154ffbf853fa4f0d843a8638d989 /src/transport
parent071fd478e813a715fea48309eefde0683a42af64 (diff)
downloadgnunet-c669897781ee561d3d8aed70fb5ee447505556d9.tar.gz
gnunet-c669897781ee561d3d8aed70fb5ee447505556d9.zip
fixing compilation issues
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/test_plugin_transport.c67
-rw-r--r--src/transport/test_transport_api.c44
2 files changed, 25 insertions, 86 deletions
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c
index 407150d3a..2248f007e 100644
--- a/src/transport/test_plugin_transport.c
+++ b/src/transport/test_plugin_transport.c
@@ -94,10 +94,11 @@ static int ok;
94 */ 94 */
95static void 95static void
96receive (void *cls, 96receive (void *cls,
97 struct GNUNET_TIME_Relative
98 latency,
99 const struct GNUNET_PeerIdentity 97 const struct GNUNET_PeerIdentity
100 *peer, const struct GNUNET_MessageHeader *message) 98 *peer, const struct GNUNET_MessageHeader *message,
99 uint32_t distance,
100 const char *sender_address,
101 size_t sender_address_len)
101{ 102{
102 /* do nothing */ 103 /* do nothing */
103} 104}
@@ -137,43 +138,6 @@ unload_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
137} 138}
138 139
139 140
140static GNUNET_SCHEDULER_TaskIdentifier validation_timeout_task;
141
142
143static void
144validation_notification (void *cls,
145 const char *name,
146 const struct GNUNET_PeerIdentity *peer,
147 uint32_t challenge, const char *sender_addr)
148{
149 if (validation_timeout_task != GNUNET_SCHEDULER_NO_TASK)
150 {
151 GNUNET_SCHEDULER_cancel (sched, validation_timeout_task);
152 validation_timeout_task = GNUNET_SCHEDULER_NO_TASK;
153 }
154
155 GNUNET_assert (challenge == 42);
156
157 ok = 0; /* if the last test succeeded, report success */
158 GNUNET_SCHEDULER_add_continuation (sched,
159 &unload_task,
160 (void *) cfg,
161 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
162}
163
164
165static void
166validation_failed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
167{
168 validation_timeout_task = GNUNET_SCHEDULER_NO_TASK;
169 GNUNET_break (0); /* output error */
170 /* the "validation_notification" was not called
171 in a timely fashion; we should set an error
172 code for main and shut down */
173 unload_plugins (NULL, cfg);
174}
175
176
177/** 141/**
178 * Simple example test that invokes 142 * Simple example test that invokes
179 * the "validate" function of the plugin 143 * the "validate" function of the plugin
@@ -185,9 +149,10 @@ validation_failed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
185 * work for other plugins; we should ask 149 * work for other plugins; we should ask
186 * the plugin about its address instead...). 150 * the plugin about its address instead...).
187 */ 151 */
188/* FIXME: won't work on IPv6 enabled systems where IPv4 mapping 152/* FIXME: this is TCP/UDP-specific and won't work
189 * isn't enabled (eg. FreeBSD > 4) 153 for HTTP/SMTP/DV; we should instead use an
190 */ 154 address that we get from the plugin itself
155 (if it is willing/able to give us one...) */
191static void 156static void
192test_validation () 157test_validation ()
193{ 158{
@@ -200,11 +165,14 @@ test_validation ()
200 soaddr.sin_family = AF_INET; 165 soaddr.sin_family = AF_INET;
201 soaddr.sin_port = htons (2368 /* FIXME: get from config! */ ); 166 soaddr.sin_port = htons (2368 /* FIXME: get from config! */ );
202 soaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); 167 soaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
203 api->validate (api->cls, 168 GNUNET_assert (GNUNET_OK ==
204 &my_identity, 42, TIMEOUT, &soaddr, sizeof (soaddr)); 169 api->check_address (api->cls,
205 /* add job to catch failure (timeout) */ 170 &soaddr, sizeof (soaddr)));
206 validation_timeout_task = 171 ok = 0;
207 GNUNET_SCHEDULER_add_delayed (sched, TIMEOUT, &validation_failed, NULL); 172 GNUNET_SCHEDULER_add_continuation (sched,
173 &unload_task,
174 (void *) cfg,
175 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
208} 176}
209 177
210 178
@@ -213,13 +181,10 @@ setup_plugin_environment ()
213{ 181{
214 env.cfg = cfg; 182 env.cfg = cfg;
215 env.sched = sched; 183 env.sched = sched;
216 env.my_public_key = &my_public_key;
217 env.my_private_key = my_private_key;
218 env.my_identity = &my_identity; 184 env.my_identity = &my_identity;
219 env.cls = &env; 185 env.cls = &env;
220 env.receive = &receive; 186 env.receive = &receive;
221 env.notify_address = &notify_address; 187 env.notify_address = &notify_address;
222 env.notify_validation = &validation_notification;
223 env.max_connections = max_connect_per_transport; 188 env.max_connections = max_connect_per_transport;
224} 189}
225 190
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