#ifndef SWIFT_NET_ADDR_H
#define SWIFT_NET_ADDR_H

#include <swift/data.h>
#include <swift/atomic.h>
#include <swift/string.h>
#include <swift/stdlib.h>

#include <swift/net/api.h>

#define SWIFT_NUMERIC_ADDR (1 << 0)

typedef struct swift_addr_t swift_addr_t;

enum swift_addr_type_t {
	SWIFT_ADDR_ANY,
	SWIFT_ADDR_IPV4,
	SWIFT_ADDR_IPV6,
};

struct swift_addr_t {
	swift_ref_t ref;
	void *data;
	unsigned int addr_type;
};

SWIFT_NET_API bool swift_init_addr(struct swift_addr_t *addr,
	unsigned int addr_type);
SWIFT_NET_API bool swift_init_addr_from(swift_addr_t *addr,
	const void *data);
SWIFT_NET_API void swift_term_addr(swift_addr_t *addr);
SWIFT_NET_API swift_addr_t *swift_new_addr(unsigned int addr_type);
SWIFT_NET_API swift_addr_t *swift_new_addr_from(const void *data);
SWIFT_NET_API void swift_del_addr(swift_addr_t *addr);
SWIFT_NET_API swift_addr_t *swift_ref_addr(swift_addr_t *addr);
SWIFT_NET_API void swift_del_addrs(swift_array_t *addr);
SWIFT_NET_API swift_array_t *swift_resolve_addr(
	unsigned int addr_type, const char *name, uint16_t port,
	unsigned int flags);
SWIFT_NET_API struct swift_str_t *swift_resolve_name(swift_addr_t *addr,
	unsigned int flags);

#endif /* SWIFT_NET_ADDR_H */
