session,
GNUNET_i2s (&address->peer),
GST_plugins_a2s (address));
- if ( (GNUNET_YES ==
- GNUNET_HELLO_address_check_option (address,
- GNUNET_HELLO_ADDRESS_INFO_INBOUND)) ||
- (GNUNET_NO ==
- GST_ats_is_known (address, session) ) )
+ if (GNUNET_YES ==
+ GNUNET_HELLO_address_check_option (address,
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND))
{
- /* inbound is always new, but outbound MAY already be known, but
- for example for UNIX, we have symmetric connections and thus we
- may not know the address yet; add if necessary! */
+ /* inbound is always new */
GST_ats_add_address (address,
session,
ats,
}
else
{
+ /* outbound should already be known */
GST_ats_new_session (address,
session);
GST_ats_update_metrics (address,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GST_neighbours_stop ();
- GST_plugins_unload ();
GST_validation_stop ();
+ GST_plugins_unload ();
GST_ats_done ();
GNUNET_ATS_scheduling_done (GST_ats);
GST_ats = NULL;
fc->ret = ai;
return GNUNET_NO;
}
- GNUNET_assert ( (fc->session != ai->session) ||
- (NULL == ai->session) );
return GNUNET_YES;
}
}
-/**
- * Test if ATS knows about this address.
- *
- * @param address the address
- * @param session the session
- * @return #GNUNET_YES if address is known, #GNUNET_NO if not.
- */
-int
-GST_ats_is_known (const struct GNUNET_HELLO_Address *address,
- struct Session *session)
-{
- return (NULL != find_ai (address, session)) ? GNUNET_YES : GNUNET_NO;
-}
-
-
/**
* Notify ATS about the new address including the network this address is
* located in.
if (NULL == (papi = GST_plugins_find (address->transport_name)))
{
/* we don't have the plugin for this address */
- GNUNET_assert (0);
+ GNUNET_break(0);
return;
}
if (NULL != session)
ai = find_ai (address, NULL);
if (NULL == ai)
{
- /* We may already be aware of the session, even if some other part
- of the code could not tell if it just created a new session or
- just got one recycled from the plugin; hence, we may be called
- with "new" session even for an "old" session; in that case,
- check that this is the case, but just ignore it. */
- GNUNET_assert (NULL != (find_ai (address, session)));
+ GNUNET_break (NULL != (find_ai (address, session)));
return;
}
GNUNET_break (NULL == ai->session);
and if we get metrics for those, they were never known to
ATS which means we end up here (however, in this
case, the address must be an outbound address). */
- GNUNET_assert (GNUNET_YES !=
- GNUNET_HELLO_address_check_option (address,
- GNUNET_HELLO_ADDRESS_INFO_INBOUND));
+ GNUNET_break (GNUNET_YES !=
+ GNUNET_HELLO_address_check_option (address,
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND));
return;
}
ai = find_ai (address, NULL);
if (NULL == ai)
{
- GNUNET_assert (0);
+ GNUNET_break (0);
return;
}
GNUNET_assert (GNUNET_YES ==
GST_ats_done (void);
-/**
- * Test if ATS knows about this address.
- *
- * @param address the address
- * @param session the session
- * @return #GNUNET_YES if address is known, #GNUNET_NO if not.
- */
-int
-GST_ats_is_known (const struct GNUNET_HELLO_Address *address,
- struct Session *session);
-
/**
* Notify ATS about the new address including the network this address is
* located in.
*/
static void
set_primary_address (struct NeighbourMapEntry *n,
- const struct GNUNET_HELLO_Address *address,
- struct Session *session,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- int is_active)
+ const struct GNUNET_HELLO_Address *address,
+ struct Session *session,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+ int is_active)
{
struct GNUNET_TRANSPORT_PluginFunctions *papi;
struct GNUNET_ATS_Information ats;
- if (0 == memcmp (&wm->clientIdentity,
- plugin->env->my_identity,
- sizeof(struct GNUNET_PeerIdentity)))
+ if (0 == memcmp (&wm->clientIdentity, plugin->env->my_identity,
+ sizeof(struct GNUNET_PeerIdentity)))
{
/* refuse connections from ourselves */
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Received %s message from `%4s' %p\n",
- "WELCOME",
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "Received %s message from `%4s' %p\n", "WELCOME",
GNUNET_i2s (&wm->clientIdentity), client);
GNUNET_STATISTICS_update (plugin->env->stats,
- gettext_noop ("# TCP WELCOME messages received"),
- 1,
- GNUNET_NO);
+ gettext_noop ("# TCP WELCOME messages received"), 1, GNUNET_NO);
session = lookup_session_by_client (plugin, client);
if (NULL != session)
{
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found existing session %p for peer `%s'\n",
- session,
- GNUNET_a2s (vaddr, alen));
- GNUNET_free (vaddr);
+ session, GNUNET_a2s (vaddr, alen));
+ GNUNET_free(vaddr);
}
}
else
session->ats_address_network_type = plugin->env->get_address_type (plugin->env->cls, vaddr, alen);
ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
ats.value = htonl (session->ats_address_network_type);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Creating new%s session %p for peer `%s' client %p \n",
- GNUNET_HELLO_address_check_option (session->address,
- GNUNET_HELLO_ADDRESS_INFO_INBOUND)
- ? " inbound" : "",
- session,
- tcp_plugin_address_to_string (NULL,
- (void *) session->address->address,
- session->address->address_length),
- client);
- GNUNET_free (vaddr);
- GNUNET_SERVER_client_set_user_context (session->client, session);
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "Creating new%s session %p for peer `%s' client %p \n",
+ GNUNET_HELLO_address_check_option (session->address,
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND)
+ ? " inbound" : "",
+ session,
+ tcp_plugin_address_to_string(NULL, (void *) session->address->address,
+ session->address->address_length),
+ client);
+ GNUNET_free(vaddr);
+ GNUNET_SERVER_client_set_user_context(session->client, session);
GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
&session->target,
session,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
/* Notify transport and ATS about new session */
- plugin->env->session_start (plugin->env->cls,
- session->address,
- session,
- &ats, 1);
+ plugin->env->session_start (NULL, session->address, session, &ats, 1);
notify_session_monitor (plugin,
session,
GNUNET_TRANSPORT_SS_INIT);
struct UDP_MessageWrapper *next;
struct FindReceiveContext frc;
- GNUNET_assert (GNUNET_YES != s->in_destroy);
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Session %p to peer `%s' address ended\n", s,
+ GNUNET_assert(GNUNET_YES != s->in_destroy);
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "Session %p to peer `%s' address ended\n", s,
GNUNET_i2s (&s->target),
- udp_address_to_string (NULL,
- s->address->address,
- s->address->address_length));
+ udp_address_to_string (NULL, s->address->address, s->address->address_length));
/* stop timeout task */
if (NULL != s->timeout_task)
{
}
}
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_remove (plugin->sessions,
- &s->target,
- s));
+ GNUNET_assert(GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_remove (plugin->sessions,
+ &s->target,
+ s));
GNUNET_STATISTICS_set (plugin->env->stats,
"# UDP sessions active",
GNUNET_CONTAINER_multipeermap_size (plugin->sessions),
address = GNUNET_HELLO_address_allocate ( &msg->sender, PLUGIN_NAME,
arg, args,
GNUNET_HELLO_ADDRESS_INFO_INBOUND);
- if ( (NULL == (s = udp_plugin_lookup_session (plugin, address))) &&
- (GNUNET_YES != s->in_destroy) )
+ if (NULL == (s = udp_plugin_lookup_session (plugin, address)))
{
s = udp_plugin_create_session (plugin, address);
plugin->env->session_start (NULL, address, s, NULL, 0);
si.arg = arg;
si.args = args;
s->rc++;
- GNUNET_SERVER_mst_receive (plugin->mst,
- &si,
- (const char *) &msg[1],
- ntohs (msg->header.size) - sizeof(struct UDPMessage),
- GNUNET_YES,
- GNUNET_NO);
+ GNUNET_SERVER_mst_receive (plugin->mst, &si, (const char *) &msg[1],
+ ntohs (msg->header.size) - sizeof(struct UDPMessage), GNUNET_YES,
+ GNUNET_NO);
s->rc--;
if ((0 == s->rc) && (GNUNET_YES == s->in_destroy))
free_session (s);
return NULL;
}
stop_broadcast (plugin);
- if (plugin->select_task != NULL)
+ if (plugin->select_task != NULL )
{
GNUNET_SCHEDULER_cancel (plugin->select_task);
plugin->select_task = NULL;
}
- if (plugin->select_task_v6 != NULL)
+ if (plugin->select_task_v6 != NULL )
{
GNUNET_SCHEDULER_cancel (plugin->select_task_v6);
plugin->select_task_v6 = NULL;
struct Plugin *plugin = cls;
struct GNUNET_HELLO_Address *address;
struct MacAndSession *mas = client;
+ struct MacAndSession xmas;
struct GNUNET_ATS_Information ats;
struct FragmentMessage *fm;
struct GNUNET_PeerIdentity tmpsource;
&mas->endpoint->wlan_addr,
sizeof (mas->endpoint->wlan_addr),
GNUNET_HELLO_ADDRESS_INFO_INBOUND);
- mas->session = lookup_session (mas->endpoint,
- &tmpsource);
- if (NULL == mas->session)
- {
- mas->session = create_session (mas->endpoint,
- &tmpsource);
- plugin->env->session_start (plugin->env->cls,
- address,
- mas->session,
- &ats, 1);
- }
plugin->env->receive (plugin->env->cls,
address,
mas->session,
GNUNET_NO);
break;
}
- mas->session = lookup_session (mas->endpoint,
- &wlanheader->sender);
- if (NULL == mas->session)
+ xmas.endpoint = mas->endpoint;
+ if (NULL == (xmas.session = lookup_session (mas->endpoint,
+ &wlanheader->sender)))
{
- mas->session = create_session (mas->endpoint,
+ xmas.session = create_session (mas->endpoint,
&wlanheader->sender);
address = GNUNET_HELLO_address_allocate (&wlanheader->sender,
PLUGIN_NAME,
&mas->endpoint->wlan_addr,
sizeof (struct WlanAddress),
GNUNET_HELLO_ADDRESS_INFO_NONE);
- plugin->env->session_start (plugin->env->cls,
+ plugin->env->session_start (NULL,
address,
- mas->session,
+ xmas.session,
NULL, 0);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Notifying transport about peer `%s''s new session %p \n",
+ "Notifying transport about peer `%s''s new session %p \n",
GNUNET_i2s (&wlanheader->sender),
- mas->session);
+ xmas.session);
GNUNET_HELLO_address_free (address);
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Processing %u bytes of DATA from peer `%s'\n",
(unsigned int) msize,
GNUNET_i2s (&wlanheader->sender));
- mas->session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ xmas.session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
(void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer,
- mas,
+ &xmas,
(const char *) &wlanheader[1],
msize - sizeof (struct WlanHeader),
GNUNET_YES,
GNUNET_BANDWIDTH_value_init (100 * 1024 *
1024 / 8),
100);
- plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data,
- plugin);
- plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data,
- plugin);
- plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data,
- plugin);
+ plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
+ plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
+ plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon,
plugin);
/**
* Context of peer 1
*/
-static struct PeerContext *p1;
+struct PeerContext *p1;
/**
* Configuration file of peer 1
*/
-static char *cfg_file_p1;
+char *cfg_file_p1;
/**
* Context of peer 2
*/
-static struct PeerContext *p2;
+struct PeerContext *p2;
/**
* Configuration file of peer 1
*/
-static char *cfg_file_p2;
+char *cfg_file_p2;
/**
* Timeout task
/**
* Transport transmit handle used
*/
-static struct GNUNET_TRANSPORT_TransmitHandle *th;
+struct GNUNET_TRANSPORT_TransmitHandle *th;
/**
* Transport testing handle
*/
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_handle *tth;
/*
* Total amount of bytes sent
static int msg_recv;
static int test_connected;
-
static int test_sending;
-
static int test_send_timeout;
#define OKPP do { ok++; } while (0)
#endif
-
static int
get_bit (const char *map, unsigned int bit);
-
static void
end ()
{