|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
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 PROTOCORE_BEGIN_DECLS enum PROTO_ENUM_PACKED | protocore_ip_family |
| Address family tag. | |
| typedef enum PROTO_ENUM_PACKED | protocore_ip_scope |
| Address scope, in rough order of reachability (used for allow/deny policy + logging). | |
| typedef struct protocore_ip | protocore_ip |
| A v4 or v6 address in network (big-endian) byte order. | |
Enumerations | |
| enum | PROTO_ENUM_PACKED { PROTOCORE_IP_NONE = 0 , PROTOCORE_IP_V4 = 4 , PROTOCORE_IP_V6 = 6 , 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 family tag. More... | |
| enum | PROTO_ENUM_PACKED { PROTOCORE_IP_NONE = 0 , PROTOCORE_IP_V4 = 4 , PROTOCORE_IP_V6 = 6 , 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). More... | |
Functions | |
| proto_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 (uint8_t *work) |
| void | protocore_ip_format (uint8_t *work) |
| void | protocore_ip_classify (uint8_t *work) |
| void | protocore_ip_equal (uint8_t *work) |
| void | protocore_ip_is_unspecified (uint8_t *work) |
| void | protocore_ip_prefix_match (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 PROTOCORE_BEGIN_DECLS enum PROTO_ENUM_PACKED protocore_ip_family |
Address family tag.
| typedef enum PROTO_ENUM_PACKED protocore_ip_scope |
Address scope, in rough order of reachability (used for allow/deny policy + logging).
| typedef struct protocore_ip protocore_ip |
A v4 or v6 address in network (big-endian) byte order.
| enum PROTO_ENUM_PACKED |
Address family tag.
| enum PROTO_ENUM_PACKED |
Address scope, in rough order of reachability (used for allow/deny policy + logging).
| proto_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 | ( | uint8_t * | work | ) |
| void protocore_ip_format | ( | uint8_t * | work | ) |
| void protocore_ip_classify | ( | uint8_t * | work | ) |
| void protocore_ip_equal | ( | uint8_t * | work | ) |
| void protocore_ip_is_unspecified | ( | uint8_t * | work | ) |
| void protocore_ip_prefix_match | ( | uint8_t * | work | ) |
|
extern |
The operands and the outcome.