Drop send_raw parameter threading: arp/icmp/igmp/ipv4 call net_send_raw directly

This commit is contained in:
Ian Gulliver
2026-04-17 14:35:10 -07:00
parent cdc113285a
commit e2daf04bed
10 changed files with 30 additions and 45 deletions

View File

@@ -1,5 +1,4 @@
#include "dispatch.h"
#include <unordered_map>
#include "pico/stdlib.h"
#include "wire.h"
#include "timer_queue.h"
@@ -12,7 +11,7 @@ static timer_queue timers;
static void igmp_reannounce() {
auto& ns = net_get_state();
igmp::send_all_reports(ns.mac, ns.ip, net_send_raw);
igmp::send_all_reports(ns.mac, ns.ip);
dispatch_schedule_ms(60000, igmp_reannounce);
}
@@ -33,7 +32,7 @@ bool dispatch_cancel_timer(timer_handle h) {
}
[[noreturn]] void dispatch_run(std::span<const handler_entry> handlers) {
std::unordered_map<int8_t, handler_fn> handler_map;
std::array<handler_fn, 128> handler_map{};
for (auto& entry : handlers) {
handler_map[entry.type_id] = entry.handle;
}
@@ -41,13 +40,12 @@ bool dispatch_cancel_timer(timer_handle h) {
static std::array<uint8_t, 4096> tx_buf;
auto dispatch_msg = [&](const DecodedMessage& msg, send_fn send) {
auto it = handler_map.find(msg.type_id);
if (it == handler_map.end()) {
if (msg.type_id < 0 || !handler_map[msg.type_id]) {
dlogf("dispatch: unknown type_id %d", msg.type_id);
return;
}
responder resp{msg.message_id, std::move(send)};
it->second(resp, msg.payload);
handler_map[msg.type_id](resp, msg.payload);
};
net_set_handler([&](std::span<const uint8_t> payload,