/*
This file is part of GNUnet
- (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
+ (C) 2010-2014 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
/**
* @file transport/plugin_transport_wlan.c
- * @brief transport plugin for wlan
+ * @brief transport plugin for wlan and/or bluetooth
* @author David Brodski
* @author Christian Grothoff
+ *
+ * BUILD_WLAN or BUILD_BLUETOOTH must be defined such that the respective
+ * variant of this code is compiled.
*/
#include "platform.h"
+#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
-#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_plugin.h"
#include "plugin_transport_wlan.h"
-#include "gnunet_common.h"
-#include "gnunet_crypto_lib.h"
#include "gnunet_fragmentation_lib.h"
#include "gnunet_constants.h"
+#if BUILD_WLAN
+/* begin case wlan */
+#define PLUGIN_NAME "wlan"
+#define CONFIG_NAME "transport-wlan"
+#define HELPER_NAME "gnunet-helper-transport-wlan"
+#define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy"
+#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_wlan_init
+#define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_wlan_done
#define LOG(kind,...) GNUNET_log_from (kind, "transport-wlan",__VA_ARGS__)
-#define PLUGIN_NAME "wlan"
+/**
+ * time out of a mac endpoint
+ */
+#define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2)
/**
- * Max size of packet (that we give to the WLAN driver for transmission)
+ * We reduce the frequence of HELLO beacons in relation to
+ * the number of MAC addresses currently visible to us.
+ * This is the multiplication factor.
*/
-#define WLAN_MTU 1430
+#define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
+
+
+/* end case wlan */
+#elif BUILD_BLUETOOTH
+/* begin case bluetooth */
+
+#define PLUGIN_NAME "bluetooth"
+#define CONFIG_NAME "transport-bluetooth"
+#define HELPER_NAME "gnunet-helper-transport-bluetooth"
+/* yes, this is correct, we use the same dummy driver as 'wlan' */
+#define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy"
+#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_bluetooth_init
+#define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_bluetooth_done
+#define LOG(kind,...) GNUNET_log_from (kind, "transport-bluetooth",__VA_ARGS__)
/**
* time out of a mac endpoint
*/
-#define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2)
+#define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 60)
+
/**
* We reduce the frequence of HELLO beacons in relation to
* the number of MAC addresses currently visible to us.
* This is the multiplication factor.
*/
-#define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
+#define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+
+/* end case bluetooth */
+#else
+#error need to build wlan or bluetooth
+#endif
+
+/**
+ * Max size of packet (that we give to the WLAN driver for transmission)
+ */
+#define WLAN_MTU 1430
+
+
/**
* Maximum number of messages in defragmentation queue per MAC
/**
* We keep all sessions in a DLL at their respective
- * 'struct MACEndpoint'.
+ * `struct MACEndpoint *`.
*/
struct Session *prev;
*/
struct GNUNET_HELLO_Address *address;
- /**
- * Head of messages currently pending for transmission to this peer.
- */
- struct PendingMessage *pending_message_head;
-
- /**
- * Tail of messages currently pending for transmission to this peer.
- */
- struct PendingMessage *pending_message_tail;
-
/**
* When should this session time out?
*/
*/
GNUNET_SCHEDULER_TaskIdentifier timeout_task;
- /**
- * Number of bytes waiting for transmission to this peer.
- */
- unsigned long long bytes_in_queue;
-
- /**
- * Number of messages waiting for transmission to this peer.
- */
- unsigned int msgs_in_queue;
-
};
/**
* The interface of the wlan card given to us by the user.
*/
- char *interface;
+ char *wlan_interface;
/**
- * Tokenizer for demultiplexing of data packets resulting from defragmentation.
+ * Tokenizer for demultiplexing of data packets resulting from
+ * defragmentation.
*/
struct GNUNET_SERVER_MessageStreamTokenizer *fragment_data_tokenizer;
* Print MAC addresses nicely.
*
* @param mac the mac address
- * @return string to a static buffer with the human-readable mac, will be overwritten during the next call to this function
+ * @return string to a static buffer with
+ * the human-readable mac, will be overwritten during the next call to
+ * this function
*/
static const char *
mac_to_string (const struct GNUNET_TRANSPORT_WLAN_MacAddress * mac)
memset (&info, 0, sizeof (info));
info.state = state;
info.is_inbound = GNUNET_SYSERR; /* hard to say */
- // info.num_msg_pending = session->msgs_in_queue; // FIXME
- // info.num_bytes_pending = session->bytes_in_queue; // FIXME
- info.receive_delay = GNUNET_TIME_UNIT_ZERO_ABS;
+ info.num_msg_pending = 0; /* we queue per MAC, not per peer */
+ info.num_bytes_pending = 0; /* we queue per MAC, not per peer */
+ info.receive_delay = GNUNET_TIME_UNIT_ZERO_ABS; /* not supported by WLAN */
info.session_timeout = session->timeout;
- info.address = session->address; // ?
+ info.address = session->address;
plugin->sic (plugin->sic_cls,
session,
&info);
GNUNET_break (0);
return;
}
-
if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
GNUNET_NO /* dropping ACKs is bad */,
NULL, NULL))
GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
- _("# WLAN ACKs sent"),
+ _("# ACKs sent"),
1, GNUNET_NO);
}
struct MacAndSession mas;
GNUNET_STATISTICS_update (plugin->env->stats,
- _("# WLAN messages defragmented"), 1,
+ _("# Messages defragmented"),
+ 1,
GNUNET_NO);
mas.session = NULL;
mas.endpoint = endpoint;
struct Session *session)
{
struct MacEndpoint *endpoint = session->mac;
- struct PendingMessage *pm;
+ struct Plugin *plugin = endpoint->plugin;
- endpoint->plugin->env->session_end (endpoint->plugin->env->cls,
- session->address,
- session);
- while (NULL != (pm = session->pending_message_head))
- {
- GNUNET_CONTAINER_DLL_remove (session->pending_message_head,
- session->pending_message_tail,
- pm);
- if (GNUNET_SCHEDULER_NO_TASK != pm->timeout_task)
- {
- GNUNET_SCHEDULER_cancel (pm->timeout_task);
- pm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
- }
- GNUNET_free (pm->msg);
- GNUNET_free (pm);
- }
+ plugin->env->session_end (plugin->env->cls,
+ session->address,
+ session);
+ notify_session_monitor (plugin,
+ session,
+ GNUNET_TRANSPORT_SS_DOWN);
GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head,
endpoint->sessions_tail,
session);
GNUNET_SCHEDULER_cancel (session->timeout_task);
session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
- _("# WLAN sessions allocated"), -1,
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# Sessions allocated"),
+ -1,
GNUNET_NO);
GNUNET_HELLO_address_free (session->address);
GNUNET_free (session);
* A session is timing out. Clean up.
*
* @param cls pointer to the Session
- * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
+ * @param tc unused
*/
static void
session_timeout (void *cls,
struct Session *session;
GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
- _("# WLAN sessions allocated"),
+ _("# Sessions allocated"),
1,
GNUNET_NO);
session = GNUNET_new (struct 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_UP);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Created new session %p for peer `%s' with endpoint %s\n",
session,
* the next fragment.
*
* @param cls the `struct FragmentMessage *`
- * @param result result of the operation (#GNUNET_OK on success, #GNUNET_NO if the helper died, #GNUNET_SYSERR
+ * @param result result of the operation (#GNUNET_OK on success,
+ * #GNUNET_NO if the helper died, #GNUNET_SYSERR
* if the helper was stopped)
*/
static void
if (NULL == endpoint)
{
- GNUNET_break (0);
- return;
+ GNUNET_break (0);
+ return;
}
-
msize = ntohs (hdr->size);
size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize;
{
&fragment_transmission_done, fm);
fm->size_on_wire += size;
if (NULL != fm->sh)
- GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN message fragments sent"),
- 1, GNUNET_NO);
+ 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 WLAN buffers",
+ "# bytes currently in buffers",
-msize, GNUNET_NO);
GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
- "# bytes transmitted via WLAN",
+ "# bytes transmitted",
msize, GNUNET_NO);
}
}
{
struct MacEndpoint *endpoint = fm->macendpoint;
- GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN messages pending (with fragmentation)"),
+ GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
+ _("# messages pending (with fragmentation)"),
-1, GNUNET_NO);
GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head,
- endpoint->sending_messages_tail, fm);
+ endpoint->sending_messages_tail,
+ fm);
if (NULL != fm->sh)
{
GNUNET_HELPER_send_cancel (fm->sh);
* A FragmentMessage has timed out. Remove it.
*
* @param cls pointer to the 'struct FragmentMessage'
- * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
+ * @param tc unused
*/
static void
fragmentmessage_timeout (void *cls,
fm->macendpoint = endpoint;
fm->target = *target;
fm->size_payload = payload_size;
- fm->size_on_wire = 0;
fm->timeout = GNUNET_TIME_relative_to_absolute (timeout);
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,
+ GNUNET_FRAGMENT_context_create (plugin->env->stats,
+ WLAN_MTU,
&plugin->tracker,
endpoint->msg_delay,
endpoint->ack_delay,
struct Session *session;
GNUNET_STATISTICS_update (plugin->env->stats,
- _("# WLAN MAC endpoints allocated"),
+ _("# MAC endpoints allocated"),
-1,
GNUNET_NO);
while (NULL != (session = endpoint->sessions_head))
/**
* A MAC endpoint is timing out. Clean up.
*
- * @param cls pointer to the `struct MacEndpoint`
+ * @param cls pointer to the `struct MacEndpoint *`
* @param tc pointer to the GNUNET_SCHEDULER_TaskContext
*/
static void
struct MacEndpoint *pos;
for (pos = plugin->mac_head; NULL != pos; pos = pos->next)
- {
if (0 == memcmp (mac, &pos->wlan_addr, sizeof (pos->wlan_addr)))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing MAC endpoint `%s'\n",
- wlan_plugin_address_to_string (NULL,
- &pos->wlan_addr.mac,
- sizeof (pos->wlan_addr)));
return pos;
- }
- }
pos = GNUNET_new (struct MacEndpoint);
pos->wlan_addr = (*mac);
pos->plugin = plugin;
pos->defrag =
- GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
+ GNUNET_DEFRAGMENT_context_create (plugin->env->stats,
+ WLAN_MTU,
MESSAGES_IN_DEFRAG_QUEUE_PER_MAC,
pos,
&wlan_data_message_handler,
pos->timeout_task =
GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
pos);
- GNUNET_CONTAINER_DLL_insert (plugin->mac_head, plugin->mac_tail, pos);
+ GNUNET_CONTAINER_DLL_insert (plugin->mac_head,
+ plugin->mac_tail,
+ pos);
plugin->mac_count++;
- GNUNET_STATISTICS_update (plugin->env->stats, _("# WLAN MAC endpoints allocated"),
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# MAC endpoints allocated"),
1, GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"New MAC endpoint `%s'\n",
wlan_plugin_get_network (void *cls,
struct Session *session)
{
+#if BUILD_WLAN
return GNUNET_ATS_NET_WLAN;
+#else
+ return GNUNET_ATS_NET_BT;
+#endif
}
wlan_plugin_address_to_string (NULL,
address->address,
address->address_length));
- endpoint = create_macendpoint (plugin, (struct WlanAddress *) address->address);
+ endpoint = create_macendpoint (plugin,
+ (struct WlanAddress *) address->address);
return get_session (endpoint, &address->peer);
}
memcpy (&wlanheader[1], msgbuf, msgbuf_size);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# bytes currently in WLAN buffers",
- msgbuf_size, GNUNET_NO);
+ "# bytes currently in buffers",
+ msgbuf_size,
+ GNUNET_NO);
send_with_fragmentation (session->mac,
to,
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,
- "# bytes received via WLAN",
+ "# bytes received",
msize, GNUNET_NO);
switch (ntohs (hdr->type))
case GNUNET_MESSAGE_TYPE_HELLO:
if (GNUNET_OK !=
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource))
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr,
+ &tmpsource))
{
GNUNET_break_op (0);
break;
sizeof (mas->endpoint->wlan_addr)));
GNUNET_STATISTICS_update (plugin->env->stats,
- _("# HELLO messages received via WLAN"), 1,
+ _("# HELLO messages received"), 1,
GNUNET_NO);
-
- address = GNUNET_HELLO_address_allocate (&tmpsource, PLUGIN_NAME,
- &mas->endpoint->wlan_addr, sizeof (mas->endpoint->wlan_addr),
- GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+ address = GNUNET_HELLO_address_allocate (&tmpsource,
+ PLUGIN_NAME,
+ &mas->endpoint->wlan_addr,
+ sizeof (mas->endpoint->wlan_addr),
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND);
plugin->env->receive (plugin->env->cls,
- address, mas->session, hdr);
+ address,
+ mas->session,
+ hdr);
plugin->env->update_address_metrics (plugin->env->cls,
- address, mas->session, &ats, 1);
+ address,
+ mas->session,
+ &ats, 1);
GNUNET_HELLO_address_free (address);
break;
case GNUNET_MESSAGE_TYPE_FRAGMENT:
&mas->endpoint->wlan_addr,
sizeof (mas->endpoint->wlan_addr)));
GNUNET_STATISTICS_update (plugin->env->stats,
- _("# fragments received via WLAN"), 1, GNUNET_NO);
+ _("# fragments received"),
+ 1,
+ GNUNET_NO);
(void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag,
hdr);
break;
GNUNET_break (0);
break;
}
- GNUNET_STATISTICS_update (plugin->env->stats, _("# ACKs received via WLAN"),
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# ACKs received"),
1, GNUNET_NO);
for (fm = mas->endpoint->sending_messages_head; NULL != fm; fm = fm->next)
{
mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
if (NULL != fm->cont)
{
- fm->cont (fm->cont_cls, &fm->target, GNUNET_OK, fm->size_payload, fm->size_on_wire);
+ fm->cont (fm->cont_cls,
+ &fm->target,
+ GNUNET_OK,
+ fm->size_payload,
+ fm->size_on_wire);
fm->cont = NULL;
}
free_fragment_message (fm);
sizeof (struct GNUNET_PeerIdentity)))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "WLAN data for `%s', not for me, ignoring\n",
+ "Data for `%s', not for me, ignoring\n",
GNUNET_i2s (&wlanheader->target));
break;
}
if (ntohl (wlanheader->crc) !=
- GNUNET_CRYPTO_crc32_n (&wlanheader[1], msize - sizeof (struct WlanHeader)))
+ GNUNET_CRYPTO_crc32_n (&wlanheader[1],
+ msize - sizeof (struct WlanHeader)))
{
GNUNET_STATISTICS_update (plugin->env->stats,
- _("# WLAN DATA messages discarded due to CRC32 error"), 1,
+ _("# DATA messages discarded due to CRC32 error"),
+ 1,
GNUNET_NO);
break;
}
if (NULL == (xmas.session = lookup_session (mas->endpoint,
&wlanheader->sender)))
{
- xmas.session = create_session (mas->endpoint, &wlanheader->sender);
+ 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 (NULL, address, xmas.session, NULL, 0);
+ plugin->env->session_start (NULL,
+ address,
+ xmas.session,
+ NULL, 0);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Notifying transport about peer `%s''s new session %p \n",
- GNUNET_i2s (&wlanheader->sender), xmas.session);
+ GNUNET_i2s (&wlanheader->sender),
+ xmas.session);
GNUNET_HELLO_address_free (address);
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Processing %u bytes of WLAN DATA from peer `%s'\n",
+ "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);
(unsigned int) ntohs (hdr->type),
GNUNET_i2s (&mas->session->target));
plugin->env->receive (plugin->env->cls,
- mas->session->address,
- mas->session,
- hdr);
+ mas->session->address,
+ mas->session,
+ hdr);
plugin->env->update_address_metrics (plugin->env->cls,
- mas->session->address,
- mas->session,
- &ats, 1);
+ mas->session->address,
+ mas->session,
+ &ats, 1);
break;
}
return GNUNET_OK;
wa.mac = plugin->mac_address;
wa.options = htonl(plugin->options);
my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
- PLUGIN_NAME, &wa, sizeof (wa), GNUNET_HELLO_ADDRESS_INFO_NONE);
- plugin->env->notify_address (plugin->env->cls, GNUNET_NO, my_address);
+ PLUGIN_NAME,
+ &wa, sizeof (wa),
+ GNUNET_HELLO_ADDRESS_INFO_NONE);
+ plugin->env->notify_address (plugin->env->cls,
+ GNUNET_NO,
+ my_address);
GNUNET_HELLO_address_free (my_address);
}
plugin->mac_address = cm->mac;
wa.mac = plugin->mac_address;
wa.options = htonl(plugin->options);
my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
- PLUGIN_NAME, &wa, sizeof (wa), GNUNET_HELLO_ADDRESS_INFO_NONE);
+ PLUGIN_NAME,
+ &wa, sizeof (wa),
+ GNUNET_HELLO_ADDRESS_INFO_NONE);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n",
mac_to_string (&cm->mac),
GNUNET_i2s (plugin->env->my_identity));
- plugin->env->notify_address (plugin->env->cls, GNUNET_YES, my_address);
+ plugin->env->notify_address (plugin->env->cls,
+ GNUNET_YES,
+ my_address);
GNUNET_HELLO_address_free (my_address);
break;
case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER:
"Got data message from helper with %u bytes\n",
msize);
GNUNET_STATISTICS_update (plugin->env->stats,
- _("# DATA messages received via WLAN"), 1,
+ _("# DATA messages received"), 1,
GNUNET_NO);
if (msize < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage))
{
}
GNUNET_STATISTICS_update (plugin->env->stats,
- _("# WLAN DATA messages processed"),
+ _("# DATA messages processed"),
1, GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Receiving %u bytes of data from MAC `%s'\n",
}
-
/**
* Task to (periodically) send a HELLO beacon
*
&radioHeader->header,
GNUNET_YES /* can drop */,
NULL, NULL))
- GNUNET_STATISTICS_update (plugin->env->stats, _("# HELLO beacons sent via WLAN"),
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ _("# HELLO beacons sent"),
1, GNUNET_NO);
}
plugin->beacon_task =
* @param cls pointer to the api struct
*/
void *
-libgnunet_plugin_transport_wlan_done (void *cls)
+LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
{
struct WlanAddress wa;
struct GNUNET_HELLO_Address *address;
GNUNET_free (api);
return NULL;
}
-
if (GNUNET_YES == plugin->have_mac)
{
memset (&wa, 0, sizeof(wa));
wa.options = htonl (plugin->options);
wa.mac = plugin->mac_address;
address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
- PLUGIN_NAME, &wa, sizeof (struct WlanAddress),
- GNUNET_HELLO_ADDRESS_INFO_NONE);
+ PLUGIN_NAME,
+ &wa, sizeof (struct WlanAddress),
+ GNUNET_HELLO_ADDRESS_INFO_NONE);
- plugin->env->notify_address (plugin->env->cls, GNUNET_NO, address);
+ plugin->env->notify_address (plugin->env->cls,
+ GNUNET_NO,
+ address);
plugin->have_mac = GNUNET_NO;
-
GNUNET_HELLO_address_free (address);
}
}
if (NULL != plugin->suid_helper)
{
- GNUNET_HELPER_stop (plugin->suid_helper, GNUNET_NO);
+ GNUNET_HELPER_stop (plugin->suid_helper,
+ GNUNET_NO);
plugin->suid_helper = NULL;
}
endpoint_next = plugin->mac_head;
GNUNET_SERVER_mst_destroy (plugin->helper_payload_tokenizer);
plugin->helper_payload_tokenizer = NULL;
}
- GNUNET_free_non_null (plugin->interface);
+ GNUNET_free_non_null (plugin->wlan_interface);
GNUNET_free (plugin);
GNUNET_free (api);
return NULL;
char plugin[5];
uint32_t options;
- if ((NULL == addr) || (addrlen == 0))
+ if ((NULL == addr) || (0 == addrlen))
{
GNUNET_break (0);
return GNUNET_SYSERR;
if (8 != SSCANF (addr,
"%4s.%u.%X:%X:%X:%X:%X:%X",
plugin, &options,
- &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
+ &a[0], &a[1], &a[2],
+ &a[3], &a[4], &a[5]))
{
GNUNET_break (0);
return GNUNET_SYSERR;
const struct GNUNET_PeerIdentity *peer,
struct Session *session)
{
- GNUNET_assert (session->timeout_task != GNUNET_SCHEDULER_NO_TASK);
+ GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != session->timeout_task);
session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
}
* @return the `struct GNUNET_TRANSPORT_PluginFunctions *` or NULL on error
*/
void *
-libgnunet_plugin_transport_wlan_init (void *cls)
+LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
{
struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
struct GNUNET_TRANSPORT_PluginFunctions *api;
struct Plugin *plugin;
- char *interface;
+ char *wlan_interface;
unsigned long long testmode;
char *binary;
testmode = 0;
/* check configuration */
if ( (GNUNET_YES ==
- GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE")) &&
+ GNUNET_CONFIGURATION_have_value (env->cfg,
+ CONFIG_NAME,
+ "TESTMODE")) &&
( (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan",
- "TESTMODE", &testmode)) ||
+ GNUNET_CONFIGURATION_get_value_number (env->cfg,
+ CONFIG_NAME,
+ "TESTMODE",
+ &testmode)) ||
(testmode > 2) ) )
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "transport-wlan", "TESTMODE");
+ CONFIG_NAME,
+ "TESTMODE");
return NULL;
}
- binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-transport-wlan");
+ binary = GNUNET_OS_get_libexec_binary_path (HELPER_NAME);
if ( (0 == testmode) &&
(GNUNET_YES !=
- GNUNET_OS_check_helper_binary (binary, GNUNET_YES, NULL)) )
+ GNUNET_OS_check_helper_binary (binary,
+ GNUNET_YES,
+ NULL)) )
{
LOG (GNUNET_ERROR_TYPE_ERROR,
_("Helper binary `%s' not SUID, cannot run WLAN transport\n"),
- "gnunet-helper-transport-wlan");
+ HELPER_NAME);
GNUNET_free (binary);
return NULL;
}
GNUNET_free (binary);
if (GNUNET_YES !=
GNUNET_CONFIGURATION_get_value_string (env->cfg,
- "transport-wlan",
+ CONFIG_NAME,
"INTERFACE",
- &interface))
+ &wlan_interface))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "transport-wlan", "INTERFACE");
+ CONFIG_NAME,
+ "INTERFACE");
return NULL;
}
plugin = GNUNET_new (struct Plugin);
- plugin->interface = interface;
+ plugin->wlan_interface = wlan_interface;
plugin->env = env;
GNUNET_STATISTICS_set (plugin->env->stats,
- _("# WLAN sessions allocated"),
+ _("# sessions allocated"),
0, GNUNET_NO);
GNUNET_STATISTICS_set (plugin->env->stats,
- _("# WLAN MAC endpoints allocated"),
+ _("# MAC endpoints allocated"),
0, 0);
GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, NULL, NULL,
GNUNET_BANDWIDTH_value_init (100 * 1024 *
switch ((unsigned int) testmode)
{
case 0: /* normal */
- plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan";
- plugin->helper_argv[1] = interface;
+ plugin->helper_argv[0] = (char *) HELPER_NAME;
+ plugin->helper_argv[1] = wlan_interface;
plugin->helper_argv[2] = NULL;
plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
- "gnunet-helper-transport-wlan",
+ HELPER_NAME,
plugin->helper_argv,
&handle_helper_message,
NULL,
plugin);
break;
case 1: /* testmode, peer 1 */
- plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
+ plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME;
plugin->helper_argv[1] = (char *) "1";
plugin->helper_argv[2] = NULL;
plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
- "gnunet-helper-transport-wlan-dummy",
+ DUMMY_HELPER_NAME,
plugin->helper_argv,
&handle_helper_message,
NULL,
plugin);
break;
case 2: /* testmode, peer 2 */
- plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
+ plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME;
plugin->helper_argv[1] = (char *) "2";
plugin->helper_argv[2] = NULL;
plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
- "gnunet-helper-transport-wlan-dummy",
+ DUMMY_HELPER_NAME,
plugin->helper_argv,
&handle_helper_message,
NULL,