summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/transport/gnunet-helper-transport-wlan-dummy.c6
-rw-r--r--src/transport/gnunet-helper-transport-wlan.c324
-rw-r--r--src/transport/plugin_transport_wlan.c183
-rw-r--r--src/transport/plugin_transport_wlan.h17
4 files changed, 219 insertions, 311 deletions
diff --git a/src/transport/gnunet-helper-transport-wlan-dummy.c b/src/transport/gnunet-helper-transport-wlan-dummy.c
index c18216b1c..6fff758c5 100644
--- a/src/transport/gnunet-helper-transport-wlan-dummy.c
+++ b/src/transport/gnunet-helper-transport-wlan-dummy.c
@@ -59,12 +59,12 @@ sigfunc (int sig)
* @return number of bytes written
*/
static int
-send_mac_to_plugin (char *buffer, struct MacAddress *mac)
+send_mac_to_plugin (char *buffer, struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
{
struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg;
- memcpy (&macmsg.mac, (char *) mac, sizeof (struct MacAddress));
+ memcpy (&macmsg.mac, (char *) mac, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
macmsg.hdr.size = htons (sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage));
macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL);
@@ -165,7 +165,7 @@ main (int argc, char *argv[])
int retval;
struct GNUNET_SERVER_MessageStreamTokenizer *stdin_mst;
struct GNUNET_SERVER_MessageStreamTokenizer *file_in_mst;
- struct MacAddress macaddr;
+ struct GNUNET_TRANSPORT_WLAN_MacAddress macaddr;
if (2 != argc)
{
diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c
index 25b94677f..582df7cf5 100644
--- a/src/transport/gnunet-helper-transport-wlan.c
+++ b/src/transport/gnunet-helper-transport-wlan.c
@@ -19,6 +19,16 @@
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
+/**
+ * @file src/transport/gnunet-helper-transport-wlan.c
+ * @brief wlan layer two server; must run as root (SUID will do)
+ * This code will work under GNU/Linux only.
+ * @author David Brodski
+ *
+ * This program serves as the mediator between the wlan interface and
+ * gnunet
+ */
+
/*-
* we use our local copy of ieee80211_radiotap.h
*
@@ -62,16 +72,6 @@
*/
/**
- * @file src/transport/gnunet-helper-transport-wlan.c
- * @brief wlan layer two server; must run as root (SUID will do)
- * This code will work under GNU/Linux only.
- * @author David Brodski
- *
- * This program serves as the mediator between the wlan interface and
- * gnunet
- */
-
-/**
* parts taken from aircrack-ng, parts changend.
*/
#define _GNU_SOURCE
@@ -111,8 +111,12 @@
*/
#define IEEE80211_ADDR_LEN 6
+/**
+ * Maximum size of a message allowed in either direction.
+ */
#define MAXLINE 4096
+
#define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK 0x80000000
@@ -309,25 +313,68 @@ struct ieee80211_radiotap_header
uint32_t it_present;
};
+/**
+ *
+ */
struct RadioTapheader
{
+ /**
+ *
+ */
struct ieee80211_radiotap_header header;
+
+ /**
+ *
+ */
uint8_t rate;
+
+ /**
+ *
+ */
uint8_t pad1;
+
+ /**
+ *
+ */
uint16_t txflags;
};
/**
- * FIXME.
+ * IO buffer used for buffering data in transit (to wireless or to stdout).
*/
struct SendBuffer
{
- unsigned int pos;
- unsigned int size;
+ /**
+ * How many bytes of data are stored in 'buf' for transmission right now?
+ * Data always starts at offset 0 and extends to 'size'.
+ */
+ size_t size;
+
+ /**
+ * How many bytes that were stored in 'buf' did we already write to the
+ * destination? Always smaller than 'size'.
+ */
+ size_t pos;
+
+ /**
+ * Buffered data; twice the maximum allowed message size as we add some
+ * headers.
+ */
char buf[MAXLINE * 2];
};
+/**
+ * Buffer for data read from stdin to be transmitted to the wirless card.
+ */
+static struct SendBuffer write_pout;
+
+/**
+ * Buffer for data read from the wireless card to be transmitted to stdout.
+ */
+static struct SendBuffer write_std;
+
+
GNUNET_NETWORK_STRUCT_BEGIN
/**
@@ -346,6 +393,7 @@ struct ieee80211_frame
} GNUNET_PACKED;
GNUNET_NETWORK_STRUCT_END
+
/**
* struct for storing the information of the hardware
*/
@@ -353,15 +401,14 @@ struct HardwareInfos
{
/**
- * send buffer
- */
- struct SendBuffer write_pout;
-
- /**
* file descriptor for the raw socket
*/
int fd_raw;
+ /**
+ * Which format has the header that we're getting when receiving packets?
+ * Some ARPHRD_IEEE80211_XXX-value.
+ */
int arptype_in;
/**
@@ -369,39 +416,16 @@ struct HardwareInfos
*/
char iface[IFNAMSIZ];
- struct MacAddress pl_mac;
+ /**
+ * MAC address of our own WLAN interface.
+ */
+ struct GNUNET_TRANSPORT_WLAN_MacAddress pl_mac;
};
-
-
- /* *INDENT-OFF* */
-#define ___my_swab16(x) \
-((u_int16_t)( \
- (((u_int16_t)(x) & (u_int16_t)0x00ffU) << 8) | \
- (((u_int16_t)(x) & (u_int16_t)0xff00U) >> 8) ))
-
-#define ___my_swab32(x) \
-((u_int32_t)( \
- (((u_int32_t)(x) & (u_int32_t)0x000000ffUL) << 24) | \
- (((u_int32_t)(x) & (u_int32_t)0x0000ff00UL) << 8) | \
- (((u_int32_t)(x) & (u_int32_t)0x00ff0000UL) >> 8) | \
- (((u_int32_t)(x) & (u_int32_t)0xff000000UL) >> 24) ))
-#define ___my_swab64(x) \
-((u_int64_t)( \
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000000000ffULL) << 56) | \
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000000000ff00ULL) << 40) | \
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000000000ff0000ULL) << 24) | \
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000ff000000ULL) << 8) | \
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000ff00000000ULL) >> 8) | \
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000ff0000000000ULL) >> 24) | \
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00ff000000000000ULL) >> 40) | \
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0xff00000000000000ULL) >> 56) ))
- /* *INDENT-ON* */
-
-
/**
- * struct ieee80211_radiotap_iterator - tracks walk through present radiotap args
+ * struct ieee80211_radiotap_iterator - tracks walk through present radiotap arguments
+ * in the radiotap header.
*/
struct ieee80211_radiotap_iterator
{
@@ -922,25 +946,6 @@ next_entry:
/**
- * function to create GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL message for plugin
- * @param buffer pointer to buffer for the message
- * @param mac pointer to the mac address
- * @return number of bytes written
- */
-static int
-send_mac_to_plugin (char *buffer, struct MacAddress *mac)
-{
- struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg;
-
- memcpy (&macmsg.mac, (char *) mac, sizeof (struct MacAddress));
- macmsg.hdr.size = htons (sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage));
- macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL);
- memcpy (buffer, &macmsg, sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage));
- return sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage);
-}
-
-
-/**
* Return the channel from the frequency (in Mhz)
* @param frequency of the channel
* @return number of the channel
@@ -960,6 +965,7 @@ get_channel_from_frequency (int frequency)
/**
* function to calculate the crc, the start of the calculation
+ *
* @param buf buffer to calc the crc
* @param len len of the buffer
* @return crc sum
@@ -1043,10 +1049,12 @@ calc_crc_osdep (const unsigned char *buf, size_t len)
/**
- * Function to check crc of the wlan packet
- * @param buf buffer of the packet
- * @param len len of the data
- * @return crc sum of the data
+ * Function to calculate and check crc of the wlan packet
+ *
+ * @param buf buffer of the packet, with len + 4 bytes of data,
+ * the last 4 bytes being the checksum
+ * @param len length of the payload in data
+ * @return 0 on success (checksum matches), 1 on error
*/
static int
check_crc_buf_osdep (const unsigned char *buf, size_t len)
@@ -1055,15 +1063,18 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len)
crc = calc_crc_osdep (buf, len);
buf += len;
- return (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] &&
- ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]);
+ if (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] &&
+ ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3])
+ return 0;
+ return 1;
}
/**
- * function to get the channel of a specific wlan card
+ * Get the channel used by our WLAN interface.
+ *
* @param dev pointer to the dev struct of the card
- * @return channel number
+ * @return channel number, -1 on error
*/
static int
linux_get_channel (const struct HardwareInfos *dev)
@@ -1272,7 +1283,7 @@ linux_read (struct HardwareInfos *dev, unsigned char *buf, size_t buf_size,
caplen -= n;
//detect fcs at the end, even if the flag wasn't set and remove it
- if ((0 == fcs_removed) && (1 == check_crc_buf_osdep (tmpbuf + n, caplen - 4)))
+ if ((0 == fcs_removed) && (0 == check_crc_buf_osdep (tmpbuf + n, caplen - 4)))
{
caplen -= 4;
}
@@ -1285,7 +1296,8 @@ linux_read (struct HardwareInfos *dev, unsigned char *buf, size_t buf_size,
/**
- * function to open the device for read/write
+ * Open the wireless network interface for reading/writing.
+ *
* @param dev pointer to the device struct
* @return 0 on success
*/
@@ -1398,26 +1410,19 @@ open_device_raw (struct HardwareInfos *dev)
/**
- * function to prepare the helper, e.g. sockets, device...
- * @param dev struct for the device
+ * Test if the given interface name really corresponds to a wireless
+ * device.
+ *
* @param iface name of the interface
- * @return 0 on success
+ * @return 0 on success, 1 on error
*/
static int
-wlan_initialize (struct HardwareInfos *dev, const char *iface)
+test_wlan_interface (const char *iface)
{
char strbuf[512];
struct stat sbuf;
int ret;
- if (dev->fd_raw >= FD_SETSIZE)
- {
- fprintf (stderr, "File descriptor too large for select (%d > %d)\n",
- dev->fd_raw, FD_SETSIZE);
- close (dev->fd_raw);
- return 1;
- }
-
/* mac80211 stack detection */
ret =
snprintf (strbuf, sizeof (strbuf), "/sys/class/net/%s/phy80211/subsystem",
@@ -1425,13 +1430,6 @@ wlan_initialize (struct HardwareInfos *dev, const char *iface)
if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf)))
{
fprintf (stderr, "Did not find 802.11 interface `%s'. Exiting.\n", iface);
- close (dev->fd_raw);
- return 1;
- }
- strncpy (dev->iface, iface, IFNAMSIZ);
- if (0 != open_device_raw (dev))
- {
- close (dev->fd_raw);
return 1;
}
return 0;
@@ -1484,7 +1482,6 @@ static void
stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr)
{
struct HardwareInfos *dev = cls;
- struct SendBuffer *write_pout = &dev->write_pout;
struct Radiotap_Send *header = (struct Radiotap_Send *) &hdr[1];
struct ieee80211_frame *wlanheader;
size_t sendsize;
@@ -1521,56 +1518,61 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr)
rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader));
rtheader.rate = header->rate;
- memcpy (write_pout->buf, &rtheader, sizeof (rtheader));
- memcpy (write_pout->buf + sizeof (rtheader), &header[1], sendsize);
+ memcpy (write_pout.buf, &rtheader, sizeof (rtheader));
+ memcpy (write_pout.buf + sizeof (rtheader), &header[1], sendsize);
/* payload contains MAC address, but we don't trust it, so we'll
* overwrite it with OUR MAC address again to prevent mischief */
- wlanheader = (struct ieee80211_frame *) (write_pout->buf + sizeof (rtheader));
+ wlanheader = (struct ieee80211_frame *) (write_pout.buf + sizeof (rtheader));
mac_set (wlanheader, dev);
- write_pout->size = sendsize + sizeof (rtheader);
+ write_pout.size = sendsize + sizeof (rtheader);
}
/**
- * main function of the helper
- * @param argc number of arguments
- * @param argv arguments
- * @return 0 on success, 1 on error
+ * Main function of the helper. This code accesses a WLAN interface
+ * in monitoring mode (layer 2) and then forwards traffic in both
+ * directions between the WLAN interface and stdin/stdout of this
+ * process. Error messages are written to stdout.
+ *
+ * @param argc number of arguments, must be 2
+ * @param argv arguments only argument is the name of the interface (i.e. 'mon0')
+ * @return 0 on success (never happens, as we don't return unless aborted), 1 on error
*/
int
main (int argc, char *argv[])
{
- uid_t uid;
struct HardwareInfos dev;
char readbuf[MAXLINE];
- struct SendBuffer write_std;
- ssize_t ret;
int maxfd;
fd_set rfds;
fd_set wfds;
- int retval;
int stdin_open;
struct MessageStreamTokenizer *stdin_mst;
int raw_eno;
+ memset (&dev, 0, sizeof (dev));
dev.fd_raw = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL));
raw_eno = errno; /* remember for later */
- uid = getuid ();
-#ifdef HAVE_SETRESUID
- if (0 != setresuid (uid, uid, uid))
+
+ /* drop privs */
{
- fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno));
- if (-1 != dev.fd_raw)
- (void) close (dev.fd_raw);
- return 1;
- }
+ uid_t uid = getuid ();
+#ifdef HAVE_SETRESUID
+ if (0 != setresuid (uid, uid, uid))
+ {
+ fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno));
+ if (-1 != dev.fd_raw)
+ (void) close (dev.fd_raw);
+ return 1;
+ }
#else
- if (0 != (setuid (uid) | seteuid (uid)))
- {
- fprintf (stderr, "Failed to setuid: %s\n", strerror (errno));
- if (-1 != dev.fd_raw)
- (void) close (dev.fd_raw);
- return 1;
+ if (0 != (setuid (uid) | seteuid (uid)))
+ {
+ fprintf (stderr, "Failed to setuid: %s\n", strerror (errno));
+ if (-1 != dev.fd_raw)
+ (void) close (dev.fd_raw);
+ return 1;
+ }
}
#endif
@@ -1589,22 +1591,43 @@ main (int argc, char *argv[])
fprintf (stderr, "Failed to create raw socket: %s\n", strerror (raw_eno));
return 1;
}
- if (0 != wlan_initialize (&dev, argv[1]))
+ if (dev.fd_raw >= FD_SETSIZE)
+ {
+ fprintf (stderr, "File descriptor too large for select (%d > %d)\n",
+ dev.fd_raw, FD_SETSIZE);
+ (void) close (dev.fd_raw);
return 1;
- dev.write_pout.size = 0;
- dev.write_pout.pos = 0;
- stdin_mst = mst_create (&stdin_send_hw, &dev);
+ }
+ if (0 != test_wlan_interface (argv[1]))
+ {
+ (void) close (dev.fd_raw);
+ return 1;
+ }
+ strncpy (dev.iface, argv[1], IFNAMSIZ);
+ if (0 != open_device_raw (&dev))
+ {
+ (void) close (dev.fd_raw);
+ return 1;
+ }
- /* send mac to STDOUT first */
- write_std.pos = 0;
- write_std.size = send_mac_to_plugin ((char *) &write_std.buf, &dev.pl_mac);
- stdin_open = 1;
+ /* send MAC address of the WLAN interface to STDOUT first */
+ {
+ struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg;
+
+ macmsg.hdr.size = htons (sizeof (macmsg));
+ macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL);
+ memcpy (&macmsg.mac, &dev.pl_mac, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
+ memcpy (write_std.buf, &macmsg, sizeof (macmsg));
+ write_std.size = sizeof (macmsg);
+ }
+ stdin_mst = mst_create (&stdin_send_hw, &dev);
+ stdin_open = 1;
while (1)
{
maxfd = -1;
FD_ZERO (&rfds);
- if ((0 == dev.write_pout.size) && (1 == stdin_open))
+ if ((0 == write_pout.size) && (1 == stdin_open))
{
FD_SET (STDIN_FILENO, &rfds);
maxfd = MAX (maxfd, STDIN_FILENO);
@@ -1620,22 +1643,24 @@ main (int argc, char *argv[])
FD_SET (STDOUT_FILENO, &wfds);
maxfd = MAX (maxfd, STDOUT_FILENO);
}
- if (0 < dev.write_pout.size)
+ if (0 < write_pout.size)
{
FD_SET (dev.fd_raw, &wfds);
maxfd = MAX (maxfd, dev.fd_raw);
}
- retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL);
- if ((-1 == retval) && (EINTR == errno))
- continue;
- if (0 > retval)
{
- fprintf (stderr, "select failed: %s\n", strerror (errno));
- break;
+ int retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL);
+ if ((-1 == retval) && (EINTR == errno))
+ continue;
+ if (0 > retval)
+ {
+ fprintf (stderr, "select failed: %s\n", strerror (errno));
+ break;
+ }
}
if (FD_ISSET (STDOUT_FILENO, &wfds))
{
- ret =
+ ssize_t ret =
write (STDOUT_FILENO, write_std.buf + write_std.pos,
write_std.size - write_std.pos);
if (0 > ret)
@@ -1652,31 +1677,35 @@ main (int argc, char *argv[])
}
if (FD_ISSET (dev.fd_raw, &wfds))
{
- ret = write (dev.fd_raw, dev.write_pout.buf, dev.write_pout.size);
+ ssize_t ret =
+ write (dev.fd_raw, write_pout.buf + write_std.pos,
+ write_pout.size - write_pout.pos);
if (0 > ret)
{
fprintf (stderr, "Failed to write to WLAN device: %s\n",
strerror (errno));
break;
}
- dev.write_pout.pos += ret;
- if ((dev.write_pout.pos != dev.write_pout.size) && (ret != 0))
+ write_pout.pos += ret;
+ if ((write_pout.pos != write_pout.size) && (0 != ret))
{
/* we should not get partial sends with packet-oriented devices... */
fprintf (stderr, "Write error, partial send: %u/%u\n",
- dev.write_pout.pos, dev.write_pout.size);
+ (unsigned int) write_pout.pos,
+ (unsigned int) write_pout.size);
break;
}
- if (dev.write_pout.pos == dev.write_pout.size)
+ if (write_pout.pos == write_pout.size)
{
- dev.write_pout.pos = 0;
- dev.write_pout.size = 0;
+ write_pout.pos = 0;
+ write_pout.size = 0;
}
}
if (FD_ISSET (STDIN_FILENO, &rfds))
{
- ret = read (STDIN_FILENO, readbuf, sizeof (readbuf));
+ ssize_t ret =
+ read (STDIN_FILENO, readbuf, sizeof (readbuf));
if (0 > ret)
{
fprintf (stderr, "Read error from STDIN: %s\n", strerror (errno));
@@ -1695,6 +1724,7 @@ main (int argc, char *argv[])
struct GNUNET_MessageHeader *header;
struct Radiotap_rx *rxinfo;
struct ieee80211_frame *datastart;
+ ssize_t ret;
header = (struct GNUNET_MessageHeader *) write_std.buf;
rxinfo = (struct Radiotap_rx *) &header[1];
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 4510ae12c..08f9c5833 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -39,7 +39,11 @@
#include "gnunet_fragmentation_lib.h"
#include "gnunet_constants.h"
-#include <string.h>
+/**
+ * DEBUG switch
+ */
+#define DEBUG_WLAN GNUNET_EXTRA_LOGGING
+
#define PROTOCOL_PREFIX "wlan"
@@ -100,15 +104,6 @@
#define WLAN_LLC_SSAP_FIELD 0x1f
-/**
- * DEBUG switch
- */
-#define DEBUG_wlan GNUNET_EXTRA_LOGGING
-#define DEBUG_wlan_retransmission GNUNET_EXTRA_LOGGING
-#define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO
-#define DEBUG_wlan_msg_dump GNUNET_EXTRA_LOGGING
-
-
#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
#define IEEE80211_FC0_VERSION_MASK 0x03
@@ -225,7 +220,7 @@ struct Plugin
/**
* The mac_address of the wlan card given to us by the helper.
*/
- struct MacAddress mac_address;
+ struct GNUNET_TRANSPORT_WLAN_MacAddress mac_address;
/**
* Sessions currently pending for transmission
@@ -488,7 +483,7 @@ struct Session_light
/**
* peer mac address
*/
- struct MacAddress addr;
+ struct GNUNET_TRANSPORT_WLAN_MacAddress addr;
/**
* mac endpoint
@@ -595,7 +590,7 @@ struct MacEndpoint
/**
* peer mac address
*/
- struct MacAddress addr;
+ struct GNUNET_TRANSPORT_WLAN_MacAddress addr;
/**
* Defrag context for this mac endpoint
@@ -704,7 +699,7 @@ free_session (struct Plugin *plugin, struct Sessionqueue *queue,
int do_free_macendpoint);
static struct MacEndpoint *
-create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr);
+create_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr);
static void
finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
@@ -771,7 +766,7 @@ hexdump (const void *mem, unsigned length)
* @return
*/
static struct MacEndpoint *
-get_macendpoint (struct Plugin *plugin, const struct MacAddress *addr,
+get_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr,
int create_new)
{
struct MacEndpoint *queue = plugin->mac_head;
@@ -779,7 +774,7 @@ get_macendpoint (struct Plugin *plugin, const struct MacAddress *addr,
while (queue != NULL)
{
//GNUNET_assert (queue->sessions_head != NULL);
- if (memcmp (addr, &queue->addr, sizeof (struct MacAddress)) == 0)
+ if (memcmp (addr, &queue->addr, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)
return queue; /* session found */
queue = queue->next;
}
@@ -837,9 +832,9 @@ static const char *
wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
{
static char ret[40];
- const struct MacAddress *mac;
+ const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac;
- if (addrlen != sizeof (struct MacAddress))
+ if (addrlen != sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))
{
GNUNET_break (0);
return NULL;
@@ -916,14 +911,11 @@ create_session (struct Plugin *plugin, struct MacEndpoint *endpoint,
queue->content->timeout_task =
GNUNET_SCHEDULER_add_delayed (SESSION_TIMEOUT, &session_timeout, queue);
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"New session %p with endpoint %p: %s\n", queue->content,
endpoint, wlan_plugin_address_to_string (NULL,
endpoint->addr.mac,
6));
-#endif
-
return queue->content;
}
@@ -936,7 +928,7 @@ create_session (struct Plugin *plugin, struct MacEndpoint *endpoint,
* @return returns the session
*/
static struct Session *
-get_session (struct Plugin *plugin, const struct MacAddress *addr,
+get_session (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr,
const struct GNUNET_PeerIdentity *peer)
{
struct MacEndpoint *mac;
@@ -1090,11 +1082,8 @@ set_next_send (struct Plugin *const plugin)
next_send = GNUNET_TIME_absolute_get_remaining (plugin->beacon_time);
}
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Next packet is send in: %u\n", next_send.rel_value);
-#endif
-
if (next_send.rel_value == GNUNET_TIME_UNIT_ZERO.rel_value)
{
if (plugin->server_write_task == GNUNET_SCHEDULER_NO_TASK)
@@ -1140,11 +1129,9 @@ get_next_queue_session (struct Plugin *plugin)
if (pm == NULL)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
"pending message is empty, should not happen. session %p\n",
session);
-#endif
sessionqueue_alt = sessionqueue;
sessionqueue = sessionqueue->next;
plugin->pendingsessions--;
@@ -1257,11 +1244,9 @@ free_fragment_message (struct Plugin *plugin, struct FragmentMessage *fm)
GNUNET_free (fm);
queue_session (plugin, session);
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Free pending fragment messages %p, session %p\n", fm,
session);
-#endif
}
/**
@@ -1302,7 +1287,7 @@ getRadiotapHeader (struct Plugin *plugin, struct MacEndpoint *endpoint,
*/
static int
getWlanHeader (struct ieee80211_frame *Header,
- const struct MacAddress *to_mac_addr, struct Plugin *plugin,
+ const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, struct Plugin *plugin,
unsigned int size)
{
uint16_t *tmp16;
@@ -1313,7 +1298,7 @@ getWlanHeader (struct ieee80211_frame *Header,
memcpy (&Header->i_addr3, &mac_bssid_gnunet, sizeof (mac_bssid_gnunet));
memcpy (&Header->i_addr2, plugin->mac_address.mac,
sizeof (plugin->mac_address));
- memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct MacAddress));
+ memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
tmp16 = (uint16_t *) Header->i_dur;
*tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290);
@@ -1344,12 +1329,9 @@ add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr)
struct GNUNET_MessageHeader *msgheader2;
uint16_t size;
-#if DEBUG_wlan_retransmission > 1
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Adding fragment of message %p to send, session %p, endpoint %p, type %u\n",
fm, fm->session, endpoint, hdr->type);
-#endif
-
size =
sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) +
sizeof (struct ieee80211_frame) + ntohs (hdr->size);
@@ -1401,12 +1383,10 @@ wlan_plugin_helper_read (void *cls,
sizeof (mybuf));
if (bytes <= 0)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
_
("Finished reading from gnunet-helper-transport-wlan stdout with code: %d\n"),
bytes);
-#endif
return;
}
GNUNET_SERVER_mst_receive (plugin->suid_tokenizer, NULL, mybuf, bytes,
@@ -1434,10 +1414,8 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
if (plugin->helper_is_running == GNUNET_YES)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"wlan_transport_start_wlan_helper not needed, helper already running!");
-#endif
return GNUNET_YES;
}
@@ -1478,12 +1456,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
if (plugin->testmode == 0)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Starting gnunet-helper-transport-wlan process cmd: %s %s %i\n",
filenamehw, plugin->interface, plugin->testmode);
-#endif
-
if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_YES)
{
plugin->server_proc =
@@ -1508,11 +1483,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
else if (plugin->testmode == 1)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
"Starting gnunet-helper-transport-wlan-dummy loopback 1 process cmd: %s %s %i\n",
absolute_filename, plugin->interface, plugin->testmode);
-#endif
plugin->server_proc =
GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
absolute_filename, absolute_filename, "1",
@@ -1527,12 +1500,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
}
else if (plugin->testmode == 2)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
"Starting gnunet-helper-transport-wlan-dummy loopback 2 process cmd: %s %s %i\n",
absolute_filename, plugin->interface, plugin->testmode);
-#endif
-
plugin->server_proc =
GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
absolute_filename, absolute_filename, "2",
@@ -1549,10 +1519,8 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
GNUNET_free (absolute_filename);
if (plugin->server_proc == NULL)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Failed to start gnunet-helper-transport-wlan process\n");
-#endif
return GNUNET_SYSERR;
}
@@ -1574,11 +1542,8 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
GNUNET_assert (plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK);
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Adding server_read_task for the gnunet-helper-transport-wlan\n");
-#endif
-
plugin->server_read_task =
GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
plugin->server_stdout_handle,
@@ -1597,17 +1562,13 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
static int
wlan_transport_stop_wlan_helper (struct Plugin *plugin)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Stoping WLAN helper process\n");
-#endif
if (plugin->helper_is_running == GNUNET_NO)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"wlan_transport_stop_wlan_helper not needed, helper already stopped!");
-#endif
return GNUNET_YES;
}
@@ -1753,12 +1714,6 @@ finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
send_hello_beacon (struct Plugin *plugin)
{
-
-#if DEBUG_wlan
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "Sending hello beacon\n");
-#endif
-
uint16_t size;
ssize_t bytes;
uint16_t hello_size;
@@ -1769,6 +1724,9 @@ send_hello_beacon (struct Plugin *plugin)
const struct GNUNET_MessageHeader *hello;
struct Finish_send *finish;
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
+ "Sending hello beacon\n");
+
GNUNET_assert (plugin != NULL);
GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"),
@@ -1874,12 +1832,9 @@ add_ack_for_send (void *cls, uint32_t msg_id,
GNUNET_CONTAINER_DLL_insert_tail (plugin->ack_send_queue_head,
plugin->ack_send_queue_tail, ack);
-#if DEBUG_wlan_retransmission > 1
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Adding ack with message id %u to send, AckSendQueue %p, endpoint %p\n",
msg_id, ack, endpoint);
-#endif
-
set_next_send (plugin);
}
@@ -1955,17 +1910,13 @@ check_fragment_queue (struct Plugin *plugin)
{
pid = session->target;
pm->transmit_cont (pm->transmit_cont_cls, &pid, GNUNET_OK);
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"called pm->transmit_cont for %p\n", session);
-#endif
}
else
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"no pm->transmit_cont for %p\n", session);
-#endif
}
GNUNET_free (pm);
@@ -1995,15 +1946,10 @@ send_ack (struct Plugin *plugin)
struct Finish_send *finish;
ack = plugin->ack_send_queue_head;
-
-
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Sending ack for message_id %u for mac endpoint %p, size %u\n",
ack->message_id, ack->endpoint,
ntohs (ack->hdr->size) - sizeof (struct Radiotap_Send));
-#endif
-
GNUNET_assert (plugin != NULL);
GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1,
GNUNET_NO);
@@ -2087,13 +2033,9 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
session = fm->session;
GNUNET_assert (session != NULL);
-
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Sending GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT for fragment message %p, size: %u\n",
fm, fm->size);
-#endif
-
getRadiotapHeader (plugin, session->mac, fm->radioHeader);
getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin,
fm->size);
@@ -2176,18 +2118,14 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
if (addrlen == 6)
{
/* TODO check for bad addresses like multicast, broadcast, etc */
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"wlan_plugin_address_suggested got good address, size %u!\n",
addrlen);
-#endif
return GNUNET_OK;
}
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"wlan_plugin_address_suggested got bad address, size %u!\n",
addrlen);
-#endif
return GNUNET_SYSERR;
}
@@ -2311,12 +2249,10 @@ wlan_plugin_send (void *cls,
GNUNET_CONTAINER_DLL_insert_tail (session->pending_message_head,
session->pending_message_tail, newmsg);
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"New message for %p with size (incl wlan header) %u added\n",
session, newmsg->message_size);
-#endif
-#if DEBUG_wlan_msg_dump > 1
+#if DEBUG_WLAN > 1
hexdump (msgbuf, GNUNET_MIN (msgbuf_size, 256));
#endif
//queue session
@@ -2519,15 +2455,13 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type,
const unsigned char *input;
//GNUNET_assert(cls !=NULL);
- if (addrlen != sizeof (struct MacAddress))
+ if (addrlen != sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress))
{
/* invalid address (MAC addresses have 6 bytes) */
//GNUNET_break (0);
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Func wlan_plugin_address_pretty_printer got size: %u, worng size!\n",
addrlen);
-#endif
asc (asc_cls, NULL);
return;
}
@@ -2536,11 +2470,9 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type,
"Transport %s: %s Mac-Address %.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
type, PROTOCOL_PREFIX, input[0], input[1], input[2],
input[3], input[4], input[5]);
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Func wlan_plugin_address_pretty_printer got size: %u, nummeric %u, type %s; made string: %s\n",
addrlen, numeric, type, ret);
-#endif
asc (asc_cls, ret);
//only one mac address per plugin
asc (asc_cls, NULL);
@@ -2570,11 +2502,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
if (ntohs (hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_DATA)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Func wlan_data_message_handler got GNUNET_MESSAGE_TYPE_WLAN_DATA size: %u\n",
ntohs (hdr->size));
-#endif
if (ntohs (hdr->size) <
sizeof (struct WlanHeader) + sizeof (struct GNUNET_MessageHeader))
@@ -2609,12 +2539,10 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
//if not in session list
if (session == NULL)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"WLAN client not in session list: packet size = %u, inner size = %u, header size = %u\n",
ntohs (wlanheader->header.size), ntohs (temp_hdr->size),
sizeof (struct WlanHeader));
-#endif
//try if it is a hello message
if (ntohs (wlanheader->header.size) >=
ntohs (temp_hdr->size) + sizeof (struct WlanHeader))
@@ -2659,11 +2587,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
sizeof (struct GNUNET_PeerIdentity)) != 0)
{
//wrong peer id
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"WLAN peer source id doesn't match packet peer source id: session %p\n",
session);
-#endif
return;
}
@@ -2672,11 +2598,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
sizeof (struct GNUNET_PeerIdentity)) != 0)
{
//wrong peer id
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"WLAN peer target id doesn't match our peer id: session %p\n",
session);
-#endif
return;
}
@@ -2718,15 +2642,12 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
ats[1].value = htonl (GNUNET_ATS_NET_WLAN);
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Calling plugin->env->receive for session %p; %s; size: %u\n",
session, wlan_plugin_address_to_string (NULL,
session->mac->
addr.mac, 6),
htons (hdr->size));
-#endif
-
plugin->env->receive (plugin->env->cls, &(session->target), hdr,
(const struct GNUNET_ATS_Information *) &ats, 2,
session, (const char *) &session->mac->addr,
@@ -2761,14 +2682,11 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
//TODO test first than create session
GNUNET_assert (session_light != NULL);
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Func wlan_data_helper got GNUNET_MESSAGE_TYPE_HELLO size: %u; %s\n",
ntohs (hdr->size), wlan_plugin_address_to_string (NULL,
session_light->addr.
mac, 6));
-#endif
-
if (session_light->macendpoint == NULL)
{
session_light->macendpoint =
@@ -2814,15 +2732,12 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
get_macendpoint (plugin, &session_light->addr, GNUNET_YES);
}
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT with size: %u; mac endpoint %p: %s\n",
ntohs (hdr->size), session_light->macendpoint,
wlan_plugin_address_to_string (NULL,
session_light->addr.mac,
6));
-#endif
-
GNUNET_STATISTICS_update (plugin->env->stats,
_("# wlan fragments received"), 1, GNUNET_NO);
int ret =
@@ -2854,24 +2769,20 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
if (session_light->macendpoint == NULL)
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n",
ntohs (hdr->size), wlan_plugin_address_to_string (NULL,
session_light->addr.mac,
6));
-#endif
return;
}
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; mac endpoint: %p; %s\n",
ntohs (hdr->size), session_light->macendpoint,
wlan_plugin_address_to_string (NULL,
session_light->addr.mac,
6));
-#endif
fm = session_light->macendpoint->sending_messages_head;
while (fm != NULL)
{
@@ -2882,10 +2793,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
if (ret == GNUNET_OK)
{
-#if DEBUG_wlan_retransmission > 1
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Got last ack, finished fragment message %p\n", fm);
-#endif
session_light->macendpoint->acks++;
fm->session->last_activity = GNUNET_TIME_absolute_get ();
session_light->macendpoint->last_activity = fm->session->last_activity;
@@ -2895,10 +2804,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
}
if (ret == GNUNET_NO)
{
-#if DEBUG_wlan_retransmission > 1
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Got ack for: %p\n", fm);
-#endif
session_light->macendpoint->acks++;
return;
}
@@ -2910,10 +2817,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
fm = fm2;
}
-#if DEBUG_wlan_retransmission > 1
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"WLAN fragment not in fragment list\n");
-#endif
return;
}
@@ -2934,7 +2839,6 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
}
-#if DEBUG_wlan
/**
* Function to print mac addresses nice *
* @param pointer to 6 byte with the mac address
@@ -2949,7 +2853,6 @@ macprinter (const u_int8_t * mac)
mac[2], mac[3], mac[4], mac[5]);
return macstr;
}
-#endif
/**
* Function for the scheduler if a mac endpoint times out
@@ -2991,7 +2894,7 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
* @return returns a macendpoint
*/
static struct MacEndpoint *
-create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr)
+create_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr)
{
struct MacEndpoint *newend = GNUNET_malloc (sizeof (struct MacEndpoint));
@@ -3016,11 +2919,9 @@ create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr)
GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan mac endpoints"),
plugin->mac_count, GNUNET_NO);
GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend);
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"New Mac Endpoint %p: %s\n", newend,
wlan_plugin_address_to_string (NULL, newend->addr.mac, 6));
-#endif
return newend;
}
@@ -3048,12 +2949,9 @@ wlan_process_helper (void *cls, void *client,
switch (ntohs (hdr->type))
{
case GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA:
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Func wlan_process_helper got GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA size: %u\n",
ntohs (hdr->size));
-#endif
-
GNUNET_STATISTICS_update (plugin->env->stats,
_("# wlan WLAN_HELPER_DATA received"), 1,
GNUNET_NO);
@@ -3062,13 +2960,11 @@ wlan_process_helper (void *cls, void *client,
sizeof (struct ieee80211_frame) +
2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx))
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Size of packet is too small; size: %u min size: %u\n",
ntohs (hdr->size),
sizeof (struct ieee80211_frame) +
sizeof (struct GNUNET_MessageHeader));
-#endif
//GNUNET_break (0);
/* FIXME: restart SUID process */
return;
@@ -3082,20 +2978,20 @@ wlan_process_helper (void *cls, void *client,
//check for bssid
if (memcmp
(&(wlanIeeeHeader->i_addr3), &mac_bssid_gnunet,
- sizeof (struct MacAddress)) == 0)
+ sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)
{
//check for broadcast or mac
if ((memcmp
(&(wlanIeeeHeader->i_addr1), &bc_all_mac,
- sizeof (struct MacAddress)) == 0) ||
+ sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) ||
(memcmp
(&(wlanIeeeHeader->i_addr1), &(plugin->mac_address),
- sizeof (struct MacAddress)) == 0))
+ sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0))
{
//if packet is from us return
if ((memcmp
(&(wlanIeeeHeader->i_addr2), &(plugin->mac_address),
- sizeof (struct MacAddress)) == 0))
+ sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0))
{
return;
}
@@ -3108,7 +3004,7 @@ wlan_process_helper (void *cls, void *client,
session_light = GNUNET_malloc (sizeof (struct Session_light));
memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2),
- sizeof (struct MacAddress));
+ sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
//session_light->session = search_session(plugin,session_light->addr);
GNUNET_STATISTICS_update (plugin->env->stats,
_("# wlan messages for this client received"),
@@ -3128,11 +3024,9 @@ wlan_process_helper (void *cls, void *client,
}
else
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Size of packet is too small; size: %u > size of packet: %u\n",
ntohs (temp_hdr->size), datasize + pos);
-#endif
}
pos += ntohs (temp_hdr->size);
@@ -3143,20 +3037,16 @@ wlan_process_helper (void *cls, void *client,
}
else
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Func wlan_process_helper got wrong MAC: %s\n",
macprinter (wlanIeeeHeader->i_addr1));
-#endif
}
}
else
{
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Func wlan_process_helper got wrong BSSID: %s\n",
macprinter (wlanIeeeHeader->i_addr2));
-#endif
}
break;
case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL:
@@ -3167,26 +3057,21 @@ wlan_process_helper (void *cls, void *client,
/* FIXME: restart SUID process */
return;
}
- memcpy (&plugin->mac_address, &hdr[1], sizeof (struct MacAddress));
-#if DEBUG_wlan
+ memcpy (&plugin->mac_address, &hdr[1], sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Received WLAN_HELPER_CONTROL message with transport of address %s\n",
wlan_plugin_address_to_string (cls, &plugin->mac_address,
- sizeof (struct
- MacAddress)));
-#endif
+ sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)));
plugin->env->notify_address (plugin->env->cls, GNUNET_YES,
&plugin->mac_address,
- sizeof (struct MacAddress));
+ sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
break;
default:
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"Func wlan_process_helper got unknown message with number %u, size %u\n",
ntohs (hdr->type), ntohs (hdr->size));
-#endif
-#if DEBUG_wlan_msg_dump > 1
+#if DEBUG_WLAN > 1
hexdump (hdr, GNUNET_MIN (ntohs (hdr->size), 256));
#endif
GNUNET_break (0);
@@ -3208,11 +3093,8 @@ libgnunet_plugin_transport_wlan_done (void *cls)
struct MacEndpoint *endpoint = plugin->mac_head;
struct MacEndpoint *endpoint_next;
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"libgnunet_plugin_transport_wlan_done started\n");
-#endif
-
wlan_transport_stop_wlan_helper (plugin);
GNUNET_assert (cls != NULL);
@@ -3311,11 +3193,8 @@ libgnunet_plugin_transport_wlan_init (void *cls)
wlan_transport_start_wlan_helper (plugin);
set_next_beacon_time (plugin);
set_next_send (plugin);
-#if DEBUG_wlan
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
"wlan init finished\n");
-#endif
-
return api;
}
diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h
index b0b8b966a..9e1bc4f22 100644
--- a/src/transport/plugin_transport_wlan.h
+++ b/src/transport/plugin_transport_wlan.h
@@ -34,38 +34,37 @@
*/
#define MAC_ADDR_SIZE 6
+GNUNET_NETWORK_STRUCT_BEGIN
/**
* A MAC Address.
*/
-struct MacAddress
+struct GNUNET_TRANSPORT_WLAN_MacAddress
{
uint8_t mac[MAC_ADDR_SIZE];
};
-
-GNUNET_NETWORK_STRUCT_BEGIN
-
/**
* Format of a WLAN Control Message.
*/
struct GNUNET_TRANSPORT_WLAN_HelperControlMessage
{
/**
- * Message header. FIXME: type?
+ * Message header. Type is
+ * GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL
*/
struct GNUNET_MessageHeader hdr;
/**
- * MAC Address. FIXME: of what?
+ * MAC Address of the local WLAN interface.
*/
- struct MacAddress mac;
+ struct GNUNET_TRANSPORT_WLAN_MacAddress mac;
};
GNUNET_NETWORK_STRUCT_END
/**
* GNUnet bssid
*/
-static const struct MacAddress mac_bssid_gnunet = {
+static const struct GNUNET_TRANSPORT_WLAN_MacAddress mac_bssid_gnunet = {
{0x13, 0x22, 0x33, 0x44, 0x55, 0x66}
};
@@ -73,7 +72,7 @@ static const struct MacAddress mac_bssid_gnunet = {
/**
* Broadcast MAC
*/
-static const struct MacAddress bc_all_mac = {
+static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac = {
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
};