2 This file is part of GNUnet
3 (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file transport/plugin_transport_wlan.c
23 * @brief transport plugin for wlan
24 * @author David Brodski
25 * @author Christian Grothoff
28 * - HELPER-continuation may be called after fragment times out (-> use after free, see FIXME)
31 #include "gnunet_hello_lib.h"
32 #include "gnunet_protocols.h"
33 #include "gnunet_util_lib.h"
34 #include "gnunet_statistics_service.h"
35 #include "gnunet_transport_service.h"
36 #include "gnunet_transport_plugin.h"
37 #include "plugin_transport_wlan.h"
38 #include "gnunet_common.h"
39 #include "gnunet_crypto_lib.h"
40 #include "gnunet_fragmentation_lib.h"
41 #include "gnunet_constants.h"
43 #define PROTOCOL_PREFIX "wlan"
45 #define LOG(kind,...) GNUNET_log_from (kind, "transport-wlan",__VA_ARGS__)
48 * Max size of packet (that we give to the WLAN driver for transmission)
53 * time out of a mac endpoint
55 #define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2)
58 * We reduce the frequence of HELLO beacons in relation to
59 * the number of MAC addresses currently visible to us.
60 * This is the multiplication factor.
62 #define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
65 * Maximum number of messages in defragmentation queue per MAC
67 #define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC 2
70 * Link layer control fields for better compatibility
71 * (i.e. GNUnet over WLAN is not IP-over-WLAN).
73 #define WLAN_LLC_DSAP_FIELD 0x1f
74 #define WLAN_LLC_SSAP_FIELD 0x1f
77 GNUNET_NETWORK_STRUCT_BEGIN
79 * Header for messages which need fragmentation. This is the format of
80 * a message we obtain AFTER defragmentation. We then need to check
81 * the CRC and then tokenize the payload and pass it to the
88 * Message type is GNUNET_MESSAGE_TYPE_WLAN_DATA.
90 struct GNUNET_MessageHeader header;
93 * CRC32 checksum (only over the payload), in NBO.
95 uint32_t crc GNUNET_PACKED;
98 * Sender of the message.
100 struct GNUNET_PeerIdentity sender;
103 * Target of the message.
105 struct GNUNET_PeerIdentity target;
107 /* followed by payload, possibly including
108 multiple messages! */
111 GNUNET_NETWORK_STRUCT_END
115 * Information kept for each message that is yet to be fragmented and
118 struct PendingMessage
121 * next entry in the DLL
123 struct PendingMessage *next;
126 * previous entry in the DLL
128 struct PendingMessage *prev;
131 * The pending message
133 struct WlanHeader *msg;
136 * Continuation function to call once the message
137 * has been sent. Can be NULL if there is no
138 * continuation to call.
140 GNUNET_TRANSPORT_TransmitContinuation transmit_cont;
143 * Cls for transmit_cont
145 void *transmit_cont_cls;
148 * Timeout task (for this message).
150 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
156 * Session handle for connections with other peers.
162 * API requirement (must be first).
164 struct SessionHeader header;
167 * We keep all sessions in a DLL at their respective
168 * 'struct MACEndpoint'.
170 struct Session *next;
173 * We keep all sessions in a DLL at their respective
174 * 'struct MACEndpoint'.
176 struct Session *prev;
179 * MAC endpoint with the address of this peer.
181 struct MacEndpoint *mac;
184 * Head of messages currently pending for transmission to this peer.
186 struct PendingMessage *pending_message_head;
189 * Tail of messages currently pending for transmission to this peer.
191 struct PendingMessage *pending_message_tail;
194 * To whom are we talking to (set to our identity
195 * if we are still waiting for the welcome message)
197 struct GNUNET_PeerIdentity target;
200 * When should this session time out?
202 struct GNUNET_TIME_Absolute timeout;
205 * Timeout task (for the session).
207 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
213 * Struct for messages that are being fragmented in a MAC's transmission queue.
215 struct FragmentMessage
219 * This is a doubly-linked list.
221 struct FragmentMessage *next;
224 * This is a doubly-linked list.
226 struct FragmentMessage *prev;
229 * MAC endpoint this message belongs to
231 struct MacEndpoint *macendpoint;
234 * Fragmentation context
236 struct GNUNET_FRAGMENT_Context *fragcontext;
239 * Transmission handle to helper (to cancel if the frag context
240 * is destroyed early for some reason).
242 struct GNUNET_HELPER_SendHandle *sh;
245 * Intended recipient.
247 struct GNUNET_PeerIdentity target;
250 * Timeout value for the message.
252 struct GNUNET_TIME_Absolute timeout;
257 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
260 * Continuation to call when we're done with this message.
262 GNUNET_TRANSPORT_TransmitContinuation cont;
273 * Struct to represent one network card connection
279 * We keep all MACs in a DLL in the plugin.
281 struct MacEndpoint *next;
284 * We keep all MACs in a DLL in the plugin.
286 struct MacEndpoint *prev;
289 * Pointer to the global plugin struct.
291 struct Plugin *plugin;
294 * Head of sessions that use this MAC.
296 struct Session *sessions_head;
299 * Tail of sessions that use this MAC.
301 struct Session *sessions_tail;
304 * Head of messages we are currently sending to this MAC.
306 struct FragmentMessage *sending_messages_head;
309 * Tail of messages we are currently sending to this MAC.
311 struct FragmentMessage *sending_messages_tail;
314 * Defrag context for this MAC
316 struct GNUNET_DEFRAGMENT_Context *defrag;
319 * When should this endpoint time out?
321 struct GNUNET_TIME_Absolute timeout;
326 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
329 * count of messages in the fragment out queue for this mac endpoint
331 unsigned int fragment_messages_out_count;
336 struct GNUNET_TRANSPORT_WLAN_MacAddress addr;
339 * Desired transmission power for this MAC
344 * Desired transmission rate for this MAC
349 * Antenna we should use for this MAC
357 * Encapsulation of all of the state of the plugin.
364 struct GNUNET_TRANSPORT_PluginEnvironment *env;
367 * Handle to helper process for priviledged operations.
369 struct GNUNET_HELPER_Handle *suid_helper;
372 * ARGV-vector for the helper (all helpers take only the binary
373 * name, one actual argument, plus the NULL terminator for 'argv').
375 char * helper_argv[3];
378 * The interface of the wlan card given to us by the user.
383 * Tokenizer for demultiplexing of data packets resulting from defragmentation.
385 struct GNUNET_SERVER_MessageStreamTokenizer *fragment_data_tokenizer;
388 * Tokenizer for demultiplexing of data packets received from the suid helper
390 struct GNUNET_SERVER_MessageStreamTokenizer *helper_payload_tokenizer;
393 * Tokenizer for demultiplexing of data packets that follow the WLAN Header
395 struct GNUNET_SERVER_MessageStreamTokenizer *wlan_header_payload_tokenizer;
398 * Head of list of open connections.
400 struct MacEndpoint *mac_head;
403 * Tail of list of open connections.
405 struct MacEndpoint *mac_tail;
408 * Number of connections
410 unsigned int mac_count;
413 * Task that periodically sends a HELLO beacon via the helper.
415 GNUNET_SCHEDULER_TaskIdentifier beacon_task;
418 * Tracker for bandwidth limit
420 struct GNUNET_BANDWIDTH_Tracker tracker;
423 * The mac_address of the wlan card given to us by the helper.
425 struct GNUNET_TRANSPORT_WLAN_MacAddress mac_address;
428 * Have we received a control message with our MAC address yet?
437 * Information associated with a message. Can contain
438 * the session or the MAC endpoint associated with the
444 * NULL if the identity of the other peer is not known.
446 struct Session *session;
449 * MAC address of the other peer, NULL if not known.
451 struct MacEndpoint *endpoint;
456 * Print MAC addresses nicely.
458 * @param mac the mac address
459 * @return string to a static buffer with the human-readable mac, will be overwritten during the next call to this function
462 mac_to_string (const struct GNUNET_TRANSPORT_WLAN_MacAddress * mac)
464 static char macstr[20];
466 GNUNET_snprintf (macstr, sizeof (macstr), "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", mac->mac[0], mac->mac[1],
467 mac->mac[2], mac->mac[3], mac->mac[4], mac->mac[5]);
473 * Fill the radiotap header
475 * @param endpoint pointer to the endpoint, can be NULL
476 * @param header pointer to the radiotap header
477 * @param size total message size
480 get_radiotap_header (struct MacEndpoint *endpoint,
481 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header,
484 header->header.type = ntohs (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER);
485 header->header.size = ntohs (size);
486 if (NULL != endpoint)
488 header->rate = endpoint->rate;
489 header->tx_power = endpoint->tx_power;
490 header->antenna = endpoint->antenna;
495 header->tx_power = 0;
502 * Generate the WLAN hardware header for one packet
504 * @param header address to write the header to
505 * @param to_mac_addr address of the recipient
506 * @param size size of the whole packet, needed to calculate the time to send the packet
509 get_wlan_header (struct Plugin *plugin,
510 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header,
511 const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr,
514 const int rate = 11000000;
516 header->frame_control = htons (IEEE80211_FC0_TYPE_DATA);
517 header->addr1 = *to_mac_addr;
518 header->addr2 = plugin->mac_address;
519 header->addr3 = mac_bssid_gnunet;
520 header->duration = GNUNET_htole16 ((size * 1000000) / rate + 290);
521 header->sequence_control = 0; // FIXME?
522 header->llc[0] = WLAN_LLC_DSAP_FIELD;
523 header->llc[1] = WLAN_LLC_SSAP_FIELD;
524 header->llc[2] = 0; // FIXME?
525 header->llc[3] = 0; // FIXME?
530 * Send an ACK for a fragment we received.
532 * @param cls the 'struct MacEndpoint' the ACK must be sent to
533 * @param msg_id id of the message
534 * @param hdr pointer to the hdr where the ack is stored
537 send_ack (void *cls, uint32_t msg_id,
538 const struct GNUNET_MessageHeader *hdr)
540 struct MacEndpoint *endpoint = cls;
541 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage* radio_header;
542 uint16_t msize = ntohs (hdr->size);
543 size_t size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize;
546 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
551 LOG (GNUNET_ERROR_TYPE_DEBUG,
552 "Sending ACK to helper\n");
553 radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
554 get_radiotap_header (endpoint, radio_header, size);
555 get_wlan_header (endpoint->plugin,
556 &radio_header->frame,
559 memcpy (&radio_header[1], hdr, msize);
561 GNUNET_HELPER_send (endpoint->plugin->suid_helper,
562 &radio_header->header,
563 GNUNET_NO /* dropping ACKs is bad */,
565 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN ACKs sent"),
571 * Handles the data after all fragments are put together
573 * @param cls macendpoint this messages belongs to
574 * @param hdr pointer to the data
577 wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
579 struct MacEndpoint *endpoint = cls;
580 struct Plugin *plugin = endpoint->plugin;
581 struct MacAndSession mas;
583 GNUNET_STATISTICS_update (plugin->env->stats,
584 _("# WLAN messages defragmented"), 1,
587 mas.endpoint = endpoint;
588 (void) GNUNET_SERVER_mst_receive (plugin->fragment_data_tokenizer,
592 GNUNET_YES, GNUNET_NO);
599 * @param session the session free
602 free_session (struct Session *session)
604 struct MacEndpoint *endpoint = session->mac;
605 struct PendingMessage *pm;
607 endpoint->plugin->env->session_end (endpoint->plugin->env->cls,
610 while (NULL != (pm = session->pending_message_head))
612 GNUNET_CONTAINER_DLL_remove (session->pending_message_head,
613 session->pending_message_tail, pm);
614 if (GNUNET_SCHEDULER_NO_TASK != pm->timeout_task)
616 GNUNET_SCHEDULER_cancel (pm->timeout_task);
617 pm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
619 GNUNET_free (pm->msg);
622 GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head,
623 endpoint->sessions_tail,
625 if (session->timeout_task != GNUNET_SCHEDULER_NO_TASK)
627 GNUNET_SCHEDULER_cancel (session->timeout_task);
628 session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
630 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN sessions allocated"), -1,
632 GNUNET_free (session);
637 * A session is timing out. Clean up.
639 * @param cls pointer to the Session
640 * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
643 session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
645 struct Session * session = cls;
646 struct GNUNET_TIME_Relative timeout;
648 session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
649 timeout = GNUNET_TIME_absolute_get_remaining (session->timeout);
650 if (0 == timeout.rel_value)
652 free_session (session);
655 session->timeout_task =
656 GNUNET_SCHEDULER_add_delayed (timeout, &session_timeout, session);
661 * Create a new session
663 * @param endpoint pointer to the mac endpoint of the peer
664 * @param peer peer identity to use for this session
665 * @return returns the session
667 static struct Session *
668 create_session (struct MacEndpoint *endpoint,
669 const struct GNUNET_PeerIdentity *peer)
671 struct Session *session;
673 for (session = endpoint->sessions_head; NULL != session; session = session->next)
674 if (0 == memcmp (peer, &session->target,
675 sizeof (struct GNUNET_PeerIdentity)))
677 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
680 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN sessions allocated"), 1,
682 session = GNUNET_malloc (sizeof (struct Session));
683 GNUNET_CONTAINER_DLL_insert_tail (endpoint->sessions_head,
684 endpoint->sessions_tail,
686 session->mac = endpoint;
687 session->target = *peer;
688 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
689 session->timeout_task =
690 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session);
691 LOG (GNUNET_ERROR_TYPE_DEBUG,
692 "Created new session for peer `%s' with endpoint %s\n",
694 mac_to_string (&endpoint->addr));
700 * Function called once we have successfully given the fragment
701 * message to the SUID helper process and we are thus ready for
704 * @param cls the 'struct FragmentMessage'
705 * @param result result of the operation (GNUNET_OK on success, GNUNET_NO if the helper died, GNUNET_SYSERR
706 * if the helper was stopped)
709 fragment_transmission_done (void *cls,
712 struct FragmentMessage *fm = cls;
715 GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext);
720 * Transmit a fragment of a message.
722 * @param cls 'struct FragmentMessage' this fragment message belongs to
723 * @param hdr pointer to the start of the fragment message
726 transmit_fragment (void *cls,
727 const struct GNUNET_MessageHeader *hdr)
729 struct FragmentMessage *fm = cls;
730 struct MacEndpoint *endpoint = fm->macendpoint;
734 msize = ntohs (hdr->size);
735 size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize;
738 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radio_header;
740 radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
741 get_radiotap_header (endpoint, radio_header, size);
742 get_wlan_header (endpoint->plugin,
743 &radio_header->frame,
746 memcpy (&radio_header[1], hdr, msize);
747 GNUNET_assert (NULL == fm->sh);
748 fm->sh = GNUNET_HELPER_send (endpoint->plugin->suid_helper,
749 &radio_header->header,
751 &fragment_transmission_done, fm);
753 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN message fragments sent"),
756 GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext);
762 * Frees the space of a message in the fragment queue (send queue)
764 * @param fm message to free
767 free_fragment_message (struct FragmentMessage *fm)
769 struct MacEndpoint *endpoint = fm->macendpoint;
771 GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN messages pending (with fragmentation)"),
773 GNUNET_CONTAINER_DLL_remove (endpoint->sending_messages_head,
774 endpoint->sending_messages_tail, fm);
777 GNUNET_HELPER_send_cancel (fm->sh);
780 GNUNET_FRAGMENT_context_destroy (fm->fragcontext);
781 if (fm->timeout_task != GNUNET_SCHEDULER_NO_TASK)
783 GNUNET_SCHEDULER_cancel (fm->timeout_task);
784 fm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
791 * A FragmentMessage has timed out. Remove it.
793 * @param cls pointer to the 'struct FragmentMessage'
794 * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
797 fragmentmessage_timeout (void *cls,
798 const struct GNUNET_SCHEDULER_TaskContext *tc)
800 struct FragmentMessage *fm = cls;
802 fm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
803 if (NULL != fm->cont)
805 fm->cont (fm->cont_cls, &fm->target, GNUNET_SYSERR);
808 free_fragment_message (fm);
813 * Transmit a message to the given destination with fragmentation.
815 * @param endpoint desired destination
816 * @param timeout how long can the message wait?
817 * @param target peer that should receive the message
818 * @param msg message to transmit
819 * @param cont continuation to call once the message has
820 * been transmitted (or if the transport is ready
821 * for the next transmission call; or if the
822 * peer disconnected...); can be NULL
823 * @param cont_cls closure for cont
826 send_with_fragmentation (struct MacEndpoint *endpoint,
827 struct GNUNET_TIME_Relative timeout,
828 const struct GNUNET_PeerIdentity *target,
829 const struct GNUNET_MessageHeader *msg,
830 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
833 struct FragmentMessage *fm;
834 struct Plugin *plugin;
836 plugin = endpoint->plugin;
837 fm = GNUNET_malloc (sizeof (struct FragmentMessage));
838 fm->macendpoint = endpoint;
839 fm->target = *target;
840 fm->timeout = GNUNET_TIME_relative_to_absolute (timeout);
842 GNUNET_FRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
844 GNUNET_TIME_UNIT_SECONDS,
846 &transmit_fragment, fm);
848 GNUNET_SCHEDULER_add_delayed (timeout,
849 &fragmentmessage_timeout, fm);
850 GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head,
851 endpoint->sending_messages_tail,
857 * Free a MAC endpoint.
859 * @param endpoint pointer to the MacEndpoint to free
862 free_macendpoint (struct MacEndpoint *endpoint)
864 struct Plugin *plugin = endpoint->plugin;
865 struct FragmentMessage *fm;
866 struct Session *session;
868 GNUNET_STATISTICS_update (plugin->env->stats,
869 _("# WLAN MAC endpoints allocated"), -1, GNUNET_NO);
870 while (NULL != (session = endpoint->sessions_head))
871 free_session (session);
872 while (NULL != (fm = endpoint->sending_messages_head))
873 free_fragment_message (fm);
874 GNUNET_CONTAINER_DLL_remove (plugin->mac_head,
878 if (GNUNET_SCHEDULER_NO_TASK != endpoint->timeout_task)
880 GNUNET_SCHEDULER_cancel (endpoint->timeout_task);
881 endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
883 GNUNET_free (endpoint);
888 * A MAC endpoint is timing out. Clean up.
890 * @param cls pointer to the MacEndpoint
891 * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
894 macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
896 struct MacEndpoint *endpoint = cls;
897 struct GNUNET_TIME_Relative timeout;
899 endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
900 timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout);
901 if (0 == timeout.rel_value)
903 free_macendpoint (endpoint);
906 endpoint->timeout_task =
907 GNUNET_SCHEDULER_add_delayed (timeout, &macendpoint_timeout,
913 * Find (or create) a MacEndpoint with a specific MAC address
915 * @param plugin pointer to the plugin struct
916 * @param addr the MAC address of the endpoint
917 * @return handle to our data structure for this MAC
919 static struct MacEndpoint *
920 create_macendpoint (struct Plugin *plugin,
921 const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr)
923 struct MacEndpoint *pos;
925 for (pos = plugin->mac_head; NULL != pos; pos = pos->next)
926 if (0 == memcmp (addr, &pos->addr, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)))
928 pos = GNUNET_malloc (sizeof (struct MacEndpoint));
930 pos->plugin = plugin;
932 GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
933 MESSAGES_IN_DEFRAG_QUEUE_PER_MAC,
935 &wlan_data_message_handler,
937 pos->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
939 GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
941 GNUNET_CONTAINER_DLL_insert (plugin->mac_head, plugin->mac_tail, pos);
943 GNUNET_STATISTICS_update (plugin->env->stats, _("# WLAN MAC endpoints allocated"),
945 LOG (GNUNET_ERROR_TYPE_DEBUG,
946 "New MAC endpoint `%s'\n",
947 mac_to_string (addr));
953 * Creates a new outbound session the transport service will use to send data to the
956 * @param cls the plugin
957 * @param address the address
958 * @return the session or NULL of max connections exceeded
960 static struct Session *
961 wlan_plugin_get_session (void *cls,
962 const struct GNUNET_HELLO_Address *address)
964 struct Plugin *plugin = cls;
965 struct MacEndpoint *endpoint;
969 if (sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress) != address->address_length)
974 LOG (GNUNET_ERROR_TYPE_DEBUG,
975 "Service asked to create session for peer `%s' with MAC `%s'\n",
976 GNUNET_i2s (&address->peer),
977 mac_to_string (address->address));
978 endpoint = create_macendpoint (plugin, address->address);
979 return create_session (endpoint, &address->peer);
984 * Function that can be used to force the plugin to disconnect
985 * from the given peer and cancel all previous transmissions
986 * (and their continuation).
989 * @param target peer from which to disconnect
992 wlan_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
994 struct Plugin *plugin = cls;
995 struct Session *session;
996 struct MacEndpoint *endpoint;
998 for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next)
999 for (session = endpoint->sessions_head; NULL != session; session = session->next)
1000 if (0 == memcmp (target, &session->target,
1001 sizeof (struct GNUNET_PeerIdentity)))
1003 free_session (session);
1004 break; /* inner-loop only (in case peer has another MAC as well!) */
1010 * Function that can be used by the transport service to transmit
1011 * a message using the plugin. Note that in the case of a
1012 * peer disconnecting, the continuation MUST be called
1013 * prior to the disconnect notification itself. This function
1014 * will be called with this peer's HELLO message to initiate
1015 * a fresh connection to another peer.
1017 * @param cls closure
1018 * @param session which session must be used
1019 * @param msgbuf the message to transmit
1020 * @param msgbuf_size number of bytes in 'msgbuf'
1021 * @param priority how important is the message (most plugins will
1022 * ignore message priority and just FIFO)
1023 * @param to how long to wait at most for the transmission (does not
1024 * require plugins to discard the message after the timeout,
1025 * just advisory for the desired delay; most plugins will ignore
1027 * @param cont continuation to call once the message has
1028 * been transmitted (or if the transport is ready
1029 * for the next transmission call; or if the
1030 * peer disconnected...); can be NULL
1031 * @param cont_cls closure for cont
1032 * @return number of bytes used (on the physical network, with overheads);
1033 * -1 on hard errors (i.e. address invalid); 0 is a legal value
1034 * and does NOT mean that the message was not transmitted (DV)
1037 wlan_plugin_send (void *cls,
1038 struct Session *session,
1039 const char *msgbuf, size_t msgbuf_size,
1040 unsigned int priority,
1041 struct GNUNET_TIME_Relative to,
1042 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
1044 struct Plugin *plugin = cls;
1045 struct WlanHeader *wlanheader;
1046 size_t size = msgbuf_size + sizeof (struct WlanHeader);
1047 char buf[size] GNUNET_ALIGN;
1049 LOG (GNUNET_ERROR_TYPE_DEBUG,
1050 "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n",
1052 GNUNET_i2s (&session->target),
1053 (unsigned int) ntohs (((struct GNUNET_MessageHeader*)msgbuf)->size),
1054 (unsigned int) ntohs (((struct GNUNET_MessageHeader*)msgbuf)->type));
1055 wlanheader = (struct WlanHeader *) buf;
1056 wlanheader->header.size = htons (msgbuf_size + sizeof (struct WlanHeader));
1057 wlanheader->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA);
1058 wlanheader->sender = *plugin->env->my_identity;
1059 wlanheader->target = session->target;
1060 wlanheader->crc = htonl (GNUNET_CRYPTO_crc32_n (msgbuf, msgbuf_size));
1061 memcpy (&wlanheader[1], msgbuf, msgbuf_size);
1062 send_with_fragmentation (session->mac,
1065 &wlanheader->header,
1072 * We have received data from the WLAN via some session. Process depending
1073 * on the message type (HELLO, DATA, FRAGMENTATION or FRAGMENTATION-ACK).
1075 * @param cls pointer to the plugin
1076 * @param client pointer to the session this message belongs to
1077 * @param hdr start of the message
1080 process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1082 struct Plugin *plugin = cls;
1083 struct MacAndSession *mas = client;
1084 struct MacAndSession xmas;
1086 struct GNUNET_ATS_Information ats[NUM_ATS]; /* FIXME: do better here */
1087 struct FragmentMessage *fm;
1088 struct GNUNET_PeerIdentity tmpsource;
1089 const struct WlanHeader *wlanheader;
1093 ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
1094 ats[0].value = htonl (1);
1095 ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
1096 ats[1].value = htonl (GNUNET_ATS_NET_WLAN);
1097 msize = ntohs (hdr->size);
1098 switch (ntohs (hdr->type))
1100 case GNUNET_MESSAGE_TYPE_HELLO:
1102 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource))
1104 GNUNET_break_op (0);
1107 LOG (GNUNET_ERROR_TYPE_DEBUG,
1108 "Processing %u bytes of HELLO from peer `%s' at MAC %s\n",
1109 (unsigned int) msize,
1110 GNUNET_i2s (&tmpsource),
1111 mac_to_string (&mas->endpoint->addr));
1113 GNUNET_STATISTICS_update (plugin->env->stats,
1114 _("# HELLO messages received via WLAN"), 1,
1116 plugin->env->receive (plugin->env->cls,
1121 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
1122 (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
1124 case GNUNET_MESSAGE_TYPE_FRAGMENT:
1125 if (NULL == mas->endpoint)
1130 LOG (GNUNET_ERROR_TYPE_DEBUG,
1131 "Processing %u bytes of FRAGMENT from MAC %s\n",
1132 (unsigned int) msize,
1133 mac_to_string (&mas->endpoint->addr));
1134 GNUNET_STATISTICS_update (plugin->env->stats,
1135 _("# fragments received via WLAN"), 1, GNUNET_NO);
1136 (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag,
1139 case GNUNET_MESSAGE_TYPE_FRAGMENT_ACK:
1140 if (NULL == mas->endpoint)
1145 GNUNET_STATISTICS_update (plugin->env->stats, _("# ACKs received via WLAN"),
1147 for (fm = mas->endpoint->sending_messages_head; NULL != fm; fm = fm->next)
1149 ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr);
1150 if (GNUNET_OK == ret)
1152 LOG (GNUNET_ERROR_TYPE_DEBUG,
1153 "Got last ACK, finished message transmission to `%s' (%p)\n",
1154 mac_to_string (&mas->endpoint->addr),
1156 mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
1157 if (NULL != fm->cont)
1159 fm->cont (fm->cont_cls, &fm->target, GNUNET_OK);
1162 free_fragment_message (fm);
1165 if (GNUNET_NO == ret)
1167 LOG (GNUNET_ERROR_TYPE_DEBUG,
1168 "Got an ACK, message transmission to `%s' not yet finished\n",
1169 mac_to_string (&mas->endpoint->addr));
1173 LOG (GNUNET_ERROR_TYPE_DEBUG,
1174 "ACK not matched against any active fragmentation with MAC `%s'\n",
1175 mac_to_string (&mas->endpoint->addr));
1177 case GNUNET_MESSAGE_TYPE_WLAN_DATA:
1178 if (NULL == mas->endpoint)
1183 if (msize < sizeof (struct WlanHeader))
1188 wlanheader = (const struct WlanHeader *) hdr;
1189 if (0 != memcmp (&wlanheader->target,
1190 plugin->env->my_identity,
1191 sizeof (struct GNUNET_PeerIdentity)))
1193 LOG (GNUNET_ERROR_TYPE_DEBUG,
1194 "WLAN data for `%s', not for me, ignoring\n",
1195 GNUNET_i2s (&wlanheader->target));
1198 if (ntohl (wlanheader->crc) !=
1199 GNUNET_CRYPTO_crc32_n (&wlanheader[1], msize - sizeof (struct WlanHeader)))
1201 GNUNET_STATISTICS_update (plugin->env->stats,
1202 _("# WLAN DATA messages discarded due to CRC32 error"), 1,
1206 xmas.endpoint = mas->endpoint;
1207 xmas.session = create_session (mas->endpoint, &wlanheader->sender);
1208 LOG (GNUNET_ERROR_TYPE_DEBUG,
1209 "Processing %u bytes of WLAN DATA from peer `%s'\n",
1210 (unsigned int) msize,
1211 GNUNET_i2s (&wlanheader->sender));
1212 (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer,
1214 (const char *) &wlanheader[1],
1215 msize - sizeof (struct WlanHeader),
1216 GNUNET_YES, GNUNET_NO);
1219 if (NULL == mas->endpoint)
1224 if (NULL == mas->session)
1229 LOG (GNUNET_ERROR_TYPE_DEBUG,
1230 "Received packet with %u bytes of type %u from peer %s\n",
1231 (unsigned int) msize,
1232 (unsigned int) ntohs (hdr->type),
1233 GNUNET_i2s (&mas->session->target));
1234 plugin->env->receive (plugin->env->cls,
1235 &mas->session->target,
1239 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
1240 (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
1248 * Function used for to process the data from the suid process
1250 * @param cls the plugin handle
1251 * @param client client that send the data (not used)
1252 * @param hdr header of the GNUNET_MessageHeader
1255 handle_helper_message (void *cls, void *client,
1256 const struct GNUNET_MessageHeader *hdr)
1258 struct Plugin *plugin = cls;
1259 const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rxinfo;
1260 const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *cm;
1261 struct MacAndSession mas;
1264 msize = ntohs (hdr->size);
1265 switch (ntohs (hdr->type))
1267 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL:
1268 if (msize != sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage))
1273 cm = (const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *) hdr;
1274 if (GNUNET_YES == plugin->have_mac)
1276 if (0 == memcmp (&plugin->mac_address,
1278 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1279 break; /* no change */
1280 /* remove old address */
1281 plugin->env->notify_address (plugin->env->cls, GNUNET_NO,
1282 &plugin->mac_address,
1283 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
1285 plugin->mac_address = cm->mac;
1286 plugin->have_mac = GNUNET_YES;
1287 LOG (GNUNET_ERROR_TYPE_DEBUG,
1288 "Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n",
1289 mac_to_string (&cm->mac),
1290 GNUNET_i2s (plugin->env->my_identity));
1291 plugin->env->notify_address (plugin->env->cls, GNUNET_YES,
1292 &plugin->mac_address,
1293 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
1295 case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER:
1296 LOG (GNUNET_ERROR_TYPE_DEBUG,
1297 "Got data message from helper with %u bytes\n",
1299 GNUNET_STATISTICS_update (plugin->env->stats,
1300 _("# DATA messages received via WLAN"), 1,
1302 if (msize < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage))
1305 LOG (GNUNET_ERROR_TYPE_DEBUG,
1306 "Size of packet is too small (%u bytes)\n",
1310 rxinfo = (const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) hdr;
1312 /* check if message is actually for us */
1313 if (0 != memcmp (&rxinfo->frame.addr3, &mac_bssid_gnunet,
1314 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1316 /* Not the GNUnet BSSID */
1319 if ( (0 != memcmp (&rxinfo->frame.addr1, &bc_all_mac,
1320 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))) &&
1321 (0 != memcmp (&rxinfo->frame.addr1, &plugin->mac_address,
1322 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))) )
1324 /* Neither broadcast nor specifically for us */
1327 if (0 == memcmp (&rxinfo->frame.addr2, &plugin->mac_address,
1328 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1330 /* packet is FROM us, thus not FOR us */
1334 GNUNET_STATISTICS_update (plugin->env->stats,
1335 _("# WLAN DATA messages processed"),
1337 LOG (GNUNET_ERROR_TYPE_DEBUG,
1338 "Receiving %u bytes of data from MAC `%s'\n",
1339 (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)),
1340 mac_to_string (&rxinfo->frame.addr2));
1341 mas.endpoint = create_macendpoint (plugin, &rxinfo->frame.addr2);
1343 (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer,
1345 (const char*) &rxinfo[1],
1346 msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage),
1347 GNUNET_YES, GNUNET_NO);
1351 LOG (GNUNET_ERROR_TYPE_DEBUG,
1352 "Unexpected message of type %u (%u bytes)",
1353 ntohs (hdr->type), ntohs (hdr->size));
1361 * Task to (periodically) send a HELLO beacon
1363 * @param cls pointer to the plugin struct
1364 * @param tc scheduler context
1367 send_hello_beacon (void *cls,
1368 const struct GNUNET_SCHEDULER_TaskContext *tc)
1370 struct Plugin *plugin = cls;
1372 uint16_t hello_size;
1373 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader;
1374 const struct GNUNET_MessageHeader *hello;
1376 hello = plugin->env->get_our_hello ();
1377 hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
1378 GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU);
1379 size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size;
1381 char buf[size] GNUNET_ALIGN;
1383 LOG (GNUNET_ERROR_TYPE_DEBUG,
1384 "Sending %u byte HELLO beacon\n",
1385 (unsigned int) size);
1386 radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf;
1387 get_radiotap_header (NULL, radioHeader, size);
1388 get_wlan_header (plugin, &radioHeader->frame, &bc_all_mac, size);
1389 memcpy (&radioHeader[1], hello, hello_size);
1391 GNUNET_HELPER_send (plugin->suid_helper,
1392 &radioHeader->header,
1393 GNUNET_YES /* can drop */,
1395 GNUNET_STATISTICS_update (plugin->env->stats, _("# HELLO beacons sent via WLAN"),
1398 plugin->beacon_task =
1399 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
1400 (HELLO_BEACON_SCALING_FACTOR,
1401 plugin->mac_count + 1),
1409 * Another peer has suggested an address for this
1410 * peer and transport plugin. Check that this could be a valid
1411 * address. If so, consider adding it to the list
1414 * @param cls closure
1415 * @param addr pointer to the address
1416 * @param addrlen length of addr
1417 * @return GNUNET_OK if this is a plausible address for this peer
1421 wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
1423 struct Plugin *plugin = cls;
1425 if (addrlen != sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))
1427 GNUNET_break_op (0);
1428 return GNUNET_SYSERR;
1430 if (GNUNET_YES != plugin->have_mac)
1432 LOG (GNUNET_ERROR_TYPE_DEBUG,
1433 "Rejecting MAC `%s': I don't know my MAC!\n",
1434 mac_to_string (addr));
1435 return GNUNET_NO; /* don't know my MAC */
1437 if (0 != memcmp (addr,
1438 &plugin->mac_address,
1441 LOG (GNUNET_ERROR_TYPE_DEBUG,
1442 "Rejecting MAC `%s': not my MAC!\n",
1443 mac_to_string (addr));
1444 return GNUNET_NO; /* not my MAC */
1451 * Function called for a quick conversion of the binary address to
1452 * a numeric address. Note that the caller must not free the
1453 * address and that the next call to this function is allowed
1454 * to override the address again.
1456 * @param cls closure
1457 * @param addr binary address
1458 * @param addrlen length of the address
1459 * @return string representing the same address
1462 wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
1464 static char ret[40];
1465 const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac;
1467 if (sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress) != addrlen)
1473 GNUNET_snprintf (ret, sizeof (ret), "%s MAC address %s",
1475 mac_to_string (mac));
1481 * Convert the transports address to a nice, human-readable format.
1483 * @param cls closure
1484 * @param type name of the transport that generated the address
1485 * @param addr one of the addresses of the host, NULL for the last address
1486 * the specific address format depends on the transport
1487 * @param addrlen length of the address
1488 * @param numeric should (IP) addresses be displayed in numeric form?
1489 * @param timeout after how long should we give up?
1490 * @param asc function to call on each string
1491 * @param asc_cls closure for asc
1494 wlan_plugin_address_pretty_printer (void *cls, const char *type,
1495 const void *addr, size_t addrlen,
1497 struct GNUNET_TIME_Relative timeout,
1498 GNUNET_TRANSPORT_AddressStringCallback asc,
1501 const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac;
1504 if (sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress) != addrlen)
1506 /* invalid address */
1507 LOG (GNUNET_ERROR_TYPE_WARNING,
1508 _("WLAN address with invalid size encountered\n"));
1509 asc (asc_cls, NULL);
1513 GNUNET_asprintf (&ret,
1514 "%s MAC address %s",
1516 mac_to_string (mac));
1519 asc (asc_cls, NULL);
1524 * Exit point from the plugin.
1526 * @param cls pointer to the api struct
1529 libgnunet_plugin_transport_wlan_done (void *cls)
1531 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
1532 struct Plugin *plugin = api->cls;
1533 struct MacEndpoint *endpoint;
1534 struct MacEndpoint *endpoint_next;
1541 if (GNUNET_SCHEDULER_NO_TASK != plugin->beacon_task)
1543 GNUNET_SCHEDULER_cancel (plugin->beacon_task);
1544 plugin->beacon_task = GNUNET_SCHEDULER_NO_TASK;
1546 if (NULL != plugin->suid_helper)
1548 GNUNET_HELPER_stop (plugin->suid_helper);
1549 plugin->suid_helper = NULL;
1551 endpoint_next = plugin->mac_head;
1552 while (NULL != (endpoint = endpoint_next))
1554 endpoint_next = endpoint->next;
1555 free_macendpoint (endpoint);
1557 if (NULL != plugin->fragment_data_tokenizer)
1559 GNUNET_SERVER_mst_destroy (plugin->fragment_data_tokenizer);
1560 plugin->fragment_data_tokenizer = NULL;
1562 if (NULL != plugin->wlan_header_payload_tokenizer)
1564 GNUNET_SERVER_mst_destroy (plugin->wlan_header_payload_tokenizer);
1565 plugin->wlan_header_payload_tokenizer = NULL;
1567 if (NULL != plugin->helper_payload_tokenizer)
1569 GNUNET_SERVER_mst_destroy (plugin->helper_payload_tokenizer);
1570 plugin->helper_payload_tokenizer = NULL;
1572 GNUNET_free_non_null (plugin->interface);
1573 GNUNET_free (plugin);
1580 * Entry point for the plugin.
1582 * @param cls closure, the 'struct GNUNET_TRANSPORT_PluginEnvironment*'
1583 * @return the 'struct GNUNET_TRANSPORT_PluginFunctions*' or NULL on error
1586 libgnunet_plugin_transport_wlan_init (void *cls)
1588 struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
1589 struct GNUNET_TRANSPORT_PluginFunctions *api;
1590 struct Plugin *plugin;
1592 unsigned long long testmode;
1594 /* check for 'special' mode */
1595 if (NULL == env->receive)
1597 /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
1598 initialze the plugin or the API */
1599 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
1601 api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
1602 api->address_to_string = &wlan_plugin_address_to_string;
1603 api->string_to_address = NULL; // FIXME!
1608 /* check configuration */
1610 GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE")) &&
1612 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan",
1613 "TESTMODE", &testmode)) ||
1616 LOG (GNUNET_ERROR_TYPE_ERROR,
1617 _("Invalid configuration option `%s' in section `%s'\n"),
1622 if ( (0 == testmode) &&
1623 (GNUNET_YES != GNUNET_OS_check_helper_binary ("gnunet-helper-transport-wlan")) )
1625 LOG (GNUNET_ERROR_TYPE_ERROR,
1626 _("Helper binary `%s' not SUID, cannot run WLAN transport\n"),
1627 "gnunet-helper-transport-wlan");
1631 GNUNET_CONFIGURATION_get_value_string
1632 (env->cfg, "transport-wlan", "INTERFACE",
1635 LOG (GNUNET_ERROR_TYPE_ERROR,
1636 _("Missing configuration option `%s' in section `%s'\n"),
1642 plugin = GNUNET_malloc (sizeof (struct Plugin));
1643 plugin->interface = interface;
1645 GNUNET_STATISTICS_set (plugin->env->stats, _("# WLAN sessions allocated"),
1647 GNUNET_STATISTICS_set (plugin->env->stats, _("# WLAN MAC endpoints allocated"),
1649 GNUNET_BANDWIDTH_tracker_init (&plugin->tracker,
1650 GNUNET_BANDWIDTH_value_init (100 * 1024 *
1652 plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1653 plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1654 plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1655 plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon,
1659 case 0: /* normal */
1660 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan";
1661 plugin->helper_argv[1] = interface;
1662 plugin->helper_argv[2] = NULL;
1663 plugin->suid_helper = GNUNET_HELPER_start ("gnunet-helper-transport-wlan",
1664 plugin->helper_argv,
1665 &handle_helper_message,
1668 case 1: /* testmode, peer 1 */
1669 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
1670 plugin->helper_argv[1] = (char *) "1";
1671 plugin->helper_argv[2] = NULL;
1672 plugin->suid_helper = GNUNET_HELPER_start ("gnunet-helper-transport-wlan-dummy",
1673 plugin->helper_argv,
1674 &handle_helper_message,
1677 case 2: /* testmode, peer 2 */
1678 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
1679 plugin->helper_argv[1] = (char *) "2";
1680 plugin->helper_argv[2] = NULL;
1681 plugin->suid_helper = GNUNET_HELPER_start ("gnunet-helper-transport-wlan-dummy",
1682 plugin->helper_argv,
1683 &handle_helper_message,
1690 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
1692 api->send = &wlan_plugin_send;
1693 api->get_session = &wlan_plugin_get_session;
1694 api->disconnect = &wlan_plugin_disconnect;
1695 api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
1696 api->check_address = &wlan_plugin_address_suggested;
1697 api->address_to_string = &wlan_plugin_address_to_string;
1702 /* end of plugin_transport_wlan.c */