net::/ipv4:: namespace, mac/addr filter framework with default filters, dlog on registry overflow
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user