From 0db0f5b8f69e2137256904edf29222e71051e77c Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 8 Jan 2014 10:50:27 +0000 Subject: implementing monitoring api --- src/transport/Makefile.am | 1 + src/transport/gnunet-service-transport_clients.c | 102 ++++++++++------ .../gnunet-service-transport_neighbours.c | 120 ++++--------------- .../gnunet-service-transport_neighbours.h | 12 +- src/transport/transport.h | 2 +- src/transport/transport_api_monitoring.c | 128 +++++++++++++++++---- 6 files changed, 207 insertions(+), 158 deletions(-) (limited to 'src/transport') diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 1221cdbea..9851a7907 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -210,6 +210,7 @@ gnunet_service_transport_SOURCES = \ gnunet-service-transport_validation.h gnunet-service-transport_validation.c \ gnunet-service-transport_manipulation.h gnunet-service-transport_manipulation.c gnunet_service_transport_LDADD = \ + $(top_builddir)/src/transport/libgnunettransport.la \ $(top_builddir)/src/ats/libgnunetats.la \ $(top_builddir)/src/hello/libgnunethello.la \ $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 7c4a9d712..6bd3e34d5 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -468,16 +468,21 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client) */ static void notify_client_about_neighbour (void *cls, - const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_HELLO_Address *address, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) + 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 TransportClient *tc = cls; struct ConnectInfoMessage *cim; size_t size = sizeof (struct ConnectInfoMessage); char buf[size] GNUNET_ALIGN; + if (GNUNET_NO == GST_neighbours_test_connected (peer)) + return; + GNUNET_assert (size < GNUNET_SERVER_MAX_MESSAGE_SIZE); cim = (struct ConnectInfoMessage *) buf; cim->header.size = htons (size); @@ -873,7 +878,7 @@ compose_address_iterate_response_message (const struct GNUNET_PeerIdentity *peer msg = GNUNET_malloc (size); msg->header.size = htons (size); msg->header.type = - htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); + htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE); msg->reserved = htonl (0); msg->peer = *peer; msg->addrlen = htonl (alen); @@ -888,33 +893,55 @@ compose_address_iterate_response_message (const struct GNUNET_PeerIdentity *peer } +struct PeerIterationContext +{ + struct GNUNET_SERVER_TransmitContext *tc; + + struct GNUNET_PeerIdentity id; + + int all; +}; + /** - * Output the active address of connected neighbours to the given client. + * Output information of neighbours to the given client. * - * @param cls the 'struct GNUNET_SERVER_TransmitContext' for transmission to the client + * @param cls the 'struct PeerIterationContext' * @param peer identity of the neighbour * @param address the address * @param bandwidth_in inbound quota in NBO * @param bandwidth_out outbound quota in NBO */ static void -output_address (void *cls, const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_HELLO_Address *address, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) +send_peer_information (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 GNUNET_SERVER_TransmitContext *tc = cls; + struct PeerIterationContext *pc = cls; struct PeerIterateResponseMessage *msg; - msg = compose_address_iterate_response_message (peer, address); - GNUNET_SERVER_transmit_context_append_message (tc, &msg->header); - GNUNET_free (msg); + if ( (GNUNET_YES == pc->all) || + (0 == memcmp (peer, &pc->id, sizeof (pc->id))) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Sending information about `%s' using address `%s' in state `%s'\n", + GNUNET_i2s(peer), address); + msg = compose_address_iterate_response_message (peer, address); + msg->state = htonl (state); + msg->state_timeout = GNUNET_TIME_absolute_hton(state_timeout); + GNUNET_SERVER_transmit_context_append_message (pc->tc, &msg->header); + GNUNET_free (msg); + } } + + /** - * Client asked to obtain information about all actively used addresses - * of connected peers + * Client asked to obtain information about a specific or all peers * Process the request. * * @param cls unused @@ -922,27 +949,27 @@ output_address (void *cls, const struct GNUNET_PeerIdentity *peer, * @param message the peer address information request */ static void -clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client, +clients_handle_monitor_peers (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { static struct GNUNET_PeerIdentity all_zeros; struct GNUNET_SERVER_TransmitContext *tc; - struct PeerIterateMessage *msg; - struct GNUNET_HELLO_Address *address; + struct PeerMonitorMessage *msg; + struct PeerIterationContext pc; - if (ntohs (message->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE) + if (ntohs (message->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST) { GNUNET_break (0); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } - if (ntohs (message->size) != sizeof (struct PeerIterateMessage)) + if (ntohs (message->size) != sizeof (struct PeerMonitorMessage)) { GNUNET_break (0); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } - msg = (struct PeerIterateMessage *) message; + msg = (struct PeerMonitorMessage *) message; if ( (GNUNET_YES != ntohl (msg->one_shot)) && (NULL != lookup_monitoring_client (client)) ) { @@ -954,26 +981,33 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client, return; } GNUNET_SERVER_disable_receive_done_warning (client); - tc = GNUNET_SERVER_transmit_context_create (client); + pc.tc = tc = GNUNET_SERVER_transmit_context_create (client); + + /* Send initial list */ if (0 == memcmp (&msg->peer, &all_zeros, sizeof (struct GNUNET_PeerIdentity))) { /* iterate over all neighbours */ - GST_neighbours_iterate (&output_address, tc); + pc.all = GNUNET_YES; + pc.id = msg->peer; } else { /* just return one neighbour */ - address = GST_neighbour_get_current_address (&msg->peer); - if (address != NULL) - output_address (tc, &msg->peer, address, - GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, - GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT); + pc.all = GNUNET_NO; + pc.id = msg->peer; } + GST_neighbours_iterate (&send_peer_information, &pc); + if (GNUNET_YES != ntohl (msg->one_shot)) + { setup_monitoring_client (client, &msg->peer); + } else + { GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, - GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); + GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE); + } + GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); } @@ -998,9 +1032,9 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server) sizeof (struct TransportRequestConnectMessage)}, {&clients_handle_address_to_string, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, 0}, - {&clients_handle_address_iterate, NULL, - GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE, - sizeof (struct PeerIterateMessage)}, + {&clients_handle_monitor_peers, NULL, + GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST, + sizeof (struct PeerMonitorMessage)}, {&GST_blacklist_handle_init, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT, sizeof (struct GNUNET_MessageHeader)}, diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index d451991f1..7d7d1f7e3 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -513,55 +513,6 @@ lookup_neighbour (const struct GNUNET_PeerIdentity *pid) } -/** - * Convert state to human-readable string. - * - * @param state the state value - * @return corresponding string - */ -static const char * -print_state (enum GNUNET_TRANSPORT_PeerState state) -{ - switch (state) - { - case S_NOT_CONNECTED: - return "S_NOT_CONNECTED"; - case S_INIT_ATS: - return "S_INIT_ATS"; - case S_INIT_BLACKLIST: - return "S_INIT_BLACKLIST"; - case S_CONNECT_SENT: - return "S_CONNECT_SENT"; - case S_CONNECT_RECV_BLACKLIST_INBOUND: - return "S_CONNECT_RECV_BLACKLIST_INBOUND"; - case S_CONNECT_RECV_ATS: - return "S_CONNECT_RECV_ATS"; - case S_CONNECT_RECV_BLACKLIST: - return "S_CONNECT_RECV_BLACKLIST"; - case S_CONNECT_RECV_ACK: - return "S_CONNECT_RECV_ACK"; - case S_CONNECTED: - return "S_CONNECTED"; - case S_RECONNECT_ATS: - return "S_RECONNECT_ATS"; - case S_RECONNECT_BLACKLIST: - return "S_RECONNECT_BLACKLIST"; - case S_RECONNECT_SENT: - return "S_RECONNECT_SENT"; - case S_CONNECTED_SWITCHING_BLACKLIST: - return "S_CONNECTED_SWITCHING_BLACKLIST"; - case S_CONNECTED_SWITCHING_CONNECT_SENT: - return "S_CONNECTED_SWITCHING_CONNECT_SENT"; - case S_DISCONNECT: - return "S_DISCONNECT"; - case S_DISCONNECT_FINISHED: - return "S_DISCONNECT_FINISHED"; - default: - GNUNET_break (0); - return "UNDEFINED"; - } -} - /** * Test if we're connected to the given peer. * @@ -573,35 +524,7 @@ test_connected (struct NeighbourMapEntry *n) { if (NULL == n) return GNUNET_NO; - switch (n->state) - { - case S_NOT_CONNECTED: - case S_INIT_ATS: - case S_INIT_BLACKLIST: - case S_CONNECT_SENT: - case S_CONNECT_RECV_BLACKLIST_INBOUND: - case S_CONNECT_RECV_ATS: - case S_CONNECT_RECV_BLACKLIST: - case S_CONNECT_RECV_ACK: - return GNUNET_NO; - case S_CONNECTED: - case S_RECONNECT_ATS: - case S_RECONNECT_BLACKLIST: - case S_RECONNECT_SENT: - case S_CONNECTED_SWITCHING_BLACKLIST: - case S_CONNECTED_SWITCHING_CONNECT_SENT: - return GNUNET_YES; - case S_DISCONNECT: - case S_DISCONNECT_FINISHED: - return GNUNET_NO; - default: - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unhandled state `%s' \n", - print_state (n->state)); - GNUNET_break (0); - break; - } - return GNUNET_SYSERR; + return GNUNET_TRANSPORT_is_connected (n->state); } /** @@ -960,7 +883,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer %s in state %s\n", GNUNET_i2s (&n->id), - print_state (n->state)); + GNUNET_TRANSPORT_p2s (n->state)); /* depending on state, notify neighbour and/or upper layers of this peer about disconnect */ switch (n->state) @@ -1022,7 +945,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n) default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s'\n", - print_state (n->state)); + GNUNET_TRANSPORT_p2s (n->state)); GNUNET_break (0); break; } @@ -1693,7 +1616,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Asked to connect to peer `%s' (state: %s)\n", GNUNET_i2s (target), - (NULL != n) ? print_state(n->state) : "NEW PEER"); + (NULL != n) ? GNUNET_TRANSPORT_p2s(n->state) : "NEW PEER"); if (NULL != n) { switch (n->state) @@ -1734,7 +1657,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s'\n", - print_state (n->state)); + GNUNET_TRANSPORT_p2s (n->state)); GNUNET_break (0); free_neighbour (n, GNUNET_NO); break; @@ -1795,7 +1718,7 @@ handle_test_blacklist_cont (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received blacklist result for peer `%s' in state %s/%d\n", GNUNET_i2s (peer), - print_state (n->state), + GNUNET_TRANSPORT_p2s (n->state), n->send_connect_ack); switch (n->state) { @@ -1992,7 +1915,7 @@ handle_test_blacklist_cont (void *cls, default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s'\n", - print_state (n->state)); + GNUNET_TRANSPORT_p2s (n->state)); GNUNET_break (0); free_neighbour (n, GNUNET_NO); break; @@ -2093,7 +2016,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received SESSION_CONNECT for peer `%s' in state %s/%d\n", GNUNET_i2s (peer), - print_state (n->state), + GNUNET_TRANSPORT_p2s (n->state), n->send_connect_ack); switch (n->state) { @@ -2161,7 +2084,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s'\n", - print_state (n->state)); + GNUNET_TRANSPORT_p2s (n->state)); GNUNET_break (0); return GNUNET_SYSERR; } @@ -2234,7 +2157,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, address->transport_name, session, GNUNET_i2s (peer), - print_state (n->state), + GNUNET_TRANSPORT_p2s (n->state), n->send_connect_ack, ntohl (bandwidth_in.value__), ntohl (bandwidth_out.value__)); @@ -2404,7 +2327,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s'\n", - print_state (n->state)); + GNUNET_TRANSPORT_p2s (n->state)); GNUNET_break (0); break; } @@ -2571,7 +2494,7 @@ master_task (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master task runs for neighbour `%s' in state %s with timeout in %s\n", GNUNET_i2s (&n->id), - print_state(n->state), + GNUNET_TRANSPORT_p2s(n->state), GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); switch (n->state) @@ -2742,7 +2665,7 @@ master_task (void *cls, default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s'\n", - print_state (n->state)); + GNUNET_TRANSPORT_p2s (n->state)); GNUNET_break (0); break; } @@ -2930,7 +2853,7 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s'\n", - print_state (n->state)); + GNUNET_TRANSPORT_p2s (n->state)); GNUNET_break (0); return GNUNET_SYSERR; } @@ -3060,7 +2983,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s'\n", - print_state (n->state)); + GNUNET_TRANSPORT_p2s (n->state)); GNUNET_break (0); break; } @@ -3117,7 +3040,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received SESSION_ACK message from peer `%s' in state %s/%d\n", GNUNET_i2s (peer), - print_state (n->state), + GNUNET_TRANSPORT_p2s (n->state), n->send_connect_ack); GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# unexpected SESSION_ACK messages"), 1, @@ -3297,7 +3220,7 @@ struct IteratorContext /** - * Call the callback from the closure for each connected neighbour. + * Call the callback from the closure for each neighbour. * * @param cls the `struct IteratorContext` * @param key the hash of the public key of the neighbour @@ -3314,8 +3237,6 @@ neighbours_iterate (void *cls, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in; struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out; - if (GNUNET_YES != test_connected (n)) - return GNUNET_OK; if (NULL != n->primary_address.address) { @@ -3327,8 +3248,11 @@ neighbours_iterate (void *cls, bandwidth_in = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT; bandwidth_out = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT; } - ic->cb (ic->cb_cls, &n->id, + ic->cb (ic->cb_cls, + &n->id, n->primary_address.address, + n->state, + n->timeout, bandwidth_in, bandwidth_out); return GNUNET_OK; } @@ -3415,7 +3339,7 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer) default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unhandled state `%s'\n", - print_state (n->state)); + GNUNET_TRANSPORT_p2s (n->state)); GNUNET_break (0); break; } diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index c72b298c5..2e0e4e692 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h @@ -170,19 +170,21 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target); /** - * Function called for each connected neighbour. + * Function called for each neighbour. * * @param cls closure * @param neighbour identity of the neighbour * @param address the address (or NULL) + * @param state current state the peer is in + * @param state_timeout timeout for this state * @param bandwidth_in inbound quota in NBO * @param bandwidth_out outbound quota in NBO */ typedef void (*GST_NeighbourIterator) (void *cls, - const struct GNUNET_PeerIdentity * - neighbour, - const struct GNUNET_HELLO_Address * - address, + const struct GNUNET_PeerIdentity *neighbour, + 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); diff --git a/src/transport/transport.h b/src/transport/transport.h index 75cdd729c..43504ec2b 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h @@ -375,7 +375,7 @@ struct PeerLookupMessage * Message from the library to the transport service * asking for binary addresses known for a peer. */ -struct PeerIterateMessage +struct PeerMonitorMessage { /** * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE diff --git a/src/transport/transport_api_monitoring.c b/src/transport/transport_api_monitoring.c index d7bc56e09..bfbe1d0a1 100644 --- a/src/transport/transport_api_monitoring.c +++ b/src/transport/transport_api_monitoring.c @@ -140,6 +140,94 @@ struct GNUNET_TRANSPORT_ValidationMonitoringContext int one_shot; }; +/** + * Check if a state is defined as connected + * + * @param state the state value + * @return GNUNET_YES or GNUNET_NO + */ +int +GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state) +{ + switch (state) + { + case S_NOT_CONNECTED: + case S_INIT_ATS: + case S_INIT_BLACKLIST: + case S_CONNECT_SENT: + case S_CONNECT_RECV_BLACKLIST_INBOUND: + case S_CONNECT_RECV_ATS: + case S_CONNECT_RECV_BLACKLIST: + case S_CONNECT_RECV_ACK: + return GNUNET_NO; + case S_CONNECTED: + case S_RECONNECT_ATS: + case S_RECONNECT_BLACKLIST: + case S_RECONNECT_SENT: + case S_CONNECTED_SWITCHING_BLACKLIST: + case S_CONNECTED_SWITCHING_CONNECT_SENT: + return GNUNET_YES; + case S_DISCONNECT: + case S_DISCONNECT_FINISHED: + return GNUNET_NO; + default: + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Unhandled state `%s' \n", + GNUNET_TRANSPORT_p2s (state)); + GNUNET_break (0); + break; + } + return GNUNET_SYSERR; +} + +/** + * Convert state to human-readable string. + * + * @param state the state value + * @return corresponding string + */ +const char * +GNUNET_TRANSPORT_p2s (enum GNUNET_TRANSPORT_PeerState state) +{ + switch (state) + { + case S_NOT_CONNECTED: + return "S_NOT_CONNECTED"; + case S_INIT_ATS: + return "S_INIT_ATS"; + case S_INIT_BLACKLIST: + return "S_INIT_BLACKLIST"; + case S_CONNECT_SENT: + return "S_CONNECT_SENT"; + case S_CONNECT_RECV_BLACKLIST_INBOUND: + return "S_CONNECT_RECV_BLACKLIST_INBOUND"; + case S_CONNECT_RECV_ATS: + return "S_CONNECT_RECV_ATS"; + case S_CONNECT_RECV_BLACKLIST: + return "S_CONNECT_RECV_BLACKLIST"; + case S_CONNECT_RECV_ACK: + return "S_CONNECT_RECV_ACK"; + case S_CONNECTED: + return "S_CONNECTED"; + case S_RECONNECT_ATS: + return "S_RECONNECT_ATS"; + case S_RECONNECT_BLACKLIST: + return "S_RECONNECT_BLACKLIST"; + case S_RECONNECT_SENT: + return "S_RECONNECT_SENT"; + case S_CONNECTED_SWITCHING_BLACKLIST: + return "S_CONNECTED_SWITCHING_BLACKLIST"; + case S_CONNECTED_SWITCHING_CONNECT_SENT: + return "S_CONNECTED_SWITCHING_CONNECT_SENT"; + case S_DISCONNECT: + return "S_DISCONNECT"; + case S_DISCONNECT_FINISHED: + return "S_DISCONNECT_FINISHED"; + default: + GNUNET_break (0); + return "UNDEFINED"; + } +} /** @@ -150,7 +238,7 @@ struct GNUNET_TRANSPORT_ValidationMonitoringContext * message with the human-readable address */ static void -peer_address_response_processor (void *cls, +peer_response_processor (void *cls, const struct GNUNET_MessageHeader *msg); @@ -162,10 +250,10 @@ peer_address_response_processor (void *cls, static void send_request (struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx) { - struct PeerIterateMessage msg; + struct PeerMonitorMessage msg; - msg.header.size = htons (sizeof (struct PeerIterateMessage)); - msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE); + msg.header.size = htons (sizeof (struct PeerMonitorMessage)); + msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST); msg.one_shot = htonl (pal_ctx->one_shot); msg.timeout = GNUNET_TIME_absolute_hton (pal_ctx->timeout); msg.peer = pal_ctx->peer; @@ -174,7 +262,7 @@ send_request (struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx) &msg.header, GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout), GNUNET_YES, - &peer_address_response_processor, + &peer_response_processor, pal_ctx)); } @@ -218,16 +306,16 @@ reconnect (struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx) /** * Function called with responses from the service. * - * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*' + * @param cls our 'struct GNUNET_TRANSPORT_PeerMonitoringContext*' * @param msg NULL on timeout or error, otherwise presumably a * message with the human-readable address */ static void -peer_address_response_processor (void *cls, +peer_response_processor (void *cls, const struct GNUNET_MessageHeader *msg) { struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx = cls; - struct PeerIterateResponseMessage *air_msg; + struct PeerIterateResponseMessage *pir_msg; struct GNUNET_HELLO_Address *address; const char *addr; const char *transport_name; @@ -251,7 +339,7 @@ peer_address_response_processor (void *cls, } size = ntohs (msg->size); GNUNET_break (ntohs (msg->type) == - GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); + GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE); if (size == sizeof (struct GNUNET_MessageHeader)) { /* done! */ @@ -270,7 +358,7 @@ peer_address_response_processor (void *cls, if ((size < sizeof (struct PeerIterateResponseMessage)) || (ntohs (msg->type) != - GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE)) + GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE)) { GNUNET_break (0); if (pal_ctx->one_shot) @@ -286,9 +374,9 @@ peer_address_response_processor (void *cls, return; } - air_msg = (struct PeerIterateResponseMessage *) msg; - tlen = ntohl (air_msg->pluginlen); - alen = ntohl (air_msg->addrlen); + pir_msg = (struct PeerIterateResponseMessage *) msg; + tlen = ntohl (pir_msg->pluginlen); + alen = ntohl (pir_msg->addrlen); if (size != sizeof (struct PeerIterateResponseMessage) + tlen + alen) { @@ -308,12 +396,12 @@ peer_address_response_processor (void *cls, if (alen == 0 && tlen == 0) { - pal_ctx->cb (pal_ctx->cb_cls, &air_msg->peer, NULL, + pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, NULL, S_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS); } else { - addr = (const char *) &air_msg[1]; + addr = (const char *) &pir_msg[1]; transport_name = &addr[alen]; if (transport_name[tlen - 1] != '\0') @@ -333,16 +421,16 @@ peer_address_response_processor (void *cls, } /* notify client */ - address = GNUNET_HELLO_address_allocate (&air_msg->peer, + address = GNUNET_HELLO_address_allocate (&pir_msg->peer, transport_name, addr, alen); - pal_ctx->cb (pal_ctx->cb_cls, &air_msg->peer, address, - ntohl(air_msg->state), - GNUNET_TIME_absolute_ntoh (air_msg->state_timeout)); + 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_address_response_processor, + GNUNET_CLIENT_receive (pal_ctx->client, &peer_response_processor, pal_ctx, GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout)); } -- cgit v1.2.3