aboutsummaryrefslogtreecommitdiffstats
path: root/lib/in46_addr.h
blob: 2b3755b2438fbb845b31367d51e1fd5fe551a288 (plain)
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
#pragma once
#include <stdint.h>
#include <netinet/in.h>

#include "../gtp/pdp.h"

#include "config.h"

/* a simple wrapper around an in6_addr to also contain the length of the address,
 * thereby implicitly indicating the address family of the address */
struct in46_addr {
	uint8_t len;
	union {
		struct in_addr v4;
#if defined(BUILD_IPv6)
		struct in6_addr v6;
#endif
	};
};

struct in46_prefix {
	struct in46_addr addr;
	uint8_t prefixlen;
};

extern int in46a_to_af(const struct in46_addr *in);
extern int in46a_to_sas(struct sockaddr_storage *out, const struct in46_addr *in);
extern const char *in46a_ntop(const struct in46_addr *in, char *dst, socklen_t dst_size);
extern const char *in46a_ntoa(const struct in46_addr *in46);
extern const char *in46p_ntoa(const struct in46_prefix *in46p);
extern int in46a_equal(const struct in46_addr *a, const struct in46_addr *b);
extern int in46a_prefix_equal(const struct in46_addr *a, const struct in46_addr *b);
extern int in46a_within_mask(const struct in46_addr *addr, const struct in46_addr *net, size_t prefixlen);
unsigned int in46a_netmasklen(const struct in46_addr *netmask);

int in46a_to_eua(const struct in46_addr *src, struct ul66_t *eua);
int in46a_from_eua(const struct ul66_t *eua, struct in46_addr *dst);