- Fixed include location of endian.h and name clash on Apples (found by Martin van Hensbergen)

diff --git a/ChangeLog b/ChangeLog
index ac56b78..a74a95e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,8 @@
 Bug fixes

    * Fixed include location of endian.h on FreeBSD (found by

      Gabriel)

+   * Fixed include location of endian.h and name clash on

+     Apples (found by Martin van Hensbergen)

    * Fixed HMAC-MD2 by modifying md2_starts(), so that the

      required HMAC ipad and opad variables are not cleared.

      (found by code coverage tests)

diff --git a/library/net.c b/library/net.c
index b213f24..17f7372 100644
--- a/library/net.c
+++ b/library/net.c
@@ -55,8 +55,11 @@
 #include <fcntl.h>
 #include <netdb.h>
 #include <errno.h>
+
 #if defined(__FreeBSD__)
 #include <sys/endian.h>
+#elif defined(__APPLE__)
+#include <machine/endian.h>
 #else
 #include <endian.h>
 #endif
@@ -74,13 +77,13 @@
  * to help determine endianess.
  */
 #if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN
-#define HTONS(n) (n)
+#define POLARSSL_HTONS(n) (n)
 #else
-#define HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8))
+#define POLARSSL_HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8))
 #endif
 
 unsigned short net_htons(unsigned short n);
-#define net_htons(n) HTONS(n)
+#define net_htons(n) POLARSSL_HTONS(n)
 
 /*
  * Initiate a TCP connection with host:port