Split net stack into eth/arp/ipv4/icmp, deferred handler responses, ping tests
This commit is contained in:
@@ -1,19 +1,25 @@
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <functional>
|
||||
#include <span>
|
||||
#include "eth.h"
|
||||
#include "ipv4.h"
|
||||
#include "span_writer.h"
|
||||
#include "msgpack.h"
|
||||
|
||||
struct net_state {
|
||||
std::array<uint8_t, 6> mac;
|
||||
std::array<uint8_t, 4> ip;
|
||||
eth::mac_addr mac;
|
||||
ipv4::ip4_addr ip;
|
||||
};
|
||||
|
||||
using net_handler = std::function<msgpack::result<size_t>(std::span<const uint8_t> payload, span_writer &out)>;
|
||||
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)>;
|
||||
|
||||
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);
|
||||
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