1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

Kernel: Start adding IPv4 support, starting with ICMP echo messages.

This doesn't work correctly yet, but it's getting nice enough to commit.
This commit is contained in:
Andreas Kling 2019-03-12 04:11:20 +01:00
parent d5dbb602b8
commit 5bd9844dd6
6 changed files with 237 additions and 0 deletions

View file

@ -24,6 +24,19 @@ void NetworkAdapter::send(const MACAddress& destination, const ARPPacket& packet
kfree(eth);
}
void NetworkAdapter::send_ipv4(const MACAddress& destination, const void* packet, size_t packet_size)
{
size_t size_in_bytes = sizeof(EthernetFrameHeader) + packet_size + sizeof(EthernetFrameCheckSequence);
auto* eth = (EthernetFrameHeader*)kmalloc(size_in_bytes);
eth->set_source(mac_address());
eth->set_destination(destination);
eth->set_ether_type(EtherType::IPv4);
memcpy(eth->payload(), packet, packet_size);
send_raw((byte*)eth, size_in_bytes);
kfree(eth);
}
void NetworkAdapter::did_receive(const byte* data, int length)
{
InterruptDisabler disabler;