Replace sorted_list/vector with callback_list doubly-linked list for timers and frame callbacks
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "ipv4.h"
|
||||
#include "span_writer.h"
|
||||
#include "msgpack.h"
|
||||
#include "callback_list.h"
|
||||
|
||||
struct net_state {
|
||||
eth::mac_addr mac;
|
||||
@@ -15,11 +16,19 @@ struct net_state {
|
||||
using net_handler = std::function<void(std::span<const uint8_t> payload,
|
||||
std::function<void(std::span<const uint8_t>)> send)>;
|
||||
|
||||
using net_frame_callback = std::function<void(std::span<const uint8_t> frame)>;
|
||||
using net_frame_callback = std::function<bool(std::span<const uint8_t> frame)>;
|
||||
|
||||
struct frame_callback_entry {
|
||||
net_frame_callback fn;
|
||||
};
|
||||
|
||||
using frame_cb_list = callback_list<frame_callback_entry, 16>;
|
||||
using frame_cb_handle = frame_cb_list::node*;
|
||||
|
||||
bool net_init();
|
||||
const net_state& net_get_state();
|
||||
void net_set_handler(net_handler handler);
|
||||
void net_add_frame_callback(net_frame_callback cb);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user