-
Notifications
You must be signed in to change notification settings - Fork 0
/
ip46.h
38 lines (30 loc) · 870 Bytes
/
ip46.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef IP46_H
#define IP46_H
#if defined(__cplusplus)
extern "C" {
#endif
#include <sys/socket.h>
#include <netinet/in.h>
typedef struct IP46 IP46;
struct IP46
{
uint32_t ip[4]; // network byte order
uint16_t port; // host byte order
uint16_t flag; // bitmask of values in enum below
};
// IP46.flag bitmask values
enum
{
IP46_IS6 = (1<<0),
};
extern int ip46_from_sockaddr(IP46 *ip46, const struct sockaddr *sa, socklen_t sa_len);
extern void ip46_to_sockaddr(const IP46 *ip46, struct sockaddr *sa, socklen_t *sa_len);
extern char *ip46_ntop(const IP46 *ip46, char *str, size_t size);
extern void ip46_v4_mapped_to_v4(IP46 *ip46);
extern int ip46_pton(IP46 *ip46, const char *str);
extern int ip46_is_v4_mapped(const IP46 *ip46);
extern int ip46_is_addr_unspecified(const IP46 *ip46);
#if defined(__cplusplus)
}
#endif
#endif