/*
This file is part of GNUnet
- (C) 2010-2014 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2010-2014 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
#define WLAN_MTU 1430
+/**
+ * Which network scope do we belong to?
+ */
+#if BUILD_WLAN
+static const enum GNUNET_ATS_Network_Type scope = GNUNET_ATS_NET_WLAN;
+#else
+static const enum GNUNET_ATS_Network_Type scope = GNUNET_ATS_NET_BT;
+#endif
+
/**
* Maximum number of messages in defragmentation queue per MAC
/**
* Timeout task (for this message).
*/
- GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+ struct GNUNET_SCHEDULER_Task * timeout_task;
};
/**
* Session handle for connections with other peers.
*/
-struct Session
+struct GNUNET_ATS_Session
{
/**
* To whom are we talking to (set to our identity
* We keep all sessions in a DLL at their respective
* `struct MACEndpoint *`.
*/
- struct Session *next;
+ struct GNUNET_ATS_Session *next;
/**
* We keep all sessions in a DLL at their respective
* `struct MACEndpoint *`.
*/
- struct Session *prev;
+ struct GNUNET_ATS_Session *prev;
/**
* MAC endpoint with the address of this peer.
/**
* Timeout task (for the session).
*/
- GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+ struct GNUNET_SCHEDULER_Task * timeout_task;
};
/**
* Timeout task.
*/
- GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+ struct GNUNET_SCHEDULER_Task * timeout_task;
/**
* Continuation to call when we're done with this message.
*/
GNUNET_TRANSPORT_TransmitContinuation cont;
+ /**
+ * Message we need to fragment and transmit, NULL after the
+ * @e fragmentcontext has been created.
+ */
+ struct GNUNET_MessageHeader *msg;
+
/**
* Closure for @e cont
*/
/**
* Head of sessions that use this MAC.
*/
- struct Session *sessions_head;
+ struct GNUNET_ATS_Session *sessions_head;
/**
* Tail of sessions that use this MAC.
*/
- struct Session *sessions_tail;
+ struct GNUNET_ATS_Session *sessions_tail;
/**
* Head of messages we are currently sending to this MAC.
/**
* Timeout task.
*/
- GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+ struct GNUNET_SCHEDULER_Task * timeout_task;
/**
* count of messages in the fragment out queue for this mac endpoint
/**
* Task that periodically sends a HELLO beacon via the helper.
*/
- GNUNET_SCHEDULER_TaskIdentifier beacon_task;
+ struct GNUNET_SCHEDULER_Task *beacon_task;
/**
* Tracker for bandwidth limit
/**
* NULL if the identity of the other peer is not known.
*/
- struct Session *session;
+ struct GNUNET_ATS_Session *session;
/**
* MAC address of the other peer, NULL if not known.
*/
static void
notify_session_monitor (struct Plugin *plugin,
- struct Session *session,
+ struct GNUNET_ATS_Session *session,
enum GNUNET_TRANSPORT_SessionState state)
{
struct GNUNET_TRANSPORT_SessionInfo info;
* @param hdr pointer to the hdr where the ack is stored
*/
static void
-send_ack (void *cls, uint32_t msg_id,
+send_ack (void *cls,
+ uint32_t msg_id,
const struct GNUNET_MessageHeader *hdr)
{
struct MacEndpoint *endpoint = cls;
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Sending ACK to helper\n");
+ "Sending ACK to %s\n",
+ mac_to_string (&endpoint->wlan_addr.mac));
radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
get_radiotap_header (endpoint, radio_header, size);
get_wlan_header (endpoint->plugin,
*/
static int
wlan_plugin_disconnect_session (void *cls,
- struct Session *session)
+ struct GNUNET_ATS_Session *session)
{
struct MacEndpoint *endpoint = session->mac;
struct Plugin *plugin = endpoint->plugin;
session);
notify_session_monitor (plugin,
session,
- GNUNET_TRANSPORT_SS_DOWN);
+ GNUNET_TRANSPORT_SS_DONE);
GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head,
endpoint->sessions_tail,
session);
- if (session->timeout_task != GNUNET_SCHEDULER_NO_TASK)
+ if (session->timeout_task != NULL)
{
GNUNET_SCHEDULER_cancel (session->timeout_task);
- session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ session->timeout_task = NULL;
}
GNUNET_STATISTICS_update (plugin->env->stats,
_("# Sessions allocated"),
* A session is timing out. Clean up.
*
* @param cls pointer to the Session
- * @param tc unused
*/
static void
-session_timeout (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+session_timeout (void *cls)
{
- struct Session *session = cls;
+ struct GNUNET_ATS_Session *session = cls;
struct GNUNET_TIME_Relative left;
- session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ session->timeout_task = NULL;
left = GNUNET_TIME_absolute_get_remaining (session->timeout);
if (0 != left.rel_value_us)
{
* @param peer peer identity to use for this session
* @return returns the session or NULL
*/
-static struct Session *
+static struct GNUNET_ATS_Session *
lookup_session (struct MacEndpoint *endpoint,
const struct GNUNET_PeerIdentity *peer)
{
- struct Session *session;
+ struct GNUNET_ATS_Session *session;
for (session = endpoint->sessions_head; NULL != session; session = session->next)
if (0 == memcmp (peer, &session->target, sizeof (struct GNUNET_PeerIdentity)))
* @param peer peer identity to use for this session
* @return returns the session or NULL
*/
-static struct Session *
+static struct GNUNET_ATS_Session *
create_session (struct MacEndpoint *endpoint,
const struct GNUNET_PeerIdentity *peer)
{
- struct Session *session;
+ struct GNUNET_ATS_Session *session;
GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
_("# Sessions allocated"),
1,
GNUNET_NO);
- session = GNUNET_new (struct Session);
+ session = GNUNET_new (struct GNUNET_ATS_Session);
GNUNET_CONTAINER_DLL_insert_tail (endpoint->sessions_head,
endpoint->sessions_tail,
session);
session->timeout_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout,
session);
+ notify_session_monitor (endpoint->plugin,
+ session,
+ GNUNET_TRANSPORT_SS_INIT);
notify_session_monitor (endpoint->plugin,
session,
GNUNET_TRANSPORT_SS_UP);
* @param peer peer identity to use for this session
* @return returns the session
*/
-static struct Session *
+static struct GNUNET_ATS_Session *
get_session (struct MacEndpoint *endpoint,
const struct GNUNET_PeerIdentity *peer)
{
- struct Session *session;
+ struct GNUNET_ATS_Session *session;
if (NULL != (session = lookup_session (endpoint, peer)))
return session;
{
struct FragmentMessage *fm = cls;
-
fm->sh = NULL;
GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext);
}
radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
get_radiotap_header (endpoint, radio_header, size);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending %u bytes of data to MAC `%s'\n",
+ (unsigned int) msize,
+ mac_to_string (&endpoint->wlan_addr.mac));
+
get_wlan_header (endpoint->plugin,
&radio_header->frame,
&endpoint->wlan_addr.mac,
&fragment_transmission_done, fm);
fm->size_on_wire += size;
if (NULL != fm->sh)
+ {
GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
_("# message fragments sent"),
1,
GNUNET_NO);
+ }
else
+ {
GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext);
+ }
GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
"# bytes currently in buffers",
-msize, GNUNET_NO);
GNUNET_HELPER_send_cancel (fm->sh);
fm->sh = NULL;
}
- GNUNET_FRAGMENT_context_destroy (fm->fragcontext,
- &endpoint->msg_delay,
- &endpoint->ack_delay);
- if (fm->timeout_task != GNUNET_SCHEDULER_NO_TASK)
+ if (NULL != fm->msg)
+ {
+ GNUNET_free (fm->msg);
+ fm->msg = NULL;
+ }
+ if (NULL != fm->fragcontext)
+ {
+ GNUNET_FRAGMENT_context_destroy (fm->fragcontext,
+ &endpoint->msg_delay,
+ &endpoint->ack_delay);
+ fm->fragcontext = NULL;
+ }
+ if (NULL != fm->timeout_task)
{
GNUNET_SCHEDULER_cancel (fm->timeout_task);
- fm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ fm->timeout_task = NULL;
}
GNUNET_free (fm);
}
* A FragmentMessage has timed out. Remove it.
*
* @param cls pointer to the 'struct FragmentMessage'
- * @param tc unused
*/
static void
-fragmentmessage_timeout (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+fragmentmessage_timeout (void *cls)
{
struct FragmentMessage *fm = cls;
- fm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ fm->timeout_task = NULL;
if (NULL != fm->cont)
{
fm->cont (fm->cont_cls,
fm->cont = cont;
fm->cont_cls = cont_cls;
/* 1 MBit/s typical data rate, 1430 byte fragments => ~100 ms per message */
- fm->fragcontext =
- GNUNET_FRAGMENT_context_create (plugin->env->stats,
- WLAN_MTU,
- &plugin->tracker,
- endpoint->msg_delay,
- endpoint->ack_delay,
- msg,
- &transmit_fragment, fm);
fm->timeout_task =
GNUNET_SCHEDULER_add_delayed (timeout,
- &fragmentmessage_timeout, fm);
+ &fragmentmessage_timeout,
+ fm);
+ if (GNUNET_YES == plugin->have_mac)
+ {
+ fm->fragcontext =
+ GNUNET_FRAGMENT_context_create (plugin->env->stats,
+ WLAN_MTU,
+ &plugin->tracker,
+ fm->macendpoint->msg_delay,
+ fm->macendpoint->ack_delay,
+ msg,
+ &transmit_fragment, fm);
+ }
+ else
+ {
+ fm->msg = GNUNET_copy_message (msg);
+ }
GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head,
endpoint->sending_messages_tail,
fm);
{
struct Plugin *plugin = endpoint->plugin;
struct FragmentMessage *fm;
- struct Session *session;
+ struct GNUNET_ATS_Session *session;
GNUNET_STATISTICS_update (plugin->env->stats,
_("# MAC endpoints allocated"),
}
plugin->mac_count--;
- if (GNUNET_SCHEDULER_NO_TASK != endpoint->timeout_task)
+ if (NULL != endpoint->timeout_task)
{
GNUNET_SCHEDULER_cancel (endpoint->timeout_task);
- endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ endpoint->timeout_task = NULL;
}
GNUNET_free (endpoint);
}
* A MAC endpoint is timing out. Clean up.
*
* @param cls pointer to the `struct MacEndpoint *`
- * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
*/
static void
-macendpoint_timeout (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+macendpoint_timeout (void *cls)
{
struct MacEndpoint *endpoint = cls;
struct GNUNET_TIME_Relative timeout;
- endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ endpoint->timeout_task = NULL;
timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout);
if (0 == timeout.rel_value_us)
{
*/
static enum GNUNET_ATS_Network_Type
wlan_plugin_get_network (void *cls,
- struct Session *session)
+ struct GNUNET_ATS_Session *session)
+{
+#if BUILD_WLAN
+ return GNUNET_ATS_NET_WLAN;
+#else
+ return GNUNET_ATS_NET_BT;
+#endif
+}
+
+
+/**
+ * Function obtain the network type for an address.
+ *
+ * @param cls closure (`struct Plugin *`)
+ * @param address the address
+ * @return the network type
+ */
+static enum GNUNET_ATS_Network_Type
+wlan_plugin_get_network_for_address (void *cls,
+ const struct GNUNET_HELLO_Address *address)
{
#if BUILD_WLAN
return GNUNET_ATS_NET_WLAN;
* @param address the address
* @return the session or NULL of max connections exceeded
*/
-static struct Session *
+static struct GNUNET_ATS_Session *
wlan_plugin_get_session (void *cls,
const struct GNUNET_HELLO_Address *address)
{
const struct GNUNET_PeerIdentity *target)
{
struct Plugin *plugin = cls;
- struct Session *session;
+ struct GNUNET_ATS_Session *session;
struct MacEndpoint *endpoint;
for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next)
*/
static ssize_t
wlan_plugin_send (void *cls,
- struct Session *session,
+ struct GNUNET_ATS_Session *session,
const char *msgbuf, size_t msgbuf_size,
unsigned int priority,
struct GNUNET_TIME_Relative to,
wlanheader->sender = *plugin->env->my_identity;
wlanheader->target = session->target;
wlanheader->crc = htonl (GNUNET_CRYPTO_crc32_n (msgbuf, msgbuf_size));
- memcpy (&wlanheader[1], msgbuf, msgbuf_size);
-
+ memcpy (&wlanheader[1],
+ msgbuf,
+ msgbuf_size);
GNUNET_STATISTICS_update (plugin->env->stats,
"# bytes currently in buffers",
msgbuf_size,
GNUNET_NO);
-
send_with_fragmentation (session->mac,
to,
&session->target,
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;
const struct WlanHeader *wlanheader;
int ret;
uint16_t msize;
- ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
-#if BUILD_WLAN
- ats.value = htonl (GNUNET_ATS_NET_WLAN);
-#else
- ats.value = htonl (GNUNET_ATS_NET_BT);
-#endif
msize = ntohs (hdr->size);
GNUNET_STATISTICS_update (plugin->env->stats,
PLUGIN_NAME,
&mas->endpoint->wlan_addr,
sizeof (mas->endpoint->wlan_addr),
- GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+ GNUNET_HELLO_ADDRESS_INFO_NONE);
+ 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,
+ scope);
+ }
plugin->env->receive (plugin->env->cls,
address,
mas->session,
hdr);
- plugin->env->update_address_metrics (plugin->env->cls,
- address,
- mas->session,
- &ats, 1);
GNUNET_HELLO_address_free (address);
break;
case GNUNET_MESSAGE_TYPE_FRAGMENT:
break;
}
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "ACK not matched against any active fragmentation with MAC `%s'\n",
- wlan_plugin_address_to_string (NULL,
- &mas->endpoint->wlan_addr,
- sizeof (mas->endpoint->wlan_addr)));
+ if (NULL == fm)
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "ACK not matched against any active fragmentation with MAC `%s'\n",
+ wlan_plugin_address_to_string (NULL,
+ &mas->endpoint->wlan_addr,
+ sizeof (mas->endpoint->wlan_addr)));
break;
case GNUNET_MESSAGE_TYPE_WLAN_DATA:
if (NULL == mas->endpoint)
GNUNET_NO);
break;
}
- xmas.endpoint = mas->endpoint;
- if (NULL == (xmas.session = lookup_session (mas->endpoint,
- &wlanheader->sender)))
+ mas->session = lookup_session (mas->endpoint,
+ &wlanheader->sender);
+ if (NULL == mas->session)
{
- xmas.session = create_session (mas->endpoint,
+ mas->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 (NULL,
+ plugin->env->session_start (plugin->env->cls,
address,
- xmas.session,
- NULL, 0);
+ mas->session,
+ scope);
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),
- xmas.session);
+ mas->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));
- xmas.session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ mas->session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
(void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer,
- &xmas,
+ mas,
(const char *) &wlanheader[1],
msize - sizeof (struct WlanHeader),
GNUNET_YES,
mas->session->address,
mas->session,
hdr);
- plugin->env->update_address_metrics (plugin->env->cls,
- mas->session->address,
- mas->session,
- &ats, 1);
break;
}
return GNUNET_OK;
}
+/**
+ * Task to (periodically) send a HELLO beacon
+ *
+ * @param cls pointer to the plugin struct
+ */
+static void
+send_hello_beacon (void *cls)
+{
+ struct Plugin *plugin = cls;
+ uint16_t size;
+ uint16_t hello_size;
+ struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader;
+ const struct GNUNET_MessageHeader *hello;
+
+ hello = plugin->env->get_our_hello ();
+ if (NULL != hello)
+ {
+ hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
+ GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU);
+ size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size;
+ {
+ char buf[size] GNUNET_ALIGN;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending %u byte HELLO beacon\n",
+ (unsigned int) size);
+ radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf;
+ get_radiotap_header (NULL, radioHeader, size);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Broadcasting %u bytes of data to MAC `%s'\n",
+ (unsigned int) size,
+ mac_to_string (&bc_all_mac));
+ get_wlan_header (plugin, &radioHeader->frame, &bc_all_mac, size);
+ memcpy (&radioHeader[1], hello, hello_size);
+ if (NULL !=
+ GNUNET_HELPER_send (plugin->suid_helper,
+ &radioHeader->header,
+ GNUNET_YES /* can drop */,
+ NULL, NULL))
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# HELLO beacons sent"),
+ 1, GNUNET_NO);
+ } }
+ plugin->beacon_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+ (HELLO_BEACON_SCALING_FACTOR,
+ plugin->mac_count + 1),
+ &send_hello_beacon,
+ plugin);
+
+}
+
+
/**
* Function used for to process the data from the suid process
*
struct WlanAddress wa;
struct MacAndSession mas;
uint16_t msize;
+ struct FragmentMessage *fm;
+ struct MacEndpoint *endpoint;
msize = ntohs (hdr->size);
switch (ntohs (hdr->type))
GNUNET_NO,
my_address);
GNUNET_HELLO_address_free (my_address);
+ plugin->mac_address = cm->mac;
+ }
+ else
+ {
+ plugin->mac_address = cm->mac;
+ plugin->have_mac = GNUNET_YES;
+ for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next)
+ {
+ for (fm = endpoint->sending_messages_head; NULL != fm; fm = fm->next)
+ {
+ if (NULL != fm->fragcontext)
+ {
+ GNUNET_break (0); /* should not happen */
+ continue;
+ }
+ fm->fragcontext =
+ GNUNET_FRAGMENT_context_create (plugin->env->stats,
+ WLAN_MTU,
+ &plugin->tracker,
+ fm->macendpoint->msg_delay,
+ fm->macendpoint->ack_delay,
+ fm->msg,
+ &transmit_fragment, fm);
+ GNUNET_free (fm->msg);
+ fm->msg = NULL;
+ }
+ }
+ GNUNET_break (NULL == plugin->beacon_task);
+ plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon,
+ plugin);
+
}
- plugin->mac_address = cm->mac;
- plugin->have_mac = GNUNET_YES;
memset (&wa, 0, sizeof (struct WlanAddress));
wa.mac = plugin->mac_address;
GNUNET_NO);
if (msize < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage))
{
- GNUNET_break (0);
- LOG (GNUNET_ERROR_TYPE_WARNING,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Size of packet is too small (%u bytes < %u)\n",
msize, sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage));
break;
"Receiving %u bytes of data from MAC `%s'\n",
(unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)),
mac_to_string (&rxinfo->frame.addr2));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Receiving %u bytes of data to MAC `%s'\n",
+ (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)),
+ mac_to_string (&rxinfo->frame.addr1));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Receiving %u bytes of data with BSSID MAC `%s'\n",
+ (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)),
+ mac_to_string (&rxinfo->frame.addr3));
wa.mac = rxinfo->frame.addr2;
wa.options = htonl (0);
mas.endpoint = create_macendpoint (plugin, &wa);
}
-/**
- * Task to (periodically) send a HELLO beacon
- *
- * @param cls pointer to the plugin struct
- * @param tc scheduler context
- */
-static void
-send_hello_beacon (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct Plugin *plugin = cls;
- uint16_t size;
- uint16_t hello_size;
- struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader;
- const struct GNUNET_MessageHeader *hello;
-
- hello = plugin->env->get_our_hello ();
- hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
- GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU);
- size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size;
- {
- char buf[size] GNUNET_ALIGN;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Sending %u byte HELLO beacon\n",
- (unsigned int) size);
- radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf;
- get_radiotap_header (NULL, radioHeader, size);
- get_wlan_header (plugin, &radioHeader->frame, &bc_all_mac, size);
- memcpy (&radioHeader[1], hello, hello_size);
- if (NULL !=
- GNUNET_HELPER_send (plugin->suid_helper,
- &radioHeader->header,
- GNUNET_YES /* can drop */,
- NULL, NULL))
- GNUNET_STATISTICS_update (plugin->env->stats,
- _("# HELLO beacons sent"),
- 1, GNUNET_NO);
- }
- plugin->beacon_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (HELLO_BEACON_SCALING_FACTOR,
- plugin->mac_count + 1),
- &send_hello_beacon,
- plugin);
-
-}
-
-
/**
* Another peer has suggested an address for this
* peer and transport plugin. Check that this could be a valid
GNUNET_HELLO_address_free (address);
}
- if (GNUNET_SCHEDULER_NO_TASK != plugin->beacon_task)
+ if (NULL != plugin->beacon_task)
{
GNUNET_SCHEDULER_cancel (plugin->beacon_task);
- plugin->beacon_task = GNUNET_SCHEDULER_NO_TASK;
+ plugin->beacon_task = NULL;
}
if (NULL != plugin->suid_helper)
{
{
struct Plugin *plugin = cls;
struct MacEndpoint *mac;
- struct Session *session;
+ struct GNUNET_ATS_Session *session;
plugin->sic = sic;
plugin->sic_cls = sic_cls;
{
for (mac = plugin->mac_head; NULL != mac; mac = mac->next)
for (session = mac->sessions_head; NULL != session; session = session->next)
+ {
+ notify_session_monitor (plugin,
+ session,
+ GNUNET_TRANSPORT_SS_INIT);
notify_session_monitor (plugin,
session,
GNUNET_TRANSPORT_SS_UP);
+ }
sic (sic_cls, NULL, NULL);
}
}
static void
wlan_plugin_update_session_timeout (void *cls,
const struct GNUNET_PeerIdentity *peer,
- struct Session *session)
+ struct GNUNET_ATS_Session *session)
{
- GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != session->timeout_task);
+ GNUNET_assert (NULL != session->timeout_task);
session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
}
static void
wlan_plugin_update_inbound_delay (void *cls,
const struct GNUNET_PeerIdentity *peer,
- struct Session *session,
+ struct GNUNET_ATS_Session *session,
struct GNUNET_TIME_Relative delay)
{
/* does nothing, as inbound delay is not supported by WLAN */
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->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon,
- 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->options = 0;
api->address_to_string = &wlan_plugin_address_to_string;
api->string_to_address = &wlan_plugin_string_to_address;
api->get_network = &wlan_plugin_get_network;
+ api->get_network_for_address = &wlan_plugin_get_network_for_address;
api->update_session_timeout = &wlan_plugin_update_session_timeout;
api->update_inbound_delay = &wlan_plugin_update_inbound_delay;
api->setup_monitor = &wlan_plugin_setup_monitor;