19 #ifndef INCLUDED_INET_H
20 #define INCLUDED_INET_H
28 static inline uint64_t
htonll(uint64_t x){
return x;}
29 static inline uint64_t
ntohll(uint64_t x){
return x;}
35 static inline uint64_t
38 return ((x & 0x00000000000000ffull) << 56) | ((x & 0x000000000000ff00ull) << 40) |
39 ((x & 0x0000000000ff0000ull) << 24) | ((x & 0x00000000ff000000ull) << 8) |
40 ((x & 0x000000ff00000000ull) >> 8) | ((x & 0x0000ff0000000000ull) >> 24) |
41 ((x & 0x00ff000000000000ull) >> 40) | ((x & 0xff00000000000000ull) >> 56);
46 static inline uint64_t
htonll(uint64_t x){
return bswap_64(x);}
47 static inline uint64_t
ntohll(uint64_t x){
return bswap_64(x);}
53 #include <arpa/inet.h>
55 #include <netinet/in.h>
61 static inline uint32_t htonl(uint32_t x){
return x; }
62 static inline uint16_t htons(uint16_t x){
return x; }
63 static inline uint32_t ntohl(uint32_t x){
return x; }
64 static inline uint16_t ntohs(uint16_t x){
return x; }
69 static inline uint16_t
72 return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
75 static inline uint32_t
78 return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \
79 | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24));
83 static inline uint32_t htonl(uint32_t x){
return bswap_32(x); }
84 static inline uint16_t htons(uint16_t x){
return bswap_16(x); }
85 static inline uint32_t ntohl(uint32_t x){
return bswap_32(x); }
86 static inline uint16_t ntohs(uint16_t x){
return bswap_16(x); }
91 static inline uint8_t
ntohx(uint8_t x){
return x; }
92 static inline uint16_t
ntohx(uint16_t x){
return ntohs(x); }
93 static inline uint32_t
ntohx(uint32_t x){
return ntohl(x); }
95 static inline uint8_t
htonx(uint8_t x){
return x; }
96 static inline uint16_t
htonx(uint16_t x){
return htons(x); }
97 static inline uint32_t
htonx(uint32_t x){
return htonl(x); }