};
- int destroy_it (void *cls,
- const struct GNUNET_PeerIdentity *key,
- void *value)
+static int
+destroy_it (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
{
- struct MonitoredPeer *m = value;
- GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove (monitored_peers,
- key, value));
- GNUNET_free_non_null (m->address);
- GNUNET_free (value);
- return GNUNET_OK;
+ struct MonitoredPeer *m = value;
+
+ GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove (monitored_peers,
+ key, value));
+ GNUNET_free_non_null (m->address);
+ GNUNET_free (value);
+ return GNUNET_OK;
}
+
/**
* Task run in monitor mode when the user presses CTRL-C to abort.
* Stops monitoring activity.
static void
resolve_validation_address (const struct GNUNET_PeerIdentity *id,
- const struct GNUNET_HELLO_Address *address, int numeric,
- struct GNUNET_TIME_Absolute last_validation,
- struct GNUNET_TIME_Absolute valid_until,
- struct GNUNET_TIME_Absolute next_validation,
- enum GNUNET_TRANSPORT_ValidationState state);
+ const struct GNUNET_HELLO_Address *address,
+ int numeric,
+ struct GNUNET_TIME_Absolute last_validation,
+ struct GNUNET_TIME_Absolute valid_until,
+ struct GNUNET_TIME_Absolute next_validation,
+ enum GNUNET_TRANSPORT_ValidationState state);
+
static void
process_validation_string (void *cls, const char *address)
}
-void process_validation_cb (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
- struct GNUNET_TIME_Absolute last_validation,
- struct GNUNET_TIME_Absolute valid_until,
- struct GNUNET_TIME_Absolute next_validation,
- enum GNUNET_TRANSPORT_ValidationState state)
+static void
+process_validation_cb (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Address *address,
+ struct GNUNET_TIME_Absolute last_validation,
+ struct GNUNET_TIME_Absolute valid_until,
+ struct GNUNET_TIME_Absolute next_validation,
+ enum GNUNET_TRANSPORT_ValidationState state)
{
if ((NULL == peer) && (NULL == address))
{
valid_until, next_validation, state);
}
+
static void
run_nat_test ()
{
head->tsk = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &fail_timeout, head);
}
+
/**
* Test our plugin's configuration (NAT traversal, etc.).
*
}
}
+
static void
resolve_peer_address (const struct GNUNET_PeerIdentity *id,
- const struct GNUNET_HELLO_Address *address, int numeric,
- enum GNUNET_TRANSPORT_PeerState state,
- struct GNUNET_TIME_Absolute state_timeout);
+ const struct GNUNET_HELLO_Address *address,
+ int numeric,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout);
+
static void
-print_info (const struct GNUNET_PeerIdentity *id, const char *transport,
- const char *addr, enum GNUNET_TRANSPORT_PeerState state,
- struct GNUNET_TIME_Absolute state_timeout)
+print_info (const struct GNUNET_PeerIdentity *id,
+ const char *transport,
+ const char *addr,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout)
{
if ( ((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) ||
}
}
+
static void
process_peer_string (void *cls, const char *address)
{
}
}
+
static void
resolve_peer_address (const struct GNUNET_PeerIdentity *id,
- const struct GNUNET_HELLO_Address *address, int numeric,
- enum GNUNET_TRANSPORT_PeerState state,
- struct GNUNET_TIME_Absolute state_timeout)
+ const struct GNUNET_HELLO_Address *address,
+ int numeric,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout)
{
struct PeerResolutionContext *rc;
RESOLUTION_TIMEOUT, &process_peer_string, rc);
}
+
/**
* Function called with information about a peers during a one shot iteration
*
*
*/
static void
-process_peer_iteration_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
- enum GNUNET_TRANSPORT_PeerState state,
- struct GNUNET_TIME_Absolute state_timeout)
+process_peer_iteration_cb (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Address *address,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout)
{
- if (peer == NULL )
+ if (NULL == peer)
{
+ if (monitor_connections)
+ {
+ FPRINTF (stdout,
+ _("Monitor disconnected from transport service. Reconnecting.\n"));
+ return;
+ }
/* done */
address_resolution_in_progress = GNUNET_NO;
pic = NULL;
op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
NULL );
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received address for peer `%s': %s\n",
- GNUNET_i2s (peer), address->transport_name);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Received address for peer `%s': %s\n",
+ GNUNET_i2s (peer), address->transport_name);
if (NULL != address)
resolve_peer_address (peer, address, numeric, state, state_timeout);
GNUNET_assert (GNUNET_NO == val_ctx->one_shot);
GNUNET_CLIENT_disconnect (val_ctx->client);
val_ctx->client = NULL;
+ /* notify clients about (re)connect */
+ val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
+ GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
+ GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT);
val_ctx->backoff = GNUNET_TIME_STD_BACKOFF (val_ctx->backoff);
val_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (val_ctx->backoff,
&do_val_connect,
/**
* Function called with responses from the service.
*
- * @param cls our 'struct GNUNET_TRANSPORT_PeerMonitoringContext*'
+ * @param cls our `struct GNUNET_TRANSPORT_PeerMonitoringContext *`
* @param msg NULL on timeout or error, otherwise presumably a
* message with the human-readable address
*/
size_t tlen;
size_t alen;
- if (msg == NULL)
+ if (NULL == msg)
{
if (val_ctx->one_shot)
{
GNUNET_HELLO_address_free (address);
}
/* expect more replies */
- GNUNET_CLIENT_receive (val_ctx->client, &val_response_processor,
- val_ctx, GNUNET_TIME_absolute_get_remaining (val_ctx->timeout));
+ GNUNET_CLIENT_receive (val_ctx->client,
+ &val_response_processor,
+ val_ctx,
+ GNUNET_TIME_absolute_get_remaining (val_ctx->timeout));
}
/**
* Function called with responses from the service.
*
- * @param cls our 'struct GNUNET_TRANSPORT_PeerMonitoringContext*'
+ * @param cls our `struct GNUNET_TRANSPORT_PeerMonitoringContext *`
* @param msg NULL on timeout or error, otherwise presumably a
* message with the human-readable address
*/
/* Done! */
if (pal_ctx->one_shot)
{
+ /* iteration finished */
pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
GNUNET_break (0);
if (pal_ctx->one_shot)
{
+ /* iteration finished (with error) */
pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL,
GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS);
GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx);
* @param cfg configuration to use
* @param peer a specific peer identity to obtain information for,
* NULL for all peers
- * @param one_shot GNUNET_YES to return the current state and then end (with NULL+NULL),
- * GNUNET_NO to monitor peers continuously
+ * @param one_shot #GNUNET_YES to return the current state and then end (with NULL+NULL),
+ * #GNUNET_NO to monitor peers continuously
* @param timeout how long is the lookup allowed to take at most
* @param peer_callback function to call with the results
- * @param peer_callback_cls closure for peer_address_callback
+ * @param peer_callback_cls closure for @a peer_address_callback
*/
struct GNUNET_TRANSPORT_PeerMonitoringContext *
GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_PeerIdentity *peer,
- int one_shot,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
- void *peer_callback_cls)
+ const struct GNUNET_PeerIdentity *peer,
+ int one_shot,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
+ void *peer_callback_cls)
{
struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx;
struct GNUNET_CLIENT_Connection *client;