(no commit message)
[oweals/gnunet.git] / src / transport / gnunet-transport-wlan-helper.c
index 47bea007efaca19983ce3ef5a70566448451ec98..7556e66639b6ee292201fdf4e3f11bcd398a4e42 100644 (file)
 /**
  * @file src/transport/gnunet-wlan.c
  * @brief wlan layer two server; must run as root (SUID will do)
- *        This code will work under GNU/Linux only.  
+ *        This code will work under GNU/Linux only.
  * @author David Brodski
  *
  * This program serves as the mediator between the wlan interface and
- * gnunet 
+ * gnunet
  */
 #include "gnunet-transport-wlan-helper.h"
-#include <pcap/pcap.h>
+#include "plugin_transport_wlan.h"
+#include "ieee80211_radiotap.h"
 
-//#include "radiotap.h"
+#include <pcap.h>
 
-// broadcast mac
-static const char macbc[] = "13223344";
+//#include "radiotap.h"
 
 // mac of this node
-char mac[] = "13223355";
+char mac[] =
+  { 0x13, 0x22, 0x33, 0x44, 0x55, 0x66 };
 
 /* wifi bitrate to use in 500kHz units */
 
@@ -56,31 +56,6 @@ static const u8 u8aRatesToUse[] = {
        1*2
 };
 
-/* Penumbra IEEE80211 header */
-static const u8 u8aIeeeHeader[] = {
-       0x08, 0x01, 0x00, 0x00,
-       0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-       0x13, 0x22, 0x33, 0x44, 0x55, 0x66,
-       0x13, 0x22, 0x33, 0x44, 0x55, 0x66,
-       0x10, 0x86,
-};
-
-/* this is the template radiotap header we send packets out with */
-
-static const u8 u8aRadiotapHeader[] = {
-
-       0x00, 0x00, // <-- radiotap version
-       0x19, 0x00, // <- radiotap header length
-       0x6f, 0x08, 0x00, 0x00, // <-- bitmap
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // <-- timestamp
-       0x00, // <-- flags (Offset +0x10)
-       0x6c, // <-- rate (0ffset +0x11)
-       0x71, 0x09, 0xc0, 0x00, // <-- channel
-       0xde, // <-- antsignal
-       0x00, // <-- antnoise
-       0x01, // <-- antenna
-
-};
 #define        OFFSET_FLAGS 0x10
 #define        OFFSET_RATE 0x11
 
@@ -176,11 +151,11 @@ int flagVerbose = 0;
 
 /**
  * ieee80211_radiotap_iterator_init - radiotap parser iterator initialization
- * @iterator: radiotap_iterator to initialize
- * @radiotap_header: radiotap header to parse
- * @max_length: total length we can parse into (eg, whole packet length)
+ * @param iterator: radiotap_iterator to initialize
+ * @param radiotap_header: radiotap header to parse
+ * @param max_length: total length we can parse into (eg, whole packet length)
  *
- * Returns: 0 or a negative error code if there is a problem.
+ * @return 0 or a negative error code if there is a problem.
  *
  * This function initializes an opaque iterator struct which can then
  * be passed to ieee80211_radiotap_iterator_next() to visit every radiotap
@@ -193,9 +168,9 @@ int flagVerbose = 0;
  * checking for a good 0 return code.  Then loop calling
  * __ieee80211_radiotap_iterator_next()... it returns either 0,
  * -ENOENT if there are no more args to parse, or -EINVAL if there is a problem.
- * The iterator's @this_arg member points to the start of the argument
+ * The iterator's this_arg member points to the start of the argument
  * associated with the current argument index that is present, which can be
- * found in the iterator's @this_arg_index member.  This arg index corresponds
+ * found in the iterator's this_arg_index member.  This arg index corresponds
  * to the IEEE80211_RADIOTAP_... defines.
  *
  * Radiotap header length:
@@ -262,16 +237,16 @@ int ieee80211_radiotap_iterator_init(
 
 /**
  * ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg
- * @iterator: radiotap_iterator to move to next arg (if any)
+ * @param iterator: radiotap_iterator to move to next arg (if any)
  *
- * Returns: 0 if there is an argument to handle,
+ * @return 0 if there is an argument to handle,
  * -ENOENT if there are no more args or -EINVAL
  * if there is something else wrong.
  *
  * This function provides the next radiotap arg index (IEEE80211_RADIOTAP_*)
- * in @this_arg_index and sets @this_arg to point to the
+ * in this_arg_index and sets this_arg to point to the
  * payload for the field.  It takes care of alignment handling and extended
- * present fields.  @this_arg can be changed by the caller (eg,
+ * present fields.  this_arg can be changed by the caller (eg,
  * incremented to move inside a compound argument like
  * IEEE80211_RADIOTAP_CHANNEL).  The args pointed to are in
  * little-endian format whatever the endianess of your CPU.
@@ -554,6 +529,11 @@ main(int argc, char *argv[])
                struct pcap_pkthdr * ppcapPacketHeader = NULL;
                struct ieee80211_radiotap_iterator rti;
                PENUMBRA_RADIOTAP_DATA prd;
+               //init of the values
+               prd.m_nRate = 255;
+               prd.m_nChannel = 255;
+               prd.m_nAntenna = 255;
+               prd.m_nRadiotapFlags = 255;
                u8 * pu8Payload = u8aSendBuffer;
                int n, nRate;
 
@@ -645,7 +625,7 @@ main(int argc, char *argv[])
                memcpy(pu8, u8aIeeeHeader, sizeof (u8aIeeeHeader));
                pu8 += sizeof (u8aIeeeHeader);
 
-               pu8 += sprintf((char *)pu8,
+               pu8 += sprintf((char *)u8aSendBuffer,
                    "Packetspammer %02d"
                    "broadcast packet"
                    "#%05d -- :-D --%s ----",