aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c183
1 files changed, 115 insertions, 68 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index a42f1a940..32c43a3aa 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2010-2014 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -20,43 +20,84 @@
20 20
21/** 21/**
22 * @file transport/plugin_transport_wlan.c 22 * @file transport/plugin_transport_wlan.c
23 * @brief transport plugin for wlan 23 * @brief transport plugin for wlan and/or bluetooth
24 * @author David Brodski 24 * @author David Brodski
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 *
27 * BUILD_WLAN or BUILD_BLUETOOTH must be defined such that the respective
28 * variant of this code is compiled.
26 */ 29 */
27#include "platform.h" 30#include "platform.h"
31#include "gnunet_util_lib.h"
28#include "gnunet_hello_lib.h" 32#include "gnunet_hello_lib.h"
29#include "gnunet_protocols.h" 33#include "gnunet_protocols.h"
30#include "gnunet_util_lib.h"
31#include "gnunet_statistics_service.h" 34#include "gnunet_statistics_service.h"
32#include "gnunet_transport_service.h" 35#include "gnunet_transport_service.h"
33#include "gnunet_transport_plugin.h" 36#include "gnunet_transport_plugin.h"
34#include "plugin_transport_wlan.h" 37#include "plugin_transport_wlan.h"
35#include "gnunet_common.h"
36#include "gnunet_crypto_lib.h"
37#include "gnunet_fragmentation_lib.h" 38#include "gnunet_fragmentation_lib.h"
38#include "gnunet_constants.h" 39#include "gnunet_constants.h"
39 40
41#if BUILD_WLAN
42/* begin case wlan */
43#define PLUGIN_NAME "wlan"
44#define CONFIG_NAME "transport-wlan"
45#define HELPER_NAME "gnunet-helper-transport-wlan"
46#define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy"
47#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_wlan_init
48#define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_wlan_done
40#define LOG(kind,...) GNUNET_log_from (kind, "transport-wlan",__VA_ARGS__) 49#define LOG(kind,...) GNUNET_log_from (kind, "transport-wlan",__VA_ARGS__)
41 50
42#define PLUGIN_NAME "wlan" 51/**
52 * time out of a mac endpoint
53 */
54#define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2)
43 55
44/** 56/**
45 * Max size of packet (that we give to the WLAN driver for transmission) 57 * We reduce the frequence of HELLO beacons in relation to
58 * the number of MAC addresses currently visible to us.
59 * This is the multiplication factor.
46 */ 60 */
47#define WLAN_MTU 1430 61#define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
62
63
64/* end case wlan */
65#elif BUILD_BLUETOOTH
66/* begin case bluetooth */
67
68#define PLUGIN_NAME "bluetooth"
69#define CONFIG_NAME "transport-bluetooth"
70#define HELPER_NAME "gnunet-helper-transport-bluetooth"
71/* yes, this is correct, we use the same dummy driver as 'wlan' */
72#define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy"
73#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_bluetooth_init
74#define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_bluetooth_done
75#define LOG(kind,...) GNUNET_log_from (kind, "transport-bluetooth",__VA_ARGS__)
48 76
49/** 77/**
50 * time out of a mac endpoint 78 * time out of a mac endpoint
51 */ 79 */
52#define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2) 80#define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 60)
81
53 82
54/** 83/**
55 * We reduce the frequence of HELLO beacons in relation to 84 * We reduce the frequence of HELLO beacons in relation to
56 * the number of MAC addresses currently visible to us. 85 * the number of MAC addresses currently visible to us.
57 * This is the multiplication factor. 86 * This is the multiplication factor.
58 */ 87 */
59#define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2) 88#define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
89
90/* end case bluetooth */
91#else
92#error need to build wlan or bluetooth
93#endif
94
95/**
96 * Max size of packet (that we give to the WLAN driver for transmission)
97 */
98#define WLAN_MTU 1430
99
100
60 101
61/** 102/**
62 * Maximum number of messages in defragmentation queue per MAC 103 * Maximum number of messages in defragmentation queue per MAC
@@ -661,7 +702,6 @@ send_ack (void *cls, uint32_t msg_id,
661 GNUNET_break (0); 702 GNUNET_break (0);
662 return; 703 return;
663 } 704 }
664
665 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 705 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
666 { 706 {
667 GNUNET_break (0); 707 GNUNET_break (0);
@@ -682,7 +722,7 @@ send_ack (void *cls, uint32_t msg_id,
682 GNUNET_NO /* dropping ACKs is bad */, 722 GNUNET_NO /* dropping ACKs is bad */,
683 NULL, NULL)) 723 NULL, NULL))
684 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, 724 GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
685 _("# WLAN ACKs sent"), 725 _("# ACKs sent"),
686 1, GNUNET_NO); 726 1, GNUNET_NO);
687} 727}
688 728
@@ -702,7 +742,7 @@ wlan_data_message_handler (void *cls,
702 struct MacAndSession mas; 742 struct MacAndSession mas;
703 743
704 GNUNET_STATISTICS_update (plugin->env->stats, 744 GNUNET_STATISTICS_update (plugin->env->stats,
705 _("# WLAN messages defragmented"), 745 _("# Messages defragmented"),
706 1, 746 1,
707 GNUNET_NO); 747 GNUNET_NO);
708 mas.session = NULL; 748 mas.session = NULL;
@@ -743,7 +783,7 @@ wlan_plugin_disconnect_session (void *cls,
743 session->timeout_task = GNUNET_SCHEDULER_NO_TASK; 783 session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
744 } 784 }
745 GNUNET_STATISTICS_update (plugin->env->stats, 785 GNUNET_STATISTICS_update (plugin->env->stats,
746 _("# WLAN sessions allocated"), 786 _("# Sessions allocated"),
747 -1, 787 -1,
748 GNUNET_NO); 788 GNUNET_NO);
749 GNUNET_HELLO_address_free (session->address); 789 GNUNET_HELLO_address_free (session->address);
@@ -771,7 +811,7 @@ wlan_plugin_query_keepalive_factor (void *cls)
771 * A session is timing out. Clean up. 811 * A session is timing out. Clean up.
772 * 812 *
773 * @param cls pointer to the Session 813 * @param cls pointer to the Session
774 * @param tc pointer to the GNUNET_SCHEDULER_TaskContext 814 * @param tc unused
775 */ 815 */
776static void 816static void
777session_timeout (void *cls, 817session_timeout (void *cls,
@@ -830,7 +870,7 @@ create_session (struct MacEndpoint *endpoint,
830 struct Session *session; 870 struct Session *session;
831 871
832 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, 872 GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
833 _("# WLAN sessions allocated"), 873 _("# Sessions allocated"),
834 1, 874 1,
835 GNUNET_NO); 875 GNUNET_NO);
836 session = GNUNET_new (struct Session); 876 session = GNUNET_new (struct Session);
@@ -848,7 +888,7 @@ create_session (struct MacEndpoint *endpoint,
848 session->timeout_task = 888 session->timeout_task =
849 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, 889 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout,
850 session); 890 session);
851 notify_session_monitor (plugin, 891 notify_session_monitor (endpoint->plugin,
852 session, 892 session,
853 GNUNET_TRANSPORT_SS_UP); 893 GNUNET_TRANSPORT_SS_UP);
854 LOG (GNUNET_ERROR_TYPE_DEBUG, 894 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -919,10 +959,9 @@ transmit_fragment (void *cls,
919 959
920 if (NULL == endpoint) 960 if (NULL == endpoint)
921 { 961 {
922 GNUNET_break (0); 962 GNUNET_break (0);
923 return; 963 return;
924 } 964 }
925
926 msize = ntohs (hdr->size); 965 msize = ntohs (hdr->size);
927 size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize; 966 size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize;
928 { 967 {
@@ -944,16 +983,16 @@ transmit_fragment (void *cls,
944 fm->size_on_wire += size; 983 fm->size_on_wire += size;
945 if (NULL != fm->sh) 984 if (NULL != fm->sh)
946 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, 985 GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
947 _("# WLAN message fragments sent"), 986 _("# message fragments sent"),
948 1, 987 1,
949 GNUNET_NO); 988 GNUNET_NO);
950 else 989 else
951 GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext); 990 GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext);
952 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, 991 GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
953 "# bytes currently in WLAN buffers", 992 "# bytes currently in buffers",
954 -msize, GNUNET_NO); 993 -msize, GNUNET_NO);
955 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, 994 GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
956 "# bytes transmitted via WLAN", 995 "# bytes transmitted",
957 msize, GNUNET_NO); 996 msize, GNUNET_NO);
958 } 997 }
959} 998}
@@ -970,7 +1009,7 @@ free_fragment_message (struct FragmentMessage *fm)
970 struct MacEndpoint *endpoint = fm->macendpoint; 1009 struct MacEndpoint *endpoint = fm->macendpoint;
971 1010
972 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, 1011 GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
973 _("# WLAN messages pending (with fragmentation)"), 1012 _("# messages pending (with fragmentation)"),
974 -1, GNUNET_NO); 1013 -1, GNUNET_NO);
975 GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head, 1014 GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head,
976 endpoint->sending_messages_tail, 1015 endpoint->sending_messages_tail,
@@ -1050,7 +1089,6 @@ send_with_fragmentation (struct MacEndpoint *endpoint,
1050 fm->macendpoint = endpoint; 1089 fm->macendpoint = endpoint;
1051 fm->target = *target; 1090 fm->target = *target;
1052 fm->size_payload = payload_size; 1091 fm->size_payload = payload_size;
1053 fm->size_on_wire = 0;
1054 fm->timeout = GNUNET_TIME_relative_to_absolute (timeout); 1092 fm->timeout = GNUNET_TIME_relative_to_absolute (timeout);
1055 fm->cont = cont; 1093 fm->cont = cont;
1056 fm->cont_cls = cont_cls; 1094 fm->cont_cls = cont_cls;
@@ -1085,7 +1123,7 @@ free_macendpoint (struct MacEndpoint *endpoint)
1085 struct Session *session; 1123 struct Session *session;
1086 1124
1087 GNUNET_STATISTICS_update (plugin->env->stats, 1125 GNUNET_STATISTICS_update (plugin->env->stats,
1088 _("# WLAN MAC endpoints allocated"), 1126 _("# MAC endpoints allocated"),
1089 -1, 1127 -1,
1090 GNUNET_NO); 1128 GNUNET_NO);
1091 while (NULL != (session = endpoint->sessions_head)) 1129 while (NULL != (session = endpoint->sessions_head))
@@ -1154,16 +1192,8 @@ create_macendpoint (struct Plugin *plugin,
1154 struct MacEndpoint *pos; 1192 struct MacEndpoint *pos;
1155 1193
1156 for (pos = plugin->mac_head; NULL != pos; pos = pos->next) 1194 for (pos = plugin->mac_head; NULL != pos; pos = pos->next)
1157 {
1158 if (0 == memcmp (mac, &pos->wlan_addr, sizeof (pos->wlan_addr))) 1195 if (0 == memcmp (mac, &pos->wlan_addr, sizeof (pos->wlan_addr)))
1159 {
1160 LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing MAC endpoint `%s'\n",
1161 wlan_plugin_address_to_string (NULL,
1162 &pos->wlan_addr.mac,
1163 sizeof (pos->wlan_addr)));
1164 return pos; 1196 return pos;
1165 }
1166 }
1167 pos = GNUNET_new (struct MacEndpoint); 1197 pos = GNUNET_new (struct MacEndpoint);
1168 pos->wlan_addr = (*mac); 1198 pos->wlan_addr = (*mac);
1169 pos->plugin = plugin; 1199 pos->plugin = plugin;
@@ -1186,7 +1216,7 @@ create_macendpoint (struct Plugin *plugin,
1186 pos); 1216 pos);
1187 plugin->mac_count++; 1217 plugin->mac_count++;
1188 GNUNET_STATISTICS_update (plugin->env->stats, 1218 GNUNET_STATISTICS_update (plugin->env->stats,
1189 _("# WLAN MAC endpoints allocated"), 1219 _("# MAC endpoints allocated"),
1190 1, GNUNET_NO); 1220 1, GNUNET_NO);
1191 LOG (GNUNET_ERROR_TYPE_DEBUG, 1221 LOG (GNUNET_ERROR_TYPE_DEBUG,
1192 "New MAC endpoint `%s'\n", 1222 "New MAC endpoint `%s'\n",
@@ -1208,7 +1238,11 @@ static enum GNUNET_ATS_Network_Type
1208wlan_plugin_get_network (void *cls, 1238wlan_plugin_get_network (void *cls,
1209 struct Session *session) 1239 struct Session *session)
1210{ 1240{
1241#if BUILD_WLAN
1211 return GNUNET_ATS_NET_WLAN; 1242 return GNUNET_ATS_NET_WLAN;
1243#else
1244 return GNUNET_ATS_NET_BT;
1245#endif
1212} 1246}
1213 1247
1214 1248
@@ -1240,7 +1274,8 @@ wlan_plugin_get_session (void *cls,
1240 wlan_plugin_address_to_string (NULL, 1274 wlan_plugin_address_to_string (NULL,
1241 address->address, 1275 address->address,
1242 address->address_length)); 1276 address->address_length));
1243 endpoint = create_macendpoint (plugin, (struct WlanAddress *) address->address); 1277 endpoint = create_macendpoint (plugin,
1278 (struct WlanAddress *) address->address);
1244 return get_session (endpoint, &address->peer); 1279 return get_session (endpoint, &address->peer);
1245} 1280}
1246 1281
@@ -1327,8 +1362,9 @@ wlan_plugin_send (void *cls,
1327 memcpy (&wlanheader[1], msgbuf, msgbuf_size); 1362 memcpy (&wlanheader[1], msgbuf, msgbuf_size);
1328 1363
1329 GNUNET_STATISTICS_update (plugin->env->stats, 1364 GNUNET_STATISTICS_update (plugin->env->stats,
1330 "# bytes currently in WLAN buffers", 1365 "# bytes currently in buffers",
1331 msgbuf_size, GNUNET_NO); 1366 msgbuf_size,
1367 GNUNET_NO);
1332 1368
1333 send_with_fragmentation (session->mac, 1369 send_with_fragmentation (session->mac,
1334 to, 1370 to,
@@ -1365,11 +1401,15 @@ process_data (void *cls,
1365 uint16_t msize; 1401 uint16_t msize;
1366 1402
1367 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); 1403 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
1404#if BUILD_WLAN
1368 ats.value = htonl (GNUNET_ATS_NET_WLAN); 1405 ats.value = htonl (GNUNET_ATS_NET_WLAN);
1406#else
1407 ats.value = htonl (GNUNET_ATS_NET_BT);
1408#endif
1369 msize = ntohs (hdr->size); 1409 msize = ntohs (hdr->size);
1370 1410
1371 GNUNET_STATISTICS_update (plugin->env->stats, 1411 GNUNET_STATISTICS_update (plugin->env->stats,
1372 "# bytes received via WLAN", 1412 "# bytes received",
1373 msize, GNUNET_NO); 1413 msize, GNUNET_NO);
1374 1414
1375 switch (ntohs (hdr->type)) 1415 switch (ntohs (hdr->type))
@@ -1398,7 +1438,7 @@ process_data (void *cls,
1398 sizeof (mas->endpoint->wlan_addr))); 1438 sizeof (mas->endpoint->wlan_addr)));
1399 1439
1400 GNUNET_STATISTICS_update (plugin->env->stats, 1440 GNUNET_STATISTICS_update (plugin->env->stats,
1401 _("# HELLO messages received via WLAN"), 1, 1441 _("# HELLO messages received"), 1,
1402 GNUNET_NO); 1442 GNUNET_NO);
1403 address = GNUNET_HELLO_address_allocate (&tmpsource, 1443 address = GNUNET_HELLO_address_allocate (&tmpsource,
1404 PLUGIN_NAME, 1444 PLUGIN_NAME,
@@ -1428,7 +1468,7 @@ process_data (void *cls,
1428 &mas->endpoint->wlan_addr, 1468 &mas->endpoint->wlan_addr,
1429 sizeof (mas->endpoint->wlan_addr))); 1469 sizeof (mas->endpoint->wlan_addr)));
1430 GNUNET_STATISTICS_update (plugin->env->stats, 1470 GNUNET_STATISTICS_update (plugin->env->stats,
1431 _("# fragments received via WLAN"), 1471 _("# fragments received"),
1432 1, 1472 1,
1433 GNUNET_NO); 1473 GNUNET_NO);
1434 (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag, 1474 (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag,
@@ -1441,7 +1481,7 @@ process_data (void *cls,
1441 break; 1481 break;
1442 } 1482 }
1443 GNUNET_STATISTICS_update (plugin->env->stats, 1483 GNUNET_STATISTICS_update (plugin->env->stats,
1444 _("# ACKs received via WLAN"), 1484 _("# ACKs received"),
1445 1, GNUNET_NO); 1485 1, GNUNET_NO);
1446 for (fm = mas->endpoint->sending_messages_head; NULL != fm; fm = fm->next) 1486 for (fm = mas->endpoint->sending_messages_head; NULL != fm; fm = fm->next)
1447 { 1487 {
@@ -1500,7 +1540,7 @@ process_data (void *cls,
1500 sizeof (struct GNUNET_PeerIdentity))) 1540 sizeof (struct GNUNET_PeerIdentity)))
1501 { 1541 {
1502 LOG (GNUNET_ERROR_TYPE_DEBUG, 1542 LOG (GNUNET_ERROR_TYPE_DEBUG,
1503 "WLAN data for `%s', not for me, ignoring\n", 1543 "Data for `%s', not for me, ignoring\n",
1504 GNUNET_i2s (&wlanheader->target)); 1544 GNUNET_i2s (&wlanheader->target));
1505 break; 1545 break;
1506 } 1546 }
@@ -1509,7 +1549,7 @@ process_data (void *cls,
1509 msize - sizeof (struct WlanHeader))) 1549 msize - sizeof (struct WlanHeader)))
1510 { 1550 {
1511 GNUNET_STATISTICS_update (plugin->env->stats, 1551 GNUNET_STATISTICS_update (plugin->env->stats,
1512 _("# WLAN DATA messages discarded due to CRC32 error"), 1552 _("# DATA messages discarded due to CRC32 error"),
1513 1, 1553 1,
1514 GNUNET_NO); 1554 GNUNET_NO);
1515 break; 1555 break;
@@ -1536,7 +1576,7 @@ process_data (void *cls,
1536 GNUNET_HELLO_address_free (address); 1576 GNUNET_HELLO_address_free (address);
1537 } 1577 }
1538 LOG (GNUNET_ERROR_TYPE_DEBUG, 1578 LOG (GNUNET_ERROR_TYPE_DEBUG,
1539 "Processing %u bytes of WLAN DATA from peer `%s'\n", 1579 "Processing %u bytes of DATA from peer `%s'\n",
1540 (unsigned int) msize, 1580 (unsigned int) msize,
1541 GNUNET_i2s (&wlanheader->sender)); 1581 GNUNET_i2s (&wlanheader->sender));
1542 xmas.session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 1582 xmas.session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
@@ -1650,7 +1690,7 @@ handle_helper_message (void *cls, void *client,
1650 "Got data message from helper with %u bytes\n", 1690 "Got data message from helper with %u bytes\n",
1651 msize); 1691 msize);
1652 GNUNET_STATISTICS_update (plugin->env->stats, 1692 GNUNET_STATISTICS_update (plugin->env->stats,
1653 _("# DATA messages received via WLAN"), 1, 1693 _("# DATA messages received"), 1,
1654 GNUNET_NO); 1694 GNUNET_NO);
1655 if (msize < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)) 1695 if (msize < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage))
1656 { 1696 {
@@ -1685,7 +1725,7 @@ handle_helper_message (void *cls, void *client,
1685 } 1725 }
1686 1726
1687 GNUNET_STATISTICS_update (plugin->env->stats, 1727 GNUNET_STATISTICS_update (plugin->env->stats,
1688 _("# WLAN DATA messages processed"), 1728 _("# DATA messages processed"),
1689 1, GNUNET_NO); 1729 1, GNUNET_NO);
1690 LOG (GNUNET_ERROR_TYPE_DEBUG, 1730 LOG (GNUNET_ERROR_TYPE_DEBUG,
1691 "Receiving %u bytes of data from MAC `%s'\n", 1731 "Receiving %u bytes of data from MAC `%s'\n",
@@ -1748,7 +1788,7 @@ send_hello_beacon (void *cls,
1748 GNUNET_YES /* can drop */, 1788 GNUNET_YES /* can drop */,
1749 NULL, NULL)) 1789 NULL, NULL))
1750 GNUNET_STATISTICS_update (plugin->env->stats, 1790 GNUNET_STATISTICS_update (plugin->env->stats,
1751 _("# HELLO beacons sent via WLAN"), 1791 _("# HELLO beacons sent"),
1752 1, GNUNET_NO); 1792 1, GNUNET_NO);
1753 } 1793 }
1754 plugin->beacon_task = 1794 plugin->beacon_task =
@@ -1850,7 +1890,7 @@ wlan_plugin_address_pretty_printer (void *cls,
1850 * @param cls pointer to the api struct 1890 * @param cls pointer to the api struct
1851 */ 1891 */
1852void * 1892void *
1853libgnunet_plugin_transport_wlan_done (void *cls) 1893LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
1854{ 1894{
1855 struct WlanAddress wa; 1895 struct WlanAddress wa;
1856 struct GNUNET_HELLO_Address *address; 1896 struct GNUNET_HELLO_Address *address;
@@ -1864,7 +1904,6 @@ libgnunet_plugin_transport_wlan_done (void *cls)
1864 GNUNET_free (api); 1904 GNUNET_free (api);
1865 return NULL; 1905 return NULL;
1866 } 1906 }
1867
1868 if (GNUNET_YES == plugin->have_mac) 1907 if (GNUNET_YES == plugin->have_mac)
1869 { 1908 {
1870 memset (&wa, 0, sizeof(wa)); 1909 memset (&wa, 0, sizeof(wa));
@@ -2063,7 +2102,7 @@ wlan_plugin_update_inbound_delay (void *cls,
2063 * @return the `struct GNUNET_TRANSPORT_PluginFunctions *` or NULL on error 2102 * @return the `struct GNUNET_TRANSPORT_PluginFunctions *` or NULL on error
2064 */ 2103 */
2065void * 2104void *
2066libgnunet_plugin_transport_wlan_init (void *cls) 2105LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
2067{ 2106{
2068 struct GNUNET_TRANSPORT_PluginEnvironment *env = cls; 2107 struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
2069 struct GNUNET_TRANSPORT_PluginFunctions *api; 2108 struct GNUNET_TRANSPORT_PluginFunctions *api;
@@ -2088,36 +2127,44 @@ libgnunet_plugin_transport_wlan_init (void *cls)
2088 testmode = 0; 2127 testmode = 0;
2089 /* check configuration */ 2128 /* check configuration */
2090 if ( (GNUNET_YES == 2129 if ( (GNUNET_YES ==
2091 GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE")) && 2130 GNUNET_CONFIGURATION_have_value (env->cfg,
2131 CONFIG_NAME,
2132 "TESTMODE")) &&
2092 ( (GNUNET_SYSERR == 2133 ( (GNUNET_SYSERR ==
2093 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan", 2134 GNUNET_CONFIGURATION_get_value_number (env->cfg,
2094 "TESTMODE", &testmode)) || 2135 CONFIG_NAME,
2136 "TESTMODE",
2137 &testmode)) ||
2095 (testmode > 2) ) ) 2138 (testmode > 2) ) )
2096 { 2139 {
2097 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 2140 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
2098 "transport-wlan", "TESTMODE"); 2141 CONFIG_NAME,
2142 "TESTMODE");
2099 return NULL; 2143 return NULL;
2100 } 2144 }
2101 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-transport-wlan"); 2145 binary = GNUNET_OS_get_libexec_binary_path (HELPER_NAME);
2102 if ( (0 == testmode) && 2146 if ( (0 == testmode) &&
2103 (GNUNET_YES != 2147 (GNUNET_YES !=
2104 GNUNET_OS_check_helper_binary (binary, GNUNET_YES, NULL)) ) 2148 GNUNET_OS_check_helper_binary (binary,
2149 GNUNET_YES,
2150 NULL)) )
2105 { 2151 {
2106 LOG (GNUNET_ERROR_TYPE_ERROR, 2152 LOG (GNUNET_ERROR_TYPE_ERROR,
2107 _("Helper binary `%s' not SUID, cannot run WLAN transport\n"), 2153 _("Helper binary `%s' not SUID, cannot run WLAN transport\n"),
2108 "gnunet-helper-transport-wlan"); 2154 HELPER_NAME);
2109 GNUNET_free (binary); 2155 GNUNET_free (binary);
2110 return NULL; 2156 return NULL;
2111 } 2157 }
2112 GNUNET_free (binary); 2158 GNUNET_free (binary);
2113 if (GNUNET_YES != 2159 if (GNUNET_YES !=
2114 GNUNET_CONFIGURATION_get_value_string (env->cfg, 2160 GNUNET_CONFIGURATION_get_value_string (env->cfg,
2115 "transport-wlan", 2161 CONFIG_NAME,
2116 "INTERFACE", 2162 "INTERFACE",
2117 &interface)) 2163 &interface))
2118 { 2164 {
2119 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 2165 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
2120 "transport-wlan", "INTERFACE"); 2166 CONFIG_NAME,
2167 "INTERFACE");
2121 return NULL; 2168 return NULL;
2122 } 2169 }
2123 2170
@@ -2125,10 +2172,10 @@ libgnunet_plugin_transport_wlan_init (void *cls)
2125 plugin->interface = interface; 2172 plugin->interface = interface;
2126 plugin->env = env; 2173 plugin->env = env;
2127 GNUNET_STATISTICS_set (plugin->env->stats, 2174 GNUNET_STATISTICS_set (plugin->env->stats,
2128 _("# WLAN sessions allocated"), 2175 _("# sessions allocated"),
2129 0, GNUNET_NO); 2176 0, GNUNET_NO);
2130 GNUNET_STATISTICS_set (plugin->env->stats, 2177 GNUNET_STATISTICS_set (plugin->env->stats,
2131 _("# WLAN MAC endpoints allocated"), 2178 _("# MAC endpoints allocated"),
2132 0, 0); 2179 0, 0);
2133 GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, NULL, NULL, 2180 GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, NULL, NULL,
2134 GNUNET_BANDWIDTH_value_init (100 * 1024 * 2181 GNUNET_BANDWIDTH_value_init (100 * 1024 *
@@ -2146,33 +2193,33 @@ libgnunet_plugin_transport_wlan_init (void *cls)
2146 switch ((unsigned int) testmode) 2193 switch ((unsigned int) testmode)
2147 { 2194 {
2148 case 0: /* normal */ 2195 case 0: /* normal */
2149 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan"; 2196 plugin->helper_argv[0] = (char *) HELPER_NAME;
2150 plugin->helper_argv[1] = interface; 2197 plugin->helper_argv[1] = interface;
2151 plugin->helper_argv[2] = NULL; 2198 plugin->helper_argv[2] = NULL;
2152 plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO, 2199 plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
2153 "gnunet-helper-transport-wlan", 2200 HELPER_NAME,
2154 plugin->helper_argv, 2201 plugin->helper_argv,
2155 &handle_helper_message, 2202 &handle_helper_message,
2156 NULL, 2203 NULL,
2157 plugin); 2204 plugin);
2158 break; 2205 break;
2159 case 1: /* testmode, peer 1 */ 2206 case 1: /* testmode, peer 1 */
2160 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy"; 2207 plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME;
2161 plugin->helper_argv[1] = (char *) "1"; 2208 plugin->helper_argv[1] = (char *) "1";
2162 plugin->helper_argv[2] = NULL; 2209 plugin->helper_argv[2] = NULL;
2163 plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO, 2210 plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
2164 "gnunet-helper-transport-wlan-dummy", 2211 DUMMY_HELPER_NAME,
2165 plugin->helper_argv, 2212 plugin->helper_argv,
2166 &handle_helper_message, 2213 &handle_helper_message,
2167 NULL, 2214 NULL,
2168 plugin); 2215 plugin);
2169 break; 2216 break;
2170 case 2: /* testmode, peer 2 */ 2217 case 2: /* testmode, peer 2 */
2171 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy"; 2218 plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME;
2172 plugin->helper_argv[1] = (char *) "2"; 2219 plugin->helper_argv[1] = (char *) "2";
2173 plugin->helper_argv[2] = NULL; 2220 plugin->helper_argv[2] = NULL;
2174 plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO, 2221 plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
2175 "gnunet-helper-transport-wlan-dummy", 2222 DUMMY_HELPER_NAME,
2176 plugin->helper_argv, 2223 plugin->helper_argv,
2177 &handle_helper_message, 2224 &handle_helper_message,
2178 NULL, 2225 NULL,