merge net into eth lib; ipv4 owns its IP via ipv4::init/get_ip; drop state struct in favor of eth::get_mac/ipv4::get_ip

This commit is contained in:
Ian Gulliver
2026-05-01 11:03:16 -07:00
parent cc1448d6a2
commit fceae27f10
17 changed files with 149 additions and 148 deletions

View File

@@ -1,7 +1,7 @@
#include "icmp.h"
#include <cstring>
#include "eth.h"
#include "ipv4.h"
#include "net.h"
#include "parse_buffer.h"
#include "prepend_buffer.h"
@@ -24,7 +24,6 @@ void handle(std::span<const uint8_t> frame, span_writer& tx) {
if (!icmp_pkt) return;
if (icmp_pkt->type != 8) return;
const auto& ns = net::get_state();
prepend_buffer<4096> buf;
memcpy(buf.append(icmp_len), pb.remaining().data() - sizeof(echo), icmp_len);
@@ -33,8 +32,8 @@ void handle(std::span<const uint8_t> frame, span_writer& tx) {
reply->checksum = 0;
reply->checksum = ipv4::checksum(reply, icmp_len);
ipv4::prepend(buf, eth_hdr->src, ns.mac, ns.ip, ip->src, 1, icmp_len);
net::send_raw(buf.span());
ipv4::prepend(buf, eth_hdr->src, eth::get_mac(), ipv4::get_ip(), ip->src, 1, icmp_len);
eth::send_raw(buf.span());
}
__attribute__((constructor))