Layer 3 (Network) - a family-tagged IP address (IPv4 or IPv6) with RFC-faithful text parsing, canonical formatting, and scope classification. More...
#include "protocore_config.h"Go to the source code of this file.
Classes | |
| struct | protocore_ip |
| A v4 or v6 address in network (big-endian) byte order. More... | |
| struct | IpArgs |
True if ip is empty (PROTOCORE_IP_NONE) or the all-zero unspecified address (0.0.0.0 / ::). More... | |
| struct | IpVars |
| struct | IpNs |
| The entries. More... | |
Macros | |
| #define | PROTOCORE_IP_STR_MAX 46 |
| Longest text an IpNs::format can produce, including the NUL (RFC 5952 v4-mapped). | |
Typedefs | |
| typedef struct protocore_ip | protocore_ip |
| A v4 or v6 address in network (big-endian) byte order. | |
Functions | |
| EMBED_BEGIN_DECLS | EMBED_ENUM_BYTE (protocore_ip_family, PROTOCORE_IP_NONE=0, PROTOCORE_IP_V4=4, PROTOCORE_IP_V6=6,) |
| Address family tag. | |
| EMBED_ENUM_BYTE (protocore_ip_scope, PROTOCORE_IP_SCOPE_UNSPECIFIED=0, PROTOCORE_IP_SCOPE_LOOPBACK, PROTOCORE_IP_SCOPE_LINK_LOCAL, PROTOCORE_IP_SCOPE_PRIVATE, PROTOCORE_IP_SCOPE_MULTICAST, PROTOCORE_IP_SCOPE_GLOBAL,) | |
| Address scope, in rough order of reachability (used for allow/deny policy + logging). | |
| embed_bool | protocore_ip_is_v4_mapped (const protocore_ip *ip) |
Parse an IPv4 or IPv6 textual address (RFC 4291 §2.2) into out. | |
| 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). | |
| 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. | |
| 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). | |
| void | protocore_ip_parse (const uint8_t *work) |
| void | protocore_ip_format (const uint8_t *work) |
| void | protocore_ip_classify (const uint8_t *work) |
| void | protocore_ip_equal (const uint8_t *work) |
| void | protocore_ip_is_unspecified (const uint8_t *work) |
| void | protocore_ip_prefix_match (const uint8_t *work) |
Variables | |
| IpVars | IpV |
| The operands and the outcome. | |
Layer 3 (Network) - a family-tagged IP address (IPv4 or IPv6) with RFC-faithful text parsing, canonical formatting, and scope classification.
One representation for both address families so the rest of the stack can carry a peer address without caring whether it is v4 or v6. The address bytes are stored in network (big-endian, left-to-right) order: a v4 address uses bytes[0..3], a v6 address bytes[0..15].
Pure and host-testable - no lwIP, no Arduino, no heap, no stdlib parsing. The parser implements RFC 4291 §2.2 text forms (dotted-quad v4; v6 with :: zero-compression and the embedded-v4 ::ffff:a.b.c.d tail); the formatter emits the RFC 5952 canonical form (lower-case, no leading zeros, the longest zero run compressed to ::, v4-mapped shown as dotted). ESP32 dual-stack bring-up (enabling IPv6 on the netif) lives in the physical layer behind PROTOCORE_ENABLE_IPV6. The TCP/UDP listeners already bind IPADDR_TYPE_ANY, so the server accepts v6 connections the moment the interface has a v6 address.
Definition in file ip.h.
| #define PROTOCORE_IP_STR_MAX 46 |
Longest text an IpNs::format can produce, including the NUL (RFC 5952 v4-mapped).
| typedef struct protocore_ip protocore_ip |
A v4 or v6 address in network (big-endian) byte order.
| EMBED_BEGIN_DECLS EMBED_ENUM_BYTE | ( | protocore_ip_family | , |
| PROTOCORE_IP_NONE | = 0, | ||
| PROTOCORE_IP_V4 | = 4, | ||
| PROTOCORE_IP_V6 | = 6 ) |
Address family tag.
| EMBED_ENUM_BYTE | ( | protocore_ip_scope | , |
| PROTOCORE_IP_SCOPE_UNSPECIFIED | = 0, | ||
| PROTOCORE_IP_SCOPE_LOOPBACK | , | ||
| PROTOCORE_IP_SCOPE_LINK_LOCAL | , | ||
| PROTOCORE_IP_SCOPE_PRIVATE | , | ||
| PROTOCORE_IP_SCOPE_MULTICAST | , | ||
| PROTOCORE_IP_SCOPE_GLOBAL | ) |
Address scope, in rough order of reachability (used for allow/deny policy + logging).
| embed_bool protocore_ip_is_v4_mapped | ( | const protocore_ip * | ip | ) |
Parse an IPv4 or IPv6 textual address (RFC 4291 §2.2) into out.
out->family set to PROTOCORE_IP_V4/V6), false if s is malformed.Format ip into out as its RFC 5952 canonical text.
ip is empty or cap is too small (need up to PROTOCORE_IP_STR_MAX).Classify ip into a ::protocore_ip_scope.
True if a and b are the same family and address.
True if ip is an IPv4-mapped IPv6 address (::ffff:a.b.c.d, RFC 4291 §2.5.5.2).
| 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).
| 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.
| 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).
ip is not a v4 (or v4-mapped) address. | void protocore_ip_parse | ( | const uint8_t * | work | ) |
Referenced by protocore_ip_prefix_match().
| void protocore_ip_format | ( | const uint8_t * | work | ) |
Referenced by protocore_ip_prefix_match().
| void protocore_ip_classify | ( | const uint8_t * | work | ) |
Referenced by protocore_ip_prefix_match().
| void protocore_ip_equal | ( | const uint8_t * | work | ) |
Referenced by protocore_ip_prefix_match().
| void protocore_ip_is_unspecified | ( | const uint8_t * | work | ) |
Referenced by protocore_ip_prefix_match().
| void protocore_ip_prefix_match | ( | const uint8_t * | work | ) |
References protocore_ip_classify(), protocore_ip_equal(), protocore_ip_format(), protocore_ip_is_unspecified(), protocore_ip_parse(), and protocore_ip_prefix_match().
Referenced by protocore_ip_prefix_match().
|
extern |
The operands and the outcome.