+#elif __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN
+
+#define ntohl(x) ((__uint32_t)(x))
+#define ntohs(x) ((__uint16_t)(x))
+#define htonl(x) ((__uint32_t)(x))
+#define htons(x) ((__uint16_t)(x))
+
+#if defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
+#define NTOHL(x) (x)
+#define NTOHS(x) (x)
+#define HTONL(x) (x)
+#define HTONS(x) (x)
+#endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */
+
+#else /* __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN */
+
+#include <libkern/_OSByteOrder.h>
+
+#define ntohs(x) __DARWIN_OSSwapInt16(x)
+#define htons(x) __DARWIN_OSSwapInt16(x)