#pragma once #include #include #include "eth.h" #include "ipv4.h" #include "span_writer.h" #include "callback_list.h" struct net_state { eth::mac_addr mac; ipv4::ip4_addr ip; }; using net_frame_callback = bool (*)(std::span frame); using frame_cb_list = callback_list; using frame_cb_handle = frame_cb_list::node*; using ethertype_handler = void (*)(std::span frame, span_writer& tx); inline constexpr uint16_t PICOMAP_PORT_BE = __builtin_bswap16(28781); bool net_init(); const net_state& net_get_state(); frame_cb_handle net_add_frame_callback(net_frame_callback cb); void net_remove_frame_callback(frame_cb_handle h); void net_poll(std::span tx); void net_send_raw(std::span data); void net_register_ethertype(uint16_t ethertype_be, ethertype_handler fn);