#include <stdio.h>
#define DEBUG 0
+static inline uint32_t htonl(uint32_t v)
+{
+ return (((v >> 24) & 0xFF) << 0)
+ | (((v >> 16) & 0xFF) << 8)
+ | (((v >> 8) & 0xFF) << 16)
+ | (((v >> 0) & 0xFF) << 24);
+}
+static inline uint16_t htons(uint16_t v)
+{
+ return (((v >> 8) & 0xFF) << 0)
+ | (((v >> 0) & 0xFF) << 8);
+}
+#define htonb(v) v
+#define ntohl(v) htonl(v)
+#define ntohs(v) htons(v)
+#define ntohb(v) v
+
#define __thread // Disable TLS
/**
k = 0;
for( ; j < 8; j ++, k++)
{
- Addr[j*2] = hi[k]>>8;
- Addr[j*2+1] = hi[k]&0xFF;
+ Addr[j*2] = low[k]>>8;
+ Addr[j*2+1] = low[k]&0xFF;
}
return 1;
return 0;
}
-static const char *Net_PrintIPv4Address(uint8_t *Address)
+static const char *Net_PrintIPv4Address(const uint8_t *Address)
{
static __thread char ret[4*3+3+1]; // '255.255.255.255\0'
return ret;
}
-static const char *Net_PrintIPv6Address(uint16_t *Address)
+static const char *Net_PrintIPv6Address(const uint16_t *Address)
{
static __thread char ret[8*4+7+1]; // 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF\0'
#if 0
#endif
sprintf(ret, "%x:%x:%x:%x:%x:%x:%x:%x",
- Address[0], Address[1], Address[2], Address[3],
- Address[4], Address[5], Address[6], Address[7]
+ ntohs(Address[0]), ntohs(Address[1]), ntohs(Address[2]), ntohs(Address[3]),
+ ntohs(Address[4]), ntohs(Address[5]), ntohs(Address[6]), ntohs(Address[7])
);
return ret;
}
-const char *Net_PrintAddress(int AddressType, void *Address)
+const char *Net_PrintAddress(int AddressType, const void *Address)
{
switch( AddressType )
{