/*
This file is part of GNUnet
- (C) 2010-2014 Christian Grothoff (and other contributing authors)
+ Copyright (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
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
}
+/**
+ * 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;
+#else
+ return GNUNET_ATS_NET_BT;
+#endif
+}
+
+
/**
* Creates a new outbound session the transport service will use to
* send data to the peer
struct Plugin *plugin = cls;
struct GNUNET_HELLO_Address *address;
struct MacAndSession *mas = client;
- 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->env->session_start (plugin->env->cls,
address,
mas->session,
- &ats, 1);
+ 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)
plugin->env->session_start (plugin->env->cls,
address,
mas->session,
- NULL, 0);
+ scope);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Notifying transport about peer `%s''s new session %p \n",
GNUNET_i2s (&wlanheader->sender),
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;
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;
+ 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;
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,
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;