aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api2_application.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-04-07 17:22:23 +0200
committerChristian Grothoff <christian@grothoff.org>2019-04-07 17:22:23 +0200
commit0142079ce2e7a5e062d06aa8dddf2fdc1529035d (patch)
treeeb0bd17aec8a7a5501435d11cfe2d53402db5dcd /src/transport/transport_api2_application.c
parenta8c2bed07d3d43c34cfcf8fe96e56ea516feaf80 (diff)
downloadgnunet-0142079ce2e7a5e062d06aa8dddf2fdc1529035d.tar.gz
gnunet-0142079ce2e7a5e062d06aa8dddf2fdc1529035d.zip
implement #5551 (UDP broadcast learning in TNG)
Diffstat (limited to 'src/transport/transport_api2_application.c')
-rw-r--r--src/transport/transport_api2_application.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/transport/transport_api2_application.c b/src/transport/transport_api2_application.c
index 325438e11..414a21fe4 100644
--- a/src/transport/transport_api2_application.c
+++ b/src/transport/transport_api2_application.c
@@ -363,4 +363,56 @@ GNUNET_TRANSPORT_application_suggest_cancel (struct GNUNET_TRANSPORT_Application
363} 363}
364 364
365 365
366
367/**
368 * An application (or a communicator) has received a HELLO (or other address
369 * data of another peer) and wants TRANSPORT to validate that the address is
370 * correct. The result is NOT returned, in fact TRANSPORT may do nothing
371 * (i.e. if it has too many active validations or recently tried this one
372 * already). If the @a addr validates, TRANSPORT will persist the address
373 * with PEERSTORE.
374 *
375 * @param ch handle
376 * @param peer identity of the peer we have an address for
377 * @param expiration when does @a addr expire; used by TRANSPORT to know when
378 * to definitively give up attempting to validate
379 * @param nt network type of @a addr (as claimed by the other peer);
380 * used by TRANSPORT to avoid trying @a addr's that really cannot work
381 * due to network type missmatches
382 * @param addr address to validate
383 */
384void
385GNUNET_TRANSPORT_application_validate (struct GNUNET_TRANSPORT_ApplicationHandle *ch,
386 const struct GNUNET_PeerIdentity *peer,
387 struct GNUNET_TIME_Absolute expiration,
388 enum GNUNET_NetworkType nt,
389 const char *addr)
390{
391 struct GNUNET_MQ_Envelope *ev;
392 struct RequestHelloValidationMessage *m;
393 size_t alen;
394
395 if (NULL == ch->mq)
396 {
397 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
398 "Address validation for %s:%s skipped as transport is not connected\n",
399 GNUNET_i2s (peer),
400 addr);
401 return;
402 }
403 alen = strlen (addr) + 1;
404 ev = GNUNET_MQ_msg_extra (m,
405 alen,
406 GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION);
407 m->peer = *peer;
408 m->expiration = GNUNET_TIME_absolute_hton (expiration);
409 m->nt = htonl ((uint32_t) nt);
410 memcpy (&m[1],
411 addr,
412 alen);
413 GNUNET_MQ_send (ch->mq,
414 ev);
415}
416
417
366/* end of transport_api2_application.c */ 418/* end of transport_api2_application.c */