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