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.c140
1 files changed, 68 insertions, 72 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 5aaa66c1e..c78cfc9e1 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -187,7 +187,7 @@ struct Session
187 187
188 /** 188 /**
189 * We keep all sessions in a DLL at their respective 189 * We keep all sessions in a DLL at their respective
190 * 'struct MACEndpoint'. 190 * `struct MACEndpoint *`.
191 */ 191 */
192 struct Session *prev; 192 struct Session *prev;
193 193
@@ -202,16 +202,6 @@ struct Session
202 struct GNUNET_HELLO_Address *address; 202 struct GNUNET_HELLO_Address *address;
203 203
204 /** 204 /**
205 * Head of messages currently pending for transmission to this peer.
206 */
207 struct PendingMessage *pending_message_head;
208
209 /**
210 * Tail of messages currently pending for transmission to this peer.
211 */
212 struct PendingMessage *pending_message_tail;
213
214 /**
215 * When should this session time out? 205 * When should this session time out?
216 */ 206 */
217 struct GNUNET_TIME_Absolute timeout; 207 struct GNUNET_TIME_Absolute timeout;
@@ -221,16 +211,6 @@ struct Session
221 */ 211 */
222 GNUNET_SCHEDULER_TaskIdentifier timeout_task; 212 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
223 213
224 /**
225 * Number of bytes waiting for transmission to this peer.
226 */
227 unsigned long long bytes_in_queue;
228
229 /**
230 * Number of messages waiting for transmission to this peer.
231 */
232 unsigned int msgs_in_queue;
233
234}; 214};
235 215
236 216
@@ -435,7 +415,8 @@ struct Plugin
435 char *interface; 415 char *interface;
436 416
437 /** 417 /**
438 * Tokenizer for demultiplexing of data packets resulting from defragmentation. 418 * Tokenizer for demultiplexing of data packets resulting from
419 * defragmentation.
439 */ 420 */
440 struct GNUNET_SERVER_MessageStreamTokenizer *fragment_data_tokenizer; 421 struct GNUNET_SERVER_MessageStreamTokenizer *fragment_data_tokenizer;
441 422
@@ -515,7 +496,9 @@ struct MacAndSession
515 * Print MAC addresses nicely. 496 * Print MAC addresses nicely.
516 * 497 *
517 * @param mac the mac address 498 * @param mac the mac address
518 * @return string to a static buffer with the human-readable mac, will be overwritten during the next call to this function 499 * @return string to a static buffer with
500 * the human-readable mac, will be overwritten during the next call to
501 * this function
519 */ 502 */
520static const char * 503static const char *
521mac_to_string (const struct GNUNET_TRANSPORT_WLAN_MacAddress * mac) 504mac_to_string (const struct GNUNET_TRANSPORT_WLAN_MacAddress * mac)
@@ -587,11 +570,11 @@ notify_session_monitor (struct Plugin *plugin,
587 memset (&info, 0, sizeof (info)); 570 memset (&info, 0, sizeof (info));
588 info.state = state; 571 info.state = state;
589 info.is_inbound = GNUNET_SYSERR; /* hard to say */ 572 info.is_inbound = GNUNET_SYSERR; /* hard to say */
590 // info.num_msg_pending = session->msgs_in_queue; // FIXME 573 info.num_msg_pending = 0; /* we queue per MAC, not per peer */
591 // info.num_bytes_pending = session->bytes_in_queue; // FIXME 574 info.num_bytes_pending = 0; /* we queue per MAC, not per peer */
592 info.receive_delay = GNUNET_TIME_UNIT_ZERO_ABS; 575 info.receive_delay = GNUNET_TIME_UNIT_ZERO_ABS; /* not supported by WLAN */
593 info.session_timeout = session->timeout; 576 info.session_timeout = session->timeout;
594 info.address = session->address; // ? 577 info.address = session->address;
595 plugin->sic (plugin->sic_cls, 578 plugin->sic (plugin->sic_cls,
596 session, 579 session,
597 &info); 580 &info);
@@ -719,7 +702,8 @@ wlan_data_message_handler (void *cls,
719 struct MacAndSession mas; 702 struct MacAndSession mas;
720 703
721 GNUNET_STATISTICS_update (plugin->env->stats, 704 GNUNET_STATISTICS_update (plugin->env->stats,
722 _("# WLAN messages defragmented"), 1, 705 _("# WLAN messages defragmented"),
706 1,
723 GNUNET_NO); 707 GNUNET_NO);
724 mas.session = NULL; 708 mas.session = NULL;
725 mas.endpoint = endpoint; 709 mas.endpoint = endpoint;
@@ -742,24 +726,11 @@ wlan_plugin_disconnect_session (void *cls,
742 struct Session *session) 726 struct Session *session)
743{ 727{
744 struct MacEndpoint *endpoint = session->mac; 728 struct MacEndpoint *endpoint = session->mac;
745 struct PendingMessage *pm; 729 struct Plugin *plugin = endpoint->plugin;
746 730
747 endpoint->plugin->env->session_end (endpoint->plugin->env->cls, 731 plugin->env->session_end (plugin->env->cls,
748 session->address, 732 session->address,
749 session); 733 session);
750 while (NULL != (pm = session->pending_message_head))
751 {
752 GNUNET_CONTAINER_DLL_remove (session->pending_message_head,
753 session->pending_message_tail,
754 pm);
755 if (GNUNET_SCHEDULER_NO_TASK != pm->timeout_task)
756 {
757 GNUNET_SCHEDULER_cancel (pm->timeout_task);
758 pm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
759 }
760 GNUNET_free (pm->msg);
761 GNUNET_free (pm);
762 }
763 GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, 734 GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head,
764 endpoint->sessions_tail, 735 endpoint->sessions_tail,
765 session); 736 session);
@@ -768,8 +739,9 @@ wlan_plugin_disconnect_session (void *cls,
768 GNUNET_SCHEDULER_cancel (session->timeout_task); 739 GNUNET_SCHEDULER_cancel (session->timeout_task);
769 session->timeout_task = GNUNET_SCHEDULER_NO_TASK; 740 session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
770 } 741 }
771 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, 742 GNUNET_STATISTICS_update (plugin->env->stats,
772 _("# WLAN sessions allocated"), -1, 743 _("# WLAN sessions allocated"),
744 -1,
773 GNUNET_NO); 745 GNUNET_NO);
774 GNUNET_HELLO_address_free (session->address); 746 GNUNET_HELLO_address_free (session->address);
775 GNUNET_free (session); 747 GNUNET_free (session);
@@ -908,7 +880,8 @@ get_session (struct MacEndpoint *endpoint,
908 * the next fragment. 880 * the next fragment.
909 * 881 *
910 * @param cls the `struct FragmentMessage *` 882 * @param cls the `struct FragmentMessage *`
911 * @param result result of the operation (#GNUNET_OK on success, #GNUNET_NO if the helper died, #GNUNET_SYSERR 883 * @param result result of the operation (#GNUNET_OK on success,
884 * #GNUNET_NO if the helper died, #GNUNET_SYSERR
912 * if the helper was stopped) 885 * if the helper was stopped)
913 */ 886 */
914static void 887static void
@@ -964,8 +937,10 @@ transmit_fragment (void *cls,
964 &fragment_transmission_done, fm); 937 &fragment_transmission_done, fm);
965 fm->size_on_wire += size; 938 fm->size_on_wire += size;
966 if (NULL != fm->sh) 939 if (NULL != fm->sh)
967 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN message fragments sent"), 940 GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
968 1, GNUNET_NO); 941 _("# WLAN message fragments sent"),
942 1,
943 GNUNET_NO);
969 else 944 else
970 GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext); 945 GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext);
971 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, 946 GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
@@ -988,10 +963,12 @@ free_fragment_message (struct FragmentMessage *fm)
988{ 963{
989 struct MacEndpoint *endpoint = fm->macendpoint; 964 struct MacEndpoint *endpoint = fm->macendpoint;
990 965
991 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN messages pending (with fragmentation)"), 966 GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
967 _("# WLAN messages pending (with fragmentation)"),
992 -1, GNUNET_NO); 968 -1, GNUNET_NO);
993 GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head, 969 GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head,
994 endpoint->sending_messages_tail, fm); 970 endpoint->sending_messages_tail,
971 fm);
995 if (NULL != fm->sh) 972 if (NULL != fm->sh)
996 { 973 {
997 GNUNET_HELPER_send_cancel (fm->sh); 974 GNUNET_HELPER_send_cancel (fm->sh);
@@ -1013,7 +990,7 @@ free_fragment_message (struct FragmentMessage *fm)
1013 * A FragmentMessage has timed out. Remove it. 990 * A FragmentMessage has timed out. Remove it.
1014 * 991 *
1015 * @param cls pointer to the 'struct FragmentMessage' 992 * @param cls pointer to the 'struct FragmentMessage'
1016 * @param tc pointer to the GNUNET_SCHEDULER_TaskContext 993 * @param tc unused
1017 */ 994 */
1018static void 995static void
1019fragmentmessage_timeout (void *cls, 996fragmentmessage_timeout (void *cls,
@@ -1132,7 +1109,7 @@ free_macendpoint (struct MacEndpoint *endpoint)
1132/** 1109/**
1133 * A MAC endpoint is timing out. Clean up. 1110 * A MAC endpoint is timing out. Clean up.
1134 * 1111 *
1135 * @param cls pointer to the `struct MacEndpoint` 1112 * @param cls pointer to the `struct MacEndpoint *`
1136 * @param tc pointer to the GNUNET_SCHEDULER_TaskContext 1113 * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
1137 */ 1114 */
1138static void 1115static void
@@ -1196,9 +1173,12 @@ create_macendpoint (struct Plugin *plugin,
1196 pos->timeout_task = 1173 pos->timeout_task =
1197 GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout, 1174 GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
1198 pos); 1175 pos);
1199 GNUNET_CONTAINER_DLL_insert (plugin->mac_head, plugin->mac_tail, pos); 1176 GNUNET_CONTAINER_DLL_insert (plugin->mac_head,
1177 plugin->mac_tail,
1178 pos);
1200 plugin->mac_count++; 1179 plugin->mac_count++;
1201 GNUNET_STATISTICS_update (plugin->env->stats, _("# WLAN MAC endpoints allocated"), 1180 GNUNET_STATISTICS_update (plugin->env->stats,
1181 _("# WLAN MAC endpoints allocated"),
1202 1, GNUNET_NO); 1182 1, GNUNET_NO);
1203 LOG (GNUNET_ERROR_TYPE_DEBUG, 1183 LOG (GNUNET_ERROR_TYPE_DEBUG,
1204 "New MAC endpoint `%s'\n", 1184 "New MAC endpoint `%s'\n",
@@ -1389,7 +1369,8 @@ process_data (void *cls,
1389 case GNUNET_MESSAGE_TYPE_HELLO: 1369 case GNUNET_MESSAGE_TYPE_HELLO:
1390 1370
1391 if (GNUNET_OK != 1371 if (GNUNET_OK !=
1392 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource)) 1372 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr,
1373 &tmpsource))
1393 { 1374 {
1394 GNUNET_break_op (0); 1375 GNUNET_break_op (0);
1395 break; 1376 break;
@@ -1434,7 +1415,9 @@ process_data (void *cls,
1434 &mas->endpoint->wlan_addr, 1415 &mas->endpoint->wlan_addr,
1435 sizeof (mas->endpoint->wlan_addr))); 1416 sizeof (mas->endpoint->wlan_addr)));
1436 GNUNET_STATISTICS_update (plugin->env->stats, 1417 GNUNET_STATISTICS_update (plugin->env->stats,
1437 _("# fragments received via WLAN"), 1, GNUNET_NO); 1418 _("# fragments received via WLAN"),
1419 1,
1420 GNUNET_NO);
1438 (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag, 1421 (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag,
1439 hdr); 1422 hdr);
1440 break; 1423 break;
@@ -1460,7 +1443,11 @@ process_data (void *cls,
1460 mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT); 1443 mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
1461 if (NULL != fm->cont) 1444 if (NULL != fm->cont)
1462 { 1445 {
1463 fm->cont (fm->cont_cls, &fm->target, GNUNET_OK, fm->size_payload, fm->size_on_wire); 1446 fm->cont (fm->cont_cls,
1447 &fm->target,
1448 GNUNET_OK,
1449 fm->size_payload,
1450 fm->size_on_wire);
1464 fm->cont = NULL; 1451 fm->cont = NULL;
1465 } 1452 }
1466 free_fragment_message (fm); 1453 free_fragment_message (fm);
@@ -1507,7 +1494,8 @@ process_data (void *cls,
1507 GNUNET_CRYPTO_crc32_n (&wlanheader[1], msize - sizeof (struct WlanHeader))) 1494 GNUNET_CRYPTO_crc32_n (&wlanheader[1], msize - sizeof (struct WlanHeader)))
1508 { 1495 {
1509 GNUNET_STATISTICS_update (plugin->env->stats, 1496 GNUNET_STATISTICS_update (plugin->env->stats,
1510 _("# WLAN DATA messages discarded due to CRC32 error"), 1, 1497 _("# WLAN DATA messages discarded due to CRC32 error"),
1498 1,
1511 GNUNET_NO); 1499 GNUNET_NO);
1512 break; 1500 break;
1513 } 1501 }
@@ -1556,13 +1544,13 @@ process_data (void *cls,
1556 (unsigned int) ntohs (hdr->type), 1544 (unsigned int) ntohs (hdr->type),
1557 GNUNET_i2s (&mas->session->target)); 1545 GNUNET_i2s (&mas->session->target));
1558 plugin->env->receive (plugin->env->cls, 1546 plugin->env->receive (plugin->env->cls,
1559 mas->session->address, 1547 mas->session->address,
1560 mas->session, 1548 mas->session,
1561 hdr); 1549 hdr);
1562 plugin->env->update_address_metrics (plugin->env->cls, 1550 plugin->env->update_address_metrics (plugin->env->cls,
1563 mas->session->address, 1551 mas->session->address,
1564 mas->session, 1552 mas->session,
1565 &ats, 1); 1553 &ats, 1);
1566 break; 1554 break;
1567 } 1555 }
1568 return GNUNET_OK; 1556 return GNUNET_OK;
@@ -1609,8 +1597,12 @@ handle_helper_message (void *cls, void *client,
1609 wa.mac = plugin->mac_address; 1597 wa.mac = plugin->mac_address;
1610 wa.options = htonl(plugin->options); 1598 wa.options = htonl(plugin->options);
1611 my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity, 1599 my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
1612 PLUGIN_NAME, &wa, sizeof (wa), GNUNET_HELLO_ADDRESS_INFO_NONE); 1600 PLUGIN_NAME,
1613 plugin->env->notify_address (plugin->env->cls, GNUNET_NO, my_address); 1601 &wa, sizeof (wa),
1602 GNUNET_HELLO_ADDRESS_INFO_NONE);
1603 plugin->env->notify_address (plugin->env->cls,
1604 GNUNET_NO,
1605 my_address);
1614 GNUNET_HELLO_address_free (my_address); 1606 GNUNET_HELLO_address_free (my_address);
1615 } 1607 }
1616 plugin->mac_address = cm->mac; 1608 plugin->mac_address = cm->mac;
@@ -1620,13 +1612,17 @@ handle_helper_message (void *cls, void *client,
1620 wa.mac = plugin->mac_address; 1612 wa.mac = plugin->mac_address;
1621 wa.options = htonl(plugin->options); 1613 wa.options = htonl(plugin->options);
1622 my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity, 1614 my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
1623 PLUGIN_NAME, &wa, sizeof (wa), GNUNET_HELLO_ADDRESS_INFO_NONE); 1615 PLUGIN_NAME,
1616 &wa, sizeof (wa),
1617 GNUNET_HELLO_ADDRESS_INFO_NONE);
1624 1618
1625 LOG (GNUNET_ERROR_TYPE_DEBUG, 1619 LOG (GNUNET_ERROR_TYPE_DEBUG,
1626 "Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n", 1620 "Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n",
1627 mac_to_string (&cm->mac), 1621 mac_to_string (&cm->mac),
1628 GNUNET_i2s (plugin->env->my_identity)); 1622 GNUNET_i2s (plugin->env->my_identity));
1629 plugin->env->notify_address (plugin->env->cls, GNUNET_YES, my_address); 1623 plugin->env->notify_address (plugin->env->cls,
1624 GNUNET_YES,
1625 my_address);
1630 GNUNET_HELLO_address_free (my_address); 1626 GNUNET_HELLO_address_free (my_address);
1631 break; 1627 break;
1632 case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER: 1628 case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER:
@@ -1696,7 +1692,6 @@ handle_helper_message (void *cls, void *client,
1696} 1692}
1697 1693
1698 1694
1699
1700/** 1695/**
1701 * Task to (periodically) send a HELLO beacon 1696 * Task to (periodically) send a HELLO beacon
1702 * 1697 *
@@ -1732,7 +1727,8 @@ send_hello_beacon (void *cls,
1732 &radioHeader->header, 1727 &radioHeader->header,
1733 GNUNET_YES /* can drop */, 1728 GNUNET_YES /* can drop */,
1734 NULL, NULL)) 1729 NULL, NULL))
1735 GNUNET_STATISTICS_update (plugin->env->stats, _("# HELLO beacons sent via WLAN"), 1730 GNUNET_STATISTICS_update (plugin->env->stats,
1731 _("# HELLO beacons sent via WLAN"),
1736 1, GNUNET_NO); 1732 1, GNUNET_NO);
1737 } 1733 }
1738 plugin->beacon_task = 1734 plugin->beacon_task =