#define IEEE80211_FC0_TYPE_CTL 0x04
#define IEEE80211_FC0_TYPE_DATA 0x08
+GNUNET_NETWORK_STRUCT_BEGIN
+
/*
* generic definitions for IEEE 802.11 frames
*/
u_int8_t i_seq[2];
u_int8_t llc[4];
} GNUNET_PACKED;
+GNUNET_NETWORK_STRUCT_END
/**
* Encapsulation of all of the state of the plugin.
};
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Header for messages which need fragmentation
*/
// followed by payload
};
-
+GNUNET_NETWORK_STRUCT_END
/**
* Information kept for each message that is yet to
else
t += sprintf (t, " ");
- t += sprintf (t, j % 2 ? " " : "-");
+ t += sprintf (t, (j % 2) ? " " : "-");
}
t += sprintf (t, " ");
return GNUNET_YES;
}
- plugin->server_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES);
+ plugin->server_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES);
if (plugin->server_stdout == NULL)
return GNUNET_SYSERR;
- plugin->server_stdin = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO);
+ plugin->server_stdin = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_YES, GNUNET_NO);
if (plugin->server_stdin == NULL)
return GNUNET_SYSERR;
if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_YES)
{
plugin->server_proc =
- GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+ GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
filenamehw, filenamehw, plugin->interface,
NULL);
}
absolute_filename, plugin->interface, plugin->testmode);
#endif
plugin->server_proc =
- GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+ GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
absolute_filename, absolute_filename, "1",
NULL);
if (plugin->server_proc == NULL)
#endif
plugin->server_proc =
- GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+ GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
absolute_filename, absolute_filename, "2",
NULL);
if (plugin->server_proc == NULL)
return GNUNET_SYSERR;
}
+
+/**
+ * Creates a new outbound session the transport service will use to send data to the
+ * peer
+ *
+ * @param cls the plugin
+ * @param address the address
+ * @return the session or NULL of max connections exceeded
+ */
+
+static struct Session *
+wlan_plugin_get_session (void *cls,
+ const struct GNUNET_HELLO_Address *address)
+{
+ struct Plugin *plugin = cls;
+ struct Session * s = NULL;
+
+ GNUNET_assert (plugin != NULL);
+ GNUNET_assert (address != NULL);
+
+ if (GNUNET_OK == wlan_plugin_address_suggested (plugin,
+ address->address,
+ address->address_length))
+ {
+ s = get_session (plugin, address->address, &address->peer);
+ }
+ else
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
+ _("Wlan Address len %d is wrong\n"), address->address_length);
+ return s;
+ }
+
+ return s;
+}
+
/**
* Function that can be used by the transport service to transmit
- * a message using the plugin.
+ * 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.
*
* @param cls closure
- * @param target who should receive this message
- * @param priority how important is the message
+ * @param session which session must be used
* @param msgbuf the message to transmit
* @param msgbuf_size number of bytes in 'msgbuf'
- * @param timeout when should we time out
- * @param session which session must be used (or NULL for "any")
- * @param addr the address to use (can be NULL if the plugin
- * is "on its own" (i.e. re-use existing TCP connection))
- * @param addrlen length of the address in bytes
- * @param force_address GNUNET_YES if the plugin MUST use the given address,
- * otherwise the plugin may use other addresses or
- * existing connections (if available)
+ * @param priority how important is the message (most plugins will
+ * ignore message priority and just FIFO)
+ * @param to how 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)
* @param cont continuation to call once the message has
* been transmitted (or if the transport is ready
* for the next transmission call; or if the
- * peer disconnected...)
+ * peer disconnected...); can be NULL
* @param cont_cls closure for cont
* @return 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)
*/
static ssize_t
-wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
- const char *msgbuf, size_t msgbuf_size, unsigned int priority,
- struct GNUNET_TIME_Relative timeout, struct Session *session,
- const void *addr, size_t addrlen, int force_address,
+wlan_plugin_send (void *cls,
+ struct Session *session,
+ const char *msgbuf, size_t msgbuf_size,
+ unsigned int priority,
+ struct GNUNET_TIME_Relative to,
GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
{
struct Plugin *plugin = cls;
struct WlanHeader *wlanheader;
GNUNET_assert (plugin != NULL);
- //check if msglen > 0
+ GNUNET_assert (session != NULL);
GNUNET_assert (msgbuf_size > 0);
- //get session if needed
- if (session == NULL)
- {
- if (wlan_plugin_address_suggested (plugin, addr, addrlen) == GNUNET_OK)
- {
- session = get_session (plugin, addr, target);
- }
- else
- {
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
- _("Wlan Address len %d is wrong\n"), addrlen);
- return -1;
- }
- }
-
- GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan messages queued"), 1,
- GNUNET_NO);
-
//queue message:
//queue message in session
//copy msg to buffer, not fragmented / segmented yet, but with message header
wlanheader->header.size = htons (msgbuf_size + sizeof (struct WlanHeader));
wlanheader->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA);
- memcpy (&(wlanheader->target), target, sizeof (struct GNUNET_PeerIdentity));
+ memcpy (&(wlanheader->target), &session->target, sizeof (struct GNUNET_PeerIdentity));
memcpy (&(wlanheader->source), plugin->env->my_identity,
sizeof (struct GNUNET_PeerIdentity));
wlanheader->crc = 0;
newmsg->transmit_cont = cont;
newmsg->transmit_cont_cls = cont_cls;
- newmsg->timeout = GNUNET_TIME_relative_to_absolute (timeout);
+ newmsg->timeout = GNUNET_TIME_relative_to_absolute (to);
newmsg->timeout.abs_value = newmsg->timeout.abs_value - 500;
check_fragment_queue (plugin);
//FIXME not the correct size
return msgbuf_size;
-
}
+
/**
* function to free a mac endpoint
* @param plugin pointer to the plugin struct
api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
api->cls = plugin;
api->send = &wlan_plugin_send;
+ api->get_session = &wlan_plugin_get_session;
api->disconnect = &wlan_plugin_disconnect;
api->address_pretty_printer = &wlan_plugin_address_pretty_printer;
api->check_address = &wlan_plugin_address_suggested;