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 fm->cont_cls = cont_cls;
844 GNUNET_FRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
846 GNUNET_TIME_UNIT_SECONDS,
848 &transmit_fragment, fm);
850 GNUNET_SCHEDULER_add_delayed (timeout,
851 &fragmentmessage_timeout, fm);
852 GNUNET_CONTAINER_DLL_insert_tail (endpoint->sending_messages_head,
853 endpoint->sending_messages_tail,
859 * Free a MAC endpoint.
861 * @param endpoint pointer to the MacEndpoint to free
864 free_macendpoint (struct MacEndpoint *endpoint)
866 struct Plugin *plugin = endpoint->plugin;
867 struct FragmentMessage *fm;
868 struct Session *session;
870 GNUNET_STATISTICS_update (plugin->env->stats,
871 _("# WLAN MAC endpoints allocated"), -1, GNUNET_NO);
872 while (NULL != (session = endpoint->sessions_head))
873 free_session (session);
874 while (NULL != (fm = endpoint->sending_messages_head))
875 free_fragment_message (fm);
876 GNUNET_CONTAINER_DLL_remove (plugin->mac_head,
880 if (GNUNET_SCHEDULER_NO_TASK != endpoint->timeout_task)
882 GNUNET_SCHEDULER_cancel (endpoint->timeout_task);
883 endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
885 GNUNET_free (endpoint);
890 * A MAC endpoint is timing out. Clean up.
892 * @param cls pointer to the MacEndpoint
893 * @param tc pointer to the GNUNET_SCHEDULER_TaskContext
896 macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
898 struct MacEndpoint *endpoint = cls;
899 struct GNUNET_TIME_Relative timeout;
901 endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
902 timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout);
903 if (0 == timeout.rel_value)
905 free_macendpoint (endpoint);
908 endpoint->timeout_task =
909 GNUNET_SCHEDULER_add_delayed (timeout, &macendpoint_timeout,
915 * Find (or create) a MacEndpoint with a specific MAC address
917 * @param plugin pointer to the plugin struct
918 * @param addr the MAC address of the endpoint
919 * @return handle to our data structure for this MAC
921 static struct MacEndpoint *
922 create_macendpoint (struct Plugin *plugin,
923 const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr)
925 struct MacEndpoint *pos;
927 for (pos = plugin->mac_head; NULL != pos; pos = pos->next)
928 if (0 == memcmp (addr, &pos->addr, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)))
930 pos = GNUNET_malloc (sizeof (struct MacEndpoint));
932 pos->plugin = plugin;
934 GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
935 MESSAGES_IN_DEFRAG_QUEUE_PER_MAC,
937 &wlan_data_message_handler,
939 pos->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
941 GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
943 GNUNET_CONTAINER_DLL_insert (plugin->mac_head, plugin->mac_tail, pos);
945 GNUNET_STATISTICS_update (plugin->env->stats, _("# WLAN MAC endpoints allocated"),
947 LOG (GNUNET_ERROR_TYPE_DEBUG,
948 "New MAC endpoint `%s'\n",
949 mac_to_string (addr));
955 * Creates a new outbound session the transport service will use to send data to the
958 * @param cls the plugin
959 * @param address the address
960 * @return the session or NULL of max connections exceeded
962 static struct Session *
963 wlan_plugin_get_session (void *cls,
964 const struct GNUNET_HELLO_Address *address)
966 struct Plugin *plugin = cls;
967 struct MacEndpoint *endpoint;
971 if (sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress) != address->address_length)
976 LOG (GNUNET_ERROR_TYPE_DEBUG,
977 "Service asked to create session for peer `%s' with MAC `%s'\n",
978 GNUNET_i2s (&address->peer),
979 mac_to_string (address->address));
980 endpoint = create_macendpoint (plugin, address->address);
981 return create_session (endpoint, &address->peer);
986 * Function that can be used to force the plugin to disconnect
987 * from the given peer and cancel all previous transmissions
988 * (and their continuation).
991 * @param target peer from which to disconnect
994 wlan_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
996 struct Plugin *plugin = cls;
997 struct Session *session;
998 struct MacEndpoint *endpoint;
1000 for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next)
1001 for (session = endpoint->sessions_head; NULL != session; session = session->next)
1002 if (0 == memcmp (target, &session->target,
1003 sizeof (struct GNUNET_PeerIdentity)))
1005 free_session (session);
1006 break; /* inner-loop only (in case peer has another MAC as well!) */
1012 * Function that can be used by the transport service to transmit
1013 * a message using the plugin. Note that in the case of a
1014 * peer disconnecting, the continuation MUST be called
1015 * prior to the disconnect notification itself. This function
1016 * will be called with this peer's HELLO message to initiate
1017 * a fresh connection to another peer.
1019 * @param cls closure
1020 * @param session which session must be used
1021 * @param msgbuf the message to transmit
1022 * @param msgbuf_size number of bytes in 'msgbuf'
1023 * @param priority how important is the message (most plugins will
1024 * ignore message priority and just FIFO)
1025 * @param to how long to wait at most for the transmission (does not
1026 * require plugins to discard the message after the timeout,
1027 * just advisory for the desired delay; most plugins will ignore
1029 * @param cont continuation to call once the message has
1030 * been transmitted (or if the transport is ready
1031 * for the next transmission call; or if the
1032 * peer disconnected...); can be NULL
1033 * @param cont_cls closure for cont
1034 * @return number of bytes used (on the physical network, with overheads);
1035 * -1 on hard errors (i.e. address invalid); 0 is a legal value
1036 * and does NOT mean that the message was not transmitted (DV)
1039 wlan_plugin_send (void *cls,
1040 struct Session *session,
1041 const char *msgbuf, size_t msgbuf_size,
1042 unsigned int priority,
1043 struct GNUNET_TIME_Relative to,
1044 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
1046 struct Plugin *plugin = cls;
1047 struct WlanHeader *wlanheader;
1048 size_t size = msgbuf_size + sizeof (struct WlanHeader);
1049 char buf[size] GNUNET_ALIGN;
1051 LOG (GNUNET_ERROR_TYPE_DEBUG,
1052 "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n",
1054 GNUNET_i2s (&session->target),
1055 (unsigned int) ntohs (((struct GNUNET_MessageHeader*)msgbuf)->size),
1056 (unsigned int) ntohs (((struct GNUNET_MessageHeader*)msgbuf)->type));
1057 wlanheader = (struct WlanHeader *) buf;
1058 wlanheader->header.size = htons (msgbuf_size + sizeof (struct WlanHeader));
1059 wlanheader->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA);
1060 wlanheader->sender = *plugin->env->my_identity;
1061 wlanheader->target = session->target;
1062 wlanheader->crc = htonl (GNUNET_CRYPTO_crc32_n (msgbuf, msgbuf_size));
1063 memcpy (&wlanheader[1], msgbuf, msgbuf_size);
1064 send_with_fragmentation (session->mac,
1067 &wlanheader->header,
1074 * We have received data from the WLAN via some session. Process depending
1075 * on the message type (HELLO, DATA, FRAGMENTATION or FRAGMENTATION-ACK).
1077 * @param cls pointer to the plugin
1078 * @param client pointer to the session this message belongs to
1079 * @param hdr start of the message
1082 process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1084 struct Plugin *plugin = cls;
1085 struct MacAndSession *mas = client;
1086 struct MacAndSession xmas;
1088 struct GNUNET_ATS_Information ats[NUM_ATS]; /* FIXME: do better here */
1089 struct FragmentMessage *fm;
1090 struct GNUNET_PeerIdentity tmpsource;
1091 const struct WlanHeader *wlanheader;
1095 ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
1096 ats[0].value = htonl (1);
1097 ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
1098 ats[1].value = htonl (GNUNET_ATS_NET_WLAN);
1099 msize = ntohs (hdr->size);
1100 switch (ntohs (hdr->type))
1102 case GNUNET_MESSAGE_TYPE_HELLO:
1104 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr, &tmpsource))
1106 GNUNET_break_op (0);
1109 LOG (GNUNET_ERROR_TYPE_DEBUG,
1110 "Processing %u bytes of HELLO from peer `%s' at MAC %s\n",
1111 (unsigned int) msize,
1112 GNUNET_i2s (&tmpsource),
1113 mac_to_string (&mas->endpoint->addr));
1115 GNUNET_STATISTICS_update (plugin->env->stats,
1116 _("# HELLO messages received via WLAN"), 1,
1118 plugin->env->receive (plugin->env->cls,
1123 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
1124 (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
1126 case GNUNET_MESSAGE_TYPE_FRAGMENT:
1127 if (NULL == mas->endpoint)
1132 LOG (GNUNET_ERROR_TYPE_DEBUG,
1133 "Processing %u bytes of FRAGMENT from MAC %s\n",
1134 (unsigned int) msize,
1135 mac_to_string (&mas->endpoint->addr));
1136 GNUNET_STATISTICS_update (plugin->env->stats,
1137 _("# fragments received via WLAN"), 1, GNUNET_NO);
1138 (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag,
1141 case GNUNET_MESSAGE_TYPE_FRAGMENT_ACK:
1142 if (NULL == mas->endpoint)
1147 GNUNET_STATISTICS_update (plugin->env->stats, _("# ACKs received via WLAN"),
1149 for (fm = mas->endpoint->sending_messages_head; NULL != fm; fm = fm->next)
1151 ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr);
1152 if (GNUNET_OK == ret)
1154 LOG (GNUNET_ERROR_TYPE_DEBUG,
1155 "Got last ACK, finished message transmission to `%s' (%p)\n",
1156 mac_to_string (&mas->endpoint->addr),
1158 mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
1159 if (NULL != fm->cont)
1161 fm->cont (fm->cont_cls, &fm->target, GNUNET_OK);
1164 free_fragment_message (fm);
1167 if (GNUNET_NO == ret)
1169 LOG (GNUNET_ERROR_TYPE_DEBUG,
1170 "Got an ACK, message transmission to `%s' not yet finished\n",
1171 mac_to_string (&mas->endpoint->addr));
1175 LOG (GNUNET_ERROR_TYPE_DEBUG,
1176 "ACK not matched against any active fragmentation with MAC `%s'\n",
1177 mac_to_string (&mas->endpoint->addr));
1179 case GNUNET_MESSAGE_TYPE_WLAN_DATA:
1180 if (NULL == mas->endpoint)
1185 if (msize < sizeof (struct WlanHeader))
1190 wlanheader = (const struct WlanHeader *) hdr;
1191 if (0 != memcmp (&wlanheader->target,
1192 plugin->env->my_identity,
1193 sizeof (struct GNUNET_PeerIdentity)))
1195 LOG (GNUNET_ERROR_TYPE_DEBUG,
1196 "WLAN data for `%s', not for me, ignoring\n",
1197 GNUNET_i2s (&wlanheader->target));
1200 if (ntohl (wlanheader->crc) !=
1201 GNUNET_CRYPTO_crc32_n (&wlanheader[1], msize - sizeof (struct WlanHeader)))
1203 GNUNET_STATISTICS_update (plugin->env->stats,
1204 _("# WLAN DATA messages discarded due to CRC32 error"), 1,
1208 xmas.endpoint = mas->endpoint;
1209 xmas.session = create_session (mas->endpoint, &wlanheader->sender);
1210 LOG (GNUNET_ERROR_TYPE_DEBUG,
1211 "Processing %u bytes of WLAN DATA from peer `%s'\n",
1212 (unsigned int) msize,
1213 GNUNET_i2s (&wlanheader->sender));
1214 (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer,
1216 (const char *) &wlanheader[1],
1217 msize - sizeof (struct WlanHeader),
1218 GNUNET_YES, GNUNET_NO);
1221 if (NULL == mas->endpoint)
1226 if (NULL == mas->session)
1231 LOG (GNUNET_ERROR_TYPE_DEBUG,
1232 "Received packet with %u bytes of type %u from peer %s\n",
1233 (unsigned int) msize,
1234 (unsigned int) ntohs (hdr->type),
1235 GNUNET_i2s (&mas->session->target));
1236 plugin->env->receive (plugin->env->cls,
1237 &mas->session->target,
1241 (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr,
1242 (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
1250 * Function used for to process the data from the suid process
1252 * @param cls the plugin handle
1253 * @param client client that send the data (not used)
1254 * @param hdr header of the GNUNET_MessageHeader
1257 handle_helper_message (void *cls, void *client,
1258 const struct GNUNET_MessageHeader *hdr)
1260 struct Plugin *plugin = cls;
1261 const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rxinfo;
1262 const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *cm;
1263 struct MacAndSession mas;
1266 msize = ntohs (hdr->size);
1267 switch (ntohs (hdr->type))
1269 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL:
1270 if (msize != sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage))
1275 cm = (const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *) hdr;
1276 if (GNUNET_YES == plugin->have_mac)
1278 if (0 == memcmp (&plugin->mac_address,
1280 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1281 break; /* no change */
1282 /* remove old address */
1283 plugin->env->notify_address (plugin->env->cls, GNUNET_NO,
1284 &plugin->mac_address,
1285 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
1287 plugin->mac_address = cm->mac;
1288 plugin->have_mac = GNUNET_YES;
1289 LOG (GNUNET_ERROR_TYPE_DEBUG,
1290 "Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n",
1291 mac_to_string (&cm->mac),
1292 GNUNET_i2s (plugin->env->my_identity));
1293 plugin->env->notify_address (plugin->env->cls, GNUNET_YES,
1294 &plugin->mac_address,
1295 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
1297 case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER:
1298 LOG (GNUNET_ERROR_TYPE_DEBUG,
1299 "Got data message from helper with %u bytes\n",
1301 GNUNET_STATISTICS_update (plugin->env->stats,
1302 _("# DATA messages received via WLAN"), 1,
1304 if (msize < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage))
1307 LOG (GNUNET_ERROR_TYPE_DEBUG,
1308 "Size of packet is too small (%u bytes)\n",
1312 rxinfo = (const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) hdr;
1314 /* check if message is actually for us */
1315 if (0 != memcmp (&rxinfo->frame.addr3, &mac_bssid_gnunet,
1316 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1318 /* Not the GNUnet BSSID */
1321 if ( (0 != memcmp (&rxinfo->frame.addr1, &bc_all_mac,
1322 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))) &&
1323 (0 != memcmp (&rxinfo->frame.addr1, &plugin->mac_address,
1324 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))) )
1326 /* Neither broadcast nor specifically for us */
1329 if (0 == memcmp (&rxinfo->frame.addr2, &plugin->mac_address,
1330 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1332 /* packet is FROM us, thus not FOR us */
1336 GNUNET_STATISTICS_update (plugin->env->stats,
1337 _("# WLAN DATA messages processed"),
1339 LOG (GNUNET_ERROR_TYPE_DEBUG,
1340 "Receiving %u bytes of data from MAC `%s'\n",
1341 (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)),
1342 mac_to_string (&rxinfo->frame.addr2));
1343 mas.endpoint = create_macendpoint (plugin, &rxinfo->frame.addr2);
1345 (void) GNUNET_SERVER_mst_receive (plugin->helper_payload_tokenizer,
1347 (const char*) &rxinfo[1],
1348 msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage),
1349 GNUNET_YES, GNUNET_NO);
1353 LOG (GNUNET_ERROR_TYPE_DEBUG,
1354 "Unexpected message of type %u (%u bytes)",
1355 ntohs (hdr->type), ntohs (hdr->size));
1363 * Task to (periodically) send a HELLO beacon
1365 * @param cls pointer to the plugin struct
1366 * @param tc scheduler context
1369 send_hello_beacon (void *cls,
1370 const struct GNUNET_SCHEDULER_TaskContext *tc)
1372 struct Plugin *plugin = cls;
1374 uint16_t hello_size;
1375 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader;
1376 const struct GNUNET_MessageHeader *hello;
1378 hello = plugin->env->get_our_hello ();
1379 hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
1380 GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU);
1381 size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size;
1383 char buf[size] GNUNET_ALIGN;
1385 LOG (GNUNET_ERROR_TYPE_DEBUG,
1386 "Sending %u byte HELLO beacon\n",
1387 (unsigned int) size);
1388 radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf;
1389 get_radiotap_header (NULL, radioHeader, size);
1390 get_wlan_header (plugin, &radioHeader->frame, &bc_all_mac, size);
1391 memcpy (&radioHeader[1], hello, hello_size);
1393 GNUNET_HELPER_send (plugin->suid_helper,
1394 &radioHeader->header,
1395 GNUNET_YES /* can drop */,
1397 GNUNET_STATISTICS_update (plugin->env->stats, _("# HELLO beacons sent via WLAN"),
1400 plugin->beacon_task =
1401 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
1402 (HELLO_BEACON_SCALING_FACTOR,
1403 plugin->mac_count + 1),
1411 * Another peer has suggested an address for this
1412 * peer and transport plugin. Check that this could be a valid
1413 * address. If so, consider adding it to the list
1416 * @param cls closure
1417 * @param addr pointer to the address
1418 * @param addrlen length of addr
1419 * @return GNUNET_OK if this is a plausible address for this peer
1423 wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
1425 struct Plugin *plugin = cls;
1427 if (addrlen != sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))
1429 GNUNET_break_op (0);
1430 return GNUNET_SYSERR;
1432 if (GNUNET_YES != plugin->have_mac)
1434 LOG (GNUNET_ERROR_TYPE_DEBUG,
1435 "Rejecting MAC `%s': I don't know my MAC!\n",
1436 mac_to_string (addr));
1437 return GNUNET_NO; /* don't know my MAC */
1439 if (0 != memcmp (addr,
1440 &plugin->mac_address,
1443 LOG (GNUNET_ERROR_TYPE_DEBUG,
1444 "Rejecting MAC `%s': not my MAC!\n",
1445 mac_to_string (addr));
1446 return GNUNET_NO; /* not my MAC */
1453 * Function called for a quick conversion of the binary address to
1454 * a numeric address. Note that the caller must not free the
1455 * address and that the next call to this function is allowed
1456 * to override the address again.
1458 * @param cls closure
1459 * @param addr binary address
1460 * @param addrlen length of the address
1461 * @return string representing the same address
1464 wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
1466 static char ret[40];
1467 const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac;
1469 if (sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress) != addrlen)
1475 GNUNET_snprintf (ret, sizeof (ret), "%s MAC address %s",
1477 mac_to_string (mac));
1483 * Convert the transports address to a nice, human-readable format.
1485 * @param cls closure
1486 * @param type name of the transport that generated the address
1487 * @param addr one of the addresses of the host, NULL for the last address
1488 * the specific address format depends on the transport
1489 * @param addrlen length of the address
1490 * @param numeric should (IP) addresses be displayed in numeric form?
1491 * @param timeout after how long should we give up?
1492 * @param asc function to call on each string
1493 * @param asc_cls closure for asc
1496 wlan_plugin_address_pretty_printer (void *cls, const char *type,
1497 const void *addr, size_t addrlen,
1499 struct GNUNET_TIME_Relative timeout,
1500 GNUNET_TRANSPORT_AddressStringCallback asc,
1503 const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac;
1506 if (sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress) != addrlen)
1508 /* invalid address */
1509 LOG (GNUNET_ERROR_TYPE_WARNING,
1510 _("WLAN address with invalid size encountered\n"));
1511 asc (asc_cls, NULL);
1515 GNUNET_asprintf (&ret,
1516 "%s MAC address %s",
1518 mac_to_string (mac));
1521 asc (asc_cls, NULL);
1526 * Exit point from the plugin.
1528 * @param cls pointer to the api struct
1531 libgnunet_plugin_transport_wlan_done (void *cls)
1533 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
1534 struct Plugin *plugin = api->cls;
1535 struct MacEndpoint *endpoint;
1536 struct MacEndpoint *endpoint_next;
1543 if (GNUNET_SCHEDULER_NO_TASK != plugin->beacon_task)
1545 GNUNET_SCHEDULER_cancel (plugin->beacon_task);
1546 plugin->beacon_task = GNUNET_SCHEDULER_NO_TASK;
1548 if (NULL != plugin->suid_helper)
1550 GNUNET_HELPER_stop (plugin->suid_helper);
1551 plugin->suid_helper = NULL;
1553 endpoint_next = plugin->mac_head;
1554 while (NULL != (endpoint = endpoint_next))
1556 endpoint_next = endpoint->next;
1557 free_macendpoint (endpoint);
1559 if (NULL != plugin->fragment_data_tokenizer)
1561 GNUNET_SERVER_mst_destroy (plugin->fragment_data_tokenizer);
1562 plugin->fragment_data_tokenizer = NULL;
1564 if (NULL != plugin->wlan_header_payload_tokenizer)
1566 GNUNET_SERVER_mst_destroy (plugin->wlan_header_payload_tokenizer);
1567 plugin->wlan_header_payload_tokenizer = NULL;
1569 if (NULL != plugin->helper_payload_tokenizer)
1571 GNUNET_SERVER_mst_destroy (plugin->helper_payload_tokenizer);
1572 plugin->helper_payload_tokenizer = NULL;
1574 GNUNET_free_non_null (plugin->interface);
1575 GNUNET_free (plugin);
1582 * Entry point for the plugin.
1584 * @param cls closure, the 'struct GNUNET_TRANSPORT_PluginEnvironment*'
1585 * @return the 'struct GNUNET_TRANSPORT_PluginFunctions*' or NULL on error
1588 libgnunet_plugin_transport_wlan_init (void *cls)
1590 struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
1591 struct GNUNET_TRANSPORT_PluginFunctions *api;
1592 struct Plugin *plugin;
1594 unsigned long long testmode;
1596 /* check for 'special' mode */
1597 if (NULL == env->receive)
1599 /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
1600 initialze the plugin or the API */
1601 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
1603 api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
1604 api->address_to_string = &wlan_plugin_address_to_string;
1605 api->string_to_address = NULL; // FIXME!
1610 /* check configuration */
1612 GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE")) &&
1614 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan",
1615 "TESTMODE", &testmode)) ||
1618 LOG (GNUNET_ERROR_TYPE_ERROR,
1619 _("Invalid configuration option `%s' in section `%s'\n"),
1624 if ( (0 == testmode) &&
1625 (GNUNET_YES != GNUNET_OS_check_helper_binary ("gnunet-helper-transport-wlan")) )
1627 LOG (GNUNET_ERROR_TYPE_ERROR,
1628 _("Helper binary `%s' not SUID, cannot run WLAN transport\n"),
1629 "gnunet-helper-transport-wlan");
1633 GNUNET_CONFIGURATION_get_value_string
1634 (env->cfg, "transport-wlan", "INTERFACE",
1637 LOG (GNUNET_ERROR_TYPE_ERROR,
1638 _("Missing configuration option `%s' in section `%s'\n"),
1644 plugin = GNUNET_malloc (sizeof (struct Plugin));
1645 plugin->interface = interface;
1647 GNUNET_STATISTICS_set (plugin->env->stats, _("# WLAN sessions allocated"),
1649 GNUNET_STATISTICS_set (plugin->env->stats, _("# WLAN MAC endpoints allocated"),
1651 GNUNET_BANDWIDTH_tracker_init (&plugin->tracker,
1652 GNUNET_BANDWIDTH_value_init (100 * 1024 *
1654 plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1655 plugin->wlan_header_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1656 plugin->helper_payload_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
1657 plugin->beacon_task = GNUNET_SCHEDULER_add_now (&send_hello_beacon,
1661 case 0: /* normal */
1662 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan";
1663 plugin->helper_argv[1] = interface;
1664 plugin->helper_argv[2] = NULL;
1665 plugin->suid_helper = GNUNET_HELPER_start ("gnunet-helper-transport-wlan",
1666 plugin->helper_argv,
1667 &handle_helper_message,
1670 case 1: /* testmode, peer 1 */
1671 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
1672 plugin->helper_argv[1] = (char *) "1";
1673 plugin->helper_argv[2] = NULL;
1674 plugin->suid_helper = GNUNET_HELPER_start ("gnunet-helper-transport-wlan-dummy",
1675 plugin->helper_argv,
1676 &handle_helper_message,
1679 case 2: /* testmode, peer 2 */
1680 plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
1681 plugin->helper_argv[1] = (char *) "2";
1682 plugin->helper_argv[2] = NULL;
1683 plugin->suid_helper = GNUNET_HELPER_start ("gnunet-helper-transport-wlan-dummy",
1684 plugin->helper_argv,
1685 &handle_helper_message,
1692 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
1694 api->send = &wlan_plugin_send;
1695 api->get_session = &wlan_plugin_get_session;
1696 api->disconnect = &wlan_plugin_disconnect;
1697 api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
1698 api->check_address = &wlan_plugin_address_suggested;
1699 api->address_to_string = &wlan_plugin_address_to_string;
1704 /* end of plugin_transport_wlan.c */