00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __LWIP_DEF_H__
00033 #define __LWIP_DEF_H__
00034
00035
00036 #include "lwip/arch.h"
00037 #include "lwip/opt.h"
00038
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042
00043 #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y))
00044 #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y))
00045
00046 #ifndef NULL
00047 #define NULL ((void *)0)
00048 #endif
00049
00050
00051 #if BYTE_ORDER == LITTLE_ENDIAN
00052 #define LWIP_MAKE_U16(a, b) ((a << 8) | b)
00053 #else
00054 #define LWIP_MAKE_U16(a, b) ((b << 8) | a)
00055 #endif
00056
00057 #ifndef LWIP_PLATFORM_BYTESWAP
00058 #define LWIP_PLATFORM_BYTESWAP 0
00059 #endif
00060
00061 #ifndef LWIP_PREFIX_BYTEORDER_FUNCS
00062
00063
00064 #ifdef htons
00065 #undef htons
00066 #endif
00067 #ifdef htonl
00068 #undef htonl
00069 #endif
00070 #ifdef ntohs
00071 #undef ntohs
00072 #endif
00073 #ifdef ntohl
00074 #undef ntohl
00075 #endif
00076
00077 #define htons(x) lwip_htons(x)
00078 #define ntohs(x) lwip_ntohs(x)
00079 #define htonl(x) lwip_htonl(x)
00080 #define ntohl(x) lwip_ntohl(x)
00081 #endif
00082
00083 #if BYTE_ORDER == BIG_ENDIAN
00084 #define lwip_htons(x) (x)
00085 #define lwip_ntohs(x) (x)
00086 #define lwip_htonl(x) (x)
00087 #define lwip_ntohl(x) (x)
00088 #define PP_HTONS(x) (x)
00089 #define PP_NTOHS(x) (x)
00090 #define PP_HTONL(x) (x)
00091 #define PP_NTOHL(x) (x)
00092 #else
00093 #if LWIP_PLATFORM_BYTESWAP
00094 #define lwip_htons(x) LWIP_PLATFORM_HTONS(x)
00095 #define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x)
00096 #define lwip_htonl(x) LWIP_PLATFORM_HTONL(x)
00097 #define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x)
00098 #else
00099 u16_t lwip_htons(u16_t x);
00100 u16_t lwip_ntohs(u16_t x);
00101 u32_t lwip_htonl(u32_t x);
00102 u32_t lwip_ntohl(u32_t x);
00103 #endif
00104
00105
00106
00107
00108 #define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
00109 #define PP_NTOHS(x) PP_HTONS(x)
00110 #define PP_HTONL(x) ((((x) & 0xff) << 24) | \
00111 (((x) & 0xff00) << 8) | \
00112 (((x) & 0xff0000UL) >> 8) | \
00113 (((x) & 0xff000000UL) >> 24))
00114 #define PP_NTOHL(x) PP_HTONL(x)
00115
00116 #endif
00117
00118 #ifdef __cplusplus
00119 }
00120 #endif
00121
00122 #endif
00123