]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
- move platform-specific constants to blip-platform.h (makes micaz otb)
authorsdhsdh <sdhsdh>
Sun, 27 Sep 2009 22:39:48 +0000 (22:39 +0000)
committersdhsdh <sdhsdh>
Sun, 27 Sep 2009 22:39:48 +0000 (22:39 +0000)
 - fix byte-order bug on big endian linux platforms

support/sdk/c/blip/lib6lowpan/6lowpan.h
support/sdk/c/blip/lib6lowpan/Makefile.am
support/sdk/c/blip/lib6lowpan/blip-platform.h [new file with mode: 0644]
support/sdk/c/blip/lib6lowpan/ip.h
support/sdk/c/blip/lib6lowpan/ip_malloc.h
support/sdk/c/blip/lib6lowpan/nwbyte.h

index c93d6cf39d6b8669e5ad342ee2046f599d58b152..636c341d9a20e819fcde934ff8efeaec11a0340b 100644 (file)
@@ -32,6 +32,8 @@
 #define __6LOWPAN_H__
 
 #include <stdint.h>
+
+#include "blip-platform.h"
 /*
  * Typedefs and static library data.
  */
@@ -185,16 +187,4 @@ struct topology_header_package {
   struct topology_entry topo[0];
 };
 
-enum {
-  IP_NUMBER_FRAGMENTS = 12,
-};
-
-#ifndef BLIP_L2_RETRIES
-#define BLIP_L2_RETRIES 5
-#endif
-
-#ifndef BLIP_L2_DELAY
-#define BLIP_L2_DELAY 15
-#endif
-
 #endif
index af31e9e135c41c0b485a8a091d97426010906af3..f6248ab04fab63287dd26b0fb20070625df6db65 100644 (file)
@@ -2,8 +2,7 @@
 AM_CFLAGS = -DPC
 noinst_LIBRARIES = lib6lowpan.a
 
-noinst_lib6lowpandir = $(includedir)/lib6lowpan-2.1.1
-noinst_lib6lowpan_HEADERS = 6lowpan.h  devconf.h  IEEE154Packet.h  in_cksum.h  \
-       ip.h  ip_malloc.h  lib6lowpan.h  TrackFlows.h
-lib6lowpan_a_SOURCES = lib6lowpan.c lib6lowpanIP.c lib6lowpanFrag.c $(lib6lowpan_HEADERS)
+lib6lowpan_h = 6lowpan.h  devconf.h  IEEE154Packet.h  in_cksum.h  \
+       ip.h  ip_malloc.h  lib6lowpan.h  TrackFlows.h blip-platform.h
+lib6lowpan_a_SOURCES = lib6lowpan.c lib6lowpanIP.c lib6lowpanFrag.c $(lib6lowpan_h)
 
diff --git a/support/sdk/c/blip/lib6lowpan/blip-platform.h b/support/sdk/c/blip/lib6lowpan/blip-platform.h
new file mode 100644 (file)
index 0000000..d93029c
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * "Copyright (c) 2008, 2009 The Regents of the University  of California.
+ * All rights reserved."
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+#ifndef _BLIP_PLATFORM_H
+#define _BLIP_PLATFORM_H
+
+/* this file has platform-specific configuration settings that don't
+   belong anywhere else */
+
+/* bring in  */
+#if defined(PC)
+// use library versions if on linux
+#include <netinet/in.h>
+#include <endian.h>
+#else
+// if we're not on a pc, assume little endian for now
+#define __LITTLE_ENDIAN 1234
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+/* buffer sizes are defined here. */
+#if !defined(PLATFORM_MICAZ)
+#define IP_MALLOC_HEAP_SIZE 1500
+enum {
+  IP_NUMBER_FRAGMENTS = 14,
+};
+#else
+#define IP_MALLOC_HEAP_SIZE 500
+enum {
+  IP_NUMBER_FRAGMENTS = 4,
+};
+#endif
+
+
+#ifndef BLIP_L2_RETRIES
+#define BLIP_L2_RETRIES 5
+#endif
+
+#ifndef BLIP_L2_DELAY
+#define BLIP_L2_DELAY 15
+#endif
+
+
+#endif
index 335687120a596f60689fb24de9ad32e9084adc59..6a4be2cd06072fc005c4092fe35ecb592e6ca713 100644 (file)
@@ -33,6 +33,7 @@
 #endif
 
 #include "6lowpan.h"
+#include "blip-platform.h"
 
 enum {
   /*
index 02e3e2e450c2e11fa792fdc076f51b84155c553a..6249e6a3a3cf76609ef8c525b0c5a90387953bb3 100644 (file)
 #define IP_MALLOC_H_
 
 #include <stdint.h>
+#include <blip-platform.h>
 
 // align on this number of byte boundarie#s
 #define IP_MALLOC_ALIGN   2
 #define IP_MALLOC_LEN     0x0fff
 #define IP_MALLOC_FLAGS   0x7000
 #define IP_MALLOC_INUSE   0x8000
-#define IP_MALLOC_HEAP_SIZE 1500
 
 extern uint8_t heap[IP_MALLOC_HEAP_SIZE];
 typedef uint16_t bndrt_t;
index 44d0ea8280151749cc600ac4f4292cf79b7fe617..f94b3a5b5ca4376664d213c1b3d7582f1c8ad36e 100644 (file)
@@ -1,17 +1,10 @@
 #ifndef _NWBYTE_H
 #define _NWBYTE_H_
 
-#if !defined(PC)
-// if we're not on a pc, assume little endian for now
-#define __LITTLE_ENDIAN 1234
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif
+#include "blip-platform.h"
 
 /* define normal network byte-orders routines  */
 #if defined(PC) 
-// use library versions if on linux
-#include <netinet/in.h>
-#include <endian.h>
 
 #define ntoh16(X)   ntohs(X)
 #define hton16(X)   htons(X)
@@ -25,7 +18,7 @@
 #define hton16(X)   (((((uint16_t)(X)) << 8) | ((uint16_t)(X) >> 8)) & 0xffff)
 
 /* this is much more efficient since gcc can insert swpb now.  */
-static uint32_t __attribute__((unused))  ntoh32(uint32_t i) {
+static inline uint32_t __attribute__((unused))  ntoh32(uint32_t i) {
   uint16_t lo = (uint16_t)i;
   uint16_t hi = (uint16_t)(i >> 16);
   lo = (lo << 8) | (lo >> 8);
@@ -53,8 +46,8 @@ static uint32_t __attribute__((unused))  ntoh32(uint32_t i) {
 #endif
 
 #else
-// assume big-endian byte-order
-#define leton16(X) (X)
+//  big-endian byte-order
+#define leton16(X) (((((uint16_t)(X)) << 8) | ((uint16_t)(X) >> 8)) & 0xffff)
 #define htole16(X) (((((uint16_t)(X)) << 8) | ((uint16_t)(X) >> 8)) & 0xffff)
 #endif