Add IGMP, prepend_buffer/parse_buffer, split UDP header, discovery tests, test all

This commit is contained in:
Ian Gulliver
2026-04-11 09:04:55 +09:00
parent e486f6501a
commit a6225faa2b
17 changed files with 582 additions and 183 deletions

View File

@@ -21,10 +21,20 @@ void handle(std::span<const uint8_t> frame, span_writer& tx,
eth::mac_addr our_mac, ipv4::ip4_addr our_ip,
std::function<void(std::span<const uint8_t>)> send_raw);
size_t build_echo_request(std::span<uint8_t> buf,
template <typename Buf>
void prepend_echo_request(Buf& buf,
eth::mac_addr src_mac, ipv4::ip4_addr src_ip,
eth::mac_addr dst_mac, ipv4::ip4_addr dst_ip,
uint16_t id, uint16_t seq);
uint16_t id, uint16_t seq) {
auto* e = buf.template prepend<echo>();
e->type = 8;
e->code = 0;
e->checksum = 0;
e->id = id;
e->seq = seq;
e->checksum = ipv4::checksum(e, sizeof(echo));
ipv4::prepend(buf, dst_mac, src_mac, src_ip, dst_ip, 1, sizeof(echo));
}
bool parse_echo_reply(std::span<const uint8_t> frame, ipv4::ip4_addr& src_ip, uint16_t expected_id);