net::/ipv4:: namespace, mac/addr filter framework with default filters, dlog on registry overflow

This commit is contained in:
Ian Gulliver
2026-05-01 10:15:54 -07:00
parent ca624e0e70
commit b82c038091
12 changed files with 216 additions and 113 deletions

View File

@@ -4,6 +4,7 @@
#include "ipv4.h"
#include "net.h"
#include "parse_buffer.h"
#include "debug_log.h"
namespace udp {
@@ -15,8 +16,11 @@ static std::array<port_entry, 8> port_handlers;
static size_t port_handler_count = 0;
void register_port(uint16_t port_be, port_handler fn) {
if (port_handler_count < port_handlers.size())
port_handlers[port_handler_count++] = {port_be, fn};
if (port_handler_count >= port_handlers.size()) {
dlogf("udp::register_port overflow: port=%u dropped", __builtin_bswap16(port_be));
return;
}
port_handlers[port_handler_count++] = {port_be, fn};
}
void handle(std::span<const uint8_t> frame, span_writer& tx) {