31 typedef uint8_t UINT8;
32 typedef uint16_t UINT16;
33 typedef uint32_t UINT32;
34 typedef uint64_t UINT64;
37 typedef int16_t INT16;
38 typedef int32_t INT32;
42 #define MAKEWORD(lo,hi) (UINT16)(((UINT16)((UINT8)(hi)) << 8) | ((UINT16)((UINT8)(lo)))) 46 #define MAKELONG(lo,hi) (UINT32)(((UINT32)((UINT16)(hi)) << 16) | ((UINT32)((UINT16)(lo)))) 50 #define LOBYTE(w) (UINT8)((UINT16)(w)) 54 #define HIBYTE(w) (UINT8)((UINT16)(w) >> 8) 58 #define LOWORD(w) (UINT16)((UINT32)(w)) 62 #define HIWORD(w) (UINT16)((UINT32)(w) >> 16) 69 NTOH16(
const UINT8* srcPtr)
73 value = MAKEWORD(srcPtr[0], srcPtr[1]);
79 HTON16(UINT8* dstPtr, UINT16 value)
81 dstPtr[0] = LOBYTE(value);
82 dstPtr[1] = HIBYTE(value);
86 NTOH24(
const UINT8* srcPtr)
90 value = MAKELONG(MAKEWORD(srcPtr[0], srcPtr[1]),
91 MAKEWORD(srcPtr[2], 0x00));
97 HTON24(UINT8* dstPtr, UINT32 value)
99 dstPtr[0] = LOBYTE(LOWORD(value));
100 dstPtr[1] = HIBYTE(LOWORD(value));
101 dstPtr[2] = LOBYTE(HIWORD(value));
105 NTOH32(
const UINT8* srcPtr)
109 value = MAKELONG(MAKEWORD(srcPtr[0], srcPtr[1]),
110 MAKEWORD(srcPtr[2], srcPtr[3]));
116 HTON32(UINT8* dstPtr, UINT32 value)
118 dstPtr[0] = LOBYTE(LOWORD(value));
119 dstPtr[1] = HIBYTE(LOWORD(value));
120 dstPtr[2] = LOBYTE(HIWORD(value));
121 dstPtr[3] = HIBYTE(HIWORD(value));
126 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 127 #define MAX(a, b) ((a) < (b) ? (b) : (a))