32 #ifndef __LWIP_DEF_H__
33 #define __LWIP_DEF_H__
36 #include "lwip/arch.h"
43 #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y))
44 #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y))
47 #define NULL ((void *)0)
52 #define LWIP_U32_DIFF(a, b) (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1)))
55 #if BYTE_ORDER == LITTLE_ENDIAN
56 #define LWIP_MAKE_U16(a, b) ((a << 8) | b)
58 #define LWIP_MAKE_U16(a, b) ((b << 8) | a)
61 #ifndef LWIP_PLATFORM_BYTESWAP
62 #define LWIP_PLATFORM_BYTESWAP 0
65 #ifndef LWIP_PREFIX_BYTEORDER_FUNCS
81 #define htons(x) lwip_htons(x)
82 #define ntohs(x) lwip_ntohs(x)
83 #define htonl(x) lwip_htonl(x)
84 #define ntohl(x) lwip_ntohl(x)
87 #if BYTE_ORDER == BIG_ENDIAN
88 #define lwip_htons(x) (x)
89 #define lwip_ntohs(x) (x)
90 #define lwip_htonl(x) (x)
91 #define lwip_ntohl(x) (x)
92 #define PP_HTONS(x) (x)
93 #define PP_NTOHS(x) (x)
94 #define PP_HTONL(x) (x)
95 #define PP_NTOHL(x) (x)
97 #if LWIP_PLATFORM_BYTESWAP
98 #define lwip_htons(x) LWIP_PLATFORM_HTONS(x)
99 #define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x)
100 #define lwip_htonl(x) LWIP_PLATFORM_HTONL(x)
101 #define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x)
103 u16_t lwip_htons(u16_t x);
104 u16_t lwip_ntohs(u16_t x);
105 u32_t lwip_htonl(u32_t x);
106 u32_t lwip_ntohl(u32_t x);
112 #define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
113 #define PP_NTOHS(x) PP_HTONS(x)
114 #define PP_HTONL(x) ((((x) & 0xff) << 24) | \
115 (((x) & 0xff00) << 8) | \
116 (((x) & 0xff0000UL) >> 8) | \
117 (((x) & 0xff000000UL) >> 24))
118 #define PP_NTOHL(x) PP_HTONL(x)