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_BLACKLIST:
163 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
164 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST:
165 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT:
167 case GNUNET_TRANSPORT_PS_DISCONNECT:
168 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED:
171 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
172 "Unhandled state `%s' \n",
173 GNUNET_TRANSPORT_ps2s (state));
177 return GNUNET_SYSERR;
181 * Convert peer state to human-readable string.
183 * @param state the state value
184 * @return corresponding string
187 GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state)
191 case GNUNET_TRANSPORT_PS_NOT_CONNECTED:
192 return "S_NOT_CONNECTED";
193 case GNUNET_TRANSPORT_PS_INIT_ATS:
195 case GNUNET_TRANSPORT_PS_CONNECT_SENT:
196 return "S_CONNECT_SENT";
197 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS:
198 return "S_CONNECT_RECV_ATS";
199 case GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK:
200 return "S_CONNECT_RECV_ACK";
201 case GNUNET_TRANSPORT_PS_CONNECTED:
202 return "S_CONNECTED";
203 case GNUNET_TRANSPORT_PS_RECONNECT_ATS:
204 return "S_RECONNECT_ATS";
205 case GNUNET_TRANSPORT_PS_RECONNECT_BLACKLIST:
206 return "S_RECONNECT_BLACKLIST";
207 case GNUNET_TRANSPORT_PS_RECONNECT_SENT:
208 return "S_RECONNECT_SENT";
209 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_BLACKLIST:
210 return "S_CONNECTED_SWITCHING_BLACKLIST";
211 case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT:
212 return "S_CONNECTED_SWITCHING_CONNECT_SENT";
213 case GNUNET_TRANSPORT_PS_DISCONNECT:
214 return "S_DISCONNECT";
215 case GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED:
216 return "S_DISCONNECT_FINISHED";
224 * Convert validation state to human-readable string.
226 * @param state the state value
227 * @return corresponding string
230 GNUNET_TRANSPORT_vs2s (enum GNUNET_TRANSPORT_ValidationState state)
234 case GNUNET_TRANSPORT_VS_NONE:
236 case GNUNET_TRANSPORT_VS_NEW:
238 case GNUNET_TRANSPORT_VS_REMOVE:
240 case GNUNET_TRANSPORT_VS_TIMEOUT:
242 case GNUNET_TRANSPORT_VS_UPDATE:
252 * Function called with responses from the service.
254 * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*'
255 * @param msg NULL on timeout or error, otherwise presumably a
256 * message with the human-readable address
259 peer_response_processor (void *cls, const struct GNUNET_MessageHeader *msg);
263 * Function called with responses from the service.
265 * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*'
266 * @param msg NULL on timeout or error, otherwise presumably a
267 * message with the human-readable address
270 val_response_processor (void *cls, const struct GNUNET_MessageHeader *msg);
273 * Send our subscription request to the service.
275 * @param pal_ctx our context
278 send_peer_mon_request (struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx)
280 struct PeerMonitorMessage msg;
282 msg.header.size = htons (sizeof (struct PeerMonitorMessage));
283 msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST);
284 msg.one_shot = htonl (pal_ctx->one_shot);
285 msg.peer = pal_ctx->peer;
286 GNUNET_assert (GNUNET_OK ==
287 GNUNET_CLIENT_transmit_and_get_response (pal_ctx->client,
289 GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout),
291 &peer_response_processor,
296 * Send our subscription request to the service.
298 * @param val_ctx our context
301 send_val_mon_request (struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx)
303 struct ValidationMonitorMessage msg;
305 msg.header.size = htons (sizeof (struct ValidationMonitorMessage));
306 msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST);
307 msg.one_shot = htonl (val_ctx->one_shot);
308 msg.peer = val_ctx->peer;
309 GNUNET_assert (GNUNET_OK ==
310 GNUNET_CLIENT_transmit_and_get_response (val_ctx->client,
312 GNUNET_TIME_absolute_get_remaining (val_ctx->timeout),
314 &val_response_processor,
319 * Task run to re-establish the connection.
321 * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*'
322 * @param tc scheduler context, unused
325 do_peer_connect (void *cls,
326 const struct GNUNET_SCHEDULER_TaskContext *tc)
328 struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls;
330 pal_ctx->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
331 pal_ctx->client = GNUNET_CLIENT_connect ("transport", pal_ctx->cfg);
332 GNUNET_assert (NULL != pal_ctx->client);
333 send_peer_mon_request (pal_ctx);
338 * Cut the existing connection and reconnect.
340 * @param pal_ctx our context
343 reconnect_peer_ctx (struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx)
345 GNUNET_assert (GNUNET_NO == pal_ctx->one_shot);
346 GNUNET_CLIENT_disconnect (pal_ctx->client);
347 pal_ctx->client = NULL;
348 pal_ctx->backoff = GNUNET_TIME_STD_BACKOFF (pal_ctx->backoff);
349 pal_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (pal_ctx->backoff,
356 * Task run to re-establish the connection.
358 * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*'
359 * @param tc scheduler context, unused
362 do_val_connect (void *cls,
363 const struct GNUNET_SCHEDULER_TaskContext *tc)
365 struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx = cls;
367 val_ctx->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
368 val_ctx->client = GNUNET_CLIENT_connect ("transport", val_ctx->cfg);
369 GNUNET_assert (NULL != val_ctx->client);
370 send_val_mon_request (val_ctx);
374 * Cut the existing connection and reconnect.
376 * @param val_ctx our context
379 reconnect_val_ctx (struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx)
381 GNUNET_assert (GNUNET_NO == val_ctx->one_shot);
382 GNUNET_CLIENT_disconnect (val_ctx->client);
383 val_ctx->client = NULL;
384 val_ctx->backoff = GNUNET_TIME_STD_BACKOFF (val_ctx->backoff);
385 val_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (val_ctx->backoff,
391 * Function called with responses from the service.
393 * @param cls our 'struct GNUNET_TRANSPORT_PeerMonitoringContext*'
394 * @param msg NULL on timeout or error, otherwise presumably a
395 * message with the human-readable address
398 val_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
400 struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx = cls;
401 struct ValidationIterateResponseMessage *vr_msg;
402 struct GNUNET_HELLO_Address *address;
404 const char *transport_name;
411 if (val_ctx->one_shot)
414 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
415 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
416 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT);
417 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
421 reconnect_val_ctx (val_ctx);
425 size = ntohs (msg->size);
426 GNUNET_break (ntohs (msg->type) ==
427 GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE);
429 if (size == sizeof (struct GNUNET_MessageHeader))
432 if (val_ctx->one_shot)
434 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
435 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
436 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
437 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
441 reconnect_val_ctx (val_ctx);
446 if ((size < sizeof (struct ValidationIterateResponseMessage)) ||
447 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE))
450 if (val_ctx->one_shot)
452 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
453 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
454 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
455 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
459 reconnect_val_ctx (val_ctx);
464 vr_msg = (struct ValidationIterateResponseMessage *) msg;
465 tlen = ntohl (vr_msg->pluginlen);
466 alen = ntohl (vr_msg->addrlen);
468 if (size != sizeof (struct ValidationIterateResponseMessage) + tlen + alen)
471 if (val_ctx->one_shot)
473 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
474 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
475 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
476 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
480 reconnect_val_ctx (val_ctx);
484 if ( (0 == tlen) && (0 == alen) )
487 if (val_ctx->one_shot)
489 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
490 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
491 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
492 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
496 reconnect_val_ctx (val_ctx);
504 GNUNET_break (0); /* This must not happen: address without plugin */
507 addr = (const char *) &vr_msg[1];
508 transport_name = &addr[alen];
510 if (transport_name[tlen - 1] != '\0')
512 /* Corrupt plugin name */
514 if (val_ctx->one_shot)
516 val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
517 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
518 GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
519 GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
523 reconnect_val_ctx (val_ctx);
529 address = GNUNET_HELLO_address_allocate (&vr_msg->peer,
530 transport_name, addr, alen, ntohl(vr_msg->local_address_info));
531 val_ctx->cb (val_ctx->cb_cls, &vr_msg->peer, address,
532 GNUNET_TIME_absolute_ntoh(vr_msg->last_validation),
533 GNUNET_TIME_absolute_ntoh(vr_msg->valid_until),
534 GNUNET_TIME_absolute_ntoh(vr_msg->next_validation),
535 ntohl(vr_msg->state));
536 GNUNET_HELLO_address_free (address);
538 /* expect more replies */
539 GNUNET_CLIENT_receive (val_ctx->client, &val_response_processor,
540 val_ctx, 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 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
587 GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
588 GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
592 reconnect_peer_ctx (pal_ctx);
597 if ((size < sizeof (struct PeerIterateResponseMessage)) ||
598 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE))
601 if (pal_ctx->one_shot)
603 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
604 GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
605 GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
609 reconnect_peer_ctx (pal_ctx);
614 pir_msg = (struct PeerIterateResponseMessage *) msg;
615 tlen = ntohl (pir_msg->pluginlen);
616 alen = ntohl (pir_msg->addrlen);
618 if (size != sizeof (struct PeerIterateResponseMessage) + tlen + alen)
621 if (pal_ctx->one_shot)
623 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
624 GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
625 GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
629 reconnect_peer_ctx (pal_ctx);
634 if ( (0 == tlen) && (0 == alen) )
636 /* No address available */
637 pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, NULL,
638 ntohl(pir_msg->state),
639 GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout));
645 GNUNET_break (0); /* This must not happen: address without plugin */
648 addr = (const char *) &pir_msg[1];
649 transport_name = &addr[alen];
651 if (transport_name[tlen - 1] != '\0')
653 /* Corrupt plugin name */
655 if (pal_ctx->one_shot)
657 pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
658 GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
659 GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
663 reconnect_peer_ctx (pal_ctx);
669 address = GNUNET_HELLO_address_allocate (&pir_msg->peer,
670 transport_name, addr, alen, ntohl(pir_msg->local_address_info));
671 pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, address,
672 ntohl(pir_msg->state),
673 GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout));
674 GNUNET_HELLO_address_free (address);
678 /* expect more replies */
679 GNUNET_CLIENT_receive (pal_ctx->client, &peer_response_processor,
681 GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout));
686 * Return information about a specific peer or all peers currently known to
687 * transport service once or in monitoring mode. To obtain information about
688 * a specific peer, a peer identity can be passed. To obtain information about
689 * all peers currently known to transport service, NULL can be passed as peer
692 * For each peer, the callback is called with information about the address used
693 * to communicate with this peer, the state this peer is currently in and the
694 * the current timeout for this state.
696 * Upon completion, the 'GNUNET_TRANSPORT_PeerIterateCallback' is called one
697 * more time with 'NULL'. After this, the operation must no longer be
698 * explicitly canceled.
700 * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the
703 * @param cfg configuration to use
704 * @param peer a specific peer identity to obtain information for,
706 * @param one_shot GNUNET_YES to return the current state and then end (with NULL+NULL),
707 * GNUNET_NO to monitor peers continuously
708 * @param timeout how long is the lookup allowed to take at most
709 * @param peer_callback function to call with the results
710 * @param peer_callback_cls closure for peer_address_callback
712 struct GNUNET_TRANSPORT_PeerMonitoringContext *
713 GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
714 const struct GNUNET_PeerIdentity *peer,
716 struct GNUNET_TIME_Relative timeout,
717 GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
718 void *peer_callback_cls)
720 struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx;
721 struct GNUNET_CLIENT_Connection *client;
723 client = GNUNET_CLIENT_connect ("transport", cfg);
726 if (GNUNET_YES != one_shot)
727 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
728 pal_ctx = GNUNET_new (struct GNUNET_TRANSPORT_PeerMonitoringContext);
729 pal_ctx->cb = peer_callback;
730 pal_ctx->cb_cls = peer_callback_cls;
732 pal_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
734 pal_ctx->peer = *peer;
735 pal_ctx->one_shot = one_shot;
736 pal_ctx->client = client;
737 send_peer_mon_request (pal_ctx);
744 * Cancel request to monitor peers
746 * @param pic handle for the request to cancel
749 GNUNET_TRANSPORT_monitor_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitoringContext *pic)
751 if (NULL != pic->client)
753 GNUNET_CLIENT_disconnect (pic->client);
756 if (GNUNET_SCHEDULER_NO_TASK != pic->reconnect_task)
758 GNUNET_SCHEDULER_cancel (pic->reconnect_task);
759 pic->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
766 * Return information about pending address validation operations for a specific
769 * @param cfg configuration to use
770 * @param peer a specific peer identity to obtain validation entries for,
772 * @param one_shot GNUNET_YES to return all entries and then end (with NULL+NULL),
773 * GNUNET_NO to monitor validation entries continuously
774 * @param timeout how long is the lookup allowed to take at most
775 * @param validation_callback function to call with the results
776 * @param validation_callback_cls closure for peer_address_callback
778 struct GNUNET_TRANSPORT_ValidationMonitoringContext *
779 GNUNET_TRANSPORT_monitor_validation_entries (const struct
780 GNUNET_CONFIGURATION_Handle *cfg,
781 const struct GNUNET_PeerIdentity *peer,
783 struct GNUNET_TIME_Relative timeout,
784 GNUNET_TRANSPORT_ValidationIterateCallback validation_callback,
785 void *validation_callback_cls)
787 struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx;
788 struct GNUNET_CLIENT_Connection *client;
790 client = GNUNET_CLIENT_connect ("transport", cfg);
793 if (GNUNET_YES != one_shot)
794 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
795 val_ctx = GNUNET_new (struct GNUNET_TRANSPORT_ValidationMonitoringContext);
796 val_ctx->cb = validation_callback;
797 val_ctx->cb_cls = validation_callback_cls;
799 val_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
801 val_ctx->peer = *peer;
802 val_ctx->one_shot = one_shot;
803 val_ctx->client = client;
804 send_val_mon_request (val_ctx);
811 * Return information about all current pending validation operations
813 * @param vic handle for the request to cancel
816 GNUNET_TRANSPORT_monitor_validation_entries_cancel (struct GNUNET_TRANSPORT_ValidationMonitoringContext *vic)
818 if (NULL != vic->client)
820 GNUNET_CLIENT_disconnect (vic->client);
823 if (GNUNET_SCHEDULER_NO_TASK != vic->reconnect_task)
825 GNUNET_SCHEDULER_cancel (vic->reconnect_task);
826 vic->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
832 /* end of transport_api_monitoring.c */