2 This file is part of GNUnet.
3 (C) 2009, 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file transport/transport_api_monitoring.c
23 * @brief montoring api for transport peer status and validation entries
25 * This api provides the ability to query the transport service about
26 * the status of a specific or all peers as well as address validation entries.
28 * Calls back with information about peer(s) including address used, state and
29 * state timeout for peer requests and address, address lifetime and next revalidation
30 * for validation entries.
33 #include "gnunet_util_lib.h"
34 #include "gnunet_arm_service.h"
35 #include "gnunet_hello_lib.h"
36 #include "gnunet_protocols.h"
37 #include "gnunet_transport_service.h"
38 #include "transport.h"
41 * Context for iterating validation entries.
43 struct GNUNET_TRANSPORT_PeerMonitoringContext
46 * Function to call with the binary address.
48 GNUNET_TRANSPORT_PeerIterateCallback cb;
56 * Connection to the service.
58 struct GNUNET_CLIENT_Connection *client;
61 * Configuration we use.
63 const struct GNUNET_CONFIGURATION_Handle *cfg;
66 * When should this operation time out?
68 struct GNUNET_TIME_Absolute timeout;
71 * Backoff for reconnect.
73 struct GNUNET_TIME_Relative backoff;
76 * Task ID for reconnect.
78 GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
81 * Identity of the peer to monitor.
83 struct GNUNET_PeerIdentity peer;
86 * Was this a one-shot request?
93 * Context for the address lookup.
95 struct GNUNET_TRANSPORT_ValidationMonitoringContext
98 * Function to call with the binary address.
100 GNUNET_TRANSPORT_ValidationIterateCallback cb;
108 * Connection to the service.
110 struct GNUNET_CLIENT_Connection *client;
113 * Configuration we use.
115 const struct GNUNET_CONFIGURATION_Handle *cfg;
118 * When should this operation time out?
120 struct GNUNET_TIME_Absolute timeout;
123 * Backoff for reconnect.
125 struct GNUNET_TIME_Relative backoff;
128 * Task ID for reconnect.
130 GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
133 * Identity of the peer to monitor.
135 struct GNUNET_PeerIdentity peer;
138 * Was this a one-shot request?
144 * Check if a state is defined as connected
146 * @param state the state value
147 * @return GNUNET_YES or GNUNET_NO
150 GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state)
154 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
155 case GNUNET_TRANSPORT_PS_INIT_ATS:
156 case GNUNET_TRANSPORT_PS_CONNECT_SENT:
157 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS:
158 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK:
160 case GNUNET_TRANSPORT_PS_CONNECTED:
161 case GNUNET_TRANSPORT_PS_RECONNECT_ATS:
162 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
163 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT:
165 case GNUNET_TRANSPORT_PS_DISCONNECT:
166 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED:
169 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
170 "Unhandled state `%s' \n",
171 GNUNET_TRANSPORT_ps2s (state));
175 return GNUNET_SYSERR;
179 * Convert peer state to human-readable string.
181 * @param state the state value
182 * @return corresponding string
185 GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state)
189 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
190 return "S_NOT_CONNECTED";
191 case GNUNET_TRANSPORT_PS_INIT_ATS:
193 case GNUNET_TRANSPORT_PS_CONNECT_SENT:
194 return "S_CONNECT_SENT";
195 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS:
196 return "S_CONNECT_RECV_ATS";
197 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK:
198 return "S_CONNECT_RECV_ACK";
199 case GNUNET_TRANSPORT_PS_CONNECTED:
200 return "S_CONNECTED";
201 case GNUNET_TRANSPORT_PS_RECONNECT_ATS:
202 return "S_RECONNECT_ATS";
203 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
204 return "S_RECONNECT_SENT";
205 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT:
206 return "S_CONNECTED_SWITCHING_CONNECT_SENT";
207 case GNUNET_TRANSPORT_PS_DISCONNECT:
208 return "S_DISCONNECT";
209 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED:
210 return "S_DISCONNECT_FINISHED";
218 * Convert validation state to human-readable string.
220 * @param state the state value
221 * @return corresponding string
224 GNUNET_TRANSPORT_vs2s (enum GNUNET_TRANSPORT_ValidationState state)
228 case GNUNET_TRANSPORT_VS_NONE:
230 case GNUNET_TRANSPORT_VS_NEW:
232 case GNUNET_TRANSPORT_VS_REMOVE:
234 case GNUNET_TRANSPORT_VS_TIMEOUT:
236 case GNUNET_TRANSPORT_VS_UPDATE:
246 * Function called with responses from the service.
248 * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*'
249 * @param msg NULL on timeout or error, otherwise presumably a
250 * message with the human-readable address
253 peer_response_processor (void *cls, const struct GNUNET_MessageHeader *msg);
257 * Function called with responses from the service.
259 * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*'
260 * @param msg NULL on timeout or error, otherwise presumably a
261 * message with the human-readable address
264 val_response_processor (void *cls, const struct GNUNET_MessageHeader *msg);
267 * Send our subscription request to the service.
269 * @param pal_ctx our context
272 send_peer_mon_request (struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx)
274 struct PeerMonitorMessage msg;
276 msg.header.size = htons (sizeof (struct PeerMonitorMessage));
277 msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST);
278 msg.one_shot = htonl (pal_ctx->one_shot);
279 msg.peer = pal_ctx->peer;
280 GNUNET_assert (GNUNET_OK ==
281 GNUNET_CLIENT_transmit_and_get_response (pal_ctx->client,
283 GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout),
285 &peer_response_processor,
290 * Send our subscription request to the service.
292 * @param val_ctx our context
295 send_val_mon_request (struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx)
297 struct ValidationMonitorMessage msg;
299 msg.header.size = htons (sizeof (struct ValidationMonitorMessage));
300 msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST);
301 msg.one_shot = htonl (val_ctx->one_shot);
302 msg.peer = val_ctx->peer;
303 GNUNET_assert (GNUNET_OK ==
304 GNUNET_CLIENT_transmit_and_get_response (val_ctx->client,
306 GNUNET_TIME_absolute_get_remaining (val_ctx->timeout),
308 &val_response_processor,
313 * Task run to re-establish the connection.
315 * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*'
316 * @param tc scheduler context, unused
319 do_peer_connect (void *cls,
320 const struct GNUNET_SCHEDULER_TaskContext *tc)
322 struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls;
324 pal_ctx->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
325 pal_ctx->client = GNUNET_CLIENT_connect ("transport", pal_ctx->cfg);
326 GNUNET_assert (NULL != pal_ctx->client);
327 send_peer_mon_request (pal_ctx);
332 * Cut the existing connection and reconnect.
334 * @param pal_ctx our context
337 reconnect_peer_ctx (struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx)
339 GNUNET_assert (GNUNET_NO == pal_ctx->one_shot);
340 GNUNET_CLIENT_disconnect (pal_ctx->client);
341 pal_ctx->client = NULL;
342 pal_ctx->backoff = GNUNET_TIME_STD_BACKOFF (pal_ctx->backoff);
343 pal_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (pal_ctx->backoff,
350 * Task run to re-establish the connection.
352 * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*'
353 * @param tc scheduler context, unused
356 do_val_connect (void *cls,
357 const struct GNUNET_SCHEDULER_TaskContext *tc)
359 struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx = cls;
361 val_ctx->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
362 val_ctx->client = GNUNET_CLIENT_connect ("transport", val_ctx->cfg);
363 GNUNET_assert (NULL != val_ctx->client);
364 send_val_mon_request (val_ctx);
368 * Cut the existing connection and reconnect.
370 * @param val_ctx our context
373 reconnect_val_ctx (struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx)
375 GNUNET_assert (GNUNET_NO == val_ctx->one_shot);
376 GNUNET_CLIENT_disconnect (val_ctx->client);
377 val_ctx->client = NULL;
378 /* notify clients about (re)connect */
379 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
380 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
381 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT);
382 val_ctx->backoff = GNUNET_TIME_STD_BACKOFF (val_ctx->backoff);
383 val_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (val_ctx->backoff,
389 * Function called with responses from the service.
391 * @param cls our `struct GNUNET_TRANSPORT_PeerMonitoringContext *`
392 * @param msg NULL on timeout or error, otherwise presumably a
393 * message with the human-readable address
396 val_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
398 struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx = cls;
399 struct ValidationIterateResponseMessage *vr_msg;
400 struct GNUNET_HELLO_Address *address;
402 const char *transport_name;
409 if (val_ctx->one_shot)
412 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
413 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
414 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT);
415 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
419 reconnect_val_ctx (val_ctx);
423 size = ntohs (msg->size);
424 GNUNET_break (ntohs (msg->type) ==
425 GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE);
427 if (size == sizeof (struct GNUNET_MessageHeader))
430 if (val_ctx->one_shot)
432 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
433 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
434 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
435 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
439 reconnect_val_ctx (val_ctx);
444 if ((size < sizeof (struct ValidationIterateResponseMessage)) ||
445 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE))
448 if (val_ctx->one_shot)
450 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
451 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
452 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
453 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
457 reconnect_val_ctx (val_ctx);
462 vr_msg = (struct ValidationIterateResponseMessage *) msg;
463 tlen = ntohl (vr_msg->pluginlen);
464 alen = ntohl (vr_msg->addrlen);
466 if (size != sizeof (struct ValidationIterateResponseMessage) + tlen + alen)
469 if (val_ctx->one_shot)
471 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
472 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
473 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
474 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
478 reconnect_val_ctx (val_ctx);
482 if ( (0 == tlen) && (0 == alen) )
485 if (val_ctx->one_shot)
487 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
488 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
489 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
490 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
494 reconnect_val_ctx (val_ctx);
502 GNUNET_break (0); /* This must not happen: address without plugin */
505 addr = (const char *) &vr_msg[1];
506 transport_name = &addr[alen];
508 if (transport_name[tlen - 1] != '\0')
510 /* Corrupt plugin name */
512 if (val_ctx->one_shot)
514 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
515 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
516 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
517 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
521 reconnect_val_ctx (val_ctx);
527 address = GNUNET_HELLO_address_allocate (&vr_msg->peer,
528 transport_name, addr, alen, ntohl(vr_msg->local_address_info));
529 val_ctx->cb (val_ctx->cb_cls, &vr_msg->peer, address,
530 GNUNET_TIME_absolute_ntoh(vr_msg->last_validation),
531 GNUNET_TIME_absolute_ntoh(vr_msg->valid_until),
532 GNUNET_TIME_absolute_ntoh(vr_msg->next_validation),
533 ntohl(vr_msg->state));
534 GNUNET_HELLO_address_free (address);
536 /* expect more replies */
537 GNUNET_CLIENT_receive (val_ctx->client,
538 &val_response_processor,
540 GNUNET_TIME_absolute_get_remaining (val_ctx->timeout));
545 * Function called with responses from the service.
547 * @param cls our `struct GNUNET_TRANSPORT_PeerMonitoringContext *`
548 * @param msg NULL on timeout or error, otherwise presumably a
549 * message with the human-readable address
552 peer_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
554 struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls;
555 struct PeerIterateResponseMessage *pir_msg;
556 struct GNUNET_HELLO_Address *address;
558 const char *transport_name;
565 if (pal_ctx->one_shot)
568 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
569 GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
570 GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
574 reconnect_peer_ctx (pal_ctx);
578 size = ntohs (msg->size);
579 GNUNET_break (ntohs (msg->type) ==
580 GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE);
581 if (size == sizeof (struct GNUNET_MessageHeader))
584 if (pal_ctx->one_shot)
586 /* iteration finished */
587 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
588 GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
589 GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
593 reconnect_peer_ctx (pal_ctx);
598 if ((size < sizeof (struct PeerIterateResponseMessage)) ||
599 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE))
602 if (pal_ctx->one_shot)
604 /* iteration finished (with error) */
605 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
606 GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
607 GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
611 reconnect_peer_ctx (pal_ctx);
616 pir_msg = (struct PeerIterateResponseMessage *) msg;
617 tlen = ntohl (pir_msg->pluginlen);
618 alen = ntohl (pir_msg->addrlen);
620 if (size != sizeof (struct PeerIterateResponseMessage) + tlen + alen)
623 if (pal_ctx->one_shot)
625 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
626 GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
627 GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
631 reconnect_peer_ctx (pal_ctx);
636 if ( (0 == tlen) && (0 == alen) )
638 /* No address available */
639 pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, NULL,
640 ntohl(pir_msg->state),
641 GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout));
647 GNUNET_break (0); /* This must not happen: address without plugin */
650 addr = (const char *) &pir_msg[1];
651 transport_name = &addr[alen];
653 if (transport_name[tlen - 1] != '\0')
655 /* Corrupt plugin name */
657 if (pal_ctx->one_shot)
659 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
660 GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
661 GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
665 reconnect_peer_ctx (pal_ctx);
671 address = GNUNET_HELLO_address_allocate (&pir_msg->peer,
672 transport_name, addr, alen, ntohl(pir_msg->local_address_info));
673 pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, address,
674 ntohl(pir_msg->state),
675 GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout));
676 GNUNET_HELLO_address_free (address);
680 /* expect more replies */
681 GNUNET_CLIENT_receive (pal_ctx->client, &peer_response_processor,
683 GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout));
688 * Return information about a specific peer or all peers currently known to
689 * transport service once or in monitoring mode. To obtain information about
690 * a specific peer, a peer identity can be passed. To obtain information about
691 * all peers currently known to transport service, NULL can be passed as peer
694 * For each peer, the callback is called with information about the address used
695 * to communicate with this peer, the state this peer is currently in and the
696 * the current timeout for this state.
698 * Upon completion, the 'GNUNET_TRANSPORT_PeerIterateCallback' is called one
699 * more time with 'NULL'. After this, the operation must no longer be
700 * explicitly canceled.
702 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the
705 * @param cfg configuration to use
706 * @param peer a specific peer identity to obtain information for,
708 * @param one_shot #GNUNET_YES to return the current state and then end (with NULL+NULL),
709 * #GNUNET_NO to monitor peers continuously
710 * @param timeout how long is the lookup allowed to take at most
711 * @param peer_callback function to call with the results
712 * @param peer_callback_cls closure for @a peer_address_callback
714 struct GNUNET_TRANSPORT_PeerMonitoringContext *
715 GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
716 const struct GNUNET_PeerIdentity *peer,
718 struct GNUNET_TIME_Relative timeout,
719 GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
720 void *peer_callback_cls)
722 struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx;
723 struct GNUNET_CLIENT_Connection *client;
725 client = GNUNET_CLIENT_connect ("transport", cfg);
728 if (GNUNET_YES != one_shot)
729 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
730 pal_ctx = GNUNET_new (struct GNUNET_TRANSPORT_PeerMonitoringContext);
731 pal_ctx->cb = peer_callback;
732 pal_ctx->cb_cls = peer_callback_cls;
734 pal_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
736 pal_ctx->peer = *peer;
737 pal_ctx->one_shot = one_shot;
738 pal_ctx->client = client;
739 send_peer_mon_request (pal_ctx);
746 * Cancel request to monitor peers
748 * @param pic handle for the request to cancel
751 GNUNET_TRANSPORT_monitor_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitoringContext *pic)
753 if (NULL != pic->client)
755 GNUNET_CLIENT_disconnect (pic->client);
758 if (GNUNET_SCHEDULER_NO_TASK != pic->reconnect_task)
760 GNUNET_SCHEDULER_cancel (pic->reconnect_task);
761 pic->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
768 * Return information about pending address validation operations for a specific
771 * @param cfg configuration to use
772 * @param peer a specific peer identity to obtain validation entries for,
774 * @param one_shot GNUNET_YES to return all entries and then end (with NULL+NULL),
775 * GNUNET_NO to monitor validation entries continuously
776 * @param timeout how long is the lookup allowed to take at most
777 * @param validation_callback function to call with the results
778 * @param validation_callback_cls closure for peer_address_callback
780 struct GNUNET_TRANSPORT_ValidationMonitoringContext *
781 GNUNET_TRANSPORT_monitor_validation_entries (const struct
782 GNUNET_CONFIGURATION_Handle *cfg,
783 const struct GNUNET_PeerIdentity *peer,
785 struct GNUNET_TIME_Relative timeout,
786 GNUNET_TRANSPORT_ValidationIterateCallback validation_callback,
787 void *validation_callback_cls)
789 struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx;
790 struct GNUNET_CLIENT_Connection *client;
792 client = GNUNET_CLIENT_connect ("transport", cfg);
795 if (GNUNET_YES != one_shot)
796 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
797 val_ctx = GNUNET_new (struct GNUNET_TRANSPORT_ValidationMonitoringContext);
798 val_ctx->cb = validation_callback;
799 val_ctx->cb_cls = validation_callback_cls;
801 val_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
803 val_ctx->peer = *peer;
804 val_ctx->one_shot = one_shot;
805 val_ctx->client = client;
806 send_val_mon_request (val_ctx);
813 * Return information about all current pending validation operations
815 * @param vic handle for the request to cancel
818 GNUNET_TRANSPORT_monitor_validation_entries_cancel (struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic)
820 if (NULL != vic->client)
822 GNUNET_CLIENT_disconnect (vic->client);
825 if (GNUNET_SCHEDULER_NO_TASK != vic->reconnect_task)
827 GNUNET_SCHEDULER_cancel (vic->reconnect_task);
828 vic->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
834 /* end of transport_api_monitoring.c */