mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
NetworkAdapter: Use a ByteBuffer instead of kmalloc/kfree in send().
This commit is contained in:
parent
60db082fdd
commit
7bcd386338
Notes:
sideshowbarker
2024-07-19 15:04:29 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7bcd3863382
1 changed files with 2 additions and 2 deletions
|
@ -41,13 +41,13 @@ NetworkAdapter::~NetworkAdapter()
|
|||
void NetworkAdapter::send(const MACAddress& destination, const ARPPacket& packet)
|
||||
{
|
||||
int size_in_bytes = sizeof(EthernetFrameHeader) + sizeof(ARPPacket);
|
||||
auto* eth = (EthernetFrameHeader*)kmalloc(size_in_bytes);
|
||||
auto buffer = ByteBuffer::create_zeroed(size_in_bytes);
|
||||
auto* eth = (EthernetFrameHeader*)buffer.pointer();
|
||||
eth->set_source(mac_address());
|
||||
eth->set_destination(destination);
|
||||
eth->set_ether_type(EtherType::ARP);
|
||||
memcpy(eth->payload(), &packet, sizeof(ARPPacket));
|
||||
send_raw((byte*)eth, size_in_bytes);
|
||||
kfree(eth);
|
||||
}
|
||||
|
||||
void NetworkAdapter::send_ipv4(const MACAddress& destination_mac, const IPv4Address& destination_ipv4, IPv4Protocol protocol, ByteBuffer&& payload)
|
||||
|
|
Loading…
Reference in a new issue