39static_assert(
sizeof(
protocore_ip_family) == 1,
"protocore_ip_family must stay one byte (PROTO_ENUM_PACKED); "
40 "protocore_ip is embedded wherever an address is stored");
52static_assert(
sizeof(
protocore_ip_scope) == 1,
"protocore_ip_scope must stay one byte (PROTO_ENUM_PACKED)");
62#define PROTOCORE_IP_STR_MAX 46
149 void (*
const parse)(uint8_t *work);
150 void (*
const format)(uint8_t *work);
151 void (*
const classify)(uint8_t *work);
152 void (*
const equal)(uint8_t *work);
153 void (*
const is_unspecified)(uint8_t *work);
154 void (*
const prefix_match)(uint8_t *work);
170static const IpNs Ip __attribute__((unused)) = {
PROTO_ENUM_PACKED
Application protocol spoken on a listener port or connection slot.
uint32_t protocore_ip_to_v4_be(const protocore_ip *ip)
The v4 address as a big-endian (network-order) uint32 (a<<24 | b<<16 | c<<8 | d).
protocore_ip protocore_ip_from_v4_octets(uint8_t a, uint8_t b, uint8_t c, uint8_t d)
Build a v4 protocore_ip from four octets (a.b.c.d).
void protocore_ip_parse(uint8_t *work)
void protocore_ip_is_unspecified(uint8_t *work)
protocore_ip protocore_ip_from_v6_bytes(const uint8_t bytes[16])
Build a v6 protocore_ip from 16 address bytes in network (big-endian) order.
enum PROTO_ENUM_PACKED protocore_ip_scope
Address scope, in rough order of reachability (used for allow/deny policy + logging).
PROTOCORE_BEGIN_DECLS enum PROTO_ENUM_PACKED protocore_ip_family
Address family tag.
void protocore_ip_prefix_match(uint8_t *work)
@ PROTOCORE_IP_NONE
empty / unparsed
@ PROTOCORE_IP_V4
IPv4 (bytes[0..3])
@ PROTOCORE_IP_SCOPE_MULTICAST
224.0.0.0/4 / ff00::/8
@ PROTOCORE_IP_V6
IPv6 (bytes[0..15])
@ PROTOCORE_IP_SCOPE_LOOPBACK
127.0.0.0/8 / ::1
@ PROTOCORE_IP_SCOPE_GLOBAL
globally routable unicast
@ PROTOCORE_IP_SCOPE_UNSPECIFIED
0.0.0.0 / ::
@ PROTOCORE_IP_SCOPE_LINK_LOCAL
169.254.0.0/16 / fe80::/10
@ PROTOCORE_IP_SCOPE_PRIVATE
RFC1918 (10/8, 172.16/12, 192.168/16) / ULA fc00::/7.
proto_bool protocore_ip_is_v4_mapped(const protocore_ip *ip)
Parse an IPv4 or IPv6 textual address (RFC 4291 §2.2) into out.
void protocore_ip_classify(uint8_t *work)
IpVars IpV
The operands and the outcome.
void protocore_ip_equal(uint8_t *work)
void protocore_ip_format(uint8_t *work)
True if ip is empty (PROTOCORE_IP_NONE) or the all-zero unspecified address (0.0.0....
char * buf
where a format writes
const char * text
the textual address a parse reads
uint8_t prefix_len
the prefix length a match tests to
size_t cap
how much room that has
const protocore_ip * b
the second address a compare or a prefix test reads
protocore_ip * out
where a parse lands its result
const protocore_ip * ip
the address a call reads
void(*const parse)(uint8_t *work)
A v4 or v6 address in network (big-endian) byte order.
uint8_t bytes[16]
network order; v4 uses the first 4
protocore_ip_family family
address family tag
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS