[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16777 - in gnunet/src/transport: . wlan
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16777 - in gnunet/src/transport: . wlan |
Date: |
Tue, 13 Sep 2011 08:59:17 +0200 |
Author: brodski
Date: 2011-09-13 08:59:16 +0200 (Tue, 13 Sep 2011)
New Revision: 16777
Modified:
gnunet/src/transport/gnunet-transport-wlan-helper.c
gnunet/src/transport/gnunet-transport-wlan-helper.h
gnunet/src/transport/plugin_transport_wlan.c
gnunet/src/transport/test_plugin_transport_wlan_dummy.c
gnunet/src/transport/wlan/helper_common.c
gnunet/src/transport/wlan/helper_common.h
gnunet/src/transport/wlan/loopback_helper.h
Log:
Big cleanup, less source files
Modified: gnunet/src/transport/gnunet-transport-wlan-helper.c
===================================================================
--- gnunet/src/transport/gnunet-transport-wlan-helper.c 2011-09-13 03:02:18 UTC
(rev 16776)
+++ gnunet/src/transport/gnunet-transport-wlan-helper.c 2011-09-13 06:59:16 UTC
(rev 16777)
@@ -80,19 +80,72 @@
*/
#include "wlan/ieee80211_radiotap.h"
#include "wlan/crctable_osdep.h"
-#include "wlan/loopback_helper.h"
-#include "wlan/ieee80211.h"
+//#include "wlan/loopback_helper.h"
+//#include "wlan/ieee80211.h"
+#include "wlan/helper_common.h"
#define ARPHRD_IEEE80211 801
#define ARPHRD_IEEE80211_PRISM 802
#define ARPHRD_IEEE80211_FULL 803
-#include "wlan/loopback_helper.h"
-
#define DEBUG 1
#define MAC_ADDR_SIZE 6
+//Part taken from file ieee80211.h
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.12 2006/12/01 18:40:51 imp Exp $
+ */
+
+#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
+
+/*
+ * generic definitions for IEEE 802.11 frames
+ */
+struct ieee80211_frame
+{
+ u_int8_t i_fc[2];
+ u_int8_t i_dur[2];
+ u_int8_t i_addr1[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr2[IEEE80211_ADDR_LEN];
+ u_int8_t i_addr3[IEEE80211_ADDR_LEN];
+ u_int8_t i_seq[2];
+ /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
+ /* see below */
+} GNUNET_PACKED;
+
+// End taken part
+
struct Hardware_Infos
{
@@ -107,6 +160,14 @@
unsigned char pl_mac[MAC_ADDR_SIZE];
};
+struct RadioTapheader
+{
+ struct ieee80211_radiotap_header header;
+ u8 rate;
+ u8 pad1;
+ u16 txflags;
+};
+
// FIXME: inline?
int
getChannelFromFrequency (int frequency);
@@ -126,6 +187,7 @@
/* CRC checksum verification routine */
// FIXME: make nice...
+// fixme doxigen
static int
check_crc_buf_osdep (unsigned char *buf, int len)
{
@@ -142,6 +204,7 @@
// FIXME: make nice...
+//fixme doxigen
static int
linux_get_channel (struct Hardware_Infos *dev)
{
@@ -173,6 +236,7 @@
// FIXME: make nice...
+//FIXME doxigen
static ssize_t
linux_read (struct Hardware_Infos *dev, unsigned char *buf, /* FIXME:
void*? */
size_t buf_size, struct Radiotap_rx *ri)
@@ -356,7 +420,7 @@
return caplen;
}
-
+//FIXME doxigen
/**
* @return 0 on success
*/
@@ -551,14 +615,7 @@
}
-struct RadioTapheader
-{
- struct ieee80211_radiotap_header header;
- u8 rate;
- u8 pad1;
- u16 txflags;
-};
-
+//FIXME: doxigen
static void
stdin_send_hw (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
{
@@ -590,7 +647,7 @@
if (sendsize <
sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader))
{
- fprintf (stderr, "Function stdin_send_hw: mailformed packet (too
small)\n");
+ fprintf (stderr, "Function stdin_send_hw: malformed packet (too small)\n");
exit (1);
}
sendsize -=
@@ -705,19 +762,21 @@
* @return number of bytes written
*/
// FIXME: use 'struct MacAddress' for 'mac' (everywhere in this file)
+/*
static int
-send_mac_to_plugin (char *buffer, uint8_t * mac)
+send_mac_to_plugin (char *buffer, struct MacAddress * mac)
{
struct Wlan_Helper_Control_Message macmsg;
macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message));
macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL);
- memcpy (macmsg.mac.mac, mac, sizeof (struct MacAddress));
+ memcpy (macmsg.mac, mac, sizeof (struct MacAddress));
memcpy (buffer, &macmsg, sizeof (struct Wlan_Helper_Control_Message));
return sizeof (struct Wlan_Helper_Control_Message);
}
+*/
-
+//FIXME: doxigen
static int
hardwaremode (int argc, char *argv[])
{
@@ -892,3 +951,79 @@
}
return hardwaremode (argc, argv);
}
+
+/*
+ * Copyright (c) 2008, Thomas d'Otreppe
+ *
+ * Common OSdep stuff
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/**
+ * Return the frequency in Mhz from a channel number
+ */
+int
+getFrequencyFromChannel (int channel)
+{
+ static int frequencies[] = {
+ -1, // No channel 0
+ 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467,
+ 2472, 2484,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, // Nothing from channel 15 to 34 (exclusive)
+ 5170, 5175, 5180, 5185, 5190, 5195, 5200, 5205, 5210, 5215, 5220, 5225,
+ 5230, 5235, 5240, 5245,
+ 5250, 5255, 5260, 5265, 5270, 5275, 5280, 5285, 5290, 5295, 5300, 5305,
+ 5310, 5315, 5320, 5325,
+ 5330, 5335, 5340, 5345, 5350, 5355, 5360, 5365, 5370, 5375, 5380, 5385,
+ 5390, 5395, 5400, 5405,
+ 5410, 5415, 5420, 5425, 5430, 5435, 5440, 5445, 5450, 5455, 5460, 5465,
+ 5470, 5475, 5480, 5485,
+ 5490, 5495, 5500, 5505, 5510, 5515, 5520, 5525, 5530, 5535, 5540, 5545,
+ 5550, 5555, 5560, 5565,
+ 5570, 5575, 5580, 5585, 5590, 5595, 5600, 5605, 5610, 5615, 5620, 5625,
+ 5630, 5635, 5640, 5645,
+ 5650, 5655, 5660, 5665, 5670, 5675, 5680, 5685, 5690, 5695, 5700, 5705,
+ 5710, 5715, 5720, 5725,
+ 5730, 5735, 5740, 5745, 5750, 5755, 5760, 5765, 5770, 5775, 5780, 5785,
+ 5790, 5795, 5800, 5805,
+ 5810, 5815, 5820, 5825, 5830, 5835, 5840, 5845, 5850, 5855, 5860, 5865,
+ 5870, 5875, 5880, 5885,
+ 5890, 5895, 5900, 5905, 5910, 5915, 5920, 5925, 5930, 5935, 5940, 5945,
+ 5950, 5955, 5960, 5965,
+ 5970, 5975, 5980, 5985, 5990, 5995, 6000, 6005, 6010, 6015, 6020, 6025,
+ 6030, 6035, 6040, 6045,
+ 6050, 6055, 6060, 6065, 6070, 6075, 6080, 6085, 6090, 6095, 6100
+ };
+
+ return (channel > 0 && channel <= 221) ? frequencies[channel] : -1;
+}
+
+/**
+ * Return the channel from the frequency (in Mhz)
+ */
+int
+getChannelFromFrequency (int frequency)
+{
+ if (frequency >= 2412 && frequency <= 2472)
+ return (frequency - 2407) / 5;
+ else if (frequency == 2484)
+ return 14;
+ else if (frequency >= 5000 && frequency <= 6100)
+ return (frequency - 5000) / 5;
+ else
+ return -1;
+}
+
Modified: gnunet/src/transport/gnunet-transport-wlan-helper.h
===================================================================
--- gnunet/src/transport/gnunet-transport-wlan-helper.h 2011-09-13 03:02:18 UTC
(rev 16776)
+++ gnunet/src/transport/gnunet-transport-wlan-helper.h 2011-09-13 06:59:16 UTC
(rev 16777)
@@ -57,18 +57,4 @@
*/
#define unlikely(x) (x)
-#define FIFO_FILE1 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_in"
-#define FIFO_FILE2 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_out"
-#define MAXLINE 4096
-
-extern int closeprog;
-
-struct sendbuf
-{
- unsigned int pos;
- unsigned int size;
- char buf[MAXLINE * 2];
-};
-
-
#endif /* gnunet_wlan_H */
Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c 2011-09-13 03:02:18 UTC
(rev 16776)
+++ gnunet/src/transport/plugin_transport_wlan.c 2011-09-13 06:59:16 UTC
(rev 16777)
@@ -24,6 +24,8 @@
* @author David Brodski
*/
+//TODO split rx and tx structures for better handling
+
#include "platform.h"
#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
@@ -91,7 +93,7 @@
/**
* DEBUG switch
*/
-#define DEBUG_wlan GNUNET_NO
+#define DEBUG_wlan GNUNET_YES
#define DEBUG_wlan_retransmission GNUNET_NO
#define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO
@@ -756,7 +758,7 @@
}
/**
- * search for a session with the addr and peer id
+ * search for a session with the address and peer id
*
* @param plugin pointer to the plugin struct
* @param addr pointer to the mac address of the peer
@@ -2281,8 +2283,9 @@
* Function used for to process the data received from the wlan interface
*
* @param cls the plugin handle
- * @param session_light FIXME: document
+ * @param session_light pointer to the struct holding known informations
* @param hdr hdr of the GNUNET_MessageHeader
+ * @param rxinfo pointer to the radiotap informations got with this packet
*/
static void
wlan_data_helper (void *cls, struct Session_light *session_light,
@@ -2448,7 +2451,11 @@
}
-//TODO DOXIGEN
+/**
+ * Function to print mac addresses nice *
+ * @param pointer to 6 byte with the mac address
+ * @return pointer to the chars which hold the print out
+ */
const char *
macprinter (const u_int8_t * mac)
{
@@ -2652,6 +2659,12 @@
sizeof (struct 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
GNUNET_break (0);
return;
}
Modified: gnunet/src/transport/test_plugin_transport_wlan_dummy.c
===================================================================
--- gnunet/src/transport/test_plugin_transport_wlan_dummy.c 2011-09-13
03:02:18 UTC (rev 16776)
+++ gnunet/src/transport/test_plugin_transport_wlan_dummy.c 2011-09-13
06:59:16 UTC (rev 16777)
@@ -47,7 +47,7 @@
#include "gnunet_util_lib.h"
#include "plugin_transport_wlan.h"
#include "gnunet_common.h"
-#include "gnunet-transport-wlan-helper.h"
+//#include "gnunet-transport-wlan-helper.h"
#include "gnunet_crypto_lib.h"
#include "wlan/loopback_helper.h"
#include "wlan/helper_common.h"
@@ -160,16 +160,16 @@
//unlink(FIFO_FILE1);
//unlink(FIFO_FILE2);
// FIXME: use mkfifo!
- erg = mknod (FIFO_FILE1, S_IFIFO | 0666, 0);
+ erg = mkfifo (FIFO_FILE1, 0666);
if (0 != erg)
{
- fprintf (stderr, "Error at mknode1 \n");
+ fprintf (stderr, "Error at mkfifo1: %s\n", strerror(errno));
//exit(1);
}
- erg = mknod (FIFO_FILE2, S_IFIFO | 0666, 0);
+ erg = mkfifo (FIFO_FILE2, 0666);
if (0 != erg)
{
- fprintf (stderr, "Error at mknode2 \n");
+ fprintf (stderr, "Error at mkfifo2: %s\n", strerror(errno));
//exit(1);
}
Modified: gnunet/src/transport/wlan/helper_common.c
===================================================================
--- gnunet/src/transport/wlan/helper_common.c 2011-09-13 03:02:18 UTC (rev
16776)
+++ gnunet/src/transport/wlan/helper_common.c 2011-09-13 06:59:16 UTC (rev
16777)
@@ -34,90 +34,15 @@
* @return number of bytes written
*/
int
-send_mac_to_plugin (char *buffer, uint8_t * mac)
+send_mac_to_plugin (char *buffer, struct MacAddress * mac)
{
struct Wlan_Helper_Control_Message macmsg;
- memcpy (macmsg.mac.mac, mac, sizeof (struct MacAddress));
+ memcpy (&macmsg.mac,(char *) mac, sizeof (struct MacAddress));
macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message));
macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL);
memcpy (buffer, &macmsg, sizeof (struct Wlan_Helper_Control_Message));
return sizeof (struct Wlan_Helper_Control_Message);
}
-
-/*
- * Copyright (c) 2008, Thomas d'Otreppe
- *
- * Common OSdep stuff
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/**
- * Return the frequency in Mhz from a channel number
- */
-int
-getFrequencyFromChannel (int channel)
-{
- static int frequencies[] = {
- -1, // No channel 0
- 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467,
- 2472, 2484,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, // Nothing from channel 15 to 34 (exclusive)
- 5170, 5175, 5180, 5185, 5190, 5195, 5200, 5205, 5210, 5215, 5220, 5225,
- 5230, 5235, 5240, 5245,
- 5250, 5255, 5260, 5265, 5270, 5275, 5280, 5285, 5290, 5295, 5300, 5305,
- 5310, 5315, 5320, 5325,
- 5330, 5335, 5340, 5345, 5350, 5355, 5360, 5365, 5370, 5375, 5380, 5385,
- 5390, 5395, 5400, 5405,
- 5410, 5415, 5420, 5425, 5430, 5435, 5440, 5445, 5450, 5455, 5460, 5465,
- 5470, 5475, 5480, 5485,
- 5490, 5495, 5500, 5505, 5510, 5515, 5520, 5525, 5530, 5535, 5540, 5545,
- 5550, 5555, 5560, 5565,
- 5570, 5575, 5580, 5585, 5590, 5595, 5600, 5605, 5610, 5615, 5620, 5625,
- 5630, 5635, 5640, 5645,
- 5650, 5655, 5660, 5665, 5670, 5675, 5680, 5685, 5690, 5695, 5700, 5705,
- 5710, 5715, 5720, 5725,
- 5730, 5735, 5740, 5745, 5750, 5755, 5760, 5765, 5770, 5775, 5780, 5785,
- 5790, 5795, 5800, 5805,
- 5810, 5815, 5820, 5825, 5830, 5835, 5840, 5845, 5850, 5855, 5860, 5865,
- 5870, 5875, 5880, 5885,
- 5890, 5895, 5900, 5905, 5910, 5915, 5920, 5925, 5930, 5935, 5940, 5945,
- 5950, 5955, 5960, 5965,
- 5970, 5975, 5980, 5985, 5990, 5995, 6000, 6005, 6010, 6015, 6020, 6025,
- 6030, 6035, 6040, 6045,
- 6050, 6055, 6060, 6065, 6070, 6075, 6080, 6085, 6090, 6095, 6100
- };
-
- return (channel > 0 && channel <= 221) ? frequencies[channel] : -1;
-}
-
-/**
- * Return the channel from the frequency (in Mhz)
- */
-int
-getChannelFromFrequency (int frequency)
-{
- if (frequency >= 2412 && frequency <= 2472)
- return (frequency - 2407) / 5;
- else if (frequency == 2484)
- return 14;
- else if (frequency >= 5000 && frequency <= 6100)
- return (frequency - 5000) / 5;
- else
- return -1;
-}
Modified: gnunet/src/transport/wlan/helper_common.h
===================================================================
--- gnunet/src/transport/wlan/helper_common.h 2011-09-13 03:02:18 UTC (rev
16776)
+++ gnunet/src/transport/wlan/helper_common.h 2011-09-13 06:59:16 UTC (rev
16777)
@@ -9,10 +9,16 @@
#define HELPER_COMMON_H_
int
-getFrequencyFromChannel (int channel);
-int
-getChannelFromFrequency (int frequency);
-int
send_mac_to_plugin (char *buffer, uint8_t * mac);
+
+#define MAXLINE 4096
+
+struct sendbuf
+{
+ unsigned int pos;
+ unsigned int size;
+ char buf[MAXLINE * 2];
+};
+
#endif /* HELPER_COMMON_H_ */
Modified: gnunet/src/transport/wlan/loopback_helper.h
===================================================================
--- gnunet/src/transport/wlan/loopback_helper.h 2011-09-13 03:02:18 UTC (rev
16776)
+++ gnunet/src/transport/wlan/loopback_helper.h 2011-09-13 06:59:16 UTC (rev
16777)
@@ -17,4 +17,10 @@
int
testmode (int argc, char *argv[]);
+
+#define FIFO_FILE1 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_in"
+#define FIFO_FILE2 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_out"
+
+extern int closeprog;
+
#endif /* LOOPBACK_HELPER_H_ */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16777 - in gnunet/src/transport: . wlan,
gnunet <=