87 #include <arpa/inet.h> 88 #include <sys/socket.h> 89 #include <sys/types.h> 91 #define ntohl(x) ((x & 0x0000000ff) << 24) | ((x & 0x0000ff00) << 8) | \ 92 ((x & 0x00ff0000) >> 8) | ((x & 0xff000000) >> 24) 93 #define htonl(x) ntohl(x) 101 typedef union ip_addr_u {
133 return (addr->
ui64[0] == 0 && addr->
ui32[3] == 0xffffffff);
159 return ntohl(addr->
ui32[2]);
173 return (
char *) &addr->
bytes[8];
187 a.
ui32[2] = htonl(i);
188 a.
ui32[3] = 0xffffffff;
207 a.
ui32[3] = 0xffffffff;
226 a.
ui32[3] = 0xffffffff;
253 for (i = 0; i < 16; i++) {
254 a.
bytes[i] = b[15-i];
268 return memcmp((
const char *)addr1, (
const char *)addr2, 16);
285 if (addr->
ui64[0] == 0) {
286 if (addr->
ui64[1] == 0 || (addr->
ui32[2] == 0 && addr->
ui32[3] == 0xffffffff)) {
304 if (strchr(str,
':') == NULL) {
305 if (inet_pton(AF_INET, str, (
void *) tmp) != 1) {
311 if (inet_pton(AF_INET6, str, (
void *) tmp) != 1) {
330 inet_ntop(AF_INET6, addr, str, INET6_ADDRSTRLEN);
INLINE ip_addr_t ip_from_16_bytes_le(char b[16])
INLINE uint32_t ip_get_v4_as_int(ip_addr_t *addr)
INLINE ip_addr_t ip_from_16_bytes_be(char b[16])
INLINE int ip_is_null(const ip_addr_t *addr)
INLINE int ip_from_str(const char *str, ip_addr_t *addr)
INLINE int ip_cmp(const ip_addr_t *addr1, const ip_addr_t *addr2)
INLINE ip_addr_t ip_from_4_bytes_be(char b[4])
INLINE ip_addr_t ip_from_int(uint32_t i)
INLINE int ip_is6(const ip_addr_t *addr)
memcpy(buffer, rec, ur_rec_size(tmplt, rec))
INLINE void ip_to_str(const ip_addr_t *addr, char *str)
INLINE int ip_is4(const ip_addr_t *addr)
INLINE ip_addr_t ip_from_4_bytes_le(char b[4])
INLINE char * ip_get_v4_as_bytes(const ip_addr_t *addr)