net::/ipv4:: namespace, mac/addr filter framework with default filters, dlog on registry overflow
This commit is contained in:
@@ -6,22 +6,28 @@
|
||||
#include "span_writer.h"
|
||||
#include "callback_list.h"
|
||||
|
||||
struct net_state {
|
||||
namespace net {
|
||||
|
||||
struct state {
|
||||
eth::mac_addr mac;
|
||||
ipv4::ip4_addr ip;
|
||||
};
|
||||
|
||||
using net_frame_callback = bool (*)(std::span<const uint8_t> frame);
|
||||
using frame_callback = bool (*)(std::span<const uint8_t> frame);
|
||||
|
||||
using frame_cb_list = callback_list<net_frame_callback, 16>;
|
||||
using frame_cb_list = callback_list<frame_callback, 16>;
|
||||
using frame_cb_handle = frame_cb_list::node*;
|
||||
|
||||
using ethertype_handler = void (*)(std::span<const uint8_t> frame, span_writer& tx);
|
||||
using mac_filter = bool (*)(const eth::mac_addr& dst);
|
||||
|
||||
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<uint8_t> tx);
|
||||
void net_send_raw(std::span<const uint8_t> data);
|
||||
void net_register_ethertype(uint16_t ethertype_be, ethertype_handler fn);
|
||||
bool init();
|
||||
const state& get_state();
|
||||
frame_cb_handle add_frame_callback(frame_callback cb);
|
||||
void remove_frame_callback(frame_cb_handle h);
|
||||
void poll(std::span<uint8_t> tx);
|
||||
void send_raw(std::span<const uint8_t> data);
|
||||
void register_ethertype(uint16_t ethertype_be, ethertype_handler fn);
|
||||
void register_mac_filter(mac_filter fn);
|
||||
|
||||
} // namespace net
|
||||
|
||||
Reference in New Issue
Block a user