diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-12 04:11:20 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-12 04:11:20 +0100 |
commit | 5bd9844dd61d61bc224e5c8d76fd916dd87b9b30 (patch) | |
tree | 16565afd5be59baafbb7170a7454a5b44f099968 /Kernel/NetworkAdapter.cpp | |
parent | d5dbb602b8cfd2025095f96283bbe8fad993527b (diff) | |
download | serenity-5bd9844dd61d61bc224e5c8d76fd916dd87b9b30.zip |
Kernel: Start adding IPv4 support, starting with ICMP echo messages.
This doesn't work correctly yet, but it's getting nice enough to commit.
Diffstat (limited to 'Kernel/NetworkAdapter.cpp')
-rw-r--r-- | Kernel/NetworkAdapter.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Kernel/NetworkAdapter.cpp b/Kernel/NetworkAdapter.cpp index 75d32c7763..bac685520d 100644 --- a/Kernel/NetworkAdapter.cpp +++ b/Kernel/NetworkAdapter.cpp @@ -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; |