diff options
Diffstat (limited to 'src/transport/transport_api_monitor_validation.c')
-rw-r--r-- | src/transport/transport_api_monitor_validation.c | 88 |
1 files changed, 34 insertions, 54 deletions
diff --git a/src/transport/transport_api_monitor_validation.c b/src/transport/transport_api_monitor_validation.c index a82e3c156..a52aee129 100644 --- a/src/transport/transport_api_monitor_validation.c +++ b/src/transport/transport_api_monitor_validation.c | |||
@@ -181,7 +181,7 @@ reconnect_val_ctx (struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx) | |||
181 | GNUNET_CLIENT_disconnect (val_ctx->client); | 181 | GNUNET_CLIENT_disconnect (val_ctx->client); |
182 | val_ctx->client = NULL; | 182 | val_ctx->client = NULL; |
183 | /* notify clients about (re)connect */ | 183 | /* notify clients about (re)connect */ |
184 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 184 | val_ctx->cb (val_ctx->cb_cls, NULL, |
185 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 185 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, |
186 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT); | 186 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT); |
187 | val_ctx->backoff = GNUNET_TIME_STD_BACKOFF (val_ctx->backoff); | 187 | val_ctx->backoff = GNUNET_TIME_STD_BACKOFF (val_ctx->backoff); |
@@ -216,7 +216,7 @@ val_response_processor (void *cls, | |||
216 | if (val_ctx->one_shot) | 216 | if (val_ctx->one_shot) |
217 | { | 217 | { |
218 | /* Disconnect */ | 218 | /* Disconnect */ |
219 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 219 | val_ctx->cb (val_ctx->cb_cls, NULL, |
220 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 220 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, |
221 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT); | 221 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT); |
222 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | 222 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); |
@@ -236,7 +236,7 @@ val_response_processor (void *cls, | |||
236 | /* Done! */ | 236 | /* Done! */ |
237 | if (val_ctx->one_shot) | 237 | if (val_ctx->one_shot) |
238 | { | 238 | { |
239 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 239 | val_ctx->cb (val_ctx->cb_cls, NULL, |
240 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 240 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, |
241 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); | 241 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); |
242 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | 242 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); |
@@ -254,7 +254,7 @@ val_response_processor (void *cls, | |||
254 | GNUNET_break (0); | 254 | GNUNET_break (0); |
255 | if (val_ctx->one_shot) | 255 | if (val_ctx->one_shot) |
256 | { | 256 | { |
257 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 257 | val_ctx->cb (val_ctx->cb_cls, NULL, |
258 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 258 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, |
259 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); | 259 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); |
260 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | 260 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); |
@@ -275,7 +275,7 @@ val_response_processor (void *cls, | |||
275 | GNUNET_break (0); | 275 | GNUNET_break (0); |
276 | if (val_ctx->one_shot) | 276 | if (val_ctx->one_shot) |
277 | { | 277 | { |
278 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 278 | val_ctx->cb (val_ctx->cb_cls, NULL, |
279 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 279 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, |
280 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); | 280 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); |
281 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | 281 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); |
@@ -286,14 +286,26 @@ val_response_processor (void *cls, | |||
286 | } | 286 | } |
287 | return; | 287 | return; |
288 | } | 288 | } |
289 | if ( (0 == tlen) && (0 == alen) ) | 289 | if (0 == tlen) |
290 | { | 290 | { |
291 | GNUNET_break (0); /* This must not happen: address without plugin */ | ||
292 | return; | ||
293 | } | ||
294 | addr = (const char *) &vr_msg[1]; | ||
295 | transport_name = &addr[alen]; | ||
296 | |||
297 | if (transport_name[tlen - 1] != '\0') | ||
298 | { | ||
299 | /* Corrupt plugin name */ | ||
291 | GNUNET_break (0); | 300 | GNUNET_break (0); |
292 | if (val_ctx->one_shot) | 301 | if (val_ctx->one_shot) |
293 | { | 302 | { |
294 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 303 | val_ctx->cb (val_ctx->cb_cls, |
295 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 304 | NULL, |
296 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); | 305 | GNUNET_TIME_UNIT_ZERO_ABS, |
306 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
307 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
308 | GNUNET_TRANSPORT_VS_NONE); | ||
297 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | 309 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); |
298 | } | 310 | } |
299 | else | 311 | else |
@@ -302,51 +314,19 @@ val_response_processor (void *cls, | |||
302 | } | 314 | } |
303 | return; | 315 | return; |
304 | } | 316 | } |
305 | else | 317 | |
306 | { | 318 | /* notify client */ |
307 | if (0 == tlen) | 319 | address = GNUNET_HELLO_address_allocate (&vr_msg->peer, |
308 | { | 320 | transport_name, |
309 | GNUNET_break (0); /* This must not happen: address without plugin */ | 321 | addr, alen, |
310 | return; | 322 | ntohl (vr_msg->local_address_info)); |
311 | } | 323 | val_ctx->cb (val_ctx->cb_cls, |
312 | addr = (const char *) &vr_msg[1]; | 324 | address, |
313 | transport_name = &addr[alen]; | 325 | GNUNET_TIME_absolute_ntoh (vr_msg->last_validation), |
314 | 326 | GNUNET_TIME_absolute_ntoh (vr_msg->valid_until), | |
315 | if (transport_name[tlen - 1] != '\0') | 327 | GNUNET_TIME_absolute_ntoh (vr_msg->next_validation), |
316 | { | 328 | ntohl(vr_msg->state)); |
317 | /* Corrupt plugin name */ | 329 | GNUNET_HELLO_address_free (address); |
318 | GNUNET_break (0); | ||
319 | if (val_ctx->one_shot) | ||
320 | { | ||
321 | val_ctx->cb (val_ctx->cb_cls, | ||
322 | NULL, NULL, | ||
323 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
324 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
325 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
326 | GNUNET_TRANSPORT_VS_NONE); | ||
327 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | ||
328 | } | ||
329 | else | ||
330 | { | ||
331 | reconnect_val_ctx (val_ctx); | ||
332 | } | ||
333 | return; | ||
334 | } | ||
335 | |||
336 | /* notify client */ | ||
337 | address = GNUNET_HELLO_address_allocate (&vr_msg->peer, | ||
338 | transport_name, | ||
339 | addr, alen, | ||
340 | ntohl (vr_msg->local_address_info)); | ||
341 | val_ctx->cb (val_ctx->cb_cls, | ||
342 | &vr_msg->peer, | ||
343 | address, | ||
344 | GNUNET_TIME_absolute_ntoh (vr_msg->last_validation), | ||
345 | GNUNET_TIME_absolute_ntoh (vr_msg->valid_until), | ||
346 | GNUNET_TIME_absolute_ntoh (vr_msg->next_validation), | ||
347 | ntohl(vr_msg->state)); | ||
348 | GNUNET_HELLO_address_free (address); | ||
349 | } | ||
350 | /* expect more replies */ | 330 | /* expect more replies */ |
351 | GNUNET_CLIENT_receive (val_ctx->client, | 331 | GNUNET_CLIENT_receive (val_ctx->client, |
352 | &val_response_processor, | 332 | &val_response_processor, |