gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r18555 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r18555 - gnunet/src/transport
Date: Sun, 11 Dec 2011 16:31:47 +0100

Author: grothoff
Date: 2011-12-11 16:31:47 +0100 (Sun, 11 Dec 2011)
New Revision: 18555

Added:
   gnunet/src/transport/gnunet-transport-wlan-sender.c
Removed:
   gnunet/src/transport/gnunet_wlan_sender.c
Modified:
   gnunet/src/transport/Makefile.am
   gnunet/src/transport/gnunet-transport-wlan-helper-dummy.c
   gnunet/src/transport/gnunet-transport-wlan-helper.c
   gnunet/src/transport/plugin_transport_wlan.c
   gnunet/src/transport/plugin_transport_wlan.h
Log:
-more minor cleanup

Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am    2011-12-11 15:10:48 UTC (rev 18554)
+++ gnunet/src/transport/Makefile.am    2011-12-11 15:31:47 UTC (rev 18555)
@@ -35,7 +35,7 @@
 if LINUX
  WLAN_BIN = gnunet-transport-wlan-helper
  WLAN_BIN_DUMMY = gnunet-transport-wlan-helper-dummy
- WLAN_BIN_SENDER = gnunet_wlan_sender
+ WLAN_BIN_SENDER = gnunet-transport-wlan-sender
  WLAN_PLUGIN_LA = libgnunet_plugin_transport_wlan.la
  WLAN_API_TEST = test_transport_api_wlan
  WLAN_REL_TEST = test_transport_api_reliability_wlan
@@ -115,9 +115,9 @@
 gnunet_transport_wlan_helper_dummy_LDADD = \
   $(top_builddir)/src/util/libgnunetutil.la 
 
-gnunet_wlan_sender_SOURCES = \
- gnunet_wlan_sender.c
-gnunet_wlan_sender_LDADD = \
+gnunet_transport_wlan_sender_SOURCES = \
+ gnunet-transport-wlan-sender.c
+gnunet_transport_wlan_sender_LDADD = \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 gnunet_transport_SOURCES = \

Modified: gnunet/src/transport/gnunet-transport-wlan-helper-dummy.c
===================================================================
--- gnunet/src/transport/gnunet-transport-wlan-helper-dummy.c   2011-12-11 
15:10:48 UTC (rev 18554)
+++ gnunet/src/transport/gnunet-transport-wlan-helper-dummy.c   2011-12-11 
15:31:47 UTC (rev 18555)
@@ -62,14 +62,14 @@
 send_mac_to_plugin (char *buffer, struct MacAddress *mac)
 {
 
-  struct Wlan_Helper_Control_Message macmsg;
+  struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg;
 
   memcpy (&macmsg.mac, (char *) mac, sizeof (struct MacAddress));
-  macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message));
+  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 Wlan_Helper_Control_Message));
-  return sizeof (struct Wlan_Helper_Control_Message);
+  memcpy (buffer, &macmsg, sizeof (struct 
GNUNET_TRANSPORT_WLAN_HelperControlMessage));
+  return sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage);
 }
 
 static void

Modified: gnunet/src/transport/gnunet-transport-wlan-helper.c
===================================================================
--- gnunet/src/transport/gnunet-transport-wlan-helper.c 2011-12-11 15:10:48 UTC 
(rev 18554)
+++ gnunet/src/transport/gnunet-transport-wlan-helper.c 2011-12-11 15:31:47 UTC 
(rev 18555)
@@ -352,9 +352,10 @@
 {
 
   /**
-  * send buffer
-  */
+   * send buffer
+   */
   struct SendBuffer write_pout;
+
   /**
    * file descriptor for the raw socket
    */
@@ -928,13 +929,13 @@
 static int
 send_mac_to_plugin (char *buffer, struct MacAddress *mac)
 {
-  struct Wlan_Helper_Control_Message macmsg;
+  struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg;
 
   memcpy (&macmsg.mac, (char *) mac, sizeof (struct MacAddress));
-  macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message));
+  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 Wlan_Helper_Control_Message));
-  return sizeof (struct Wlan_Helper_Control_Message);
+  memcpy (buffer, &macmsg, sizeof (struct 
GNUNET_TRANSPORT_WLAN_HelperControlMessage));
+  return sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage);
 }
 
 
@@ -1078,7 +1079,7 @@
   strncpy (wrq.ifr_name, dev->iface, IFNAMSIZ);
   fd = dev->fd_raw;
   if (0 > ioctl (fd, SIOCGIWFREQ, &wrq))
-    return (-1);
+    return -1;
 
   frequency = wrq.u.freq.m;
   if (100000000 < frequency)
@@ -1151,8 +1152,8 @@
       n = *(int *) (tmpbuf + 4);
     }
 
-    if (n < 8 || n >= caplen)
-      return (0);
+    if ( (n < 8) || (n >= caplen) )
+      return 0;
   }
     break;
 
@@ -1164,7 +1165,7 @@
     rthdr = (struct ieee80211_radiotap_header *) tmpbuf;
 
     if (ieee80211_radiotap_iterator_init (&iterator, rthdr, caplen) < 0)
-      return (0);
+      return 0;
 
     /* go through the radiotap arguments we have been given
      * by the driver
@@ -1456,7 +1457,7 @@
 mac_test (const struct ieee80211_frame *uint8_taIeeeHeader,
           const struct HardwareInfos *dev)
 {
-  if (0 != memcmp (uint8_taIeeeHeader->i_addr3, &mac_bssid, MAC_ADDR_SIZE))
+  if (0 != memcmp (uint8_taIeeeHeader->i_addr3, &mac_bssid_gnunet, 
MAC_ADDR_SIZE))
     return 1;
   if (0 == memcmp (uint8_taIeeeHeader->i_addr1, &dev->pl_mac, MAC_ADDR_SIZE))
     return 0;
@@ -1478,7 +1479,7 @@
   uint8_taIeeeHeader->i_fc[0] = 0x08;
   uint8_taIeeeHeader->i_fc[1] = 0x00;
   memcpy (uint8_taIeeeHeader->i_addr2, &dev->pl_mac, MAC_ADDR_SIZE);
-  memcpy (uint8_taIeeeHeader->i_addr3, &mac_bssid, MAC_ADDR_SIZE);
+  memcpy (uint8_taIeeeHeader->i_addr3, &mac_bssid_gnunet, MAC_ADDR_SIZE);
 }
 
 

Copied: gnunet/src/transport/gnunet-transport-wlan-sender.c (from rev 18553, 
gnunet/src/transport/gnunet_wlan_sender.c)
===================================================================
--- gnunet/src/transport/gnunet-transport-wlan-sender.c                         
(rev 0)
+++ gnunet/src/transport/gnunet-transport-wlan-sender.c 2011-12-11 15:31:47 UTC 
(rev 18555)
@@ -0,0 +1,236 @@
+/*
+ This file is part of GNUnet
+ (C) 2011 Christian Grothoff (and other contributing authors)
+
+ GNUnet 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 3, or (at your
+ option) any later version.
+
+ GNUnet 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 GNUnet; see the file COPYING.  If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file transport/gnunet-transport-wlan-sender.c
+ * @brief program to send via WLAN as much as possible (to test 
physical/theoretical throughput)
+ * @author David Brodski
+ */
+#include "platform.h"
+#include "gnunet_protocols.h"
+#include "plugin_transport_wlan.h"
+
+#define WLAN_MTU 1500
+
+/**
+ * LLC fields for better compatibility
+ */
+#define WLAN_LLC_DSAP_FIELD 0x1f
+#define WLAN_LLC_SSAP_FIELD 0x1f
+
+#define IEEE80211_ADDR_LEN      6       /* size of 802.11 address */
+
+#define IEEE80211_FC0_VERSION_MASK              0x03
+#define IEEE80211_FC0_VERSION_SHIFT             0
+#define IEEE80211_FC0_VERSION_0                 0x00
+#define IEEE80211_FC0_TYPE_MASK                 0x0c
+#define IEEE80211_FC0_TYPE_SHIFT                2
+#define IEEE80211_FC0_TYPE_MGT                  0x00
+#define IEEE80211_FC0_TYPE_CTL                  0x04
+#define IEEE80211_FC0_TYPE_DATA                 0x08
+
+
+/*
+ * 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];
+  u_int8_t llc[4];
+} GNUNET_PACKED;
+
+
+/**
+ * function to fill the radiotap header
+ * @param header pointer to the radiotap header
+ * @return GNUNET_YES at success
+ */
+static int
+getRadiotapHeader (struct Radiotap_Send *header)
+{
+  header->rate = 255;
+  header->tx_power = 0;
+  header->antenna = 0;
+
+  return GNUNET_YES;
+}
+
+/**
+ * function to generate the wlan hardware header for one packet
+ * @param Header address to write the header to
+ * @param to_mac_addr pointer to the address of the recipient
+ * @param mac pointer to the mac address to send from (normally overwritten 
over by helper)
+ * @param size size of the whole packet, needed to calculate the time to send 
the packet
+ * @return GNUNET_YES if there was no error
+ */
+static int
+getWlanHeader (struct ieee80211_frame *Header, const char *to_mac_addr,
+               const char *mac, unsigned int size)
+{
+  uint16_t *tmp16;
+  const int rate = 11000000;
+
+  Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA;
+  Header->i_fc[1] = 0x00;
+  memcpy (&Header->i_addr3, &mac_bssid_gnunet, sizeof (mac_bssid_gnunet));
+  memcpy (&Header->i_addr2, mac, sizeof (mac_bssid_gnunet));
+  memcpy (&Header->i_addr1, to_mac_addr, sizeof (mac_bssid_gnunet));
+
+  tmp16 = (uint16_t *) Header->i_dur;
+  *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290);
+  Header->llc[0] = WLAN_LLC_DSAP_FIELD;
+  Header->llc[1] = WLAN_LLC_SSAP_FIELD;
+
+  return GNUNET_YES;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  char msg_buf[WLAN_MTU];
+  struct GNUNET_MessageHeader *msg;
+  struct ieee80211_frame *wlan_header;
+  struct Radiotap_Send *radiotap;
+
+  unsigned int temp[6];
+  char inmac[6];
+  char outmac[6];
+  int pos;
+  long long count;
+  double bytes_per_s;
+  time_t start;
+  time_t akt;
+  int i;
+
+  if (4 != argc)
+  {
+    fprintf (stderr,
+             "This program must be started with the interface and the targets 
and source mac as argument.\n");
+    fprintf (stderr,
+             "Usage: interface-name mac-target mac-source\n"
+             "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
+    return 1;
+  }
+  if (6 !=
+      sscanf (argv[3], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2],
+              &temp[3], &temp[4], &temp[5]))
+  {
+    fprintf (stderr,
+             "Usage: interface-name mac-target mac-source\n"
+             "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
+    return 1;
+  }
+  if (6 !=
+      sscanf (argv[2], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2],
+              &temp[3], &temp[4], &temp[5]))
+  {
+    fprintf (stderr,
+             "Usage: interface-name mac-target mac-source\n"
+             "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
+    return 1;
+  }
+  for (i = 0; i < 6; i++)
+    inmac[i] = temp[i];
+  for (i = 0; i < 6; i++)
+    outmac[i] = temp[i];
+
+  pid_t pid;
+  int commpipe[2];              /* This holds the fd for the input & output of 
the pipe */
+
+  /* Setup communication pipeline first */
+  if (pipe (commpipe))
+  {
+    fprintf (stderr, 
+            "Failed to create pipe: %s\n",
+            STRERROR (errno));
+    exit (1);
+  }
+
+  /* Attempt to fork and check for errors */
+  if ((pid = fork ()) == -1)
+  {
+    fprintf (stderr, "Failed to fork: %s\n", 
+            STRERROR (errno));    
+    exit (1);
+  }
+
+  if (pid)
+  {
+    /* A positive (non-negative) PID indicates the parent process */
+    close (commpipe[0]);        /* Close unused side of pipe (in side) */
+    setvbuf (stdout, (char *) NULL, _IONBF, 0); /* Set non-buffered output on 
stdout */
+
+
+    msg = (struct GNUNET_MessageHeader *) msg_buf;
+    msg->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
+    msg->size = htons (WLAN_MTU);
+    radiotap = (struct Radiotap_Send *) &msg[1];
+    wlan_header = (struct ieee80211_frame *) &radiotap[1];
+    pos = 0;
+
+    getRadiotapHeader (radiotap);
+    getWlanHeader (wlan_header, outmac, inmac,
+                   WLAN_MTU - sizeof (struct GNUNET_MessageHeader));
+
+    start = time (NULL);
+    count = 0;
+    while (1)
+    {
+      pos += write (commpipe[1], msg, WLAN_MTU - pos);
+      if (pos % WLAN_MTU == 0)
+      {
+        pos = 0;
+        count++;
+
+        if (count % 1000 == 0)
+        {
+          akt = time (NULL);
+          bytes_per_s = count * WLAN_MTU / (akt - start);
+          bytes_per_s /= 1024;
+          printf ("send %f kbytes/s\n", bytes_per_s);
+        }
+      }
+
+    }
+  }
+  else
+  {
+    /* A zero PID indicates that this is the child process */
+    (void) close (0);
+    if (-1 == dup2 (commpipe[0], 0))    /* Replace stdin with the in side of 
the pipe */
+      fprintf (stderr, "dup2 failed: %s\n", strerror (errno));
+    (void) close (commpipe[1]); /* Close unused side of pipe (out side) */
+    /* Replace the child fork with a new process */
+    if (execl
+        ("gnunet-transport-wlan-helper", "gnunet-transport-wlan-helper",
+         argv[1], NULL) == -1)
+    {
+      fprintf (stderr, "Could not start gnunet-transport-wlan-helper!");
+      _exit (1);
+    }
+  }
+  return 0;
+}

Deleted: gnunet/src/transport/gnunet_wlan_sender.c
===================================================================
--- gnunet/src/transport/gnunet_wlan_sender.c   2011-12-11 15:10:48 UTC (rev 
18554)
+++ gnunet/src/transport/gnunet_wlan_sender.c   2011-12-11 15:31:47 UTC (rev 
18555)
@@ -1,249 +0,0 @@
-/*
- This file is part of GNUnet
- (C) 2011 Christian Grothoff (and other contributing authors)
-
- GNUnet 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 3, or (at your
- option) any later version.
-
- GNUnet 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 GNUnet; see the file COPYING.  If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-/**
- * @file transport/gnunet_wlan_sender.c
- * @brief program to send via WLAN as much as possible (to test 
physical/theoretical throughput)
- * @author David Brodski
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <netinet/in.h>
-#include <string.h>
-#include <time.h>
-#include <errno.h>
-#include "gnunet_protocols.h"
-#include "plugin_transport_wlan.h"
-
-#define WLAN_MTU 1500
-
-/**
- * LLC fields for better compatibility
- */
-#define WLAN_LLC_DSAP_FIELD 0x1f
-#define WLAN_LLC_SSAP_FIELD 0x1f
-
-#define IEEE80211_ADDR_LEN      6       /* size of 802.11 address */
-
-#define IEEE80211_FC0_VERSION_MASK              0x03
-#define IEEE80211_FC0_VERSION_SHIFT             0
-#define IEEE80211_FC0_VERSION_0                 0x00
-#define IEEE80211_FC0_TYPE_MASK                 0x0c
-#define IEEE80211_FC0_TYPE_SHIFT                2
-#define IEEE80211_FC0_TYPE_MGT                  0x00
-#define IEEE80211_FC0_TYPE_CTL                  0x04
-#define IEEE80211_FC0_TYPE_DATA                 0x08
-
-
-/*
- * 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];
-  u_int8_t llc[4];
-#if DEBUG_wlan_ip_udp_packets_on_air > 1
-  struct iph ip;
-  struct udphdr udp;
-#endif
-} GNUNET_PACKED;
-
-/**
- * function to fill the radiotap header
- * @param header pointer to the radiotap header
- * @return GNUNET_YES at success
- */
-static int
-getRadiotapHeader (struct Radiotap_Send *header)
-{
-
-
-  header->rate = 255;
-  header->tx_power = 0;
-  header->antenna = 0;
-
-  return GNUNET_YES;
-}
-
-/**
- * function to generate the wlan hardware header for one packet
- * @param Header address to write the header to
- * @param to_mac_addr pointer to the address of the recipient
- * @param mac pointer to the mac address to send from (normally overwritten 
over by helper)
- * @param size size of the whole packet, needed to calculate the time to send 
the packet
- * @return GNUNET_YES if there was no error
- */
-static int
-getWlanHeader (struct ieee80211_frame *Header, const char *to_mac_addr,
-               const char *mac, unsigned int size)
-{
-  uint16_t *tmp16;
-  const int rate = 11000000;
-
-  Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA;
-  Header->i_fc[1] = 0x00;
-  memcpy (&Header->i_addr3, &mac_bssid, sizeof (mac_bssid));
-  memcpy (&Header->i_addr2, mac, sizeof (mac_bssid));
-  memcpy (&Header->i_addr1, to_mac_addr, sizeof (mac_bssid));
-
-  tmp16 = (uint16_t *) Header->i_dur;
-  *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290);
-  Header->llc[0] = WLAN_LLC_DSAP_FIELD;
-  Header->llc[1] = WLAN_LLC_SSAP_FIELD;
-
-  return GNUNET_YES;
-}
-
-int
-main (int argc, char *argv[])
-{
-  char msg_buf[WLAN_MTU];
-  struct GNUNET_MessageHeader *msg;
-  struct ieee80211_frame *wlan_header;
-  struct Radiotap_Send *radiotap;
-
-  unsigned int temp[6];
-  char inmac[6];
-  char outmac[6];
-  int pos;
-  long long count;
-  double bytes_per_s;
-  time_t start;
-  time_t akt;
-  int i;
-
-  if (4 != argc)
-  {
-    fprintf (stderr,
-             "This program must be started with the interface and the targets 
and source mac as argument.\n");
-    fprintf (stderr,
-             "Usage: interface-name mac-target mac-source\n"
-             "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
-    return 1;
-  }
-  if (6 !=
-      sscanf (argv[3], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2],
-              &temp[3], &temp[4], &temp[5]))
-  {
-    fprintf (stderr,
-             "Usage: interface-name mac-target mac-source\n"
-             "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
-    return 1;
-  }
-  if (6 !=
-      sscanf (argv[2], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2],
-              &temp[3], &temp[4], &temp[5]))
-  {
-    fprintf (stderr,
-             "Usage: interface-name mac-target mac-source\n"
-             "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
-    return 1;
-  }
-  for (i = 0; i < 6; i++)
-  {
-    inmac[i] = temp[i];
-  }
-  for (i = 0; i < 6; i++)
-  {
-    outmac[i] = temp[i];
-  }
-
-
-  pid_t pid;
-  int commpipe[2];              /* This holds the fd for the input & output of 
the pipe */
-
-  /* Setup communication pipeline first */
-  if (pipe (commpipe))
-  {
-    fprintf (stderr, "Pipe error!\n");
-    exit (1);
-  }
-
-  /* Attempt to fork and check for errors */
-  if ((pid = fork ()) == -1)
-  {
-    fprintf (stderr, "Fork error. Exiting.\n"); /* something went wrong */
-    exit (1);
-  }
-
-  if (pid)
-  {
-    /* A positive (non-negative) PID indicates the parent process */
-    close (commpipe[0]);        /* Close unused side of pipe (in side) */
-    setvbuf (stdout, (char *) NULL, _IONBF, 0); /* Set non-buffered output on 
stdout */
-
-
-    msg = (struct GNUNET_MessageHeader *) msg_buf;
-    msg->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
-    msg->size = htons (WLAN_MTU);
-    radiotap = (struct Radiotap_Send *) &msg[1];
-    wlan_header = (struct ieee80211_frame *) &radiotap[1];
-    pos = 0;
-
-    getRadiotapHeader (radiotap);
-    getWlanHeader (wlan_header, outmac, inmac,
-                   WLAN_MTU - sizeof (struct GNUNET_MessageHeader));
-
-    start = time (NULL);
-    count = 0;
-    while (1)
-    {
-      pos += write (commpipe[1], msg, WLAN_MTU - pos);
-      if (pos % WLAN_MTU == 0)
-      {
-        pos = 0;
-        count++;
-
-        if (count % 1000 == 0)
-        {
-          akt = time (NULL);
-          bytes_per_s = count * WLAN_MTU / (akt - start);
-          bytes_per_s /= 1024;
-          printf ("send %f kbytes/s\n", bytes_per_s);
-        }
-      }
-
-    }
-  }
-  else
-  {
-    /* A zero PID indicates that this is the child process */
-    (void) close (0);
-    if (-1 == dup2 (commpipe[0], 0))    /* Replace stdin with the in side of 
the pipe */
-      fprintf (stderr, "dup2 failed: %s\n", strerror (errno));
-    (void) close (commpipe[1]); /* Close unused side of pipe (out side) */
-    /* Replace the child fork with a new process */
-    if (execl
-        ("gnunet-transport-wlan-helper", "gnunet-transport-wlan-helper",
-         argv[1], NULL) == -1)
-    {
-      fprintf (stderr, "Could not start gnunet-transport-wlan-helper!");
-      _exit (1);
-    }
-  }
-  return 0;
-}

Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c        2011-12-11 15:10:48 UTC 
(rev 18554)
+++ gnunet/src/transport/plugin_transport_wlan.c        2011-12-11 15:31:47 UTC 
(rev 18555)
@@ -121,41 +121,6 @@
 #define IEEE80211_FC0_TYPE_DATA                 0x08
 
 /*
- * Structure of an internet header, naked of options.
- */
-struct iph
-{
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-  unsigned int ip_hl:4;         /* header length */
-  unsigned int ip_v:4;          /* version */
-#endif
-#if __BYTE_ORDER == __BIG_ENDIAN
-  unsigned int ip_v:4;          /* version */
-  unsigned int ip_hl:4;         /* header length */
-#endif
-  u_int8_t ip_tos;              /* type of service */
-  u_short ip_len;               /* total length */
-  u_short ip_id;                /* identification */
-  u_short ip_off;               /* fragment offset field */
-#define IP_RF 0x8000            /* reserved fragment flag */
-#define IP_DF 0x4000            /* dont fragment flag */
-#define IP_MF 0x2000            /* more fragments flag */
-#define IP_OFFMASK 0x1fff       /* mask for fragmenting bits */
-  u_int8_t ip_ttl;              /* time to live */
-  u_int8_t ip_p;                /* protocol */
-  u_short ip_sum;               /* checksum */
-  struct in_addr ip_src, ip_dst;        /* source and dest address */
-};
-
-struct udphdr
-{
-  u_int16_t source;
-  u_int16_t dest;
-  u_int16_t len;
-  u_int16_t check;
-};
-
-/*
  * generic definitions for IEEE 802.11 frames
  */
 struct ieee80211_frame
@@ -167,10 +132,6 @@
   u_int8_t i_addr3[IEEE80211_ADDR_LEN];
   u_int8_t i_seq[2];
   u_int8_t llc[4];
-#if DEBUG_wlan_ip_udp_packets_on_air > 1
-  struct iph ip;
-  struct udphdr udp;
-#endif
 } GNUNET_PACKED;
 
 /**
@@ -1344,7 +1305,7 @@
 
   Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA;
   Header->i_fc[1] = 0x00;
-  memcpy (&Header->i_addr3, &mac_bssid, sizeof (mac_bssid));
+  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));
@@ -1354,36 +1315,6 @@
   Header->llc[0] = WLAN_LLC_DSAP_FIELD;
   Header->llc[1] = WLAN_LLC_SSAP_FIELD;
 
-#if DEBUG_wlan_ip_udp_packets_on_air > 1
-  uint crc = 0;
-  uint16_t *x;
-  int count;
-
-  Header->ip.ip_dst.s_addr = *((uint32_t *) & to_mac_addr->mac[2]);
-  Header->ip.ip_src.s_addr = *((uint32_t *) & plugin->mac_address.mac[2]);
-  Header->ip.ip_v = 4;
-  Header->ip.ip_hl = 5;
-  Header->ip.ip_p = 17;
-  Header->ip.ip_ttl = 1;
-  Header->ip.ip_len = htons (size + 8);
-  Header->ip.ip_sum = 0;
-  x = (uint16_t *) & Header->ip;
-  count = sizeof (struct iph);
-  while (count > 1)
-  {
-    /* This is the inner loop */
-    crc += (unsigned short) *x++;
-    count -= 2;
-  }
-  /* Add left-over byte, if any */
-  if (count > 0)
-    crc += *(unsigned char *) x;
-  crc = (crc & 0xffff) + (crc >> 16);
-  Header->ip.ip_sum = htons (~(unsigned short) crc);
-  Header->udp.len = htons (size - sizeof (struct ieee80211_frame));
-
-#endif
-
   return GNUNET_YES;
 }
 
@@ -3124,7 +3055,7 @@
 
     //check for bssid
     if (memcmp
-        (&(wlanIeeeHeader->i_addr3), &mac_bssid,
+        (&(wlanIeeeHeader->i_addr3), &mac_bssid_gnunet,
          sizeof (struct MacAddress)) == 0)
     {
       //check for broadcast or mac
@@ -3204,7 +3135,7 @@
     break;
   case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL:
     //TODO more control messages
-    if (ntohs (hdr->size) != sizeof (struct Wlan_Helper_Control_Message))
+    if (ntohs (hdr->size) != sizeof (struct 
GNUNET_TRANSPORT_WLAN_HelperControlMessage))
     {
       GNUNET_break (0);
       /* FIXME: restart SUID process */

Modified: gnunet/src/transport/plugin_transport_wlan.h
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.h        2011-12-11 15:10:48 UTC 
(rev 18554)
+++ gnunet/src/transport/plugin_transport_wlan.h        2011-12-11 15:31:47 UTC 
(rev 18555)
@@ -46,7 +46,7 @@
 /**
  * Format of a WLAN Control Message.
  */
-struct Wlan_Helper_Control_Message
+struct GNUNET_TRANSPORT_WLAN_HelperControlMessage
 {
   /**
    * Message header. FIXME: type?
@@ -63,7 +63,7 @@
 /**
  * GNUnet bssid
  */
-static const struct MacAddress mac_bssid = {
+static const struct MacAddress mac_bssid_gnunet = {
   {0x13, 0x22, 0x33, 0x44, 0x55, 0x66}
 };
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]