GNUnet  0.11.x
Data Structures | Macros | Typedefs | Functions | Variables
plugin_transport_wlan.c File Reference

transport plugin for wlan and/or bluetooth More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_plugin.h"
#include "plugin_transport_wlan.h"
#include "gnunet_fragmentation_lib.h"
#include "gnunet_constants.h"
#include "tcp_server_mst_legacy.c"
Include dependency graph for plugin_transport_wlan.c:

Go to the source code of this file.

Data Structures

struct  WlanHeader
 Header for messages which need fragmentation. More...
 
struct  WlanAddress
 Address format for WLAN. More...
 
struct  PendingMessage
 List containing all messages that are yet to be send. More...
 
struct  GNUNET_ATS_Session
 Session handle for connections. More...
 
struct  FragmentMessage
 Struct for messages that are being fragmented in a MAC's transmission queue. More...
 
struct  MacEndpoint
 Struct to represent one network card connection. More...
 
struct  Plugin
 Handle for a plugin. More...
 
struct  MacAndSession
 Information associated with a message. More...
 

Macros

#define WLAN_MTU   1430
 Max size of packet (that we give to the WLAN driver for transmission) More...
 
#define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC   2
 Maximum number of messages in defragmentation queue per MAC. More...
 
#define WLAN_LLC_DSAP_FIELD   0x1f
 Link layer control fields for better compatibility (i.e. More...
 
#define WLAN_LLC_SSAP_FIELD   0x1f
 

Typedefs

typedef int(* GNUNET_SERVER_MessageTokenizerCallback) (void *cls, void *client, const struct GNUNET_MessageHeader *message)
 Functions with this signature are called whenever a complete message is received by the tokenizer. More...
 

Functions

static const char * mac_to_string (const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
 Print MAC addresses nicely. More...
 
static const char * wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
 Function called for a quick conversion of the binary address to a numeric address. More...
 
static void notify_session_monitor (struct Plugin *plugin, struct GNUNET_ATS_Session *session, enum GNUNET_TRANSPORT_SessionState state)
 If a session monitor is attached, notify it about the new session state. More...
 
static void get_radiotap_header (struct MacEndpoint *endpoint, struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header, uint16_t size)
 Fill the radiotap header. More...
 
static void get_wlan_header (struct Plugin *plugin, struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header, const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, unsigned int size)
 Generate the WLAN hardware header for one packet. More...
 
static void send_ack (void *cls, uint32_t msg_id, const struct GNUNET_MessageHeader *hdr)
 Send an ACK for a fragment we received. More...
 
static void wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
 Handles the data after all fragments are put together. More...
 
static int wlan_plugin_disconnect_session (void *cls, struct GNUNET_ATS_Session *session)
 Free a session. More...
 
static unsigned int wlan_plugin_query_keepalive_factor (void *cls)
 Function that is called to get the keepalive factor. More...
 
static void session_timeout (void *cls)
 A session is timing out. More...
 
static struct GNUNET_ATS_Sessionlookup_session (struct MacEndpoint *endpoint, const struct GNUNET_PeerIdentity *peer)
 Lookup a new session. More...
 
static struct GNUNET_ATS_Sessioncreate_session (struct MacEndpoint *endpoint, const struct GNUNET_PeerIdentity *peer)
 Create a new session. More...
 
static struct GNUNET_ATS_Sessionget_session (struct MacEndpoint *endpoint, const struct GNUNET_PeerIdentity *peer)
 Look up a session for a peer and create a new session if none is found. More...
 
static void fragment_transmission_done (void *cls, int result)
 Function called once we have successfully given the fragment message to the SUID helper process and we are thus ready for the next fragment. More...
 
static void transmit_fragment (void *cls, const struct GNUNET_MessageHeader *hdr)
 Transmit a fragment of a message. More...
 
static void free_fragment_message (struct FragmentMessage *fm)
 Frees the space of a message in the fragment queue (send queue) More...
 
static void fragmentmessage_timeout (void *cls)
 A FragmentMessage has timed out. More...
 
static void send_with_fragmentation (struct MacEndpoint *endpoint, struct GNUNET_TIME_Relative timeout, const struct GNUNET_PeerIdentity *target, const struct GNUNET_MessageHeader *msg, size_t payload_size, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
 Transmit a message to the given destination with fragmentation. More...
 
static void free_macendpoint (struct MacEndpoint *endpoint)
 Free a MAC endpoint. More...
 
static void macendpoint_timeout (void *cls)
 A MAC endpoint is timing out. More...
 
static struct MacEndpointcreate_macendpoint (struct Plugin *plugin, struct WlanAddress *mac)
 Find (or create) a MacEndpoint with a specific MAC address. More...
 
static enum GNUNET_NetworkType wlan_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session)
 Function obtain the network type for a session. More...
 
static enum GNUNET_NetworkType wlan_plugin_get_network_for_address (void *cls, const struct GNUNET_HELLO_Address *address)
 Function obtain the network type for an address. More...
 
static struct GNUNET_ATS_Sessionwlan_plugin_get_session (void *cls, const struct GNUNET_HELLO_Address *address)
 Creates a new outbound session the transport service will use to send data to the peer. More...
 
static void wlan_plugin_disconnect_peer (void *cls, const struct GNUNET_PeerIdentity *target)
 Function that can be used to force the plugin to disconnect from the given peer and cancel all previous transmissions (and their continuation). More...
 
static ssize_t wlan_plugin_send (void *cls, struct GNUNET_ATS_Session *session, const char *msgbuf, size_t msgbuf_size, unsigned int priority, struct GNUNET_TIME_Relative to, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
 Function that can be used by the transport service to transmit a message using the plugin. More...
 
static int process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
 We have received data from the WLAN via some session. More...
 
static void send_hello_beacon (void *cls)
 Task to (periodically) send a HELLO beacon. More...
 
static int handle_helper_message (void *cls, const struct GNUNET_MessageHeader *hdr)
 Function used for to process the data from the suid process. More...
 
static int wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
 Another peer has suggested an address for this peer and transport plugin. More...
 
static void wlan_plugin_address_pretty_printer (void *cls, const char *type, const void *addr, size_t addrlen, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressStringCallback asc, void *asc_cls)
 Convert the transports address to a nice, human-readable format. More...
 
void * LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
 Exit point from the plugin. More...
 
static int wlan_plugin_string_to_address (void *cls, const char *addr, uint16_t addrlen, void **buf, size_t *added)
 Function called to convert a string address to a binary address. More...
 
static void wlan_plugin_setup_monitor (void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls)
 Begin monitoring sessions of a plugin. More...
 
static void wlan_plugin_update_session_timeout (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session)
 Function that will be called whenever the transport service wants to notify the plugin that a session is still active and in use and therefore the session timeout for this session has to be updated. More...
 
static void wlan_plugin_update_inbound_delay (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session, struct GNUNET_TIME_Relative delay)
 Function that will be called whenever the transport service wants to notify the plugin that the inbound quota changed and that the plugin should update it's delay for the next receive value. More...
 
void * LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
 Entry point for the plugin. More...
 

Variables

static enum GNUNET_NetworkType scope = GNUNET_NT_BT
 Which network scope do we belong to? More...
 

Detailed Description

transport plugin for wlan and/or bluetooth

Author
David Brodski
Christian Grothoff

BUILD_WLAN or BUILD_BLUETOOTH must be defined such that the respective variant of this code is compiled.

Definition in file plugin_transport_wlan.c.

Macro Definition Documentation

◆ WLAN_MTU

#define WLAN_MTU   1430

Max size of packet (that we give to the WLAN driver for transmission)

Definition at line 131 of file plugin_transport_wlan.c.

◆ MESSAGES_IN_DEFRAG_QUEUE_PER_MAC

#define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC   2

Maximum number of messages in defragmentation queue per MAC.

Definition at line 147 of file plugin_transport_wlan.c.

◆ WLAN_LLC_DSAP_FIELD

#define WLAN_LLC_DSAP_FIELD   0x1f

Link layer control fields for better compatibility (i.e.

GNUnet over WLAN is not IP-over-WLAN).

Definition at line 153 of file plugin_transport_wlan.c.

◆ WLAN_LLC_SSAP_FIELD

#define WLAN_LLC_SSAP_FIELD   0x1f

Definition at line 154 of file plugin_transport_wlan.c.

Typedef Documentation

◆ GNUNET_SERVER_MessageTokenizerCallback

typedef int(* GNUNET_SERVER_MessageTokenizerCallback) (void *cls, void *client, const struct GNUNET_MessageHeader *message)

Functions with this signature are called whenever a complete message is received by the tokenizer.

Do not call GNUNET_SERVER_mst_destroy from within the scope of this callback.

Parameters
clsclosure
clientidentification of the client
messagethe actual message
Returns
GNUNET_OK on success, GNUNET_SYSERR to stop further processing

Definition at line 117 of file plugin_transport_wlan.c.

Function Documentation

◆ mac_to_string()

static const char* mac_to_string ( const struct GNUNET_TRANSPORT_WLAN_MacAddress mac)
static

Print MAC addresses nicely.

Parameters
macthe mac address
Returns
string to a static buffer with the human-readable mac, will be overwritten during the next call to this function

Definition at line 584 of file plugin_transport_wlan.c.

585 {
586  static char macstr[20];
587 
588  GNUNET_snprintf (macstr,
589  sizeof(macstr),
590  "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
591  mac->mac[0], mac->mac[1],
592  mac->mac[2], mac->mac[3],
593  mac->mac[4], mac->mac[5]);
594  return macstr;
595 }
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.

References GNUNET_snprintf(), and GNUNET_TRANSPORT_WLAN_MacAddress::mac.

Referenced by create_session(), handle_helper_message(), send_ack(), send_hello_beacon(), transmit_fragment(), wlan_plugin_address_suggested(), and wlan_plugin_address_to_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wlan_plugin_address_to_string()

static const char* wlan_plugin_address_to_string ( void *  cls,
const void *  addr,
size_t  addrlen 
)
static

Function called for a quick conversion of the binary address to a numeric address.

Note that the caller must not free the address and that the next call to this function is allowed to override the address again.

Parameters
clsclosure
addrbinary address
addrlenlength of the address
Returns
string representing the same address

Definition at line 610 of file plugin_transport_wlan.c.

613 {
615  static char macstr[36];
616 
617  if (sizeof(struct WlanAddress) != addrlen)
618  {
619  GNUNET_break (0);
620  return NULL;
621  }
622  mac = &((struct WlanAddress *) addr)->mac;
623  GNUNET_snprintf (macstr,
624  sizeof(macstr),
625  "%s.%u.%s",
626  PLUGIN_NAME,
627  ntohl (((struct WlanAddress *) addr)->options),
628  mac_to_string (mac));
629  return macstr;
630 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define PLUGIN_NAME
static const char * mac_to_string(const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
Print MAC addresses nicely.
Address format for WLAN.
struct GNUNET_TRANSPORT_WLAN_MacAddress mac
WLAN addresses using MACs.

References GNUNET_break, GNUNET_snprintf(), WlanAddress::mac, GNUNET_TRANSPORT_WLAN_MacAddress::mac, mac_to_string(), options, and PLUGIN_NAME.

Referenced by create_macendpoint(), process_data(), wlan_plugin_address_pretty_printer(), and wlan_plugin_get_session().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_session_monitor()

static void notify_session_monitor ( struct Plugin plugin,
struct GNUNET_ATS_Session session,
enum GNUNET_TRANSPORT_SessionState  state 
)
static

If a session monitor is attached, notify it about the new session state.

Parameters
pluginour plugin
sessionsession that changed state
statenew state of the session

Definition at line 642 of file plugin_transport_wlan.c.

645 {
646  struct GNUNET_TRANSPORT_SessionInfo info;
647 
648  if (NULL == plugin->sic)
649  return;
650  memset (&info, 0, sizeof(info));
651  info.state = state;
652  info.is_inbound = GNUNET_SYSERR; /* hard to say */
653  info.num_msg_pending = 0; /* we queue per MAC, not per peer */
654  info.num_bytes_pending = 0; /* we queue per MAC, not per peer */
655  info.receive_delay = GNUNET_TIME_UNIT_ZERO_ABS; /* not supported by WLAN */
656  info.session_timeout = session->timeout;
657  info.address = session->address;
659  session,
660  &info);
661 }
struct Plugin * plugin
The process handle to the testbed service.
enum State state
current state of profiling
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_TIME_Absolute timeout
When does this session time out.
struct GNUNET_HELLO_Address * address
Address.
Information about a plugin's session.
void * sic_cls
Closure for sic.
GNUNET_TRANSPORT_SessionInfoCallback sic
Function to call about session status changes.

References GNUNET_TRANSPORT_SessionInfo::address, GNUNET_ATS_Session::address, GNUNET_SYSERR, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_SessionInfo::is_inbound, GNUNET_TRANSPORT_SessionInfo::num_bytes_pending, GNUNET_TRANSPORT_SessionInfo::num_msg_pending, plugin, GNUNET_TRANSPORT_SessionInfo::receive_delay, GNUNET_TRANSPORT_SessionInfo::session_timeout, Plugin::sic, Plugin::sic_cls, GNUNET_TRANSPORT_SessionInfo::state, state, and GNUNET_ATS_Session::timeout.

Referenced by create_session(), wlan_plugin_disconnect_session(), and wlan_plugin_setup_monitor().

Here is the caller graph for this function:

◆ get_radiotap_header()

static void get_radiotap_header ( struct MacEndpoint endpoint,
struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage header,
uint16_t  size 
)
static

Fill the radiotap header.

Parameters
endpointpointer to the endpoint, can be NULL
headerpointer to the radiotap header
sizetotal message size

Definition at line 672 of file plugin_transport_wlan.c.

675 {
677  header->header.size = ntohs (size);
678  if (NULL != endpoint)
679  {
680  header->rate = endpoint->rate;
681  header->tx_power = endpoint->tx_power;
682  header->antenna = endpoint->antenna;
683  }
684  else
685  {
686  header->rate = 255;
687  header->tx_power = 0;
688  header->antenna = 0;
689  }
690 }
#define GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER
Type of data messages from the plugin to the gnunet-wlan-helper.
static unsigned int size
Size of the "table".
Definition: peer.c:67
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
uint16_t tx_power
Transmit power expressed as unitless distance from max power set at factory calibration.
struct GNUNET_MessageHeader header
Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER'.
uint8_t antenna
Antenna; the first antenna is 0.
uint8_t rate
Desired transmission rate for this MAC.
uint8_t antenna
Antenna we should use for this MAC.
uint16_t tx_power
Desired transmission power for this MAC.

References MacEndpoint::antenna, GNUNET_TRANSPORT_WLAN_RadiotapSendMessage::antenna, GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER, GNUNET_TRANSPORT_WLAN_RadiotapSendMessage::header, MacEndpoint::rate, GNUNET_TRANSPORT_WLAN_RadiotapSendMessage::rate, GNUNET_MessageHeader::size, size, MacEndpoint::tx_power, GNUNET_TRANSPORT_WLAN_RadiotapSendMessage::tx_power, and GNUNET_MessageHeader::type.

Referenced by send_ack(), send_hello_beacon(), and transmit_fragment().

Here is the caller graph for this function:

◆ get_wlan_header()

static void get_wlan_header ( struct Plugin plugin,
struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame header,
const struct GNUNET_TRANSPORT_WLAN_MacAddress to_mac_addr,
unsigned int  size 
)
static

Generate the WLAN hardware header for one packet.

Parameters
pluginthe plugin handle
headeraddress to write the header to
to_mac_addraddress of the recipient
sizesize of the whole packet, needed to calculate the time to send the packet

Definition at line 702 of file plugin_transport_wlan.c.

706 {
707  const int rate = 11000000;
708 
709  header->frame_control = htons (IEEE80211_FC0_TYPE_DATA);
710  header->addr1 = *to_mac_addr;
711  header->addr2 = plugin->mac_address;
712  header->addr3 = mac_bssid_gnunet;
713  header->duration = GNUNET_htole16 ((size * 1000000) / rate + 290);
714  header->sequence_control = 0; // FIXME?
715  header->llc[0] = WLAN_LLC_DSAP_FIELD;
716  header->llc[1] = WLAN_LLC_SSAP_FIELD;
717  header->llc[2] = 0; // FIXME?
718  header->llc[3] = 0; // FIXME?
719 }
#define IEEE80211_FC0_TYPE_DATA
#define GNUNET_htole16(x)
#define WLAN_LLC_DSAP_FIELD
Link layer control fields for better compatibility (i.e.
#define WLAN_LLC_SSAP_FIELD
static GNUNET_NETWORK_STRUCT_END const struct GNUNET_TRANSPORT_WLAN_MacAddress mac_bssid_gnunet
GNUnet bssid.
uint16_t frame_control
802.11 Frame Control field.
struct GNUNET_TRANSPORT_WLAN_MacAddress addr1
Address 1: destination address in ad-hoc mode or AP, BSSID if station,.
uint16_t duration
Microseconds to reserve link (duration), 0 by default.
u_int8_t llc[4]
Link layer control (LLC).
struct GNUNET_TRANSPORT_WLAN_MacAddress addr3
Address 3: BSSID in ad-hoc mode, Destination if station, source if AP.
struct GNUNET_TRANSPORT_WLAN_MacAddress addr2
Address 2: source address if in ad-hoc-mode or station, BSSID if AP.
uint16_t sequence_control
802.11 sequence control field; contains fragment number an sequence number (we set this to all zeros)...
struct GNUNET_TRANSPORT_WLAN_MacAddress mac_address
The mac_address of the wlan card given to us by the helper.

References GNUNET_TRANSPORT_WLAN_Ieee80211Frame::addr1, GNUNET_TRANSPORT_WLAN_Ieee80211Frame::addr2, GNUNET_TRANSPORT_WLAN_Ieee80211Frame::addr3, GNUNET_TRANSPORT_WLAN_Ieee80211Frame::duration, GNUNET_TRANSPORT_WLAN_Ieee80211Frame::frame_control, GNUNET_htole16, IEEE80211_FC0_TYPE_DATA, GNUNET_TRANSPORT_WLAN_Ieee80211Frame::llc, Plugin::mac_address, mac_bssid_gnunet, plugin, GNUNET_TRANSPORT_WLAN_Ieee80211Frame::sequence_control, size, WLAN_LLC_DSAP_FIELD, and WLAN_LLC_SSAP_FIELD.

Referenced by send_ack(), send_hello_beacon(), and transmit_fragment().

Here is the caller graph for this function:

◆ send_ack()

static void send_ack ( void *  cls,
uint32_t  msg_id,
const struct GNUNET_MessageHeader hdr 
)
static

Send an ACK for a fragment we received.

Parameters
clsthe struct MacEndpoint * the ACK must be sent to
msg_idid of the message
hdrpointer to the hdr where the ack is stored

Definition at line 730 of file plugin_transport_wlan.c.

733 {
734  struct MacEndpoint *endpoint = cls;
735  struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*radio_header;
736  uint16_t msize = ntohs (hdr->size);
737  size_t size = sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)
738  + msize;
739  char buf[size];
740 
741  if (NULL == endpoint)
742  {
743  GNUNET_break (0);
744  return;
745  }
747  {
748  GNUNET_break (0);
749  return;
750  }
752  "Sending ACK to %s\n",
753  mac_to_string (&endpoint->wlan_addr.mac));
754  radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
755  get_radiotap_header (endpoint, radio_header, size);
756  get_wlan_header (endpoint->plugin,
757  &radio_header->frame,
758  &endpoint->wlan_addr.mac,
759  sizeof(endpoint->wlan_addr.mac));
760  GNUNET_memcpy (&radio_header[1], hdr, msize);
761  if (NULL !=
763  &radio_header->header,
764  GNUNET_NO /* dropping ACKs is bad */,
765  NULL, NULL))
766  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
767  _ ("# ACKs sent"),
768  1, GNUNET_NO);
769 }
#define LOG(kind,...)
Definition: abd_api.c:38
static char buf[2048]
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_NO
Definition: gnunet_common.h:94
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send(struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, int can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls)
Send an message to the helper.
Definition: helper.c:657
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
static void get_wlan_header(struct Plugin *plugin, struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *header, const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, unsigned int size)
Generate the WLAN hardware header for one packet.
static void get_radiotap_header(struct MacEndpoint *endpoint, struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header, uint16_t size)
Fill the radiotap header.
Message from the plugin to the WLAN helper: send the given message with the given connection paramete...
struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame
IEEE Frame to transmit (the sender MAC address will be overwritten by the helper as it does not trust...
Struct to represent one network card connection.
struct Plugin * plugin
Pointer to the global plugin struct.
struct WlanAddress wlan_addr
peer MAC address
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
struct GNUNET_HELPER_Handle * suid_helper
Handle to helper process for privileged operations.

References _, buf, Plugin::env, GNUNET_TRANSPORT_WLAN_RadiotapSendMessage::frame, get_radiotap_header(), get_wlan_header(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELPER_send(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TRANSPORT_WLAN_RadiotapSendMessage::header, LOG, WlanAddress::mac, mac_to_string(), MacEndpoint::plugin, GNUNET_MessageHeader::size, size, Plugin::suid_helper, and MacEndpoint::wlan_addr.

Referenced by create_macendpoint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wlan_data_message_handler()

static void wlan_data_message_handler ( void *  cls,
const struct GNUNET_MessageHeader hdr 
)
static

Handles the data after all fragments are put together.

Parameters
clsmacendpoint this messages belongs to
hdrpointer to the data

Definition at line 779 of file plugin_transport_wlan.c.

781 {
782  struct MacEndpoint *endpoint = cls;
783  struct Plugin *plugin = endpoint->plugin;
784  struct MacAndSession mas;
785 
787  _ ("# Messages defragmented"),
788  1,
789  GNUNET_NO);
790  mas.session = NULL;
791  mas.endpoint = endpoint;
793  &mas,
794  (const char *) hdr,
795  ntohs (hdr->size),
797 }
@ GNUNET_YES
Definition: gnunet_common.h:97
int GNUNET_SERVER_mst_receive(struct GNUNET_SERVER_MessageStreamTokenizer *mst, void *client_identity, const char *buf, size_t size, int purge, int one_shot)
Add incoming data to the receive buffer and call the callback for all complete messages.
Information associated with a message.
struct MacEndpoint * endpoint
MAC address of the other peer, NULL if not known.
Handle for a plugin.
Definition: block.c:38
struct GNUNET_SERVER_MessageStreamTokenizer * fragment_data_tokenizer
Tokenizer for demultiplexing of data packets resulting from defragmentation.

References _, MacAndSession::endpoint, Plugin::env, Plugin::fragment_data_tokenizer, GNUNET_NO, GNUNET_SERVER_mst_receive(), GNUNET_STATISTICS_update(), GNUNET_YES, plugin, MacEndpoint::plugin, MacAndSession::session, and GNUNET_MessageHeader::size.

Referenced by create_macendpoint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wlan_plugin_disconnect_session()

static int wlan_plugin_disconnect_session ( void *  cls,
struct GNUNET_ATS_Session session 
)
static

Free a session.

Parameters
clsour struct Plugin.
sessionthe session free

Definition at line 807 of file plugin_transport_wlan.c.

809 {
810  struct MacEndpoint *endpoint = session->mac;
811  struct Plugin *plugin = endpoint->plugin;
812 
813  plugin->env->session_end (plugin->env->cls,
814  session->address,
815  session);
817  session,
820  endpoint->sessions_tail,
821  session);
822  if (session->timeout_task != NULL)
823  {
825  session->timeout_task = NULL;
826  }
828  _ ("# Sessions allocated"),
829  -1,
830  GNUNET_NO);
832  GNUNET_free (session);
833  return GNUNET_OK;
834 }
@ GNUNET_OK
Definition: gnunet_common.h:95
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_HELLO_address_free(addr)
Free an address.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
@ GNUNET_TRANSPORT_SS_DONE
Session is being torn down and about to disappear.
static void notify_session_monitor(struct Plugin *plugin, struct GNUNET_ATS_Session *session, enum GNUNET_TRANSPORT_SessionState state)
If a session monitor is attached, notify it about the new session state.
struct MacEndpoint * mac
MAC endpoint with the address of this peer.
struct GNUNET_SCHEDULER_Task * timeout_task
Session timeout task.
void * cls
Closure to use for callbacks.
struct GNUNET_ATS_Session * sessions_head
Head of sessions that use this MAC.
struct GNUNET_ATS_Session * sessions_tail
Tail of sessions that use this MAC.

References _, GNUNET_ATS_Session::address, GNUNET_DATACACHE_PluginEnvironment::cls, Plugin::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_HELLO_address_free, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_TRANSPORT_SS_DONE, GNUNET_ATS_Session::mac, notify_session_monitor(), plugin, MacEndpoint::plugin, MacEndpoint::sessions_head, MacEndpoint::sessions_tail, and GNUNET_ATS_Session::timeout_task.

Referenced by free_macendpoint(), session_timeout(), and wlan_plugin_disconnect_peer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wlan_plugin_query_keepalive_factor()

static unsigned int wlan_plugin_query_keepalive_factor ( void *  cls)
static

Function that is called to get the keepalive factor.

GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to calculate the interval between keepalive packets.

Parameters
clsclosure with the struct Plugin
Returns
keepalive factor

Definition at line 846 of file plugin_transport_wlan.c.

847 {
848  return 3;
849 }

◆ session_timeout()

static void session_timeout ( void *  cls)
static

A session is timing out.

Clean up.

Parameters
clspointer to the Session

Definition at line 858 of file plugin_transport_wlan.c.

859 {
860  struct GNUNET_ATS_Session *session = cls;
861  struct GNUNET_TIME_Relative left;
862 
863  session->timeout_task = NULL;
865  if (0 != left.rel_value_us)
866  {
867  session->timeout_task =
870  session);
871  return;
872  }
874  session);
875 }
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1269
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:232
static void session_timeout(void *cls)
A session is timing out.
static int wlan_plugin_disconnect_session(void *cls, struct GNUNET_ATS_Session *session)
Free a session.
Session handle for connections.
Time for relative time used by GNUnet, in microseconds.

References GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_absolute_get_remaining(), GNUNET_ATS_Session::mac, MacEndpoint::plugin, GNUNET_TIME_Relative::rel_value_us, GNUNET_ATS_Session::timeout, GNUNET_ATS_Session::timeout_task, and wlan_plugin_disconnect_session().

Referenced by create_session().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup_session()

static struct GNUNET_ATS_Session* lookup_session ( struct MacEndpoint endpoint,
const struct GNUNET_PeerIdentity peer 
)
static

Lookup a new session.

Parameters
endpointpointer to the mac endpoint of the peer
peerpeer identity to use for this session
Returns
returns the session or NULL

Definition at line 886 of file plugin_transport_wlan.c.

888 {
889  struct GNUNET_ATS_Session *session;
890 
891  for (session = endpoint->sessions_head; NULL != session; session =
892  session->next)
893  if (0 == memcmp (peer, &session->target, sizeof(struct
895  return session;
896  return NULL;
897 }
struct GNUNET_PeerIdentity target
To whom are we talking to.
struct GNUNET_ATS_Session * next
Stored in a linked list.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References GNUNET_ATS_Session::next, peer, MacEndpoint::sessions_head, and GNUNET_ATS_Session::target.

Referenced by get_session(), and process_data().

Here is the caller graph for this function:

◆ create_session()

static struct GNUNET_ATS_Session* create_session ( struct MacEndpoint endpoint,
const struct GNUNET_PeerIdentity peer 
)
static

Create a new session.

Parameters
endpointpointer to the mac endpoint of the peer
peerpeer identity to use for this session
Returns
returns the session or NULL

Definition at line 908 of file plugin_transport_wlan.c.

910 {
911  struct GNUNET_ATS_Session *session;
912 
913  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
914  _ ("# Sessions allocated"),
915  1,
916  GNUNET_NO);
917  session = GNUNET_new (struct GNUNET_ATS_Session);
919  endpoint->sessions_tail,
920  session);
922  PLUGIN_NAME,
923  &endpoint->wlan_addr,
924  sizeof(endpoint->wlan_addr),
926  session->mac = endpoint;
927  session->target = *peer;
930  session->timeout_task =
933  session);
934  notify_session_monitor (endpoint->plugin,
935  session,
937  notify_session_monitor (endpoint->plugin,
938  session,
941  "Created new session %p for peer `%s' with endpoint %s\n",
942  session,
943  GNUNET_i2s (peer),
944  mac_to_string (&endpoint->wlan_addr.mac));
945 
946  return session;
947 }
#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
After how long do we consider a connection to a peer dead if we don't receive messages from the peer?
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_allocate(const struct GNUNET_PeerIdentity *peer, const char *transport_name, const void *address, size_t address_length, enum GNUNET_HELLO_AddressInfo local_info)
Allocate an address struct.
Definition: address.c:73
@ GNUNET_HELLO_ADDRESS_INFO_NONE
No additional information.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:181
@ GNUNET_TRANSPORT_SS_INIT
The session was created (first call for each session object).
@ GNUNET_TRANSPORT_SS_UP
Session is fully UP.

References _, GNUNET_ATS_Session::address, Plugin::env, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_address_allocate(), GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_i2s(), GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_TIME_relative_to_absolute(), GNUNET_TRANSPORT_SS_INIT, GNUNET_TRANSPORT_SS_UP, LOG, WlanAddress::mac, GNUNET_ATS_Session::mac, mac_to_string(), notify_session_monitor(), peer, MacEndpoint::plugin, PLUGIN_NAME, session_timeout(), MacEndpoint::sessions_head, MacEndpoint::sessions_tail, GNUNET_ATS_Session::target, GNUNET_ATS_Session::timeout, GNUNET_ATS_Session::timeout_task, and MacEndpoint::wlan_addr.

Referenced by get_session(), and process_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_session()

static struct GNUNET_ATS_Session* get_session ( struct MacEndpoint endpoint,
const struct GNUNET_PeerIdentity peer 
)
static

Look up a session for a peer and create a new session if none is found.

Parameters
endpointpointer to the mac endpoint of the peer
peerpeer identity to use for this session
Returns
returns the session

Definition at line 958 of file plugin_transport_wlan.c.

960 {
961  struct GNUNET_ATS_Session *session;
962 
963  if (NULL != (session = lookup_session (endpoint, peer)))
964  return session;
965  return create_session (endpoint, peer);
966 }
static struct GNUNET_ATS_Session * create_session(struct MacEndpoint *endpoint, const struct GNUNET_PeerIdentity *peer)
Create a new session.
static struct GNUNET_ATS_Session * lookup_session(struct MacEndpoint *endpoint, const struct GNUNET_PeerIdentity *peer)
Lookup a new session.

References create_session(), lookup_session(), and peer.

Referenced by wlan_plugin_get_session().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fragment_transmission_done()

static void fragment_transmission_done ( void *  cls,
int  result 
)
static

Function called once we have successfully given the fragment message to the SUID helper process and we are thus ready for the next fragment.

Parameters
clsthe struct FragmentMessage *
resultresult of the operation (GNUNET_OK on success, GNUNET_NO if the helper died, GNUNET_SYSERR if the helper was stopped)

Definition at line 980 of file plugin_transport_wlan.c.

982 {
983  struct FragmentMessage *fm = cls;
984 
985  fm->sh = NULL;
987 }
void GNUNET_FRAGMENT_context_transmission_done(struct GNUNET_FRAGMENT_Context *fc)
Continuation to call from the 'proc' function after the fragment has been transmitted (and hence the ...
Struct for messages that are being fragmented in a MAC's transmission queue.
struct GNUNET_HELPER_SendHandle * sh
Transmission handle to helper (to cancel if the frag context is destroyed early for some reason).
struct GNUNET_FRAGMENT_Context * fragcontext
Fragmentation context.

References FragmentMessage::fragcontext, GNUNET_FRAGMENT_context_transmission_done(), and FragmentMessage::sh.

Referenced by transmit_fragment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transmit_fragment()

static void transmit_fragment ( void *  cls,
const struct GNUNET_MessageHeader hdr 
)
static

Transmit a fragment of a message.

Parameters
clsstruct FragmentMessage * this fragment message belongs to
hdrpointer to the start of the fragment message

Definition at line 997 of file plugin_transport_wlan.c.

999 {
1000  struct FragmentMessage *fm = cls;
1001  struct MacEndpoint *endpoint = fm->macendpoint;
1002  size_t size;
1003  uint16_t msize;
1004 
1005  if (NULL == endpoint)
1006  {
1007  GNUNET_break (0);
1008  return;
1009  }
1010  msize = ntohs (hdr->size);
1011  size = sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize;
1012  {
1013  char buf[size];
1014  struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radio_header;
1015 
1016  radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
1017  get_radiotap_header (endpoint, radio_header, size);
1019  "Sending %u bytes of data to MAC `%s'\n",
1020  (unsigned int) msize,
1021  mac_to_string (&endpoint->wlan_addr.mac));
1022 
1023  get_wlan_header (endpoint->plugin,
1024  &radio_header->frame,
1025  &endpoint->wlan_addr.mac,
1026  sizeof(endpoint->wlan_addr.mac));
1027  GNUNET_memcpy (&radio_header[1], hdr, msize);
1028  GNUNET_assert (NULL == fm->sh);
1029  fm->sh = GNUNET_HELPER_send (endpoint->plugin->suid_helper,
1030  &radio_header->header,
1031  GNUNET_NO,
1033  fm->size_on_wire += size;
1034  if (NULL != fm->sh)
1035  {
1036  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
1037  _ ("# message fragments sent"),
1038  1,
1039  GNUNET_NO);
1040  }
1041  else
1042  {
1044  }
1045  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
1046  "# bytes currently in buffers",
1047  -msize, GNUNET_NO);
1048  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
1049  "# bytes transmitted",
1050  msize, GNUNET_NO);
1051  }
1052 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void fragment_transmission_done(void *cls, int result)
Function called once we have successfully given the fragment message to the SUID helper process and w...
size_t size_on_wire
Number of bytes used to transmit message.
struct MacEndpoint * macendpoint
MAC endpoint this message belongs to.

References _, buf, Plugin::env, FragmentMessage::fragcontext, fragment_transmission_done(), GNUNET_TRANSPORT_WLAN_RadiotapSendMessage::frame, get_radiotap_header(), get_wlan_header(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FRAGMENT_context_transmission_done(), GNUNET_HELPER_send(), GNUNET_memcpy, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TRANSPORT_WLAN_RadiotapSendMessage::header, LOG, WlanAddress::mac, mac_to_string(), FragmentMessage::macendpoint, MacEndpoint::plugin, FragmentMessage::sh, GNUNET_MessageHeader::size, size, FragmentMessage::size_on_wire, Plugin::suid_helper, and MacEndpoint::wlan_addr.

Referenced by handle_helper_message(), and send_with_fragmentation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_fragment_message()

static void free_fragment_message ( struct FragmentMessage fm)
static

Frees the space of a message in the fragment queue (send queue)

Parameters
fmmessage to free

Definition at line 1061 of file plugin_transport_wlan.c.

1062 {
1063  struct MacEndpoint *endpoint = fm->macendpoint;
1064 
1065  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
1066  _ ("# messages pending (with fragmentation)"),
1067  -1, GNUNET_NO);
1069  endpoint->sending_messages_tail,
1070  fm);
1071  if (NULL != fm->sh)
1072  {
1074  fm->sh = NULL;
1075  }
1076  if (NULL != fm->msg)
1077  {
1078  GNUNET_free (fm->msg);
1079  fm->msg = NULL;
1080  }
1081  if (NULL != fm->fragcontext)
1082  {
1084  &endpoint->msg_delay,
1085  &endpoint->ack_delay);
1086  fm->fragcontext = NULL;
1087  }
1088  if (NULL != fm->timeout_task)
1089  {
1091  fm->timeout_task = NULL;
1092  }
1093  GNUNET_free (fm);
1094 }
void GNUNET_FRAGMENT_context_destroy(struct GNUNET_FRAGMENT_Context *fc, struct GNUNET_TIME_Relative *msg_delay, struct GNUNET_TIME_Relative *ack_delay)
Destroy the given fragmentation context (stop calling 'proc', free resources).
void GNUNET_HELPER_send_cancel(struct GNUNET_HELPER_SendHandle *sh)
Cancel a GNUNET_HELPER_send operation.
Definition: helper.c:697
struct GNUNET_MessageHeader * msg
Message we need to fragment and transmit, NULL after the fragmentcontext has been created.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
struct GNUNET_TIME_Relative ack_delay
ACK delay for fragmentation context.
struct GNUNET_TIME_Relative msg_delay
Message delay for fragmentation context.
struct FragmentMessage * sending_messages_head
Head of messages we are currently sending to this MAC.
struct FragmentMessage * sending_messages_tail
Tail of messages we are currently sending to this MAC.

References _, MacEndpoint::ack_delay, Plugin::env, FragmentMessage::fragcontext, GNUNET_CONTAINER_DLL_remove, GNUNET_FRAGMENT_context_destroy(), GNUNET_free, GNUNET_HELPER_send_cancel(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), FragmentMessage::macendpoint, FragmentMessage::msg, MacEndpoint::msg_delay, MacEndpoint::plugin, MacEndpoint::sending_messages_head, MacEndpoint::sending_messages_tail, FragmentMessage::sh, and FragmentMessage::timeout_task.

Referenced by fragmentmessage_timeout(), free_macendpoint(), and process_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fragmentmessage_timeout()

static void fragmentmessage_timeout ( void *  cls)
static

A FragmentMessage has timed out.

Remove it.

Parameters
clspointer to the 'struct FragmentMessage'

Definition at line 1103 of file plugin_transport_wlan.c.

1104 {
1105  struct FragmentMessage *fm = cls;
1106 
1107  fm->timeout_task = NULL;
1108  if (NULL != fm->cont)
1109  {
1110  fm->cont (fm->cont_cls,
1111  &fm->target,
1112  GNUNET_SYSERR,
1113  fm->size_payload,
1114  fm->size_on_wire);
1115  fm->cont = NULL;
1116  }
1117  free_fragment_message (fm);
1118 }
static void free_fragment_message(struct FragmentMessage *fm)
Frees the space of a message in the fragment queue (send queue)
struct GNUNET_PeerIdentity target
Intended recipient.
GNUNET_TRANSPORT_TransmitContinuation cont
Continuation to call when we're done with this message.
void * cont_cls
Closure for cont.
size_t size_payload
Size of original message.

References FragmentMessage::cont, FragmentMessage::cont_cls, free_fragment_message(), GNUNET_SYSERR, FragmentMessage::size_on_wire, FragmentMessage::size_payload, FragmentMessage::target, and FragmentMessage::timeout_task.

Referenced by send_with_fragmentation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_with_fragmentation()

static void send_with_fragmentation ( struct MacEndpoint endpoint,
struct GNUNET_TIME_Relative  timeout,
const struct GNUNET_PeerIdentity target,
const struct GNUNET_MessageHeader msg,
size_t  payload_size,
GNUNET_TRANSPORT_TransmitContinuation  cont,
void *  cont_cls 
)
static

Transmit a message to the given destination with fragmentation.

Parameters
endpointdesired destination
timeouthow long can the message wait?
targetpeer that should receive the message
msgmessage to transmit
payload_sizebytes of payload
contcontinuation to call once the message has been transmitted (or if the transport is ready for the next transmission call; or if the peer disconnected...); can be NULL
cont_clsclosure for cont

Definition at line 1136 of file plugin_transport_wlan.c.

1144 {
1145  struct FragmentMessage *fm;
1146  struct Plugin *plugin;
1147 
1148  plugin = endpoint->plugin;
1149  fm = GNUNET_new (struct FragmentMessage);
1150  fm->macendpoint = endpoint;
1151  fm->target = *target;
1152  fm->size_payload = payload_size;
1154  fm->cont = cont;
1155  fm->cont_cls = cont_cls;
1156  /* 1 MBit/s typical data rate, 1430 byte fragments => ~100 ms per message */
1157  fm->timeout_task =
1160  fm);
1161  if (GNUNET_YES == plugin->have_mac)
1162  {
1163  fm->fragcontext =
1165  WLAN_MTU,
1166  &plugin->tracker,
1167  fm->macendpoint->msg_delay,
1168  fm->macendpoint->ack_delay,
1169  msg,
1170  &transmit_fragment, fm);
1171  }
1172  else
1173  {
1174  fm->msg = GNUNET_copy_message (msg);
1175  }
1177  endpoint->sending_messages_tail,
1178  fm);
1179 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
struct GNUNET_FRAGMENT_Context * GNUNET_FRAGMENT_context_create(struct GNUNET_STATISTICS_Handle *stats, uint16_t mtu, struct GNUNET_BANDWIDTH_Tracker *tracker, struct GNUNET_TIME_Relative msg_delay, struct GNUNET_TIME_Relative ack_delay, const struct GNUNET_MessageHeader *msg, GNUNET_FRAGMENT_MessageProcessor proc, void *proc_cls)
Create a fragmentation context for the given message.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
static void fragmentmessage_timeout(void *cls)
A FragmentMessage has timed out.
#define WLAN_MTU
Max size of packet (that we give to the WLAN driver for transmission)
static void transmit_fragment(void *cls, const struct GNUNET_MessageHeader *hdr)
Transmit a fragment of a message.
struct GNUNET_TIME_Absolute timeout
Timeout value for the message.
struct GNUNET_BANDWIDTH_Tracker tracker
Bandwidth tracker to limit global UDP traffic.
int have_mac
Have we received a control message with our MAC address yet?

References MacEndpoint::ack_delay, FragmentMessage::cont, FragmentMessage::cont_cls, Plugin::env, FragmentMessage::fragcontext, fragmentmessage_timeout(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_copy_message(), GNUNET_FRAGMENT_context_create(), GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, Plugin::have_mac, FragmentMessage::macendpoint, msg, FragmentMessage::msg, MacEndpoint::msg_delay, plugin, MacEndpoint::plugin, MacEndpoint::sending_messages_head, MacEndpoint::sending_messages_tail, FragmentMessage::size_payload, FragmentMessage::target, timeout, FragmentMessage::timeout, FragmentMessage::timeout_task, Plugin::tracker, transmit_fragment(), and WLAN_MTU.

Referenced by wlan_plugin_send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_macendpoint()

static void free_macendpoint ( struct MacEndpoint endpoint)
static

Free a MAC endpoint.

Parameters
endpointpointer to the MacEndpoint to free

Definition at line 1188 of file plugin_transport_wlan.c.

1189 {
1190  struct Plugin *plugin = endpoint->plugin;
1191  struct FragmentMessage *fm;
1192  struct GNUNET_ATS_Session *session;
1193 
1195  _ ("# MAC endpoints allocated"),
1196  -1,
1197  GNUNET_NO);
1198  while (NULL != (session = endpoint->sessions_head))
1200  session);
1201  while (NULL != (fm = endpoint->sending_messages_head))
1202  free_fragment_message (fm);
1204  plugin->mac_tail,
1205  endpoint);
1206 
1207  if (NULL != endpoint->defrag)
1208  {
1210  endpoint->defrag = NULL;
1211  }
1212 
1213  plugin->mac_count--;
1214  if (NULL != endpoint->timeout_task)
1215  {
1217  endpoint->timeout_task = NULL;
1218  }
1219  GNUNET_free (endpoint);
1220 }
void GNUNET_DEFRAGMENT_context_destroy(struct GNUNET_DEFRAGMENT_Context *dc)
Destroy the given defragmentation context.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
struct GNUNET_DEFRAGMENT_Context * defrag
Defrag context for this MAC.
struct MacEndpoint * mac_tail
Tail of list of open connections.
struct MacEndpoint * mac_head
Head of list of open connections.
unsigned int mac_count
Number of connections.

References _, MacEndpoint::defrag, Plugin::env, free_fragment_message(), GNUNET_CONTAINER_DLL_remove, GNUNET_DEFRAGMENT_context_destroy(), GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), Plugin::mac_count, Plugin::mac_head, Plugin::mac_tail, plugin, MacEndpoint::plugin, MacEndpoint::sending_messages_head, MacEndpoint::sessions_head, MacEndpoint::timeout_task, and wlan_plugin_disconnect_session().

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_DONE(), and macendpoint_timeout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ macendpoint_timeout()

static void macendpoint_timeout ( void *  cls)
static

A MAC endpoint is timing out.

Clean up.

Parameters
clspointer to the struct MacEndpoint *

Definition at line 1229 of file plugin_transport_wlan.c.

1230 {
1231  struct MacEndpoint *endpoint = cls;
1233 
1234  endpoint->timeout_task = NULL;
1236  if (0 == timeout.rel_value_us)
1237  {
1238  free_macendpoint (endpoint);
1239  return;
1240  }
1241  endpoint->timeout_task =
1244  endpoint);
1245 }
static void free_macendpoint(struct MacEndpoint *endpoint)
Free a MAC endpoint.
static void macendpoint_timeout(void *cls)
A MAC endpoint is timing out.
uint64_t rel_value_us
The actual value.
struct GNUNET_TIME_Absolute timeout
When should this endpoint time out?

References free_macendpoint(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_Relative::rel_value_us, timeout, MacEndpoint::timeout, and MacEndpoint::timeout_task.

Referenced by create_macendpoint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_macendpoint()

static struct MacEndpoint* create_macendpoint ( struct Plugin plugin,
struct WlanAddress mac 
)
static

Find (or create) a MacEndpoint with a specific MAC address.

Parameters
pluginpointer to the plugin struct
macthe MAC address of the endpoint
Returns
handle to our data structure for this MAC

Definition at line 1256 of file plugin_transport_wlan.c.

1258 {
1259  struct MacEndpoint *pos;
1260 
1261  for (pos = plugin->mac_head; NULL != pos; pos = pos->next)
1262  if (0 == memcmp (mac, &pos->wlan_addr, sizeof(pos->wlan_addr)))
1263  return pos;
1264  pos = GNUNET_new (struct MacEndpoint);
1265  pos->wlan_addr = (*mac);
1266  pos->plugin = plugin;
1267  pos->defrag =
1269  WLAN_MTU,
1271  pos,
1273  &send_ack);
1274 
1277  100);
1278  pos->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
1279  pos->timeout_task =
1280  GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
1281  pos);
1283  plugin->mac_tail,
1284  pos);
1285  plugin->mac_count++;
1287  _ ("# MAC endpoints allocated"),
1288  1, GNUNET_NO);
1290  "New MAC endpoint `%s'\n",
1292  &pos->wlan_addr,
1293  sizeof(struct WlanAddress)));
1294  return pos;
1295 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_DEFRAGMENT_Context * GNUNET_DEFRAGMENT_context_create(struct GNUNET_STATISTICS_Handle *stats, uint16_t mtu, unsigned int num_msgs, void *cls, GNUNET_FRAGMENT_MessageProcessor proc, GNUNET_DEFRAGMENT_AckProcessor ackp)
Create a defragmentation context.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:311
static void send_ack(void *cls, uint32_t msg_id, const struct GNUNET_MessageHeader *hdr)
Send an ACK for a fragment we received.
static void wlan_data_message_handler(void *cls, const struct GNUNET_MessageHeader *hdr)
Handles the data after all fragments are put together.
static const char * wlan_plugin_address_to_string(void *cls, const void *addr, size_t addrlen)
Function called for a quick conversion of the binary address to a numeric address.
#define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC
Maximum number of messages in defragmentation queue per MAC.
struct MacEndpoint * next
We keep all MACs in a DLL in the plugin.

References _, MacEndpoint::ack_delay, MacEndpoint::defrag, Plugin::env, GNUNET_CONTAINER_DLL_insert, GNUNET_DEFRAGMENT_context_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_MILLISECONDS, LOG, Plugin::mac_count, Plugin::mac_head, Plugin::mac_tail, macendpoint_timeout(), MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, MacEndpoint::msg_delay, MacEndpoint::next, plugin, MacEndpoint::plugin, send_ack(), MacEndpoint::timeout, MacEndpoint::timeout_task, MacEndpoint::wlan_addr, wlan_data_message_handler(), WLAN_MTU, and wlan_plugin_address_to_string().

Referenced by handle_helper_message(), and wlan_plugin_get_session().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wlan_plugin_get_network()

static enum GNUNET_NetworkType wlan_plugin_get_network ( void *  cls,
struct GNUNET_ATS_Session session 
)
static

Function obtain the network type for a session.

Parameters
clsclosure (struct Plugin*)
sessionthe session
Returns
the network type in HBO or GNUNET_SYSERR

Definition at line 1256 of file plugin_transport_wlan.c.

1308 {
1309 #if BUILD_WLAN
1310  return GNUNET_NT_WLAN;
1311 #else
1312  return GNUNET_NT_BT;
1313 #endif
1314 }
@ GNUNET_NT_WLAN
Wireless LAN (i.e.
Definition: gnunet_nt_lib.h:60
@ GNUNET_NT_BT
Bluetooth LAN.
Definition: gnunet_nt_lib.h:65

◆ wlan_plugin_get_network_for_address()

static enum GNUNET_NetworkType wlan_plugin_get_network_for_address ( void *  cls,
const struct GNUNET_HELLO_Address address 
)
static

Function obtain the network type for an address.

Parameters
clsclosure (struct Plugin *)
addressthe address
Returns
the network type

Definition at line 1256 of file plugin_transport_wlan.c.

1327 {
1328 #if BUILD_WLAN
1329  return GNUNET_NT_WLAN;
1330 #else
1331  return GNUNET_NT_BT;
1332 #endif
1333 }

◆ wlan_plugin_get_session()

static struct GNUNET_ATS_Session* wlan_plugin_get_session ( void *  cls,
const struct GNUNET_HELLO_Address address 
)
static

Creates a new outbound session the transport service will use to send data to the peer.

Parameters
clsthe struct Plugin *
addressthe address
Returns
the session or NULL of max connections exceeded

Definition at line 1345 of file plugin_transport_wlan.c.

1347 {
1348  struct Plugin *plugin = cls;
1349  struct MacEndpoint *endpoint;
1350 
1351  if (NULL == address)
1352  return NULL;
1353  if (sizeof(struct WlanAddress) != address->address_length)
1354  {
1355  GNUNET_break (0);
1356  return NULL;
1357  }
1359  "Service asked to create session for peer `%s' with MAC `%s'\n",
1360  GNUNET_i2s (&address->peer),
1362  address->address,
1363  address->address_length));
1364  endpoint = create_macendpoint (plugin,
1365  (struct WlanAddress *) address->address);
1366  return get_session (endpoint, &address->peer);
1367 }
static char * address
GNS address for this phone.
static struct MacEndpoint * create_macendpoint(struct Plugin *plugin, struct WlanAddress *mac)
Find (or create) a MacEndpoint with a specific MAC address.
static struct GNUNET_ATS_Session * get_session(struct MacEndpoint *endpoint, const struct GNUNET_PeerIdentity *peer)
Look up a session for a peer and create a new session if none is found.

References address, create_macendpoint(), get_session(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), LOG, plugin, and wlan_plugin_address_to_string().

Here is the call graph for this function:

◆ wlan_plugin_disconnect_peer()

static void wlan_plugin_disconnect_peer ( void *  cls,
const struct GNUNET_PeerIdentity target 
)
static

Function that can be used to force the plugin to disconnect from the given peer and cancel all previous transmissions (and their continuation).

Parameters
clsclosure
targetpeer from which to disconnect

Definition at line 1379 of file plugin_transport_wlan.c.

1381 {
1382  struct Plugin *plugin = cls;
1383  struct GNUNET_ATS_Session *session;
1384  struct MacEndpoint *endpoint;
1385 
1386  for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next)
1387  for (session = endpoint->sessions_head; NULL != session; session =
1388  session->next)
1389  if (0 == memcmp (target, &session->target,
1390  sizeof(struct GNUNET_PeerIdentity)))
1391  {
1393  break; /* inner-loop only (in case peer has another MAC as well!) */
1394  }
1395 }

References Plugin::mac_head, GNUNET_ATS_Session::next, MacEndpoint::next, plugin, MacEndpoint::sessions_head, GNUNET_ATS_Session::target, and wlan_plugin_disconnect_session().

Here is the call graph for this function:

◆ wlan_plugin_send()

static ssize_t wlan_plugin_send ( void *  cls,
struct GNUNET_ATS_Session session,
const char *  msgbuf,
size_t  msgbuf_size,
unsigned int  priority,
struct GNUNET_TIME_Relative  to,
GNUNET_TRANSPORT_TransmitContinuation  cont,
void *  cont_cls 
)
static

Function that can be used by the transport service to transmit a message using the plugin.

Note that in the case of a peer disconnecting, the continuation MUST be called prior to the disconnect notification itself. This function will be called with this peer's HELLO message to initiate a fresh connection to another peer.

Parameters
clsclosure
sessionwhich session must be used
msgbufthe message to transmit
msgbuf_sizenumber of bytes in msgbuf
priorityhow important is the message (most plugins will ignore message priority and just FIFO)
tohow long to wait at most for the transmission (does not require plugins to discard the message after the timeout, just advisory for the desired delay; most plugins will ignore this as well)
contcontinuation to call once the message has been transmitted (or if the transport is ready for the next transmission call; or if the peer disconnected...); can be NULL
cont_clsclosure for cont
Returns
number of bytes used (on the physical network, with overheads); -1 on hard errors (i.e. address invalid); 0 is a legal value and does NOT mean that the message was not transmitted (DV)

Definition at line 1426 of file plugin_transport_wlan.c.

1432 {
1433  struct Plugin *plugin = cls;
1434  struct WlanHeader *wlanheader;
1435  size_t size = msgbuf_size + sizeof(struct WlanHeader);
1436  char buf[size] GNUNET_ALIGN;
1437 
1439  "Transmitting %llu bytes of payload to peer `%s' (starting with %u byte message of type %u)\n",
1440  (unsigned long long) msgbuf_size,
1441  GNUNET_i2s (&session->target),
1442  (unsigned int) ntohs (((struct GNUNET_MessageHeader*) msgbuf)->size),
1443  (unsigned int) ntohs (((struct GNUNET_MessageHeader*) msgbuf)->type));
1444  wlanheader = (struct WlanHeader *) buf;
1445  wlanheader->header.size = htons (msgbuf_size + sizeof(struct WlanHeader));
1446  wlanheader->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA);
1447  wlanheader->sender = *plugin->env->my_identity;
1448  wlanheader->target = session->target;
1449  wlanheader->crc = htonl (GNUNET_CRYPTO_crc32_n (msgbuf, msgbuf_size));
1450  GNUNET_memcpy (&wlanheader[1],
1451  msgbuf,
1452  msgbuf_size);
1454  "# bytes currently in buffers",
1455  msgbuf_size,
1456  GNUNET_NO);
1457  send_with_fragmentation (session->mac,
1458  to,
1459  &session->target,
1460  &wlanheader->header,
1461  msgbuf_size,
1462  cont, cont_cls);
1463  return size;
1464 }
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
int32_t GNUNET_CRYPTO_crc32_n(const void *buf, size_t len)
Compute the CRC32 checksum for the first len bytes of the buffer.
Definition: crypto_crc.c:106
#define GNUNET_MESSAGE_TYPE_WLAN_DATA
Type of messages for data over the wlan.
static void send_with_fragmentation(struct MacEndpoint *endpoint, struct GNUNET_TIME_Relative timeout, const struct GNUNET_PeerIdentity *target, const struct GNUNET_MessageHeader *msg, size_t payload_size, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
Transmit a message to the given destination with fragmentation.
Header for all communications.
Header for messages which need fragmentation.
struct GNUNET_PeerIdentity target
Target of the message.
uint32_t crc
CRC32 checksum (only over the payload), in NBO.
struct GNUNET_PeerIdentity sender
Sender of the message.
struct GNUNET_MessageHeader header
Message type is GNUNET_MESSAGE_TYPE_WLAN_DATA.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

References buf, WlanHeader::crc, Plugin::env, GNUNET_ALIGN, GNUNET_CRYPTO_crc32_n(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_WLAN_DATA, GNUNET_NO, GNUNET_STATISTICS_update(), WlanHeader::header, LOG, GNUNET_ATS_Session::mac, plugin, send_with_fragmentation(), WlanHeader::sender, GNUNET_MessageHeader::size, size, GNUNET_ATS_Session::target, WlanHeader::target, GNUNET_MessageHeader::type, and type.

Here is the call graph for this function:

◆ process_data()

static int process_data ( void *  cls,
void *  client,
const struct GNUNET_MessageHeader hdr 
)
static

We have received data from the WLAN via some session.

Process depending on the message type (HELLO, DATA, FRAGMENTATION or FRAGMENTATION-ACK).

Parameters
clspointer to the plugin
clientpointer to the session this message belongs to
hdrstart of the message

Definition at line 1476 of file plugin_transport_wlan.c.

1479 {
1480  struct Plugin *plugin = cls;
1481  struct GNUNET_HELLO_Address *address;
1482  struct MacAndSession *mas = client;
1483  struct FragmentMessage *fm;
1484  struct GNUNET_PeerIdentity tmpsource;
1485  const struct WlanHeader *wlanheader;
1486  int ret;
1487  uint16_t msize;
1488 
1489  msize = ntohs (hdr->size);
1490 
1492  "# bytes received",
1493  msize, GNUNET_NO);
1494 
1495  switch (ntohs (hdr->type))
1496  {
1498 
1499  if (GNUNET_OK !=
1500  GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr,
1501  &tmpsource))
1502  {
1503  GNUNET_break_op (0);
1504  break;
1505  }
1506  if (NULL == mas->endpoint)
1507  {
1508  GNUNET_break (0);
1509  break;
1510  }
1511 
1513  "Processing %u bytes of HELLO from peer `%s' at MAC %s\n",
1514  (unsigned int) msize,
1515  GNUNET_i2s (&tmpsource),
1517  &mas->endpoint->wlan_addr,
1518  sizeof(mas->endpoint->wlan_addr)));
1519 
1521  _ ("# HELLO messages received"), 1,
1522  GNUNET_NO);
1523  address = GNUNET_HELLO_address_allocate (&tmpsource,
1524  PLUGIN_NAME,
1525  &mas->endpoint->wlan_addr,
1526  sizeof(mas->endpoint->wlan_addr),
1528  mas->session = lookup_session (mas->endpoint,
1529  &tmpsource);
1530  if (NULL == mas->session)
1531  {
1532  mas->session = create_session (mas->endpoint,
1533  &tmpsource);
1534  plugin->env->session_start (plugin->env->cls,
1535  address,
1536  mas->session,
1537  scope);
1538  }
1539  plugin->env->receive (plugin->env->cls,
1540  address,
1541  mas->session,
1542  hdr);
1544  break;
1545 
1547  if (NULL == mas->endpoint)
1548  {
1549  GNUNET_break (0);
1550  break;
1551  }
1553  "Processing %u bytes of FRAGMENT from MAC %s\n",
1554  (unsigned int) msize,
1556  &mas->endpoint->wlan_addr,
1557  sizeof(mas->endpoint->wlan_addr)));
1559  _ ("# fragments received"),
1560  1,
1561  GNUNET_NO);
1563  hdr);
1564  break;
1565 
1567  if (NULL == mas->endpoint)
1568  {
1569  GNUNET_break (0);
1570  break;
1571  }
1573  _ ("# ACKs received"),
1574  1, GNUNET_NO);
1575  for (fm = mas->endpoint->sending_messages_head; NULL != fm; fm = fm->next)
1576  {
1578  if (GNUNET_OK == ret)
1579  {
1581  "Got last ACK, finished message transmission to `%s' (%p)\n",
1583  &mas->endpoint->wlan_addr,
1584  sizeof(mas->endpoint->wlan_addr)),
1585  fm);
1587  MACENDPOINT_TIMEOUT);
1588  if (NULL != fm->cont)
1589  {
1590  fm->cont (fm->cont_cls,
1591  &fm->target,
1592  GNUNET_OK,
1593  fm->size_payload,
1594  fm->size_on_wire);
1595  fm->cont = NULL;
1596  }
1597  free_fragment_message (fm);
1598  break;
1599  }
1600  if (GNUNET_NO == ret)
1601  {
1603  "Got an ACK, message transmission to `%s' not yet finished\n",
1605  &mas->endpoint->wlan_addr,
1606  sizeof(mas->endpoint->wlan_addr)));
1607  break;
1608  }
1609  }
1610  if (NULL == fm)
1612  "ACK not matched against any active fragmentation with MAC `%s'\n",
1614  &mas->endpoint->wlan_addr,
1615  sizeof(mas->endpoint->wlan_addr)));
1616  break;
1617 
1619  if (NULL == mas->endpoint)
1620  {
1621  GNUNET_break (0);
1622  break;
1623  }
1624  if (msize < sizeof(struct WlanHeader))
1625  {
1626  GNUNET_break (0);
1627  break;
1628  }
1629  wlanheader = (const struct WlanHeader *) hdr;
1630  if (0 != memcmp (&wlanheader->target,
1631  plugin->env->my_identity,
1632  sizeof(struct GNUNET_PeerIdentity)))
1633  {
1635  "Data for `%s', not for me, ignoring\n",
1636  GNUNET_i2s (&wlanheader->target));
1637  break;
1638  }
1639  if (ntohl (wlanheader->crc) !=
1640  GNUNET_CRYPTO_crc32_n (&wlanheader[1],
1641  msize - sizeof(struct WlanHeader)))
1642  {
1644  _ (
1645  "# DATA messages discarded due to CRC32 error"),
1646  1,
1647  GNUNET_NO);
1648  break;
1649  }
1650  mas->session = lookup_session (mas->endpoint,
1651  &wlanheader->sender);
1652  if (NULL == mas->session)
1653  {
1654  mas->session = create_session (mas->endpoint,
1655  &wlanheader->sender);
1657  PLUGIN_NAME,
1658  &mas->endpoint->wlan_addr,
1659  sizeof(struct WlanAddress),
1661  plugin->env->session_start (plugin->env->cls,
1662  address,
1663  mas->session,
1664  scope);
1666  "Notifying transport about peer `%s''s new session %p \n",
1667  GNUNET_i2s (&wlanheader->sender),
1668  mas->session);
1670  }
1672  "Processing %u bytes of DATA from peer `%s'\n",
1673  (unsigned int) msize,
1674  GNUNET_i2s (&wlanheader->sender));
1678  mas,
1679  (const char *) &wlanheader[1],
1680  msize - sizeof(struct WlanHeader),
1681  GNUNET_YES,
1682  GNUNET_NO);
1683  break;
1684 
1685  default:
1686  if (NULL == mas->endpoint)
1687  {
1688  GNUNET_break (0);
1689  break;
1690  }
1691  if (NULL == mas->session)
1692  {
1693  GNUNET_break (0);
1694  break;
1695  }
1697  "Received packet with %u bytes of type %u from peer %s\n",
1698  (unsigned int) msize,
1699  (unsigned int) ntohs (hdr->type),
1700  GNUNET_i2s (&mas->session->target));
1701  plugin->env->receive (plugin->env->cls,
1702  mas->session->address,
1703  mas->session,
1704  hdr);
1705  break;
1706  }
1707  return GNUNET_OK;
1708 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
int GNUNET_DEFRAGMENT_process_fragment(struct GNUNET_DEFRAGMENT_Context *dc, const struct GNUNET_MessageHeader *msg)
We have received a fragment.
int GNUNET_FRAGMENT_process_ack(struct GNUNET_FRAGMENT_Context *fc, const struct GNUNET_MessageHeader *msg)
Process an acknowledgement message we got from the other side (to control re-transmits).
int GNUNET_HELLO_get_id(const struct GNUNET_HELLO_Message *hello, struct GNUNET_PeerIdentity *peer)
Get the peer identity from a HELLO message.
Definition: hello.c:671
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_MESSAGE_TYPE_FRAGMENT
FRAGMENT of a larger message.
#define GNUNET_MESSAGE_TYPE_FRAGMENT_ACK
Acknowledgement of a FRAGMENT of a larger message.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
struct FragmentMessage * next
This is a doubly-linked list.
An address for communicating with a peer.
A HELLO message is used to exchange information about transports with other peers.
struct GNUNET_ATS_Session * session
NULL if the identity of the other peer is not known.
struct GNUNET_SERVER_MessageStreamTokenizer * wlan_header_payload_tokenizer
Tokenizer for demultiplexing of data packets that follow the WLAN Header.

References _, address, GNUNET_ATS_Session::address, GNUNET_DATACACHE_PluginEnvironment::cls, FragmentMessage::cont, FragmentMessage::cont_cls, WlanHeader::crc, create_session(), MacEndpoint::defrag, MacAndSession::endpoint, Plugin::env, FragmentMessage::fragcontext, free_fragment_message(), GNUNET_break, GNUNET_break_op, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_CRYPTO_crc32_n(), GNUNET_DEFRAGMENT_process_fragment(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_FRAGMENT_process_ack(), GNUNET_HELLO_address_allocate(), GNUNET_HELLO_address_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_HELLO_get_id(), GNUNET_i2s(), GNUNET_MESSAGE_TYPE_FRAGMENT, GNUNET_MESSAGE_TYPE_FRAGMENT_ACK, GNUNET_MESSAGE_TYPE_HELLO, GNUNET_MESSAGE_TYPE_WLAN_DATA, GNUNET_NO, GNUNET_OK, GNUNET_SERVER_mst_receive(), GNUNET_STATISTICS_update(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, LOG, lookup_session(), FragmentMessage::next, plugin, PLUGIN_NAME, ret, scope, WlanHeader::sender, MacEndpoint::sending_messages_head, MacAndSession::session, GNUNET_MessageHeader::size, FragmentMessage::size_on_wire, FragmentMessage::size_payload, GNUNET_ATS_Session::target, WlanHeader::target, FragmentMessage::target, GNUNET_ATS_Session::timeout, MacEndpoint::timeout, GNUNET_MessageHeader::type, MacEndpoint::wlan_addr, Plugin::wlan_header_payload_tokenizer, and wlan_plugin_address_to_string().

Here is the call graph for this function:

◆ send_hello_beacon()

static void send_hello_beacon ( void *  cls)
static

Task to (periodically) send a HELLO beacon.

Parameters
clspointer to the plugin struct

Definition at line 1717 of file plugin_transport_wlan.c.

1718 {
1719  struct Plugin *plugin = cls;
1720  uint16_t size;
1721  uint16_t hello_size;
1722  struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader;
1723  const struct GNUNET_MessageHeader *hello;
1724 
1725  hello = plugin->env->get_our_hello ();
1726  if (NULL != hello)
1727  {
1728  hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
1729  GNUNET_assert (sizeof(struct WlanHeader) + hello_size <= WLAN_MTU);
1731  + hello_size;
1732  {
1733  char buf[size] GNUNET_ALIGN;
1734 
1736  "Sending %u byte HELLO beacon\n",
1737  (unsigned int) size);
1738  radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf;
1739  get_radiotap_header (NULL, radioHeader, size);
1741  "Broadcasting %u bytes of data to MAC `%s'\n",
1742  (unsigned int) size,
1744  get_wlan_header (plugin, &radioHeader->frame, &bc_all_mac, size);
1745  GNUNET_memcpy (&radioHeader[1], hello, hello_size);
1746  if (NULL !=
1748  &radioHeader->header,
1749  GNUNET_YES /* can drop */,
1750  NULL, NULL))
1752  _ ("# HELLO beacons sent"),
1753  1, GNUNET_NO);
1754  }
1755  }
1756  plugin->beacon_task =
1758  (HELLO_BEACON_SCALING_FACTOR,
1759  plugin->mac_count + 1),
1761  plugin);
1762 }
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
Definition: hello.c:652
static void send_hello_beacon(void *cls)
Task to (periodically) send a HELLO beacon.
static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac
Broadcast MAC.
struct GNUNET_SCHEDULER_Task * beacon_task
Task that periodically sends a HELLO beacon via the helper.

References _, bc_all_mac, Plugin::beacon_task, buf, Plugin::env, GNUNET_TRANSPORT_WLAN_RadiotapSendMessage::frame, get_radiotap_header(), get_wlan_header(), GNUNET_ALIGN, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_size(), GNUNET_HELPER_send(), GNUNET_memcpy, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_TIME_relative_multiply(), GNUNET_YES, GNUNET_TRANSPORT_WLAN_RadiotapSendMessage::header, LOG, Plugin::mac_count, mac_to_string(), plugin, size, Plugin::suid_helper, and WLAN_MTU.

Referenced by handle_helper_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_helper_message()

static int handle_helper_message ( void *  cls,
const struct GNUNET_MessageHeader hdr 
)
static

Function used for to process the data from the suid process.

Parameters
clsthe plugin handle
hdrheader of the GNUNET_MessageHeader

Definition at line 1772 of file plugin_transport_wlan.c.

1774 {
1775  struct Plugin *plugin = cls;
1776  struct GNUNET_HELLO_Address *my_address;
1777  const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rxinfo;
1779  struct WlanAddress wa;
1780  struct MacAndSession mas;
1781  uint16_t msize;
1782  struct FragmentMessage *fm;
1783  struct MacEndpoint *endpoint;
1784 
1785  msize = ntohs (hdr->size);
1786  switch (ntohs (hdr->type))
1787  {
1789  if (msize != sizeof(struct GNUNET_TRANSPORT_WLAN_HelperControlMessage))
1790  {
1791  GNUNET_break (0);
1792  break;
1793  }
1794  cm = (const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *) hdr;
1795  if (GNUNET_YES == plugin->have_mac)
1796  {
1797  if (0 == memcmp (&plugin->mac_address,
1798  &cm->mac,
1799  sizeof(struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1800  break; /* no change */
1801  /* remove old address */
1802  memset (&wa, 0, sizeof(struct WlanAddress));
1803  wa.mac = plugin->mac_address;
1804  wa.options = htonl (plugin->options);
1805  my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
1806  PLUGIN_NAME,
1807  &wa, sizeof(wa),
1809  plugin->env->notify_address (plugin->env->cls,
1810  GNUNET_NO,
1811  my_address);
1812  GNUNET_HELLO_address_free (my_address);
1813  plugin->mac_address = cm->mac;
1814  }
1815  else
1816  {
1817  plugin->mac_address = cm->mac;
1819  for (endpoint = plugin->mac_head; NULL != endpoint; endpoint =
1820  endpoint->next)
1821  {
1822  for (fm = endpoint->sending_messages_head; NULL != fm; fm = fm->next)
1823  {
1824  if (NULL != fm->fragcontext)
1825  {
1826  GNUNET_break (0); /* should not happen */
1827  continue;
1828  }
1829  fm->fragcontext =
1831  WLAN_MTU,
1832  &plugin->tracker,
1833  fm->macendpoint->msg_delay,
1834  fm->macendpoint->ack_delay,
1835  fm->msg,
1836  &transmit_fragment, fm);
1837  GNUNET_free (fm->msg);
1838  fm->msg = NULL;
1839  }
1840  }
1841  GNUNET_break (NULL == plugin->beacon_task);
1843  plugin);
1844  }
1845 
1846  memset (&wa, 0, sizeof(struct WlanAddress));
1847  wa.mac = plugin->mac_address;
1848  wa.options = htonl (plugin->options);
1849  my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
1850  PLUGIN_NAME,
1851  &wa, sizeof(wa),
1853 
1855  "Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n",
1856  mac_to_string (&cm->mac),
1857  GNUNET_i2s (plugin->env->my_identity));
1858  plugin->env->notify_address (plugin->env->cls,
1859  GNUNET_YES,
1860  my_address);
1861  GNUNET_HELLO_address_free (my_address);
1862  break;
1863 
1866  "Got data message from helper with %u bytes\n",
1867  msize);
1869  _ ("# DATA messages received"), 1,
1870  GNUNET_NO);
1871  if (msize < sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage))
1872  {
1874  "Size of packet is too small (%llu bytes < %llu)\n",
1875  (unsigned long long) msize,
1876  (unsigned long long) sizeof(struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage));
1877  break;
1878  }
1879  rxinfo = (const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) hdr;
1880 
1881  /* check if message is actually for us */
1882  if (0 != memcmp (&rxinfo->frame.addr3, &mac_bssid_gnunet,
1883  sizeof(struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1884  {
1885  /* Not the GNUnet BSSID */
1886  break;
1887  }
1888  if ((0 != memcmp (&rxinfo->frame.addr1, &bc_all_mac,
1889  sizeof(struct GNUNET_TRANSPORT_WLAN_MacAddress))) &&
1890  (0 != memcmp (&rxinfo->frame.addr1, &plugin->mac_address,
1891  sizeof(struct GNUNET_TRANSPORT_WLAN_MacAddress))))
1892  {
1893  /* Neither broadcast nor specifically for us */
1894  break;
1895  }
1896  if (0 == memcmp (&rxinfo->frame.addr2, &plugin->mac_address,
1897  sizeof(struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1898  {
1899  /* packet is FROM us, thus not FOR us */
1900  break;
1901  }
1902 
1904  _ ("# DATA messages processed"),
1905  1, GNUNET_NO);
1907  "Receiving %u bytes of data from MAC `%s'\n",
1908  (unsigned int) (msize - sizeof(struct
1910  mac_to_string (&rxinfo->frame.addr2));
1912  "Receiving %u bytes of data to MAC `%s'\n",
1913  (unsigned int) (msize - sizeof(struct
1915  mac_to_string (&rxinfo->frame.addr1));
1917  "Receiving %u bytes of data with BSSID MAC `%s'\n",
1918  (unsigned int) (msize - sizeof(struct
1920  mac_to_string (&rxinfo->frame.addr3));
1921  wa.mac = rxinfo->frame.addr2;
1922  wa.options = htonl (0);
1923  mas.endpoint = create_macendpoint (plugin, &wa);
1924  mas.session = NULL;
1926  &mas,
1927  (const char *) &rxinfo[1],
1928  msize - sizeof(struct
1931  break;
1932 
1933  default:
1934  GNUNET_break (0);
1936  "Unexpected message of type %u (%u bytes)",
1937  ntohs (hdr->type),
1938  ntohs (hdr->size));
1939  break;
1940  }
1941  return GNUNET_OK;
1942 }
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL
Control message between the gnunet-wlan-helper and the daemon (with the MAC).
#define GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER
Type of data messages from the gnunet-wlan-helper to the plugin.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1296
struct GNUNET_MessageHeader hdr
Message header.
struct GNUNET_TRANSPORT_WLAN_MacAddress mac
MAC Address of the local WLAN interface.
Message from the WLAN helper to the plugin: we have received the given message with the given perform...
struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame
IEEE Frame.
uint32_t options
Options for addresses.
struct GNUNET_SERVER_MessageStreamTokenizer * helper_payload_tokenizer
Tokenizer for demultiplexing of data packets received from the suid helper.

References _, MacEndpoint::ack_delay, GNUNET_TRANSPORT_WLAN_Ieee80211Frame::addr1, GNUNET_TRANSPORT_WLAN_Ieee80211Frame::addr2, GNUNET_TRANSPORT_WLAN_Ieee80211Frame::addr3, bc_all_mac, Plugin::beacon_task, GNUNET_DATACACHE_PluginEnvironment::cls, create_macendpoint(), MacAndSession::endpoint, Plugin::env, FragmentMessage::fragcontext, GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage::frame, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_FRAGMENT_context_create(), GNUNET_free, GNUNET_HELLO_address_allocate(), GNUNET_HELLO_address_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER, GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SERVER_mst_receive(), GNUNET_STATISTICS_update(), GNUNET_YES, Plugin::have_mac, GNUNET_TRANSPORT_WLAN_HelperControlMessage::hdr, Plugin::helper_payload_tokenizer, LOG, WlanAddress::mac, GNUNET_TRANSPORT_WLAN_HelperControlMessage::mac, Plugin::mac_address, mac_bssid_gnunet, Plugin::mac_head, mac_to_string(), FragmentMessage::macendpoint, FragmentMessage::msg, MacEndpoint::msg_delay, FragmentMessage::next, MacEndpoint::next, WlanAddress::options, Plugin::options, plugin, PLUGIN_NAME, send_hello_beacon(), MacEndpoint::sending_messages_head, MacAndSession::session, GNUNET_MessageHeader::size, Plugin::tracker, transmit_fragment(), GNUNET_MessageHeader::type, and WLAN_MTU.

Here is the call graph for this function:

◆ wlan_plugin_address_suggested()

static int wlan_plugin_address_suggested ( void *  cls,
const void *  addr,
size_t  addrlen 
)
static

Another peer has suggested an address for this peer and transport plugin.

Check that this could be a valid address. If so, consider adding it to the list of addresses.

Parameters
clsclosure
addrpointer to the address
addrlenlength of addr
Returns
GNUNET_OK if this is a plausible address for this peer and transport

Definition at line 1958 of file plugin_transport_wlan.c.

1961 {
1962  struct Plugin *plugin = cls;
1963  struct WlanAddress *wa = (struct WlanAddress *) addr;
1964 
1965  if (addrlen != sizeof(struct WlanAddress))
1966  {
1967  GNUNET_break_op (0);
1968  return GNUNET_SYSERR;
1969  }
1970  if (GNUNET_YES != plugin->have_mac)
1971  {
1973  "Rejecting MAC `%s': I don't know my MAC!\n",
1974  mac_to_string (addr));
1975  return GNUNET_NO; /* don't know my MAC */
1976  }
1977  if (0 != memcmp (&wa->mac,
1978  &plugin->mac_address,
1979  sizeof(wa->mac)))
1980  {
1982  "Rejecting MAC `%s': not my MAC!\n",
1983  mac_to_string (addr));
1984  return GNUNET_NO; /* not my MAC */
1985  }
1986  return GNUNET_OK;
1987 }

References GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, Plugin::have_mac, LOG, WlanAddress::mac, Plugin::mac_address, mac_to_string(), and plugin.

Here is the call graph for this function:

◆ wlan_plugin_address_pretty_printer()

static void wlan_plugin_address_pretty_printer ( void *  cls,
const char *  type,
const void *  addr,
size_t  addrlen,
int  numeric,
struct GNUNET_TIME_Relative  timeout,
GNUNET_TRANSPORT_AddressStringCallback  asc,
void *  asc_cls 
)
static

Convert the transports address to a nice, human-readable format.

Parameters
clsclosure
typename of the transport that generated the address
addrone of the addresses of the host, NULL for the last address the specific address format depends on the transport
addrlenlength of the address
numericshould (IP) addresses be displayed in numeric form?
timeoutafter how long should we give up?
ascfunction to call on each string
asc_clsclosure for asc

Definition at line 2004 of file plugin_transport_wlan.c.

2012 {
2013  const char *ret;
2014 
2015  if (sizeof(struct WlanAddress) == addrlen)
2017  addr,
2018  addrlen);
2019  else
2020  ret = NULL;
2021  asc (asc_cls,
2022  ret,
2023  (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
2024  asc (asc_cls, NULL, GNUNET_OK);
2025 }

References GNUNET_OK, GNUNET_SYSERR, ret, and wlan_plugin_address_to_string().

Here is the call graph for this function:

◆ LIBGNUNET_PLUGIN_TRANSPORT_DONE()

void* LIBGNUNET_PLUGIN_TRANSPORT_DONE ( void *  cls)

Exit point from the plugin.

Parameters
clspointer to the api struct

Definition at line 2034 of file plugin_transport_wlan.c.

2035 {
2036  struct WlanAddress wa;
2037  struct GNUNET_HELLO_Address *address;
2038  struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
2039  struct Plugin *plugin = api->cls;
2040  struct MacEndpoint *endpoint;
2041  struct MacEndpoint *endpoint_next;
2042 
2043  if (NULL == plugin)
2044  {
2045  GNUNET_free (api);
2046  return NULL;
2047  }
2048  if (GNUNET_YES == plugin->have_mac)
2049  {
2050  memset (&wa, 0, sizeof(wa));
2051  wa.options = htonl (plugin->options);
2052  wa.mac = plugin->mac_address;
2054  PLUGIN_NAME,
2055  &wa, sizeof(struct WlanAddress),
2057 
2058  plugin->env->notify_address (plugin->env->cls,
2059  GNUNET_NO,
2060  address);
2063  }
2064 
2065  if (NULL != plugin->beacon_task)
2066  {
2068  plugin->beacon_task = NULL;
2069  }
2070  if (NULL != plugin->suid_helper)
2071  {
2073  GNUNET_NO);
2074  plugin->suid_helper = NULL;
2075  }
2076  endpoint_next = plugin->mac_head;
2077  while (NULL != (endpoint = endpoint_next))
2078  {
2079  endpoint_next = endpoint->next;
2080  free_macendpoint (endpoint);
2081  }
2082  if (NULL != plugin->fragment_data_tokenizer)
2083  {
2086  }
2088  {
2091  }
2092  if (NULL != plugin->helper_payload_tokenizer)
2093  {
2096  }
2098  GNUNET_free (plugin);
2099  GNUNET_free (api);
2100  return NULL;
2101 }
void GNUNET_HELPER_stop(struct GNUNET_HELPER_Handle *h, int soft_kill)
Kills the helper, closes the pipe, frees the handle and calls wait() on the helper process.
Definition: helper.c:567
void GNUNET_SERVER_mst_destroy(struct GNUNET_SERVER_MessageStreamTokenizer *mst)
Destroys a tokenizer.
void * cls
Closure for all of the callbacks.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure for all of the callbacks.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
char * wlan_interface
The interface of the wlan card given to us by the user.

References address, Plugin::api, Plugin::beacon_task, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_DATACACHE_PluginEnvironment::cls, GNUNET_TRANSPORT_PluginFunctions::cls, Plugin::env, Plugin::fragment_data_tokenizer, free_macendpoint(), GNUNET_free, GNUNET_HELLO_address_allocate(), GNUNET_HELLO_address_free, GNUNET_HELLO_ADDRESS_INFO_NONE, GNUNET_HELPER_stop(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_SERVER_mst_destroy(), GNUNET_YES, Plugin::have_mac, Plugin::helper_payload_tokenizer, WlanAddress::mac, Plugin::mac_address, Plugin::mac_head, MacEndpoint::next, WlanAddress::options, Plugin::options, plugin, PLUGIN_NAME, Plugin::suid_helper, Plugin::wlan_header_payload_tokenizer, and Plugin::wlan_interface.

Here is the call graph for this function:

◆ wlan_plugin_string_to_address()

static int wlan_plugin_string_to_address ( void *  cls,
const char *  addr,
uint16_t  addrlen,
void **  buf,
size_t *  added 
)
static

Function called to convert a string address to a binary address.

Parameters
clsclosure (struct Plugin *)
addrstring address
addrlenlength of the address
buflocation to store the buffer
addedlocation to store the number of bytes in the buffer. If the function returns GNUNET_SYSERR, its contents are undefined.
Returns
GNUNET_OK on success, GNUNET_SYSERR on failure

Definition at line 2117 of file plugin_transport_wlan.c.

2122 {
2123  struct WlanAddress *wa;
2124  unsigned int a[6];
2125  unsigned int i;
2126  char plugin[5];
2127  uint32_t options;
2128 
2129  if ((NULL == addr) || (0 == addrlen))
2130  {
2131  GNUNET_break (0);
2132  return GNUNET_SYSERR;
2133  }
2134  if ('\0' != addr[addrlen - 1])
2135  {
2136  GNUNET_break (0);
2137  return GNUNET_SYSERR;
2138  }
2139  if (strlen (addr) != addrlen - 1)
2140  {
2141  GNUNET_break (0);
2142  return GNUNET_SYSERR;
2143  }
2144 
2145  if (8 != sscanf (addr,
2146  "%4s.%u.%X:%X:%X:%X:%X:%X",
2147  plugin, &options,
2148  &a[0], &a[1], &a[2],
2149  &a[3], &a[4], &a[5]))
2150  {
2151  GNUNET_break (0);
2152  return GNUNET_SYSERR;
2153  }
2154  wa = GNUNET_new (struct WlanAddress);
2155  for (i = 0; i < 6; i++)
2156  wa->mac.mac[i] = a[i];
2157  wa->options = htonl (0);
2158  *buf = wa;
2159  *added = sizeof(struct WlanAddress);
2160  return GNUNET_OK;
2161 }
uint32_t options
Options set for the WLAN, in NBO.

References buf, GNUNET_break, GNUNET_new, GNUNET_OK, GNUNET_SYSERR, WlanAddress::mac, GNUNET_TRANSPORT_WLAN_MacAddress::mac, options, WlanAddress::options, and plugin.

◆ wlan_plugin_setup_monitor()

static void wlan_plugin_setup_monitor ( void *  cls,
GNUNET_TRANSPORT_SessionInfoCallback  sic,
void *  sic_cls 
)
static

Begin monitoring sessions of a plugin.

There can only be one active monitor per plugin (i.e. if there are multiple monitors, the transport service needs to multiplex the generated events over all of them).

Parameters
clsclosure of the plugin
siccallback to invoke, NULL to disable monitor; plugin will being by iterating over all active sessions immediately and then enter monitor mode
sic_clsclosure for sic

Definition at line 2177 of file plugin_transport_wlan.c.

2180 {
2181  struct Plugin *plugin = cls;
2182  struct MacEndpoint *mac;
2183  struct GNUNET_ATS_Session *session;
2184 
2185  plugin->sic = sic;
2186  plugin->sic_cls = sic_cls;
2187  if (NULL != sic)
2188  {
2189  for (mac = plugin->mac_head; NULL != mac; mac = mac->next)
2190  for (session = mac->sessions_head; NULL != session; session =
2191  session->next)
2192  {
2194  session,
2197  session,
2199  }
2200  sic (sic_cls, NULL, NULL);
2201  }
2202 }

References GNUNET_TRANSPORT_SS_INIT, GNUNET_TRANSPORT_SS_UP, GNUNET_ATS_Session::mac, Plugin::mac_head, GNUNET_ATS_Session::next, MacEndpoint::next, notify_session_monitor(), plugin, MacEndpoint::sessions_head, Plugin::sic, and Plugin::sic_cls.

Here is the call graph for this function:

◆ wlan_plugin_update_session_timeout()

static void wlan_plugin_update_session_timeout ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_ATS_Session session 
)
static

Function that will be called whenever the transport service wants to notify the plugin that a session is still active and in use and therefore the session timeout for this session has to be updated.

Parameters
clsclosure
peerwhich peer was the session for
sessionwhich session is being updated

Definition at line 2215 of file plugin_transport_wlan.c.

2218 {
2219  GNUNET_assert (NULL != session->timeout_task);
2222 }

References GNUNET_assert, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, GNUNET_TIME_relative_to_absolute(), GNUNET_ATS_Session::timeout, and GNUNET_ATS_Session::timeout_task.

Here is the call graph for this function:

◆ wlan_plugin_update_inbound_delay()

static void wlan_plugin_update_inbound_delay ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_ATS_Session session,
struct GNUNET_TIME_Relative  delay 
)
static

Function that will be called whenever the transport service wants to notify the plugin that the inbound quota changed and that the plugin should update it's delay for the next receive value.

Parameters
clsclosure
peerwhich peer was the session for
sessionwhich session is being updated
delaynew delay to use for receiving

Definition at line 2236 of file plugin_transport_wlan.c.

2240 {
2241  /* does nothing, as inbound delay is not supported by WLAN */
2242 }

◆ LIBGNUNET_PLUGIN_TRANSPORT_INIT()

void* LIBGNUNET_PLUGIN_TRANSPORT_INIT ( void *  cls)

Entry point for the plugin.

Parameters
clsclosure, the struct GNUNET_TRANSPORT_PluginEnvironment *
Returns
the struct GNUNET_TRANSPORT_PluginFunctions * or NULL on error

Definition at line 2252 of file plugin_transport_wlan.c.

2253 {
2256  struct Plugin *plugin;
2257  char *wlan_interface;
2258  unsigned long long testmode;
2259  char *binary;
2260 
2261  /* check for 'special' mode */
2262  if (NULL == env->receive)
2263  {
2264  /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
2265  initialize the plugin or the API */
2267  api->cls = NULL;
2268  api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
2269  api->address_to_string = &wlan_plugin_address_to_string;
2270  api->string_to_address = &wlan_plugin_string_to_address;
2271  return api;
2272  }
2273 
2274  testmode = 0;
2275  /* check configuration */
2276  if ((GNUNET_YES ==
2278  CONFIG_NAME,
2279  "TESTMODE")) &&
2280  ((GNUNET_SYSERR ==
2282  CONFIG_NAME,
2283  "TESTMODE",
2284  &testmode)) ||
2285  (testmode > 2)))
2286  {
2288  CONFIG_NAME,
2289  "TESTMODE");
2290  return NULL;
2291  }
2292  binary = GNUNET_OS_get_libexec_binary_path (HELPER_NAME);
2293  if ((0 == testmode) &&
2294  (GNUNET_YES !=
2296  GNUNET_YES,
2297  NULL)))
2298  {
2300  _ ("Helper binary `%s' not SUID, cannot run WLAN transport\n"),
2301  HELPER_NAME);
2302  GNUNET_free (binary);
2303  return NULL;
2304  }
2305  GNUNET_free (binary);
2306  if (GNUNET_YES !=
2308  CONFIG_NAME,
2309  "INTERFACE",
2310  &wlan_interface))
2311  {
2313  CONFIG_NAME,
2314  "INTERFACE");
2315  return NULL;
2316  }
2317 
2318  plugin = GNUNET_new (struct Plugin);
2320  plugin->env = env;
2321  GNUNET_STATISTICS_set (plugin->env->stats,
2322  _ ("# sessions allocated"),
2323  0, GNUNET_NO);
2324  GNUNET_STATISTICS_set (plugin->env->stats,
2325  _ ("# MAC endpoints allocated"),
2326  0, 0);
2328  GNUNET_BANDWIDTH_value_init (100 * 1024
2329  * 1024 / 8),
2330  100);
2332  plugin);
2334  &process_data,
2335  plugin);
2337  plugin);
2338 
2339  plugin->options = 0;
2340 
2341  /* some compilers do not like switch on 'long long'... */
2342  switch ((unsigned int) testmode)
2343  {
2344  case 0: /* normal */
2345  plugin->helper_argv[0] = (char *) HELPER_NAME;
2347  plugin->helper_argv[2] = NULL;
2349  HELPER_NAME,
2352  NULL,
2353  plugin);
2354  break;
2355 
2356  case 1: /* testmode, peer 1 */
2357  plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME;
2358  plugin->helper_argv[1] = (char *) "1";
2359  plugin->helper_argv[2] = NULL;
2361  DUMMY_HELPER_NAME,
2364  NULL,
2365  plugin);
2366  break;
2367 
2368  case 2: /* testmode, peer 2 */
2369  plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME;
2370  plugin->helper_argv[1] = (char *) "2";
2371  plugin->helper_argv[2] = NULL;
2373  DUMMY_HELPER_NAME,
2376  NULL,
2377  plugin);
2378  break;
2379 
2380  default:
2381  GNUNET_assert (0);
2382  }
2383 
2385  api->cls = plugin;
2386  api->send = &wlan_plugin_send;
2387  api->get_session = &wlan_plugin_get_session;
2388  api->disconnect_peer = &wlan_plugin_disconnect_peer;
2389  api->disconnect_session = &wlan_plugin_disconnect_session;
2390  api->query_keepalive_factor = &wlan_plugin_query_keepalive_factor;
2391  api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
2392  api->check_address = &wlan_plugin_address_suggested;
2393  api->address_to_string = &wlan_plugin_address_to_string;
2394  api->string_to_address = &wlan_plugin_string_to_address;
2395  api->get_network = &wlan_plugin_get_network;
2396  api->get_network_for_address = &wlan_plugin_get_network_for_address;
2397  api->update_session_timeout = &wlan_plugin_update_session_timeout;
2398  api->update_inbound_delay = &wlan_plugin_update_inbound_delay;
2399  api->setup_monitor = &wlan_plugin_setup_monitor;
2400  return api;
2401 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init(uint32_t bytes_per_second)
Create a new bandwidth value.
Definition: bandwidth.c:39
void GNUNET_BANDWIDTH_tracker_init(struct GNUNET_BANDWIDTH_Tracker *av, GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, void *update_cb_cls, struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit, uint32_t max_carry_s)
Initialize bandwidth tracker.
Definition: bandwidth.c:302
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
struct GNUNET_HELPER_Handle * GNUNET_HELPER_start(int with_control_pipe, const char *binary_name, char *const binary_argv[], GNUNET_MessageTokenizerCallback cb, GNUNET_HELPER_ExceptionCallback exp_cb, void *cb_cls)
Starts a helper and begins reading from it.
Definition: helper.c:491
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
char * GNUNET_OS_get_libexec_binary_path(const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
int GNUNET_OS_check_helper_binary(const char *binary, int check_suid, const char *params)
Check whether an executable exists and possibly if the suid bit is set on the file.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
struct GNUNET_SERVER_MessageStreamTokenizer * GNUNET_SERVER_mst_create(GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
static ssize_t wlan_plugin_send(void *cls, struct GNUNET_ATS_Session *session, const char *msgbuf, size_t msgbuf_size, unsigned int priority, struct GNUNET_TIME_Relative to, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
Function that can be used by the transport service to transmit a message using the plugin.
static unsigned int wlan_plugin_query_keepalive_factor(void *cls)
Function that is called to get the keepalive factor.
static void wlan_plugin_update_inbound_delay(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session, struct GNUNET_TIME_Relative delay)
Function that will be called whenever the transport service wants to notify the plugin that the inbou...
static void wlan_plugin_disconnect_peer(void *cls, const struct GNUNET_PeerIdentity *target)
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
static void wlan_plugin_setup_monitor(void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls)
Begin monitoring sessions of a plugin.
static struct GNUNET_ATS_Session * wlan_plugin_get_session(void *cls, const struct GNUNET_HELLO_Address *address)
Creates a new outbound session the transport service will use to send data to the peer.
static int wlan_plugin_address_suggested(void *cls, const void *addr, size_t addrlen)
Another peer has suggested an address for this peer and transport plugin.
static int wlan_plugin_string_to_address(void *cls, const char *addr, uint16_t addrlen, void **buf, size_t *added)
Function called to convert a string address to a binary address.
static void wlan_plugin_address_pretty_printer(void *cls, const char *type, const void *addr, size_t addrlen, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressStringCallback asc, void *asc_cls)
Convert the transports address to a nice, human-readable format.
static void wlan_plugin_update_session_timeout(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session)
Function that will be called whenever the transport service wants to notify the plugin that a session...
static enum GNUNET_NetworkType wlan_plugin_get_network(void *cls, struct GNUNET_ATS_Session *session)
Function obtain the network type for a session.
static int process_data(void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
We have received data from the WLAN via some session.
static int handle_helper_message(void *cls, const struct GNUNET_MessageHeader *hdr)
Function used for to process the data from the suid process.
static enum GNUNET_NetworkType wlan_plugin_get_network_for_address(void *cls, const struct GNUNET_HELLO_Address *address)
Function obtain the network type for an address.
The transport service will pass a pointer to a struct of this type as the first and only argument to ...
void * cls
Closure for the various callbacks.
char * helper_argv[3]
ARGV-vector for the helper (all helpers take only the binary name, one actual argument,...

Variable Documentation

◆ scope

enum GNUNET_NetworkType scope = GNUNET_NT_BT
static