Drop handle_udp parameter threading: ipv4::handle calls net_handle_udp directly
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <functional>
|
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "eth.h"
|
#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<const uint8_t> frame, span_writer& tx,
|
void handle(std::span<const uint8_t> frame, span_writer& tx,
|
||||||
eth::mac_addr our_mac, ip4_addr our_ip, ip4_addr subnet_broadcast,
|
eth::mac_addr our_mac, ip4_addr our_ip, ip4_addr subnet_broadcast);
|
||||||
std::function<void(std::span<const uint8_t>, span_writer&)> handle_udp);
|
|
||||||
|
|
||||||
} // namespace ipv4
|
} // namespace ipv4
|
||||||
|
|||||||
@@ -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_remove_frame_callback(frame_cb_handle h);
|
||||||
void net_poll(std::span<uint8_t> tx);
|
void net_poll(std::span<uint8_t> tx);
|
||||||
void net_send_raw(std::span<const uint8_t> data);
|
void net_send_raw(std::span<const uint8_t> data);
|
||||||
|
void net_handle_udp(std::span<const uint8_t> frame, span_writer& tx);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "ipv4.h"
|
#include "ipv4.h"
|
||||||
#include "icmp.h"
|
#include "icmp.h"
|
||||||
#include "igmp.h"
|
#include "igmp.h"
|
||||||
|
#include "net.h"
|
||||||
#include "parse_buffer.h"
|
#include "parse_buffer.h"
|
||||||
|
|
||||||
namespace ipv4 {
|
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<const uint8_t> frame, span_writer& tx,
|
void handle(std::span<const uint8_t> frame, span_writer& tx,
|
||||||
eth::mac_addr our_mac, ip4_addr our_ip, ip4_addr subnet_broadcast,
|
eth::mac_addr our_mac, ip4_addr our_ip, ip4_addr subnet_broadcast) {
|
||||||
std::function<void(std::span<const uint8_t>, span_writer&)> handle_udp) {
|
|
||||||
parse_buffer pb(frame);
|
parse_buffer pb(frame);
|
||||||
pb.consume<eth::header>();
|
pb.consume<eth::header>();
|
||||||
auto* ip = pb.consume<header>();
|
auto* ip = pb.consume<header>();
|
||||||
@@ -47,7 +47,7 @@ void handle(std::span<const uint8_t> frame, span_writer& tx,
|
|||||||
case 17:
|
case 17:
|
||||||
if (!ip_match(ip->dst, our_ip, subnet_broadcast))
|
if (!ip_match(ip->dst, our_ip, subnet_broadcast))
|
||||||
return;
|
return;
|
||||||
handle_udp(frame, tx);
|
net_handle_udp(frame, tx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ void net_send_raw(std::span<const uint8_t> data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_udp(std::span<const uint8_t> frame, span_writer& tx) {
|
void net_handle_udp(std::span<const uint8_t> frame, span_writer& tx) {
|
||||||
parse_buffer pb(frame);
|
parse_buffer pb(frame);
|
||||||
auto* eth_hdr = pb.consume<eth::header>();
|
auto* eth_hdr = pb.consume<eth::header>();
|
||||||
auto* ip = pb.consume<ipv4::header>();
|
auto* ip = pb.consume<ipv4::header>();
|
||||||
@@ -84,7 +84,7 @@ static void process_frame(std::span<const uint8_t> frame, span_writer& tx) {
|
|||||||
arp::handle(frame, tx, state.mac, state.ip);
|
arp::handle(frame, tx, state.mac, state.ip);
|
||||||
break;
|
break;
|
||||||
case eth::ETH_IPV4:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user