gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r12878 - gnunet/src/transport
Date: Tue, 7 Sep 2010 11:51:01 +0200

Author: grothoff
Date: 2010-09-07 11:51:01 +0200 (Tue, 07 Sep 2010)
New Revision: 12878

Modified:
   gnunet/src/transport/ieee80211_radiotap.h
   gnunet/src/transport/plugin_transport_wlan.c
Log:
fix warnings

Modified: gnunet/src/transport/ieee80211_radiotap.h
===================================================================
--- gnunet/src/transport/ieee80211_radiotap.h   2010-09-07 09:41:31 UTC (rev 
12877)
+++ gnunet/src/transport/ieee80211_radiotap.h   2010-09-07 09:51:01 UTC (rev 
12878)
@@ -37,7 +37,7 @@
 
 #include <linux/if_ether.h>
 #include <linux/kernel.h>
-//#include <asm/unaligned.h>
+// #include <asm/unaligned.h>
 
 /* Base version of the radiotap packet header data */
 #define PKTHDR_RADIOTAP_VERSION                0
@@ -254,12 +254,18 @@
        ((x) + 1000) * 5)
 
 /* helpers */
+static inline u16 get_unaligned_le16(const u8 *p)
+{
+  return p[0] | p[1] << 8;
+}
+
+
 static inline int ieee80211_get_radiotap_len(unsigned char *data)
 {
        struct ieee80211_radiotap_header *hdr =
                (struct ieee80211_radiotap_header *)data;
 
-       return get_unaligned_le16(&hdr->it_len);
+       return get_unaligned_le16( (const u8 *) &hdr->it_len);
 }
 
 #endif                         /* IEEE80211_RADIOTAP_H */

Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c        2010-09-07 09:41:31 UTC 
(rev 12877)
+++ gnunet/src/transport/plugin_transport_wlan.c        2010-09-07 09:51:01 UTC 
(rev 12878)
@@ -26,9 +26,7 @@
 
 #include "platform.h"
 #include "gnunet_protocols.h"
-#include "gnunet_connection_lib.h"
-#include "gnunet_server_lib.h"
-#include "gnunet_service_lib.h"
+#include "gnunet_util_lib.h"
 #include "gnunet_statistics_service.h"
 #include "gnunet_transport_service.h"
 #include "plugin_transport.h"
@@ -37,9 +35,6 @@
 
 #define DEBUG_wlan GNUNET_NO
 
-static void
-wlan_plugin_helper_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext 
*tc);
-
 /**
  * After how long do we expire an address that we
  * learned from another peer if it is not reconfirmed
@@ -265,34 +260,32 @@
  */
 static void
 wlan_plugin_address_pretty_printer (void *cls,
-                                        const char *type,
-                                        const void *addr,
-                                        size_t addrlen,
-                                        int numeric,
-                                        struct GNUNET_TIME_Relative timeout,
-                                        GNUNET_TRANSPORT_AddressStringCallback
-                                        asc, void *asc_cls)
+                                   const char *type,
+                                   const void *addr,
+                                   size_t addrlen,
+                                   int numeric,
+                                   struct GNUNET_TIME_Relative timeout,
+                                   GNUNET_TRANSPORT_AddressStringCallback
+                                   asc, void *asc_cls)
 {
-  unsigned int res;
-  char * ret;
-  char * input;
-
+  char ret[92];
+  const unsigned char * input;
+  
   GNUNET_assert(cls !=NULL);
-  //Mac Adress has 6 bytes
-  if (addrlen == 6){
-    input = addr;
-    res = GNUNET_asprintf(&ret,"%s Mac-Adress %X:%X:%X:%X:%X:%X", 
PROTOCOL_PREFIX, input[0], input[1],input[2],input[3],input[4],input[5]);
-
-    GNUNET_assert(res != 0);
-    asc (asc_cls, ret);
-    GNUNET_free_non_null (ret);
-
-  } else {
-    /* invalid address */
-    GNUNET_break_op (0);
-    asc (asc_cls, NULL);
-    return;
-  }
+  if (addrlen != 6)
+    {
+      /* invalid address (MAC addresses have 6 bytes) */
+      GNUNET_break (0);
+      asc (asc_cls, NULL);
+      return;
+    }
+  input = (const unsigned char*) addr;
+  GNUNET_snprintf (ret, 
+                  sizeof (ret),
+                  "%s Mac-Adress %X:%X:%X:%X:%X:%X",
+                  PROTOCOL_PREFIX, 
+                  input[0], input[1], input[2], input[3], input[4], input[5]); 
 
+  asc (asc_cls, ret);
 }
 
 
@@ -345,30 +338,30 @@
  */
 static const char* 
 wlan_plugin_address_to_string (void *cls,
-                                  const void *addr,
-                                  size_t addrlen)
+                              const void *addr,
+                              size_t addrlen)
 {
-  unsigned int res;
-  char * ret;
-  char * input;
-
+  char ret[92];
+  const unsigned char * input;
+  
   GNUNET_assert(cls !=NULL);
-  //Mac Adress has 6 bytes
-  if (addrlen == 6){
-    input = addr;
-    res = GNUNET_asprintf(&ret,"%X:%X:%X:%X:%X:%X", input[0], 
input[1],input[2],input[3],input[4],input[5]);
-
-    GNUNET_assert(res != 0);
-    return ret;
-
-  } else {
-    /* invalid address */
-    GNUNET_break (0);
-    return NULL;
-  }
+  if (addrlen != 6)
+    {
+      /* invalid address (MAC addresses have 6 bytes) */
+      GNUNET_break (0);
+      return NULL;
+    }
+  input = (const unsigned char*) addr;
+  GNUNET_snprintf (ret, 
+                  sizeof (ret),
+                  "%s Mac-Adress %X:%X:%X:%X:%X:%X",
+                  PROTOCOL_PREFIX, 
+                  input[0], input[1], input[2], input[3], input[4], input[5]); 
 
+  return GNUNET_strdup (ret);
 }
 
 
+#if 0
 /**
  * Function for used to process the data from the suid process
  */
@@ -399,7 +392,36 @@
 }
 
 
+static void
+wlan_plugin_helper_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext 
*tc)
+{
+  struct Plugin *plugin = cls;
+  char mybuf[3000]; //max size of packet from helper
+  ssize_t bytes;
+  //memset(&mybuf, 0, sizeof(mybuf)); //?
 
+  if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
+    return;
+
+  bytes = GNUNET_DISK_file_read(plugin->server_stdout_handle, &mybuf, 
sizeof(mybuf));
+
+  if (bytes < 1)
+    {
+#if DEBUG_TCP_NAT
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      _("Finished reading from wlan-helper stdout with code: 
%d\n"), bytes);
+#endif
+      return;
+    }
+
+  plugin->server_read_task =
+  GNUNET_SCHEDULER_add_read_file (plugin->env->sched,
+                                  GNUNET_TIME_UNIT_FOREVER_REL,
+                                  plugin->server_stdout_handle, 
&wlan_plugin_helper_read, plugin);
+
+}
+
+
 /**
  * Start the gnunet-wlan-helper process for users behind NAT.
  *
@@ -407,7 +429,6 @@
  *
  * @return GNUNET_YES if process was started, GNUNET_SYSERR on error
  */
-
 static int
 wlan_transport_start_wlan_helper(struct Plugin *plugin)
 {
@@ -452,39 +473,9 @@
 
 
 
-
-static void
-wlan_plugin_helper_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext 
*tc)
-{
-  struct Plugin *plugin = cls;
-  char mybuf[3000]; //max size of packet from helper
-  ssize_t bytes;
-  //memset(&mybuf, 0, sizeof(mybuf)); //?
-  int i;
-
-
-  if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
-    return;
-
-  bytes = GNUNET_DISK_file_read(plugin->server_stdout_handle, &mybuf, 
sizeof(mybuf));
-
-  if (bytes < 1)
-    {
-#if DEBUG_TCP_NAT
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      _("Finished reading from wlan-helper stdout with code: 
%d\n"), bytes);
 #endif
-      return;
-    }
 
-  plugin->server_read_task =
-  GNUNET_SCHEDULER_add_read_file (plugin->env->sched,
-                                  GNUNET_TIME_UNIT_FOREVER_REL,
-                                  plugin->server_stdout_handle, 
&wlan_plugin_helper_read, plugin);
 
-}
-
-
 /**
  * Entry point for the plugin.
  */




reply via email to

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