summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-02 22:25:48 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-02 22:25:48 +0000
commit69c3a52cfa679175da8f06bdcb8e2e4195465e44 (patch)
tree73109126cfcf1a807c5dc1e778f40b955fc959c5
parentc42deb089faffd654e27bf661ce85d5c1bb38b7a (diff)
avoid passing both PeerIdentity and Address (which contains PeerIdentity) if address is always present as then this is redundant
-rw-r--r--src/hello/hello.c2
-rw-r--r--src/include/gnunet_peer_lib.h19
-rw-r--r--src/include/gnunet_transport_service.h13
-rw-r--r--src/transport/gnunet-service-transport.c63
-rw-r--r--src/transport/gnunet-service-transport_ats.c4
-rw-r--r--src/transport/gnunet-service-transport_blacklist.c19
-rw-r--r--src/transport/gnunet-service-transport_clients.c8
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c181
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h32
-rw-r--r--src/transport/gnunet-service-transport_plugins.c5
-rw-r--r--src/transport/gnunet-service-transport_validation.c150
-rw-r--r--src/transport/gnunet-service-transport_validation.h7
-rw-r--r--src/transport/gnunet-transport.c34
-rw-r--r--src/transport/test_transport_api_monitor_peers.c14
-rw-r--r--src/transport/test_transport_api_monitor_validation.c49
-rw-r--r--src/transport/transport_api_monitor_peers.c58
-rw-r--r--src/transport/transport_api_monitor_validation.c88
17 files changed, 317 insertions, 429 deletions
diff --git a/src/hello/hello.c b/src/hello/hello.c
index 22da56e88..3c836a9e4 100644
--- a/src/hello/hello.c
+++ b/src/hello/hello.c
@@ -539,7 +539,7 @@ GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello)
*
* @param hello the hello message
* @param publicKey where to copy the public key information, can be NULL
- * @return GNUNET_SYSERR if the HELLO was malformed
+ * @return #GNUNET_SYSERR if the HELLO was malformed
*/
int
GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello,
diff --git a/src/include/gnunet_peer_lib.h b/src/include/gnunet_peer_lib.h
index fbe13e2cf..30347a8ff 100644
--- a/src/include/gnunet_peer_lib.h
+++ b/src/include/gnunet_peer_lib.h
@@ -38,11 +38,10 @@ extern "C"
#endif
/**
- * A GNUNET_PEER_Id is simply a shorter
- * version of a "struct GNUNET_PeerIdentifier"
- * that can be used inside of a GNUnet peer
- * to save memory when the same identifier
- * needs to be used over and over again.
+ * A GNUNET_PEER_Id is simply a shorter version of a "struct
+ * GNUNET_PeerIdentifier" that can be used inside of a GNUnet peer to
+ * save memory when the same identifier needs to be used over and over
+ * again.
*/
typedef unsigned int GNUNET_PEER_Id;
@@ -82,10 +81,11 @@ GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta);
* Decrement multiple RCs of peer identities by one.
*
* @param ids array of PIDs to decrement the RCs of
- * @param count size of the ids array
+ * @param count size of the @a ids array
*/
void
-GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids, unsigned int count);
+GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids,
+ unsigned int count);
/**
@@ -95,14 +95,15 @@ GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids, unsigned int count);
* @param pid where to write the normal peer identity
*/
void
-GNUNET_PEER_resolve (GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid);
+GNUNET_PEER_resolve (GNUNET_PEER_Id id,
+ struct GNUNET_PeerIdentity *pid);
/**
* Convert an interned PID to a normal peer identity.
*
* @param id interned PID to convert
- * @return pointer to peer identity, valid as long 'id' is valid
+ * @return pointer to peer identity, valid as long @a id is valid
*/
const struct GNUNET_PeerIdentity *
GNUNET_PEER_resolve2 (GNUNET_PEER_Id id);
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index d1b341a8c..a511a0e7d 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -41,7 +41,7 @@ extern "C"
/**
* Version number of the transport API.
*/
-#define GNUNET_TRANSPORT_VERSION 0x00000001
+#define GNUNET_TRANSPORT_VERSION 0x00000002
/**
@@ -672,7 +672,7 @@ struct GNUNET_TRANSPORT_PeerMonitoringContext;
* @param cls closure
* @param peer peer this update is about,
* NULL if this is the final last callback for a iteration operation
- * @param address address, NULL for disconnect notification in monitor mode
+ * @param address address, NULL if this is the final callback for iteration op
* @param state current state this peer is in
* @param state_timeout timeout for the current state of the peer
*/
@@ -789,13 +789,11 @@ enum GNUNET_TRANSPORT_ValidationState
* the current state of the validation entry,
*
* If the monitoring was called with `one_shot==GNUNET_YES`, a final callback
- * with `peer==NULL` and `address==NULL` is executed.
+ * with `address==NULL` is executed.
*
* @param cls closure
- * @param peer peer this update is about,
+ * @param address address this update is about,
* NULL if this is the final last callback for a iteration operation
- * @param address address,
- * NULL for disconnect notification in monitor mode
* @param last_validation when was this address last validated
* @param valid_until when does this address expire
* @param next_validation time of the next validation operation
@@ -803,7 +801,6 @@ enum GNUNET_TRANSPORT_ValidationState
*/
typedef void
(*GNUNET_TRANSPORT_ValidationIterateCallback) (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,
@@ -1061,5 +1058,3 @@ GNUNET_TRANSPORT_monitor_plugins_cancel (struct GNUNET_TRANSPORT_PluginMonitor *
/* ifndef GNUNET_TRANSPORT_SERVICE_H */
#endif
/* end of gnunet_transport_service.h */
-
-
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 3ff5ab172..ca0f6b813 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -161,7 +161,7 @@ struct BlacklistCheckContext *bc_tail;
* Transmit our HELLO message to the given (connected) neighbour.
*
* @param cls the 'HELLO' message
- * @param target a connected neighbour
+ * @param peer identity of the peer
* @param address the address
* @param state current state this peer is in
* @param state_timeout timeout for the current state of the peer
@@ -169,22 +169,27 @@ struct BlacklistCheckContext *bc_tail;
* @param bandwidth_out outbound quota in NBO
*/
static void
-transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target,
- const struct GNUNET_HELLO_Address *address,
- enum GNUNET_TRANSPORT_PeerState state,
- struct GNUNET_TIME_Absolute state_timeout,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
+transmit_our_hello (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Address *address,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
{
const struct GNUNET_MessageHeader *hello = cls;
- if (GNUNET_NO == GST_neighbours_test_connected (target))
+ if (GNUNET_NO == GST_neighbours_test_connected (peer))
return;
- GST_neighbours_send (target, hello, ntohs (hello->size), hello_expiration,
+ GST_neighbours_send (peer,
+ hello,
+ ntohs (hello->size),
+ hello_expiration,
NULL, NULL);
}
+
/**
* My HELLO has changed. Tell everyone who should know.
*
@@ -202,7 +207,6 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
/**
* We received some payload. Prepare to pass it on to our clients.
*
- * @param peer (claimed) identity of the other peer
* @param address address and (claimed) identity of the other peer
* @param session identifier used for this session (NULL for plugins
* that do not offer bi-directional communication to the sender
@@ -211,8 +215,7 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
* @return how long the plugin should wait until receiving more data
*/
static struct GNUNET_TIME_Relative
-process_payload (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
+process_payload (const struct GNUNET_HELLO_Address *address,
struct Session *session,
const struct GNUNET_MessageHeader *message)
{
@@ -224,14 +227,16 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
char buf[size] GNUNET_ALIGN;
do_forward = GNUNET_SYSERR;
- ret = GST_neighbours_calculate_receive_delay (peer, msg_size, &do_forward);
- if (! GST_neighbours_test_connected (peer))
+ ret = GST_neighbours_calculate_receive_delay (&address->peer,
+ msg_size,
+ &do_forward);
+ if (! GST_neighbours_test_connected (&address->peer))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Discarded %u bytes type %u payload from peer `%s'\n",
msg_size,
ntohs (message->type),
- GNUNET_i2s (peer));
+ GNUNET_i2s (&address->peer));
GNUNET_STATISTICS_update (GST_stats, gettext_noop
("# bytes payload discarded due to not connected peer"),
msg_size,
@@ -244,7 +249,7 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
im = (struct InboundMessage *) buf;
im->header.size = htons (size);
im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
- im->peer = *peer;
+ im->peer = address->peer;
memcpy (&im[1], message, ntohs (message->size));
GST_clients_broadcast (&im->header, GNUNET_YES);
return ret;
@@ -427,8 +432,7 @@ GST_receive_callback (void *cls,
gettext_noop ("# bytes total received"),
ntohs (message->size),
GNUNET_NO);
- GST_neighbours_notify_data_recv (&address->peer,
- address,
+ GST_neighbours_notify_data_recv (address,
session,
message);
switch (type)
@@ -489,7 +493,6 @@ GST_receive_callback (void *cls,
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK:
if (GNUNET_OK !=
GST_neighbours_handle_session_syn_ack (message,
- &address->peer,
address,
session))
{
@@ -500,7 +503,6 @@ GST_receive_callback (void *cls,
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
if (GNUNET_OK !=
GST_neighbours_handle_session_ack (message,
- &address->peer,
address,
session))
{
@@ -524,12 +526,10 @@ GST_receive_callback (void *cls,
gettext_noop ("# bytes payload received"),
ntohs (message->size),
GNUNET_NO);
- GST_neighbours_notify_payload_recv (&address->peer,
- address,
+ GST_neighbours_notify_payload_recv (address,
session,
message);
- ret = process_payload (&address->peer,
- address,
+ ret = process_payload (address,
session,
message);
break;
@@ -838,8 +838,7 @@ ats_request_address_change (void *cls,
return;
}
- GST_neighbours_switch_to_address (&address->peer,
- address,
+ GST_neighbours_switch_to_address (address,
session,
bandwidth_in, bandwidth_out);
}
@@ -911,12 +910,12 @@ neighbours_disconnect_notification (void *cls,
* active address.
*
* @param cls closure
- * @param peer peer this update is about (never NULL)
- * @param address address, NULL on disconnect
+ * @param peer identity of the peer
+ * @param address address possibly NULL if peer is not connected
* @param state current state this peer is in
* @param state_timeout timeout for the current state of the peer
- * @param bandwidth_in bandwidth assigned inbound
- * @param bandwidth_out bandwidth assigned outbound
+ * @param bandwidth_in bandwidth assigned inbound, 0 on disconnect
+ * @param bandwidth_out bandwidth assigned outbound, 0 on disconnect
*/
static void
neighbours_changed_notification (void *cls,
@@ -930,10 +929,10 @@ neighbours_changed_notification (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n",
GNUNET_i2s (peer),
- (NULL != address) ? GST_plugins_a2s (address) : "<none>",
+ GST_plugins_a2s (address),
GNUNET_TRANSPORT_ps2s (state),
GNUNET_STRINGS_absolute_time_to_string (state_timeout));
-
+ /* FIXME: include bandwidth in notification! */
GST_clients_broadcast_peer_notification (peer,
address,
state,
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c
index bc20038f1..0d61365d8 100644
--- a/src/transport/gnunet-service-transport_ats.c
+++ b/src/transport/gnunet-service-transport_ats.c
@@ -314,7 +314,7 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
&ai->address->peer,
ai,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
- publish_p2a_stat_update ();
+ publish_p2a_stat_update ();
}
@@ -534,11 +534,11 @@ destroy_ai (void *cls,
{
struct AddressInfo *ai = value;
- GNUNET_HELLO_address_free (ai->address);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_remove (p2a,
key,
ai));
+ GNUNET_HELLO_address_free (ai->address);
GNUNET_free (ai);
return GNUNET_OK;
}
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c
index f1904a5d3..d19ff2e9b 100644
--- a/src/transport/gnunet-service-transport_blacklist.c
+++ b/src/transport/gnunet-service-transport_blacklist.c
@@ -501,7 +501,7 @@ struct TestConnectionContext
* blacklisting client.
*
* @param cls the `struct TestConnectionContext *`
- * @param peer neighbour's identity
+ * @param peer identity of the peer
* @param address the address
* @param state current state this peer is in
* @param state_timeout timeout for the current state of the peer
@@ -509,18 +509,21 @@ struct TestConnectionContext
* @param bandwidth_out bandwidth assigned outbound
*/
static void
-test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
- enum GNUNET_TRANSPORT_PeerState state,
- struct GNUNET_TIME_Absolute state_timeout,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
+test_connection_ok (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Address *address,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
{
struct TestConnectionContext *tcc = cls;
struct GST_BlacklistCheck *bc;
bc = GNUNET_new (struct GST_BlacklistCheck);
- GNUNET_CONTAINER_DLL_insert(bc_head, bc_tail, bc);
+ GNUNET_CONTAINER_DLL_insert (bc_head,
+ bc_tail,
+ bc);
bc->peer = *peer;
bc->cont = &confirm_or_drop_neighbour;
bc->cont_cls = NULL;
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index 3cbd80452..35229c59d 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -1181,7 +1181,6 @@ struct IterationContext
* Output information of validation entries to the given client.
*
* @param cls the `struct IterationContext *`
- * @param peer identity of the neighbour
* @param address the address
* @param last_validation point in time when last validation was performed
* @param valid_until point in time how long address is valid
@@ -1190,7 +1189,6 @@ struct IterationContext
*/
static void
send_validation_information (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,
@@ -1201,13 +1199,13 @@ send_validation_information (void *cls,
struct ValidationIterateResponseMessage *msg;
if ( (GNUNET_YES != pc->all) &&
- (0 != memcmp (peer, &pc->id, sizeof (pc->id))) )
+ (0 != memcmp (&address->peer, &pc->id, sizeof (pc->id))) )
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending information about for validation entry for peer `%s' using address `%s'\n",
- GNUNET_i2s(peer),
+ GNUNET_i2s (&address->peer),
(NULL != address) ? GST_plugins_a2s (address) : "<none>");
- msg = compose_validation_iterate_response_message (peer, address);
+ msg = compose_validation_iterate_response_message (&address->peer, address);
msg->last_validation = GNUNET_TIME_absolute_hton(last_validation);
msg->valid_until = GNUNET_TIME_absolute_hton(valid_until);
msg->next_validation = GNUNET_TIME_absolute_hton(next_validation);
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 48bd8cdf8..8119d4cba 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -377,7 +377,7 @@ struct NeighbourMapEntry
/**
* Time where we should cut the connection (timeout) if we don't
* make progress in the state machine (or get a KEEPALIVE_RESPONSE
- * if we are in S_CONNECTED).
+ * if we are in #S_CONNECTED).
*/
struct GNUNET_TIME_Absolute timeout;
@@ -418,7 +418,7 @@ struct NeighbourMapEntry
* (once we have an address to use and the peer has been allowed by our
* blacklist). Initially set to #ACK_UNDEFINED. Set to #ACK_SEND_SYN_ACK
* if we need to send a SYN_ACK. Set to #ACK_SEND_ACK if we did
- * send a SYN_ACK and should go to 'S_CONNECTED' upon receiving a
+ * send a SYN_ACK and should go to #S_CONNECTED upon receiving a
* 'ACK' (regardless of what our own state machine might say).
*/
enum GST_ACK_State ack_state;
@@ -659,18 +659,21 @@ free_address (struct NeighbourAddress *na)
* @param s the new state
*/
static void
-set_state (struct NeighbourMapEntry *n, enum GNUNET_TRANSPORT_PeerState s)
+set_state (struct NeighbourMapEntry *n,
+ enum GNUNET_TRANSPORT_PeerState s)
{
n->state = s;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Neighbour `%s' changed state to %s\n",
- GNUNET_i2s (&n->id),
- GNUNET_TRANSPORT_ps2s(s));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Neighbour `%s' changed state to %s\n",
+ GNUNET_i2s (&n->id),
+ GNUNET_TRANSPORT_ps2s(s));
neighbour_change_cb (callback_cls,
- &n->id,
- n->primary_address.address,
- n->state, n->timeout,
- n->primary_address.bandwidth_in,
- n->primary_address.bandwidth_out);
+ &n->id,
+ n->primary_address.address,
+ n->state,
+ n->timeout,
+ n->primary_address.bandwidth_in,
+ n->primary_address.bandwidth_out);
}
@@ -683,21 +686,23 @@ set_state (struct NeighbourMapEntry *n, enum GNUNET_TRANSPORT_PeerState s)
*/
static void
set_state_and_timeout (struct NeighbourMapEntry *n,
- enum GNUNET_TRANSPORT_PeerState s,
- struct GNUNET_TIME_Absolute timeout)
+ enum GNUNET_TRANSPORT_PeerState s,
+ struct GNUNET_TIME_Absolute timeout)
{
n->state = s;
n->timeout = timeout;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Neighbour `%s' changed state to %s with timeout %s\n",
- GNUNET_i2s (&n->id),
- GNUNET_TRANSPORT_ps2s(s),
- GNUNET_STRINGS_absolute_time_to_string (timeout));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Neighbour `%s' changed state to %s with timeout %s\n",
+ GNUNET_i2s (&n->id),
+ GNUNET_TRANSPORT_ps2s(s),
+ GNUNET_STRINGS_absolute_time_to_string (timeout));
neighbour_change_cb (callback_cls,
- &n->id,
- n->primary_address.address,
- n->state, n->timeout,
- n->primary_address.bandwidth_in,
- n->primary_address.bandwidth_out);
+ &n->id,
+ n->primary_address.address,
+ n->state,
+ n->timeout,
+ n->primary_address.bandwidth_in,
+ n->primary_address.bandwidth_out);
}
@@ -709,7 +714,7 @@ set_state_and_timeout (struct NeighbourMapEntry *n,
*/
static void
set_timeout (struct NeighbourMapEntry *n,
- struct GNUNET_TIME_Absolute timeout)
+ struct GNUNET_TIME_Absolute timeout)
{
n->timeout = timeout;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -717,11 +722,11 @@ set_timeout (struct NeighbourMapEntry *n,
GNUNET_i2s (&n->id),
GNUNET_STRINGS_absolute_time_to_string (timeout));
neighbour_change_cb (callback_cls,
- &n->id,
- n->primary_address.address,
- n->state, n->timeout,
- n->primary_address.bandwidth_in,
- n->primary_address.bandwidth_out);
+ &n->id,
+ n->primary_address.address,
+ n->state, n->timeout,
+ n->primary_address.bandwidth_in,
+ n->primary_address.bandwidth_out);
}
@@ -876,7 +881,8 @@ set_primary_address (struct NeighbourMapEntry *n,
neighbour_change_cb (callback_cls,
&n->id,
n->primary_address.address,
- n->state, n->timeout,
+ n->state,
+ n->timeout,
n->primary_address.bandwidth_in,
n->primary_address.bandwidth_out);
}
@@ -891,16 +897,16 @@ set_primary_address (struct NeighbourMapEntry *n,
static void
unset_primary_address (struct NeighbourMapEntry *n)
{
- /* Unset primary address */
- free_address (&n->primary_address);
-
- /* Notify monitoring about it */
+ /* Notify monitoring about change */
neighbour_change_cb (callback_cls,
&n->id,
- NULL,
- n->state, n->timeout,
- n->primary_address.bandwidth_in,
- n->primary_address.bandwidth_out);
+ n->primary_address.address,
+ n->state,
+ n->timeout,
+ GNUNET_BANDWIDTH_value_init (0),
+ GNUNET_BANDWIDTH_value_init (0));
+ /* Unset primary address */
+ free_address (&n->primary_address);
}
@@ -1048,8 +1054,9 @@ send_with_session (struct NeighbourMapEntry *n,
cont, cont_cls)))) &&
(NULL != cont))
cont (cont_cls, &n->id, GNUNET_SYSERR, msgbuf_size, 0);
- GST_neighbours_notify_data_sent (&n->id,
- n->primary_address.address, n->primary_address.session, msgbuf_size);
+ GST_neighbours_notify_data_sent (n->primary_address.address,
+ n->primary_address.session,
+ msgbuf_size);
GNUNET_break (NULL != papi);
return result;
}
@@ -1841,8 +1848,7 @@ send_syn (struct NeighbourAddress *na)
break;
}
}
- GST_neighbours_notify_data_sent (&na->address->peer,
- na->address,
+ GST_neighbours_notify_data_sent (na->address,
na->session,
sizeof (struct TransportSynMessage));
}
@@ -1901,8 +1907,8 @@ send_session_connect_ack_cont (void *cls,
*/
static void
send_connect_ack_message (const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_TIME_Absolute timestamp)
+ struct Session *session,
+ struct GNUNET_TIME_Absolute timestamp)
{
struct GNUNET_TRANSPORT_PluginFunctions *papi;
struct TransportSynMessage connect_msg;
@@ -2738,7 +2744,6 @@ switch_address_bl_check_cont (void *cls,
* Before accepting this addresses and actively using it, a blacklist check
* is performed. If this blacklist check fails the address will be destroyed.
*
- * @param peer identity of the peer to switch the address for
* @param address address of the other peer,
* @param session session to use or NULL if transport should initiate a session
* @param bandwidth_in inbound quota to be used when connection is up,
@@ -2747,8 +2752,7 @@ switch_address_bl_check_cont (void *cls,
* 0 to disconnect from peer
*/
void
-GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
+GST_neighbours_switch_to_address (const struct GNUNET_HELLO_Address *address,
struct Session *session,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
@@ -2759,13 +2763,13 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ATS has decided on an address for peer %s\n",
- GNUNET_i2s (peer));
+ GNUNET_i2s (&address->peer));
GNUNET_assert (NULL != address->transport_name);
- if (NULL == (n = lookup_neighbour (peer)))
+ if (NULL == (n = lookup_neighbour (&address->peer)))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %s is unknown, suggestion ignored\n",
- GNUNET_i2s (peer));
+ GNUNET_i2s (&address->peer));
return;
}
@@ -2786,12 +2790,15 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ATS suggests %s address '%s' session %p for "
- "peer `%s' in state %s/%s \n",
- GNUNET_HELLO_address_check_option (address,
- GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound",
- GST_plugins_a2s (address), session, GNUNET_i2s (peer),
- GNUNET_TRANSPORT_ps2s (n->state), print_ack_state (n->ack_state));
+ "ATS suggests %s address '%s' session %p for "
+ "peer `%s' in state %s/%s \n",
+ GNUNET_HELLO_address_check_option (address,
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound",
+ GST_plugins_a2s (address),
+ session,
+ GNUNET_i2s (&address->peer),
+ GNUNET_TRANSPORT_ps2s (n->state),
+ print_ack_state (n->ack_state));
/* Perform blacklist check */
blc_ctx = GNUNET_new (struct BlacklistCheckSwitchContext);
@@ -2802,7 +2809,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
GNUNET_CONTAINER_DLL_insert (pending_bc_head,
pending_bc_tail,
blc_ctx);
- if (NULL != (blc = GST_blacklist_test_allowed (peer,
+ if (NULL != (blc = GST_blacklist_test_allowed (&address->peer,
address->transport_name,
&switch_address_bl_check_cont,
blc_ctx)))
@@ -2908,14 +2915,13 @@ utilization_transmission (void *cls,
void
-GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
+GST_neighbours_notify_data_recv (const struct GNUNET_HELLO_Address *address,
struct Session *session,
const struct GNUNET_MessageHeader *message)
{
struct NeighbourMapEntry *n;
- n = lookup_neighbour (peer);
+ n = lookup_neighbour (&address->peer);
if (NULL == n)
return;
n->util_total_bytes_recv += ntohs(message->size);
@@ -2923,13 +2929,13 @@ GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
void
-GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
+GST_neighbours_notify_payload_recv (const struct GNUNET_HELLO_Address *address,
struct Session *session,
const struct GNUNET_MessageHeader *message)
{
struct NeighbourMapEntry *n;
- n = lookup_neighbour (peer);
+
+ n = lookup_neighbour (&address->peer);
if (NULL == n)
return;
n->util_payload_bytes_recv += ntohs(message->size);
@@ -2937,13 +2943,13 @@ GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer,
void
-GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
+GST_neighbours_notify_data_sent (const struct GNUNET_HELLO_Address *address,
struct Session *session,
size_t size)
{
struct NeighbourMapEntry *n;
- n = lookup_neighbour (peer);
+
+ n = lookup_neighbour (&address->peer);
if (NULL == n)
return;
if (n->primary_address.session != session)
@@ -3154,9 +3160,8 @@ send_session_ack_message (struct NeighbourMapEntry *n)
*/
int
GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *message,
- const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
- struct Session *session)
+ const struct GNUNET_HELLO_Address *address,
+ struct Session *session)
{
const struct TransportSynMessage *scm;
struct GNUNET_TIME_Absolute ts;
@@ -3164,7 +3169,7 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received SYN_ACK message from peer `%s'\n",
- GNUNET_i2s (peer));
+ GNUNET_i2s (&address->peer));
if (ntohs (message->size) != sizeof (struct TransportSynMessage))
{
@@ -3177,7 +3182,7 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag
1, GNUNET_NO);
scm = (const struct TransportSynMessage *) message;
GNUNET_break_op (ntohl (scm->reserved) == 0);
- if (NULL == (n = lookup_neighbour (peer)))
+ if (NULL == (n = lookup_neighbour (&address->peer)))
{
GNUNET_STATISTICS_update (GST_stats,
gettext_noop
@@ -3211,7 +3216,8 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag
gettext_noop ("# peers connected"),
++neighbours_connected,
GNUNET_NO);
- connect_notify_cb (callback_cls, &n->id,
+ connect_notify_cb (callback_cls,
+ &n->id,
n->primary_address.bandwidth_in,
n->primary_address.bandwidth_out);
/* Tell ATS that the outbound session we created to send SYN was successful */
@@ -3433,15 +3439,12 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
* connected. Otherwise, do nothing.
*
* @param message possibly a 'struct SessionConnectMessage' (check format)
- * @param peer identity of the peer to switch the address for
- * @param address address of the other peer, NULL if other peer
- * connected to us
+ * @param address address of the other peer
* @param session session to use (or NULL)
* @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
*/
int
GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
- const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
struct Session *session)
{
@@ -3449,7 +3452,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received ACK message from peer `%s'\n",
- GNUNET_i2s (peer));
+ GNUNET_i2s (&address->peer));
if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader))
{
GNUNET_break_op (0);
@@ -3459,7 +3462,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
gettext_noop
("# ACK messages received"),
1, GNUNET_NO);
- if (NULL == (n = lookup_neighbour (peer)))
+ if (NULL == (n = lookup_neighbour (&address->peer)))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -3468,7 +3471,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received %s for peer `%s' in state %s/%s\n",
"ACK",
- GNUNET_i2s (peer),
+ GNUNET_i2s (&address->peer),
GNUNET_TRANSPORT_ps2s (n->state),
print_ack_state (n->ack_state));
@@ -3488,7 +3491,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Received unexpected ACK message from peer `%s' in state %s/%s\n",
- GNUNET_i2s (peer),
+ GNUNET_i2s (&address->peer),
GNUNET_TRANSPORT_ps2s (n->state),
print_ack_state (n->ack_state));
@@ -3502,14 +3505,14 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
if (GNUNET_NO == GST_neighbours_test_connected(&n->id))
{
/* Notify about connection */
- connect_notify_cb (callback_cls, &n->id,
- n->primary_address.bandwidth_in,
- n->primary_address.bandwidth_out);\
-
- GNUNET_STATISTICS_set (GST_stats,
- gettext_noop ("# peers connected"),
- ++neighbours_connected,
- GNUNET_NO);
+ connect_notify_cb (callback_cls,
+ &n->id,
+ n->primary_address.bandwidth_in,
+ n->primary_address.bandwidth_out);
+ GNUNET_STATISTICS_set (GST_stats,
+ gettext_noop ("# peers connected"),
+ ++neighbours_connected,
+ GNUNET_NO);
}
if (GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT == n->state)
@@ -3673,7 +3676,7 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer
/**
- * Closure for the neighbours_iterate function.
+ * Closure for the #neighbours_iterate() function.
*/
struct IteratorContext
{
@@ -3683,7 +3686,7 @@ struct IteratorContext
GST_NeighbourIterator cb;
/**
- * Closure for 'cb'.
+ * Closure for @e cb.
*/
void *cb_cls;
};
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h
index 744a3b913..0c07557d0 100644
--- a/src/transport/gnunet-service-transport_neighbours.h
+++ b/src/transport/gnunet-service-transport_neighbours.h
@@ -201,8 +201,8 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target);
* Function called for each neighbour.
*
* @param cls closure
- * @param neighbour identity of the neighbour
- * @param address the address (or NULL)
+ * @param peer identity of the neighbour
+ * @param address the address of the neighbour
* @param state current state the peer is in
* @param state_timeout timeout for this state
* @param bandwidth_in inbound quota in NBO
@@ -210,7 +210,7 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target);
*/
typedef void
(*GST_NeighbourIterator) (void *cls,
- const struct GNUNET_PeerIdentity *neighbour,
+ const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
enum GNUNET_TRANSPORT_PeerState state,
struct GNUNET_TIME_Absolute state_timeout,
@@ -245,8 +245,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
* FIXME
*/
void
-GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
+GST_neighbours_notify_data_recv (const struct GNUNET_HELLO_Address *address,
struct Session *session,
const struct GNUNET_MessageHeader *message);
@@ -255,8 +254,7 @@ GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
* FIXME
*/
void
-GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
+GST_neighbours_notify_payload_recv (const struct GNUNET_HELLO_Address *address,
struct Session *session,
const struct GNUNET_MessageHeader *message);
@@ -273,8 +271,7 @@ GST_neighbours_notify_payload_sent (const struct GNUNET_PeerIdentity *peer,
* FIXME
*/
void
-GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
+GST_neighbours_notify_data_sent (const struct GNUNET_HELLO_Address *address,
struct Session *session,
size_t size);
@@ -283,16 +280,13 @@ GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer,
* For an existing neighbour record, set the active connection to
* use the given address.
*
- * @param peer identity of the peer to switch the address for
- * @param address address of the other peer, NULL if other peer
- * connected to us
+ * @param address address of the other peer to start using
* @param session session to use (or NULL)
* @param bandwidth_in inbound quota to be used when connection is up
* @param bandwidth_out outbound quota to be used when connection is up
*/
void
-GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address,
+GST_neighbours_switch_to_address (const struct GNUNET_HELLO_Address *address,
struct Session *session,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
@@ -316,15 +310,12 @@ GST_neighbours_handle_session_syn (const struct GNUNET_MessageHeader *message,
* Consider switching to it.
*
* @param message possibly a `struct SessionConnectMessage` (check format)
- * @param peer identity of the peer to switch the address for
- * @param address address of the other peer, NULL if other peer
- * connected to us
+ * @param address address of the other peer
* @param session session to use (or NULL)
* @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
*/
int
GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *message,
- const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
struct Session *session);
@@ -335,15 +326,12 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag
* connected. Otherwise, do nothing.
*
* @param message possibly a 'struct SessionConnectMessage' (check format)
- * @param peer identity of the peer to switch the address for
- * @param address address of the other peer, NULL if other peer
- * connected to us
+ * @param address address of the other peer
* @param session session to use (or NULL)
* @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
*/
int
GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
- const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
struct Session *session);
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c
index 44e6a2a65..e8b795f9d 100644
--- a/src/transport/gnunet-service-transport_plugins.c
+++ b/src/transport/gnunet-service-transport_plugins.c
@@ -356,10 +356,7 @@ GST_plugins_a2s (const struct GNUNET_HELLO_Address *address)
static const char *s;
if (NULL == address)
- {
- GNUNET_break (0); /* a HELLO address cannot be NULL */
- return "<invalid>";
- }
+ return "<NULL>";
if (0 == address->address_length)
return TRANSPORT_SESSION_INBOUND_STRING; /* Addresse with length 0 are inbound, address->address itself may be NULL */
api = GST_plugins_printer_find (address->transport_name);
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 59b99b8fc..d0a731789 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -190,11 +190,6 @@ struct ValidationEntry
struct GST_BlacklistCheck *bc;
/**
- * Public key of the peer.
- */
- struct GNUNET_CRYPTO_EddsaPublicKey public_key;
-
- /**
* Cached PONG signature
*/
struct GNUNET_CRYPTO_EddsaSignature pong_sig_cache;
@@ -388,7 +383,7 @@ validation_entry_match (void *cls,
struct ValidationEntryMatchContext *vemc = cls;
struct ValidationEntry *ve = value;
- if (0 == GNUNET_HELLO_address_cmp (ve->address,
+ if (0 == GNUNET_HELLO_address_cmp (ve->address,
vemc->address))
{
vemc->ve = ve;
@@ -447,7 +442,7 @@ cleanup_validation_entry (void *cls,
}
GNUNET_break (GNUNET_OK ==
GNUNET_CONTAINER_multipeermap_remove (validation_map,
- &ve->address->peer,
+ &ve->address->peer,
ve));
if (GNUNET_YES == ve->known_to_ats)
{
@@ -585,10 +580,10 @@ transmit_ping_if_allowed (void *cls,
* [HELLO][TransportPingMessage][Transport name][Address] */
memcpy (message_buf, hello, hsize);
memcpy (&message_buf[hsize],
- &ping,
+ &ping,
sizeof (struct TransportPingMessage));
memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize],
- ve->address->transport_name,
+ ve->address->transport_name,
slen);
memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize],
ve->address->address,
@@ -624,7 +619,7 @@ transmit_ping_if_allowed (void *cls,
GST_plugins_a2s (ve->address));
GNUNET_break(0);
}
- GST_neighbours_notify_data_sent (pid, ve->address, session, tsize);
+ GST_neighbours_notify_data_sent (ve->address, session, tsize);
}
else
{
@@ -709,7 +704,7 @@ revalidate_address (void *cls,
ve->revalidation_task =
GNUNET_SCHEDULER_add_delayed (delay,
&revalidate_address, ve);
- ve->next_validation = GNUNET_TIME_relative_to_absolute (delay);
+ ve->next_validation = GNUNET_TIME_relative_to_absolute (delay);
return;
}
/* check if globally we have too many active validations at a
@@ -726,7 +721,7 @@ revalidate_address (void *cls,
GST_plugins_a2s (ve->address));
ve->revalidation_task =
GNUNET_SCHEDULER_add_delayed (blocked_for, &revalidate_address, ve);
- ve->next_validation = GNUNET_TIME_relative_to_absolute (blocked_for);
+ ve->next_validation = GNUNET_TIME_relative_to_absolute (blocked_for);
return;
}
@@ -769,14 +764,12 @@ revalidate_address (void *cls,
* the given address and transport. If none exists, create one (but
* without starting any validation).
*
- * @param public_key public key of the peer, NULL for unknown
* @param address address to find
* @return validation entry matching the given specifications, NULL
* if we don't have an existing entry and no public key was given
*/
static struct ValidationEntry *
-find_validation_entry (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key,
- const struct GNUNET_HELLO_Address *address)
+find_validation_entry (const struct GNUNET_HELLO_Address *address)
{
struct ValidationEntryMatchContext vemc;
struct ValidationEntry *ve;
@@ -788,12 +781,9 @@ find_validation_entry (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key,
&validation_entry_match, &vemc);
if (NULL != (ve = vemc.ve))
return ve;
- if (NULL == public_key)
- return NULL;
ve = GNUNET_new (struct ValidationEntry);
ve->in_use = GNUNET_SYSERR; /* not defined */
ve->address = GNUNET_HELLO_address_copy (address);
- ve->public_key = *public_key;
ve->pong_sig_valid_until = GNUNET_TIME_absolute_get_zero_();
memset (&ve->pong_sig_cache, '\0', sizeof (struct GNUNET_CRYPTO_EddsaSignature));
ve->latency = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -828,12 +818,10 @@ add_valid_address (void *cls,
struct ValidationEntry *ve;
struct GNUNET_PeerIdentity pid;
struct GNUNET_ATS_Information ats;
- struct GNUNET_CRYPTO_EddsaPublicKey public_key;
if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
return GNUNET_OK; /* expired */
- if ((GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) ||
- (GNUNET_OK != GNUNET_HELLO_get_key (hello, &public_key)))
+ if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
{
GNUNET_break (0);
return GNUNET_OK; /* invalid HELLO !? */
@@ -852,7 +840,7 @@ add_valid_address (void *cls,
return GNUNET_OK;
}
- ve = find_validation_entry (&public_key, address);
+ ve = find_validation_entry (address);
ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until,
expiration);
if (NULL == ve->revalidation_task)
@@ -967,7 +955,6 @@ GST_validation_stop ()
* Send the given PONG to the given address.
*
* @param cls the PONG message
- * @param public_key public key for the peer, never NULL
* @param valid_until is ZERO if we never validated the address,
* otherwise a time up to when we consider it (or was) valid
* @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO)
@@ -977,7 +964,6 @@ GST_validation_stop ()
*/
static void
multicast_pong (void *cls,
- const struct GNUNET_CRYPTO_EddsaPublicKey *public_key,
struct GNUNET_TIME_Absolute valid_until,
struct GNUNET_TIME_Absolute validation_block,
const struct GNUNET_HELLO_Address *address)
@@ -1005,8 +991,7 @@ multicast_pong (void *cls,
PONG_PRIORITY,
ACCEPTABLE_PING_DELAY,
NULL, NULL);
- GST_neighbours_notify_data_sent (&address->peer,
- address,
+ GST_neighbours_notify_data_sent (address,
session,
pong->header.size);
@@ -1234,12 +1219,13 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
else
{
ret = papi->send (papi->cls, session,
- (const char *) pong, ntohs (pong->header.size),
+ (const char *) pong,
+ ntohs (pong->header.size),
PONG_PRIORITY, ACCEPTABLE_PING_DELAY,
NULL, NULL);
if (-1 != ret)
- GST_neighbours_notify_data_sent (sender,
- sender_address, session,
+ GST_neighbours_notify_data_sent (sender_address,
+ session,
pong->header.size);
}
}
@@ -1270,28 +1256,10 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
/**
- * Context for the #validate_address_iterator() function
- */
-struct ValidateAddressContext
-{
- /**
- * Hash of the public key of the peer whose address is being validated.
- */
- struct GNUNET_PeerIdentity pid;
-
- /**
- * Public key of the peer whose address is being validated.
- */
- struct GNUNET_CRYPTO_EddsaPublicKey public_key;
-
-};
-
-
-/**
* Iterator callback to go over all addresses and try to validate them
* (unless blocked or already validated).
*
- * @param cls pointer to a `struct ValidateAddressContext *`
+ * @param cls NULL
* @param address the address
* @param expiration expiration time
* @return #GNUNET_OK (keep the address)
@@ -1301,10 +1269,8 @@ validate_address_iterator (void *cls,
const struct GNUNET_HELLO_Address *address,
struct GNUNET_TIME_Absolute expiration)
{
- const struct ValidateAddressContext *vac = cls;
struct GNUNET_TRANSPORT_PluginFunctions * papi;
struct ValidationEntry *ve;
- struct GNUNET_TIME_Relative canonical_delay;
if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
{
@@ -1312,34 +1278,13 @@ validate_address_iterator (void *cls,
"Skipping expired address from HELLO\n");
return GNUNET_OK; /* expired */
}
- ve = find_validation_entry (&vac->public_key, address);
-
- papi = GST_plugins_find (ve->address->transport_name);
- if (papi == NULL)
+ papi = GST_plugins_find (address->transport_name);
+ if (NULL == papi)
{
- /* This plugin is currently unvailable ... retry later */
- if (NULL == ve->revalidation_task)
- {
- if (GNUNET_YES == ve->in_use)
- canonical_delay = CONNECTED_PING_FREQUENCY;
- else if (GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value_us > 0)
- canonical_delay = VALIDATED_PING_FREQUENCY;
- else
- canonical_delay = UNVALIDATED_PING_KEEPALIVE;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Plugin `%s' unavailable, validation process for peer `%s' delayed for %llu ms\n",
- ve->address->transport_name,
- GNUNET_i2s (&ve->address->peer),
- (long long unsigned) canonical_delay.rel_value_us / 1000);
-
- ve->revalidation_task = GNUNET_SCHEDULER_add_delayed (canonical_delay,
- &revalidate_address, ve);
- }
+ /* This plugin is currently unvailable ... ignore */
return GNUNET_OK;
}
-
-
+ ve = find_validation_entry (address);
if (NULL == ve->revalidation_task)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1427,7 +1372,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
address.address_length = addrlen;
address.transport_name = tname;
address.local_info = GNUNET_HELLO_ADDRESS_INFO_NONE;
- ve = find_validation_entry (NULL, &address);
+ ve = find_validation_entry (&address);
if ((NULL == ve) || (GNUNET_NO == ve->expecting_pong))
{
GNUNET_STATISTICS_update (GST_stats,
@@ -1437,8 +1382,8 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
return GNUNET_OK;
}
/* now check that PONG is well-formed */
- if (0 != memcmp (&ve->address->peer,
- sender,
+ if (0 != memcmp (&ve->address->peer,
+ sender,
sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break_op (0);
@@ -1479,7 +1424,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
/* Do expensive verification */
sig_res = GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
&pong->purpose, &pong->signature,
- &ve->public_key);
+ &ve->address->peer.public_key);
if (sig_res == GNUNET_SYSERR)
{
GNUNET_break_op (0);
@@ -1549,7 +1494,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
/* build HELLO to store in PEERINFO */
ve->copied = GNUNET_NO;
- hello = GNUNET_HELLO_create (&ve->public_key,
+ hello = GNUNET_HELLO_create (&ve->address->peer.public_key,
&add_valid_peer_address, ve,
GNUNET_NO);
GNUNET_PEERINFO_add_peer (GST_peerinfo, hello, NULL, NULL);
@@ -1570,41 +1515,43 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
{
const struct GNUNET_HELLO_Message *hm =
(const struct GNUNET_HELLO_Message *) hello;
- struct ValidateAddressContext vac;
+ struct GNUNET_PeerIdentity pid;
struct GNUNET_HELLO_Message *h;
int friend;
friend = GNUNET_HELLO_is_friend_only (hm);
if ( ( (GNUNET_YES != friend) &&
(GNUNET_NO != friend) ) ||
- (GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) ||
- (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key)))
+ (GNUNET_OK != GNUNET_HELLO_get_id (hm, &pid)) )
{
/* malformed HELLO */
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
if (0 ==
- memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity)))
+ memcmp (&GST_my_identity,
+ &pid,
+ sizeof (struct GNUNET_PeerIdentity)))
return GNUNET_OK;
/* Add peer identity without addresses to peerinfo service */
- h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL, friend);
+ h = GNUNET_HELLO_create (&pid.public_key, NULL, NULL, friend);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Validation received new %s message for peer `%s' with size %u\n"),
"HELLO",
- GNUNET_i2s (&vac.pid),
+ GNUNET_i2s (&pid),
ntohs (hello->size));
GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Adding `%s' without addresses for peer `%s'\n"), "HELLO",
- GNUNET_i2s (&vac.pid));
+ GNUNET_i2s (&pid));
GNUNET_free (h);
GNUNET_assert (NULL ==
- GNUNET_HELLO_iterate_addresses (hm, GNUNET_NO,
+ GNUNET_HELLO_iterate_addresses (hm,
+ GNUNET_NO,
&validate_address_iterator,
- &vac));
+ NULL));
return GNUNET_OK;
}
@@ -1644,7 +1591,6 @@ iterate_addresses (void *cls,
struct ValidationEntry *ve = value;
ic->cb (ic->cb_cls,
- &ve->public_key,
ve->valid_until,
ve->revalidation_block,
ve->address);
@@ -1662,7 +1608,8 @@ iterate_addresses (void *cls,
*/
void
GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
- GST_ValidationAddressCallback cb, void *cb_cls)
+ GST_ValidationAddressCallback cb,
+ void *cb_cls)
{
struct IteratorContext ic;
@@ -1691,8 +1638,11 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
{
struct ValidationEntry *ve;
+ if (GNUNET_HELLO_address_check_option (address,
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND))
+ return; /* ignore inbound for validation */
if (NULL != address)
- ve = find_validation_entry (NULL, address);
+ ve = find_validation_entry (address);
else
ve = NULL; /* FIXME: lookup based on session... */
if (NULL == ve)
@@ -1721,7 +1671,8 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
if (in_use == GNUNET_YES)
{
/* from now on, higher frequeny, so reschedule now */
- GNUNET_SCHEDULER_cancel (ve->revalidation_task);
+ if (NULL != ve->revalidation_task)
+ GNUNET_SCHEDULER_cancel (ve->revalidation_task);
ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
}
}
@@ -1731,15 +1682,13 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
* Query validation about the latest observed latency on a given
* address.
*
- * @param sender peer
* @param address the address
* @param session session
* @return observed latency of the address, FOREVER if the address was
* never successfully validated
*/
struct GNUNET_TIME_Relative
-GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_HELLO_Address *address,
+GST_validation_get_address_latency (const struct GNUNET_HELLO_Address *address,
struct Session *session)
{
struct ValidationEntry *ve;
@@ -1749,7 +1698,7 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
GNUNET_break (0); // FIXME: support having latency only with session...
return GNUNET_TIME_UNIT_FOREVER_REL;
}
- ve = find_validation_entry (NULL, address);
+ ve = find_validation_entry (address);
if (NULL == ve)
return GNUNET_TIME_UNIT_FOREVER_REL;
return ve->latency;
@@ -1790,13 +1739,12 @@ validation_entries_iterate (void *cls,
struct ValidationIteratorContext *ic = cls;
struct ValidationEntry *ve = value;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Notifying about validation entry for peer `%s' address `%s' \n",
- GNUNET_i2s (&ve->address->peer),
+ GNUNET_i2s (&ve->address->peer),
GST_plugins_a2s (ve->address));
ic->cb (ic->cb_cls,
- &ve->address->peer,
- ve->address,
+ ve->address,
ve->send_time,
ve->valid_until,
ve->next_validation,
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h
index df2ef0ee8..ce5c427a1 100644
--- a/src/transport/gnunet-service-transport_validation.h
+++ b/src/transport/gnunet-service-transport_validation.h
@@ -67,15 +67,13 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
* Query validation about the latest observed latency on a given
* address.
*
- * @param sender peer
* @param address the address
* @param session session
* @return observed latency of the address, FOREVER if the address was
* never successfully validated
*/
struct GNUNET_TIME_Relative
-GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_HELLO_Address *address,
+GST_validation_get_address_latency (const struct GNUNET_HELLO_Address *address,
struct Session *session);
@@ -84,7 +82,6 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
* active address.
*
* @param cls closure
- * @param peer peer this update is about (never NULL)
* @param address address (never NULL)
* @param last_validation point in time when last validation was performed
* @param valid_until point in time how long address is valid
@@ -93,7 +90,6 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
*/
typedef void
(*GST_ValidationChangedCallback) (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,
@@ -166,7 +162,6 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
*/
typedef void
(*GST_ValidationAddressCallback) (void *cls,
- const struct GNUNET_CRYPTO_EddsaPublicKey *public_key,
struct GNUNET_TIME_Absolute valid_until,
struct GNUNET_TIME_Absolute validation_block,
const struct GNUNET_HELLO_Address *address);
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index f20e11852..f90ce9005 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -67,11 +67,6 @@ struct ValidationResolutionContext
struct ValidationResolutionContext *prev;
/**
- * Peer identity
- */
- struct GNUNET_PeerIdentity id;
-
- /**
* Address to resolve
*/
struct GNUNET_HELLO_Address *addrcp;
@@ -745,7 +740,6 @@ result_callback (void *cls,
/**
* Resolve address we got a validation state for to a string.
*
- * @param id peer identity the address is for
* @param address the address itself
* @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
* @param last_validation when was the address validated last
@@ -754,8 +748,7 @@ result_callback (void *cls,
* @param state where are we in the validation state machine
*/
static void
-resolve_validation_address (const struct GNUNET_PeerIdentity *id,
- const struct GNUNET_HELLO_Address *address,
+resolve_validation_address (const struct GNUNET_HELLO_Address *address,
int numeric,
struct GNUNET_TIME_Absolute last_validation,
struct GNUNET_TIME_Absolute valid_until,
@@ -795,7 +788,7 @@ process_validation_string (void *cls,
{
FPRINTF (stderr,
"Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
- GNUNET_i2s (&vc->id),
+ GNUNET_i2s (&vc->addrcp->peer),
vc->addrcp->transport_name,
(unsigned int) vc->addrcp->address_length);
}
@@ -816,7 +809,7 @@ process_validation_string (void *cls,
FPRINTF (stdout,
_("Peer `%s' %s %s\n\t%s%s\n\t%s%s\n\t%s%s\n"),
- GNUNET_i2s (&vc->id),
+ GNUNET_i2s (&vc->addrcp->peer),
(GNUNET_OK == res) ? address : "<invalid address>",
(monitor_validation) ? GNUNET_TRANSPORT_vs2s (vc->state) : "",
"Valid until : ", s_valid,
@@ -840,8 +833,7 @@ process_validation_string (void *cls,
(note: this should be unnecessary, as
transport should fallback to numeric lookup
internally if DNS takes too long anyway) */
- resolve_validation_address (&vc->id,
- vc->addrcp,
+ resolve_validation_address (vc->addrcp,
GNUNET_NO,
vc->last_validation,
vc->valid_until,
@@ -852,7 +844,7 @@ process_validation_string (void *cls,
{
FPRINTF (stdout,
_("Peer `%s' %s `%s' \n"),
- GNUNET_i2s (&vc->id),
+ GNUNET_i2s (&vc->addrcp->peer),
"<unable to resolve address>",
GNUNET_TRANSPORT_vs2s (vc->state));
}
@@ -882,7 +874,6 @@ process_validation_string (void *cls,
/**
* Resolve address we got a validation state for to a string.
*
- * @param id peer identity the address is for
* @param address the address itself
* @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
* @param last_validation when was the address validated last
@@ -891,8 +882,7 @@ process_validation_string (void *cls,
* @param state where are we in the validation state machine
*/
static void
-resolve_validation_address (const struct GNUNET_PeerIdentity *id,
- const struct GNUNET_HELLO_Address *address,
+resolve_validation_address (const struct GNUNET_HELLO_Address *address,
int numeric,
struct GNUNET_TIME_Absolute last_validation,
struct GNUNET_TIME_Absolute valid_until,
@@ -906,7 +896,6 @@ resolve_validation_address (const struct GNUNET_PeerIdentity *id,
GNUNET_CONTAINER_DLL_insert(vc_head, vc_tail, vc);
address_resolutions++;
- vc->id = (*id);
vc->transport = GNUNET_strdup(address->transport_name);
vc->addrcp = GNUNET_HELLO_address_copy (address);
vc->printed = GNUNET_NO;
@@ -928,7 +917,6 @@ resolve_validation_address (const struct GNUNET_PeerIdentity *id,
* Resolve address we got a validation state for to a string.
*
* @param cls NULL
- * @param peer peer identity the address is for
* @param address the address itself
* @param last_validation when was the address validated last
* @param valid_until until when is the address valid
@@ -937,14 +925,13 @@ resolve_validation_address (const struct GNUNET_PeerIdentity *id,
*/
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))
+ if (NULL == address)
{
if (monitor_validation)
{
@@ -961,7 +948,7 @@ process_validation_cb (void *cls,
end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
return;
}
- if ((NULL == peer) || (NULL == address))
+ if (NULL == address)
{
/* invalid response */
vic = NULL;
@@ -970,8 +957,7 @@ process_validation_cb (void *cls,
end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
return;
}
- resolve_validation_address (peer,
- address,
+ resolve_validation_address (address,
numeric,
last_validation,
valid_until,
@@ -1451,7 +1437,7 @@ resolve_peer_address (const struct GNUNET_PeerIdentity *id,
GNUNET_CONTAINER_DLL_insert(rc_head, rc_tail, rc);
address_resolutions++;
- rc->id = (*id);
+ rc->id = *id;
rc->transport = GNUNET_strdup(address->transport_name);
rc->addrcp = GNUNET_HELLO_address_copy (address);
rc->printed = GNUNET_NO;
diff --git a/src/transport/test_transport_api_monitor_peers.c b/src/transport/test_transport_api_monitor_peers.c
index 81d2f0478..536507c47 100644
--- a/src/transport/test_transport_api_monitor_peers.c
+++ b/src/transport/test_transport_api_monitor_peers.c
@@ -386,20 +386,19 @@ start_cb (struct PeerContext *p, void *cls)
static void
monitor1_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 ((NULL == peer) || (NULL == p1))
+ if ((NULL == address) || (NULL == p1))
return;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Monitor 1: %s %s %s\n",
- GNUNET_i2s (peer),
+ GNUNET_i2s (&address->peer),
GNUNET_TRANSPORT_ps2s (state),
GNUNET_STRINGS_absolute_time_to_string(state_timeout));
- if ((0 == memcmp (peer, &p2->id, sizeof (p2->id)) &&
+ if ((0 == memcmp (&address->peer, &p2->id, sizeof (p2->id)) &&
(GNUNET_YES == GNUNET_TRANSPORT_is_connected(state)) &&
GNUNET_NO == p1_c) )
{
@@ -412,20 +411,19 @@ monitor1_cb (void *cls,
static void
monitor2_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 ((NULL == peer) || (NULL == p2))
+ if ((NULL == address) || (NULL == p2))
return;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Monitor 2: %s %s %s\n",
- GNUNET_i2s (peer),
+ GNUNET_i2s (&address->peer),
GNUNET_TRANSPORT_ps2s (state),
GNUNET_STRINGS_absolute_time_to_string(state_timeout));
- if ((0 == memcmp (peer, &p1->id, sizeof (p1->id)) &&
+ if ((0 == memcmp (&address->peer, &p1->id, sizeof (p1->id)) &&
(GNUNET_YES == GNUNET_TRANSPORT_is_connected(state)) &&
GNUNET_NO == p2_c) )
{
diff --git a/src/transport/test_transport_api_monitor_validation.c b/src/transport/test_transport_api_monitor_validation.c
index 261f1a7d0..12be8584e 100644
--- a/src/transport/test_transport_api_monitor_validation.c
+++ b/src/transport/test_transport_api_monitor_validation.c
@@ -392,43 +392,50 @@ start_cb (struct PeerContext *p, void *cls)
static void
monitor1_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)
+ 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 == p1))
+ if ((NULL == address) || (NULL == p1))
return;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Monitor 1: %s %s %s\n",
- GNUNET_i2s (peer), GNUNET_TRANSPORT_vs2s(state), GNUNET_STRINGS_absolute_time_to_string(valid_until));
- if (0 == memcmp (peer, &p2->id, sizeof (p2->id)))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Monitor 1: %s %s %s\n",
+ GNUNET_i2s (&address->peer),
+ GNUNET_TRANSPORT_vs2s (state),
+ GNUNET_STRINGS_absolute_time_to_string(valid_until));
+ if (0 == memcmp (&address->peer,
+ &p2->id,
+ sizeof (p2->id)))
p1_c++;
}
static void
monitor2_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)
+ 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 == p2))
+ if ((NULL == address) || (NULL == p2))
return;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Monitor 2: %s %s %s\n",
- GNUNET_i2s (peer), GNUNET_TRANSPORT_vs2s(state), GNUNET_STRINGS_absolute_time_to_string(valid_until));
- if (0 == memcmp (peer, &p1->id, sizeof (p1->id)))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Monitor 2: %s %s %s\n",
+ GNUNET_i2s (&address->peer),
+ GNUNET_TRANSPORT_vs2s(state),
+ GNUNET_STRINGS_absolute_time_to_string(valid_until));
+ if (0 == memcmp (&address->peer,
+ &p1->id,
+ sizeof (p1->id)))
p2_c++;
}
-
static void
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
diff --git a/src/transport/transport_api_monitor_peers.c b/src/transport/transport_api_monitor_peers.c
index aaf1000f6..5b3fd64b8 100644
--- a/src/transport/transport_api_monitor_peers.c
+++ b/src/transport/transport_api_monitor_peers.c
@@ -333,49 +333,39 @@ peer_response_processor (void *cls,
return;
}
- if ( (0 == tlen) && (0 == alen) )
+ if (0 == tlen)
{
- /* No address available */
- pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, NULL,
- ntohl(pir_msg->state),
- GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout));
+ GNUNET_break (0); /* This must not happen: address without plugin */
+ return;
}
- else
+ addr = (const char *) &pir_msg[1];
+ transport_name = &addr[alen];
+
+ if (transport_name[tlen - 1] != '\0')
{
- if (0 == tlen)
+ /* Corrupt plugin name */
+ GNUNET_break (0);
+ if (pal_ctx->one_shot)
{
- GNUNET_break (0); /* This must not happen: address without plugin */
- return;
+ 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);
}
- addr = (const char *) &pir_msg[1];
- transport_name = &addr[alen];
-
- if (transport_name[tlen - 1] != '\0')
+ else
{
- /* Corrupt plugin name */
- GNUNET_break (0);
- if (pal_ctx->one_shot)
- {
- 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);
- }
- else
- {
- reconnect_peer_ctx (pal_ctx);
- }
- return;
+ reconnect_peer_ctx (pal_ctx);
}
+ return;
+ }
- /* notify client */
- address = GNUNET_HELLO_address_allocate (&pir_msg->peer,
- transport_name, addr, alen, ntohl(pir_msg->local_address_info));
- pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, address,
- ntohl(pir_msg->state),
- GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout));
- GNUNET_HELLO_address_free (address);
+ /* notify client */
+ address = GNUNET_HELLO_address_allocate (&pir_msg->peer,
+ transport_name, addr, alen, ntohl(pir_msg->local_address_info));
+ pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, address,
+ ntohl(pir_msg->state),
+ GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout));
+ GNUNET_HELLO_address_free (address);
- }
/* expect more replies */
GNUNET_CLIENT_receive (pal_ctx->client, &peer_response_processor,
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)
GNUNET_CLIENT_disconnect (val_ctx->client);
val_ctx->client = NULL;
/* notify clients about (re)connect */
- val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
+ val_ctx->cb (val_ctx->cb_cls, 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);
@@ -216,7 +216,7 @@ val_response_processor (void *cls,
if (val_ctx->one_shot)
{
/* Disconnect */
- val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
+ val_ctx->cb (val_ctx->cb_cls, NULL,
GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT);
GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
@@ -236,7 +236,7 @@ val_response_processor (void *cls,
/* Done! */
if (val_ctx->one_shot)
{
- val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
+ val_ctx->cb (val_ctx->cb_cls, NULL,
GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
@@ -254,7 +254,7 @@ val_response_processor (void *cls,
GNUNET_break (0);
if (val_ctx->one_shot)
{
- val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
+ val_ctx->cb (val_ctx->cb_cls, NULL,
GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
@@ -275,7 +275,7 @@ val_response_processor (void *cls,
GNUNET_break (0);
if (val_ctx->one_shot)
{
- val_ctx->cb (val_ctx->cb_cls, NULL, NULL,
+ val_ctx->cb (val_ctx->cb_cls, NULL,
GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS,
GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE);
GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
@@ -286,14 +286,26 @@ val_response_processor (void *cls,
}
return;
}
- if ( (0 == tlen) && (0 == alen) )
+ if (0 == tlen)
{
+ GNUNET_break (0); /* This must not happen: address without plugin */
+ return;
+ }
+ addr = (const char *) &vr_msg[1];
+ transport_name = &addr[alen];
+
+ if (transport_name[tlen - 1] != '\0')
+ {
+ /* Corrupt plugin name */
GNUNET_break (0);
if (val_ctx->one_shot)
{
- 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_NONE);
+ val_ctx->cb (val_ctx->cb_cls,
+ NULL,
+ GNUNET_TIME_UNIT_ZERO_ABS,
+ GNUNET_TIME_UNIT_ZERO_ABS,
+ GNUNET_TIME_UNIT_ZERO_ABS,
+ GNUNET_TRANSPORT_VS_NONE);
GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
}
else
@@ -302,51 +314,19 @@ val_response_processor (void *cls,
}
return;
}
- else
- {
- if (0 == tlen)
- {
- GNUNET_break (0); /* This must not happen: address without plugin */
- return;
- }
- addr = (const char *) &vr_msg[1];
- transport_name = &addr[alen];
-
- if (transport_name[tlen - 1] != '\0')
- {
- /* Corrupt plugin name */
- GNUNET_break (0);
- if (val_ctx->one_shot)
- {
- 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_NONE);
- GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx);
- }
- else
- {
- reconnect_val_ctx (val_ctx);
- }
- return;
- }
-
- /* notify client */
- address = GNUNET_HELLO_address_allocate (&vr_msg->peer,
- transport_name,
- addr, alen,
- ntohl (vr_msg->local_address_info));
- val_ctx->cb (val_ctx->cb_cls,
- &vr_msg->peer,
- address,
- GNUNET_TIME_absolute_ntoh (vr_msg->last_validation),
- GNUNET_TIME_absolute_ntoh (vr_msg->valid_until),
- GNUNET_TIME_absolute_ntoh (vr_msg->next_validation),
- ntohl(vr_msg->state));
- GNUNET_HELLO_address_free (address);
- }
+
+ /* notify client */
+ address = GNUNET_HELLO_address_allocate (&vr_msg->peer,
+ transport_name,
+ addr, alen,
+ ntohl (vr_msg->local_address_info));
+ val_ctx->cb (val_ctx->cb_cls,
+ address,
+ GNUNET_TIME_absolute_ntoh (vr_msg->last_validation),
+ GNUNET_TIME_absolute_ntoh (vr_msg->valid_until),
+ GNUNET_TIME_absolute_ntoh (vr_msg->next_validation),
+ ntohl(vr_msg->state));
+ GNUNET_HELLO_address_free (address);
/* expect more replies */
GNUNET_CLIENT_receive (val_ctx->client,
&val_response_processor,