From 40f7fb5941b424ac6e3f69d6cf89f4431ce9b680 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 17 Apr 2026 14:55:09 -0700 Subject: [PATCH] Drop handle_udp parameter threading: ipv4::handle calls net_handle_udp directly --- firmware/include/ipv4.h | 4 +--- firmware/include/net.h | 1 + firmware/lib/ipv4.cpp | 6 +++--- firmware/lib/net.cpp | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/firmware/include/ipv4.h b/firmware/include/ipv4.h index 03f6b2b..98626f7 100644 --- a/firmware/include/ipv4.h +++ b/firmware/include/ipv4.h @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include "eth.h" @@ -57,7 +56,6 @@ void prepend(Buf& buf, const eth::mac_addr& dst_mac, const eth::mac_addr& src_ma } void handle(std::span frame, span_writer& tx, - eth::mac_addr our_mac, ip4_addr our_ip, ip4_addr subnet_broadcast, - std::function, span_writer&)> handle_udp); + eth::mac_addr our_mac, ip4_addr our_ip, ip4_addr subnet_broadcast); } // namespace ipv4 diff --git a/firmware/include/net.h b/firmware/include/net.h index a4bbe5d..0b485f6 100644 --- a/firmware/include/net.h +++ b/firmware/include/net.h @@ -31,3 +31,4 @@ frame_cb_handle net_add_frame_callback(net_frame_callback cb); void net_remove_frame_callback(frame_cb_handle h); void net_poll(std::span tx); void net_send_raw(std::span data); +void net_handle_udp(std::span frame, span_writer& tx); diff --git a/firmware/lib/ipv4.cpp b/firmware/lib/ipv4.cpp index b06282c..93efd2a 100644 --- a/firmware/lib/ipv4.cpp +++ b/firmware/lib/ipv4.cpp @@ -1,6 +1,7 @@ #include "ipv4.h" #include "icmp.h" #include "igmp.h" +#include "net.h" #include "parse_buffer.h" namespace ipv4 { @@ -24,8 +25,7 @@ static bool ip_match(const ip4_addr& dst, const ip4_addr& our_ip, const ip4_addr } void handle(std::span frame, span_writer& tx, - eth::mac_addr our_mac, ip4_addr our_ip, ip4_addr subnet_broadcast, - std::function, span_writer&)> handle_udp) { + eth::mac_addr our_mac, ip4_addr our_ip, ip4_addr subnet_broadcast) { parse_buffer pb(frame); pb.consume(); auto* ip = pb.consume
(); @@ -47,7 +47,7 @@ void handle(std::span frame, span_writer& tx, case 17: if (!ip_match(ip->dst, our_ip, subnet_broadcast)) return; - handle_udp(frame, tx); + net_handle_udp(frame, tx); break; } } diff --git a/firmware/lib/net.cpp b/firmware/lib/net.cpp index 26beb4c..f4884e6 100644 --- a/firmware/lib/net.cpp +++ b/firmware/lib/net.cpp @@ -28,7 +28,7 @@ void net_send_raw(std::span data) { }); } -static void handle_udp(std::span frame, span_writer& tx) { +void net_handle_udp(std::span frame, span_writer& tx) { parse_buffer pb(frame); auto* eth_hdr = pb.consume(); auto* ip = pb.consume(); @@ -84,7 +84,7 @@ static void process_frame(std::span frame, span_writer& tx) { arp::handle(frame, tx, state.mac, state.ip); break; case eth::ETH_IPV4: - ipv4::handle(frame, tx, state.mac, state.ip, IP_BROADCAST_SUBNET, handle_udp); + ipv4::handle(frame, tx, state.mac, state.ip, IP_BROADCAST_SUBNET); break; } }