Split net stack into eth/arp/ipv4/icmp, deferred handler responses, ping tests

This commit is contained in:
Ian Gulliver
2026-04-11 08:15:41 +09:00
parent 34efaeefd5
commit c35c1de76a
16 changed files with 522 additions and 330 deletions

28
firmware/include/arp.h Normal file
View File

@@ -0,0 +1,28 @@
#pragma once
#include <functional>
#include <span>
#include "eth.h"
#include "ipv4.h"
#include "span_writer.h"
namespace arp {
struct __attribute__((packed)) packet {
eth::header eth;
uint16_t htype;
uint16_t ptype;
uint8_t hlen;
uint8_t plen;
uint16_t oper;
eth::mac_addr sha;
ipv4::ip4_addr spa;
eth::mac_addr tha;
ipv4::ip4_addr tpa;
};
static_assert(sizeof(packet) == 42);
void handle(std::span<const uint8_t> frame, span_writer& tx,
eth::mac_addr our_mac, ipv4::ip4_addr our_ip,
std::function<void(std::span<const uint8_t>)> send_raw);
} // namespace arp