44 #define PLUGIN_NAME "wlan" 45 #define CONFIG_NAME "transport-wlan" 46 #define HELPER_NAME "gnunet-helper-transport-wlan" 47 #define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy" 48 #define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_wlan_init 49 #define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_wlan_done 50 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-wlan", __VA_ARGS__) 56 #define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply ( \ 57 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2) 64 #define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply ( \ 65 GNUNET_TIME_UNIT_SECONDS, 2) 72 #define PLUGIN_NAME "bluetooth" 73 #define CONFIG_NAME "transport-bluetooth" 74 #define HELPER_NAME "gnunet-helper-transport-bluetooth" 76 #define DUMMY_HELPER_NAME "gnunet-helper-transport-wlan-dummy" 77 #define LIBGNUNET_PLUGIN_TRANSPORT_INIT \ 78 libgnunet_plugin_transport_bluetooth_init 79 #define LIBGNUNET_PLUGIN_TRANSPORT_DONE \ 80 libgnunet_plugin_transport_bluetooth_done 81 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-bluetooth", \ 87 #define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply ( \ 88 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 60) 96 #define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply ( \ 97 GNUNET_TIME_UNIT_SECONDS, 60) 101 #error need to build wlan or bluetooth 131 #define WLAN_MTU 1430 147 #define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC 2 153 #define WLAN_LLC_DSAP_FIELD 0x1f 154 #define WLAN_LLC_SSAP_FIELD 0x1f 242 void *transmit_cont_cls;
586 static char macstr[20];
590 "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
593 mac->
mac[4], mac->
mac[5]);
615 static char macstr[36];
648 if (NULL == plugin->
sic)
650 memset (&info, 0,
sizeof(info));
678 if (NULL != endpoint)
707 const int rate = 11000000;
710 header->
addr1 = *to_mac_addr;
736 uint16_t msize = ntohs (hdr->
size);
741 if (NULL == endpoint)
752 "Sending ACK to %s\n",
757 &radio_header->
frame,
787 _ (
"# Messages defragmented"),
813 plugin->
env->session_end (plugin->
env->
cls,
828 _ (
"# Sessions allocated"),
891 for (session = endpoint->
sessions_head; NULL != session; session =
893 if (0 == memcmp (peer, &session->
target,
sizeof(
struct 914 _ (
"# Sessions allocated"),
926 session->
mac = endpoint;
941 "Created new session %p for peer `%s' with endpoint %s\n",
1005 if (NULL == endpoint)
1010 msize = ntohs (hdr->
size);
1019 "Sending %u bytes of data to MAC `%s'\n",
1020 (
unsigned int) msize,
1024 &radio_header->
frame,
1037 _ (
"# message fragments sent"),
1046 "# bytes currently in buffers",
1049 "# bytes transmitted",
1066 _ (
"# messages pending (with fragmentation)"),
1076 if (NULL != fm->
msg)
1108 if (NULL != fm->
cont)
1140 size_t payload_size,
1148 plugin = endpoint->
plugin;
1195 _ (
"# MAC endpoints allocated"),
1207 if (NULL != endpoint->
defrag)
1261 for (pos = plugin->
mac_head; NULL != pos; pos = pos->
next)
1287 _ (
"# MAC endpoints allocated"),
1290 "New MAC endpoint `%s'\n",
1351 if (NULL == address)
1359 "Service asked to create session for peer `%s' with MAC `%s'\n",
1386 for (endpoint = plugin->
mac_head; NULL != endpoint; endpoint = endpoint->
next)
1387 for (session = endpoint->
sessions_head; NULL != session; session =
1389 if (0 == memcmp (target, &session->
target,
1428 const char *msgbuf,
size_t msgbuf_size,
1429 unsigned int priority,
1439 "Transmitting %llu bytes of payload to peer `%s' (starting with %u byte message of type %u)\n",
1440 (
unsigned long long) msgbuf_size,
1447 wlanheader->
sender = *plugin->
env->my_identity;
1454 "# bytes currently in buffers",
1489 msize = ntohs (hdr->
size);
1495 switch (ntohs (hdr->
type))
1513 "Processing %u bytes of HELLO from peer `%s' at MAC %s\n",
1514 (
unsigned int) msize,
1521 _ (
"# HELLO messages received"), 1,
1534 plugin->
env->session_start (plugin->
env->
cls,
1553 "Processing %u bytes of FRAGMENT from MAC %s\n",
1554 (
unsigned int) msize,
1559 _ (
"# fragments received"),
1573 _ (
"# ACKs received"),
1581 "Got last ACK, finished message transmission to `%s' (%p)\n",
1587 MACENDPOINT_TIMEOUT);
1588 if (NULL != fm->
cont)
1603 "Got an ACK, message transmission to `%s' not yet finished\n",
1612 "ACK not matched against any active fragmentation with MAC `%s'\n",
1629 wlanheader = (
const struct WlanHeader *) hdr;
1630 if (0 != memcmp (&wlanheader->
target,
1631 plugin->
env->my_identity,
1635 "Data for `%s', not for me, ignoring\n",
1639 if (ntohl (wlanheader->
crc) !=
1645 "# DATA messages discarded due to CRC32 error"),
1661 plugin->
env->session_start (plugin->
env->
cls,
1666 "Notifying transport about peer `%s''s new session %p \n",
1672 "Processing %u bytes of DATA from peer `%s'\n",
1673 (
unsigned int) msize,
1679 (
const char *) &wlanheader[1],
1697 "Received packet with %u bytes of type %u from peer %s\n",
1698 (
unsigned int) msize,
1699 (
unsigned int) ntohs (hdr->type),
1721 uint16_t hello_size;
1725 hello = plugin->
env->get_our_hello ();
1736 "Sending %u byte HELLO beacon\n",
1737 (
unsigned int) size);
1741 "Broadcasting %u bytes of data to MAC `%s'\n",
1742 (
unsigned int) size,
1752 _ (
"# HELLO beacons sent"),
1758 (HELLO_BEACON_SCALING_FACTOR,
1785 msize = ntohs (hdr->
size);
1786 switch (ntohs (hdr->
type))
1809 plugin->
env->notify_address (plugin->
env->
cls,
1819 for (endpoint = plugin->
mac_head; NULL != endpoint; endpoint =
1855 "Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n",
1858 plugin->
env->notify_address (plugin->
env->
cls,
1866 "Got data message from helper with %u bytes\n",
1869 _ (
"# DATA messages received"), 1,
1874 "Size of packet is too small (%llu bytes < %llu)\n",
1875 (
unsigned long long) msize,
1904 _ (
"# DATA messages processed"),
1907 "Receiving %u bytes of data from MAC `%s'\n",
1908 (
unsigned int) (msize -
sizeof(
struct 1912 "Receiving %u bytes of data to MAC `%s'\n",
1913 (
unsigned int) (msize -
sizeof(
struct 1917 "Receiving %u bytes of data with BSSID MAC `%s'\n",
1918 (
unsigned int) (msize -
sizeof(
struct 1927 (
const char *) &rxinfo[1],
1928 msize -
sizeof(
struct 1936 "Unexpected message of type %u (%u bytes)",
1973 "Rejecting MAC `%s': I don't know my MAC!\n",
1977 if (0 != memcmp (&wa->
mac,
1982 "Rejecting MAC `%s': not my MAC!\n",
2024 asc (asc_cls, NULL, GNUNET_OK);
2050 memset (&wa, 0,
sizeof(wa));
2058 plugin->
env->notify_address (plugin->
env->
cls,
2077 while (NULL != (endpoint = endpoint_next))
2079 endpoint_next = endpoint->
next;
2129 if ((NULL == addr) || (0 == addrlen))
2134 if (
'\0' != addr[addrlen - 1])
2139 if (strlen (addr) != addrlen - 1)
2145 if (8 != sscanf (addr,
2146 "%4s.%u.%X:%X:%X:%X:%X:%X",
2148 &a[0], &a[1], &a[2],
2149 &a[3], &a[4], &a[5]))
2155 for (i = 0; i < 6; i++)
2189 for (mac = plugin->
mac_head; NULL != mac; mac = mac->
next)
2190 for (session = mac->
sessions_head; NULL != session; session =
2200 sic (sic_cls, NULL, NULL);
2258 unsigned long long testmode;
2293 if ((0 == testmode) &&
2300 _ (
"Helper binary `%s' not SUID, cannot run WLAN transport\n"),
2322 _ (
"# sessions allocated"),
2325 _ (
"# MAC endpoints allocated"),
2342 switch ((
unsigned int) testmode)
2357 plugin->
helper_argv[0] = (
char *) DUMMY_HELPER_NAME;
2369 plugin->
helper_argv[0] = (
char *) DUMMY_HELPER_NAME;
static struct GNUNET_ATS_Session * create_session(struct MacEndpoint *endpoint, const struct GNUNET_PeerIdentity *peer)
Create a new session.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static int handle_helper_message(void *cls, const struct GNUNET_MessageHeader *hdr)
Function used for to process the data from the suid process.
size_t address_length
Number of bytes in address.
Session is being torn down and about to disappear.
static void session_timeout(void *cls)
A session is timing out.
GNUNET_TRANSPORT_SessionInfoCallback sic
Function to call about session status changes.
GNUNET_TRANSPORT_TransmitContinuation cont
Continuation to call when we'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.
struct GNUNET_HELPER_Handle * suid_helper
Handle to helper process for priviledged operations.
#define GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL
Control message between the gnunet-wlan-helper and the daemon (with the MAC).
uint32_t num_bytes_pending
Number of bytes pending transmission for this session.
char * helper_argv[3]
ARGV-vector for the helper (all helpers take only the binary name, one actual argument, plus the NULL terminator for 'argv').
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.
A HELLO message is used to exchange information about transports with other peers.
#define WLAN_LLC_SSAP_FIELD
struct MacEndpoint * endpoint
MAC address of the other peer, NULL if not known.
struct GNUNET_MessageHeader * msg
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)...
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.
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.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
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.
uint64_t rel_value_us
The actual value.
const void * address
Binary representation of the address (plugin-specific).
static void wlan_plugin_setup_monitor(void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls)
Begin monitoring sessions of a plugin.
int have_mac
Have we received a control message with our MAC address yet?
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
uint8_t antenna
Antenna we should use for this MAC.
static struct GNUNET_ATS_Session * lookup_session(struct MacEndpoint *endpoint, const struct GNUNET_PeerIdentity *peer)
Lookup a new session.
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_GETOPT_CommandLineOption options[]
int32_t GNUNET_CRYPTO_crc32_n(const void *buf, size_t len)
Compute the CRC32 checksum for the first len bytes of the buffer.
static void get_radiotap_header(struct MacEndpoint *endpoint, struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header, uint16_t size)
Fill the radiotap header.
struct MacEndpoint * prev
We keep all MACs in a DLL in the plugin.
struct GNUNET_SCHEDULER_Task * timeout_task
Session timeout task.
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 MacEndpoint * macendpoint
MAC endpoint this message belongs to.
uint8_t antenna
Antenna; the first antenna is 0.
The handle to a helper process.
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.
struct GNUNET_ATS_Session * next
Stored in a linked list.
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...
int is_inbound
GNUNET_YES if this is an inbound connection, GNUNET_NO if this is an outbound connection, GNUNET_SYSERR if connections of this plugin are so fundamentally bidirectional that they have no 'initiator'
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
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.
static unsigned int wlan_plugin_query_keepalive_factor(void *cls)
Function that is called to get the keepalive factor.
enum GNUNET_TRANSPORT_SessionState state
New state of the session.
struct GNUNET_SERVER_MessageStreamTokenizer * helper_payload_tokenizer
Tokenizer for demultiplexing of data packets received from the suid helper.
struct GNUNET_ATS_Session * prev
Stored in a linked list.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t options
Options for addresses.
unsigned int mac_count
Number of connections.
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
static void transmit_fragment(void *cls, const struct GNUNET_MessageHeader *hdr)
Transmit a fragment of a message.
struct GNUNET_HELPER_SendHandle * sh
Transmission handle to helper (to cancel if the frag context is destroyed early for some reason)...
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.
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...
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.
void * LIBGNUNET_PLUGIN_TRANSPORT_INIT(void *cls)
Entry point for 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.
Entry in the queue of messages we need to transmit to the helper.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
struct PendingMessage * next
DLL next, prev.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
Struct to track available bandwidth.
struct GNUNET_TIME_Absolute timeout
When does this session time out.
static ssize_t wlan_plugin_send(void *cls, struct GNUNET_ATS_Session *session, const char *msgbuf, size_t msgbuf_size, unsigned int priority, struct GNUNET_TIME_Relative to, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
Function that can be used by the transport service to transmit a message using the plugin...
static int numeric
Option -n.
int GNUNET_OS_check_helper_binary(const char *binary, int check_suid, const char *params)
Check whether an executable exists and possibly if the suid bit is set on the file.
void GNUNET_SERVER_mst_destroy(struct GNUNET_SERVER_MessageStreamTokenizer *mst)
Destroys a tokenizer.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_HELLO_Address * address
Address.
static char * helper_argv[8]
Command-line arguments we are giving to the hijacker process.
#define WLAN_LLC_DSAP_FIELD
Link layer control fields for better compatibility (i.e.
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.
static void wlan_data_message_handler(void *cls, const struct GNUNET_MessageHeader *hdr)
Handles the data after all fragments are put together.
u_int8_t llc[4]
Link layer control (LLC).
#define IEEE80211_FC0_TYPE_DATA
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
const struct GNUNET_HELLO_Address * address
Address used by the session.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_MESSAGE_TYPE_FRAGMENT_ACK
Acknowledgement of a FRAGMENT of a larger message.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
uint32_t num_msg_pending
Number of messages pending transmission for this session.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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.
uint8_t rate
Desired transmission rate for this MAC.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
struct GNUNET_TIME_Absolute receive_delay
Until when does this plugin refuse to receive to manage staying within the inbound quota...
struct MacEndpoint * mac_head
Head of list of open connections.
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 ...
Format of a WLAN Control Message.
struct Plugin * plugin
Pointer to the global plugin struct.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
Handle to a message stream tokenizer.
GNUNET_TRANSPORT_PluginReceiveCallback receive
Function that should be called by the transport plugin whenever a message is received.
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...
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.
GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout
Function that will be called whenever the transport service wants to notify the plugin that a session...
Information about a plugin's session.
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.
struct GNUNET_ATS_Session * sessions_head
Head of sessions that use this MAC.
struct FragmentMessage * next
This is a doubly-linked list.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task (for this message).
void * cls
Closure for the various callbacks.
enum State state
current state of profiling
void GNUNET_HELPER_send_cancel(struct GNUNET_HELPER_SendHandle *sh)
Cancel a GNUNET_HELPER_send operation.
void * cls
Closure for all of the callbacks.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
void GNUNET_DEFRAGMENT_context_destroy(struct GNUNET_DEFRAGMENT_Context *dc)
Destroy the given defragmentation context.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
void(* GNUNET_TRANSPORT_AddressStringCallback)(void *cls, const char *address, int res)
Function called by the pretty printer for the resolved address for each human-readable address obtain...
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.
Session handle for connections.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
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.
The transport service will pass a pointer to a struct of this type as the first and only argument to ...
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
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...
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.
struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame
IEEE Frame.
void(* GNUNET_TRANSPORT_SessionInfoCallback)(void *cls, struct GNUNET_ATS_Session *session, const struct GNUNET_TRANSPORT_SessionInfo *info)
Function called by the plugin with information about the current sessions managed by the plugin (for ...
struct GNUNET_SERVER_MessageStreamTokenizer * wlan_header_payload_tokenizer
Tokenizer for demultiplexing of data packets that follow the WLAN Header.
static int result
Global testing status.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
static GNUNET_NETWORK_STRUCT_END const struct GNUNET_TRANSPORT_WLAN_MacAddress mac_bssid_gnunet
GNUnet bssid.
struct MacEndpoint * mac_tail
Tail of list of open connections.
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_TIME_Absolute session_timeout
At what time will this session timeout (unless activity happens)?
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...
#define GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER
Type of data messages from the plugin to the gnunet-wlan-helper.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
static char * plugin
Solver plugin name as string.
#define GNUNET_htole16(x)
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 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.
static void send_ack(void *cls, uint32_t msg_id, const struct GNUNET_MessageHeader *hdr)
Send an ACK for a fragment we received.
Defragmentation context (one per connection).
static void free_macendpoint(struct MacEndpoint *endpoint)
Free a MAC endpoint.
uint16_t tx_power
Desired transmission power for this MAC.
struct FragmentMessage * prev
This is a doubly-linked list.
struct PendingMessage * prev
This is a doubly-linked list.
Struct for messages that are being fragmented in a MAC's transmission queue.
uint16_t frame_control
802.11 Frame Control field.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_MESSAGE_TYPE_WLAN_DATA
Type of messages for data over the wlan.
static unsigned int size
Size of the "table".
struct MacEndpoint * mac
MAC endpoint with the address of this peer.
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.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
static void fragmentmessage_timeout(void *cls)
A FragmentMessage has timed out.
struct GNUNET_TIME_Absolute timeout
Timeout value for the message.
struct GNUNET_MQ_Envelope * env
struct GNUNET_ATS_Session * sessions_tail
Tail of sessions that use this MAC.
void(* GNUNET_TRANSPORT_TransmitContinuation)(void *cls, const struct GNUNET_PeerIdentity *target, int result, size_t size_payload, size_t size_on_wire)
Function called by the GNUNET_TRANSPORT_TransmitFunction upon "completion".
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void * LIBGNUNET_PLUGIN_TRANSPORT_DONE(void *cls)
Exit point from the plugin.
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run on timeout.
struct GNUNET_MessageHeader header
Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER'.
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
struct GNUNET_PeerIdentity peer
For which peer is this an address?
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init(uint32_t bytes_per_second)
Create a new bandwidth value.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
uint8_t rate
wlan send rate
struct WlanAddress wlan_addr
peer MAC address
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.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
struct GNUNET_DEFRAGMENT_Context * defrag
Defrag context for this MAC.
struct WlanHeader * msg
The pending message.
struct FragmentMessage * sending_messages_tail
Tail of messages we are currently sending to this MAC.
#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
After how long do we consider a connection to a peer dead if we don't receive messages from the peer...
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
uint16_t sequence_control
802.11 sequence control field; contains fragment number an sequence number (we set this to all zeros)...
GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor
Function that is used to query keepalive factor.
The identity of the host (wraps the signing key of the peer).
No additional information.
uint16_t duration
Microseconds to reserve link (duration), 0 by default.
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.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's...
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
struct GNUNET_TIME_Relative ack_delay
ACK delay for fragmentation context.
#define GNUNET_PACKED
gcc-ism to get packed structs.
size_t size_payload
Size of original message.
#define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC
Maximum number of messages in defragmentation queue per MAC.
struct GNUNET_PeerIdentity target
To whom are we talking to.
generic definitions for IEEE 802.11 frames
unsigned int fragment_messages_out_count
count of messages in the fragment out queue for this mac endpoint
static void macendpoint_timeout(void *cls)
A MAC endpoint is timing out.
An address for communicating with a peer.
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.
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.
The session was created (first call for each session object).
Entry in list of pending tasks.
header for transport plugin and the helper for wlan
List containing all messages that are yet to be send.
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
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 void send_hello_beacon(void *cls)
Task to (periodically) send a HELLO beacon.
struct GNUNET_TIME_Absolute timeout
When should this endpoint time out?
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?
void * cls
Closure to use for callbacks.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer
Function to pretty-print addresses.
int GNUNET_DEFRAGMENT_process_fragment(struct GNUNET_DEFRAGMENT_Context *dc, const struct GNUNET_MessageHeader *msg)
We have received a fragment.
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_TRANSPORT_WLAN_MacAddress addr3
Address 3: BSSID in ad-hoc mode, Destination if station, source if AP.
struct GNUNET_PeerIdentity target
Intended recipient.
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_SCHEDULER_Task * timeout_task
Timeout task.
struct GNUNET_BANDWIDTH_Tracker tracker
Bandwidth tracker to limit global UDP traffic.
#define GNUNET_MESSAGE_TYPE_FRAGMENT
FRAGMENT of a larger message.
static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac
Broadcast MAC.
uint32_t options
Options set for the WLAN, in NBO.
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.
struct GNUNET_MessageHeader * msg
Message we need to fragment and transmit, NULL after the fragmentcontext has been created...
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
GNUNET_TRANSPORT_CheckAddress check_address
Function that will be called to check if a binary address for this plugin is well-formed and correspo...
Information associated with a message.
GNUNET_TRANSPORT_SessionState
Possible states of a session in a plugin.
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).
Message from the plugin to the WLAN helper: send the given message with the given connection paramete...
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).
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,.
void * sic_cls
Closure for sic.
struct GNUNET_SERVER_MessageStreamTokenizer * GNUNET_SERVER_mst_create(GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
uint16_t tx_power
Transmit power expressed as unitless distance from max power set at factory calibration.
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 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.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_ATS_Session * session
NULL if the identity of the other peer is not known.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
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.
#define WLAN_MTU
Max size of packet (that we give to the WLAN driver for transmission)
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.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.