19#include <citrusleaf/cf_byte_order.h>
24#include <netinet/in.h>
25#include <sys/socket.h>
29#define in_addr_t ULONG
32#define AS_IP_ADDRESS_SIZE 64
71 uint16_t port = (addr->sa_family == AF_INET)?
72 ((
struct sockaddr_in*)addr)->sin_port :
73 ((
struct sockaddr_in6*)addr)->sin6_port;
74 return cf_swap_from_be16(port);
81static inline socklen_t
84 return (addr->sa_family == AF_INET)?
sizeof(
struct sockaddr_in) : sizeof(struct sockaddr_in6);
95 memcpy(trg, src, size);
105 if (addr->sa_family == AF_INET) {
106 struct sockaddr_in* a = (
struct sockaddr_in*)addr;
107 return (cf_swap_to_be32(a->sin_addr.s_addr) & 0xff000000) == 0x7f000000;
110 struct sockaddr_in6* a = (
struct sockaddr_in6*)addr;
111 return memcmp(&a->sin6_addr, &in6addr_loopback,
sizeof(
struct in6_addr)) == 0;
static bool as_address_is_local(struct sockaddr *addr)
static uint16_t as_address_port(struct sockaddr *addr)
static socklen_t as_address_size(struct sockaddr *addr)
static void as_address_copy_storage(struct sockaddr *src, struct sockaddr_storage *trg)
AS_EXTERN void as_address_short_name(struct sockaddr *addr, char *name, socklen_t size)
AS_EXTERN void as_address_name(struct sockaddr *addr, char *name, socklen_t size)