diff options
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 2091 |
1 files changed, 1041 insertions, 1050 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index e1a93bf88..a6d44ecb5 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2010-2014 GNUnet e.V. | 3 | Copyright (C) 2010-2014 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file transport/plugin_transport_wlan.c | 22 | * @file transport/plugin_transport_wlan.c |
@@ -47,20 +47,20 @@ | |||
47 | #define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy" | 47 | #define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy" |
48 | #define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_wlan_init | 48 | #define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_wlan_init |
49 | #define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_wlan_done | 49 | #define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_wlan_done |
50 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-wlan",__VA_ARGS__) | 50 | #define LOG(kind, ...) GNUNET_log_from(kind, "transport-wlan", __VA_ARGS__) |
51 | 51 | ||
52 | 52 | ||
53 | /** | 53 | /** |
54 | * time out of a mac endpoint | 54 | * time out of a mac endpoint |
55 | */ | 55 | */ |
56 | #define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2) | 56 | #define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2) |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * We reduce the frequence of HELLO beacons in relation to | 59 | * We reduce the frequence of HELLO beacons in relation to |
60 | * the number of MAC addresses currently visible to us. | 60 | * the number of MAC addresses currently visible to us. |
61 | * This is the multiplication factor. | 61 | * This is the multiplication factor. |
62 | */ | 62 | */ |
63 | #define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2) | 63 | #define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2) |
64 | 64 | ||
65 | 65 | ||
66 | /* end case wlan */ | 66 | /* end case wlan */ |
@@ -74,12 +74,12 @@ | |||
74 | #define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy" | 74 | #define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy" |
75 | #define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_bluetooth_init | 75 | #define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_bluetooth_init |
76 | #define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_bluetooth_done | 76 | #define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_bluetooth_done |
77 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-bluetooth",__VA_ARGS__) | 77 | #define LOG(kind, ...) GNUNET_log_from(kind, "transport-bluetooth", __VA_ARGS__) |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * time out of a mac endpoint | 80 | * time out of a mac endpoint |
81 | */ | 81 | */ |
82 | #define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 60) | 82 | #define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 60) |
83 | 83 | ||
84 | 84 | ||
85 | /** | 85 | /** |
@@ -87,7 +87,7 @@ | |||
87 | * the number of MAC addresses currently visible to us. | 87 | * the number of MAC addresses currently visible to us. |
88 | * This is the multiplication factor. | 88 | * This is the multiplication factor. |
89 | */ | 89 | */ |
90 | #define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | 90 | #define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) |
91 | 91 | ||
92 | /* end case bluetooth */ | 92 | /* end case bluetooth */ |
93 | #else | 93 | #else |
@@ -154,9 +154,7 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
154 | * the CRC and then tokenize the payload and pass it to the | 154 | * the CRC and then tokenize the payload and pass it to the |
155 | * 'receive' callback. | 155 | * 'receive' callback. |
156 | */ | 156 | */ |
157 | struct WlanHeader | 157 | struct WlanHeader { |
158 | { | ||
159 | |||
160 | /** | 158 | /** |
161 | * Message type is #GNUNET_MESSAGE_TYPE_WLAN_DATA. | 159 | * Message type is #GNUNET_MESSAGE_TYPE_WLAN_DATA. |
162 | */ | 160 | */ |
@@ -179,15 +177,13 @@ struct WlanHeader | |||
179 | 177 | ||
180 | /* followed by payload, possibly including | 178 | /* followed by payload, possibly including |
181 | multiple messages! */ | 179 | multiple messages! */ |
182 | |||
183 | }; | 180 | }; |
184 | 181 | ||
185 | 182 | ||
186 | /** | 183 | /** |
187 | * Address format for WLAN. | 184 | * Address format for WLAN. |
188 | */ | 185 | */ |
189 | struct WlanAddress | 186 | struct WlanAddress { |
190 | { | ||
191 | /** | 187 | /** |
192 | * Options set for the WLAN, in NBO. | 188 | * Options set for the WLAN, in NBO. |
193 | */ | 189 | */ |
@@ -207,8 +203,7 @@ GNUNET_NETWORK_STRUCT_END | |||
207 | * Information kept for each message that is yet to be fragmented and | 203 | * Information kept for each message that is yet to be fragmented and |
208 | * transmitted. | 204 | * transmitted. |
209 | */ | 205 | */ |
210 | struct PendingMessage | 206 | struct PendingMessage { |
211 | { | ||
212 | /** | 207 | /** |
213 | * next entry in the DLL | 208 | * next entry in the DLL |
214 | */ | 209 | */ |
@@ -240,15 +235,13 @@ struct PendingMessage | |||
240 | * Timeout task (for this message). | 235 | * Timeout task (for this message). |
241 | */ | 236 | */ |
242 | struct GNUNET_SCHEDULER_Task * timeout_task; | 237 | struct GNUNET_SCHEDULER_Task * timeout_task; |
243 | |||
244 | }; | 238 | }; |
245 | 239 | ||
246 | 240 | ||
247 | /** | 241 | /** |
248 | * Session handle for connections with other peers. | 242 | * Session handle for connections with other peers. |
249 | */ | 243 | */ |
250 | struct GNUNET_ATS_Session | 244 | struct GNUNET_ATS_Session { |
251 | { | ||
252 | /** | 245 | /** |
253 | * To whom are we talking to (set to our identity | 246 | * To whom are we talking to (set to our identity |
254 | * if we are still waiting for the welcome message) | 247 | * if we are still waiting for the welcome message) |
@@ -286,16 +279,13 @@ struct GNUNET_ATS_Session | |||
286 | * Timeout task (for the session). | 279 | * Timeout task (for the session). |
287 | */ | 280 | */ |
288 | struct GNUNET_SCHEDULER_Task * timeout_task; | 281 | struct GNUNET_SCHEDULER_Task * timeout_task; |
289 | |||
290 | }; | 282 | }; |
291 | 283 | ||
292 | 284 | ||
293 | /** | 285 | /** |
294 | * Struct for messages that are being fragmented in a MAC's transmission queue. | 286 | * Struct for messages that are being fragmented in a MAC's transmission queue. |
295 | */ | 287 | */ |
296 | struct FragmentMessage | 288 | struct FragmentMessage { |
297 | { | ||
298 | |||
299 | /** | 289 | /** |
300 | * This is a doubly-linked list. | 290 | * This is a doubly-linked list. |
301 | */ | 291 | */ |
@@ -362,16 +352,13 @@ struct FragmentMessage | |||
362 | * Number of bytes used to transmit message | 352 | * Number of bytes used to transmit message |
363 | */ | 353 | */ |
364 | size_t size_on_wire; | 354 | size_t size_on_wire; |
365 | |||
366 | }; | 355 | }; |
367 | 356 | ||
368 | 357 | ||
369 | /** | 358 | /** |
370 | * Struct to represent one network card connection | 359 | * Struct to represent one network card connection |
371 | */ | 360 | */ |
372 | struct MacEndpoint | 361 | struct MacEndpoint { |
373 | { | ||
374 | |||
375 | /** | 362 | /** |
376 | * We keep all MACs in a DLL in the plugin. | 363 | * We keep all MACs in a DLL in the plugin. |
377 | */ | 364 | */ |
@@ -456,15 +443,13 @@ struct MacEndpoint | |||
456 | * Antenna we should use for this MAC | 443 | * Antenna we should use for this MAC |
457 | */ | 444 | */ |
458 | uint8_t antenna; | 445 | uint8_t antenna; |
459 | |||
460 | }; | 446 | }; |
461 | 447 | ||
462 | 448 | ||
463 | /** | 449 | /** |
464 | * Encapsulation of all of the state of the plugin. | 450 | * Encapsulation of all of the state of the plugin. |
465 | */ | 451 | */ |
466 | struct Plugin | 452 | struct Plugin { |
467 | { | ||
468 | /** | 453 | /** |
469 | * Our environment. | 454 | * Our environment. |
470 | */ | 455 | */ |
@@ -551,7 +536,6 @@ struct Plugin | |||
551 | * Options for addresses | 536 | * Options for addresses |
552 | */ | 537 | */ |
553 | uint32_t options; | 538 | uint32_t options; |
554 | |||
555 | }; | 539 | }; |
556 | 540 | ||
557 | 541 | ||
@@ -560,8 +544,7 @@ struct Plugin | |||
560 | * the session or the MAC endpoint associated with the | 544 | * the session or the MAC endpoint associated with the |
561 | * message (or both). | 545 | * message (or both). |
562 | */ | 546 | */ |
563 | struct MacAndSession | 547 | struct MacAndSession { |
564 | { | ||
565 | /** | 548 | /** |
566 | * NULL if the identity of the other peer is not known. | 549 | * NULL if the identity of the other peer is not known. |
567 | */ | 550 | */ |
@@ -583,16 +566,16 @@ struct MacAndSession | |||
583 | * this function | 566 | * this function |
584 | */ | 567 | */ |
585 | static const char * | 568 | static const char * |
586 | mac_to_string (const struct GNUNET_TRANSPORT_WLAN_MacAddress * mac) | 569 | mac_to_string(const struct GNUNET_TRANSPORT_WLAN_MacAddress * mac) |
587 | { | 570 | { |
588 | static char macstr[20]; | 571 | static char macstr[20]; |
589 | 572 | ||
590 | GNUNET_snprintf (macstr, | 573 | GNUNET_snprintf(macstr, |
591 | sizeof (macstr), | 574 | sizeof(macstr), |
592 | "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 575 | "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
593 | mac->mac[0], mac->mac[1], | 576 | mac->mac[0], mac->mac[1], |
594 | mac->mac[2], mac->mac[3], | 577 | mac->mac[2], mac->mac[3], |
595 | mac->mac[4], mac->mac[5]); | 578 | mac->mac[4], mac->mac[5]); |
596 | return macstr; | 579 | return macstr; |
597 | } | 580 | } |
598 | 581 | ||
@@ -609,25 +592,25 @@ mac_to_string (const struct GNUNET_TRANSPORT_WLAN_MacAddress * mac) | |||
609 | * @return string representing the same address | 592 | * @return string representing the same address |
610 | */ | 593 | */ |
611 | static const char * | 594 | static const char * |
612 | wlan_plugin_address_to_string (void *cls, | 595 | wlan_plugin_address_to_string(void *cls, |
613 | const void *addr, | 596 | const void *addr, |
614 | size_t addrlen) | 597 | size_t addrlen) |
615 | { | 598 | { |
616 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac; | 599 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac; |
617 | static char macstr[36]; | 600 | static char macstr[36]; |
618 | 601 | ||
619 | if (sizeof (struct WlanAddress) != addrlen) | 602 | if (sizeof(struct WlanAddress) != addrlen) |
620 | { | 603 | { |
621 | GNUNET_break (0); | 604 | GNUNET_break(0); |
622 | return NULL; | 605 | return NULL; |
623 | } | 606 | } |
624 | mac = &((struct WlanAddress *) addr)->mac; | 607 | mac = &((struct WlanAddress *)addr)->mac; |
625 | GNUNET_snprintf (macstr, | 608 | GNUNET_snprintf(macstr, |
626 | sizeof (macstr), | 609 | sizeof(macstr), |
627 | "%s.%u.%s", | 610 | "%s.%u.%s", |
628 | PLUGIN_NAME, | 611 | PLUGIN_NAME, |
629 | ntohl (((struct WlanAddress *) addr)->options), | 612 | ntohl(((struct WlanAddress *)addr)->options), |
630 | mac_to_string (mac)); | 613 | mac_to_string(mac)); |
631 | return macstr; | 614 | return macstr; |
632 | } | 615 | } |
633 | 616 | ||
@@ -641,15 +624,15 @@ wlan_plugin_address_to_string (void *cls, | |||
641 | * @param state new state of the session | 624 | * @param state new state of the session |
642 | */ | 625 | */ |
643 | static void | 626 | static void |
644 | notify_session_monitor (struct Plugin *plugin, | 627 | notify_session_monitor(struct Plugin *plugin, |
645 | struct GNUNET_ATS_Session *session, | 628 | struct GNUNET_ATS_Session *session, |
646 | enum GNUNET_TRANSPORT_SessionState state) | 629 | enum GNUNET_TRANSPORT_SessionState state) |
647 | { | 630 | { |
648 | struct GNUNET_TRANSPORT_SessionInfo info; | 631 | struct GNUNET_TRANSPORT_SessionInfo info; |
649 | 632 | ||
650 | if (NULL == plugin->sic) | 633 | if (NULL == plugin->sic) |
651 | return; | 634 | return; |
652 | memset (&info, 0, sizeof (info)); | 635 | memset(&info, 0, sizeof(info)); |
653 | info.state = state; | 636 | info.state = state; |
654 | info.is_inbound = GNUNET_SYSERR; /* hard to say */ | 637 | info.is_inbound = GNUNET_SYSERR; /* hard to say */ |
655 | info.num_msg_pending = 0; /* we queue per MAC, not per peer */ | 638 | info.num_msg_pending = 0; /* we queue per MAC, not per peer */ |
@@ -657,9 +640,9 @@ notify_session_monitor (struct Plugin *plugin, | |||
657 | info.receive_delay = GNUNET_TIME_UNIT_ZERO_ABS; /* not supported by WLAN */ | 640 | info.receive_delay = GNUNET_TIME_UNIT_ZERO_ABS; /* not supported by WLAN */ |
658 | info.session_timeout = session->timeout; | 641 | info.session_timeout = session->timeout; |
659 | info.address = session->address; | 642 | info.address = session->address; |
660 | plugin->sic (plugin->sic_cls, | 643 | plugin->sic(plugin->sic_cls, |
661 | session, | 644 | session, |
662 | &info); | 645 | &info); |
663 | } | 646 | } |
664 | 647 | ||
665 | 648 | ||
@@ -671,24 +654,24 @@ notify_session_monitor (struct Plugin *plugin, | |||
671 | * @param size total message size | 654 | * @param size total message size |
672 | */ | 655 | */ |
673 | static void | 656 | static void |
674 | get_radiotap_header (struct MacEndpoint *endpoint, | 657 | get_radiotap_header(struct MacEndpoint *endpoint, |
675 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header, | 658 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header, |
676 | uint16_t size) | 659 | uint16_t size) |
677 | { | 660 | { |
678 | header->header.type = ntohs (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER); | 661 | header->header.type = ntohs(GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER); |
679 | header->header.size = ntohs (size); | 662 | header->header.size = ntohs(size); |
680 | if (NULL != endpoint) | 663 | if (NULL != endpoint) |
681 | { | 664 | { |
682 | header->rate = endpoint->rate; | 665 | header->rate = endpoint->rate; |
683 | header->tx_power = endpoint->tx_power; | 666 | header->tx_power = endpoint->tx_power; |
684 | header->antenna = endpoint->antenna; | 667 | header->antenna = endpoint->antenna; |
685 | } | 668 | } |
686 | else | 669 | else |
687 | { | 670 | { |
688 | header->rate = 255; | 671 | header->rate = 255; |
689 | header->tx_power = 0; | 672 | header->tx_power = 0; |
690 | header->antenna = 0; | 673 | header->antenna = 0; |
691 | } | 674 | } |
692 | } | 675 | } |
693 | 676 | ||
694 | 677 | ||
@@ -701,18 +684,18 @@ get_radiotap_header (struct MacEndpoint *endpoint, | |||
701 | * @param size size of the whole packet, needed to calculate the time to send the packet | 684 | * @param size size of the whole packet, needed to calculate the time to send the packet |
702 | */ | 685 | */ |
703 | static void | 686 | static void |
704 | get_wlan_header (struct Plugin *plugin, | 687 | get_wlan_header(struct Plugin *plugin, |
705 | struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header, | 688 | struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header, |
706 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, | 689 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, |
707 | unsigned int size) | 690 | unsigned int size) |
708 | { | 691 | { |
709 | const int rate = 11000000; | 692 | const int rate = 11000000; |
710 | 693 | ||
711 | header->frame_control = htons (IEEE80211_FC0_TYPE_DATA); | 694 | header->frame_control = htons(IEEE80211_FC0_TYPE_DATA); |
712 | header->addr1 = *to_mac_addr; | 695 | header->addr1 = *to_mac_addr; |
713 | header->addr2 = plugin->mac_address; | 696 | header->addr2 = plugin->mac_address; |
714 | header->addr3 = mac_bssid_gnunet; | 697 | header->addr3 = mac_bssid_gnunet; |
715 | header->duration = GNUNET_htole16 ((size * 1000000) / rate + 290); | 698 | header->duration = GNUNET_htole16((size * 1000000) / rate + 290); |
716 | header->sequence_control = 0; // FIXME? | 699 | header->sequence_control = 0; // FIXME? |
717 | header->llc[0] = WLAN_LLC_DSAP_FIELD; | 700 | header->llc[0] = WLAN_LLC_DSAP_FIELD; |
718 | header->llc[1] = WLAN_LLC_SSAP_FIELD; | 701 | header->llc[1] = WLAN_LLC_SSAP_FIELD; |
@@ -729,44 +712,44 @@ get_wlan_header (struct Plugin *plugin, | |||
729 | * @param hdr pointer to the hdr where the ack is stored | 712 | * @param hdr pointer to the hdr where the ack is stored |
730 | */ | 713 | */ |
731 | static void | 714 | static void |
732 | send_ack (void *cls, | 715 | send_ack(void *cls, |
733 | uint32_t msg_id, | 716 | uint32_t msg_id, |
734 | const struct GNUNET_MessageHeader *hdr) | 717 | const struct GNUNET_MessageHeader *hdr) |
735 | { | 718 | { |
736 | struct MacEndpoint *endpoint = cls; | 719 | struct MacEndpoint *endpoint = cls; |
737 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage* radio_header; | 720 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage* radio_header; |
738 | uint16_t msize = ntohs (hdr->size); | 721 | uint16_t msize = ntohs(hdr->size); |
739 | size_t size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize; | 722 | size_t size = sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize; |
740 | char buf[size]; | 723 | char buf[size]; |
741 | 724 | ||
742 | if (NULL == endpoint) | 725 | if (NULL == endpoint) |
743 | { | 726 | { |
744 | GNUNET_break (0); | 727 | GNUNET_break(0); |
745 | return; | 728 | return; |
746 | } | 729 | } |
747 | if (size >= GNUNET_MAX_MESSAGE_SIZE) | 730 | if (size >= GNUNET_MAX_MESSAGE_SIZE) |
748 | { | 731 | { |
749 | GNUNET_break (0); | 732 | GNUNET_break(0); |
750 | return; | 733 | return; |
751 | } | 734 | } |
752 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 735 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
753 | "Sending ACK to %s\n", | 736 | "Sending ACK to %s\n", |
754 | mac_to_string (&endpoint->wlan_addr.mac)); | 737 | mac_to_string(&endpoint->wlan_addr.mac)); |
755 | radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; | 738 | radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *)buf; |
756 | get_radiotap_header (endpoint, radio_header, size); | 739 | get_radiotap_header(endpoint, radio_header, size); |
757 | get_wlan_header (endpoint->plugin, | 740 | get_wlan_header(endpoint->plugin, |
758 | &radio_header->frame, | 741 | &radio_header->frame, |
759 | &endpoint->wlan_addr.mac, | 742 | &endpoint->wlan_addr.mac, |
760 | sizeof (endpoint->wlan_addr.mac)); | 743 | sizeof(endpoint->wlan_addr.mac)); |
761 | GNUNET_memcpy (&radio_header[1], hdr, msize); | 744 | GNUNET_memcpy(&radio_header[1], hdr, msize); |
762 | if (NULL != | 745 | if (NULL != |
763 | GNUNET_HELPER_send (endpoint->plugin->suid_helper, | 746 | GNUNET_HELPER_send(endpoint->plugin->suid_helper, |
764 | &radio_header->header, | 747 | &radio_header->header, |
765 | GNUNET_NO /* dropping ACKs is bad */, | 748 | GNUNET_NO /* dropping ACKs is bad */, |
766 | NULL, NULL)) | 749 | NULL, NULL)) |
767 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, | 750 | GNUNET_STATISTICS_update(endpoint->plugin->env->stats, |
768 | _("# ACKs sent"), | 751 | _("# ACKs sent"), |
769 | 1, GNUNET_NO); | 752 | 1, GNUNET_NO); |
770 | } | 753 | } |
771 | 754 | ||
772 | 755 | ||
@@ -777,24 +760,24 @@ send_ack (void *cls, | |||
777 | * @param hdr pointer to the data | 760 | * @param hdr pointer to the data |
778 | */ | 761 | */ |
779 | static void | 762 | static void |
780 | wlan_data_message_handler (void *cls, | 763 | wlan_data_message_handler(void *cls, |
781 | const struct GNUNET_MessageHeader *hdr) | 764 | const struct GNUNET_MessageHeader *hdr) |
782 | { | 765 | { |
783 | struct MacEndpoint *endpoint = cls; | 766 | struct MacEndpoint *endpoint = cls; |
784 | struct Plugin *plugin = endpoint->plugin; | 767 | struct Plugin *plugin = endpoint->plugin; |
785 | struct MacAndSession mas; | 768 | struct MacAndSession mas; |
786 | 769 | ||
787 | GNUNET_STATISTICS_update (plugin->env->stats, | 770 | GNUNET_STATISTICS_update(plugin->env->stats, |
788 | _("# Messages defragmented"), | 771 | _("# Messages defragmented"), |
789 | 1, | 772 | 1, |
790 | GNUNET_NO); | 773 | GNUNET_NO); |
791 | mas.session = NULL; | 774 | mas.session = NULL; |
792 | mas.endpoint = endpoint; | 775 | mas.endpoint = endpoint; |
793 | (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer, | 776 | (void)GNUNET_SERVER_mst_receive(plugin->fragment_data_tokenizer, |
794 | &mas, | 777 | &mas, |
795 | (const char *) hdr, | 778 | (const char *)hdr, |
796 | ntohs (hdr->size), | 779 | ntohs(hdr->size), |
797 | GNUNET_YES, GNUNET_NO); | 780 | GNUNET_YES, GNUNET_NO); |
798 | } | 781 | } |
799 | 782 | ||
800 | 783 | ||
@@ -805,32 +788,32 @@ wlan_data_message_handler (void *cls, | |||
805 | * @param session the session free | 788 | * @param session the session free |
806 | */ | 789 | */ |
807 | static int | 790 | static int |
808 | wlan_plugin_disconnect_session (void *cls, | 791 | wlan_plugin_disconnect_session(void *cls, |
809 | struct GNUNET_ATS_Session *session) | 792 | struct GNUNET_ATS_Session *session) |
810 | { | 793 | { |
811 | struct MacEndpoint *endpoint = session->mac; | 794 | struct MacEndpoint *endpoint = session->mac; |
812 | struct Plugin *plugin = endpoint->plugin; | 795 | struct Plugin *plugin = endpoint->plugin; |
813 | 796 | ||
814 | plugin->env->session_end (plugin->env->cls, | 797 | plugin->env->session_end(plugin->env->cls, |
815 | session->address, | 798 | session->address, |
816 | session); | 799 | session); |
817 | notify_session_monitor (plugin, | 800 | notify_session_monitor(plugin, |
818 | session, | 801 | session, |
819 | GNUNET_TRANSPORT_SS_DONE); | 802 | GNUNET_TRANSPORT_SS_DONE); |
820 | GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, | 803 | GNUNET_CONTAINER_DLL_remove(endpoint->sessions_head, |
821 | endpoint->sessions_tail, | 804 | endpoint->sessions_tail, |
822 | session); | 805 | session); |
823 | if (session->timeout_task != NULL) | 806 | if (session->timeout_task != NULL) |
824 | { | 807 | { |
825 | GNUNET_SCHEDULER_cancel (session->timeout_task); | 808 | GNUNET_SCHEDULER_cancel(session->timeout_task); |
826 | session->timeout_task = NULL; | 809 | session->timeout_task = NULL; |
827 | } | 810 | } |
828 | GNUNET_STATISTICS_update (plugin->env->stats, | 811 | GNUNET_STATISTICS_update(plugin->env->stats, |
829 | _("# Sessions allocated"), | 812 | _("# Sessions allocated"), |
830 | -1, | 813 | -1, |
831 | GNUNET_NO); | 814 | GNUNET_NO); |
832 | GNUNET_HELLO_address_free (session->address); | 815 | GNUNET_HELLO_address_free(session->address); |
833 | GNUNET_free (session); | 816 | GNUNET_free(session); |
834 | return GNUNET_OK; | 817 | return GNUNET_OK; |
835 | } | 818 | } |
836 | 819 | ||
@@ -844,7 +827,7 @@ wlan_plugin_disconnect_session (void *cls, | |||
844 | * @return keepalive factor | 827 | * @return keepalive factor |
845 | */ | 828 | */ |
846 | static unsigned int | 829 | static unsigned int |
847 | wlan_plugin_query_keepalive_factor (void *cls) | 830 | wlan_plugin_query_keepalive_factor(void *cls) |
848 | { | 831 | { |
849 | return 3; | 832 | return 3; |
850 | } | 833 | } |
@@ -856,23 +839,23 @@ wlan_plugin_query_keepalive_factor (void *cls) | |||
856 | * @param cls pointer to the Session | 839 | * @param cls pointer to the Session |
857 | */ | 840 | */ |
858 | static void | 841 | static void |
859 | session_timeout (void *cls) | 842 | session_timeout(void *cls) |
860 | { | 843 | { |
861 | struct GNUNET_ATS_Session *session = cls; | 844 | struct GNUNET_ATS_Session *session = cls; |
862 | struct GNUNET_TIME_Relative left; | 845 | struct GNUNET_TIME_Relative left; |
863 | 846 | ||
864 | session->timeout_task = NULL; | 847 | session->timeout_task = NULL; |
865 | left = GNUNET_TIME_absolute_get_remaining (session->timeout); | 848 | left = GNUNET_TIME_absolute_get_remaining(session->timeout); |
866 | if (0 != left.rel_value_us) | 849 | if (0 != left.rel_value_us) |
867 | { | 850 | { |
868 | session->timeout_task = | 851 | session->timeout_task = |
869 | GNUNET_SCHEDULER_add_delayed (left, | 852 | GNUNET_SCHEDULER_add_delayed(left, |
870 | &session_timeout, | 853 | &session_timeout, |
871 | session); | 854 | session); |
872 | return; | 855 | return; |
873 | } | 856 | } |
874 | wlan_plugin_disconnect_session (session->mac->plugin, | 857 | wlan_plugin_disconnect_session(session->mac->plugin, |
875 | session); | 858 | session); |
876 | } | 859 | } |
877 | 860 | ||
878 | 861 | ||
@@ -885,13 +868,13 @@ session_timeout (void *cls) | |||
885 | * @return returns the session or NULL | 868 | * @return returns the session or NULL |
886 | */ | 869 | */ |
887 | static struct GNUNET_ATS_Session * | 870 | static struct GNUNET_ATS_Session * |
888 | lookup_session (struct MacEndpoint *endpoint, | 871 | lookup_session(struct MacEndpoint *endpoint, |
889 | const struct GNUNET_PeerIdentity *peer) | 872 | const struct GNUNET_PeerIdentity *peer) |
890 | { | 873 | { |
891 | struct GNUNET_ATS_Session *session; | 874 | struct GNUNET_ATS_Session *session; |
892 | 875 | ||
893 | for (session = endpoint->sessions_head; NULL != session; session = session->next) | 876 | for (session = endpoint->sessions_head; NULL != session; session = session->next) |
894 | if (0 == memcmp (peer, &session->target, sizeof (struct GNUNET_PeerIdentity))) | 877 | if (0 == memcmp(peer, &session->target, sizeof(struct GNUNET_PeerIdentity))) |
895 | return session; | 878 | return session; |
896 | return NULL; | 879 | return NULL; |
897 | } | 880 | } |
@@ -905,41 +888,41 @@ lookup_session (struct MacEndpoint *endpoint, | |||
905 | * @return returns the session or NULL | 888 | * @return returns the session or NULL |
906 | */ | 889 | */ |
907 | static struct GNUNET_ATS_Session * | 890 | static struct GNUNET_ATS_Session * |
908 | create_session (struct MacEndpoint *endpoint, | 891 | create_session(struct MacEndpoint *endpoint, |
909 | const struct GNUNET_PeerIdentity *peer) | 892 | const struct GNUNET_PeerIdentity *peer) |
910 | { | 893 | { |
911 | struct GNUNET_ATS_Session *session; | 894 | struct GNUNET_ATS_Session *session; |
912 | 895 | ||
913 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, | 896 | GNUNET_STATISTICS_update(endpoint->plugin->env->stats, |
914 | _("# Sessions allocated"), | 897 | _("# Sessions allocated"), |
915 | 1, | 898 | 1, |
916 | GNUNET_NO); | 899 | GNUNET_NO); |
917 | session = GNUNET_new (struct GNUNET_ATS_Session); | 900 | session = GNUNET_new(struct GNUNET_ATS_Session); |
918 | GNUNET_CONTAINER_DLL_insert_tail (endpoint->sessions_head, | 901 | GNUNET_CONTAINER_DLL_insert_tail(endpoint->sessions_head, |
919 | endpoint->sessions_tail, | 902 | endpoint->sessions_tail, |
920 | session); | 903 | session); |
921 | session->address = GNUNET_HELLO_address_allocate (peer, | 904 | session->address = GNUNET_HELLO_address_allocate(peer, |
922 | PLUGIN_NAME, | 905 | PLUGIN_NAME, |
923 | &endpoint->wlan_addr, | 906 | &endpoint->wlan_addr, |
924 | sizeof (endpoint->wlan_addr), | 907 | sizeof(endpoint->wlan_addr), |
925 | GNUNET_HELLO_ADDRESS_INFO_NONE); | 908 | GNUNET_HELLO_ADDRESS_INFO_NONE); |
926 | session->mac = endpoint; | 909 | session->mac = endpoint; |
927 | session->target = *peer; | 910 | session->target = *peer; |
928 | session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 911 | session->timeout = GNUNET_TIME_relative_to_absolute(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
929 | session->timeout_task = | 912 | session->timeout_task = |
930 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, | 913 | GNUNET_SCHEDULER_add_delayed(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, |
931 | session); | 914 | session); |
932 | notify_session_monitor (endpoint->plugin, | 915 | notify_session_monitor(endpoint->plugin, |
933 | session, | 916 | session, |
934 | GNUNET_TRANSPORT_SS_INIT); | 917 | GNUNET_TRANSPORT_SS_INIT); |
935 | notify_session_monitor (endpoint->plugin, | 918 | notify_session_monitor(endpoint->plugin, |
936 | session, | 919 | session, |
937 | GNUNET_TRANSPORT_SS_UP); | 920 | GNUNET_TRANSPORT_SS_UP); |
938 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 921 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
939 | "Created new session %p for peer `%s' with endpoint %s\n", | 922 | "Created new session %p for peer `%s' with endpoint %s\n", |
940 | session, | 923 | session, |
941 | GNUNET_i2s (peer), | 924 | GNUNET_i2s(peer), |
942 | mac_to_string (&endpoint->wlan_addr.mac)); | 925 | mac_to_string(&endpoint->wlan_addr.mac)); |
943 | 926 | ||
944 | return session; | 927 | return session; |
945 | } | 928 | } |
@@ -953,14 +936,14 @@ create_session (struct MacEndpoint *endpoint, | |||
953 | * @return returns the session | 936 | * @return returns the session |
954 | */ | 937 | */ |
955 | static struct GNUNET_ATS_Session * | 938 | static struct GNUNET_ATS_Session * |
956 | get_session (struct MacEndpoint *endpoint, | 939 | get_session(struct MacEndpoint *endpoint, |
957 | const struct GNUNET_PeerIdentity *peer) | 940 | const struct GNUNET_PeerIdentity *peer) |
958 | { | 941 | { |
959 | struct GNUNET_ATS_Session *session; | 942 | struct GNUNET_ATS_Session *session; |
960 | 943 | ||
961 | if (NULL != (session = lookup_session (endpoint, peer))) | 944 | if (NULL != (session = lookup_session(endpoint, peer))) |
962 | return session; | 945 | return session; |
963 | return create_session (endpoint, peer); | 946 | return create_session(endpoint, peer); |
964 | } | 947 | } |
965 | 948 | ||
966 | 949 | ||
@@ -975,13 +958,13 @@ get_session (struct MacEndpoint *endpoint, | |||
975 | * if the helper was stopped) | 958 | * if the helper was stopped) |
976 | */ | 959 | */ |
977 | static void | 960 | static void |
978 | fragment_transmission_done (void *cls, | 961 | fragment_transmission_done(void *cls, |
979 | int result) | 962 | int result) |
980 | { | 963 | { |
981 | struct FragmentMessage *fm = cls; | 964 | struct FragmentMessage *fm = cls; |
982 | 965 | ||
983 | fm->sh = NULL; | 966 | fm->sh = NULL; |
984 | GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext); | 967 | GNUNET_FRAGMENT_context_transmission_done(fm->fragcontext); |
985 | } | 968 | } |
986 | 969 | ||
987 | 970 | ||
@@ -992,8 +975,8 @@ fragment_transmission_done (void *cls, | |||
992 | * @param hdr pointer to the start of the fragment message | 975 | * @param hdr pointer to the start of the fragment message |
993 | */ | 976 | */ |
994 | static void | 977 | static void |
995 | transmit_fragment (void *cls, | 978 | transmit_fragment(void *cls, |
996 | const struct GNUNET_MessageHeader *hdr) | 979 | const struct GNUNET_MessageHeader *hdr) |
997 | { | 980 | { |
998 | struct FragmentMessage *fm = cls; | 981 | struct FragmentMessage *fm = cls; |
999 | struct MacEndpoint *endpoint = fm->macendpoint; | 982 | struct MacEndpoint *endpoint = fm->macendpoint; |
@@ -1001,51 +984,51 @@ transmit_fragment (void *cls, | |||
1001 | uint16_t msize; | 984 | uint16_t msize; |
1002 | 985 | ||
1003 | if (NULL == endpoint) | 986 | if (NULL == endpoint) |
1004 | { | 987 | { |
1005 | GNUNET_break (0); | 988 | GNUNET_break(0); |
1006 | return; | 989 | return; |
1007 | } | 990 | } |
1008 | msize = ntohs (hdr->size); | 991 | msize = ntohs(hdr->size); |
1009 | size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize; | 992 | size = sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize; |
1010 | { | 993 | { |
1011 | char buf[size]; | 994 | char buf[size]; |
1012 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radio_header; | 995 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radio_header; |
1013 | 996 | ||
1014 | radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf; | 997 | radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *)buf; |
1015 | get_radiotap_header (endpoint, radio_header, size); | 998 | get_radiotap_header(endpoint, radio_header, size); |
1016 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 999 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1017 | "Sending %u bytes of data to MAC `%s'\n", | 1000 | "Sending %u bytes of data to MAC `%s'\n", |
1018 | (unsigned int) msize, | 1001 | (unsigned int)msize, |
1019 | mac_to_string (&endpoint->wlan_addr.mac)); | 1002 | mac_to_string(&endpoint->wlan_addr.mac)); |
1020 | 1003 | ||
1021 | get_wlan_header (endpoint->plugin, | 1004 | get_wlan_header(endpoint->plugin, |
1022 | &radio_header->frame, | 1005 | &radio_header->frame, |
1023 | &endpoint->wlan_addr.mac, | 1006 | &endpoint->wlan_addr.mac, |
1024 | sizeof (endpoint->wlan_addr.mac)); | 1007 | sizeof(endpoint->wlan_addr.mac)); |
1025 | GNUNET_memcpy (&radio_header[1], hdr, msize); | 1008 | GNUNET_memcpy(&radio_header[1], hdr, msize); |
1026 | GNUNET_assert (NULL == fm->sh); | 1009 | GNUNET_assert(NULL == fm->sh); |
1027 | fm->sh = GNUNET_HELPER_send (endpoint->plugin->suid_helper, | 1010 | fm->sh = GNUNET_HELPER_send(endpoint->plugin->suid_helper, |
1028 | &radio_header->header, | 1011 | &radio_header->header, |
1029 | GNUNET_NO, | 1012 | GNUNET_NO, |
1030 | &fragment_transmission_done, fm); | 1013 | &fragment_transmission_done, fm); |
1031 | fm->size_on_wire += size; | 1014 | fm->size_on_wire += size; |
1032 | if (NULL != fm->sh) | 1015 | if (NULL != fm->sh) |
1033 | { | 1016 | { |
1034 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, | 1017 | GNUNET_STATISTICS_update(endpoint->plugin->env->stats, |
1035 | _("# message fragments sent"), | 1018 | _("# message fragments sent"), |
1036 | 1, | 1019 | 1, |
1037 | GNUNET_NO); | 1020 | GNUNET_NO); |
1038 | } | 1021 | } |
1039 | else | 1022 | else |
1040 | { | 1023 | { |
1041 | GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext); | 1024 | GNUNET_FRAGMENT_context_transmission_done(fm->fragcontext); |
1042 | } | 1025 | } |
1043 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, | 1026 | GNUNET_STATISTICS_update(endpoint->plugin->env->stats, |
1044 | "# bytes currently in buffers", | 1027 | "# bytes currently in buffers", |
1045 | -msize, GNUNET_NO); | 1028 | -msize, GNUNET_NO); |
1046 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, | 1029 | GNUNET_STATISTICS_update(endpoint->plugin->env->stats, |
1047 | "# bytes transmitted", | 1030 | "# bytes transmitted", |
1048 | msize, GNUNET_NO); | 1031 | msize, GNUNET_NO); |
1049 | } | 1032 | } |
1050 | } | 1033 | } |
1051 | 1034 | ||
@@ -1056,39 +1039,39 @@ transmit_fragment (void *cls, | |||
1056 | * @param fm message to free | 1039 | * @param fm message to free |
1057 | */ | 1040 | */ |
1058 | static void | 1041 | static void |
1059 | free_fragment_message (struct FragmentMessage *fm) | 1042 | free_fragment_message(struct FragmentMessage *fm) |
1060 | { | 1043 | { |
1061 | struct MacEndpoint *endpoint = fm->macendpoint; | 1044 | struct MacEndpoint *endpoint = fm->macendpoint; |
1062 | 1045 | ||
1063 | GNUNET_STATISTICS_update (endpoint->plugin->env->stats, | 1046 | GNUNET_STATISTICS_update(endpoint->plugin->env->stats, |
1064 | _("# messages pending (with fragmentation)"), | 1047 | _("# messages pending (with fragmentation)"), |
1065 | -1, GNUNET_NO); | 1048 | -1, GNUNET_NO); |
1066 | GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head, | 1049 | GNUNET_CONTAINER_DLL_remove(endpoint->sending_messages_head, |
1067 | endpoint->sending_messages_tail, | 1050 | endpoint->sending_messages_tail, |
1068 | fm); | 1051 | fm); |
1069 | if (NULL != fm->sh) | 1052 | if (NULL != fm->sh) |
1070 | { | 1053 | { |
1071 | GNUNET_HELPER_send_cancel (fm->sh); | 1054 | GNUNET_HELPER_send_cancel(fm->sh); |
1072 | fm->sh = NULL; | 1055 | fm->sh = NULL; |
1073 | } | 1056 | } |
1074 | if (NULL != fm->msg) | 1057 | if (NULL != fm->msg) |
1075 | { | 1058 | { |
1076 | GNUNET_free (fm->msg); | 1059 | GNUNET_free(fm->msg); |
1077 | fm->msg = NULL; | 1060 | fm->msg = NULL; |
1078 | } | 1061 | } |
1079 | if (NULL != fm->fragcontext) | 1062 | if (NULL != fm->fragcontext) |
1080 | { | 1063 | { |
1081 | GNUNET_FRAGMENT_context_destroy (fm->fragcontext, | 1064 | GNUNET_FRAGMENT_context_destroy(fm->fragcontext, |
1082 | &endpoint->msg_delay, | 1065 | &endpoint->msg_delay, |
1083 | &endpoint->ack_delay); | 1066 | &endpoint->ack_delay); |
1084 | fm->fragcontext = NULL; | 1067 | fm->fragcontext = NULL; |
1085 | } | 1068 | } |
1086 | if (NULL != fm->timeout_task) | 1069 | if (NULL != fm->timeout_task) |
1087 | { | 1070 | { |
1088 | GNUNET_SCHEDULER_cancel (fm->timeout_task); | 1071 | GNUNET_SCHEDULER_cancel(fm->timeout_task); |
1089 | fm->timeout_task = NULL; | 1072 | fm->timeout_task = NULL; |
1090 | } | 1073 | } |
1091 | GNUNET_free (fm); | 1074 | GNUNET_free(fm); |
1092 | } | 1075 | } |
1093 | 1076 | ||
1094 | 1077 | ||
@@ -1098,21 +1081,21 @@ free_fragment_message (struct FragmentMessage *fm) | |||
1098 | * @param cls pointer to the 'struct FragmentMessage' | 1081 | * @param cls pointer to the 'struct FragmentMessage' |
1099 | */ | 1082 | */ |
1100 | static void | 1083 | static void |
1101 | fragmentmessage_timeout (void *cls) | 1084 | fragmentmessage_timeout(void *cls) |
1102 | { | 1085 | { |
1103 | struct FragmentMessage *fm = cls; | 1086 | struct FragmentMessage *fm = cls; |
1104 | 1087 | ||
1105 | fm->timeout_task = NULL; | 1088 | fm->timeout_task = NULL; |
1106 | if (NULL != fm->cont) | 1089 | if (NULL != fm->cont) |
1107 | { | 1090 | { |
1108 | fm->cont (fm->cont_cls, | 1091 | fm->cont(fm->cont_cls, |
1109 | &fm->target, | 1092 | &fm->target, |
1110 | GNUNET_SYSERR, | 1093 | GNUNET_SYSERR, |
1111 | fm->size_payload, | 1094 | fm->size_payload, |
1112 | fm->size_on_wire); | 1095 | fm->size_on_wire); |
1113 | fm->cont = NULL; | 1096 | fm->cont = NULL; |
1114 | } | 1097 | } |
1115 | free_fragment_message (fm); | 1098 | free_fragment_message(fm); |
1116 | } | 1099 | } |
1117 | 1100 | ||
1118 | 1101 | ||
@@ -1131,49 +1114,49 @@ fragmentmessage_timeout (void *cls) | |||
1131 | * @param cont_cls closure for @a cont | 1114 | * @param cont_cls closure for @a cont |
1132 | */ | 1115 | */ |
1133 | static void | 1116 | static void |
1134 | send_with_fragmentation (struct MacEndpoint *endpoint, | 1117 | send_with_fragmentation(struct MacEndpoint *endpoint, |
1135 | struct GNUNET_TIME_Relative timeout, | 1118 | struct GNUNET_TIME_Relative timeout, |
1136 | const struct GNUNET_PeerIdentity *target, | 1119 | const struct GNUNET_PeerIdentity *target, |
1137 | const struct GNUNET_MessageHeader *msg, | 1120 | const struct GNUNET_MessageHeader *msg, |
1138 | size_t payload_size, | 1121 | size_t payload_size, |
1139 | GNUNET_TRANSPORT_TransmitContinuation cont, | 1122 | GNUNET_TRANSPORT_TransmitContinuation cont, |
1140 | void *cont_cls) | 1123 | void *cont_cls) |
1141 | 1124 | ||
1142 | { | 1125 | { |
1143 | struct FragmentMessage *fm; | 1126 | struct FragmentMessage *fm; |
1144 | struct Plugin *plugin; | 1127 | struct Plugin *plugin; |
1145 | 1128 | ||
1146 | plugin = endpoint->plugin; | 1129 | plugin = endpoint->plugin; |
1147 | fm = GNUNET_new (struct FragmentMessage); | 1130 | fm = GNUNET_new(struct FragmentMessage); |
1148 | fm->macendpoint = endpoint; | 1131 | fm->macendpoint = endpoint; |
1149 | fm->target = *target; | 1132 | fm->target = *target; |
1150 | fm->size_payload = payload_size; | 1133 | fm->size_payload = payload_size; |
1151 | fm->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 1134 | fm->timeout = GNUNET_TIME_relative_to_absolute(timeout); |
1152 | fm->cont = cont; | 1135 | fm->cont = cont; |
1153 | fm->cont_cls = cont_cls; | 1136 | fm->cont_cls = cont_cls; |
1154 | /* 1 MBit/s typical data rate, 1430 byte fragments => ~100 ms per message */ | 1137 | /* 1 MBit/s typical data rate, 1430 byte fragments => ~100 ms per message */ |
1155 | fm->timeout_task = | 1138 | fm->timeout_task = |
1156 | GNUNET_SCHEDULER_add_delayed (timeout, | 1139 | GNUNET_SCHEDULER_add_delayed(timeout, |
1157 | &fragmentmessage_timeout, | 1140 | &fragmentmessage_timeout, |
1158 | fm); | 1141 | fm); |
1159 | if (GNUNET_YES == plugin->have_mac) | 1142 | if (GNUNET_YES == plugin->have_mac) |
1160 | { | 1143 | { |
1161 | fm->fragcontext = | 1144 | fm->fragcontext = |
1162 | GNUNET_FRAGMENT_context_create (plugin->env->stats, | 1145 | GNUNET_FRAGMENT_context_create(plugin->env->stats, |
1163 | WLAN_MTU, | 1146 | WLAN_MTU, |
1164 | &plugin->tracker, | 1147 | &plugin->tracker, |
1165 | fm->macendpoint->msg_delay, | 1148 | fm->macendpoint->msg_delay, |
1166 | fm->macendpoint->ack_delay, | 1149 | fm->macendpoint->ack_delay, |
1167 | msg, | 1150 | msg, |
1168 | &transmit_fragment, fm); | 1151 | &transmit_fragment, fm); |
1169 | } | 1152 | } |
1170 | else | 1153 | else |
1171 | { | 1154 | { |
1172 | fm->msg = GNUNET_copy_message (msg); | 1155 | fm->msg = GNUNET_copy_message(msg); |
1173 | } | 1156 | } |
1174 | GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head, | 1157 | GNUNET_CONTAINER_DLL_insert_tail(endpoint->sending_messages_head, |
1175 | endpoint->sending_messages_tail, | 1158 | endpoint->sending_messages_tail, |
1176 | fm); | 1159 | fm); |
1177 | } | 1160 | } |
1178 | 1161 | ||
1179 | 1162 | ||
@@ -1183,38 +1166,38 @@ send_with_fragmentation (struct MacEndpoint *endpoint, | |||
1183 | * @param endpoint pointer to the MacEndpoint to free | 1166 | * @param endpoint pointer to the MacEndpoint to free |
1184 | */ | 1167 | */ |
1185 | static void | 1168 | static void |
1186 | free_macendpoint (struct MacEndpoint *endpoint) | 1169 | free_macendpoint(struct MacEndpoint *endpoint) |
1187 | { | 1170 | { |
1188 | struct Plugin *plugin = endpoint->plugin; | 1171 | struct Plugin *plugin = endpoint->plugin; |
1189 | struct FragmentMessage *fm; | 1172 | struct FragmentMessage *fm; |
1190 | struct GNUNET_ATS_Session *session; | 1173 | struct GNUNET_ATS_Session *session; |
1191 | 1174 | ||
1192 | GNUNET_STATISTICS_update (plugin->env->stats, | 1175 | GNUNET_STATISTICS_update(plugin->env->stats, |
1193 | _("# MAC endpoints allocated"), | 1176 | _("# MAC endpoints allocated"), |
1194 | -1, | 1177 | -1, |
1195 | GNUNET_NO); | 1178 | GNUNET_NO); |
1196 | while (NULL != (session = endpoint->sessions_head)) | 1179 | while (NULL != (session = endpoint->sessions_head)) |
1197 | wlan_plugin_disconnect_session (plugin, | 1180 | wlan_plugin_disconnect_session(plugin, |
1198 | session); | 1181 | session); |
1199 | while (NULL != (fm = endpoint->sending_messages_head)) | 1182 | while (NULL != (fm = endpoint->sending_messages_head)) |
1200 | free_fragment_message (fm); | 1183 | free_fragment_message(fm); |
1201 | GNUNET_CONTAINER_DLL_remove (plugin->mac_head, | 1184 | GNUNET_CONTAINER_DLL_remove(plugin->mac_head, |
1202 | plugin->mac_tail, | 1185 | plugin->mac_tail, |
1203 | endpoint); | 1186 | endpoint); |
1204 | 1187 | ||
1205 | if (NULL != endpoint->defrag) | 1188 | if (NULL != endpoint->defrag) |
1206 | { | 1189 | { |
1207 | GNUNET_DEFRAGMENT_context_destroy(endpoint->defrag); | 1190 | GNUNET_DEFRAGMENT_context_destroy(endpoint->defrag); |
1208 | endpoint->defrag = NULL; | 1191 | endpoint->defrag = NULL; |
1209 | } | 1192 | } |
1210 | 1193 | ||
1211 | plugin->mac_count--; | 1194 | plugin->mac_count--; |
1212 | if (NULL != endpoint->timeout_task) | 1195 | if (NULL != endpoint->timeout_task) |
1213 | { | 1196 | { |
1214 | GNUNET_SCHEDULER_cancel (endpoint->timeout_task); | 1197 | GNUNET_SCHEDULER_cancel(endpoint->timeout_task); |
1215 | endpoint->timeout_task = NULL; | 1198 | endpoint->timeout_task = NULL; |
1216 | } | 1199 | } |
1217 | GNUNET_free (endpoint); | 1200 | GNUNET_free(endpoint); |
1218 | } | 1201 | } |
1219 | 1202 | ||
1220 | 1203 | ||
@@ -1224,22 +1207,22 @@ free_macendpoint (struct MacEndpoint *endpoint) | |||
1224 | * @param cls pointer to the `struct MacEndpoint *` | 1207 | * @param cls pointer to the `struct MacEndpoint *` |
1225 | */ | 1208 | */ |
1226 | static void | 1209 | static void |
1227 | macendpoint_timeout (void *cls) | 1210 | macendpoint_timeout(void *cls) |
1228 | { | 1211 | { |
1229 | struct MacEndpoint *endpoint = cls; | 1212 | struct MacEndpoint *endpoint = cls; |
1230 | struct GNUNET_TIME_Relative timeout; | 1213 | struct GNUNET_TIME_Relative timeout; |
1231 | 1214 | ||
1232 | endpoint->timeout_task = NULL; | 1215 | endpoint->timeout_task = NULL; |
1233 | timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout); | 1216 | timeout = GNUNET_TIME_absolute_get_remaining(endpoint->timeout); |
1234 | if (0 == timeout.rel_value_us) | 1217 | if (0 == timeout.rel_value_us) |
1235 | { | 1218 | { |
1236 | free_macendpoint (endpoint); | 1219 | free_macendpoint(endpoint); |
1237 | return; | 1220 | return; |
1238 | } | 1221 | } |
1239 | endpoint->timeout_task = | 1222 | endpoint->timeout_task = |
1240 | GNUNET_SCHEDULER_add_delayed (timeout, | 1223 | GNUNET_SCHEDULER_add_delayed(timeout, |
1241 | &macendpoint_timeout, | 1224 | &macendpoint_timeout, |
1242 | endpoint); | 1225 | endpoint); |
1243 | } | 1226 | } |
1244 | 1227 | ||
1245 | 1228 | ||
@@ -1251,43 +1234,43 @@ macendpoint_timeout (void *cls) | |||
1251 | * @return handle to our data structure for this MAC | 1234 | * @return handle to our data structure for this MAC |
1252 | */ | 1235 | */ |
1253 | static struct MacEndpoint * | 1236 | static struct MacEndpoint * |
1254 | create_macendpoint (struct Plugin *plugin, | 1237 | create_macendpoint(struct Plugin *plugin, |
1255 | struct WlanAddress *mac) | 1238 | struct WlanAddress *mac) |
1256 | { | 1239 | { |
1257 | struct MacEndpoint *pos; | 1240 | struct MacEndpoint *pos; |
1258 | 1241 | ||
1259 | for (pos = plugin->mac_head; NULL != pos; pos = pos->next) | 1242 | for (pos = plugin->mac_head; NULL != pos; pos = pos->next) |
1260 | if (0 == memcmp (mac, &pos->wlan_addr, sizeof (pos->wlan_addr))) | 1243 | if (0 == memcmp(mac, &pos->wlan_addr, sizeof(pos->wlan_addr))) |
1261 | return pos; | 1244 | return pos; |
1262 | pos = GNUNET_new (struct MacEndpoint); | 1245 | pos = GNUNET_new(struct MacEndpoint); |
1263 | pos->wlan_addr = (*mac); | 1246 | pos->wlan_addr = (*mac); |
1264 | pos->plugin = plugin; | 1247 | pos->plugin = plugin; |
1265 | pos->defrag = | 1248 | pos->defrag = |
1266 | GNUNET_DEFRAGMENT_context_create (plugin->env->stats, | 1249 | GNUNET_DEFRAGMENT_context_create(plugin->env->stats, |
1267 | WLAN_MTU, | 1250 | WLAN_MTU, |
1268 | MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, | 1251 | MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, |
1269 | pos, | 1252 | pos, |
1270 | &wlan_data_message_handler, | 1253 | &wlan_data_message_handler, |
1271 | &send_ack); | 1254 | &send_ack); |
1272 | 1255 | ||
1273 | pos->msg_delay = GNUNET_TIME_UNIT_MILLISECONDS; | 1256 | pos->msg_delay = GNUNET_TIME_UNIT_MILLISECONDS; |
1274 | pos->ack_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100); | 1257 | pos->ack_delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100); |
1275 | pos->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT); | 1258 | pos->timeout = GNUNET_TIME_relative_to_absolute(MACENDPOINT_TIMEOUT); |
1276 | pos->timeout_task = | 1259 | pos->timeout_task = |
1277 | GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout, | 1260 | GNUNET_SCHEDULER_add_delayed(MACENDPOINT_TIMEOUT, &macendpoint_timeout, |
1278 | pos); | 1261 | pos); |
1279 | GNUNET_CONTAINER_DLL_insert (plugin->mac_head, | 1262 | GNUNET_CONTAINER_DLL_insert(plugin->mac_head, |
1280 | plugin->mac_tail, | 1263 | plugin->mac_tail, |
1281 | pos); | 1264 | pos); |
1282 | plugin->mac_count++; | 1265 | plugin->mac_count++; |
1283 | GNUNET_STATISTICS_update (plugin->env->stats, | 1266 | GNUNET_STATISTICS_update(plugin->env->stats, |
1284 | _("# MAC endpoints allocated"), | 1267 | _("# MAC endpoints allocated"), |
1285 | 1, GNUNET_NO); | 1268 | 1, GNUNET_NO); |
1286 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1269 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1287 | "New MAC endpoint `%s'\n", | 1270 | "New MAC endpoint `%s'\n", |
1288 | wlan_plugin_address_to_string (NULL, | 1271 | wlan_plugin_address_to_string(NULL, |
1289 | &pos->wlan_addr, | 1272 | &pos->wlan_addr, |
1290 | sizeof (struct WlanAddress))); | 1273 | sizeof(struct WlanAddress))); |
1291 | return pos; | 1274 | return pos; |
1292 | } | 1275 | } |
1293 | 1276 | ||
@@ -1300,8 +1283,8 @@ create_macendpoint (struct Plugin *plugin, | |||
1300 | * @return the network type in HBO or #GNUNET_SYSERR | 1283 | * @return the network type in HBO or #GNUNET_SYSERR |
1301 | */ | 1284 | */ |
1302 | static enum GNUNET_NetworkType | 1285 | static enum GNUNET_NetworkType |
1303 | wlan_plugin_get_network (void *cls, | 1286 | wlan_plugin_get_network(void *cls, |
1304 | struct GNUNET_ATS_Session *session) | 1287 | struct GNUNET_ATS_Session *session) |
1305 | { | 1288 | { |
1306 | #if BUILD_WLAN | 1289 | #if BUILD_WLAN |
1307 | return GNUNET_NT_WLAN; | 1290 | return GNUNET_NT_WLAN; |
@@ -1319,7 +1302,7 @@ wlan_plugin_get_network (void *cls, | |||
1319 | * @return the network type | 1302 | * @return the network type |
1320 | */ | 1303 | */ |
1321 | static enum GNUNET_NetworkType | 1304 | static enum GNUNET_NetworkType |
1322 | wlan_plugin_get_network_for_address (void *cls, | 1305 | wlan_plugin_get_network_for_address(void *cls, |
1323 | const struct GNUNET_HELLO_Address *address) | 1306 | const struct GNUNET_HELLO_Address *address) |
1324 | { | 1307 | { |
1325 | #if BUILD_WLAN | 1308 | #if BUILD_WLAN |
@@ -1339,28 +1322,28 @@ wlan_plugin_get_network_for_address (void *cls, | |||
1339 | * @return the session or NULL of max connections exceeded | 1322 | * @return the session or NULL of max connections exceeded |
1340 | */ | 1323 | */ |
1341 | static struct GNUNET_ATS_Session * | 1324 | static struct GNUNET_ATS_Session * |
1342 | wlan_plugin_get_session (void *cls, | 1325 | wlan_plugin_get_session(void *cls, |
1343 | const struct GNUNET_HELLO_Address *address) | 1326 | const struct GNUNET_HELLO_Address *address) |
1344 | { | 1327 | { |
1345 | struct Plugin *plugin = cls; | 1328 | struct Plugin *plugin = cls; |
1346 | struct MacEndpoint *endpoint; | 1329 | struct MacEndpoint *endpoint; |
1347 | 1330 | ||
1348 | if (NULL == address) | 1331 | if (NULL == address) |
1349 | return NULL; | 1332 | return NULL; |
1350 | if (sizeof (struct WlanAddress) != address->address_length) | 1333 | if (sizeof(struct WlanAddress) != address->address_length) |
1351 | { | 1334 | { |
1352 | GNUNET_break (0); | 1335 | GNUNET_break(0); |
1353 | return NULL; | 1336 | return NULL; |
1354 | } | 1337 | } |
1355 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1338 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1356 | "Service asked to create session for peer `%s' with MAC `%s'\n", | 1339 | "Service asked to create session for peer `%s' with MAC `%s'\n", |
1357 | GNUNET_i2s (&address->peer), | 1340 | GNUNET_i2s(&address->peer), |
1358 | wlan_plugin_address_to_string (NULL, | 1341 | wlan_plugin_address_to_string(NULL, |
1359 | address->address, | 1342 | address->address, |
1360 | address->address_length)); | 1343 | address->address_length)); |
1361 | endpoint = create_macendpoint (plugin, | 1344 | endpoint = create_macendpoint(plugin, |
1362 | (struct WlanAddress *) address->address); | 1345 | (struct WlanAddress *)address->address); |
1363 | return get_session (endpoint, &address->peer); | 1346 | return get_session(endpoint, &address->peer); |
1364 | } | 1347 | } |
1365 | 1348 | ||
1366 | 1349 | ||
@@ -1373,8 +1356,8 @@ wlan_plugin_get_session (void *cls, | |||
1373 | * @param target peer from which to disconnect | 1356 | * @param target peer from which to disconnect |
1374 | */ | 1357 | */ |
1375 | static void | 1358 | static void |
1376 | wlan_plugin_disconnect_peer (void *cls, | 1359 | wlan_plugin_disconnect_peer(void *cls, |
1377 | const struct GNUNET_PeerIdentity *target) | 1360 | const struct GNUNET_PeerIdentity *target) |
1378 | { | 1361 | { |
1379 | struct Plugin *plugin = cls; | 1362 | struct Plugin *plugin = cls; |
1380 | struct GNUNET_ATS_Session *session; | 1363 | struct GNUNET_ATS_Session *session; |
@@ -1382,12 +1365,12 @@ wlan_plugin_disconnect_peer (void *cls, | |||
1382 | 1365 | ||
1383 | for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next) | 1366 | for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next) |
1384 | for (session = endpoint->sessions_head; NULL != session; session = session->next) | 1367 | for (session = endpoint->sessions_head; NULL != session; session = session->next) |
1385 | if (0 == memcmp (target, &session->target, | 1368 | if (0 == memcmp(target, &session->target, |
1386 | sizeof (struct GNUNET_PeerIdentity))) | 1369 | sizeof(struct GNUNET_PeerIdentity))) |
1387 | { | 1370 | { |
1388 | wlan_plugin_disconnect_session (plugin, session); | 1371 | wlan_plugin_disconnect_session(plugin, session); |
1389 | break; /* inner-loop only (in case peer has another MAC as well!) */ | 1372 | break; /* inner-loop only (in case peer has another MAC as well!) */ |
1390 | } | 1373 | } |
1391 | } | 1374 | } |
1392 | 1375 | ||
1393 | 1376 | ||
@@ -1419,43 +1402,43 @@ wlan_plugin_disconnect_peer (void *cls, | |||
1419 | * and does NOT mean that the message was not transmitted (DV) | 1402 | * and does NOT mean that the message was not transmitted (DV) |
1420 | */ | 1403 | */ |
1421 | static ssize_t | 1404 | static ssize_t |
1422 | wlan_plugin_send (void *cls, | 1405 | wlan_plugin_send(void *cls, |
1423 | struct GNUNET_ATS_Session *session, | 1406 | struct GNUNET_ATS_Session *session, |
1424 | const char *msgbuf, size_t msgbuf_size, | 1407 | const char *msgbuf, size_t msgbuf_size, |
1425 | unsigned int priority, | 1408 | unsigned int priority, |
1426 | struct GNUNET_TIME_Relative to, | 1409 | struct GNUNET_TIME_Relative to, |
1427 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 1410 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
1428 | { | 1411 | { |
1429 | struct Plugin *plugin = cls; | 1412 | struct Plugin *plugin = cls; |
1430 | struct WlanHeader *wlanheader; | 1413 | struct WlanHeader *wlanheader; |
1431 | size_t size = msgbuf_size + sizeof (struct WlanHeader); | 1414 | size_t size = msgbuf_size + sizeof(struct WlanHeader); |
1432 | char buf[size] GNUNET_ALIGN; | 1415 | char buf[size] GNUNET_ALIGN; |
1433 | 1416 | ||
1434 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1417 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1435 | "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n", | 1418 | "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n", |
1436 | msgbuf_size, | 1419 | msgbuf_size, |
1437 | GNUNET_i2s (&session->target), | 1420 | GNUNET_i2s(&session->target), |
1438 | (unsigned int) ntohs (((struct GNUNET_MessageHeader*)msgbuf)->size), | 1421 | (unsigned int)ntohs(((struct GNUNET_MessageHeader*)msgbuf)->size), |
1439 | (unsigned int) ntohs (((struct GNUNET_MessageHeader*)msgbuf)->type)); | 1422 | (unsigned int)ntohs(((struct GNUNET_MessageHeader*)msgbuf)->type)); |
1440 | wlanheader = (struct WlanHeader *) buf; | 1423 | wlanheader = (struct WlanHeader *)buf; |
1441 | wlanheader->header.size = htons (msgbuf_size + sizeof (struct WlanHeader)); | 1424 | wlanheader->header.size = htons(msgbuf_size + sizeof(struct WlanHeader)); |
1442 | wlanheader->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA); | 1425 | wlanheader->header.type = htons(GNUNET_MESSAGE_TYPE_WLAN_DATA); |
1443 | wlanheader->sender = *plugin->env->my_identity; | 1426 | wlanheader->sender = *plugin->env->my_identity; |
1444 | wlanheader->target = session->target; | 1427 | wlanheader->target = session->target; |
1445 | wlanheader->crc = htonl (GNUNET_CRYPTO_crc32_n (msgbuf, msgbuf_size)); | 1428 | wlanheader->crc = htonl(GNUNET_CRYPTO_crc32_n(msgbuf, msgbuf_size)); |
1446 | GNUNET_memcpy (&wlanheader[1], | 1429 | GNUNET_memcpy(&wlanheader[1], |
1447 | msgbuf, | 1430 | msgbuf, |
1448 | msgbuf_size); | 1431 | msgbuf_size); |
1449 | GNUNET_STATISTICS_update (plugin->env->stats, | 1432 | GNUNET_STATISTICS_update(plugin->env->stats, |
1450 | "# bytes currently in buffers", | 1433 | "# bytes currently in buffers", |
1451 | msgbuf_size, | 1434 | msgbuf_size, |
1452 | GNUNET_NO); | 1435 | GNUNET_NO); |
1453 | send_with_fragmentation (session->mac, | 1436 | send_with_fragmentation(session->mac, |
1454 | to, | 1437 | to, |
1455 | &session->target, | 1438 | &session->target, |
1456 | &wlanheader->header, | 1439 | &wlanheader->header, |
1457 | msgbuf_size, | 1440 | msgbuf_size, |
1458 | cont, cont_cls); | 1441 | cont, cont_cls); |
1459 | return size; | 1442 | return size; |
1460 | } | 1443 | } |
1461 | 1444 | ||
@@ -1469,9 +1452,9 @@ wlan_plugin_send (void *cls, | |||
1469 | * @param hdr start of the message | 1452 | * @param hdr start of the message |
1470 | */ | 1453 | */ |
1471 | static int | 1454 | static int |
1472 | process_data (void *cls, | 1455 | process_data(void *cls, |
1473 | void *client, | 1456 | void *client, |
1474 | const struct GNUNET_MessageHeader *hdr) | 1457 | const struct GNUNET_MessageHeader *hdr) |
1475 | { | 1458 | { |
1476 | struct Plugin *plugin = cls; | 1459 | struct Plugin *plugin = cls; |
1477 | struct GNUNET_HELLO_Address *address; | 1460 | struct GNUNET_HELLO_Address *address; |
@@ -1482,217 +1465,221 @@ process_data (void *cls, | |||
1482 | int ret; | 1465 | int ret; |
1483 | uint16_t msize; | 1466 | uint16_t msize; |
1484 | 1467 | ||
1485 | msize = ntohs (hdr->size); | 1468 | msize = ntohs(hdr->size); |
1486 | |||
1487 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1488 | "# bytes received", | ||
1489 | msize, GNUNET_NO); | ||
1490 | 1469 | ||
1491 | switch (ntohs (hdr->type)) | 1470 | GNUNET_STATISTICS_update(plugin->env->stats, |
1492 | { | 1471 | "# bytes received", |
1493 | case GNUNET_MESSAGE_TYPE_HELLO: | 1472 | msize, GNUNET_NO); |
1494 | 1473 | ||
1495 | if (GNUNET_OK != | 1474 | switch (ntohs(hdr->type)) |
1496 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, | ||
1497 | &tmpsource)) | ||
1498 | { | ||
1499 | GNUNET_break_op (0); | ||
1500 | break; | ||
1501 | } | ||
1502 | if (NULL == mas->endpoint) | ||
1503 | { | 1475 | { |
1504 | GNUNET_break (0); | 1476 | case GNUNET_MESSAGE_TYPE_HELLO: |
1505 | break; | ||
1506 | } | ||
1507 | 1477 | ||
1508 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1478 | if (GNUNET_OK != |
1509 | "Processing %u bytes of HELLO from peer `%s' at MAC %s\n", | 1479 | GNUNET_HELLO_get_id((const struct GNUNET_HELLO_Message *)hdr, |
1510 | (unsigned int) msize, | 1480 | &tmpsource)) |
1511 | GNUNET_i2s (&tmpsource), | 1481 | { |
1512 | wlan_plugin_address_to_string (NULL, | 1482 | GNUNET_break_op(0); |
1483 | break; | ||
1484 | } | ||
1485 | if (NULL == mas->endpoint) | ||
1486 | { | ||
1487 | GNUNET_break(0); | ||
1488 | break; | ||
1489 | } | ||
1490 | |||
1491 | LOG(GNUNET_ERROR_TYPE_DEBUG, | ||
1492 | "Processing %u bytes of HELLO from peer `%s' at MAC %s\n", | ||
1493 | (unsigned int)msize, | ||
1494 | GNUNET_i2s(&tmpsource), | ||
1495 | wlan_plugin_address_to_string(NULL, | ||
1513 | &mas->endpoint->wlan_addr, | 1496 | &mas->endpoint->wlan_addr, |
1514 | sizeof (mas->endpoint->wlan_addr))); | 1497 | sizeof(mas->endpoint->wlan_addr))); |
1515 | 1498 | ||
1516 | GNUNET_STATISTICS_update (plugin->env->stats, | 1499 | GNUNET_STATISTICS_update(plugin->env->stats, |
1517 | _("# HELLO messages received"), 1, | 1500 | _("# HELLO messages received"), 1, |
1518 | GNUNET_NO); | 1501 | GNUNET_NO); |
1519 | address = GNUNET_HELLO_address_allocate (&tmpsource, | 1502 | address = GNUNET_HELLO_address_allocate(&tmpsource, |
1520 | PLUGIN_NAME, | 1503 | PLUGIN_NAME, |
1521 | &mas->endpoint->wlan_addr, | 1504 | &mas->endpoint->wlan_addr, |
1522 | sizeof (mas->endpoint->wlan_addr), | 1505 | sizeof(mas->endpoint->wlan_addr), |
1523 | GNUNET_HELLO_ADDRESS_INFO_NONE); | 1506 | GNUNET_HELLO_ADDRESS_INFO_NONE); |
1524 | mas->session = lookup_session (mas->endpoint, | 1507 | mas->session = lookup_session(mas->endpoint, |
1525 | &tmpsource); | 1508 | &tmpsource); |
1526 | if (NULL == mas->session) | 1509 | if (NULL == mas->session) |
1527 | { | 1510 | { |
1528 | mas->session = create_session (mas->endpoint, | 1511 | mas->session = create_session(mas->endpoint, |
1529 | &tmpsource); | 1512 | &tmpsource); |
1530 | plugin->env->session_start (plugin->env->cls, | 1513 | plugin->env->session_start(plugin->env->cls, |
1531 | address, | 1514 | address, |
1532 | mas->session, | 1515 | mas->session, |
1533 | scope); | 1516 | scope); |
1534 | } | 1517 | } |
1535 | plugin->env->receive (plugin->env->cls, | 1518 | plugin->env->receive(plugin->env->cls, |
1536 | address, | 1519 | address, |
1537 | mas->session, | 1520 | mas->session, |
1538 | hdr); | 1521 | hdr); |
1539 | GNUNET_HELLO_address_free (address); | 1522 | GNUNET_HELLO_address_free(address); |
1540 | break; | ||
1541 | case GNUNET_MESSAGE_TYPE_FRAGMENT: | ||
1542 | if (NULL == mas->endpoint) | ||
1543 | { | ||
1544 | GNUNET_break (0); | ||
1545 | break; | 1523 | break; |
1546 | } | 1524 | |
1547 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1525 | case GNUNET_MESSAGE_TYPE_FRAGMENT: |
1548 | "Processing %u bytes of FRAGMENT from MAC %s\n", | 1526 | if (NULL == mas->endpoint) |
1549 | (unsigned int) msize, | 1527 | { |
1550 | wlan_plugin_address_to_string (NULL, | 1528 | GNUNET_break(0); |
1529 | break; | ||
1530 | } | ||
1531 | LOG(GNUNET_ERROR_TYPE_DEBUG, | ||
1532 | "Processing %u bytes of FRAGMENT from MAC %s\n", | ||
1533 | (unsigned int)msize, | ||
1534 | wlan_plugin_address_to_string(NULL, | ||
1551 | &mas->endpoint->wlan_addr, | 1535 | &mas->endpoint->wlan_addr, |
1552 | sizeof (mas->endpoint->wlan_addr))); | 1536 | sizeof(mas->endpoint->wlan_addr))); |
1553 | GNUNET_STATISTICS_update (plugin->env->stats, | 1537 | GNUNET_STATISTICS_update(plugin->env->stats, |
1554 | _("# fragments received"), | 1538 | _("# fragments received"), |
1555 | 1, | 1539 | 1, |
1556 | GNUNET_NO); | 1540 | GNUNET_NO); |
1557 | (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag, | 1541 | (void)GNUNET_DEFRAGMENT_process_fragment(mas->endpoint->defrag, |
1558 | hdr); | 1542 | hdr); |
1559 | break; | ||
1560 | case GNUNET_MESSAGE_TYPE_FRAGMENT_ACK: | ||
1561 | if (NULL == mas->endpoint) | ||
1562 | { | ||
1563 | GNUNET_break (0); | ||
1564 | break; | 1543 | break; |
1565 | } | 1544 | |
1566 | GNUNET_STATISTICS_update (plugin->env->stats, | 1545 | case GNUNET_MESSAGE_TYPE_FRAGMENT_ACK: |
1567 | _("# ACKs received"), | 1546 | if (NULL == mas->endpoint) |
1568 | 1, GNUNET_NO); | 1547 | { |
1569 | for (fm = mas->endpoint->sending_messages_head; NULL != fm; fm = fm->next) | 1548 | GNUNET_break(0); |
1570 | { | 1549 | break; |
1571 | ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr); | 1550 | } |
1572 | if (GNUNET_OK == ret) | 1551 | GNUNET_STATISTICS_update(plugin->env->stats, |
1573 | { | 1552 | _("# ACKs received"), |
1574 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1553 | 1, GNUNET_NO); |
1575 | "Got last ACK, finished message transmission to `%s' (%p)\n", | 1554 | for (fm = mas->endpoint->sending_messages_head; NULL != fm; fm = fm->next) |
1576 | wlan_plugin_address_to_string (NULL, | 1555 | { |
1577 | &mas->endpoint->wlan_addr, | 1556 | ret = GNUNET_FRAGMENT_process_ack(fm->fragcontext, hdr); |
1578 | sizeof (mas->endpoint->wlan_addr)), | 1557 | if (GNUNET_OK == ret) |
1579 | fm); | 1558 | { |
1580 | mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT); | 1559 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1581 | if (NULL != fm->cont) | 1560 | "Got last ACK, finished message transmission to `%s' (%p)\n", |
1582 | { | 1561 | wlan_plugin_address_to_string(NULL, |
1583 | fm->cont (fm->cont_cls, | 1562 | &mas->endpoint->wlan_addr, |
1584 | &fm->target, | 1563 | sizeof(mas->endpoint->wlan_addr)), |
1585 | GNUNET_OK, | 1564 | fm); |
1586 | fm->size_payload, | 1565 | mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute(MACENDPOINT_TIMEOUT); |
1587 | fm->size_on_wire); | 1566 | if (NULL != fm->cont) |
1588 | fm->cont = NULL; | 1567 | { |
1589 | } | 1568 | fm->cont(fm->cont_cls, |
1590 | free_fragment_message (fm); | 1569 | &fm->target, |
1591 | break; | 1570 | GNUNET_OK, |
1592 | } | 1571 | fm->size_payload, |
1593 | if (GNUNET_NO == ret) | 1572 | fm->size_on_wire); |
1594 | { | 1573 | fm->cont = NULL; |
1595 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1574 | } |
1596 | "Got an ACK, message transmission to `%s' not yet finished\n", | 1575 | free_fragment_message(fm); |
1597 | wlan_plugin_address_to_string (NULL, | 1576 | break; |
1598 | &mas->endpoint->wlan_addr, | 1577 | } |
1599 | sizeof (mas->endpoint->wlan_addr))); | 1578 | if (GNUNET_NO == ret) |
1600 | break; | 1579 | { |
1601 | } | 1580 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1602 | } | 1581 | "Got an ACK, message transmission to `%s' not yet finished\n", |
1603 | if (NULL == fm) | 1582 | wlan_plugin_address_to_string(NULL, |
1604 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1583 | &mas->endpoint->wlan_addr, |
1605 | "ACK not matched against any active fragmentation with MAC `%s'\n", | 1584 | sizeof(mas->endpoint->wlan_addr))); |
1606 | wlan_plugin_address_to_string (NULL, | 1585 | break; |
1586 | } | ||
1587 | } | ||
1588 | if (NULL == fm) | ||
1589 | LOG(GNUNET_ERROR_TYPE_DEBUG, | ||
1590 | "ACK not matched against any active fragmentation with MAC `%s'\n", | ||
1591 | wlan_plugin_address_to_string(NULL, | ||
1607 | &mas->endpoint->wlan_addr, | 1592 | &mas->endpoint->wlan_addr, |
1608 | sizeof (mas->endpoint->wlan_addr))); | 1593 | sizeof(mas->endpoint->wlan_addr))); |
1609 | break; | ||
1610 | case GNUNET_MESSAGE_TYPE_WLAN_DATA: | ||
1611 | if (NULL == mas->endpoint) | ||
1612 | { | ||
1613 | GNUNET_break (0); | ||
1614 | break; | ||
1615 | } | ||
1616 | if (msize < sizeof (struct WlanHeader)) | ||
1617 | { | ||
1618 | GNUNET_break (0); | ||
1619 | break; | ||
1620 | } | ||
1621 | wlanheader = (const struct WlanHeader *) hdr; | ||
1622 | if (0 != memcmp (&wlanheader->target, | ||
1623 | plugin->env->my_identity, | ||
1624 | sizeof (struct GNUNET_PeerIdentity))) | ||
1625 | { | ||
1626 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1627 | "Data for `%s', not for me, ignoring\n", | ||
1628 | GNUNET_i2s (&wlanheader->target)); | ||
1629 | break; | 1594 | break; |
1630 | } | 1595 | |
1631 | if (ntohl (wlanheader->crc) != | 1596 | case GNUNET_MESSAGE_TYPE_WLAN_DATA: |
1632 | GNUNET_CRYPTO_crc32_n (&wlanheader[1], | 1597 | if (NULL == mas->endpoint) |
1633 | msize - sizeof (struct WlanHeader))) | 1598 | { |
1634 | { | 1599 | GNUNET_break(0); |
1635 | GNUNET_STATISTICS_update (plugin->env->stats, | 1600 | break; |
1636 | _("# DATA messages discarded due to CRC32 error"), | 1601 | } |
1637 | 1, | 1602 | if (msize < sizeof(struct WlanHeader)) |
1638 | GNUNET_NO); | 1603 | { |
1639 | break; | 1604 | GNUNET_break(0); |
1640 | } | 1605 | break; |
1641 | mas->session = lookup_session (mas->endpoint, | 1606 | } |
1642 | &wlanheader->sender); | 1607 | wlanheader = (const struct WlanHeader *)hdr; |
1643 | if (NULL == mas->session) | 1608 | if (0 != memcmp(&wlanheader->target, |
1644 | { | 1609 | plugin->env->my_identity, |
1645 | mas->session = create_session (mas->endpoint, | 1610 | sizeof(struct GNUNET_PeerIdentity))) |
1646 | &wlanheader->sender); | 1611 | { |
1647 | address = GNUNET_HELLO_address_allocate (&wlanheader->sender, | 1612 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1648 | PLUGIN_NAME, | 1613 | "Data for `%s', not for me, ignoring\n", |
1649 | &mas->endpoint->wlan_addr, | 1614 | GNUNET_i2s(&wlanheader->target)); |
1650 | sizeof (struct WlanAddress), | 1615 | break; |
1651 | GNUNET_HELLO_ADDRESS_INFO_NONE); | 1616 | } |
1652 | plugin->env->session_start (plugin->env->cls, | 1617 | if (ntohl(wlanheader->crc) != |
1653 | address, | 1618 | GNUNET_CRYPTO_crc32_n(&wlanheader[1], |
1654 | mas->session, | 1619 | msize - sizeof(struct WlanHeader))) |
1655 | scope); | 1620 | { |
1656 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1621 | GNUNET_STATISTICS_update(plugin->env->stats, |
1657 | "Notifying transport about peer `%s''s new session %p \n", | 1622 | _("# DATA messages discarded due to CRC32 error"), |
1658 | GNUNET_i2s (&wlanheader->sender), | 1623 | 1, |
1659 | mas->session); | 1624 | GNUNET_NO); |
1660 | GNUNET_HELLO_address_free (address); | 1625 | break; |
1661 | } | 1626 | } |
1662 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1627 | mas->session = lookup_session(mas->endpoint, |
1663 | "Processing %u bytes of DATA from peer `%s'\n", | 1628 | &wlanheader->sender); |
1664 | (unsigned int) msize, | 1629 | if (NULL == mas->session) |
1665 | GNUNET_i2s (&wlanheader->sender)); | 1630 | { |
1666 | mas->session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 1631 | mas->session = create_session(mas->endpoint, |
1667 | (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer, | 1632 | &wlanheader->sender); |
1668 | mas, | 1633 | address = GNUNET_HELLO_address_allocate(&wlanheader->sender, |
1669 | (const char *) &wlanheader[1], | 1634 | PLUGIN_NAME, |
1670 | msize - sizeof (struct WlanHeader), | 1635 | &mas->endpoint->wlan_addr, |
1671 | GNUNET_YES, | 1636 | sizeof(struct WlanAddress), |
1637 | GNUNET_HELLO_ADDRESS_INFO_NONE); | ||
1638 | plugin->env->session_start(plugin->env->cls, | ||
1639 | address, | ||
1640 | mas->session, | ||
1641 | scope); | ||
1642 | LOG(GNUNET_ERROR_TYPE_DEBUG, | ||
1643 | "Notifying transport about peer `%s''s new session %p \n", | ||
1644 | GNUNET_i2s(&wlanheader->sender), | ||
1645 | mas->session); | ||
1646 | GNUNET_HELLO_address_free(address); | ||
1647 | } | ||
1648 | LOG(GNUNET_ERROR_TYPE_DEBUG, | ||
1649 | "Processing %u bytes of DATA from peer `%s'\n", | ||
1650 | (unsigned int)msize, | ||
1651 | GNUNET_i2s(&wlanheader->sender)); | ||
1652 | mas->session->timeout = GNUNET_TIME_relative_to_absolute(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | ||
1653 | (void)GNUNET_SERVER_mst_receive(plugin->wlan_header_payload_tokenizer, | ||
1654 | mas, | ||
1655 | (const char *)&wlanheader[1], | ||
1656 | msize - sizeof(struct WlanHeader), | ||
1657 | GNUNET_YES, | ||
1672 | GNUNET_NO); | 1658 | GNUNET_NO); |
1673 | break; | ||
1674 | default: | ||
1675 | if (NULL == mas->endpoint) | ||
1676 | { | ||
1677 | GNUNET_break (0); | ||
1678 | break; | 1659 | break; |
1679 | } | 1660 | |
1680 | if (NULL == mas->session) | 1661 | default: |
1681 | { | 1662 | if (NULL == mas->endpoint) |
1682 | GNUNET_break (0); | 1663 | { |
1664 | GNUNET_break(0); | ||
1665 | break; | ||
1666 | } | ||
1667 | if (NULL == mas->session) | ||
1668 | { | ||
1669 | GNUNET_break(0); | ||
1670 | break; | ||
1671 | } | ||
1672 | LOG(GNUNET_ERROR_TYPE_DEBUG, | ||
1673 | "Received packet with %u bytes of type %u from peer %s\n", | ||
1674 | (unsigned int)msize, | ||
1675 | (unsigned int)ntohs(hdr->type), | ||
1676 | GNUNET_i2s(&mas->session->target)); | ||
1677 | plugin->env->receive(plugin->env->cls, | ||
1678 | mas->session->address, | ||
1679 | mas->session, | ||
1680 | hdr); | ||
1683 | break; | 1681 | break; |
1684 | } | 1682 | } |
1685 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1686 | "Received packet with %u bytes of type %u from peer %s\n", | ||
1687 | (unsigned int) msize, | ||
1688 | (unsigned int) ntohs (hdr->type), | ||
1689 | GNUNET_i2s (&mas->session->target)); | ||
1690 | plugin->env->receive (plugin->env->cls, | ||
1691 | mas->session->address, | ||
1692 | mas->session, | ||
1693 | hdr); | ||
1694 | break; | ||
1695 | } | ||
1696 | return GNUNET_OK; | 1683 | return GNUNET_OK; |
1697 | } | 1684 | } |
1698 | 1685 | ||
@@ -1703,7 +1690,7 @@ process_data (void *cls, | |||
1703 | * @param cls pointer to the plugin struct | 1690 | * @param cls pointer to the plugin struct |
1704 | */ | 1691 | */ |
1705 | static void | 1692 | static void |
1706 | send_hello_beacon (void *cls) | 1693 | send_hello_beacon(void *cls) |
1707 | { | 1694 | { |
1708 | struct Plugin *plugin = cls; | 1695 | struct Plugin *plugin = cls; |
1709 | uint16_t size; | 1696 | uint16_t size; |
@@ -1711,42 +1698,42 @@ send_hello_beacon (void *cls) | |||
1711 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader; | 1698 | struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader; |
1712 | const struct GNUNET_MessageHeader *hello; | 1699 | const struct GNUNET_MessageHeader *hello; |
1713 | 1700 | ||
1714 | hello = plugin->env->get_our_hello (); | 1701 | hello = plugin->env->get_our_hello(); |
1715 | if (NULL != hello) | 1702 | if (NULL != hello) |
1716 | { | 1703 | { |
1717 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); | 1704 | hello_size = GNUNET_HELLO_size((struct GNUNET_HELLO_Message *)hello); |
1718 | GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU); | 1705 | GNUNET_assert(sizeof(struct WlanHeader) + hello_size <= WLAN_MTU); |
1719 | size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size; | 1706 | size = sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size; |
1720 | { | 1707 | { |
1721 | char buf[size] GNUNET_ALIGN; | 1708 | char buf[size] GNUNET_ALIGN; |
1722 | 1709 | ||
1723 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1710 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1724 | "Sending %u byte HELLO beacon\n", | 1711 | "Sending %u byte HELLO beacon\n", |
1725 | (unsigned int) size); | 1712 | (unsigned int)size); |
1726 | radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf; | 1713 | radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*)buf; |
1727 | get_radiotap_header (NULL, radioHeader, size); | 1714 | get_radiotap_header(NULL, radioHeader, size); |
1728 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1715 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1729 | "Broadcasting %u bytes of data to MAC `%s'\n", | 1716 | "Broadcasting %u bytes of data to MAC `%s'\n", |
1730 | (unsigned int) size, | 1717 | (unsigned int)size, |
1731 | mac_to_string (&bc_all_mac)); | 1718 | mac_to_string(&bc_all_mac)); |
1732 | get_wlan_header (plugin, &radioHeader->frame, &bc_all_mac, size); | 1719 | get_wlan_header(plugin, &radioHeader->frame, &bc_all_mac, size); |
1733 | GNUNET_memcpy (&radioHeader[1], hello, hello_size); | 1720 | GNUNET_memcpy(&radioHeader[1], hello, hello_size); |
1734 | if (NULL != | 1721 | if (NULL != |
1735 | GNUNET_HELPER_send (plugin->suid_helper, | 1722 | GNUNET_HELPER_send(plugin->suid_helper, |
1736 | &radioHeader->header, | 1723 | &radioHeader->header, |
1737 | GNUNET_YES /* can drop */, | 1724 | GNUNET_YES /* can drop */, |
1738 | NULL, NULL)) | 1725 | NULL, NULL)) |
1739 | GNUNET_STATISTICS_update (plugin->env->stats, | 1726 | GNUNET_STATISTICS_update(plugin->env->stats, |
1740 | _("# HELLO beacons sent"), | 1727 | _("# HELLO beacons sent"), |
1741 | 1, GNUNET_NO); | 1728 | 1, GNUNET_NO); |
1742 | } } | 1729 | } |
1730 | } | ||
1743 | plugin->beacon_task = | 1731 | plugin->beacon_task = |
1744 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 1732 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply |
1745 | (HELLO_BEACON_SCALING_FACTOR, | 1733 | (HELLO_BEACON_SCALING_FACTOR, |
1746 | plugin->mac_count + 1), | 1734 | plugin->mac_count + 1), |
1747 | &send_hello_beacon, | 1735 | &send_hello_beacon, |
1748 | plugin); | 1736 | plugin); |
1749 | |||
1750 | } | 1737 | } |
1751 | 1738 | ||
1752 | 1739 | ||
@@ -1757,8 +1744,8 @@ send_hello_beacon (void *cls) | |||
1757 | * @param hdr header of the GNUNET_MessageHeader | 1744 | * @param hdr header of the GNUNET_MessageHeader |
1758 | */ | 1745 | */ |
1759 | static int | 1746 | static int |
1760 | handle_helper_message (void *cls, | 1747 | handle_helper_message(void *cls, |
1761 | const struct GNUNET_MessageHeader *hdr) | 1748 | const struct GNUNET_MessageHeader *hdr) |
1762 | { | 1749 | { |
1763 | struct Plugin *plugin = cls; | 1750 | struct Plugin *plugin = cls; |
1764 | struct GNUNET_HELLO_Address *my_address; | 1751 | struct GNUNET_HELLO_Address *my_address; |
@@ -1770,155 +1757,156 @@ handle_helper_message (void *cls, | |||
1770 | struct FragmentMessage *fm; | 1757 | struct FragmentMessage *fm; |
1771 | struct MacEndpoint *endpoint; | 1758 | struct MacEndpoint *endpoint; |
1772 | 1759 | ||
1773 | msize = ntohs (hdr->size); | 1760 | msize = ntohs(hdr->size); |
1774 | switch (ntohs (hdr->type)) | 1761 | switch (ntohs(hdr->type)) |
1775 | { | ||
1776 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: | ||
1777 | if (msize != sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage)) | ||
1778 | { | 1762 | { |
1779 | GNUNET_break (0); | 1763 | case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: |
1780 | break; | 1764 | if (msize != sizeof(struct GNUNET_TRANSPORT_WLAN_HelperControlMessage)) |
1781 | } | 1765 | { |
1782 | cm = (const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *) hdr; | 1766 | GNUNET_break(0); |
1783 | if (GNUNET_YES == plugin->have_mac) | 1767 | break; |
1784 | { | 1768 | } |
1785 | if (0 == memcmp (&plugin->mac_address, | 1769 | cm = (const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *)hdr; |
1786 | &cm->mac, | 1770 | if (GNUNET_YES == plugin->have_mac) |
1787 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))) | 1771 | { |
1788 | break; /* no change */ | 1772 | if (0 == memcmp(&plugin->mac_address, |
1789 | /* remove old address */ | 1773 | &cm->mac, |
1790 | memset (&wa, 0, sizeof (struct WlanAddress)); | 1774 | sizeof(struct GNUNET_TRANSPORT_WLAN_MacAddress))) |
1775 | break; /* no change */ | ||
1776 | /* remove old address */ | ||
1777 | memset(&wa, 0, sizeof(struct WlanAddress)); | ||
1778 | wa.mac = plugin->mac_address; | ||
1779 | wa.options = htonl(plugin->options); | ||
1780 | my_address = GNUNET_HELLO_address_allocate(plugin->env->my_identity, | ||
1781 | PLUGIN_NAME, | ||
1782 | &wa, sizeof(wa), | ||
1783 | GNUNET_HELLO_ADDRESS_INFO_NONE); | ||
1784 | plugin->env->notify_address(plugin->env->cls, | ||
1785 | GNUNET_NO, | ||
1786 | my_address); | ||
1787 | GNUNET_HELLO_address_free(my_address); | ||
1788 | plugin->mac_address = cm->mac; | ||
1789 | } | ||
1790 | else | ||
1791 | { | ||
1792 | plugin->mac_address = cm->mac; | ||
1793 | plugin->have_mac = GNUNET_YES; | ||
1794 | for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next) | ||
1795 | { | ||
1796 | for (fm = endpoint->sending_messages_head; NULL != fm; fm = fm->next) | ||
1797 | { | ||
1798 | if (NULL != fm->fragcontext) | ||
1799 | { | ||
1800 | GNUNET_break(0); /* should not happen */ | ||
1801 | continue; | ||
1802 | } | ||
1803 | fm->fragcontext = | ||
1804 | GNUNET_FRAGMENT_context_create(plugin->env->stats, | ||
1805 | WLAN_MTU, | ||
1806 | &plugin->tracker, | ||
1807 | fm->macendpoint->msg_delay, | ||
1808 | fm->macendpoint->ack_delay, | ||
1809 | fm->msg, | ||
1810 | &transmit_fragment, fm); | ||
1811 | GNUNET_free(fm->msg); | ||
1812 | fm->msg = NULL; | ||
1813 | } | ||
1814 | } | ||
1815 | GNUNET_break(NULL == plugin->beacon_task); | ||
1816 | plugin->beacon_task = GNUNET_SCHEDULER_add_now(&send_hello_beacon, | ||
1817 | plugin); | ||
1818 | } | ||
1819 | |||
1820 | memset(&wa, 0, sizeof(struct WlanAddress)); | ||
1791 | wa.mac = plugin->mac_address; | 1821 | wa.mac = plugin->mac_address; |
1792 | wa.options = htonl(plugin->options); | 1822 | wa.options = htonl(plugin->options); |
1793 | my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity, | 1823 | my_address = GNUNET_HELLO_address_allocate(plugin->env->my_identity, |
1794 | PLUGIN_NAME, | 1824 | PLUGIN_NAME, |
1795 | &wa, sizeof (wa), | 1825 | &wa, sizeof(wa), |
1796 | GNUNET_HELLO_ADDRESS_INFO_NONE); | 1826 | GNUNET_HELLO_ADDRESS_INFO_NONE); |
1797 | plugin->env->notify_address (plugin->env->cls, | 1827 | |
1798 | GNUNET_NO, | 1828 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1799 | my_address); | 1829 | "Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n", |
1800 | GNUNET_HELLO_address_free (my_address); | 1830 | mac_to_string(&cm->mac), |
1801 | plugin->mac_address = cm->mac; | 1831 | GNUNET_i2s(plugin->env->my_identity)); |
1802 | } | 1832 | plugin->env->notify_address(plugin->env->cls, |
1803 | else | 1833 | GNUNET_YES, |
1804 | { | 1834 | my_address); |
1805 | plugin->mac_address = cm->mac; | 1835 | GNUNET_HELLO_address_free(my_address); |
1806 | plugin->have_mac = GNUNET_YES; | 1836 | break; |
1807 | for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next) | 1837 | |
1808 | { | 1838 | case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER: |
1809 | for (fm = endpoint->sending_messages_head; NULL != fm; fm = fm->next) | 1839 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1840 | "Got data message from helper with %u bytes\n", | ||
1841 | msize); | ||
1842 | GNUNET_STATISTICS_update(plugin->env->stats, | ||
1843 | _("# DATA messages received"), 1, | ||
1844 | GNUNET_NO); | ||
1845 | if (msize < sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)) | ||
1810 | { | 1846 | { |
1811 | if (NULL != fm->fragcontext) | 1847 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1812 | { | 1848 | "Size of packet is too small (%u bytes < %u)\n", |
1813 | GNUNET_break (0); /* should not happen */ | 1849 | msize, sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)); |
1814 | continue; | 1850 | break; |
1815 | } | ||
1816 | fm->fragcontext = | ||
1817 | GNUNET_FRAGMENT_context_create (plugin->env->stats, | ||
1818 | WLAN_MTU, | ||
1819 | &plugin->tracker, | ||
1820 | fm->macendpoint->msg_delay, | ||
1821 | fm->macendpoint->ack_delay, | ||
1822 | fm->msg, | ||
1823 | &transmit_fragment, fm); | ||
1824 | GNUNET_free (fm->msg); | ||
1825 | fm->msg = NULL; | ||
1826 | } | 1851 | } |
1827 | } | 1852 | rxinfo = (const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *)hdr; |
1828 | GNUNET_break (NULL == plugin->beacon_task); | ||
1829 | plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon, | ||
1830 | plugin); | ||
1831 | 1853 | ||
1832 | } | 1854 | /* check if message is actually for us */ |
1855 | if (0 != memcmp(&rxinfo->frame.addr3, &mac_bssid_gnunet, | ||
1856 | sizeof(struct GNUNET_TRANSPORT_WLAN_MacAddress))) | ||
1857 | { | ||
1858 | /* Not the GNUnet BSSID */ | ||
1859 | break; | ||
1860 | } | ||
1861 | if ((0 != memcmp(&rxinfo->frame.addr1, &bc_all_mac, | ||
1862 | sizeof(struct GNUNET_TRANSPORT_WLAN_MacAddress))) && | ||
1863 | (0 != memcmp(&rxinfo->frame.addr1, &plugin->mac_address, | ||
1864 | sizeof(struct GNUNET_TRANSPORT_WLAN_MacAddress)))) | ||
1865 | { | ||
1866 | /* Neither broadcast nor specifically for us */ | ||
1867 | break; | ||
1868 | } | ||
1869 | if (0 == memcmp(&rxinfo->frame.addr2, &plugin->mac_address, | ||
1870 | sizeof(struct GNUNET_TRANSPORT_WLAN_MacAddress))) | ||
1871 | { | ||
1872 | /* packet is FROM us, thus not FOR us */ | ||
1873 | break; | ||
1874 | } | ||
1833 | 1875 | ||
1834 | memset (&wa, 0, sizeof (struct WlanAddress)); | 1876 | GNUNET_STATISTICS_update(plugin->env->stats, |
1835 | wa.mac = plugin->mac_address; | 1877 | _("# DATA messages processed"), |
1836 | wa.options = htonl(plugin->options); | 1878 | 1, GNUNET_NO); |
1837 | my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity, | 1879 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1838 | PLUGIN_NAME, | 1880 | "Receiving %u bytes of data from MAC `%s'\n", |
1839 | &wa, sizeof (wa), | 1881 | (unsigned int)(msize - sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)), |
1840 | GNUNET_HELLO_ADDRESS_INFO_NONE); | 1882 | mac_to_string(&rxinfo->frame.addr2)); |
1841 | 1883 | LOG(GNUNET_ERROR_TYPE_DEBUG, | |
1842 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1884 | "Receiving %u bytes of data to MAC `%s'\n", |
1843 | "Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n", | 1885 | (unsigned int)(msize - sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)), |
1844 | mac_to_string (&cm->mac), | 1886 | mac_to_string(&rxinfo->frame.addr1)); |
1845 | GNUNET_i2s (plugin->env->my_identity)); | 1887 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1846 | plugin->env->notify_address (plugin->env->cls, | 1888 | "Receiving %u bytes of data with BSSID MAC `%s'\n", |
1847 | GNUNET_YES, | 1889 | (unsigned int)(msize - sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)), |
1848 | my_address); | 1890 | mac_to_string(&rxinfo->frame.addr3)); |
1849 | GNUNET_HELLO_address_free (my_address); | 1891 | wa.mac = rxinfo->frame.addr2; |
1850 | break; | 1892 | wa.options = htonl(0); |
1851 | case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER: | 1893 | mas.endpoint = create_macendpoint(plugin, &wa); |
1852 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1894 | mas.session = NULL; |
1853 | "Got data message from helper with %u bytes\n", | 1895 | (void)GNUNET_SERVER_mst_receive(plugin->helper_payload_tokenizer, |
1854 | msize); | 1896 | &mas, |
1855 | GNUNET_STATISTICS_update (plugin->env->stats, | 1897 | (const char*)&rxinfo[1], |
1856 | _("# DATA messages received"), 1, | 1898 | msize - sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage), |
1857 | GNUNET_NO); | 1899 | GNUNET_YES, GNUNET_NO); |
1858 | if (msize < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)) | ||
1859 | { | ||
1860 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1861 | "Size of packet is too small (%u bytes < %u)\n", | ||
1862 | msize, sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)); | ||
1863 | break; | 1900 | break; |
1864 | } | ||
1865 | rxinfo = (const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) hdr; | ||
1866 | 1901 | ||
1867 | /* check if message is actually for us */ | 1902 | default: |
1868 | if (0 != memcmp (&rxinfo->frame.addr3, &mac_bssid_gnunet, | 1903 | GNUNET_break(0); |
1869 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))) | 1904 | LOG(GNUNET_ERROR_TYPE_ERROR, |
1870 | { | 1905 | "Unexpected message of type %u (%u bytes)", |
1871 | /* Not the GNUnet BSSID */ | 1906 | ntohs(hdr->type), |
1907 | ntohs(hdr->size)); | ||
1872 | break; | 1908 | break; |
1873 | } | 1909 | } |
1874 | if ( (0 != memcmp (&rxinfo->frame.addr1, &bc_all_mac, | ||
1875 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))) && | ||
1876 | (0 != memcmp (&rxinfo->frame.addr1, &plugin->mac_address, | ||
1877 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))) ) | ||
1878 | { | ||
1879 | /* Neither broadcast nor specifically for us */ | ||
1880 | break; | ||
1881 | } | ||
1882 | if (0 == memcmp (&rxinfo->frame.addr2, &plugin->mac_address, | ||
1883 | sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))) | ||
1884 | { | ||
1885 | /* packet is FROM us, thus not FOR us */ | ||
1886 | break; | ||
1887 | } | ||
1888 | |||
1889 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1890 | _("# DATA messages processed"), | ||
1891 | 1, GNUNET_NO); | ||
1892 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1893 | "Receiving %u bytes of data from MAC `%s'\n", | ||
1894 | (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)), | ||
1895 | mac_to_string (&rxinfo->frame.addr2)); | ||
1896 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1897 | "Receiving %u bytes of data to MAC `%s'\n", | ||
1898 | (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)), | ||
1899 | mac_to_string (&rxinfo->frame.addr1)); | ||
1900 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1901 | "Receiving %u bytes of data with BSSID MAC `%s'\n", | ||
1902 | (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)), | ||
1903 | mac_to_string (&rxinfo->frame.addr3)); | ||
1904 | wa.mac = rxinfo->frame.addr2; | ||
1905 | wa.options = htonl (0); | ||
1906 | mas.endpoint = create_macendpoint (plugin, &wa); | ||
1907 | mas.session = NULL; | ||
1908 | (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer, | ||
1909 | &mas, | ||
1910 | (const char*) &rxinfo[1], | ||
1911 | msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage), | ||
1912 | GNUNET_YES, GNUNET_NO); | ||
1913 | break; | ||
1914 | default: | ||
1915 | GNUNET_break (0); | ||
1916 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
1917 | "Unexpected message of type %u (%u bytes)", | ||
1918 | ntohs (hdr->type), | ||
1919 | ntohs (hdr->size)); | ||
1920 | break; | ||
1921 | } | ||
1922 | return GNUNET_OK; | 1910 | return GNUNET_OK; |
1923 | } | 1911 | } |
1924 | 1912 | ||
@@ -1936,34 +1924,34 @@ handle_helper_message (void *cls, | |||
1936 | * and transport | 1924 | * and transport |
1937 | */ | 1925 | */ |
1938 | static int | 1926 | static int |
1939 | wlan_plugin_address_suggested (void *cls, | 1927 | wlan_plugin_address_suggested(void *cls, |
1940 | const void *addr, | 1928 | const void *addr, |
1941 | size_t addrlen) | 1929 | size_t addrlen) |
1942 | { | 1930 | { |
1943 | struct Plugin *plugin = cls; | 1931 | struct Plugin *plugin = cls; |
1944 | struct WlanAddress *wa = (struct WlanAddress *) addr; | 1932 | struct WlanAddress *wa = (struct WlanAddress *)addr; |
1945 | 1933 | ||
1946 | if (addrlen != sizeof (struct WlanAddress)) | 1934 | if (addrlen != sizeof(struct WlanAddress)) |
1947 | { | 1935 | { |
1948 | GNUNET_break_op (0); | 1936 | GNUNET_break_op(0); |
1949 | return GNUNET_SYSERR; | 1937 | return GNUNET_SYSERR; |
1950 | } | 1938 | } |
1951 | if (GNUNET_YES != plugin->have_mac) | 1939 | if (GNUNET_YES != plugin->have_mac) |
1952 | { | 1940 | { |
1953 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1941 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1954 | "Rejecting MAC `%s': I don't know my MAC!\n", | 1942 | "Rejecting MAC `%s': I don't know my MAC!\n", |
1955 | mac_to_string (addr)); | 1943 | mac_to_string(addr)); |
1956 | return GNUNET_NO; /* don't know my MAC */ | 1944 | return GNUNET_NO; /* don't know my MAC */ |
1957 | } | 1945 | } |
1958 | if (0 != memcmp (&wa->mac, | 1946 | if (0 != memcmp(&wa->mac, |
1959 | &plugin->mac_address, | 1947 | &plugin->mac_address, |
1960 | sizeof (wa->mac))) | 1948 | sizeof(wa->mac))) |
1961 | { | 1949 | { |
1962 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1950 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1963 | "Rejecting MAC `%s': not my MAC!\n", | 1951 | "Rejecting MAC `%s': not my MAC!\n", |
1964 | mac_to_string (addr)); | 1952 | mac_to_string(addr)); |
1965 | return GNUNET_NO; /* not my MAC */ | 1953 | return GNUNET_NO; /* not my MAC */ |
1966 | } | 1954 | } |
1967 | return GNUNET_OK; | 1955 | return GNUNET_OK; |
1968 | } | 1956 | } |
1969 | 1957 | ||
@@ -1982,27 +1970,27 @@ wlan_plugin_address_suggested (void *cls, | |||
1982 | * @param asc_cls closure for @a asc | 1970 | * @param asc_cls closure for @a asc |
1983 | */ | 1971 | */ |
1984 | static void | 1972 | static void |
1985 | wlan_plugin_address_pretty_printer (void *cls, | 1973 | wlan_plugin_address_pretty_printer(void *cls, |
1986 | const char *type, | 1974 | const char *type, |
1987 | const void *addr, | 1975 | const void *addr, |
1988 | size_t addrlen, | 1976 | size_t addrlen, |
1989 | int numeric, | 1977 | int numeric, |
1990 | struct GNUNET_TIME_Relative timeout, | 1978 | struct GNUNET_TIME_Relative timeout, |
1991 | GNUNET_TRANSPORT_AddressStringCallback asc, | 1979 | GNUNET_TRANSPORT_AddressStringCallback asc, |
1992 | void *asc_cls) | 1980 | void *asc_cls) |
1993 | { | 1981 | { |
1994 | const char *ret; | 1982 | const char *ret; |
1995 | 1983 | ||
1996 | if (sizeof (struct WlanAddress) == addrlen) | 1984 | if (sizeof(struct WlanAddress) == addrlen) |
1997 | ret = wlan_plugin_address_to_string (NULL, | 1985 | ret = wlan_plugin_address_to_string(NULL, |
1998 | addr, | 1986 | addr, |
1999 | addrlen); | 1987 | addrlen); |
2000 | else | 1988 | else |
2001 | ret = NULL; | 1989 | ret = NULL; |
2002 | asc (asc_cls, | 1990 | asc(asc_cls, |
2003 | ret, | 1991 | ret, |
2004 | (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK); | 1992 | (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK); |
2005 | asc (asc_cls, NULL, GNUNET_OK); | 1993 | asc(asc_cls, NULL, GNUNET_OK); |
2006 | } | 1994 | } |
2007 | 1995 | ||
2008 | 1996 | ||
@@ -2012,7 +2000,7 @@ wlan_plugin_address_pretty_printer (void *cls, | |||
2012 | * @param cls pointer to the api struct | 2000 | * @param cls pointer to the api struct |
2013 | */ | 2001 | */ |
2014 | void * | 2002 | void * |
2015 | LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | 2003 | LIBGNUNET_PLUGIN_TRANSPORT_DONE(void *cls) |
2016 | { | 2004 | { |
2017 | struct WlanAddress wa; | 2005 | struct WlanAddress wa; |
2018 | struct GNUNET_HELLO_Address *address; | 2006 | struct GNUNET_HELLO_Address *address; |
@@ -2022,62 +2010,62 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | |||
2022 | struct MacEndpoint *endpoint_next; | 2010 | struct MacEndpoint *endpoint_next; |
2023 | 2011 | ||
2024 | if (NULL == plugin) | 2012 | if (NULL == plugin) |
2025 | { | 2013 | { |
2026 | GNUNET_free (api); | 2014 | GNUNET_free(api); |
2027 | return NULL; | 2015 | return NULL; |
2028 | } | 2016 | } |
2029 | if (GNUNET_YES == plugin->have_mac) | 2017 | if (GNUNET_YES == plugin->have_mac) |
2030 | { | 2018 | { |
2031 | memset (&wa, 0, sizeof(wa)); | 2019 | memset(&wa, 0, sizeof(wa)); |
2032 | wa.options = htonl (plugin->options); | 2020 | wa.options = htonl(plugin->options); |
2033 | wa.mac = plugin->mac_address; | 2021 | wa.mac = plugin->mac_address; |
2034 | address = GNUNET_HELLO_address_allocate (plugin->env->my_identity, | 2022 | address = GNUNET_HELLO_address_allocate(plugin->env->my_identity, |
2035 | PLUGIN_NAME, | 2023 | PLUGIN_NAME, |
2036 | &wa, sizeof (struct WlanAddress), | 2024 | &wa, sizeof(struct WlanAddress), |
2037 | GNUNET_HELLO_ADDRESS_INFO_NONE); | 2025 | GNUNET_HELLO_ADDRESS_INFO_NONE); |
2038 | 2026 | ||
2039 | plugin->env->notify_address (plugin->env->cls, | 2027 | plugin->env->notify_address(plugin->env->cls, |
2040 | GNUNET_NO, | 2028 | GNUNET_NO, |
2041 | address); | 2029 | address); |
2042 | plugin->have_mac = GNUNET_NO; | 2030 | plugin->have_mac = GNUNET_NO; |
2043 | GNUNET_HELLO_address_free (address); | 2031 | GNUNET_HELLO_address_free(address); |
2044 | } | 2032 | } |
2045 | 2033 | ||
2046 | if (NULL != plugin->beacon_task) | 2034 | if (NULL != plugin->beacon_task) |
2047 | { | 2035 | { |
2048 | GNUNET_SCHEDULER_cancel (plugin->beacon_task); | 2036 | GNUNET_SCHEDULER_cancel(plugin->beacon_task); |
2049 | plugin->beacon_task = NULL; | 2037 | plugin->beacon_task = NULL; |
2050 | } | 2038 | } |
2051 | if (NULL != plugin->suid_helper) | 2039 | if (NULL != plugin->suid_helper) |
2052 | { | 2040 | { |
2053 | GNUNET_HELPER_stop (plugin->suid_helper, | 2041 | GNUNET_HELPER_stop(plugin->suid_helper, |
2054 | GNUNET_NO); | 2042 | GNUNET_NO); |
2055 | plugin->suid_helper = NULL; | 2043 | plugin->suid_helper = NULL; |
2056 | } | 2044 | } |
2057 | endpoint_next = plugin->mac_head; | 2045 | endpoint_next = plugin->mac_head; |
2058 | while (NULL != (endpoint = endpoint_next)) | 2046 | while (NULL != (endpoint = endpoint_next)) |
2059 | { | 2047 | { |
2060 | endpoint_next = endpoint->next; | 2048 | endpoint_next = endpoint->next; |
2061 | free_macendpoint (endpoint); | 2049 | free_macendpoint(endpoint); |
2062 | } | 2050 | } |
2063 | if (NULL != plugin->fragment_data_tokenizer) | 2051 | if (NULL != plugin->fragment_data_tokenizer) |
2064 | { | 2052 | { |
2065 | GNUNET_SERVER_mst_destroy (plugin->fragment_data_tokenizer); | 2053 | GNUNET_SERVER_mst_destroy(plugin->fragment_data_tokenizer); |
2066 | plugin->fragment_data_tokenizer = NULL; | 2054 | plugin->fragment_data_tokenizer = NULL; |
2067 | } | 2055 | } |
2068 | if (NULL != plugin->wlan_header_payload_tokenizer) | 2056 | if (NULL != plugin->wlan_header_payload_tokenizer) |
2069 | { | 2057 | { |
2070 | GNUNET_SERVER_mst_destroy (plugin->wlan_header_payload_tokenizer); | 2058 | GNUNET_SERVER_mst_destroy(plugin->wlan_header_payload_tokenizer); |
2071 | plugin->wlan_header_payload_tokenizer = NULL; | 2059 | plugin->wlan_header_payload_tokenizer = NULL; |
2072 | } | 2060 | } |
2073 | if (NULL != plugin->helper_payload_tokenizer) | 2061 | if (NULL != plugin->helper_payload_tokenizer) |
2074 | { | 2062 | { |
2075 | GNUNET_SERVER_mst_destroy (plugin->helper_payload_tokenizer); | 2063 | GNUNET_SERVER_mst_destroy(plugin->helper_payload_tokenizer); |
2076 | plugin->helper_payload_tokenizer = NULL; | 2064 | plugin->helper_payload_tokenizer = NULL; |
2077 | } | 2065 | } |
2078 | GNUNET_free_non_null (plugin->wlan_interface); | 2066 | GNUNET_free_non_null(plugin->wlan_interface); |
2079 | GNUNET_free (plugin); | 2067 | GNUNET_free(plugin); |
2080 | GNUNET_free (api); | 2068 | GNUNET_free(api); |
2081 | return NULL; | 2069 | return NULL; |
2082 | } | 2070 | } |
2083 | 2071 | ||
@@ -2095,11 +2083,11 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | |||
2095 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 2083 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
2096 | */ | 2084 | */ |
2097 | static int | 2085 | static int |
2098 | wlan_plugin_string_to_address (void *cls, | 2086 | wlan_plugin_string_to_address(void *cls, |
2099 | const char *addr, | 2087 | const char *addr, |
2100 | uint16_t addrlen, | 2088 | uint16_t addrlen, |
2101 | void **buf, | 2089 | void **buf, |
2102 | size_t *added) | 2090 | size_t *added) |
2103 | { | 2091 | { |
2104 | struct WlanAddress *wa; | 2092 | struct WlanAddress *wa; |
2105 | unsigned int a[6]; | 2093 | unsigned int a[6]; |
@@ -2108,36 +2096,36 @@ wlan_plugin_string_to_address (void *cls, | |||
2108 | uint32_t options; | 2096 | uint32_t options; |
2109 | 2097 | ||
2110 | if ((NULL == addr) || (0 == addrlen)) | 2098 | if ((NULL == addr) || (0 == addrlen)) |
2111 | { | 2099 | { |
2112 | GNUNET_break (0); | 2100 | GNUNET_break(0); |
2113 | return GNUNET_SYSERR; | 2101 | return GNUNET_SYSERR; |
2114 | } | 2102 | } |
2115 | if ('\0' != addr[addrlen - 1]) | 2103 | if ('\0' != addr[addrlen - 1]) |
2116 | { | 2104 | { |
2117 | GNUNET_break (0); | 2105 | GNUNET_break(0); |
2118 | return GNUNET_SYSERR; | 2106 | return GNUNET_SYSERR; |
2119 | } | 2107 | } |
2120 | if (strlen (addr) != addrlen - 1) | 2108 | if (strlen(addr) != addrlen - 1) |
2121 | { | 2109 | { |
2122 | GNUNET_break (0); | 2110 | GNUNET_break(0); |
2123 | return GNUNET_SYSERR; | 2111 | return GNUNET_SYSERR; |
2124 | } | 2112 | } |
2125 | 2113 | ||
2126 | if (8 != SSCANF (addr, | 2114 | if (8 != SSCANF(addr, |
2127 | "%4s.%u.%X:%X:%X:%X:%X:%X", | 2115 | "%4s.%u.%X:%X:%X:%X:%X:%X", |
2128 | plugin, &options, | 2116 | plugin, &options, |
2129 | &a[0], &a[1], &a[2], | 2117 | &a[0], &a[1], &a[2], |
2130 | &a[3], &a[4], &a[5])) | 2118 | &a[3], &a[4], &a[5])) |
2131 | { | 2119 | { |
2132 | GNUNET_break (0); | 2120 | GNUNET_break(0); |
2133 | return GNUNET_SYSERR; | 2121 | return GNUNET_SYSERR; |
2134 | } | 2122 | } |
2135 | wa = GNUNET_new (struct WlanAddress); | 2123 | wa = GNUNET_new(struct WlanAddress); |
2136 | for (i=0;i<6;i++) | 2124 | for (i = 0; i < 6; i++) |
2137 | wa->mac.mac[i] = a[i]; | 2125 | wa->mac.mac[i] = a[i]; |
2138 | wa->options = htonl (0); | 2126 | wa->options = htonl(0); |
2139 | *buf = wa; | 2127 | *buf = wa; |
2140 | *added = sizeof (struct WlanAddress); | 2128 | *added = sizeof(struct WlanAddress); |
2141 | return GNUNET_OK; | 2129 | return GNUNET_OK; |
2142 | } | 2130 | } |
2143 | 2131 | ||
@@ -2155,9 +2143,9 @@ wlan_plugin_string_to_address (void *cls, | |||
2155 | * @param sic_cls closure for @a sic | 2143 | * @param sic_cls closure for @a sic |
2156 | */ | 2144 | */ |
2157 | static void | 2145 | static void |
2158 | wlan_plugin_setup_monitor (void *cls, | 2146 | wlan_plugin_setup_monitor(void *cls, |
2159 | GNUNET_TRANSPORT_SessionInfoCallback sic, | 2147 | GNUNET_TRANSPORT_SessionInfoCallback sic, |
2160 | void *sic_cls) | 2148 | void *sic_cls) |
2161 | { | 2149 | { |
2162 | struct Plugin *plugin = cls; | 2150 | struct Plugin *plugin = cls; |
2163 | struct MacEndpoint *mac; | 2151 | struct MacEndpoint *mac; |
@@ -2166,19 +2154,19 @@ wlan_plugin_setup_monitor (void *cls, | |||
2166 | plugin->sic = sic; | 2154 | plugin->sic = sic; |
2167 | plugin->sic_cls = sic_cls; | 2155 | plugin->sic_cls = sic_cls; |
2168 | if (NULL != sic) | 2156 | if (NULL != sic) |
2169 | { | 2157 | { |
2170 | for (mac = plugin->mac_head; NULL != mac; mac = mac->next) | 2158 | for (mac = plugin->mac_head; NULL != mac; mac = mac->next) |
2171 | for (session = mac->sessions_head; NULL != session; session = session->next) | 2159 | for (session = mac->sessions_head; NULL != session; session = session->next) |
2172 | { | 2160 | { |
2173 | notify_session_monitor (plugin, | 2161 | notify_session_monitor(plugin, |
2174 | session, | 2162 | session, |
2175 | GNUNET_TRANSPORT_SS_INIT); | 2163 | GNUNET_TRANSPORT_SS_INIT); |
2176 | notify_session_monitor (plugin, | 2164 | notify_session_monitor(plugin, |
2177 | session, | 2165 | session, |
2178 | GNUNET_TRANSPORT_SS_UP); | 2166 | GNUNET_TRANSPORT_SS_UP); |
2179 | } | 2167 | } |
2180 | sic (sic_cls, NULL, NULL); | 2168 | sic(sic_cls, NULL, NULL); |
2181 | } | 2169 | } |
2182 | } | 2170 | } |
2183 | 2171 | ||
2184 | 2172 | ||
@@ -2193,12 +2181,12 @@ wlan_plugin_setup_monitor (void *cls, | |||
2193 | * @param session which session is being updated | 2181 | * @param session which session is being updated |
2194 | */ | 2182 | */ |
2195 | static void | 2183 | static void |
2196 | wlan_plugin_update_session_timeout (void *cls, | 2184 | wlan_plugin_update_session_timeout(void *cls, |
2197 | const struct GNUNET_PeerIdentity *peer, | 2185 | const struct GNUNET_PeerIdentity *peer, |
2198 | struct GNUNET_ATS_Session *session) | 2186 | struct GNUNET_ATS_Session *session) |
2199 | { | 2187 | { |
2200 | GNUNET_assert (NULL != session->timeout_task); | 2188 | GNUNET_assert(NULL != session->timeout_task); |
2201 | session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 2189 | session->timeout = GNUNET_TIME_relative_to_absolute(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
2202 | } | 2190 | } |
2203 | 2191 | ||
2204 | 2192 | ||
@@ -2213,10 +2201,10 @@ wlan_plugin_update_session_timeout (void *cls, | |||
2213 | * @param delay new delay to use for receiving | 2201 | * @param delay new delay to use for receiving |
2214 | */ | 2202 | */ |
2215 | static void | 2203 | static void |
2216 | wlan_plugin_update_inbound_delay (void *cls, | 2204 | wlan_plugin_update_inbound_delay(void *cls, |
2217 | const struct GNUNET_PeerIdentity *peer, | 2205 | const struct GNUNET_PeerIdentity *peer, |
2218 | struct GNUNET_ATS_Session *session, | 2206 | struct GNUNET_ATS_Session *session, |
2219 | struct GNUNET_TIME_Relative delay) | 2207 | struct GNUNET_TIME_Relative delay) |
2220 | { | 2208 | { |
2221 | /* does nothing, as inbound delay is not supported by WLAN */ | 2209 | /* does nothing, as inbound delay is not supported by WLAN */ |
2222 | } | 2210 | } |
@@ -2229,7 +2217,7 @@ wlan_plugin_update_inbound_delay (void *cls, | |||
2229 | * @return the `struct GNUNET_TRANSPORT_PluginFunctions *` or NULL on error | 2217 | * @return the `struct GNUNET_TRANSPORT_PluginFunctions *` or NULL on error |
2230 | */ | 2218 | */ |
2231 | void * | 2219 | void * |
2232 | LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | 2220 | LIBGNUNET_PLUGIN_TRANSPORT_INIT(void *cls) |
2233 | { | 2221 | { |
2234 | struct GNUNET_TRANSPORT_PluginEnvironment *env = cls; | 2222 | struct GNUNET_TRANSPORT_PluginEnvironment *env = cls; |
2235 | struct GNUNET_TRANSPORT_PluginFunctions *api; | 2223 | struct GNUNET_TRANSPORT_PluginFunctions *api; |
@@ -2240,124 +2228,127 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
2240 | 2228 | ||
2241 | /* check for 'special' mode */ | 2229 | /* check for 'special' mode */ |
2242 | if (NULL == env->receive) | 2230 | if (NULL == env->receive) |
2243 | { | 2231 | { |
2244 | /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully | 2232 | /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully |
2245 | initialze the plugin or the API */ | 2233 | initialze the plugin or the API */ |
2246 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); | 2234 | api = GNUNET_new(struct GNUNET_TRANSPORT_PluginFunctions); |
2247 | api->cls = NULL; | 2235 | api->cls = NULL; |
2248 | api->address_pretty_printer = &wlan_plugin_address_pretty_printer; | 2236 | api->address_pretty_printer = &wlan_plugin_address_pretty_printer; |
2249 | api->address_to_string = &wlan_plugin_address_to_string; | 2237 | api->address_to_string = &wlan_plugin_address_to_string; |
2250 | api->string_to_address = &wlan_plugin_string_to_address; | 2238 | api->string_to_address = &wlan_plugin_string_to_address; |
2251 | return api; | 2239 | return api; |
2252 | } | 2240 | } |
2253 | 2241 | ||
2254 | testmode = 0; | 2242 | testmode = 0; |
2255 | /* check configuration */ | 2243 | /* check configuration */ |
2256 | if ( (GNUNET_YES == | 2244 | if ((GNUNET_YES == |
2257 | GNUNET_CONFIGURATION_have_value (env->cfg, | 2245 | GNUNET_CONFIGURATION_have_value(env->cfg, |
2258 | CONFIG_NAME, | 2246 | CONFIG_NAME, |
2259 | "TESTMODE")) && | 2247 | "TESTMODE")) && |
2260 | ( (GNUNET_SYSERR == | 2248 | ((GNUNET_SYSERR == |
2261 | GNUNET_CONFIGURATION_get_value_number (env->cfg, | 2249 | GNUNET_CONFIGURATION_get_value_number(env->cfg, |
2262 | CONFIG_NAME, | 2250 | CONFIG_NAME, |
2263 | "TESTMODE", | 2251 | "TESTMODE", |
2264 | &testmode)) || | 2252 | &testmode)) || |
2265 | (testmode > 2) ) ) | 2253 | (testmode > 2))) |
2266 | { | 2254 | { |
2267 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 2255 | GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, |
2268 | CONFIG_NAME, | 2256 | CONFIG_NAME, |
2269 | "TESTMODE"); | 2257 | "TESTMODE"); |
2270 | return NULL; | 2258 | return NULL; |
2271 | } | 2259 | } |
2272 | binary = GNUNET_OS_get_libexec_binary_path (HELPER_NAME); | 2260 | binary = GNUNET_OS_get_libexec_binary_path(HELPER_NAME); |
2273 | if ( (0 == testmode) && | 2261 | if ((0 == testmode) && |
2274 | (GNUNET_YES != | 2262 | (GNUNET_YES != |
2275 | GNUNET_OS_check_helper_binary (binary, | 2263 | GNUNET_OS_check_helper_binary(binary, |
2276 | GNUNET_YES, | 2264 | GNUNET_YES, |
2277 | NULL)) ) | 2265 | NULL))) |
2278 | { | 2266 | { |
2279 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2267 | LOG(GNUNET_ERROR_TYPE_ERROR, |
2280 | _("Helper binary `%s' not SUID, cannot run WLAN transport\n"), | 2268 | _("Helper binary `%s' not SUID, cannot run WLAN transport\n"), |
2281 | HELPER_NAME); | 2269 | HELPER_NAME); |
2282 | GNUNET_free (binary); | 2270 | GNUNET_free(binary); |
2283 | return NULL; | 2271 | return NULL; |
2284 | } | 2272 | } |
2285 | GNUNET_free (binary); | 2273 | GNUNET_free(binary); |
2286 | if (GNUNET_YES != | 2274 | if (GNUNET_YES != |
2287 | GNUNET_CONFIGURATION_get_value_string (env->cfg, | 2275 | GNUNET_CONFIGURATION_get_value_string(env->cfg, |
2288 | CONFIG_NAME, | 2276 | CONFIG_NAME, |
2289 | "INTERFACE", | 2277 | "INTERFACE", |
2290 | &wlan_interface)) | 2278 | &wlan_interface)) |
2291 | { | 2279 | { |
2292 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 2280 | GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, |
2293 | CONFIG_NAME, | 2281 | CONFIG_NAME, |
2294 | "INTERFACE"); | 2282 | "INTERFACE"); |
2295 | return NULL; | 2283 | return NULL; |
2296 | } | 2284 | } |
2297 | 2285 | ||
2298 | plugin = GNUNET_new (struct Plugin); | 2286 | plugin = GNUNET_new(struct Plugin); |
2299 | plugin->wlan_interface = wlan_interface; | 2287 | plugin->wlan_interface = wlan_interface; |
2300 | plugin->env = env; | 2288 | plugin->env = env; |
2301 | GNUNET_STATISTICS_set (plugin->env->stats, | 2289 | GNUNET_STATISTICS_set(plugin->env->stats, |
2302 | _("# sessions allocated"), | 2290 | _("# sessions allocated"), |
2303 | 0, GNUNET_NO); | 2291 | 0, GNUNET_NO); |
2304 | GNUNET_STATISTICS_set (plugin->env->stats, | 2292 | GNUNET_STATISTICS_set(plugin->env->stats, |
2305 | _("# MAC endpoints allocated"), | 2293 | _("# MAC endpoints allocated"), |
2306 | 0, 0); | 2294 | 0, 0); |
2307 | GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, NULL, NULL, | 2295 | GNUNET_BANDWIDTH_tracker_init(&plugin->tracker, NULL, NULL, |
2308 | GNUNET_BANDWIDTH_value_init (100 * 1024 * | 2296 | GNUNET_BANDWIDTH_value_init(100 * 1024 * |
2309 | 1024 / 8), | 2297 | 1024 / 8), |
2310 | 100); | 2298 | 100); |
2311 | plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, | 2299 | plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create(&process_data, |
2300 | plugin); | ||
2301 | plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create(&process_data, | ||
2302 | plugin); | ||
2303 | plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create(&process_data, | ||
2312 | plugin); | 2304 | plugin); |
2313 | plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, | ||
2314 | plugin); | ||
2315 | plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, | ||
2316 | plugin); | ||
2317 | 2305 | ||
2318 | plugin->options = 0; | 2306 | plugin->options = 0; |
2319 | 2307 | ||
2320 | /* some compilers do not like switch on 'long long'... */ | 2308 | /* some compilers do not like switch on 'long long'... */ |
2321 | switch ((unsigned int) testmode) | 2309 | switch ((unsigned int)testmode) |
2322 | { | 2310 | { |
2323 | case 0: /* normal */ | 2311 | case 0: /* normal */ |
2324 | plugin->helper_argv[0] = (char *) HELPER_NAME; | 2312 | plugin->helper_argv[0] = (char *)HELPER_NAME; |
2325 | plugin->helper_argv[1] = wlan_interface; | 2313 | plugin->helper_argv[1] = wlan_interface; |
2326 | plugin->helper_argv[2] = NULL; | 2314 | plugin->helper_argv[2] = NULL; |
2327 | plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO, | 2315 | plugin->suid_helper = GNUNET_HELPER_start(GNUNET_NO, |
2328 | HELPER_NAME, | 2316 | HELPER_NAME, |
2329 | plugin->helper_argv, | 2317 | plugin->helper_argv, |
2330 | &handle_helper_message, | 2318 | &handle_helper_message, |
2331 | NULL, | 2319 | NULL, |
2332 | plugin); | 2320 | plugin); |
2333 | break; | 2321 | break; |
2334 | case 1: /* testmode, peer 1 */ | 2322 | |
2335 | plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME; | 2323 | case 1: /* testmode, peer 1 */ |
2336 | plugin->helper_argv[1] = (char *) "1"; | 2324 | plugin->helper_argv[0] = (char *)DUMMY_HELPER_NAME; |
2337 | plugin->helper_argv[2] = NULL; | 2325 | plugin->helper_argv[1] = (char *)"1"; |
2338 | plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO, | 2326 | plugin->helper_argv[2] = NULL; |
2339 | DUMMY_HELPER_NAME, | 2327 | plugin->suid_helper = GNUNET_HELPER_start(GNUNET_NO, |
2340 | plugin->helper_argv, | 2328 | DUMMY_HELPER_NAME, |
2341 | &handle_helper_message, | 2329 | plugin->helper_argv, |
2342 | NULL, | 2330 | &handle_helper_message, |
2343 | plugin); | 2331 | NULL, |
2344 | break; | 2332 | plugin); |
2345 | case 2: /* testmode, peer 2 */ | 2333 | break; |
2346 | plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME; | 2334 | |
2347 | plugin->helper_argv[1] = (char *) "2"; | 2335 | case 2: /* testmode, peer 2 */ |
2348 | plugin->helper_argv[2] = NULL; | 2336 | plugin->helper_argv[0] = (char *)DUMMY_HELPER_NAME; |
2349 | plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO, | 2337 | plugin->helper_argv[1] = (char *)"2"; |
2350 | DUMMY_HELPER_NAME, | 2338 | plugin->helper_argv[2] = NULL; |
2351 | plugin->helper_argv, | 2339 | plugin->suid_helper = GNUNET_HELPER_start(GNUNET_NO, |
2352 | &handle_helper_message, | 2340 | DUMMY_HELPER_NAME, |
2353 | NULL, | 2341 | plugin->helper_argv, |
2354 | plugin); | 2342 | &handle_helper_message, |
2355 | break; | 2343 | NULL, |
2356 | default: | 2344 | plugin); |
2357 | GNUNET_assert (0); | 2345 | break; |
2358 | } | 2346 | |
2347 | default: | ||
2348 | GNUNET_assert(0); | ||
2349 | } | ||
2359 | 2350 | ||
2360 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); | 2351 | api = GNUNET_new(struct GNUNET_TRANSPORT_PluginFunctions); |
2361 | api->cls = plugin; | 2352 | api->cls = plugin; |
2362 | api->send = &wlan_plugin_send; | 2353 | api->send = &wlan_plugin_send; |
2363 | api->get_session = &wlan_plugin_get_session; | 2354 | api->get_session = &wlan_plugin_get_session; |