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, 31 insertions, 152 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 4510ae12c..08f9c5833 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -39,7 +39,11 @@
39#include "gnunet_fragmentation_lib.h" 39#include "gnunet_fragmentation_lib.h"
40#include "gnunet_constants.h" 40#include "gnunet_constants.h"
41 41
42#include <string.h> 42/**
43 * DEBUG switch
44 */
45#define DEBUG_WLAN GNUNET_EXTRA_LOGGING
46
43 47
44#define PROTOCOL_PREFIX "wlan" 48#define PROTOCOL_PREFIX "wlan"
45 49
@@ -100,15 +104,6 @@
100#define WLAN_LLC_SSAP_FIELD 0x1f 104#define WLAN_LLC_SSAP_FIELD 0x1f
101 105
102 106
103/**
104 * DEBUG switch
105 */
106#define DEBUG_wlan GNUNET_EXTRA_LOGGING
107#define DEBUG_wlan_retransmission GNUNET_EXTRA_LOGGING
108#define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO
109#define DEBUG_wlan_msg_dump GNUNET_EXTRA_LOGGING
110
111
112#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ 107#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
113 108
114#define IEEE80211_FC0_VERSION_MASK 0x03 109#define IEEE80211_FC0_VERSION_MASK 0x03
@@ -225,7 +220,7 @@ struct Plugin
225 /** 220 /**
226 * The mac_address of the wlan card given to us by the helper. 221 * The mac_address of the wlan card given to us by the helper.
227 */ 222 */
228 struct MacAddress mac_address; 223 struct GNUNET_TRANSPORT_WLAN_MacAddress mac_address;
229 224
230 /** 225 /**
231 * Sessions currently pending for transmission 226 * Sessions currently pending for transmission
@@ -488,7 +483,7 @@ struct Session_light
488 /** 483 /**
489 * peer mac address 484 * peer mac address
490 */ 485 */
491 struct MacAddress addr; 486 struct GNUNET_TRANSPORT_WLAN_MacAddress addr;
492 487
493 /** 488 /**
494 * mac endpoint 489 * mac endpoint
@@ -595,7 +590,7 @@ struct MacEndpoint
595 /** 590 /**
596 * peer mac address 591 * peer mac address
597 */ 592 */
598 struct MacAddress addr; 593 struct GNUNET_TRANSPORT_WLAN_MacAddress addr;
599 594
600 /** 595 /**
601 * Defrag context for this mac endpoint 596 * Defrag context for this mac endpoint
@@ -704,7 +699,7 @@ free_session (struct Plugin *plugin, struct Sessionqueue *queue,
704 int do_free_macendpoint); 699 int do_free_macendpoint);
705 700
706static struct MacEndpoint * 701static struct MacEndpoint *
707create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr); 702create_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr);
708 703
709static void 704static void
710finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 705finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
@@ -771,7 +766,7 @@ hexdump (const void *mem, unsigned length)
771 * @return 766 * @return
772 */ 767 */
773static struct MacEndpoint * 768static struct MacEndpoint *
774get_macendpoint (struct Plugin *plugin, const struct MacAddress *addr, 769get_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr,
775 int create_new) 770 int create_new)
776{ 771{
777 struct MacEndpoint *queue = plugin->mac_head; 772 struct MacEndpoint *queue = plugin->mac_head;
@@ -779,7 +774,7 @@ get_macendpoint (struct Plugin *plugin, const struct MacAddress *addr,
779 while (queue != NULL) 774 while (queue != NULL)
780 { 775 {
781 //GNUNET_assert (queue->sessions_head != NULL); 776 //GNUNET_assert (queue->sessions_head != NULL);
782 if (memcmp (addr, &queue->addr, sizeof (struct MacAddress)) == 0) 777 if (memcmp (addr, &queue->addr, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)
783 return queue; /* session found */ 778 return queue; /* session found */
784 queue = queue->next; 779 queue = queue->next;
785 } 780 }
@@ -837,9 +832,9 @@ static const char *
837wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) 832wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
838{ 833{
839 static char ret[40]; 834 static char ret[40];
840 const struct MacAddress *mac; 835 const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac;
841 836
842 if (addrlen != sizeof (struct MacAddress)) 837 if (addrlen != sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))
843 { 838 {
844 GNUNET_break (0); 839 GNUNET_break (0);
845 return NULL; 840 return NULL;
@@ -916,14 +911,11 @@ create_session (struct Plugin *plugin, struct MacEndpoint *endpoint,
916 queue->content->timeout_task = 911 queue->content->timeout_task =
917 GNUNET_SCHEDULER_add_delayed (SESSION_TIMEOUT, &session_timeout, queue); 912 GNUNET_SCHEDULER_add_delayed (SESSION_TIMEOUT, &session_timeout, queue);
918 913
919#if DEBUG_wlan
920 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 914 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
921 "New session %p with endpoint %p: %s\n", queue->content, 915 "New session %p with endpoint %p: %s\n", queue->content,
922 endpoint, wlan_plugin_address_to_string (NULL, 916 endpoint, wlan_plugin_address_to_string (NULL,
923 endpoint->addr.mac, 917 endpoint->addr.mac,
924 6)); 918 6));
925#endif
926
927 return queue->content; 919 return queue->content;
928} 920}
929 921
@@ -936,7 +928,7 @@ create_session (struct Plugin *plugin, struct MacEndpoint *endpoint,
936 * @return returns the session 928 * @return returns the session
937 */ 929 */
938static struct Session * 930static struct Session *
939get_session (struct Plugin *plugin, const struct MacAddress *addr, 931get_session (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr,
940 const struct GNUNET_PeerIdentity *peer) 932 const struct GNUNET_PeerIdentity *peer)
941{ 933{
942 struct MacEndpoint *mac; 934 struct MacEndpoint *mac;
@@ -1090,11 +1082,8 @@ set_next_send (struct Plugin *const plugin)
1090 next_send = GNUNET_TIME_absolute_get_remaining (plugin->beacon_time); 1082 next_send = GNUNET_TIME_absolute_get_remaining (plugin->beacon_time);
1091 } 1083 }
1092 1084
1093#if DEBUG_wlan
1094 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1085 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1095 "Next packet is send in: %u\n", next_send.rel_value); 1086 "Next packet is send in: %u\n", next_send.rel_value);
1096#endif
1097
1098 if (next_send.rel_value == GNUNET_TIME_UNIT_ZERO.rel_value) 1087 if (next_send.rel_value == GNUNET_TIME_UNIT_ZERO.rel_value)
1099 { 1088 {
1100 if (plugin->server_write_task == GNUNET_SCHEDULER_NO_TASK) 1089 if (plugin->server_write_task == GNUNET_SCHEDULER_NO_TASK)
@@ -1140,11 +1129,9 @@ get_next_queue_session (struct Plugin *plugin)
1140 1129
1141 if (pm == NULL) 1130 if (pm == NULL)
1142 { 1131 {
1143#if DEBUG_wlan
1144 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1132 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
1145 "pending message is empty, should not happen. session %p\n", 1133 "pending message is empty, should not happen. session %p\n",
1146 session); 1134 session);
1147#endif
1148 sessionqueue_alt = sessionqueue; 1135 sessionqueue_alt = sessionqueue;
1149 sessionqueue = sessionqueue->next; 1136 sessionqueue = sessionqueue->next;
1150 plugin->pendingsessions--; 1137 plugin->pendingsessions--;
@@ -1257,11 +1244,9 @@ free_fragment_message (struct Plugin *plugin, struct FragmentMessage *fm)
1257 GNUNET_free (fm); 1244 GNUNET_free (fm);
1258 1245
1259 queue_session (plugin, session); 1246 queue_session (plugin, session);
1260#if DEBUG_wlan
1261 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1247 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1262 "Free pending fragment messages %p, session %p\n", fm, 1248 "Free pending fragment messages %p, session %p\n", fm,
1263 session); 1249 session);
1264#endif
1265} 1250}
1266 1251
1267/** 1252/**
@@ -1302,7 +1287,7 @@ getRadiotapHeader (struct Plugin *plugin, struct MacEndpoint *endpoint,
1302 */ 1287 */
1303static int 1288static int
1304getWlanHeader (struct ieee80211_frame *Header, 1289getWlanHeader (struct ieee80211_frame *Header,
1305 const struct MacAddress *to_mac_addr, struct Plugin *plugin, 1290 const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, struct Plugin *plugin,
1306 unsigned int size) 1291 unsigned int size)
1307{ 1292{
1308 uint16_t *tmp16; 1293 uint16_t *tmp16;
@@ -1313,7 +1298,7 @@ getWlanHeader (struct ieee80211_frame *Header,
1313 memcpy (&Header->i_addr3, &mac_bssid_gnunet, sizeof (mac_bssid_gnunet)); 1298 memcpy (&Header->i_addr3, &mac_bssid_gnunet, sizeof (mac_bssid_gnunet));
1314 memcpy (&Header->i_addr2, plugin->mac_address.mac, 1299 memcpy (&Header->i_addr2, plugin->mac_address.mac,
1315 sizeof (plugin->mac_address)); 1300 sizeof (plugin->mac_address));
1316 memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct MacAddress)); 1301 memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
1317 1302
1318 tmp16 = (uint16_t *) Header->i_dur; 1303 tmp16 = (uint16_t *) Header->i_dur;
1319 *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290); 1304 *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290);
@@ -1344,12 +1329,9 @@ add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr)
1344 struct GNUNET_MessageHeader *msgheader2; 1329 struct GNUNET_MessageHeader *msgheader2;
1345 uint16_t size; 1330 uint16_t size;
1346 1331
1347#if DEBUG_wlan_retransmission > 1
1348 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1332 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1349 "Adding fragment of message %p to send, session %p, endpoint %p, type %u\n", 1333 "Adding fragment of message %p to send, session %p, endpoint %p, type %u\n",
1350 fm, fm->session, endpoint, hdr->type); 1334 fm, fm->session, endpoint, hdr->type);
1351#endif
1352
1353 size = 1335 size =
1354 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + 1336 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) +
1355 sizeof (struct ieee80211_frame) + ntohs (hdr->size); 1337 sizeof (struct ieee80211_frame) + ntohs (hdr->size);
@@ -1401,12 +1383,10 @@ wlan_plugin_helper_read (void *cls,
1401 sizeof (mybuf)); 1383 sizeof (mybuf));
1402 if (bytes <= 0) 1384 if (bytes <= 0)
1403 { 1385 {
1404#if DEBUG_wlan
1405 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1386 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1406 _ 1387 _
1407 ("Finished reading from gnunet-helper-transport-wlan stdout with code: %d\n"), 1388 ("Finished reading from gnunet-helper-transport-wlan stdout with code: %d\n"),
1408 bytes); 1389 bytes);
1409#endif
1410 return; 1390 return;
1411 } 1391 }
1412 GNUNET_SERVER_mst_receive (plugin->suid_tokenizer, NULL, mybuf, bytes, 1392 GNUNET_SERVER_mst_receive (plugin->suid_tokenizer, NULL, mybuf, bytes,
@@ -1434,10 +1414,8 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1434 1414
1435 if (plugin->helper_is_running == GNUNET_YES) 1415 if (plugin->helper_is_running == GNUNET_YES)
1436 { 1416 {
1437#if DEBUG_wlan
1438 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1417 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1439 "wlan_transport_start_wlan_helper not needed, helper already running!"); 1418 "wlan_transport_start_wlan_helper not needed, helper already running!");
1440#endif
1441 return GNUNET_YES; 1419 return GNUNET_YES;
1442 } 1420 }
1443 1421
@@ -1478,12 +1456,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1478 if (plugin->testmode == 0) 1456 if (plugin->testmode == 0)
1479 { 1457 {
1480 1458
1481#if DEBUG_wlan
1482 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1459 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1483 "Starting gnunet-helper-transport-wlan process cmd: %s %s %i\n", 1460 "Starting gnunet-helper-transport-wlan process cmd: %s %s %i\n",
1484 filenamehw, plugin->interface, plugin->testmode); 1461 filenamehw, plugin->interface, plugin->testmode);
1485#endif
1486
1487 if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_YES) 1462 if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_YES)
1488 { 1463 {
1489 plugin->server_proc = 1464 plugin->server_proc =
@@ -1508,11 +1483,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1508 else if (plugin->testmode == 1) 1483 else if (plugin->testmode == 1)
1509 { 1484 {
1510 1485
1511#if DEBUG_wlan
1512 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, 1486 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
1513 "Starting gnunet-helper-transport-wlan-dummy loopback 1 process cmd: %s %s %i\n", 1487 "Starting gnunet-helper-transport-wlan-dummy loopback 1 process cmd: %s %s %i\n",
1514 absolute_filename, plugin->interface, plugin->testmode); 1488 absolute_filename, plugin->interface, plugin->testmode);
1515#endif
1516 plugin->server_proc = 1489 plugin->server_proc =
1517 GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout, 1490 GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
1518 absolute_filename, absolute_filename, "1", 1491 absolute_filename, absolute_filename, "1",
@@ -1527,12 +1500,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1527 } 1500 }
1528 else if (plugin->testmode == 2) 1501 else if (plugin->testmode == 2)
1529 { 1502 {
1530#if DEBUG_wlan
1531 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, 1503 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
1532 "Starting gnunet-helper-transport-wlan-dummy loopback 2 process cmd: %s %s %i\n", 1504 "Starting gnunet-helper-transport-wlan-dummy loopback 2 process cmd: %s %s %i\n",
1533 absolute_filename, plugin->interface, plugin->testmode); 1505 absolute_filename, plugin->interface, plugin->testmode);
1534#endif
1535
1536 plugin->server_proc = 1506 plugin->server_proc =
1537 GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout, 1507 GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
1538 absolute_filename, absolute_filename, "2", 1508 absolute_filename, absolute_filename, "2",
@@ -1549,10 +1519,8 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1549 GNUNET_free (absolute_filename); 1519 GNUNET_free (absolute_filename);
1550 if (plugin->server_proc == NULL) 1520 if (plugin->server_proc == NULL)
1551 { 1521 {
1552#if DEBUG_wlan
1553 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1522 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1554 "Failed to start gnunet-helper-transport-wlan process\n"); 1523 "Failed to start gnunet-helper-transport-wlan process\n");
1555#endif
1556 return GNUNET_SYSERR; 1524 return GNUNET_SYSERR;
1557 } 1525 }
1558 1526
@@ -1574,11 +1542,8 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1574 1542
1575 GNUNET_assert (plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK); 1543 GNUNET_assert (plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK);
1576 1544
1577#if DEBUG_wlan
1578 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1545 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1579 "Adding server_read_task for the gnunet-helper-transport-wlan\n"); 1546 "Adding server_read_task for the gnunet-helper-transport-wlan\n");
1580#endif
1581
1582 plugin->server_read_task = 1547 plugin->server_read_task =
1583 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 1548 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
1584 plugin->server_stdout_handle, 1549 plugin->server_stdout_handle,
@@ -1597,17 +1562,13 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1597static int 1562static int
1598wlan_transport_stop_wlan_helper (struct Plugin *plugin) 1563wlan_transport_stop_wlan_helper (struct Plugin *plugin)
1599{ 1564{
1600#if DEBUG_wlan
1601 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1565 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1602 "Stoping WLAN helper process\n"); 1566 "Stoping WLAN helper process\n");
1603#endif
1604 1567
1605 if (plugin->helper_is_running == GNUNET_NO) 1568 if (plugin->helper_is_running == GNUNET_NO)
1606 { 1569 {
1607#if DEBUG_wlan
1608 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1570 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1609 "wlan_transport_stop_wlan_helper not needed, helper already stopped!"); 1571 "wlan_transport_stop_wlan_helper not needed, helper already stopped!");
1610#endif
1611 return GNUNET_YES; 1572 return GNUNET_YES;
1612 } 1573 }
1613 1574
@@ -1753,12 +1714,6 @@ finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1753static void 1714static void
1754send_hello_beacon (struct Plugin *plugin) 1715send_hello_beacon (struct Plugin *plugin)
1755{ 1716{
1756
1757#if DEBUG_wlan
1758 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1759 "Sending hello beacon\n");
1760#endif
1761
1762 uint16_t size; 1717 uint16_t size;
1763 ssize_t bytes; 1718 ssize_t bytes;
1764 uint16_t hello_size; 1719 uint16_t hello_size;
@@ -1769,6 +1724,9 @@ send_hello_beacon (struct Plugin *plugin)
1769 const struct GNUNET_MessageHeader *hello; 1724 const struct GNUNET_MessageHeader *hello;
1770 struct Finish_send *finish; 1725 struct Finish_send *finish;
1771 1726
1727 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1728 "Sending hello beacon\n");
1729
1772 GNUNET_assert (plugin != NULL); 1730 GNUNET_assert (plugin != NULL);
1773 1731
1774 GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"), 1732 GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"),
@@ -1874,12 +1832,9 @@ add_ack_for_send (void *cls, uint32_t msg_id,
1874 GNUNET_CONTAINER_DLL_insert_tail (plugin->ack_send_queue_head, 1832 GNUNET_CONTAINER_DLL_insert_tail (plugin->ack_send_queue_head,
1875 plugin->ack_send_queue_tail, ack); 1833 plugin->ack_send_queue_tail, ack);
1876 1834
1877#if DEBUG_wlan_retransmission > 1
1878 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1835 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1879 "Adding ack with message id %u to send, AckSendQueue %p, endpoint %p\n", 1836 "Adding ack with message id %u to send, AckSendQueue %p, endpoint %p\n",
1880 msg_id, ack, endpoint); 1837 msg_id, ack, endpoint);
1881#endif
1882
1883 set_next_send (plugin); 1838 set_next_send (plugin);
1884} 1839}
1885 1840
@@ -1955,17 +1910,13 @@ check_fragment_queue (struct Plugin *plugin)
1955 { 1910 {
1956 pid = session->target; 1911 pid = session->target;
1957 pm->transmit_cont (pm->transmit_cont_cls, &pid, GNUNET_OK); 1912 pm->transmit_cont (pm->transmit_cont_cls, &pid, GNUNET_OK);
1958#if DEBUG_wlan
1959 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1913 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1960 "called pm->transmit_cont for %p\n", session); 1914 "called pm->transmit_cont for %p\n", session);
1961#endif
1962 } 1915 }
1963 else 1916 else
1964 { 1917 {
1965#if DEBUG_wlan
1966 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1918 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1967 "no pm->transmit_cont for %p\n", session); 1919 "no pm->transmit_cont for %p\n", session);
1968#endif
1969 } 1920 }
1970 GNUNET_free (pm); 1921 GNUNET_free (pm);
1971 1922
@@ -1995,15 +1946,10 @@ send_ack (struct Plugin *plugin)
1995 struct Finish_send *finish; 1946 struct Finish_send *finish;
1996 1947
1997 ack = plugin->ack_send_queue_head; 1948 ack = plugin->ack_send_queue_head;
1998
1999
2000#if DEBUG_wlan
2001 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1949 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2002 "Sending ack for message_id %u for mac endpoint %p, size %u\n", 1950 "Sending ack for message_id %u for mac endpoint %p, size %u\n",
2003 ack->message_id, ack->endpoint, 1951 ack->message_id, ack->endpoint,
2004 ntohs (ack->hdr->size) - sizeof (struct Radiotap_Send)); 1952 ntohs (ack->hdr->size) - sizeof (struct Radiotap_Send));
2005#endif
2006
2007 GNUNET_assert (plugin != NULL); 1953 GNUNET_assert (plugin != NULL);
2008 GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1, 1954 GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1,
2009 GNUNET_NO); 1955 GNUNET_NO);
@@ -2087,13 +2033,9 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2087 2033
2088 session = fm->session; 2034 session = fm->session;
2089 GNUNET_assert (session != NULL); 2035 GNUNET_assert (session != NULL);
2090
2091#if DEBUG_wlan
2092 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2036 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2093 "Sending GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT for fragment message %p, size: %u\n", 2037 "Sending GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT for fragment message %p, size: %u\n",
2094 fm, fm->size); 2038 fm, fm->size);
2095#endif
2096
2097 getRadiotapHeader (plugin, session->mac, fm->radioHeader); 2039 getRadiotapHeader (plugin, session->mac, fm->radioHeader);
2098 getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin, 2040 getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin,
2099 fm->size); 2041 fm->size);
@@ -2176,18 +2118,14 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
2176 if (addrlen == 6) 2118 if (addrlen == 6)
2177 { 2119 {
2178 /* TODO check for bad addresses like multicast, broadcast, etc */ 2120 /* TODO check for bad addresses like multicast, broadcast, etc */
2179#if DEBUG_wlan
2180 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2121 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2181 "wlan_plugin_address_suggested got good address, size %u!\n", 2122 "wlan_plugin_address_suggested got good address, size %u!\n",
2182 addrlen); 2123 addrlen);
2183#endif
2184 return GNUNET_OK; 2124 return GNUNET_OK;
2185 } 2125 }
2186#if DEBUG_wlan
2187 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2126 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2188 "wlan_plugin_address_suggested got bad address, size %u!\n", 2127 "wlan_plugin_address_suggested got bad address, size %u!\n",
2189 addrlen); 2128 addrlen);
2190#endif
2191 return GNUNET_SYSERR; 2129 return GNUNET_SYSERR;
2192} 2130}
2193 2131
@@ -2311,12 +2249,10 @@ wlan_plugin_send (void *cls,
2311 GNUNET_CONTAINER_DLL_insert_tail (session->pending_message_head, 2249 GNUNET_CONTAINER_DLL_insert_tail (session->pending_message_head,
2312 session->pending_message_tail, newmsg); 2250 session->pending_message_tail, newmsg);
2313 2251
2314#if DEBUG_wlan
2315 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2252 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2316 "New message for %p with size (incl wlan header) %u added\n", 2253 "New message for %p with size (incl wlan header) %u added\n",
2317 session, newmsg->message_size); 2254 session, newmsg->message_size);
2318#endif 2255#if DEBUG_WLAN > 1
2319#if DEBUG_wlan_msg_dump > 1
2320 hexdump (msgbuf, GNUNET_MIN (msgbuf_size, 256)); 2256 hexdump (msgbuf, GNUNET_MIN (msgbuf_size, 256));
2321#endif 2257#endif
2322 //queue session 2258 //queue session
@@ -2519,15 +2455,13 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type,
2519 const unsigned char *input; 2455 const unsigned char *input;
2520 2456
2521 //GNUNET_assert(cls !=NULL); 2457 //GNUNET_assert(cls !=NULL);
2522 if (addrlen != sizeof (struct MacAddress)) 2458 if (addrlen != sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))
2523 { 2459 {
2524 /* invalid address (MAC addresses have 6 bytes) */ 2460 /* invalid address (MAC addresses have 6 bytes) */
2525 //GNUNET_break (0); 2461 //GNUNET_break (0);
2526#if DEBUG_wlan
2527 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2462 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2528 "Func wlan_plugin_address_pretty_printer got size: %u, worng size!\n", 2463 "Func wlan_plugin_address_pretty_printer got size: %u, worng size!\n",
2529 addrlen); 2464 addrlen);
2530#endif
2531 asc (asc_cls, NULL); 2465 asc (asc_cls, NULL);
2532 return; 2466 return;
2533 } 2467 }
@@ -2536,11 +2470,9 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type,
2536 "Transport %s: %s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", 2470 "Transport %s: %s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
2537 type, PROTOCOL_PREFIX, input[0], input[1], input[2], 2471 type, PROTOCOL_PREFIX, input[0], input[1], input[2],
2538 input[3], input[4], input[5]); 2472 input[3], input[4], input[5]);
2539#if DEBUG_wlan
2540 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2473 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2541 "Func wlan_plugin_address_pretty_printer got size: %u, nummeric %u, type %s; made string: %s\n", 2474 "Func wlan_plugin_address_pretty_printer got size: %u, nummeric %u, type %s; made string: %s\n",
2542 addrlen, numeric, type, ret); 2475 addrlen, numeric, type, ret);
2543#endif
2544 asc (asc_cls, ret); 2476 asc (asc_cls, ret);
2545 //only one mac address per plugin 2477 //only one mac address per plugin
2546 asc (asc_cls, NULL); 2478 asc (asc_cls, NULL);
@@ -2570,11 +2502,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2570 if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_DATA) 2502 if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_DATA)
2571 { 2503 {
2572 2504
2573#if DEBUG_wlan
2574 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2505 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2575 "Func wlan_data_message_handler got GNUNET_MESSAGE_TYPE_WLAN_DATA size: %u\n", 2506 "Func wlan_data_message_handler got GNUNET_MESSAGE_TYPE_WLAN_DATA size: %u\n",
2576 ntohs (hdr->size)); 2507 ntohs (hdr->size));
2577#endif
2578 2508
2579 if (ntohs (hdr->size) < 2509 if (ntohs (hdr->size) <
2580 sizeof (struct WlanHeader) + sizeof (struct GNUNET_MessageHeader)) 2510 sizeof (struct WlanHeader) + sizeof (struct GNUNET_MessageHeader))
@@ -2609,12 +2539,10 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2609 //if not in session list 2539 //if not in session list
2610 if (session == NULL) 2540 if (session == NULL)
2611 { 2541 {
2612#if DEBUG_wlan
2613 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2542 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2614 "WLAN client not in session list: packet size = %u, inner size = %u, header size = %u\n", 2543 "WLAN client not in session list: packet size = %u, inner size = %u, header size = %u\n",
2615 ntohs (wlanheader->header.size), ntohs (temp_hdr->size), 2544 ntohs (wlanheader->header.size), ntohs (temp_hdr->size),
2616 sizeof (struct WlanHeader)); 2545 sizeof (struct WlanHeader));
2617#endif
2618 //try if it is a hello message 2546 //try if it is a hello message
2619 if (ntohs (wlanheader->header.size) >= 2547 if (ntohs (wlanheader->header.size) >=
2620 ntohs (temp_hdr->size) + sizeof (struct WlanHeader)) 2548 ntohs (temp_hdr->size) + sizeof (struct WlanHeader))
@@ -2659,11 +2587,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2659 sizeof (struct GNUNET_PeerIdentity)) != 0) 2587 sizeof (struct GNUNET_PeerIdentity)) != 0)
2660 { 2588 {
2661 //wrong peer id 2589 //wrong peer id
2662#if DEBUG_wlan
2663 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2590 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2664 "WLAN peer source id doesn't match packet peer source id: session %p\n", 2591 "WLAN peer source id doesn't match packet peer source id: session %p\n",
2665 session); 2592 session);
2666#endif
2667 return; 2593 return;
2668 } 2594 }
2669 2595
@@ -2672,11 +2598,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2672 sizeof (struct GNUNET_PeerIdentity)) != 0) 2598 sizeof (struct GNUNET_PeerIdentity)) != 0)
2673 { 2599 {
2674 //wrong peer id 2600 //wrong peer id
2675#if DEBUG_wlan
2676 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2601 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2677 "WLAN peer target id doesn't match our peer id: session %p\n", 2602 "WLAN peer target id doesn't match our peer id: session %p\n",
2678 session); 2603 session);
2679#endif
2680 return; 2604 return;
2681 } 2605 }
2682 2606
@@ -2718,15 +2642,12 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
2718 ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); 2642 ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
2719 ats[1].value = htonl (GNUNET_ATS_NET_WLAN); 2643 ats[1].value = htonl (GNUNET_ATS_NET_WLAN);
2720 2644
2721#if DEBUG_wlan
2722 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2645 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2723 "Calling plugin->env->receive for session %p; %s; size: %u\n", 2646 "Calling plugin->env->receive for session %p; %s; size: %u\n",
2724 session, wlan_plugin_address_to_string (NULL, 2647 session, wlan_plugin_address_to_string (NULL,
2725 session->mac-> 2648 session->mac->
2726 addr.mac, 6), 2649 addr.mac, 6),
2727 htons (hdr->size)); 2650 htons (hdr->size));
2728#endif
2729
2730 plugin->env->receive (plugin->env->cls, &(session->target), hdr, 2651 plugin->env->receive (plugin->env->cls, &(session->target), hdr,
2731 (const struct GNUNET_ATS_Information *) &ats, 2, 2652 (const struct GNUNET_ATS_Information *) &ats, 2,
2732 session, (const char *) &session->mac->addr, 2653 session, (const char *) &session->mac->addr,
@@ -2761,14 +2682,11 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2761 //TODO test first than create session 2682 //TODO test first than create session
2762 GNUNET_assert (session_light != NULL); 2683 GNUNET_assert (session_light != NULL);
2763 2684
2764#if DEBUG_wlan
2765 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2685 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2766 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_HELLO size: %u; %s\n", 2686 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_HELLO size: %u; %s\n",
2767 ntohs (hdr->size), wlan_plugin_address_to_string (NULL, 2687 ntohs (hdr->size), wlan_plugin_address_to_string (NULL,
2768 session_light->addr. 2688 session_light->addr.
2769 mac, 6)); 2689 mac, 6));
2770#endif
2771
2772 if (session_light->macendpoint == NULL) 2690 if (session_light->macendpoint == NULL)
2773 { 2691 {
2774 session_light->macendpoint = 2692 session_light->macendpoint =
@@ -2814,15 +2732,12 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2814 get_macendpoint (plugin, &session_light->addr, GNUNET_YES); 2732 get_macendpoint (plugin, &session_light->addr, GNUNET_YES);
2815 } 2733 }
2816 2734
2817#if DEBUG_wlan
2818 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2735 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2819 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT with size: %u; mac endpoint %p: %s\n", 2736 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT with size: %u; mac endpoint %p: %s\n",
2820 ntohs (hdr->size), session_light->macendpoint, 2737 ntohs (hdr->size), session_light->macendpoint,
2821 wlan_plugin_address_to_string (NULL, 2738 wlan_plugin_address_to_string (NULL,
2822 session_light->addr.mac, 2739 session_light->addr.mac,
2823 6)); 2740 6));
2824#endif
2825
2826 GNUNET_STATISTICS_update (plugin->env->stats, 2741 GNUNET_STATISTICS_update (plugin->env->stats,
2827 _("# wlan fragments received"), 1, GNUNET_NO); 2742 _("# wlan fragments received"), 1, GNUNET_NO);
2828 int ret = 2743 int ret =
@@ -2854,24 +2769,20 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2854 2769
2855 if (session_light->macendpoint == NULL) 2770 if (session_light->macendpoint == NULL)
2856 { 2771 {
2857#if DEBUG_wlan
2858 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2772 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2859 "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n", 2773 "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n",
2860 ntohs (hdr->size), wlan_plugin_address_to_string (NULL, 2774 ntohs (hdr->size), wlan_plugin_address_to_string (NULL,
2861 session_light->addr.mac, 2775 session_light->addr.mac,
2862 6)); 2776 6));
2863#endif
2864 return; 2777 return;
2865 } 2778 }
2866 2779
2867#if DEBUG_wlan
2868 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2780 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2869 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; mac endpoint: %p; %s\n", 2781 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; mac endpoint: %p; %s\n",
2870 ntohs (hdr->size), session_light->macendpoint, 2782 ntohs (hdr->size), session_light->macendpoint,
2871 wlan_plugin_address_to_string (NULL, 2783 wlan_plugin_address_to_string (NULL,
2872 session_light->addr.mac, 2784 session_light->addr.mac,
2873 6)); 2785 6));
2874#endif
2875 fm = session_light->macendpoint->sending_messages_head; 2786 fm = session_light->macendpoint->sending_messages_head;
2876 while (fm != NULL) 2787 while (fm != NULL)
2877 { 2788 {
@@ -2882,10 +2793,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2882 2793
2883 if (ret == GNUNET_OK) 2794 if (ret == GNUNET_OK)
2884 { 2795 {
2885#if DEBUG_wlan_retransmission > 1
2886 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2796 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2887 "Got last ack, finished fragment message %p\n", fm); 2797 "Got last ack, finished fragment message %p\n", fm);
2888#endif
2889 session_light->macendpoint->acks++; 2798 session_light->macendpoint->acks++;
2890 fm->session->last_activity = GNUNET_TIME_absolute_get (); 2799 fm->session->last_activity = GNUNET_TIME_absolute_get ();
2891 session_light->macendpoint->last_activity = fm->session->last_activity; 2800 session_light->macendpoint->last_activity = fm->session->last_activity;
@@ -2895,10 +2804,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2895 } 2804 }
2896 if (ret == GNUNET_NO) 2805 if (ret == GNUNET_NO)
2897 { 2806 {
2898#if DEBUG_wlan_retransmission > 1
2899 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2807 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2900 "Got ack for: %p\n", fm); 2808 "Got ack for: %p\n", fm);
2901#endif
2902 session_light->macendpoint->acks++; 2809 session_light->macendpoint->acks++;
2903 return; 2810 return;
2904 } 2811 }
@@ -2910,10 +2817,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2910 fm = fm2; 2817 fm = fm2;
2911 } 2818 }
2912 2819
2913#if DEBUG_wlan_retransmission > 1
2914 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2820 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2915 "WLAN fragment not in fragment list\n"); 2821 "WLAN fragment not in fragment list\n");
2916#endif
2917 return; 2822 return;
2918 2823
2919 } 2824 }
@@ -2934,7 +2839,6 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2934 2839
2935} 2840}
2936 2841
2937#if DEBUG_wlan
2938/** 2842/**
2939 * Function to print mac addresses nice * 2843 * Function to print mac addresses nice *
2940 * @param pointer to 6 byte with the mac address 2844 * @param pointer to 6 byte with the mac address
@@ -2949,7 +2853,6 @@ macprinter (const u_int8_t * mac)
2949 mac[2], mac[3], mac[4], mac[5]); 2853 mac[2], mac[3], mac[4], mac[5]);
2950 return macstr; 2854 return macstr;
2951} 2855}
2952#endif
2953 2856
2954/** 2857/**
2955 * Function for the scheduler if a mac endpoint times out 2858 * Function for the scheduler if a mac endpoint times out
@@ -2991,7 +2894,7 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2991 * @return returns a macendpoint 2894 * @return returns a macendpoint
2992 */ 2895 */
2993static struct MacEndpoint * 2896static struct MacEndpoint *
2994create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr) 2897create_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr)
2995{ 2898{
2996 struct MacEndpoint *newend = GNUNET_malloc (sizeof (struct MacEndpoint)); 2899 struct MacEndpoint *newend = GNUNET_malloc (sizeof (struct MacEndpoint));
2997 2900
@@ -3016,11 +2919,9 @@ create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr)
3016 GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan mac endpoints"), 2919 GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan mac endpoints"),
3017 plugin->mac_count, GNUNET_NO); 2920 plugin->mac_count, GNUNET_NO);
3018 GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend); 2921 GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend);
3019#if DEBUG_wlan
3020 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2922 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3021 "New Mac Endpoint %p: %s\n", newend, 2923 "New Mac Endpoint %p: %s\n", newend,
3022 wlan_plugin_address_to_string (NULL, newend->addr.mac, 6)); 2924 wlan_plugin_address_to_string (NULL, newend->addr.mac, 6));
3023#endif
3024 return newend; 2925 return newend;
3025} 2926}
3026 2927
@@ -3048,12 +2949,9 @@ wlan_process_helper (void *cls, void *client,
3048 switch (ntohs (hdr->type)) 2949 switch (ntohs (hdr->type))
3049 { 2950 {
3050 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA: 2951 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA:
3051#if DEBUG_wlan
3052 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2952 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3053 "Func wlan_process_helper got GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA size: %u\n", 2953 "Func wlan_process_helper got GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA size: %u\n",
3054 ntohs (hdr->size)); 2954 ntohs (hdr->size));
3055#endif
3056
3057 GNUNET_STATISTICS_update (plugin->env->stats, 2955 GNUNET_STATISTICS_update (plugin->env->stats,
3058 _("# wlan WLAN_HELPER_DATA received"), 1, 2956 _("# wlan WLAN_HELPER_DATA received"), 1,
3059 GNUNET_NO); 2957 GNUNET_NO);
@@ -3062,13 +2960,11 @@ wlan_process_helper (void *cls, void *client,
3062 sizeof (struct ieee80211_frame) + 2960 sizeof (struct ieee80211_frame) +
3063 2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx)) 2961 2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx))
3064 { 2962 {
3065#if DEBUG_wlan
3066 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2963 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3067 "Size of packet is too small; size: %u min size: %u\n", 2964 "Size of packet is too small; size: %u min size: %u\n",
3068 ntohs (hdr->size), 2965 ntohs (hdr->size),
3069 sizeof (struct ieee80211_frame) + 2966 sizeof (struct ieee80211_frame) +
3070 sizeof (struct GNUNET_MessageHeader)); 2967 sizeof (struct GNUNET_MessageHeader));
3071#endif
3072 //GNUNET_break (0); 2968 //GNUNET_break (0);
3073 /* FIXME: restart SUID process */ 2969 /* FIXME: restart SUID process */
3074 return; 2970 return;
@@ -3082,20 +2978,20 @@ wlan_process_helper (void *cls, void *client,
3082 //check for bssid 2978 //check for bssid
3083 if (memcmp 2979 if (memcmp
3084 (&(wlanIeeeHeader->i_addr3), &mac_bssid_gnunet, 2980 (&(wlanIeeeHeader->i_addr3), &mac_bssid_gnunet,
3085 sizeof (struct MacAddress)) == 0) 2981 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)
3086 { 2982 {
3087 //check for broadcast or mac 2983 //check for broadcast or mac
3088 if ((memcmp 2984 if ((memcmp
3089 (&(wlanIeeeHeader->i_addr1), &bc_all_mac, 2985 (&(wlanIeeeHeader->i_addr1), &bc_all_mac,
3090 sizeof (struct MacAddress)) == 0) || 2986 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) ||
3091 (memcmp 2987 (memcmp
3092 (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address), 2988 (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address),
3093 sizeof (struct MacAddress)) == 0)) 2989 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0))
3094 { 2990 {
3095 //if packet is from us return 2991 //if packet is from us return
3096 if ((memcmp 2992 if ((memcmp
3097 (&(wlanIeeeHeader->i_addr2), &(plugin->mac_address), 2993 (&(wlanIeeeHeader->i_addr2), &(plugin->mac_address),
3098 sizeof (struct MacAddress)) == 0)) 2994 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0))
3099 { 2995 {
3100 return; 2996 return;
3101 } 2997 }
@@ -3108,7 +3004,7 @@ wlan_process_helper (void *cls, void *client,
3108 3004
3109 session_light = GNUNET_malloc (sizeof (struct Session_light)); 3005 session_light = GNUNET_malloc (sizeof (struct Session_light));
3110 memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2), 3006 memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2),
3111 sizeof (struct MacAddress)); 3007 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
3112 //session_light->session = search_session(plugin,session_light->addr); 3008 //session_light->session = search_session(plugin,session_light->addr);
3113 GNUNET_STATISTICS_update (plugin->env->stats, 3009 GNUNET_STATISTICS_update (plugin->env->stats,
3114 _("# wlan messages for this client received"), 3010 _("# wlan messages for this client received"),
@@ -3128,11 +3024,9 @@ wlan_process_helper (void *cls, void *client,
3128 } 3024 }
3129 else 3025 else
3130 { 3026 {
3131#if DEBUG_wlan
3132 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 3027 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3133 "Size of packet is too small; size: %u > size of packet: %u\n", 3028 "Size of packet is too small; size: %u > size of packet: %u\n",
3134 ntohs (temp_hdr->size), datasize + pos); 3029 ntohs (temp_hdr->size), datasize + pos);
3135#endif
3136 } 3030 }
3137 pos += ntohs (temp_hdr->size); 3031 pos += ntohs (temp_hdr->size);
3138 3032
@@ -3143,20 +3037,16 @@ wlan_process_helper (void *cls, void *client,
3143 } 3037 }
3144 else 3038 else
3145 { 3039 {
3146#if DEBUG_wlan
3147 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 3040 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3148 "Func wlan_process_helper got wrong MAC: %s\n", 3041 "Func wlan_process_helper got wrong MAC: %s\n",
3149 macprinter (wlanIeeeHeader->i_addr1)); 3042 macprinter (wlanIeeeHeader->i_addr1));
3150#endif
3151 } 3043 }
3152 } 3044 }
3153 else 3045 else
3154 { 3046 {
3155#if DEBUG_wlan
3156 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 3047 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3157 "Func wlan_process_helper got wrong BSSID: %s\n", 3048 "Func wlan_process_helper got wrong BSSID: %s\n",
3158 macprinter (wlanIeeeHeader->i_addr2)); 3049 macprinter (wlanIeeeHeader->i_addr2));
3159#endif
3160 } 3050 }
3161 break; 3051 break;
3162 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: 3052 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL:
@@ -3167,26 +3057,21 @@ wlan_process_helper (void *cls, void *client,
3167 /* FIXME: restart SUID process */ 3057 /* FIXME: restart SUID process */
3168 return; 3058 return;
3169 } 3059 }
3170 memcpy (&plugin->mac_address, &hdr[1], sizeof (struct MacAddress)); 3060 memcpy (&plugin->mac_address, &hdr[1], sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
3171#if DEBUG_wlan
3172 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 3061 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3173 "Received WLAN_HELPER_CONTROL message with transport of address %s\n", 3062 "Received WLAN_HELPER_CONTROL message with transport of address %s\n",
3174 wlan_plugin_address_to_string (cls, &plugin->mac_address, 3063 wlan_plugin_address_to_string (cls, &plugin->mac_address,
3175 sizeof (struct 3064 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)));
3176 MacAddress)));
3177#endif
3178 plugin->env->notify_address (plugin->env->cls, GNUNET_YES, 3065 plugin->env->notify_address (plugin->env->cls, GNUNET_YES,
3179 &plugin->mac_address, 3066 &plugin->mac_address,
3180 sizeof (struct MacAddress)); 3067 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
3181 break; 3068 break;
3182 default: 3069 default:
3183#if DEBUG_wlan
3184 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 3070 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3185 "Func wlan_process_helper got unknown message with number %u, size %u\n", 3071 "Func wlan_process_helper got unknown message with number %u, size %u\n",
3186 ntohs (hdr->type), ntohs (hdr->size)); 3072 ntohs (hdr->type), ntohs (hdr->size));
3187 3073
3188#endif 3074#if DEBUG_WLAN > 1
3189#if DEBUG_wlan_msg_dump > 1
3190 hexdump (hdr, GNUNET_MIN (ntohs (hdr->size), 256)); 3075 hexdump (hdr, GNUNET_MIN (ntohs (hdr->size), 256));
3191#endif 3076#endif
3192 GNUNET_break (0); 3077 GNUNET_break (0);
@@ -3208,11 +3093,8 @@ libgnunet_plugin_transport_wlan_done (void *cls)
3208 struct MacEndpoint *endpoint = plugin->mac_head; 3093 struct MacEndpoint *endpoint = plugin->mac_head;
3209 struct MacEndpoint *endpoint_next; 3094 struct MacEndpoint *endpoint_next;
3210 3095
3211#if DEBUG_wlan
3212 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 3096 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3213 "libgnunet_plugin_transport_wlan_done started\n"); 3097 "libgnunet_plugin_transport_wlan_done started\n");
3214#endif
3215
3216 wlan_transport_stop_wlan_helper (plugin); 3098 wlan_transport_stop_wlan_helper (plugin);
3217 3099
3218 GNUNET_assert (cls != NULL); 3100 GNUNET_assert (cls != NULL);
@@ -3311,11 +3193,8 @@ libgnunet_plugin_transport_wlan_init (void *cls)
3311 wlan_transport_start_wlan_helper (plugin); 3193 wlan_transport_start_wlan_helper (plugin);
3312 set_next_beacon_time (plugin); 3194 set_next_beacon_time (plugin);
3313 set_next_send (plugin); 3195 set_next_send (plugin);
3314#if DEBUG_wlan
3315 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 3196 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3316 "wlan init finished\n"); 3197 "wlan init finished\n");
3317#endif
3318
3319 return api; 3198 return api;
3320} 3199}
3321 3200