diff options
author | David Brodski <david@brodski.eu> | 2011-08-04 08:59:18 +0000 |
---|---|---|
committer | David Brodski <david@brodski.eu> | 2011-08-04 08:59:18 +0000 |
commit | e3013e62061007990cb8a089ea797a3c72973a56 (patch) | |
tree | 2a9c5a8c3417dd85b5fff86954a66908410f78bc /src/transport/plugin_transport_wlan.c | |
parent | 903d8fdb3cba026f175501558d5e703ac9973277 (diff) | |
download | gnunet-e3013e62061007990cb8a089ea797a3c72973a56.tar.gz gnunet-e3013e62061007990cb8a089ea797a3c72973a56.zip |
Cleanup of log messages and timeouts implemented
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 315 |
1 files changed, 195 insertions, 120 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 51c6d3053..d90522062 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -42,15 +42,27 @@ | |||
42 | 42 | ||
43 | #define PROTOCOL_PREFIX "wlan" | 43 | #define PROTOCOL_PREFIX "wlan" |
44 | 44 | ||
45 | #define PLUGIN_LOG_NAME "wlan-plugin" | ||
46 | |||
45 | /** | 47 | /** |
46 | * Max size of packet from helper | 48 | * Max size of packet |
47 | */ | 49 | */ |
48 | #define WLAN_MTU 1450 | 50 | #define WLAN_MTU 1450 |
49 | 51 | ||
50 | /** | 52 | /** |
51 | * Time until retransmission of a fragment in ms | 53 | * time out of a session |
54 | */ | ||
55 | #define SESSION_TIMEOUT GNUNET_TIME_UNIT_MINUTES | ||
56 | |||
57 | /** | ||
58 | * time out of a mac endpoint | ||
59 | */ | ||
60 | #define MACENDPOINT_TIMEOUT GNUNET_TIME_UNIT_MINUTES | ||
61 | |||
62 | /** | ||
63 | * scaling factor for hello beacon | ||
52 | */ | 64 | */ |
53 | #define FRAGMENT_TIMEOUT GNUNET_TIME_UNIT_SECONDS | 65 | #define HALLO_BEACON_SCALING_FACTOR 900 |
54 | 66 | ||
55 | /** | 67 | /** |
56 | * max size of fragment queue | 68 | * max size of fragment queue |
@@ -67,11 +79,6 @@ | |||
67 | #define FRAGMENT_QUEUE_MESSAGES_OUT_PER_MACENDPOINT 1 | 79 | #define FRAGMENT_QUEUE_MESSAGES_OUT_PER_MACENDPOINT 1 |
68 | 80 | ||
69 | /** | 81 | /** |
70 | * time until message in in queue | ||
71 | */ | ||
72 | #define MESSAGE_IN_TIMEOUT GNUNET_TIME_UNIT_SECONDS | ||
73 | |||
74 | /** | ||
75 | * max messages in in queue | 82 | * max messages in in queue |
76 | */ | 83 | */ |
77 | #define MESSAGES_IN_QUEUE_SIZE 10 | 84 | #define MESSAGES_IN_QUEUE_SIZE 10 |
@@ -79,27 +86,15 @@ | |||
79 | * max messages in in queue per session/client | 86 | * max messages in in queue per session/client |
80 | */ | 87 | */ |
81 | #define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC 1 | 88 | #define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC 1 |
89 | |||
90 | |||
82 | /** | 91 | /** |
83 | * scaling factor for hello beacon | 92 | * DEBUG switch |
84 | */ | 93 | */ |
85 | #define HALLO_BEACON_SCALING_FACTOR 900 | ||
86 | |||
87 | #define DEBUG_wlan GNUNET_NO | 94 | #define DEBUG_wlan GNUNET_NO |
88 | #define DEBUG_wlan_retransmission GNUNET_NO | 95 | #define DEBUG_wlan_retransmission GNUNET_NO |
89 | #define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO | 96 | #define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO |
90 | 97 | ||
91 | #define MESSAGE_LENGHT_UNKNOWN -1 | ||
92 | //#define NO_MESSAGE_OR_MESSAGE_FINISHED -2 | ||
93 | /** | ||
94 | * size of log for recently used incomming messages id | ||
95 | */ | ||
96 | #define MESSAGE_ID_BACKLOG_SIZE 5 | ||
97 | /** | ||
98 | * After how long do we expire an address that we | ||
99 | * learned from another peer if it is not reconfirmed | ||
100 | * by anyone? | ||
101 | */ | ||
102 | #define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6) | ||
103 | 98 | ||
104 | #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ | 99 | #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ |
105 | 100 | ||
@@ -164,22 +159,6 @@ struct iph ip; | |||
164 | struct udphdr udp; | 159 | struct udphdr udp; |
165 | #endif | 160 | #endif |
166 | }GNUNET_PACKED; | 161 | }GNUNET_PACKED; |
167 | /** | ||
168 | * Initial handshake message for a session. | ||
169 | */ | ||
170 | struct WelcomeMessage | ||
171 | { | ||
172 | /** | ||
173 | * Type is GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME. | ||
174 | */ | ||
175 | struct GNUNET_MessageHeader header; | ||
176 | |||
177 | /** | ||
178 | * Identit*mac_y of the node connecting (TCP client) | ||
179 | */ | ||
180 | struct GNUNET_PeerIdentity clientIdentity; | ||
181 | |||
182 | }; | ||
183 | 162 | ||
184 | /** | 163 | /** |
185 | * Encapsulation of all of the state of the plugin. | 164 | * Encapsulation of all of the state of the plugin. |
@@ -518,11 +497,16 @@ struct Session | |||
518 | 497 | ||
519 | /** | 498 | /** |
520 | * Last activity on this connection. Used to select preferred | 499 | * Last activity on this connection. Used to select preferred |
521 | * connection. | 500 | * connection and timeout |
522 | */ | 501 | */ |
523 | struct GNUNET_TIME_Absolute last_activity; | 502 | struct GNUNET_TIME_Absolute last_activity; |
524 | 503 | ||
525 | /** | 504 | /** |
505 | * Timeout task. | ||
506 | */ | ||
507 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | ||
508 | |||
509 | /** | ||
526 | * peer connection | 510 | * peer connection |
527 | */ | 511 | */ |
528 | struct MacEndpoint * mac; | 512 | struct MacEndpoint * mac; |
@@ -607,6 +591,17 @@ struct MacEndpoint | |||
607 | * Acks received | 591 | * Acks received |
608 | */ | 592 | */ |
609 | int acks; | 593 | int acks; |
594 | |||
595 | /** | ||
596 | * Last activity on this endpoint. Used to select preferred | ||
597 | * connection. | ||
598 | */ | ||
599 | struct GNUNET_TIME_Absolute last_activity; | ||
600 | |||
601 | /** | ||
602 | * Timeout task. | ||
603 | */ | ||
604 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | ||
610 | }; | 605 | }; |
611 | 606 | ||
612 | /** | 607 | /** |
@@ -633,14 +628,19 @@ struct FragmentMessage | |||
633 | struct FragmentMessage *prev; | 628 | struct FragmentMessage *prev; |
634 | 629 | ||
635 | /** | 630 | /** |
636 | * Timeout value for the pending message. | 631 | * Fragmentation context |
632 | */ | ||
633 | struct GNUNET_FRAGMENT_Context * fragcontext; | ||
634 | |||
635 | /** | ||
636 | * Timeout value for the message. | ||
637 | */ | 637 | */ |
638 | struct GNUNET_TIME_Absolute timeout; | 638 | struct GNUNET_TIME_Absolute timeout; |
639 | 639 | ||
640 | /** | 640 | /** |
641 | * Fragmentation context | 641 | * Timeout task. |
642 | */ | 642 | */ |
643 | struct GNUNET_FRAGMENT_Context * fragcontext; | 643 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; |
644 | 644 | ||
645 | /** | 645 | /** |
646 | * Fragment to send | 646 | * Fragment to send |
@@ -810,6 +810,33 @@ wlan_plugin_address_to_string(void *cls, const void *addr, size_t addrlen) | |||
810 | } | 810 | } |
811 | 811 | ||
812 | /** | 812 | /** |
813 | * Function for the scheduler if a session times out | ||
814 | * @param cls pointer to the Sessionqueue | ||
815 | * @param tc pointer to the GNUNET_SCHEDULER_TaskContext | ||
816 | */ | ||
817 | static void | ||
818 | session_timeout (void *cls, | ||
819 | const struct GNUNET_SCHEDULER_TaskContext *tc){ | ||
820 | struct Sessionqueue * queue = cls; | ||
821 | GNUNET_assert(queue != NULL); | ||
822 | queue->content->timeout_task = GNUNET_SCHEDULER_NO_TASK; | ||
823 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN){ | ||
824 | return; | ||
825 | } | ||
826 | if (GNUNET_TIME_absolute_get_remaining( | ||
827 | GNUNET_TIME_absolute_add(queue->content->last_activity, SESSION_TIMEOUT)).rel_value | ||
828 | == 0) | ||
829 | { | ||
830 | free_session(queue->content->mac->plugin,queue,GNUNET_YES); | ||
831 | } | ||
832 | else | ||
833 | { | ||
834 | queue->content->timeout_task = GNUNET_SCHEDULER_add_delayed(SESSION_TIMEOUT, | ||
835 | &session_timeout, queue); | ||
836 | } | ||
837 | } | ||
838 | |||
839 | /** | ||
813 | * create a new session | 840 | * create a new session |
814 | * | 841 | * |
815 | * @param plugin pointer to the plugin struct | 842 | * @param plugin pointer to the plugin struct |
@@ -822,16 +849,18 @@ create_session(struct Plugin *plugin, struct MacEndpoint * endpoint, | |||
822 | const struct GNUNET_PeerIdentity * peer) | 849 | const struct GNUNET_PeerIdentity * peer) |
823 | { | 850 | { |
824 | GNUNET_assert(endpoint != NULL); | 851 | GNUNET_assert(endpoint != NULL); |
825 | struct Sessionqueue * queue = GNUNET_malloc (sizeof (struct Sessionqueue)); | 852 | struct Sessionqueue * queue = GNUNET_malloc (sizeof (struct Sessionqueue) + sizeof (struct Session)); |
826 | 853 | ||
827 | GNUNET_CONTAINER_DLL_insert_tail(endpoint->sessions_head, endpoint->sessions_tail, queue); | 854 | GNUNET_CONTAINER_DLL_insert_tail(endpoint->sessions_head, endpoint->sessions_tail, queue); |
828 | 855 | ||
829 | queue->content = GNUNET_malloc (sizeof (struct Session)); | 856 | queue->content = (struct Session *) &queue[1]; |
830 | queue->content->mac = endpoint; | 857 | queue->content->mac = endpoint; |
831 | memcpy(&(queue->content->target), peer, sizeof(struct GNUNET_PeerIdentity)); | 858 | memcpy(&(queue->content->target), peer, sizeof(struct GNUNET_PeerIdentity)); |
859 | queue->content->last_activity = GNUNET_TIME_absolute_get(); | ||
860 | queue->content->timeout_task = GNUNET_SCHEDULER_add_delayed(SESSION_TIMEOUT,&session_timeout, queue); | ||
832 | 861 | ||
833 | #if DEBUG_wlan | 862 | #if DEBUG_wlan |
834 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "New session %p with endpoint %p: %s\n", | 863 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "New session %p with endpoint %p: %s\n", |
835 | queue->content, endpoint, | 864 | queue->content, endpoint, |
836 | wlan_plugin_address_to_string(NULL, endpoint->addr.mac, 6)); | 865 | wlan_plugin_address_to_string(NULL, endpoint->addr.mac, 6)); |
837 | #endif | 866 | #endif |
@@ -991,10 +1020,8 @@ set_next_send(struct Plugin * const plugin) | |||
991 | } | 1020 | } |
992 | 1021 | ||
993 | #if DEBUG_wlan | 1022 | #if DEBUG_wlan |
994 | 1023 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "Next packet is send in: %u\n", | |
995 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Next packet is send in: %u\n", | ||
996 | next_send.rel_value); | 1024 | next_send.rel_value); |
997 | |||
998 | #endif | 1025 | #endif |
999 | 1026 | ||
1000 | if (next_send.rel_value == GNUNET_TIME_UNIT_ZERO.rel_value) | 1027 | if (next_send.rel_value == GNUNET_TIME_UNIT_ZERO.rel_value) |
@@ -1040,7 +1067,7 @@ get_next_queue_session(struct Plugin * plugin) | |||
1040 | #if DEBUG_wlan | 1067 | #if DEBUG_wlan |
1041 | if (pm == NULL) | 1068 | if (pm == NULL) |
1042 | { | 1069 | { |
1043 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1070 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
1044 | "pending message is empty, should not happen. session %p\n", | 1071 | "pending message is empty, should not happen. session %p\n", |
1045 | session); | 1072 | session); |
1046 | } | 1073 | } |
@@ -1128,11 +1155,13 @@ free_fragment_message(struct Plugin * plugin, struct FragmentMessage * fm) | |||
1128 | plugin->pending_Fragment_Messages--; | 1155 | plugin->pending_Fragment_Messages--; |
1129 | GNUNET_CONTAINER_DLL_remove(endpoint->sending_messages_head,endpoint->sending_messages_tail, fm); | 1156 | GNUNET_CONTAINER_DLL_remove(endpoint->sending_messages_head,endpoint->sending_messages_tail, fm); |
1130 | GNUNET_FRAGMENT_context_destroy(fm->fragcontext); | 1157 | GNUNET_FRAGMENT_context_destroy(fm->fragcontext); |
1158 | if (fm->timeout_task != GNUNET_SCHEDULER_NO_TASK) | ||
1159 | GNUNET_SCHEDULER_cancel(fm->timeout_task); | ||
1131 | GNUNET_free(fm); | 1160 | GNUNET_free(fm); |
1132 | 1161 | ||
1133 | queue_session(plugin, session); | 1162 | queue_session(plugin, session); |
1134 | #if DEBUG_wlan | 1163 | #if DEBUG_wlan |
1135 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1164 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1136 | "Free pending fragment messages %p, session %p\n", fm, session); | 1165 | "Free pending fragment messages %p, session %p\n", fm, session); |
1137 | #endif | 1166 | #endif |
1138 | } | 1167 | } |
@@ -1278,7 +1307,7 @@ add_message_for_send(void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1278 | uint16_t size; | 1307 | uint16_t size; |
1279 | 1308 | ||
1280 | #if DEBUG_wlan_retransmission | 1309 | #if DEBUG_wlan_retransmission |
1281 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1310 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1282 | "Adding fragment of message %p to send, session %p, endpoint %p\n", fm, | 1311 | "Adding fragment of message %p to send, session %p, endpoint %p\n", fm, |
1283 | fm->session, endpoint); | 1312 | fm->session, endpoint); |
1284 | #endif | 1313 | #endif |
@@ -1314,7 +1343,7 @@ send_hello_beacon(struct Plugin * plugin) | |||
1314 | { | 1343 | { |
1315 | 1344 | ||
1316 | #if DEBUG_wlan | 1345 | #if DEBUG_wlan |
1317 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending hello beacon\n"); | 1346 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "Sending hello beacon\n"); |
1318 | #endif | 1347 | #endif |
1319 | 1348 | ||
1320 | uint16_t size; | 1349 | uint16_t size; |
@@ -1352,7 +1381,7 @@ send_hello_beacon(struct Plugin * plugin) | |||
1352 | 1381 | ||
1353 | if (bytes == GNUNET_SYSERR) | 1382 | if (bytes == GNUNET_SYSERR) |
1354 | { | 1383 | { |
1355 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1384 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
1356 | _("Error writing to wlan healper. errno == %d, ERROR: %s\n"), | 1385 | _("Error writing to wlan healper. errno == %d, ERROR: %s\n"), |
1357 | errno, strerror(errno)); | 1386 | errno, strerror(errno)); |
1358 | 1387 | ||
@@ -1412,7 +1441,7 @@ add_ack_for_send(void *cls, uint32_t msg_id, | |||
1412 | plugin->ack_send_queue_tail, ack); | 1441 | plugin->ack_send_queue_tail, ack); |
1413 | 1442 | ||
1414 | #if DEBUG_wlan_retransmission | 1443 | #if DEBUG_wlan_retransmission |
1415 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1444 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1416 | "Adding ack with message id %u to send, AckSendQueue %p, endpoint %p\n", | 1445 | "Adding ack with message id %u to send, AckSendQueue %p, endpoint %p\n", |
1417 | msg_id, ack, endpoint); | 1446 | msg_id, ack, endpoint); |
1418 | #endif | 1447 | #endif |
@@ -1421,6 +1450,23 @@ add_ack_for_send(void *cls, uint32_t msg_id, | |||
1421 | } | 1450 | } |
1422 | 1451 | ||
1423 | /** | 1452 | /** |
1453 | * Function for the scheduler if a FragmentMessage times out | ||
1454 | * @param cls pointer to the FragmentMessage | ||
1455 | * @param tc pointer to the GNUNET_SCHEDULER_TaskContext | ||
1456 | */ | ||
1457 | static void | ||
1458 | fragmentmessage_timeout (void *cls, | ||
1459 | const struct GNUNET_SCHEDULER_TaskContext *tc){ | ||
1460 | struct FragmentMessage * fm = cls; | ||
1461 | GNUNET_assert(fm != NULL); | ||
1462 | fm->timeout_task = GNUNET_SCHEDULER_NO_TASK; | ||
1463 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN){ | ||
1464 | return; | ||
1465 | } | ||
1466 | free_fragment_message(fm->session->mac->plugin,fm); | ||
1467 | } | ||
1468 | |||
1469 | /** | ||
1424 | * Function to check if there is some space in the fragment queue | 1470 | * Function to check if there is some space in the fragment queue |
1425 | * inserts a message if space is available | 1471 | * inserts a message if space is available |
1426 | * @param plugin the plugin struct | 1472 | * @param plugin the plugin struct |
@@ -1455,6 +1501,7 @@ check_fragment_queue(struct Plugin * plugin) | |||
1455 | WLAN_MTU, &plugin->tracker, GNUNET_TIME_UNIT_SECONDS, | 1501 | WLAN_MTU, &plugin->tracker, GNUNET_TIME_UNIT_SECONDS, |
1456 | &(pm->msg->header), &add_message_for_send, | 1502 | &(pm->msg->header), &add_message_for_send, |
1457 | fm); | 1503 | fm); |
1504 | fm->timeout_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_absolute_get_remaining(fm->timeout),fragmentmessage_timeout,fm); | ||
1458 | GNUNET_CONTAINER_DLL_insert_tail(session->mac->sending_messages_head,session->mac->sending_messages_tail,fm); | 1505 | GNUNET_CONTAINER_DLL_insert_tail(session->mac->sending_messages_head,session->mac->sending_messages_tail,fm); |
1459 | 1506 | ||
1460 | if (pm->transmit_cont != NULL) | 1507 | if (pm->transmit_cont != NULL) |
@@ -1462,14 +1509,14 @@ check_fragment_queue(struct Plugin * plugin) | |||
1462 | pid = session->target; | 1509 | pid = session->target; |
1463 | pm->transmit_cont(pm->transmit_cont_cls, &pid, GNUNET_OK); | 1510 | pm->transmit_cont(pm->transmit_cont_cls, &pid, GNUNET_OK); |
1464 | #if DEBUG_wlan | 1511 | #if DEBUG_wlan |
1465 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1512 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1466 | "called pm->transmit_cont for %p\n", session); | 1513 | "called pm->transmit_cont for %p\n", session); |
1467 | #endif | 1514 | #endif |
1468 | } | 1515 | } |
1469 | else | 1516 | else |
1470 | { | 1517 | { |
1471 | #if DEBUG_wlan | 1518 | #if DEBUG_wlan |
1472 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1519 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1473 | "no pm->transmit_cont for %p\n", session); | 1520 | "no pm->transmit_cont for %p\n", session); |
1474 | #endif | 1521 | #endif |
1475 | } | 1522 | } |
@@ -1500,7 +1547,7 @@ send_ack(struct Plugin * plugin, struct AckSendQueue * ack) | |||
1500 | ssize_t bytes; | 1547 | ssize_t bytes; |
1501 | 1548 | ||
1502 | #if DEBUG_wlan | 1549 | #if DEBUG_wlan |
1503 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1550 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1504 | "Sending ack for message_id %u for mac endpoint %p, size %u\n", | 1551 | "Sending ack for message_id %u for mac endpoint %p, size %u\n", |
1505 | ack->message_id, ack->endpoint, | 1552 | ack->message_id, ack->endpoint, |
1506 | ntohs(ack->hdr->size) - sizeof(struct Radiotap_Send)); | 1553 | ntohs(ack->hdr->size) - sizeof(struct Radiotap_Send)); |
@@ -1514,7 +1561,7 @@ send_ack(struct Plugin * plugin, struct AckSendQueue * ack) | |||
1514 | ntohs(ack->hdr->size)); | 1561 | ntohs(ack->hdr->size)); |
1515 | if (bytes == GNUNET_SYSERR) | 1562 | if (bytes == GNUNET_SYSERR) |
1516 | { | 1563 | { |
1517 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1564 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
1518 | _("Error writing to wlan healper. errno == %d, ERROR: %s\n"), | 1565 | _("Error writing to wlan healper. errno == %d, ERROR: %s\n"), |
1519 | errno, strerror(errno)); | 1566 | errno, strerror(errno)); |
1520 | 1567 | ||
@@ -1615,8 +1662,7 @@ do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1615 | GNUNET_assert(session != NULL); | 1662 | GNUNET_assert(session != NULL); |
1616 | 1663 | ||
1617 | #if DEBUG_wlan | 1664 | #if DEBUG_wlan |
1618 | GNUNET_log( | 1665 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG,PLUGIN_LOG_NAME, |
1619 | GNUNET_ERROR_TYPE_DEBUG, | ||
1620 | "Sending GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT for fragment message %p, size: %u\n", | 1666 | "Sending GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT for fragment message %p, size: %u\n", |
1621 | fm, fm->size); | 1667 | fm, fm->size); |
1622 | #endif | 1668 | #endif |
@@ -1629,7 +1675,7 @@ do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1629 | fm->size); | 1675 | fm->size); |
1630 | if (bytes == GNUNET_SYSERR) | 1676 | if (bytes == GNUNET_SYSERR) |
1631 | { | 1677 | { |
1632 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1678 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
1633 | _("Error writing to wlan healper. errno == %d, ERROR: %s\n"), | 1679 | _("Error writing to wlan healper. errno == %d, ERROR: %s\n"), |
1634 | errno, strerror(errno)); | 1680 | errno, strerror(errno)); |
1635 | 1681 | ||
@@ -1661,7 +1707,7 @@ do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1661 | return; | 1707 | return; |
1662 | } | 1708 | } |
1663 | 1709 | ||
1664 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1710 | GNUNET_log_from(GNUNET_ERROR_TYPE_WARNING, PLUGIN_LOG_NAME, |
1665 | "do_transmit did nothing, should not happen!\n"); | 1711 | "do_transmit did nothing, should not happen!\n"); |
1666 | } | 1712 | } |
1667 | 1713 | ||
@@ -1746,7 +1792,7 @@ wlan_plugin_send(void *cls, const struct GNUNET_PeerIdentity * target, | |||
1746 | } | 1792 | } |
1747 | else | 1793 | else |
1748 | { | 1794 | { |
1749 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1795 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
1750 | _("Wlan Address len %d is wrong\n"), addrlen); | 1796 | _("Wlan Address len %d is wrong\n"), addrlen); |
1751 | return -1; | 1797 | return -1; |
1752 | } | 1798 | } |
@@ -1760,8 +1806,7 @@ wlan_plugin_send(void *cls, const struct GNUNET_PeerIdentity * target, | |||
1760 | if (session->pending_message_head != NULL) | 1806 | if (session->pending_message_head != NULL) |
1761 | { | 1807 | { |
1762 | newmsg = session->pending_message_head; | 1808 | newmsg = session->pending_message_head; |
1763 | GNUNET_log( | 1809 | GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, |
1764 | GNUNET_ERROR_TYPE_ERROR, | ||
1765 | "wlan_plugin_send: a pending message is already in the queue for this client\n remaining time to send this message is %u, queued fragment messages for this mac connection %u\n", | 1810 | "wlan_plugin_send: a pending message is already in the queue for this client\n remaining time to send this message is %u, queued fragment messages for this mac connection %u\n", |
1766 | GNUNET_TIME_absolute_get_remaining(newmsg->timeout).rel_value, | 1811 | GNUNET_TIME_absolute_get_remaining(newmsg->timeout).rel_value, |
1767 | session->mac->fragment_messages_out_count); | 1812 | session->mac->fragment_messages_out_count); |
@@ -1780,7 +1825,7 @@ wlan_plugin_send(void *cls, const struct GNUNET_PeerIdentity * target, | |||
1780 | memcpy(&wlanheader[1], msgbuf, msgbuf_size); | 1825 | memcpy(&wlanheader[1], msgbuf, msgbuf_size); |
1781 | wlanheader->crc = htonl( | 1826 | wlanheader->crc = htonl( |
1782 | getcrc32((char*) wlanheader, msgbuf_size + sizeof(struct WlanHeader))); | 1827 | getcrc32((char*) wlanheader, msgbuf_size + sizeof(struct WlanHeader))); |
1783 | //GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Wlan message Header crc: %u, %u\n",getcrc32((char*) wlanheader, msgbuf_size + sizeof(struct WlanHeader)), wlanheader->crc); | 1828 | //GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, "Wlan message Header crc: %u, %u\n",getcrc32((char*) wlanheader, msgbuf_size + sizeof(struct WlanHeader)), wlanheader->crc); |
1784 | //hexdump(newmsg->msg, msgbuf_size + sizeof(struct WlanHeader)); | 1829 | //hexdump(newmsg->msg, msgbuf_size + sizeof(struct WlanHeader)); |
1785 | 1830 | ||
1786 | newmsg->transmit_cont = cont; | 1831 | newmsg->transmit_cont = cont; |
@@ -1794,7 +1839,7 @@ wlan_plugin_send(void *cls, const struct GNUNET_PeerIdentity * target, | |||
1794 | GNUNET_CONTAINER_DLL_insert_tail(session->pending_message_head, session->pending_message_tail, newmsg); | 1839 | GNUNET_CONTAINER_DLL_insert_tail(session->pending_message_head, session->pending_message_tail, newmsg); |
1795 | 1840 | ||
1796 | #if DEBUG_wlan | 1841 | #if DEBUG_wlan |
1797 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1842 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
1798 | "New message for %p with size (incl wlan header) %u added\n", session, | 1843 | "New message for %p with size (incl wlan header) %u added\n", session, |
1799 | newmsg->message_size); | 1844 | newmsg->message_size); |
1800 | #endif | 1845 | #endif |
@@ -1814,13 +1859,13 @@ wlan_plugin_send(void *cls, const struct GNUNET_PeerIdentity * target, | |||
1814 | * @param endpoin pointer to the MacEndpoint to free | 1859 | * @param endpoin pointer to the MacEndpoint to free |
1815 | */ | 1860 | */ |
1816 | static void | 1861 | static void |
1817 | free_macendpoint(struct Plugin * plugin, struct MacEndpoint * endpoin) | 1862 | free_macendpoint(struct Plugin * plugin, struct MacEndpoint * endpoint) |
1818 | { | 1863 | { |
1819 | struct Sessionqueue * sessions; | 1864 | struct Sessionqueue * sessions; |
1820 | struct Sessionqueue * sessions_next; | 1865 | struct Sessionqueue * sessions_next; |
1821 | GNUNET_assert(endpoin != NULL); | 1866 | GNUNET_assert(endpoint != NULL); |
1822 | 1867 | ||
1823 | sessions = endpoin->sessions_head; | 1868 | sessions = endpoint->sessions_head; |
1824 | while (sessions != NULL) | 1869 | while (sessions != NULL) |
1825 | { | 1870 | { |
1826 | sessions_next = sessions->next; | 1871 | sessions_next = sessions->next; |
@@ -1828,8 +1873,10 @@ free_macendpoint(struct Plugin * plugin, struct MacEndpoint * endpoin) | |||
1828 | sessions = sessions_next; | 1873 | sessions = sessions_next; |
1829 | } | 1874 | } |
1830 | 1875 | ||
1831 | GNUNET_CONTAINER_DLL_remove(plugin->mac_head,plugin->mac_tail,endpoin); | 1876 | GNUNET_CONTAINER_DLL_remove(plugin->mac_head,plugin->mac_tail,endpoint); |
1832 | GNUNET_free(endpoin); | 1877 | if (endpoint->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
1878 | GNUNET_SCHEDULER_cancel(endpoint->timeout_task); | ||
1879 | GNUNET_free(endpoint); | ||
1833 | 1880 | ||
1834 | } | 1881 | } |
1835 | 1882 | ||
@@ -1904,7 +1951,9 @@ free_session(struct Plugin * plugin, struct Sessionqueue * queue, | |||
1904 | { | 1951 | { |
1905 | free_macendpoint(plugin, endpoint); | 1952 | free_macendpoint(plugin, endpoint); |
1906 | } | 1953 | } |
1907 | GNUNET_free(queue->content); | 1954 | |
1955 | if (queue->content->timeout_task != GNUNET_SCHEDULER_NO_TASK) | ||
1956 | GNUNET_SCHEDULER_cancel(queue->content->timeout_task); | ||
1908 | GNUNET_free(queue); | 1957 | GNUNET_free(queue); |
1909 | check_fragment_queue(plugin); | 1958 | check_fragment_queue(plugin); |
1910 | } | 1959 | } |
@@ -2006,8 +2055,7 @@ wlan_data_message_handler(void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2006 | { | 2055 | { |
2007 | 2056 | ||
2008 | #if DEBUG_wlan | 2057 | #if DEBUG_wlan |
2009 | GNUNET_log( | 2058 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2010 | GNUNET_ERROR_TYPE_DEBUG, | ||
2011 | "Func wlan_data_message_handler got GNUNET_MESSAGE_TYPE_WLAN_DATA size: %u\n", | 2059 | "Func wlan_data_message_handler got GNUNET_MESSAGE_TYPE_WLAN_DATA size: %u\n", |
2012 | ntohs(hdr->size)); | 2060 | ntohs(hdr->size)); |
2013 | #endif | 2061 | #endif |
@@ -2030,7 +2078,7 @@ wlan_data_message_handler(void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2030 | if (getcrc32((char *) wlanheader, ntohs(wlanheader->header.size)) != crc) | 2078 | if (getcrc32((char *) wlanheader, ntohs(wlanheader->header.size)) != crc) |
2031 | { | 2079 | { |
2032 | //wrong crc, dispose message | 2080 | //wrong crc, dispose message |
2033 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 2081 | GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, |
2034 | "Wlan message header crc was wrong: %u != %u\n", | 2082 | "Wlan message header crc was wrong: %u != %u\n", |
2035 | getcrc32((char *) wlanheader, ntohs(wlanheader->header.size)), | 2083 | getcrc32((char *) wlanheader, ntohs(wlanheader->header.size)), |
2036 | crc); | 2084 | crc); |
@@ -2042,8 +2090,7 @@ wlan_data_message_handler(void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2042 | if (session == NULL) | 2090 | if (session == NULL) |
2043 | { | 2091 | { |
2044 | #if DEBUG_wlan | 2092 | #if DEBUG_wlan |
2045 | GNUNET_log( | 2093 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2046 | GNUNET_ERROR_TYPE_DEBUG, | ||
2047 | "WLAN client not in session list: packet size = %u, inner size = %u, header size = %u\n", | 2094 | "WLAN client not in session list: packet size = %u, inner size = %u, header size = %u\n", |
2048 | ntohs(wlanheader->header.size), ntohs(temp_hdr->size), | 2095 | ntohs(wlanheader->header.size), ntohs(temp_hdr->size), |
2049 | sizeof(struct WlanHeader)); | 2096 | sizeof(struct WlanHeader)); |
@@ -2062,7 +2109,7 @@ wlan_data_message_handler(void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2062 | } | 2109 | } |
2063 | else | 2110 | else |
2064 | { | 2111 | { |
2065 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 2112 | GNUNET_log_from(GNUNET_ERROR_TYPE_WARNING, PLUGIN_LOG_NAME, |
2066 | "WLAN client not in session list and hello message is not okay\n"); | 2113 | "WLAN client not in session list and hello message is not okay\n"); |
2067 | return; | 2114 | return; |
2068 | } | 2115 | } |
@@ -2070,15 +2117,14 @@ wlan_data_message_handler(void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2070 | } | 2117 | } |
2071 | else | 2118 | else |
2072 | { | 2119 | { |
2073 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 2120 | GNUNET_log_from(GNUNET_ERROR_TYPE_WARNING, PLUGIN_LOG_NAME, |
2074 | "WLAN client not in session list and not a hello message\n"); | 2121 | "WLAN client not in session list and not a hello message\n"); |
2075 | return; | 2122 | return; |
2076 | } | 2123 | } |
2077 | } | 2124 | } |
2078 | else | 2125 | else |
2079 | { | 2126 | { |
2080 | GNUNET_log( | 2127 | GNUNET_log_from(GNUNET_ERROR_TYPE_WARNING, PLUGIN_LOG_NAME, |
2081 | GNUNET_ERROR_TYPE_WARNING, | ||
2082 | "WLAN client not in session list and message size in does not fit\npacket size = %u, inner size = %u, header size = %u\n", | 2128 | "WLAN client not in session list and message size in does not fit\npacket size = %u, inner size = %u, header size = %u\n", |
2083 | ntohs(wlanheader->header.size), ntohs(temp_hdr->size), | 2129 | ntohs(wlanheader->header.size), ntohs(temp_hdr->size), |
2084 | sizeof(struct WlanHeader)); | 2130 | sizeof(struct WlanHeader)); |
@@ -2093,8 +2139,7 @@ wlan_data_message_handler(void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2093 | { | 2139 | { |
2094 | //wrong peer id | 2140 | //wrong peer id |
2095 | #if DEBUG_wlan | 2141 | #if DEBUG_wlan |
2096 | GNUNET_log( | 2142 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2097 | GNUNET_ERROR_TYPE_DEBUG, | ||
2098 | "WLAN peer source id doesn't match packet peer source id: session %p\n", | 2143 | "WLAN peer source id doesn't match packet peer source id: session %p\n", |
2099 | session); | 2144 | session); |
2100 | #endif | 2145 | #endif |
@@ -2106,7 +2151,7 @@ wlan_data_message_handler(void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2106 | { | 2151 | { |
2107 | //wrong peer id | 2152 | //wrong peer id |
2108 | #if DEBUG_wlan | 2153 | #if DEBUG_wlan |
2109 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2154 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2110 | "WLAN peer target id doesn't match our peer id: session %p\n", | 2155 | "WLAN peer target id doesn't match our peer id: session %p\n", |
2111 | session); | 2156 | session); |
2112 | #endif | 2157 | #endif |
@@ -2121,13 +2166,19 @@ wlan_data_message_handler(void *cls, const struct GNUNET_MessageHeader *hdr) | |||
2121 | } | 2166 | } |
2122 | else | 2167 | else |
2123 | { | 2168 | { |
2124 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 2169 | GNUNET_log_from(GNUNET_ERROR_TYPE_WARNING, PLUGIN_LOG_NAME, |
2125 | "wlan_data_message_handler got wrong message type\n"); | 2170 | "wlan_data_message_handler got wrong message type\n"); |
2126 | return; | 2171 | return; |
2127 | } | 2172 | } |
2128 | } | 2173 | } |
2129 | 2174 | ||
2130 | //TODO DOXIGEN | 2175 | /** |
2176 | * function to process the a message, give it to the higher layer | ||
2177 | * @param cls pointer to the plugin | ||
2178 | * @param client pointer to the session this message belongs to | ||
2179 | * @param hdr start of the message | ||
2180 | */ | ||
2181 | //TODO ATS informations | ||
2131 | static void | 2182 | static void |
2132 | process_data(void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | 2183 | process_data(void *cls, void *client, const struct GNUNET_MessageHeader *hdr) |
2133 | { | 2184 | { |
@@ -2144,7 +2195,7 @@ process_data(void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
2144 | distance[1].value = htonl(0); | 2195 | distance[1].value = htonl(0); |
2145 | 2196 | ||
2146 | #if DEBUG_wlan | 2197 | #if DEBUG_wlan |
2147 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2198 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2148 | "Calling plugin->env->receive for session %p; %s; size: %u\n", session, | 2199 | "Calling plugin->env->receive for session %p; %s; size: %u\n", session, |
2149 | wlan_plugin_address_to_string(NULL, session->mac->addr.mac, 6), | 2200 | wlan_plugin_address_to_string(NULL, session->mac->addr.mac, 6), |
2150 | htons(hdr->size)); | 2201 | htons(hdr->size)); |
@@ -2179,8 +2230,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2179 | GNUNET_assert(session_light != NULL); | 2230 | GNUNET_assert(session_light != NULL); |
2180 | 2231 | ||
2181 | #if DEBUG_wlan | 2232 | #if DEBUG_wlan |
2182 | GNUNET_log( | 2233 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2183 | GNUNET_ERROR_TYPE_DEBUG, | ||
2184 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT size: %u; %s\n", | 2234 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT size: %u; %s\n", |
2185 | ntohs(hdr->size), | 2235 | ntohs(hdr->size), |
2186 | wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6)); | 2236 | wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6)); |
@@ -2210,8 +2260,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2210 | } | 2260 | } |
2211 | 2261 | ||
2212 | #if DEBUG_wlan | 2262 | #if DEBUG_wlan |
2213 | GNUNET_log( | 2263 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2214 | GNUNET_ERROR_TYPE_DEBUG, | ||
2215 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT with size: %u; mac endpoint %p: %s\n", | 2264 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT with size: %u; mac endpoint %p: %s\n", |
2216 | ntohs(hdr->size), session_light->macendpoint, | 2265 | ntohs(hdr->size), session_light->macendpoint, |
2217 | wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6)); | 2266 | wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6)); |
@@ -2245,8 +2294,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2245 | if (session_light->macendpoint == NULL) | 2294 | if (session_light->macendpoint == NULL) |
2246 | { | 2295 | { |
2247 | #if DEBUG_wlan | 2296 | #if DEBUG_wlan |
2248 | GNUNET_log( | 2297 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2249 | GNUNET_ERROR_TYPE_DEBUG, | ||
2250 | "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n", | 2298 | "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n", |
2251 | ntohs(hdr->size), | 2299 | ntohs(hdr->size), |
2252 | wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6)); | 2300 | wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6)); |
@@ -2255,8 +2303,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2255 | } | 2303 | } |
2256 | 2304 | ||
2257 | #if DEBUG_wlan | 2305 | #if DEBUG_wlan |
2258 | GNUNET_log( | 2306 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2259 | GNUNET_ERROR_TYPE_DEBUG, | ||
2260 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; mac endpoint: %p; %s\n", | 2307 | "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; mac endpoint: %p; %s\n", |
2261 | ntohs(hdr->size), session_light->macendpoint, | 2308 | ntohs(hdr->size), session_light->macendpoint, |
2262 | wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6)); | 2309 | wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6)); |
@@ -2269,10 +2316,12 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2269 | if (ret == GNUNET_OK) | 2316 | if (ret == GNUNET_OK) |
2270 | { | 2317 | { |
2271 | #if DEBUG_wlan_retransmission | 2318 | #if DEBUG_wlan_retransmission |
2272 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2319 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2273 | "Got last ack, finished fragment message %p\n", fm); | 2320 | "Got last ack, finished fragment message %p\n", fm); |
2274 | #endif | 2321 | #endif |
2275 | session_light->macendpoint->acks++; | 2322 | session_light->macendpoint->acks++; |
2323 | fm->session->last_activity = GNUNET_TIME_absolute_get(); | ||
2324 | session_light->macendpoint->last_activity = fm->session->last_activity; | ||
2276 | free_fragment_message(plugin, fm); | 2325 | free_fragment_message(plugin, fm); |
2277 | check_fragment_queue(plugin); | 2326 | check_fragment_queue(plugin); |
2278 | return; | 2327 | return; |
@@ -2280,7 +2329,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2280 | if (ret == GNUNET_NO) | 2329 | if (ret == GNUNET_NO) |
2281 | { | 2330 | { |
2282 | #if DEBUG_wlan_retransmission | 2331 | #if DEBUG_wlan_retransmission |
2283 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Got ack for: %p\n", fm); | 2332 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "Got ack for: %p\n", fm); |
2284 | #endif | 2333 | #endif |
2285 | session_light->macendpoint->acks++; | 2334 | session_light->macendpoint->acks++; |
2286 | return; | 2335 | return; |
@@ -2294,7 +2343,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2294 | } | 2343 | } |
2295 | 2344 | ||
2296 | #if DEBUG_wlan_retransmission | 2345 | #if DEBUG_wlan_retransmission |
2297 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2346 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2298 | "WLAN fragment not in fragment list\n"); | 2347 | "WLAN fragment not in fragment list\n"); |
2299 | #endif | 2348 | #endif |
2300 | return; | 2349 | return; |
@@ -2303,8 +2352,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2303 | else | 2352 | else |
2304 | { | 2353 | { |
2305 | // TODO Wrong data? | 2354 | // TODO Wrong data? |
2306 | GNUNET_log( | 2355 | GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, |
2307 | GNUNET_ERROR_TYPE_INFO, | ||
2308 | "WLAN packet inside the WLAN helper packet has not the right type: %u size: %u\n", | 2356 | "WLAN packet inside the WLAN helper packet has not the right type: %u size: %u\n", |
2309 | ntohs(hdr->type), ntohs(hdr->size)); | 2357 | ntohs(hdr->type), ntohs(hdr->size)); |
2310 | GNUNET_break(0); | 2358 | GNUNET_break(0); |
@@ -2312,7 +2360,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light, | |||
2312 | } | 2360 | } |
2313 | 2361 | ||
2314 | #if 0 | 2362 | #if 0 |
2315 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2363 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2316 | "Helper finished\n"); | 2364 | "Helper finished\n"); |
2317 | #endif | 2365 | #endif |
2318 | 2366 | ||
@@ -2330,6 +2378,33 @@ macprinter(const u_int8_t * mac) | |||
2330 | } | 2378 | } |
2331 | 2379 | ||
2332 | /** | 2380 | /** |
2381 | * Function for the scheduler if a mac endpoint times out | ||
2382 | * @param cls pointer to the MacEndpoint | ||
2383 | * @param tc pointer to the GNUNET_SCHEDULER_TaskContext | ||
2384 | */ | ||
2385 | static void | ||
2386 | macendpoint_timeout (void *cls, | ||
2387 | const struct GNUNET_SCHEDULER_TaskContext *tc){ | ||
2388 | struct MacEndpoint * endpoint = cls; | ||
2389 | GNUNET_assert(endpoint != NULL); | ||
2390 | endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK; | ||
2391 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN){ | ||
2392 | return; | ||
2393 | } | ||
2394 | if (GNUNET_TIME_absolute_get_remaining( | ||
2395 | GNUNET_TIME_absolute_add(endpoint->last_activity, MACENDPOINT_TIMEOUT)).rel_value | ||
2396 | == 0) | ||
2397 | { | ||
2398 | free_macendpoint(endpoint->plugin,endpoint); | ||
2399 | } | ||
2400 | else | ||
2401 | { | ||
2402 | endpoint->timeout_task = GNUNET_SCHEDULER_add_delayed(MACENDPOINT_TIMEOUT, | ||
2403 | &macendpoint_timeout, endpoint); | ||
2404 | } | ||
2405 | } | ||
2406 | |||
2407 | /** | ||
2333 | * function to create an macendpoint | 2408 | * function to create an macendpoint |
2334 | * @param plugin pointer to the plugin struct | 2409 | * @param plugin pointer to the plugin struct |
2335 | * @param addr pointer to the macaddress | 2410 | * @param addr pointer to the macaddress |
@@ -2346,11 +2421,14 @@ create_macendpoint(struct Plugin *plugin, const struct MacAddress *addr) | |||
2346 | newend->defrag = GNUNET_DEFRAGMENT_context_create(plugin->env->stats, | 2421 | newend->defrag = GNUNET_DEFRAGMENT_context_create(plugin->env->stats, |
2347 | WLAN_MTU, MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, newend, | 2422 | WLAN_MTU, MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, newend, |
2348 | &wlan_data_message_handler, &add_ack_for_send); | 2423 | &wlan_data_message_handler, &add_ack_for_send); |
2424 | newend->last_activity = GNUNET_TIME_absolute_get(); | ||
2425 | newend->timeout_task = GNUNET_SCHEDULER_add_delayed(MACENDPOINT_TIMEOUT, | ||
2426 | &macendpoint_timeout, newend); | ||
2349 | 2427 | ||
2350 | plugin->mac_count++; | 2428 | plugin->mac_count++; |
2351 | GNUNET_CONTAINER_DLL_insert_tail(plugin->mac_head, plugin->mac_tail, newend); | 2429 | GNUNET_CONTAINER_DLL_insert_tail(plugin->mac_head, plugin->mac_tail, newend); |
2352 | #if DEBUG_wlan | 2430 | #if DEBUG_wlan |
2353 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "New Mac Endpoint %p: %s\n", newend, | 2431 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "New Mac Endpoint %p: %s\n", newend, |
2354 | wlan_plugin_address_to_string(NULL, newend->addr.mac, 6)); | 2432 | wlan_plugin_address_to_string(NULL, newend->addr.mac, 6)); |
2355 | #endif | 2433 | #endif |
2356 | return newend; | 2434 | return newend; |
@@ -2380,8 +2458,7 @@ wlan_process_helper(void *cls, void *client, | |||
2380 | { | 2458 | { |
2381 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA: | 2459 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA: |
2382 | #if DEBUG_wlan | 2460 | #if DEBUG_wlan |
2383 | GNUNET_log( | 2461 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2384 | GNUNET_ERROR_TYPE_DEBUG, | ||
2385 | "Func wlan_process_helper got GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA size: %u\n", | 2462 | "Func wlan_process_helper got GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA size: %u\n", |
2386 | ntohs(hdr->size)); | 2463 | ntohs(hdr->size)); |
2387 | #endif | 2464 | #endif |
@@ -2391,8 +2468,7 @@ wlan_process_helper(void *cls, void *client, | |||
2391 | + sizeof(struct GNUNET_MessageHeader) + sizeof(struct Radiotap_rx)) | 2468 | + sizeof(struct GNUNET_MessageHeader) + sizeof(struct Radiotap_rx)) |
2392 | { | 2469 | { |
2393 | #if DEBUG_wlan | 2470 | #if DEBUG_wlan |
2394 | GNUNET_log( | 2471 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2395 | GNUNET_ERROR_TYPE_DEBUG, | ||
2396 | "Size of packet is too small; size: %u min size: %u\n", | 2472 | "Size of packet is too small; size: %u min size: %u\n", |
2397 | ntohs(hdr->size), | 2473 | ntohs(hdr->size), |
2398 | sizeof(struct ieee80211_frame) | 2474 | sizeof(struct ieee80211_frame) |
@@ -2447,7 +2523,7 @@ wlan_process_helper(void *cls, void *client, | |||
2447 | else | 2523 | else |
2448 | { | 2524 | { |
2449 | #if DEBUG_wlan | 2525 | #if DEBUG_wlan |
2450 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2526 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2451 | "Func wlan_process_helper got wrong MAC: %s\n", | 2527 | "Func wlan_process_helper got wrong MAC: %s\n", |
2452 | macprinter(wlanIeeeHeader->i_addr1)); | 2528 | macprinter(wlanIeeeHeader->i_addr1)); |
2453 | #endif | 2529 | #endif |
@@ -2456,7 +2532,7 @@ wlan_process_helper(void *cls, void *client, | |||
2456 | else | 2532 | else |
2457 | { | 2533 | { |
2458 | #if DEBUG_wlan | 2534 | #if DEBUG_wlan |
2459 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2535 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2460 | "Func wlan_process_helper got wrong BSSID: %s\n", | 2536 | "Func wlan_process_helper got wrong BSSID: %s\n", |
2461 | macprinter(wlanIeeeHeader->i_addr2)); | 2537 | macprinter(wlanIeeeHeader->i_addr2)); |
2462 | #endif | 2538 | #endif |
@@ -2473,8 +2549,7 @@ wlan_process_helper(void *cls, void *client, | |||
2473 | } | 2549 | } |
2474 | memcpy(&plugin->mac_address, &hdr[1], sizeof(struct MacAddress)); | 2550 | memcpy(&plugin->mac_address, &hdr[1], sizeof(struct MacAddress)); |
2475 | #if DEBUG_wlan | 2551 | #if DEBUG_wlan |
2476 | GNUNET_log( | 2552 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2477 | GNUNET_ERROR_TYPE_DEBUG, | ||
2478 | "Received WLAN_HELPER_CONTROL message with transport of address %s\n", | 2553 | "Received WLAN_HELPER_CONTROL message with transport of address %s\n", |
2479 | wlan_plugin_address_to_string(cls, &plugin->mac_address, | 2554 | wlan_plugin_address_to_string(cls, &plugin->mac_address, |
2480 | sizeof(struct MacAddress))); | 2555 | sizeof(struct MacAddress))); |
@@ -2514,7 +2589,7 @@ wlan_plugin_helper_read(void *cls, | |||
2514 | if (bytes <= 0) | 2589 | if (bytes <= 0) |
2515 | { | 2590 | { |
2516 | #if DEBUG_wlan | 2591 | #if DEBUG_wlan |
2517 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2592 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2518 | _("Finished reading from wlan-helper stdout with code: %d\n"), | 2593 | _("Finished reading from wlan-helper stdout with code: %d\n"), |
2519 | bytes); | 2594 | bytes); |
2520 | #endif | 2595 | #endif |
@@ -2555,7 +2630,7 @@ wlan_transport_start_wlan_helper(struct Plugin *plugin, int testmode) | |||
2555 | { | 2630 | { |
2556 | 2631 | ||
2557 | #if DEBUG_wlan | 2632 | #if DEBUG_wlan |
2558 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2633 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2559 | "Starting gnunet-wlan-helper process cmd: %s %s %i\n", filenamehw, | 2634 | "Starting gnunet-wlan-helper process cmd: %s %s %i\n", filenamehw, |
2560 | plugin->interface, testmode); | 2635 | plugin->interface, testmode); |
2561 | #endif | 2636 | #endif |
@@ -2568,7 +2643,7 @@ wlan_transport_start_wlan_helper(struct Plugin *plugin, int testmode) | |||
2568 | { | 2643 | { |
2569 | 2644 | ||
2570 | #if DEBUG_wlan | 2645 | #if DEBUG_wlan |
2571 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2646 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2572 | "Starting gnunet-wlan-helper loopback 1 process cmd: %s %s %i\n", | 2647 | "Starting gnunet-wlan-helper loopback 1 process cmd: %s %s %i\n", |
2573 | filenameloopback, plugin->interface, testmode); | 2648 | filenameloopback, plugin->interface, testmode); |
2574 | #endif | 2649 | #endif |
@@ -2579,7 +2654,7 @@ wlan_transport_start_wlan_helper(struct Plugin *plugin, int testmode) | |||
2579 | else if (testmode == 2) | 2654 | else if (testmode == 2) |
2580 | { | 2655 | { |
2581 | #if DEBUG_wlan | 2656 | #if DEBUG_wlan |
2582 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2657 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2583 | "Starting gnunet-wlan-helper loopback 2 process cmd: %s %s %i\n", | 2658 | "Starting gnunet-wlan-helper loopback 2 process cmd: %s %s %i\n", |
2584 | filenameloopback, plugin->interface, testmode); | 2659 | filenameloopback, plugin->interface, testmode); |
2585 | #endif | 2660 | #endif |
@@ -2589,7 +2664,7 @@ wlan_transport_start_wlan_helper(struct Plugin *plugin, int testmode) | |||
2589 | if (plugin->server_proc == NULL) | 2664 | if (plugin->server_proc == NULL) |
2590 | { | 2665 | { |
2591 | #if DEBUG_wlan | 2666 | #if DEBUG_wlan |
2592 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2667 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2593 | "Failed to start gnunet-wlan-helper process\n"); | 2668 | "Failed to start gnunet-wlan-helper process\n"); |
2594 | #endif | 2669 | #endif |
2595 | return GNUNET_SYSERR; | 2670 | return GNUNET_SYSERR; |
@@ -2609,7 +2684,7 @@ wlan_transport_start_wlan_helper(struct Plugin *plugin, int testmode) | |||
2609 | GNUNET_assert(plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK); | 2684 | GNUNET_assert(plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK); |
2610 | 2685 | ||
2611 | #if DEBUG_wlan | 2686 | #if DEBUG_wlan |
2612 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2687 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2613 | "Adding server_read_task for the wlan-helper\n"); | 2688 | "Adding server_read_task for the wlan-helper\n"); |
2614 | #endif | 2689 | #endif |
2615 | 2690 | ||
@@ -2635,7 +2710,7 @@ libgnunet_plugin_transport_wlan_done(void *cls) | |||
2635 | struct MacEndpoint * endpoint_next; | 2710 | struct MacEndpoint * endpoint_next; |
2636 | 2711 | ||
2637 | #if DEBUG_wlan | 2712 | #if DEBUG_wlan |
2638 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2713 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, |
2639 | "libgnunet_plugin_transport_wlan_done started\n"); | 2714 | "libgnunet_plugin_transport_wlan_done started\n"); |
2640 | #endif | 2715 | #endif |
2641 | 2716 | ||
@@ -2748,7 +2823,7 @@ libgnunet_plugin_transport_wlan_init(void *cls) | |||
2748 | wlan_transport_start_wlan_helper(plugin, testmode); | 2823 | wlan_transport_start_wlan_helper(plugin, testmode); |
2749 | 2824 | ||
2750 | #if DEBUG_wlan | 2825 | #if DEBUG_wlan |
2751 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "wlan init finished\n"); | 2826 | GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "wlan init finished\n"); |
2752 | #endif | 2827 | #endif |
2753 | 2828 | ||
2754 | return api; | 2829 | return api; |