26#ifndef PROTOCORE_PHYSICAL_H
27#define PROTOCORE_PHYSICAL_H
39#ifndef PROTOCORE_PHYSICAL_HAS_BACKEND
40#define PROTOCORE_PHYSICAL_HAS_BACKEND 1
220#if PROTOCORE_PHYSICAL_HAS_BACKEND && !PROTOCORE_VENDOR_ESP
229proto_bool protocore_phy_mock_deliver(
const uint8_t *frame, uint16_t len, int8_t rssi, uint8_t channel);
248#define PROTOCORE_IF_NONE (-1)
353 void (*
const wifi_init)(uint8_t *work);
355 void (*
const wifi_radio_init)(uint8_t *work);
356 void (*
const wifi_ap_init)(uint8_t *work);
357 void (*
const wifi_ssid)(uint8_t *work);
358 void (*
const wifi_channel)(uint8_t *work);
359 void (*
const wifi_rssi)(uint8_t *work);
360 void (*
const wifi_ap_ip)(uint8_t *work);
361 void (*
const wifi_mac)(uint8_t *work);
362 void (*
const eth_init)(uint8_t *work);
364 void (*
const ip6_init)(uint8_t *work);
365 void (*
const ip6_global)(uint8_t *work);
366 void (*
const ip6_ready)(uint8_t *work);
367 void (*
const egress)(uint8_t *work);
368 void (*
const egress_ip)(uint8_t *work);
369 void (*
const egress_mac)(uint8_t *work);
370 void (*
const classify_ip)(uint8_t *work);
371 void (*
const iface_add)(uint8_t *work);
372 void (*
const iface_reset)(uint8_t *work);
373 void (*
const iface_present)(uint8_t *work);
374 void (*
const iface_kind)(uint8_t *work);
375 void (*
const iface_at)(uint8_t *work);
376 void (*
const iface_count)(uint8_t *work);
377 void (*
const iface_send)(uint8_t *work);
412static const PhysicalNs Physical __attribute__((unused)) = {
enum PROTO_ENUM_PACKED protocore_if_kind
What an interface is, and the filter that selects one.
PROTO_ENUM_PACKED
Application protocol spoken on a listener port or connection slot.
Layer 3 (Network) - a family-tagged IP address (IPv4 or IPv6) with RFC-faithful text parsing,...
protocore_if_kind protocore_net_classify_ip(uint32_t egress_ip, uint32_t sta_ip, uint32_t ap_ip)
Map a live default-route IPv4 to the interface it belongs to.
uint8_t protocore_net_channel(void)
Station channel (1..14), or 0 when not associated.
proto_bool init_wifi_radio_physical(uint8_t channel)
Start the radio in station mode without associating.
void protocore_physical_classify_ip(uint8_t *work)
proto_bool net_global_ipv6(protocore_ip *out)
The interface's global unicast IPv6 address (RFC 4291 sec 2.5.4).
proto_bool(* protocore_if_send_fn)(uint8_t if_id, const uint8_t *data, uint16_t len, void *ctx)
Put len octets on interface if_id.
void protocore_physical_iface_kind(uint8_t *work)
void protocore_physical_wifi_ssid(uint8_t *work)
int8_t protocore_net_rssi(void)
Station link RSSI in dBm, or 0 when not associated.
PhysicalVars PhysicalV
The operands and the outcome.
void protocore_physical_iface_reset(uint8_t *work)
proto_bool init_eth_physical(void)
Start a wired Ethernet link (PROTOCORE_ENABLE_ETHERNET).
proto_bool eth_ready(void)
True when the wired link is up and holds an IPv4 address.
void protocore_physical_ip6_init(uint8_t *work)
void protocore_physical_wifi_init(uint8_t *work)
size_t protocore_net_ssid(char *out, size_t cap)
Copy the associated SSID into out, null-terminated.
void protocore_physical_wifi_ready(uint8_t *work)
proto_bool init_ipv6_physical(void)
Enable dual IP layer operation on the WiFi interface (RFC 4213 sec 2, PROTOCORE_ENABLE_IPV6).
void protocore_physical_wifi_ap_ip(uint8_t *work)
void protocore_physical_wifi_channel(uint8_t *work)
uint8_t * protocore_physical_span(void)
The PROTOCORE_PHYSICAL_BORROW bytes this module's state lives in.
uint32_t protocore_net_egress_ip(void)
IPv4 of the current default-route interface, network byte order (RFC 791 app. B), 0 if none.
void protocore_physical_iface_add(uint8_t *work)
void protocore_physical_iface_count(uint8_t *work)
proto_bool protocore_net_egress_mac(uint8_t out[6])
Copy the hardware address of the current default-route interface into out (6 octets).
proto_bool protocore_net_mac(uint8_t out[6])
Copy the 802.11 station hardware address into out (6 octets, RFC 826 ar$hln = 6).
proto_bool protocore_phy_tx_power_set(int8_t dbm)
Cap transmit power.
proto_bool protocore_phy_monitor_begin(uint8_t channel, protocore_phy_frame_fn cb)
Enter monitor mode on channel, delivering frames to cb.
PROTOCORE_BEGIN_DECLS proto_bool init_wifi_physical(const char *ssid, const char *password)
Start an 802.11 station join to an access point.
protocore_if_kind protocore_net_egress(void)
Which interface carries outbound traffic (RFC 1122 sec 3.3.1.2).
void protocore_phy_monitor_set_channel(uint8_t channel)
Retune monitor mode to channel.
proto_bool wifi_ready(void)
True when the station link is associated and holds an IPv4 address.
uint32_t protocore_net_ap_ip(void)
softAP IPv4, network byte order, or 0 when the softAP is down.
void protocore_physical_wifi_rssi(uint8_t *work)
@ PROTOCORE_PHY_PS_NONE
Radio always on: lowest latency, highest average draw.
@ PROTOCORE_PHY_PS_MAX_MODEM
Wake on a longer listen interval: lowest draw, highest latency.
@ PROTOCORE_PHY_PS_MIN_MODEM
Wake on every DTIM beacon.
void protocore_physical_egress_mac(uint8_t *work)
void protocore_physical_wifi_radio_init(uint8_t *work)
void protocore_physical_eth_init(uint8_t *work)
protocore_phy_ps protocore_phy_ps_get(void)
The active power-save mode (PROTOCORE_PHY_PS_NONE when unsupported).
enum PROTO_ENUM_PACKED protocore_phy_ps
Radio power-save mode, in the library's own vocabulary (IEEE 802.11 power management).
void protocore_physical_ip6_global(uint8_t *work)
void protocore_physical_eth_ready(uint8_t *work)
void protocore_physical_iface_at(uint8_t *work)
void protocore_physical_egress(uint8_t *work)
void protocore_physical_wifi_mac(uint8_t *work)
void protocore_physical_iface_send(uint8_t *work)
void protocore_physical_egress_ip(uint8_t *work)
void(* protocore_phy_frame_fn)(const uint8_t *frame, uint16_t len, int8_t rssi, uint8_t channel)
One received frame, delivered in neutral terms.
void protocore_physical_iface_present(uint8_t *work)
void protocore_phy_monitor_end(void)
Leave monitor mode.
void protocore_physical_wifi_ap_init(uint8_t *work)
proto_bool protocore_ipv6_ready(void)
True once a global unicast IPv6 address is configured.
proto_bool protocore_phy_ps_set(protocore_phy_ps mode)
Apply a power-save mode. False when there is no radio backend.
void protocore_physical_ip6_ready(uint8_t *work)
proto_bool init_wifi_ap_physical(const char *ssid, const char *password)
Start a softAP, with AP and station coexistence so a station link runs alongside it.
What names an interface in the registry, and the frame a send puts on it.
uint8_t id
the interface a call acts on
const uint8_t * data
the frame a send puts on the wire
void * ctx
what that callback is handed back
uint16_t len
its length in octets
uint8_t i
the registry row a lookup names
protocore_if_send_fn send
how octets reach the interface being registered
protocore_if_kind kind
what the interface being registered is
void(*const wifi_init)(uint8_t *work)
Where a readout copies to.
uint8_t * mac
receives a 6-octet hardware address (RFC 826 ar$hln = 6)
size_t cap
how much room text has
protocore_ip * ip6
receives the global unicast IPv6 address (RFC 4291 sec 2.5.4)
char * text
receives the SSID, null-terminated
What the egress classifier judges: the live route and the two WiFi addresses.
uint32_t egress_ip
default-route IPv4, network byte order (RFC 791 app. B); 0 if no route
uint32_t ap_ip
softAP IPv4, network byte order; 0 if the softAP is down
uint32_t sta_ip
station IPv4, network byte order; 0 if not associated
protocore_if_kind if_kind
What an 802.11 bring-up takes: the station join, the softAP, and the radio-only start.
uint8_t channel
channel a radio-only start pins (1..14); 0 leaves it to a capture layer
const char * ssid
SSID a join or a softAP names (IEEE 802.11-2020 9.4.2.2, <= 32 octets)
const char * password
WPA2 passphrase; "" opens the softAP.
A v4 or v6 address in network (big-endian) byte order.
#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