gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r18463 - in gnunet/src: include transport


From: gnunet
Subject: [GNUnet-SVN] r18463 - in gnunet/src: include transport
Date: Tue, 6 Dec 2011 15:55:46 +0100

Author: wachs
Date: 2011-12-06 15:55:46 +0100 (Tue, 06 Dec 2011)
New Revision: 18463

Modified:
   gnunet/src/include/gnunet_common.h
   gnunet/src/transport/gnunet-transport-wlan-helper.c
   gnunet/src/transport/gnunet_wlan_sender.c
   gnunet/src/transport/plugin_transport_wlan.c
Log:
adding GNUnet endian operations


Modified: gnunet/src/include/gnunet_common.h
===================================================================
--- gnunet/src/include/gnunet_common.h  2011-12-06 14:21:20 UTC (rev 18462)
+++ gnunet/src/include/gnunet_common.h  2011-12-06 14:55:46 UTC (rev 18463)
@@ -73,6 +73,45 @@
 #define GNUNET_MAX(a,b) (((a) > (b)) ? (a) : (b))
 
 /**
+ * Endian operations
+ */
+
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+#  define GNUNET_htobe16(x) __bswap_16 (x)
+#  define GNUNET_htole16(x) (x)
+#  define GNUNET_be16toh(x) __bswap_16 (x)
+#  define GNUNET_le16toh(x) (x)
+
+#  define GNUNET_htobe32(x) __bswap_32 (x)
+#  define GNUNET_htole32(x) (x)
+#  define GNUNET_be32toh(x) __bswap_32 (x)
+#  define GNUNET_le32toh(x) (x)
+
+#  define GNUNET_htobe64(x) __bswap_64 (x)
+#  define GNUNET_htole64(x) (x)
+#  define GNUNET_be64toh(x) __bswap_64 (x)
+#  define GNUNET_le64toh(x) (x)
+# if __BYTE_ORDER == __BIG_ENDIAN
+#  define GNUNET_htobe16(x) (x)
+#  define GNUNET_htole16(x) __bswap_16 (x)
+#  define GNUNET_be16toh(x) (x)
+#  define GNUNET_le16toh(x) __bswap_16 (x)
+
+#  define GNUNET_htobe32(x) (x)
+#  define GNUNET_htole32(x) __bswap_32 (x)
+#  define GNUNET_be32toh(x) (x)
+#  define GNUNET_le32toh(x) __bswap_32 (x)
+
+#  define GNUNET_htobe64(x) (x)
+#  define GNUNET_htole64(x) __bswap_64 (x)
+#  define GNUNET_be64toh(x) (x)
+#  define GNUNET_le64toh(x) __bswap_64 (x)
+# endif
+#endif
+
+
+
+/**
  * gcc-ism to get packed structs.
  */
 #define GNUNET_PACKED __attribute__((packed))

Modified: gnunet/src/transport/gnunet-transport-wlan-helper.c
===================================================================
--- gnunet/src/transport/gnunet-transport-wlan-helper.c 2011-12-06 14:21:20 UTC 
(rev 18462)
+++ gnunet/src/transport/gnunet-transport-wlan-helper.c 2011-12-06 14:55:46 UTC 
(rev 18463)
@@ -96,7 +96,6 @@
 #include <errno.h>
 #include <dirent.h>
 #include <sys/param.h>
-#include <endian.h>
 #include <unistd.h>
 #include <stdint.h>
 
@@ -399,25 +398,7 @@
   (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0xff00000000000000ULL) >> 56) ))
  /* *INDENT-ON* */
 
-#ifndef htole16
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define htole16(x) (x)
-#define le16toh(x) (x)
-#define htole32(x) (x)
-#define le32toh(x) (x)
-#define htole64(x) (x)
-#define le64toh(x) (x)
-#else
-#define htole16(x) ___my_swab16 (x)
-#define le16toh(x) ___my_swab16 (x)
-#define htole32(x) ___my_swab32 (x)
-#define le32toh(x) ___my_swab32 (x)
-#define htole64(x) ___my_swab64 (x)
-#define le64toh(x) ___my_swab64 (x)
-#endif
-#endif
 
-
 /**
  * struct ieee80211_radiotap_iterator - tracks walk through present radiotap 
args
  */
@@ -494,13 +475,13 @@
 
   /* sanity check for allowed length and radiotap length field */
 
-  if (max_length < (le16toh (radiotap_header->it_len)))
+  if (max_length < (GNUNET_le16toh (radiotap_header->it_len)))
     return (-EINVAL);
 
   iterator->rtheader = radiotap_header;
-  iterator->max_length = le16toh (radiotap_header->it_len);
+  iterator->max_length = GNUNET_le16toh (radiotap_header->it_len);
   iterator->arg_index = 0;
-  iterator->bitmap_shifter = le32toh (radiotap_header->it_present);
+  iterator->bitmap_shifter = GNUNET_le32toh (radiotap_header->it_present);
   iterator->arg =
       ((uint8_t *) radiotap_header) + sizeof (struct 
ieee80211_radiotap_header);
   iterator->this_arg = 0;
@@ -509,7 +490,7 @@
 
   if ((iterator->bitmap_shifter & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK))
   {
-    while (le32toh (*((uint32_t *) iterator->arg)) &
+    while (GNUNET_le32toh (*((uint32_t *) iterator->arg)) &
            IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)
     {
       iterator->arg += sizeof (uint32_t);
@@ -670,7 +651,7 @@
       {
         /* b31 was set, there is more */
         /* move to next uint32_t bitmap */
-        iterator->bitmap_shifter = le32toh (*iterator->next_bitmap);
+        iterator->bitmap_shifter = GNUNET_le32toh (*iterator->next_bitmap);
         iterator->next_bitmap++;
       }
       else
@@ -963,7 +944,7 @@
       {
 
       case IEEE80211_RADIOTAP_TSFT:
-        ri->ri_mactime = le64toh (*((uint64_t *) iterator.this_arg));
+        ri->ri_mactime = GNUNET_le64toh (*((uint64_t *) iterator.this_arg));
         break;
 
       case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
@@ -1043,7 +1024,7 @@
         break;
       }
     }
-    n = le16toh (rthdr->it_len);
+    n = GNUNET_le16toh (rthdr->it_len);
     if (n <= 0 || n >= caplen)
       return 0;
   }
@@ -1285,12 +1266,12 @@
   struct RadioTapheader rtheader;
 
   rtheader.header.it_version = 0;
-  rtheader.header.it_len = htole16 (0x0c);
-  rtheader.header.it_present = htole32 (0x00008004);
+  rtheader.header.it_len = GNUNET_htole16 (0x0c);
+  rtheader.header.it_present = GNUNET_le16toh (0x00008004);
   rtheader.rate = 0x00;
   rtheader.pad1 = 0x00;
   rtheader.txflags =
-      htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ);
+      GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | 
IEEE80211_RADIOTAP_F_TX_NOSEQ);
 
   /*  { 0x00, 0x00, <-- radiotap version
    * 0x0c, 0x00, <- radiotap header length
@@ -1321,7 +1302,7 @@
     exit (1);
   }
 
-  rtheader.header.it_len = htole16 (sizeof (rtheader));
+  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);

Modified: gnunet/src/transport/gnunet_wlan_sender.c
===================================================================
--- gnunet/src/transport/gnunet_wlan_sender.c   2011-12-06 14:21:20 UTC (rev 
18462)
+++ gnunet/src/transport/gnunet_wlan_sender.c   2011-12-06 14:55:46 UTC (rev 
18463)
@@ -111,7 +111,7 @@
   memcpy (&Header->i_addr1, to_mac_addr, sizeof (mac_bssid));
 
   tmp16 = (uint16_t *) Header->i_dur;
-  *tmp16 = (uint16_t) htole16 ((size * 1000000) / rate + 290);
+  *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290);
   Header->llc[0] = WLAN_LLC_DSAP_FIELD;
   Header->llc[1] = WLAN_LLC_SSAP_FIELD;
 

Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c        2011-12-06 14:21:20 UTC 
(rev 18462)
+++ gnunet/src/transport/plugin_transport_wlan.c        2011-12-06 14:55:46 UTC 
(rev 18463)
@@ -1320,7 +1320,7 @@
   memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct MacAddress));
 
   tmp16 = (uint16_t *) Header->i_dur;
-  *tmp16 = (uint16_t) htole16 ((size * 1000000) / rate + 290);
+  *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290);
   Header->llc[0] = WLAN_LLC_DSAP_FIELD;
   Header->llc[1] = WLAN_LLC_SSAP_FIELD;
 




reply via email to

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