GNUnet  0.10.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
 Information about ongoing sessions of the transport client. 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 124 of file plugin_transport_wlan.c.

Referenced by create_macendpoint(), handle_helper_message(), send_hello_beacon(), and send_with_fragmentation().

◆ 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 140 of file plugin_transport_wlan.c.

Referenced by create_macendpoint().

◆ 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 146 of file plugin_transport_wlan.c.

Referenced by get_wlan_header().

◆ WLAN_LLC_SSAP_FIELD

#define WLAN_LLC_SSAP_FIELD   0x1f

Definition at line 147 of file plugin_transport_wlan.c.

Referenced by get_wlan_header().

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 112 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 586 of file plugin_transport_wlan.c.

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().

587 {
588  static char macstr[20];
589 
590  GNUNET_snprintf (macstr,
591  sizeof (macstr),
592  "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
593  mac->mac[0], mac->mac[1],
594  mac->mac[2], mac->mac[3],
595  mac->mac[4], mac->mac[5]);
596  return macstr;
597 }
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
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 612 of file plugin_transport_wlan.c.

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

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

615 {
617  static char macstr[36];
618 
619  if (sizeof (struct WlanAddress) != addrlen)
620  {
621  GNUNET_break (0);
622  return NULL;
623  }
624  mac = &((struct WlanAddress *) addr)->mac;
625  GNUNET_snprintf (macstr,
626  sizeof (macstr),
627  "%s.%u.%s",
628  PLUGIN_NAME,
629  ntohl (((struct WlanAddress *) addr)->options),
630  mac_to_string (mac));
631  return macstr;
632 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
Address format for WLAN.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
#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.
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 644 of file plugin_transport_wlan.c.

References GNUNET_ATS_Session::address, GNUNET_TRANSPORT_SessionInfo::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, GNUNET_TRANSPORT_SessionInfo::receive_delay, GNUNET_TRANSPORT_SessionInfo::session_timeout, Plugin::sic, Plugin::sic_cls, state, GNUNET_TRANSPORT_SessionInfo::state, and GNUNET_ATS_Session::timeout.

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

647 {
648  struct GNUNET_TRANSPORT_SessionInfo info;
649 
650  if (NULL == plugin->sic)
651  return;
652  memset (&info, 0, sizeof (info));
653  info.state = state;
654  info.is_inbound = GNUNET_SYSERR; /* hard to say */
655  info.num_msg_pending = 0; /* we queue per MAC, not per peer */
656  info.num_bytes_pending = 0; /* we queue per MAC, not per peer */
657  info.receive_delay = GNUNET_TIME_UNIT_ZERO_ABS; /* not supported by WLAN */
658  info.session_timeout = session->timeout;
659  info.address = session->address;
660  plugin->sic (plugin->sic_cls,
661  session,
662  &info);
663 }
GNUNET_TRANSPORT_SessionInfoCallback sic
Function to call about session status changes.
#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.
enum State state
current state of profiling
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
void * sic_cls
Closure for sic.
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 674 of file plugin_transport_wlan.c.

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

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

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

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, GNUNET_TRANSPORT_WLAN_Ieee80211Frame::sequence_control, WLAN_LLC_DSAP_FIELD, and WLAN_LLC_SSAP_FIELD.

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

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

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, size, GNUNET_MessageHeader::size, Plugin::suid_helper, and MacEndpoint::wlan_addr.

Referenced by create_macendpoint().

735 {
736  struct MacEndpoint *endpoint = cls;
737  struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage* radio_header;
738  uint16_t msize = ntohs (hdr->size);
739  size_t size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize;
740  char buf[size];
741 
742  if (NULL == endpoint)
743  {
744  GNUNET_break (0);
745  return;
746  }
747  if (size >= GNUNET_MAX_MESSAGE_SIZE)
748  {
749  GNUNET_break (0);
750  return;
751  }
753  "Sending ACK to %s\n",
754  mac_to_string (&endpoint->wlan_addr.mac));
755  radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
756  get_radiotap_header (endpoint, radio_header, size);
757  get_wlan_header (endpoint->plugin,
758  &radio_header->frame,
759  &endpoint->wlan_addr.mac,
760  sizeof (endpoint->wlan_addr.mac));
761  GNUNET_memcpy (&radio_header[1], hdr, msize);
762  if (NULL !=
764  &radio_header->header,
765  GNUNET_NO /* dropping ACKs is bad */,
766  NULL, NULL))
767  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
768  _("# ACKs sent"),
769  1, GNUNET_NO);
770 }
struct GNUNET_HELPER_Handle * suid_helper
Handle to helper process for priviledged operations.
static void get_radiotap_header(struct MacEndpoint *endpoint, struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header, uint16_t size)
Fill the radiotap header.
#define LOG(kind,...)
Definition: arm_api.c:33
#define GNUNET_NO
Definition: gnunet_common.h:81
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
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 GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct Plugin * plugin
Pointer to the global plugin struct.
#define GNUNET_memcpy(dst, src, n)
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
static char buf[2048]
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...
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MessageHeader header
Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER'.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
struct WlanAddress wlan_addr
peer MAC address
struct GNUNET_TRANSPORT_WLAN_MacAddress mac
WLAN addresses using MACs.
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:660
static const char * mac_to_string(const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
Print MAC addresses nicely.
Struct to represent one network card connection.
Message from the plugin to the WLAN helper: send the given message with the given connection paramete...
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.
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 780 of file plugin_transport_wlan.c.

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().

782 {
783  struct MacEndpoint *endpoint = cls;
784  struct Plugin *plugin = endpoint->plugin;
785  struct MacAndSession mas;
786 
787  GNUNET_STATISTICS_update (plugin->env->stats,
788  _("# Messages defragmented"),
789  1,
790  GNUNET_NO);
791  mas.session = NULL;
792  mas.endpoint = endpoint;
794  &mas,
795  (const char *) hdr,
796  ntohs (hdr->size),
798 }
struct MacEndpoint * endpoint
MAC address of the other peer, NULL if not known.
struct GNUNET_SERVER_MessageStreamTokenizer * fragment_data_tokenizer
Tokenizer for demultiplexing of data packets resulting from defragmentation.
#define GNUNET_NO
Definition: gnunet_common.h:81
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.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
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:208
struct Plugin * plugin
Pointer to the global plugin struct.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
Handle for a plugin.
Definition: block.c:37
#define GNUNET_YES
Definition: gnunet_common.h:80
Struct to represent one network card connection.
Information associated with a message.
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 808 of file plugin_transport_wlan.c.

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(), LIBGNUNET_PLUGIN_TRANSPORT_INIT(), session_timeout(), and wlan_plugin_disconnect_peer().

810 {
811  struct MacEndpoint *endpoint = session->mac;
812  struct Plugin *plugin = endpoint->plugin;
813 
814  plugin->env->session_end (plugin->env->cls,
815  session->address,
816  session);
817  notify_session_monitor (plugin,
818  session,
821  endpoint->sessions_tail,
822  session);
823  if (session->timeout_task != NULL)
824  {
826  session->timeout_task = NULL;
827  }
828  GNUNET_STATISTICS_update (plugin->env->stats,
829  _("# Sessions allocated"),
830  -1,
831  GNUNET_NO);
833  GNUNET_free (session);
834  return GNUNET_OK;
835 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
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 GNUNET_SCHEDULER_Task * timeout_task
Session timeout task.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_HELLO_Address * address
Address.
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:208
struct Plugin * plugin
Pointer to the global plugin struct.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct GNUNET_ATS_Session * sessions_head
Head of sessions that use this MAC.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
struct MacEndpoint * mac
MAC endpoint with the address of this peer.
struct GNUNET_ATS_Session * sessions_tail
Tail of sessions that use this MAC.
Handle for a plugin.
Definition: block.c:37
void * cls
Closure to use for callbacks.
Struct to represent one network card connection.
#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:965
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 847 of file plugin_transport_wlan.c.

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

848 {
849  return 3;
850 }
Here is the caller graph for this function:

◆ session_timeout()

static void session_timeout ( void *  cls)
static

A session is timing out.

Clean up.

Parameters
clspointer to the Session

Definition at line 859 of file plugin_transport_wlan.c.

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().

860 {
861  struct GNUNET_ATS_Session *session = cls;
862  struct GNUNET_TIME_Relative left;
863 
864  session->timeout_task = NULL;
866  if (0 != left.rel_value_us)
867  {
868  session->timeout_task =
871  session);
872  return;
873  }
875  session);
876 }
static void session_timeout(void *cls)
A session is timing out.
struct GNUNET_SCHEDULER_Task * timeout_task
Session timeout task.
struct GNUNET_TIME_Absolute timeout
When does this session time out.
struct Plugin * plugin
Pointer to the global plugin struct.
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:1246
Information about ongoing sessions of the transport client.
struct MacEndpoint * mac
MAC endpoint with the address of this peer.
static int wlan_plugin_disconnect_session(void *cls, struct GNUNET_ATS_Session *session)
Free a session.
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:331
Time for relative time used by GNUnet, in microseconds.
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 888 of file plugin_transport_wlan.c.

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

Referenced by get_session(), and process_data().

890 {
891  struct GNUNET_ATS_Session *session;
892 
893  for (session = endpoint->sessions_head; NULL != session; session = session->next)
894  if (0 == memcmp (peer, &session->target, sizeof (struct GNUNET_PeerIdentity)))
895  return session;
896  return NULL;
897 }
struct GNUNET_ATS_Session * next
Stored in a linked list.
struct GNUNET_ATS_Session * sessions_head
Head of sessions that use this MAC.
Information about ongoing sessions of the transport client.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_PeerIdentity target
To whom are we talking to.
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.

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().

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);
921  session->address = GNUNET_HELLO_address_allocate (peer,
922  PLUGIN_NAME,
923  &endpoint->wlan_addr,
924  sizeof (endpoint->wlan_addr),
926  session->mac = endpoint;
927  session->target = *peer;
929  session->timeout_task =
931  session);
932  notify_session_monitor (endpoint->plugin,
933  session,
935  notify_session_monitor (endpoint->plugin,
936  session,
939  "Created new session %p for peer `%s' with endpoint %s\n",
940  session,
941  GNUNET_i2s (peer),
942  mac_to_string (&endpoint->wlan_addr.mac));
943 
944  return session;
945 }
static void session_timeout(void *cls)
A session is timing out.
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 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
struct GNUNET_SCHEDULER_Task * timeout_task
Session timeout task.
#define LOG(kind,...)
Definition: arm_api.c:33
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:245
struct GNUNET_TIME_Absolute timeout
When does this session time out.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_HELLO_Address * address
Address.
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:208
struct Plugin * plugin
Pointer to the global plugin struct.
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:1246
struct GNUNET_ATS_Session * sessions_head
Head of sessions that use this MAC.
Information about ongoing sessions of the transport client.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct MacEndpoint * mac
MAC endpoint with the address of this peer.
struct GNUNET_ATS_Session * sessions_tail
Tail of sessions that use this MAC.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct WlanAddress wlan_addr
peer MAC address
struct GNUNET_TRANSPORT_WLAN_MacAddress mac
WLAN addresses using MACs.
#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...
No additional information.
struct GNUNET_PeerIdentity target
To whom are we talking to.
#define PLUGIN_NAME
static const char * mac_to_string(const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
Print MAC addresses nicely.
The session was created (first call for each session object).
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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 956 of file plugin_transport_wlan.c.

References create_session(), and lookup_session().

Referenced by wlan_plugin_get_session().

958 {
959  struct GNUNET_ATS_Session *session;
960 
961  if (NULL != (session = lookup_session (endpoint, peer)))
962  return session;
963  return create_session (endpoint, peer);
964 }
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.
Information about ongoing sessions of the transport client.
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 978 of file plugin_transport_wlan.c.

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

Referenced by transmit_fragment().

980 {
981  struct FragmentMessage *fm = cls;
982 
983  fm->sh = NULL;
985 }
struct GNUNET_HELPER_SendHandle * sh
Transmission handle to helper (to cancel if the frag context is destroyed early for some reason)...
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_FRAGMENT_Context * fragcontext
Fragmentation context.
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 995 of file plugin_transport_wlan.c.

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, size, GNUNET_MessageHeader::size, FragmentMessage::size_on_wire, Plugin::suid_helper, and MacEndpoint::wlan_addr.

Referenced by handle_helper_message(), and send_with_fragmentation().

997 {
998  struct FragmentMessage *fm = cls;
999  struct MacEndpoint *endpoint = fm->macendpoint;
1000  size_t size;
1001  uint16_t msize;
1002 
1003  if (NULL == endpoint)
1004  {
1005  GNUNET_break (0);
1006  return;
1007  }
1008  msize = ntohs (hdr->size);
1009  size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + msize;
1010  {
1011  char buf[size];
1012  struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radio_header;
1013 
1014  radio_header = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) buf;
1015  get_radiotap_header (endpoint, radio_header, size);
1017  "Sending %u bytes of data to MAC `%s'\n",
1018  (unsigned int) msize,
1019  mac_to_string (&endpoint->wlan_addr.mac));
1020 
1021  get_wlan_header (endpoint->plugin,
1022  &radio_header->frame,
1023  &endpoint->wlan_addr.mac,
1024  sizeof (endpoint->wlan_addr.mac));
1025  GNUNET_memcpy (&radio_header[1], hdr, msize);
1026  GNUNET_assert (NULL == fm->sh);
1027  fm->sh = GNUNET_HELPER_send (endpoint->plugin->suid_helper,
1028  &radio_header->header,
1029  GNUNET_NO,
1031  fm->size_on_wire += size;
1032  if (NULL != fm->sh)
1033  {
1034  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
1035  _("# message fragments sent"),
1036  1,
1037  GNUNET_NO);
1038  }
1039  else
1040  {
1042  }
1043  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
1044  "# bytes currently in buffers",
1045  -msize, GNUNET_NO);
1046  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
1047  "# bytes transmitted",
1048  msize, GNUNET_NO);
1049  }
1050 }
struct GNUNET_HELPER_Handle * suid_helper
Handle to helper process for priviledged operations.
static void get_radiotap_header(struct MacEndpoint *endpoint, struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header, uint16_t size)
Fill the radiotap header.
struct MacEndpoint * macendpoint
MAC endpoint this message belongs to.
#define LOG(kind,...)
Definition: arm_api.c:33
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_HELPER_SendHandle * sh
Transmission handle to helper (to cancel if the frag context is destroyed early for some reason)...
#define GNUNET_NO
Definition: gnunet_common.h:81
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
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 GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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 ...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct Plugin * plugin
Pointer to the global plugin struct.
#define GNUNET_memcpy(dst, src, n)
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
static char buf[2048]
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 for messages that are being fragmented in a MAC's transmission queue.
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_FRAGMENT_Context * fragcontext
Fragmentation context.
struct GNUNET_MessageHeader header
Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER'.
struct WlanAddress wlan_addr
peer MAC address
struct GNUNET_TRANSPORT_WLAN_MacAddress mac
WLAN addresses using MACs.
size_t size_on_wire
Number of bytes used to transmit 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:660
static const char * mac_to_string(const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
Print MAC addresses nicely.
Struct to represent one network card connection.
Message from the plugin to the WLAN helper: send the given message with the given connection paramete...
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...
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.
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 1059 of file plugin_transport_wlan.c.

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().

1060 {
1061  struct MacEndpoint *endpoint = fm->macendpoint;
1062 
1063  GNUNET_STATISTICS_update (endpoint->plugin->env->stats,
1064  _("# messages pending (with fragmentation)"),
1065  -1, GNUNET_NO);
1067  endpoint->sending_messages_tail,
1068  fm);
1069  if (NULL != fm->sh)
1070  {
1072  fm->sh = NULL;
1073  }
1074  if (NULL != fm->msg)
1075  {
1076  GNUNET_free (fm->msg);
1077  fm->msg = NULL;
1078  }
1079  if (NULL != fm->fragcontext)
1080  {
1082  &endpoint->msg_delay,
1083  &endpoint->ack_delay);
1084  fm->fragcontext = NULL;
1085  }
1086  if (NULL != fm->timeout_task)
1087  {
1089  fm->timeout_task = NULL;
1090  }
1091  GNUNET_free (fm);
1092 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct MacEndpoint * macendpoint
MAC endpoint this message belongs to.
struct GNUNET_HELPER_SendHandle * sh
Transmission handle to helper (to cancel if the frag context is destroyed early for some reason)...
#define GNUNET_NO
Definition: gnunet_common.h:81
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:208
struct Plugin * plugin
Pointer to the global plugin struct.
void GNUNET_HELPER_send_cancel(struct GNUNET_HELPER_SendHandle *sh)
Cancel a GNUNET_HELPER_send operation.
Definition: helper.c:701
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
struct FragmentMessage * sending_messages_head
Head of messages we are currently sending to this MAC.
struct GNUNET_FRAGMENT_Context * fragcontext
Fragmentation context.
struct FragmentMessage * sending_messages_tail
Tail of messages we are currently sending to this MAC.
struct GNUNET_TIME_Relative ack_delay
ACK delay for fragmentation context.
struct GNUNET_TIME_Relative msg_delay
Message delay for fragmentation context.
Struct to represent one network card connection.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
struct GNUNET_MessageHeader * msg
Message we need to fragment and transmit, NULL after the fragmentcontext has been created...
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).
#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:965
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 1101 of file plugin_transport_wlan.c.

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().

1102 {
1103  struct FragmentMessage *fm = cls;
1104 
1105  fm->timeout_task = NULL;
1106  if (NULL != fm->cont)
1107  {
1108  fm->cont (fm->cont_cls,
1109  &fm->target,
1110  GNUNET_SYSERR,
1111  fm->size_payload,
1112  fm->size_on_wire);
1113  fm->cont = NULL;
1114  }
1115  free_fragment_message (fm);
1116 }
GNUNET_TRANSPORT_TransmitContinuation cont
Continuation to call when we're done with this message.
static void free_fragment_message(struct FragmentMessage *fm)
Frees the space of a message in the fragment queue (send queue)
void * cont_cls
Closure for cont.
Struct for messages that are being fragmented in a MAC's transmission queue.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
size_t size_on_wire
Number of bytes used to transmit message.
size_t size_payload
Size of original message.
struct GNUNET_PeerIdentity target
Intended recipient.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
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 1134 of file plugin_transport_wlan.c.

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, FragmentMessage::msg, MacEndpoint::msg_delay, plugin, MacEndpoint::plugin, MacEndpoint::sending_messages_head, MacEndpoint::sending_messages_tail, FragmentMessage::size_payload, WlanHeader::target, FragmentMessage::target, FragmentMessage::timeout, FragmentMessage::timeout_task, Plugin::tracker, transmit_fragment(), and WLAN_MTU.

Referenced by wlan_plugin_send().

1142 {
1143  struct FragmentMessage *fm;
1144  struct Plugin *plugin;
1145 
1146  plugin = endpoint->plugin;
1147  fm = GNUNET_new (struct FragmentMessage);
1148  fm->macendpoint = endpoint;
1149  fm->target = *target;
1150  fm->size_payload = payload_size;
1151  fm->timeout = GNUNET_TIME_relative_to_absolute (timeout);
1152  fm->cont = cont;
1153  fm->cont_cls = cont_cls;
1154  /* 1 MBit/s typical data rate, 1430 byte fragments => ~100 ms per message */
1155  fm->timeout_task =
1158  fm);
1159  if (GNUNET_YES == plugin->have_mac)
1160  {
1161  fm->fragcontext =
1162  GNUNET_FRAGMENT_context_create (plugin->env->stats,
1163  WLAN_MTU,
1164  &plugin->tracker,
1165  fm->macendpoint->msg_delay,
1166  fm->macendpoint->ack_delay,
1167  msg,
1168  &transmit_fragment, fm);
1169  }
1170  else
1171  {
1172  fm->msg = GNUNET_copy_message (msg);
1173  }
1175  endpoint->sending_messages_tail,
1176  fm);
1177 }
GNUNET_TRANSPORT_TransmitContinuation cont
Continuation to call when we're done with this message.
int have_mac
Have we received a control message with our MAC address yet?
void * cont_cls
Closure for cont.
struct MacEndpoint * macendpoint
MAC endpoint this message belongs to.
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:245
static void transmit_fragment(void *cls, const struct GNUNET_MessageHeader *hdr)
Transmit a fragment of a message.
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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct Plugin * plugin
Pointer to the global plugin struct.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
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:1246
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
struct FragmentMessage * sending_messages_head
Head of messages we are currently sending to this MAC.
Struct for messages that are being fragmented in a MAC's transmission queue.
struct GNUNET_FRAGMENT_Context * fragcontext
Fragmentation context.
static void fragmentmessage_timeout(void *cls)
A FragmentMessage has timed out.
struct GNUNET_TIME_Absolute timeout
Timeout value for the message.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct FragmentMessage * sending_messages_tail
Tail of messages we are currently sending to this MAC.
struct GNUNET_TIME_Relative ack_delay
ACK delay for fragmentation context.
size_t size_payload
Size of original message.
Handle for a plugin.
Definition: block.c:37
struct GNUNET_TIME_Relative msg_delay
Message delay for fragmentation context.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_PeerIdentity target
Intended recipient.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
struct GNUNET_BANDWIDTH_Tracker tracker
Bandwidth tracker to limit global UDP traffic.
struct GNUNET_MessageHeader * msg
Message we need to fragment and transmit, NULL after the fragmentcontext has been created...
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define WLAN_MTU
Max size of packet (that we give to the WLAN driver for transmission)
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 1186 of file plugin_transport_wlan.c.

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().

1187 {
1188  struct Plugin *plugin = endpoint->plugin;
1189  struct FragmentMessage *fm;
1190  struct GNUNET_ATS_Session *session;
1191 
1192  GNUNET_STATISTICS_update (plugin->env->stats,
1193  _("# MAC endpoints allocated"),
1194  -1,
1195  GNUNET_NO);
1196  while (NULL != (session = endpoint->sessions_head))
1198  session);
1199  while (NULL != (fm = endpoint->sending_messages_head))
1200  free_fragment_message (fm);
1202  plugin->mac_tail,
1203  endpoint);
1204 
1205  if (NULL != endpoint->defrag)
1206  {
1208  endpoint->defrag = NULL;
1209  }
1210 
1211  plugin->mac_count--;
1212  if (NULL != endpoint->timeout_task)
1213  {
1215  endpoint->timeout_task = NULL;
1216  }
1217  GNUNET_free (endpoint);
1218 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static void free_fragment_message(struct FragmentMessage *fm)
Frees the space of a message in the fragment queue (send queue)
unsigned int mac_count
Number of connections.
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct MacEndpoint * mac_head
Head of list of open connections.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct Plugin * plugin
Pointer to the global plugin struct.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct GNUNET_ATS_Session * sessions_head
Head of sessions that use this MAC.
void GNUNET_DEFRAGMENT_context_destroy(struct GNUNET_DEFRAGMENT_Context *dc)
Destroy the given defragmentation context.
Information about ongoing sessions of the transport client.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
struct MacEndpoint * mac_tail
Tail of list of open connections.
struct FragmentMessage * sending_messages_head
Head of messages we are currently sending to this MAC.
Struct for messages that are being fragmented in a MAC's transmission queue.
struct GNUNET_DEFRAGMENT_Context * defrag
Defrag context for this MAC.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
Handle for a plugin.
Definition: block.c:37
static int wlan_plugin_disconnect_session(void *cls, struct GNUNET_ATS_Session *session)
Free a session.
#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:965
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 1227 of file plugin_transport_wlan.c.

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

Referenced by create_macendpoint().

1228 {
1229  struct MacEndpoint *endpoint = cls;
1231 
1232  endpoint->timeout_task = NULL;
1234  if (0 == timeout.rel_value_us)
1235  {
1236  free_macendpoint (endpoint);
1237  return;
1238  }
1239  endpoint->timeout_task =
1242  endpoint);
1243 }
uint64_t rel_value_us
The actual value.
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:1246
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:114
static void free_macendpoint(struct MacEndpoint *endpoint)
Free a MAC endpoint.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
static void macendpoint_timeout(void *cls)
A MAC endpoint is timing out.
struct GNUNET_TIME_Absolute timeout
When should this endpoint time out?
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:331
Struct to represent one network card connection.
Time for relative time used by GNUnet, in microseconds.
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 1254 of file plugin_transport_wlan.c.

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().

1256 {
1257  struct MacEndpoint *pos;
1258 
1259  for (pos = plugin->mac_head; NULL != pos; pos = pos->next)
1260  if (0 == memcmp (mac, &pos->wlan_addr, sizeof (pos->wlan_addr)))
1261  return pos;
1262  pos = GNUNET_new (struct MacEndpoint);
1263  pos->wlan_addr = (*mac);
1264  pos->plugin = plugin;
1265  pos->defrag =
1266  GNUNET_DEFRAGMENT_context_create (plugin->env->stats,
1267  WLAN_MTU,
1269  pos,
1271  &send_ack);
1272 
1275  pos->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
1276  pos->timeout_task =
1277  GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
1278  pos);
1280  plugin->mac_tail,
1281  pos);
1282  plugin->mac_count++;
1283  GNUNET_STATISTICS_update (plugin->env->stats,
1284  _("# MAC endpoints allocated"),
1285  1, GNUNET_NO);
1287  "New MAC endpoint `%s'\n",
1289  &pos->wlan_addr,
1290  sizeof (struct WlanAddress)));
1291  return pos;
1292 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
Address format for WLAN.
#define LOG(kind,...)
Definition: arm_api.c:33
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:245
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.
unsigned int mac_count
Number of connections.
struct MacEndpoint * next
We keep all MACs in a DLL in the plugin.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void wlan_data_message_handler(void *cls, const struct GNUNET_MessageHeader *hdr)
Handles the data after all fragments are put together.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct MacEndpoint * mac_head
Head of list of open connections.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct Plugin * plugin
Pointer to the global plugin struct.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
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:1246
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
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:439
struct MacEndpoint * mac_tail
Tail of list of open connections.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
static void send_ack(void *cls, uint32_t msg_id, const struct GNUNET_MessageHeader *hdr)
Send an ACK for a fragment we received.
struct WlanAddress wlan_addr
peer MAC address
struct GNUNET_DEFRAGMENT_Context * defrag
Defrag context for this MAC.
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.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
struct GNUNET_TIME_Relative ack_delay
ACK delay for fragmentation context.
#define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC
Maximum number of messages in defragmentation queue per MAC.
static void macendpoint_timeout(void *cls)
A MAC endpoint is timing out.
struct GNUNET_TIME_Relative msg_delay
Message delay for fragmentation context.
struct GNUNET_TIME_Absolute timeout
When should this endpoint time out?
Struct to represent one network card connection.
#define WLAN_MTU
Max size of packet (that we give to the WLAN driver for transmission)
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 1303 of file plugin_transport_wlan.c.

References GNUNET_NT_BT, and GNUNET_NT_WLAN.

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

1305 {
1306 #if BUILD_WLAN
1307  return GNUNET_NT_WLAN;
1308 #else
1309  return GNUNET_NT_BT;
1310 #endif
1311 }
Wireless LAN (i.e.
Definition: gnunet_nt_lib.h:60
Bluetooth LAN.
Definition: gnunet_nt_lib.h:65
Here is the caller graph for this function:

◆ 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 1322 of file plugin_transport_wlan.c.

References GNUNET_NT_BT, and GNUNET_NT_WLAN.

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

1324 {
1325 #if BUILD_WLAN
1326  return GNUNET_NT_WLAN;
1327 #else
1328  return GNUNET_NT_BT;
1329 #endif
1330 }
Wireless LAN (i.e.
Definition: gnunet_nt_lib.h:60
Bluetooth LAN.
Definition: gnunet_nt_lib.h:65
Here is the caller graph for this function:

◆ 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 1342 of file plugin_transport_wlan.c.

References GNUNET_HELLO_Address::address, GNUNET_HELLO_Address::address_length, create_macendpoint(), get_session(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), LOG, GNUNET_HELLO_Address::peer, plugin, and wlan_plugin_address_to_string().

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

1344 {
1345  struct Plugin *plugin = cls;
1346  struct MacEndpoint *endpoint;
1347 
1348  if (NULL == address)
1349  return NULL;
1350  if (sizeof (struct WlanAddress) != address->address_length)
1351  {
1352  GNUNET_break (0);
1353  return NULL;
1354  }
1356  "Service asked to create session for peer `%s' with MAC `%s'\n",
1357  GNUNET_i2s (&address->peer),
1359  address->address,
1360  address->address_length));
1361  endpoint = create_macendpoint (plugin,
1362  (struct WlanAddress *) address->address);
1363  return get_session (endpoint, &address->peer);
1364 }
size_t address_length
Number of bytes in address.
const void * address
Binary representation of the address (plugin-specific).
Address format for WLAN.
#define LOG(kind,...)
Definition: arm_api.c:33
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
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.
static struct MacEndpoint * create_macendpoint(struct Plugin *plugin, struct WlanAddress *mac)
Find (or create) a MacEndpoint with a specific MAC address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
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.
Handle for a plugin.
Definition: block.c:37
Struct to represent one network card connection.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller 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 1376 of file plugin_transport_wlan.c.

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

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

1378 {
1379  struct Plugin *plugin = cls;
1380  struct GNUNET_ATS_Session *session;
1381  struct MacEndpoint *endpoint;
1382 
1383  for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next)
1384  for (session = endpoint->sessions_head; NULL != session; session = session->next)
1385  if (0 == memcmp (target, &session->target,
1386  sizeof (struct GNUNET_PeerIdentity)))
1387  {
1388  wlan_plugin_disconnect_session (plugin, session);
1389  break; /* inner-loop only (in case peer has another MAC as well!) */
1390  }
1391 }
struct GNUNET_ATS_Session * next
Stored in a linked list.
struct MacEndpoint * next
We keep all MACs in a DLL in the plugin.
struct MacEndpoint * mac_head
Head of list of open connections.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct GNUNET_ATS_Session * sessions_head
Head of sessions that use this MAC.
Information about ongoing sessions of the transport client.
The identity of the host (wraps the signing key of the peer).
Handle for a plugin.
Definition: block.c:37
struct GNUNET_PeerIdentity target
To whom are we talking to.
static int wlan_plugin_disconnect_session(void *cls, struct GNUNET_ATS_Session *session)
Free a session.
Struct to represent one network card connection.
Here is the call graph for this function:
Here is the caller 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 1422 of file plugin_transport_wlan.c.

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, size, GNUNET_MessageHeader::size, WlanHeader::target, GNUNET_ATS_Session::target, type, and GNUNET_MessageHeader::type.

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

1428 {
1429  struct Plugin *plugin = cls;
1430  struct WlanHeader *wlanheader;
1431  size_t size = msgbuf_size + sizeof (struct WlanHeader);
1432  char buf[size] GNUNET_ALIGN;
1433 
1435  "Transmitting %u bytes of payload to peer `%s' (starting with %u byte message of type %u)\n",
1436  msgbuf_size,
1437  GNUNET_i2s (&session->target),
1438  (unsigned int) ntohs (((struct GNUNET_MessageHeader*)msgbuf)->size),
1439  (unsigned int) ntohs (((struct GNUNET_MessageHeader*)msgbuf)->type));
1440  wlanheader = (struct WlanHeader *) buf;
1441  wlanheader->header.size = htons (msgbuf_size + sizeof (struct WlanHeader));
1442  wlanheader->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA);
1443  wlanheader->sender = *plugin->env->my_identity;
1444  wlanheader->target = session->target;
1445  wlanheader->crc = htonl (GNUNET_CRYPTO_crc32_n (msgbuf, msgbuf_size));
1446  GNUNET_memcpy (&wlanheader[1],
1447  msgbuf,
1448  msgbuf_size);
1449  GNUNET_STATISTICS_update (plugin->env->stats,
1450  "# bytes currently in buffers",
1451  msgbuf_size,
1452  GNUNET_NO);
1453  send_with_fragmentation (session->mac,
1454  to,
1455  &session->target,
1456  &wlanheader->header,
1457  msgbuf_size,
1458  cont, cont_cls);
1459  return size;
1460 }
uint32_t crc
CRC32 checksum (only over the payload), in NBO.
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:105
#define LOG(kind,...)
Definition: arm_api.c:33
Header for messages which need fragmentation.
struct GNUNET_PeerIdentity sender
Sender of the message.
#define GNUNET_NO
Definition: gnunet_common.h:81
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_memcpy(dst, src, n)
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
static char buf[2048]
struct GNUNET_PeerIdentity target
Target of the message.
#define GNUNET_MESSAGE_TYPE_WLAN_DATA
Type of messages for data over the wlan.
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MessageHeader header
Message type is GNUNET_MESSAGE_TYPE_WLAN_DATA.
struct MacEndpoint * mac
MAC endpoint with the address of this peer.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's...
Handle for a plugin.
Definition: block.c:37
struct GNUNET_PeerIdentity target
To whom are we talking to.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Header for all communications.
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.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller 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 1472 of file plugin_transport_wlan.c.

References _, GNUNET_ATS_Session::address, 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(), LOG, lookup_session(), FragmentMessage::next, plugin, PLUGIN_NAME, ret, WlanHeader::sender, MacEndpoint::sending_messages_head, MacAndSession::session, GNUNET_MessageHeader::size, FragmentMessage::size_on_wire, FragmentMessage::size_payload, WlanHeader::target, FragmentMessage::target, GNUNET_ATS_Session::target, GNUNET_ATS_Session::timeout, MacEndpoint::timeout, GNUNET_MessageHeader::type, MacEndpoint::wlan_addr, Plugin::wlan_header_payload_tokenizer, and wlan_plugin_address_to_string().

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

1475 {
1476  struct Plugin *plugin = cls;
1477  struct GNUNET_HELLO_Address *address;
1478  struct MacAndSession *mas = client;
1479  struct FragmentMessage *fm;
1480  struct GNUNET_PeerIdentity tmpsource;
1481  const struct WlanHeader *wlanheader;
1482  int ret;
1483  uint16_t msize;
1484 
1485  msize = ntohs (hdr->size);
1486 
1487  GNUNET_STATISTICS_update (plugin->env->stats,
1488  "# bytes received",
1489  msize, GNUNET_NO);
1490 
1491  switch (ntohs (hdr->type))
1492  {
1494 
1495  if (GNUNET_OK !=
1496  GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr,
1497  &tmpsource))
1498  {
1499  GNUNET_break_op (0);
1500  break;
1501  }
1502  if (NULL == mas->endpoint)
1503  {
1504  GNUNET_break (0);
1505  break;
1506  }
1507 
1509  "Processing %u bytes of HELLO from peer `%s' at MAC %s\n",
1510  (unsigned int) msize,
1511  GNUNET_i2s (&tmpsource),
1513  &mas->endpoint->wlan_addr,
1514  sizeof (mas->endpoint->wlan_addr)));
1515 
1516  GNUNET_STATISTICS_update (plugin->env->stats,
1517  _("# HELLO messages received"), 1,
1518  GNUNET_NO);
1519  address = GNUNET_HELLO_address_allocate (&tmpsource,
1520  PLUGIN_NAME,
1521  &mas->endpoint->wlan_addr,
1522  sizeof (mas->endpoint->wlan_addr),
1524  mas->session = lookup_session (mas->endpoint,
1525  &tmpsource);
1526  if (NULL == mas->session)
1527  {
1528  mas->session = create_session (mas->endpoint,
1529  &tmpsource);
1530  plugin->env->session_start (plugin->env->cls,
1531  address,
1532  mas->session,
1533  scope);
1534  }
1535  plugin->env->receive (plugin->env->cls,
1536  address,
1537  mas->session,
1538  hdr);
1539  GNUNET_HELLO_address_free (address);
1540  break;
1542  if (NULL == mas->endpoint)
1543  {
1544  GNUNET_break (0);
1545  break;
1546  }
1548  "Processing %u bytes of FRAGMENT from MAC %s\n",
1549  (unsigned int) msize,
1551  &mas->endpoint->wlan_addr,
1552  sizeof (mas->endpoint->wlan_addr)));
1553  GNUNET_STATISTICS_update (plugin->env->stats,
1554  _("# fragments received"),
1555  1,
1556  GNUNET_NO);
1558  hdr);
1559  break;
1561  if (NULL == mas->endpoint)
1562  {
1563  GNUNET_break (0);
1564  break;
1565  }
1566  GNUNET_STATISTICS_update (plugin->env->stats,
1567  _("# ACKs received"),
1568  1, GNUNET_NO);
1569  for (fm = mas->endpoint->sending_messages_head; NULL != fm; fm = fm->next)
1570  {
1571  ret = GNUNET_FRAGMENT_process_ack (fm->fragcontext, hdr);
1572  if (GNUNET_OK == ret)
1573  {
1575  "Got last ACK, finished message transmission to `%s' (%p)\n",
1577  &mas->endpoint->wlan_addr,
1578  sizeof (mas->endpoint->wlan_addr)),
1579  fm);
1580  mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
1581  if (NULL != fm->cont)
1582  {
1583  fm->cont (fm->cont_cls,
1584  &fm->target,
1585  GNUNET_OK,
1586  fm->size_payload,
1587  fm->size_on_wire);
1588  fm->cont = NULL;
1589  }
1590  free_fragment_message (fm);
1591  break;
1592  }
1593  if (GNUNET_NO == ret)
1594  {
1596  "Got an ACK, message transmission to `%s' not yet finished\n",
1598  &mas->endpoint->wlan_addr,
1599  sizeof (mas->endpoint->wlan_addr)));
1600  break;
1601  }
1602  }
1603  if (NULL == fm)
1605  "ACK not matched against any active fragmentation with MAC `%s'\n",
1607  &mas->endpoint->wlan_addr,
1608  sizeof (mas->endpoint->wlan_addr)));
1609  break;
1611  if (NULL == mas->endpoint)
1612  {
1613  GNUNET_break (0);
1614  break;
1615  }
1616  if (msize < sizeof (struct WlanHeader))
1617  {
1618  GNUNET_break (0);
1619  break;
1620  }
1621  wlanheader = (const struct WlanHeader *) hdr;
1622  if (0 != memcmp (&wlanheader->target,
1623  plugin->env->my_identity,
1624  sizeof (struct GNUNET_PeerIdentity)))
1625  {
1627  "Data for `%s', not for me, ignoring\n",
1628  GNUNET_i2s (&wlanheader->target));
1629  break;
1630  }
1631  if (ntohl (wlanheader->crc) !=
1632  GNUNET_CRYPTO_crc32_n (&wlanheader[1],
1633  msize - sizeof (struct WlanHeader)))
1634  {
1635  GNUNET_STATISTICS_update (plugin->env->stats,
1636  _("# DATA messages discarded due to CRC32 error"),
1637  1,
1638  GNUNET_NO);
1639  break;
1640  }
1641  mas->session = lookup_session (mas->endpoint,
1642  &wlanheader->sender);
1643  if (NULL == mas->session)
1644  {
1645  mas->session = create_session (mas->endpoint,
1646  &wlanheader->sender);
1647  address = GNUNET_HELLO_address_allocate (&wlanheader->sender,
1648  PLUGIN_NAME,
1649  &mas->endpoint->wlan_addr,
1650  sizeof (struct WlanAddress),
1652  plugin->env->session_start (plugin->env->cls,
1653  address,
1654  mas->session,
1655  scope);
1657  "Notifying transport about peer `%s''s new session %p \n",
1658  GNUNET_i2s (&wlanheader->sender),
1659  mas->session);
1660  GNUNET_HELLO_address_free (address);
1661  }
1663  "Processing %u bytes of DATA from peer `%s'\n",
1664  (unsigned int) msize,
1665  GNUNET_i2s (&wlanheader->sender));
1668  mas,
1669  (const char *) &wlanheader[1],
1670  msize - sizeof (struct WlanHeader),
1671  GNUNET_YES,
1672  GNUNET_NO);
1673  break;
1674  default:
1675  if (NULL == mas->endpoint)
1676  {
1677  GNUNET_break (0);
1678  break;
1679  }
1680  if (NULL == mas->session)
1681  {
1682  GNUNET_break (0);
1683  break;
1684  }
1686  "Received packet with %u bytes of type %u from peer %s\n",
1687  (unsigned int) msize,
1688  (unsigned int) ntohs (hdr->type),
1689  GNUNET_i2s (&mas->session->target));
1690  plugin->env->receive (plugin->env->cls,
1691  mas->session->address,
1692  mas->session,
1693  hdr);
1694  break;
1695  }
1696  return GNUNET_OK;
1697 }
static struct GNUNET_ATS_Session * create_session(struct MacEndpoint *endpoint, const struct GNUNET_PeerIdentity *peer)
Create a new session.
GNUNET_TRANSPORT_TransmitContinuation cont
Continuation to call when we&#39;re done with this message.
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:668
A HELLO message is used to exchange information about transports with other peers.
uint32_t crc
CRC32 checksum (only over the payload), in NBO.
struct MacEndpoint * endpoint
MAC address of the other peer, NULL if not known.
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
static struct GNUNET_ATS_Session * lookup_session(struct MacEndpoint *endpoint, const struct GNUNET_PeerIdentity *peer)
Lookup a new session.
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:105
Address format for WLAN.
static void free_fragment_message(struct FragmentMessage *fm)
Frees the space of a message in the fragment queue (send queue)
void * cont_cls
Closure for cont.
#define LOG(kind,...)
Definition: arm_api.c:33
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:245
Header for messages which need fragmentation.
struct GNUNET_PeerIdentity sender
Sender of the message.
struct GNUNET_TIME_Absolute timeout
When does this session time out.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_HELLO_Address * address
Address.
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.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define GNUNET_MESSAGE_TYPE_FRAGMENT_ACK
Acknowledgement of a FRAGMENT of a larger message.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct FragmentMessage * next
This is a doubly-linked list.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
struct GNUNET_SERVER_MessageStreamTokenizer * wlan_header_payload_tokenizer
Tokenizer for demultiplexing of data packets that follow the WLAN Header.
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).
struct GNUNET_PeerIdentity target
Target of the message.
struct FragmentMessage * sending_messages_head
Head of messages we are currently sending to this MAC.
Struct for messages that are being fragmented in a MAC&#39;s transmission queue.
#define GNUNET_MESSAGE_TYPE_WLAN_DATA
Type of messages for data over the wlan.
struct GNUNET_FRAGMENT_Context * fragcontext
Fragmentation context.
struct WlanAddress wlan_addr
peer MAC address
struct GNUNET_DEFRAGMENT_Context * defrag
Defrag context for this MAC.
#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
After how long do we consider a connection to a peer dead if we don&#39;t receive messages from the peer...
The identity of the host (wraps the signing key of the peer).
No additional information.
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.
size_t size_on_wire
Number of bytes used to transmit message.
size_t size_payload
Size of original message.
Handle for a plugin.
Definition: block.c:37
struct GNUNET_PeerIdentity target
To whom are we talking to.
#define PLUGIN_NAME
An address for communicating with a peer.
struct GNUNET_TIME_Absolute timeout
When should this endpoint time out?
void * cls
Closure to use for callbacks.
int GNUNET_DEFRAGMENT_process_fragment(struct GNUNET_DEFRAGMENT_Context *dc, const struct GNUNET_MessageHeader *msg)
We have received a fragment.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_PeerIdentity target
Intended recipient.
#define GNUNET_MESSAGE_TYPE_FRAGMENT
FRAGMENT of a larger message.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
Information associated with a message.
static char * address
GNS address for this phone.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_HELLO_address_free(addr)
Free an address.
struct GNUNET_ATS_Session * session
NULL if the identity of the other peer is not known.
Here is the call graph for this function:
Here is the caller 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 1706 of file plugin_transport_wlan.c.

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().

1707 {
1708  struct Plugin *plugin = cls;
1709  uint16_t size;
1710  uint16_t hello_size;
1711  struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader;
1712  const struct GNUNET_MessageHeader *hello;
1713 
1714  hello = plugin->env->get_our_hello ();
1715  if (NULL != hello)
1716  {
1717  hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
1718  GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU);
1719  size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size;
1720  {
1721  char buf[size] GNUNET_ALIGN;
1722 
1724  "Sending %u byte HELLO beacon\n",
1725  (unsigned int) size);
1726  radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) buf;
1727  get_radiotap_header (NULL, radioHeader, size);
1729  "Broadcasting %u bytes of data to MAC `%s'\n",
1730  (unsigned int) size,
1732  get_wlan_header (plugin, &radioHeader->frame, &bc_all_mac, size);
1733  GNUNET_memcpy (&radioHeader[1], hello, hello_size);
1734  if (NULL !=
1736  &radioHeader->header,
1737  GNUNET_YES /* can drop */,
1738  NULL, NULL))
1739  GNUNET_STATISTICS_update (plugin->env->stats,
1740  _("# HELLO beacons sent"),
1741  1, GNUNET_NO);
1742  } }
1743  plugin->beacon_task =
1745  (HELLO_BEACON_SCALING_FACTOR,
1746  plugin->mac_count + 1),
1748  plugin);
1749 
1750 }
struct GNUNET_HELPER_Handle * suid_helper
Handle to helper process for priviledged operations.
A HELLO message is used to exchange information about transports with other peers.
static void get_radiotap_header(struct MacEndpoint *endpoint, struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header, uint16_t size)
Fill the radiotap header.
#define LOG(kind,...)
Definition: arm_api.c:33
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
unsigned int mac_count
Number of connections.
Header for messages which need fragmentation.
#define GNUNET_NO
Definition: gnunet_common.h:81
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:208
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
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:1246
#define GNUNET_memcpy(dst, src, n)
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
static char buf[2048]
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:439
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 GNUNET_SCHEDULER_Task * beacon_task
Task that periodically sends a HELLO beacon via the helper.
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MessageHeader header
Type is &#39;GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER&#39;.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to &#39;struct&#39;s...
Handle for a plugin.
Definition: block.c:37
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:660
static const char * mac_to_string(const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
Print MAC addresses nicely.
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
Definition: hello.c:649
static void send_hello_beacon(void *cls)
Task to (periodically) send a HELLO beacon.
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:80
static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac
Broadcast MAC.
Message from the plugin to the WLAN helper: send the given message with the given connection paramete...
#define WLAN_MTU
Max size of packet (that we give to the WLAN driver for transmission)
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.
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 1760 of file plugin_transport_wlan.c.

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, Plugin::helper_payload_tokenizer, LOG, GNUNET_TRANSPORT_WLAN_HelperControlMessage::mac, WlanAddress::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.

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

1762 {
1763  struct Plugin *plugin = cls;
1764  struct GNUNET_HELLO_Address *my_address;
1765  const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rxinfo;
1767  struct WlanAddress wa;
1768  struct MacAndSession mas;
1769  uint16_t msize;
1770  struct FragmentMessage *fm;
1771  struct MacEndpoint *endpoint;
1772 
1773  msize = ntohs (hdr->size);
1774  switch (ntohs (hdr->type))
1775  {
1777  if (msize != sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage))
1778  {
1779  GNUNET_break (0);
1780  break;
1781  }
1782  cm = (const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *) hdr;
1783  if (GNUNET_YES == plugin->have_mac)
1784  {
1785  if (0 == memcmp (&plugin->mac_address,
1786  &cm->mac,
1787  sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1788  break; /* no change */
1789  /* remove old address */
1790  memset (&wa, 0, sizeof (struct WlanAddress));
1791  wa.mac = plugin->mac_address;
1792  wa.options = htonl(plugin->options);
1793  my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
1794  PLUGIN_NAME,
1795  &wa, sizeof (wa),
1797  plugin->env->notify_address (plugin->env->cls,
1798  GNUNET_NO,
1799  my_address);
1800  GNUNET_HELLO_address_free (my_address);
1801  plugin->mac_address = cm->mac;
1802  }
1803  else
1804  {
1805  plugin->mac_address = cm->mac;
1806  plugin->have_mac = GNUNET_YES;
1807  for (endpoint = plugin->mac_head; NULL != endpoint; endpoint = endpoint->next)
1808  {
1809  for (fm = endpoint->sending_messages_head; NULL != fm; fm = fm->next)
1810  {
1811  if (NULL != fm->fragcontext)
1812  {
1813  GNUNET_break (0); /* should not happen */
1814  continue;
1815  }
1816  fm->fragcontext =
1817  GNUNET_FRAGMENT_context_create (plugin->env->stats,
1818  WLAN_MTU,
1819  &plugin->tracker,
1820  fm->macendpoint->msg_delay,
1821  fm->macendpoint->ack_delay,
1822  fm->msg,
1823  &transmit_fragment, fm);
1824  GNUNET_free (fm->msg);
1825  fm->msg = NULL;
1826  }
1827  }
1828  GNUNET_break (NULL == plugin->beacon_task);
1830  plugin);
1831 
1832  }
1833 
1834  memset (&wa, 0, sizeof (struct WlanAddress));
1835  wa.mac = plugin->mac_address;
1836  wa.options = htonl(plugin->options);
1837  my_address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
1838  PLUGIN_NAME,
1839  &wa, sizeof (wa),
1841 
1843  "Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n",
1844  mac_to_string (&cm->mac),
1845  GNUNET_i2s (plugin->env->my_identity));
1846  plugin->env->notify_address (plugin->env->cls,
1847  GNUNET_YES,
1848  my_address);
1849  GNUNET_HELLO_address_free (my_address);
1850  break;
1853  "Got data message from helper with %u bytes\n",
1854  msize);
1855  GNUNET_STATISTICS_update (plugin->env->stats,
1856  _("# DATA messages received"), 1,
1857  GNUNET_NO);
1858  if (msize < sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage))
1859  {
1861  "Size of packet is too small (%u bytes < %u)\n",
1862  msize, sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage));
1863  break;
1864  }
1865  rxinfo = (const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) hdr;
1866 
1867  /* check if message is actually for us */
1868  if (0 != memcmp (&rxinfo->frame.addr3, &mac_bssid_gnunet,
1869  sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1870  {
1871  /* Not the GNUnet BSSID */
1872  break;
1873  }
1874  if ( (0 != memcmp (&rxinfo->frame.addr1, &bc_all_mac,
1875  sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))) &&
1876  (0 != memcmp (&rxinfo->frame.addr1, &plugin->mac_address,
1877  sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))) )
1878  {
1879  /* Neither broadcast nor specifically for us */
1880  break;
1881  }
1882  if (0 == memcmp (&rxinfo->frame.addr2, &plugin->mac_address,
1883  sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)))
1884  {
1885  /* packet is FROM us, thus not FOR us */
1886  break;
1887  }
1888 
1889  GNUNET_STATISTICS_update (plugin->env->stats,
1890  _("# DATA messages processed"),
1891  1, GNUNET_NO);
1893  "Receiving %u bytes of data from MAC `%s'\n",
1894  (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)),
1895  mac_to_string (&rxinfo->frame.addr2));
1897  "Receiving %u bytes of data to MAC `%s'\n",
1898  (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)),
1899  mac_to_string (&rxinfo->frame.addr1));
1901  "Receiving %u bytes of data with BSSID MAC `%s'\n",
1902  (unsigned int) (msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)),
1903  mac_to_string (&rxinfo->frame.addr3));
1904  wa.mac = rxinfo->frame.addr2;
1905  wa.options = htonl (0);
1906  mas.endpoint = create_macendpoint (plugin, &wa);
1907  mas.session = NULL;
1909  &mas,
1910  (const char*) &rxinfo[1],
1911  msize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage),
1913  break;
1914  default:
1915  GNUNET_break (0);
1917  "Unexpected message of type %u (%u bytes)",
1918  ntohs (hdr->type),
1919  ntohs (hdr->size));
1920  break;
1921  }
1922  return GNUNET_OK;
1923 }
#define GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL
Control message between the gnunet-wlan-helper and the daemon (with the MAC).
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
int have_mac
Have we received a control message with our MAC address yet?
Address format for WLAN.
struct MacEndpoint * macendpoint
MAC endpoint this message belongs to.
#define LOG(kind,...)
Definition: arm_api.c:33
struct GNUNET_SERVER_MessageStreamTokenizer * helper_payload_tokenizer
Tokenizer for demultiplexing of data packets received from the suid helper.
uint32_t options
Options for addresses.
static void transmit_fragment(void *cls, const struct GNUNET_MessageHeader *hdr)
Transmit a fragment of a message.
struct MacEndpoint * next
We keep all MACs in a DLL in the plugin.
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.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
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 GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct MacEndpoint * mac_head
Head of list of open connections.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
Format of a WLAN Control Message.
Message from the WLAN helper to the plugin: we have received the given message with the given perform...
struct GNUNET_TRANSPORT_WLAN_MacAddress mac
MAC Address of the local WLAN interface.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct FragmentMessage * next
This is a doubly-linked list.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
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:1273
struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame
IEEE Frame.
static GNUNET_NETWORK_STRUCT_END const struct GNUNET_TRANSPORT_WLAN_MacAddress mac_bssid_gnunet
GNUnet bssid.
struct FragmentMessage * sending_messages_head
Head of messages we are currently sending to this MAC.
struct GNUNET_SCHEDULER_Task * beacon_task
Task that periodically sends a HELLO beacon via the helper.
Struct for messages that are being fragmented in a MAC&#39;s transmission queue.
struct GNUNET_FRAGMENT_Context * fragcontext
Fragmentation context.
static struct MacEndpoint * create_macendpoint(struct Plugin *plugin, struct WlanAddress *mac)
Find (or create) a MacEndpoint with a specific MAC address.
struct GNUNET_TRANSPORT_WLAN_MacAddress mac_address
The mac_address of the wlan card given to us by the helper.
No additional information.
struct GNUNET_TIME_Relative ack_delay
ACK delay for fragmentation context.
Handle for a plugin.
Definition: block.c:37
#define PLUGIN_NAME
An address for communicating with a peer.
struct GNUNET_TIME_Relative msg_delay
Message delay for fragmentation context.
static const char * mac_to_string(const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
Print MAC addresses nicely.
static void send_hello_beacon(void *cls)
Task to (periodically) send a HELLO beacon.
void * cls
Closure to use for callbacks.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_TRANSPORT_WLAN_MacAddress addr3
Address 3: BSSID in ad-hoc mode, Destination if station, source if AP.
Struct to represent one network card connection.
#define GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER
Type of data messages from the gnunet-wlan-helper to the plugin.
struct GNUNET_BANDWIDTH_Tracker tracker
Bandwidth tracker to limit global UDP traffic.
static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac
Broadcast MAC.
struct GNUNET_MessageHeader * msg
Message we need to fragment and transmit, NULL after the fragmentcontext has been created...
Information associated with a message.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_TRANSPORT_WLAN_MacAddress addr2
Address 2: source address if in ad-hoc-mode or station, BSSID if AP.
#define GNUNET_HELLO_address_free(addr)
Free an address.
struct GNUNET_TRANSPORT_WLAN_MacAddress addr1
Address 1: destination address in ad-hoc mode or AP, BSSID if station,.
#define GNUNET_free(ptr)
Wrapper around free.
#define WLAN_MTU
Max size of packet (that we give to the WLAN driver for transmission)
Here is the call graph for this function:
Here is the caller 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 1939 of file plugin_transport_wlan.c.

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.

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

1942 {
1943  struct Plugin *plugin = cls;
1944  struct WlanAddress *wa = (struct WlanAddress *) addr;
1945 
1946  if (addrlen != sizeof (struct WlanAddress))
1947  {
1948  GNUNET_break_op (0);
1949  return GNUNET_SYSERR;
1950  }
1951  if (GNUNET_YES != plugin->have_mac)
1952  {
1954  "Rejecting MAC `%s': I don't know my MAC!\n",
1955  mac_to_string (addr));
1956  return GNUNET_NO; /* don't know my MAC */
1957  }
1958  if (0 != memcmp (&wa->mac,
1959  &plugin->mac_address,
1960  sizeof (wa->mac)))
1961  {
1963  "Rejecting MAC `%s': not my MAC!\n",
1964  mac_to_string (addr));
1965  return GNUNET_NO; /* not my MAC */
1966  }
1967  return GNUNET_OK;
1968 }
int have_mac
Have we received a control message with our MAC address yet?
Address format for WLAN.
#define LOG(kind,...)
Definition: arm_api.c:33
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_TRANSPORT_WLAN_MacAddress mac_address
The mac_address of the wlan card given to us by the helper.
struct GNUNET_TRANSPORT_WLAN_MacAddress mac
WLAN addresses using MACs.
Handle for a plugin.
Definition: block.c:37
static const char * mac_to_string(const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
Print MAC addresses nicely.
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller 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 1985 of file plugin_transport_wlan.c.

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

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

1993 {
1994  const char *ret;
1995 
1996  if (sizeof (struct WlanAddress) == addrlen)
1997  ret = wlan_plugin_address_to_string (NULL,
1998  addr,
1999  addrlen);
2000  else
2001  ret = NULL;
2002  asc (asc_cls,
2003  ret,
2004  (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
2005  asc (asc_cls, NULL, GNUNET_OK);
2006 }
Address format for WLAN.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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.
Here is the call graph for this function:
Here is the caller 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 2015 of file plugin_transport_wlan.c.

References address, Plugin::beacon_task, GNUNET_DATACACHE_PluginEnvironment::cls, GNUNET_TRANSPORT_PluginFunctions::cls, Plugin::env, Plugin::fragment_data_tokenizer, free_macendpoint(), GNUNET_free, GNUNET_free_non_null, 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.

2016 {
2017  struct WlanAddress wa;
2018  struct GNUNET_HELLO_Address *address;
2019  struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
2020  struct Plugin *plugin = api->cls;
2021  struct MacEndpoint *endpoint;
2022  struct MacEndpoint *endpoint_next;
2023 
2024  if (NULL == plugin)
2025  {
2026  GNUNET_free (api);
2027  return NULL;
2028  }
2029  if (GNUNET_YES == plugin->have_mac)
2030  {
2031  memset (&wa, 0, sizeof(wa));
2032  wa.options = htonl (plugin->options);
2033  wa.mac = plugin->mac_address;
2034  address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
2035  PLUGIN_NAME,
2036  &wa, sizeof (struct WlanAddress),
2038 
2039  plugin->env->notify_address (plugin->env->cls,
2040  GNUNET_NO,
2041  address);
2042  plugin->have_mac = GNUNET_NO;
2043  GNUNET_HELLO_address_free (address);
2044  }
2045 
2046  if (NULL != plugin->beacon_task)
2047  {
2049  plugin->beacon_task = NULL;
2050  }
2051  if (NULL != plugin->suid_helper)
2052  {
2054  GNUNET_NO);
2055  plugin->suid_helper = NULL;
2056  }
2057  endpoint_next = plugin->mac_head;
2058  while (NULL != (endpoint = endpoint_next))
2059  {
2060  endpoint_next = endpoint->next;
2061  free_macendpoint (endpoint);
2062  }
2063  if (NULL != plugin->fragment_data_tokenizer)
2064  {
2066  plugin->fragment_data_tokenizer = NULL;
2067  }
2068  if (NULL != plugin->wlan_header_payload_tokenizer)
2069  {
2071  plugin->wlan_header_payload_tokenizer = NULL;
2072  }
2073  if (NULL != plugin->helper_payload_tokenizer)
2074  {
2076  plugin->helper_payload_tokenizer = NULL;
2077  }
2079  GNUNET_free (plugin);
2080  GNUNET_free (api);
2081  return NULL;
2082 }
struct GNUNET_HELPER_Handle * suid_helper
Handle to helper process for priviledged operations.
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
int have_mac
Have we received a control message with our MAC address yet?
Address format for WLAN.
struct GNUNET_SERVER_MessageStreamTokenizer * helper_payload_tokenizer
Tokenizer for demultiplexing of data packets received from the suid helper.
uint32_t options
Options for addresses.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
struct MacEndpoint * next
We keep all MACs in a DLL in the plugin.
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:569
struct GNUNET_SERVER_MessageStreamTokenizer * fragment_data_tokenizer
Tokenizer for demultiplexing of data packets resulting from defragmentation.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
void GNUNET_SERVER_mst_destroy(struct GNUNET_SERVER_MessageStreamTokenizer *mst)
Destroys a tokenizer.
struct MacEndpoint * mac_head
Head of list of open connections.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
void * cls
Closure for all of the callbacks.
char * wlan_interface
The interface of the wlan card given to us by the user.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
struct GNUNET_SERVER_MessageStreamTokenizer * wlan_header_payload_tokenizer
Tokenizer for demultiplexing of data packets that follow the WLAN Header.
struct GNUNET_SCHEDULER_Task * beacon_task
Task that periodically sends a HELLO beacon via the helper.
static void free_macendpoint(struct MacEndpoint *endpoint)
Free a MAC endpoint.
struct GNUNET_TRANSPORT_WLAN_MacAddress mac_address
The mac_address of the wlan card given to us by the helper.
No additional information.
Handle for a plugin.
Definition: block.c:37
#define PLUGIN_NAME
An address for communicating with a peer.
void * cls
Closure to use for callbacks.
#define GNUNET_YES
Definition: gnunet_common.h:80
Struct to represent one network card connection.
static char * address
GNS address for this phone.
#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:965
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 2098 of file plugin_transport_wlan.c.

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

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

2103 {
2104  struct WlanAddress *wa;
2105  unsigned int a[6];
2106  unsigned int i;
2107  char plugin[5];
2108  uint32_t options;
2109 
2110  if ((NULL == addr) || (0 == addrlen))
2111  {
2112  GNUNET_break (0);
2113  return GNUNET_SYSERR;
2114  }
2115  if ('\0' != addr[addrlen - 1])
2116  {
2117  GNUNET_break (0);
2118  return GNUNET_SYSERR;
2119  }
2120  if (strlen (addr) != addrlen - 1)
2121  {
2122  GNUNET_break (0);
2123  return GNUNET_SYSERR;
2124  }
2125 
2126  if (8 != SSCANF (addr,
2127  "%4s.%u.%X:%X:%X:%X:%X:%X",
2128  plugin, &options,
2129  &a[0], &a[1], &a[2],
2130  &a[3], &a[4], &a[5]))
2131  {
2132  GNUNET_break (0);
2133  return GNUNET_SYSERR;
2134  }
2135  wa = GNUNET_new (struct WlanAddress);
2136  for (i=0;i<6;i++)
2137  wa->mac.mac[i] = a[i];
2138  wa->options = htonl (0);
2139  *buf = wa;
2140  *added = sizeof (struct WlanAddress);
2141  return GNUNET_OK;
2142 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
Address format for WLAN.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
static char buf[2048]
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_TRANSPORT_WLAN_MacAddress mac
WLAN addresses using MACs.
#define SSCANF
Definition: plibc.h:691
uint32_t options
Options set for the WLAN, in NBO.
Here is the caller graph for this function:

◆ 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 2158 of file plugin_transport_wlan.c.

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

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

2161 {
2162  struct Plugin *plugin = cls;
2163  struct MacEndpoint *mac;
2164  struct GNUNET_ATS_Session *session;
2165 
2166  plugin->sic = sic;
2167  plugin->sic_cls = sic_cls;
2168  if (NULL != sic)
2169  {
2170  for (mac = plugin->mac_head; NULL != mac; mac = mac->next)
2171  for (session = mac->sessions_head; NULL != session; session = session->next)
2172  {
2173  notify_session_monitor (plugin,
2174  session,
2176  notify_session_monitor (plugin,
2177  session,
2179  }
2180  sic (sic_cls, NULL, NULL);
2181  }
2182 }
GNUNET_TRANSPORT_SessionInfoCallback sic
Function to call about session status changes.
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 GNUNET_ATS_Session * next
Stored in a linked list.
struct MacEndpoint * next
We keep all MACs in a DLL in the plugin.
struct MacEndpoint * mac_head
Head of list of open connections.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct GNUNET_ATS_Session * sessions_head
Head of sessions that use this MAC.
Information about ongoing sessions of the transport client.
Handle for a plugin.
Definition: block.c:37
The session was created (first call for each session object).
Struct to represent one network card connection.
void * sic_cls
Closure for sic.
Here is the call graph for this function:
Here is the caller 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 2196 of file plugin_transport_wlan.c.

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

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

2199 {
2200  GNUNET_assert (NULL != session->timeout_task);
2202 }
struct GNUNET_SCHEDULER_Task * timeout_task
Session timeout task.
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:245
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TIME_Absolute timeout
When does this session time out.
#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
After how long do we consider a connection to a peer dead if we don&#39;t receive messages from the peer...
Here is the call graph for this function:
Here is the caller 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 2216 of file plugin_transport_wlan.c.

Referenced by LIBGNUNET_PLUGIN_TRANSPORT_INIT().

2220 {
2221  /* does nothing, as inbound delay is not supported by WLAN */
2222 }
Here is the caller graph for this function:

◆ 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 2232 of file plugin_transport_wlan.c.

References _, GNUNET_TRANSPORT_PluginFunctions::address_pretty_printer, GNUNET_TRANSPORT_PluginFunctions::address_to_string, Plugin::api, GNUNET_TRANSPORT_PluginEnvironment::cfg, GNUNET_TRANSPORT_PluginFunctions::check_address, GNUNET_TRANSPORT_PluginEnvironment::cls, GNUNET_TRANSPORT_PluginFunctions::cls, GNUNET_TRANSPORT_PluginFunctions::disconnect_peer, GNUNET_TRANSPORT_PluginFunctions::disconnect_session, env, Plugin::env, Plugin::fragment_data_tokenizer, GNUNET_TRANSPORT_PluginFunctions::get_network, GNUNET_TRANSPORT_PluginFunctions::get_network_for_address, GNUNET_TRANSPORT_PluginFunctions::get_session, GNUNET_assert, GNUNET_BANDWIDTH_tracker_init(), GNUNET_BANDWIDTH_value_init(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_have_value(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_HELPER_start(), GNUNET_log_config_missing(), GNUNET_new, GNUNET_NO, GNUNET_OS_check_helper_binary(), GNUNET_OS_get_libexec_binary_path(), GNUNET_SERVER_mst_create(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_YES, handle_helper_message(), Plugin::helper_argv, Plugin::helper_payload_tokenizer, LOG, Plugin::options, plugin, process_data(), GNUNET_TRANSPORT_PluginFunctions::query_keepalive_factor, GNUNET_TRANSPORT_PluginEnvironment::receive, GNUNET_TRANSPORT_PluginFunctions::send, GNUNET_TRANSPORT_PluginFunctions::setup_monitor, GNUNET_TRANSPORT_PluginFunctions::string_to_address, Plugin::suid_helper, Plugin::tracker, GNUNET_TRANSPORT_PluginFunctions::update_inbound_delay, GNUNET_TRANSPORT_PluginFunctions::update_session_timeout, Plugin::wlan_header_payload_tokenizer, Plugin::wlan_interface, wlan_plugin_address_pretty_printer(), wlan_plugin_address_suggested(), wlan_plugin_address_to_string(), wlan_plugin_disconnect_peer(), wlan_plugin_disconnect_session(), wlan_plugin_get_network(), wlan_plugin_get_network_for_address(), wlan_plugin_get_session(), wlan_plugin_query_keepalive_factor(), wlan_plugin_send(), wlan_plugin_setup_monitor(), wlan_plugin_string_to_address(), wlan_plugin_update_inbound_delay(), and wlan_plugin_update_session_timeout().

2233 {
2236  struct Plugin *plugin;
2237  char *wlan_interface;
2238  unsigned long long testmode;
2239  char *binary;
2240 
2241  /* check for 'special' mode */
2242  if (NULL == env->receive)
2243  {
2244  /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
2245  initialze the plugin or the API */
2247  api->cls = NULL;
2251  return api;
2252  }
2253 
2254  testmode = 0;
2255  /* check configuration */
2256  if ( (GNUNET_YES ==
2258  CONFIG_NAME,
2259  "TESTMODE")) &&
2260  ( (GNUNET_SYSERR ==
2262  CONFIG_NAME,
2263  "TESTMODE",
2264  &testmode)) ||
2265  (testmode > 2) ) )
2266  {
2268  CONFIG_NAME,
2269  "TESTMODE");
2270  return NULL;
2271  }
2272  binary = GNUNET_OS_get_libexec_binary_path (HELPER_NAME);
2273  if ( (0 == testmode) &&
2274  (GNUNET_YES !=
2276  GNUNET_YES,
2277  NULL)) )
2278  {
2280  _("Helper binary `%s' not SUID, cannot run WLAN transport\n"),
2281  HELPER_NAME);
2282  GNUNET_free (binary);
2283  return NULL;
2284  }
2285  GNUNET_free (binary);
2286  if (GNUNET_YES !=
2288  CONFIG_NAME,
2289  "INTERFACE",
2290  &wlan_interface))
2291  {
2293  CONFIG_NAME,
2294  "INTERFACE");
2295  return NULL;
2296  }
2297 
2298  plugin = GNUNET_new (struct Plugin);
2299  plugin->wlan_interface = wlan_interface;
2300  plugin->env = env;
2301  GNUNET_STATISTICS_set (plugin->env->stats,
2302  _("# sessions allocated"),
2303  0, GNUNET_NO);
2304  GNUNET_STATISTICS_set (plugin->env->stats,
2305  _("# MAC endpoints allocated"),
2306  0, 0);
2307  GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, NULL, NULL,
2308  GNUNET_BANDWIDTH_value_init (100 * 1024 *
2309  1024 / 8),
2310  100);
2312  plugin);
2314  plugin);
2316  plugin);
2317 
2318  plugin->options = 0;
2319 
2320  /* some compilers do not like switch on 'long long'... */
2321  switch ((unsigned int) testmode)
2322  {
2323  case 0: /* normal */
2324  plugin->helper_argv[0] = (char *) HELPER_NAME;
2325  plugin->helper_argv[1] = wlan_interface;
2326  plugin->helper_argv[2] = NULL;
2328  HELPER_NAME,
2329  plugin->helper_argv,
2331  NULL,
2332  plugin);
2333  break;
2334  case 1: /* testmode, peer 1 */
2335  plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME;
2336  plugin->helper_argv[1] = (char *) "1";
2337  plugin->helper_argv[2] = NULL;
2339  DUMMY_HELPER_NAME,
2340  plugin->helper_argv,
2342  NULL,
2343  plugin);
2344  break;
2345  case 2: /* testmode, peer 2 */
2346  plugin->helper_argv[0] = (char *) DUMMY_HELPER_NAME;
2347  plugin->helper_argv[1] = (char *) "2";
2348  plugin->helper_argv[2] = NULL;
2350  DUMMY_HELPER_NAME,
2351  plugin->helper_argv,
2353  NULL,
2354  plugin);
2355  break;
2356  default:
2357  GNUNET_assert (0);
2358  }
2359 
2361  api->cls = plugin;
2362  api->send = &wlan_plugin_send;
2376  return api;
2377 }
static int handle_helper_message(void *cls, const struct GNUNET_MessageHeader *hdr)
Function used for to process the data from the suid process.
struct GNUNET_HELPER_Handle * suid_helper
Handle to helper process for priviledged operations.
char * helper_argv[3]
ARGV-vector for the helper (all helpers take only the binary name, one actual argument, plus the NULL terminator for &#39;argv&#39;).
GNUNET_TRANSPORT_CreateSession get_session
Function that will be called tell the plugin to create a session object.
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...
GNUNET_TRANSPORT_AddressToString address_to_string
Function that will be called to convert a binary address to a string (numeric conversion only)...
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.
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
int 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.
static void wlan_plugin_setup_monitor(void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls)
Begin monitoring sessions of a plugin.
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...
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
GNUNET_TRANSPORT_TransmitFunction send
Function that the transport service will use to transmit data to another peer.
GNUNET_TRANSPORT_DisconnectPeerFunction disconnect_peer
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
#define LOG(kind,...)
Definition: arm_api.c:33
static unsigned int wlan_plugin_query_keepalive_factor(void *cls)
Function that is called to get the keepalive factor.
struct GNUNET_SERVER_MessageStreamTokenizer * helper_payload_tokenizer
Tokenizer for demultiplexing of data packets received from the suid helper.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t options
Options for addresses.
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
GNUNET_TRANSPORT_SessionMonitorSetup setup_monitor
Function to monitor the sessions managed by the plugin.
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.
struct GNUNET_SERVER_MessageStreamTokenizer * fragment_data_tokenizer
Tokenizer for demultiplexing of data packets resulting from defragmentation.
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...
#define GNUNET_NO
Definition: gnunet_common.h:81
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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
GNUNET_TRANSPORT_PluginReceiveCallback receive
Function that should be called by the transport plugin whenever a message is received.
GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout
Function that will be called whenever the transport service wants to notify the plugin that a session...
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
void * cls
Closure for the various callbacks.
void * cls
Closure for all of the callbacks.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
GNUNET_TRANSPORT_StringToAddress string_to_address
Function that will be called to convert a string address to binary (numeric conversion only)...
char * wlan_interface
The interface of the wlan card given to us by the user.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
The transport service will pass a pointer to a struct of this type as the first and only argument to ...
int 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.
GNUNET_TRANSPORT_GetNetworkType get_network
Function to obtain the network type for a session.
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...
struct GNUNET_SERVER_MessageStreamTokenizer * wlan_header_payload_tokenizer
Tokenizer for demultiplexing of data packets that follow the WLAN Header.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
GNUNET_TRANSPORT_UpdateInboundDelay update_inbound_delay
Function that will be called whenever the transport service wants to notify the plugin that the inbou...
int 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.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor
Function that is used to query keepalive factor.
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.
Handle for a plugin.
Definition: block.c:37
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 ...
static int wlan_plugin_disconnect_session(void *cls, struct GNUNET_ATS_Session *session)
Free a session.
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer
Function to pretty-print addresses.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_BANDWIDTH_Tracker tracker
Bandwidth tracker to limit global UDP traffic.
GNUNET_TRANSPORT_CheckAddress check_address
Function that will be called to check if a binary address for this plugin is well-formed and correspo...
struct GNUNET_SERVER_MessageStreamTokenizer * GNUNET_SERVER_mst_create(GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
static enum GNUNET_NetworkType wlan_plugin_get_network(void *cls, struct GNUNET_ATS_Session *session)
Function obtain the network type for a session.
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...
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_TRANSPORT_GetNetworkTypeForAddress get_network_for_address
Function to obtain the network type for an address.
static int process_data(void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
We have received data from the WLAN via some session.
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.
Here is the call graph for this function:

Variable Documentation

◆ scope

enum GNUNET_NetworkType scope = GNUNET_NT_BT
static

Which network scope do we belong to?

Definition at line 133 of file plugin_transport_wlan.c.

Referenced by create_session(), plugin_env_session_start(), and server_lookup_connection().