ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
net_addr.h File Reference

Layer 4 (Transport) - the stack's address type, as the library's protocore_ip. More...

Go to the source code of this file.

Classes

struct  NetAddrInArgs
 Inbound: the stack's address, and the library address it lands in. More...
struct  NetAddrOutArgs
 Outbound: the library address, and the stack address it lands in. More...
struct  NetAddrNs

Functions

void protocore_net_addr_to_ip (const protocore_net_ip *a, protocore_ip *out)
 Read the stack's address into out, network-order bytes preserved.
embed_bool protocore_net_addr_from_ip (const protocore_ip *a, protocore_net_ip *out)
 Write a into the stack's own address type; false when it cannot be represented.

Variables

NetAddrNs NetAddr
 The one symbol this module exports.

Detailed Description

Layer 4 (Transport) - the stack's address type, as the library's protocore_ip.

The stack keeps a peer address in its own family-tagged union, laid out however the vendor chose. Everything above the transport carries a protocore_ip: a one-byte family tag and sixteen bytes in network order, the same on every target. TCP needs that mapping on accept and on the per-slot address accessor; UDP needs it once per received datagram. One conversion serves both, so it sits beside them rather than inside either.

RFC 9293 sec 3.9.2: "Any lower-level protocol will have to provide the source address, destination address, and protocol fields." These two convert between the form the lower-level module states them in and the family-tagged form every layer above reads.

The address bytes are read out of the vendor value byte by byte rather than shifted out of it. A shift reads the value's arithmetic, which is the host's byte order. The stack holds the address in network order, so the bytes are the address and the number is not.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file net_addr.h.

Function Documentation

◆ protocore_net_addr_to_ip()

void protocore_net_addr_to_ip ( const protocore_net_ip * a,
protocore_ip * out )

Read the stack's address into out, network-order bytes preserved.

◆ protocore_net_addr_from_ip()

embed_bool protocore_net_addr_from_ip ( const protocore_ip * a,
protocore_net_ip * out )

Write a into the stack's own address type; false when it cannot be represented.

Variable Documentation

◆ NetAddr

NetAddrNs NetAddr
extern

The one symbol this module exports.