#pragma once #include #include #include #include "eth.h" #include "ipv4.h" #include "span_writer.h" #include "msgpack.h" #include "callback_list.h" struct net_state { eth::mac_addr mac; ipv4::ip4_addr ip; }; using encode_fn = std::function(span_writer&)>; using send_fn = std::function; using net_handler = std::function payload, send_fn send)>; using net_frame_callback = std::function frame)>; using frame_cb_list = callback_list; using frame_cb_handle = frame_cb_list::node*; bool net_init(); const net_state& net_get_state(); void net_set_handler(net_handler handler); 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);