mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
Kernel: More work on Ethernet support.
This commit is contained in:
parent
97664fad60
commit
1678ac69ef
8 changed files with 62 additions and 9 deletions
|
@ -1,12 +1,23 @@
|
|||
#include <Kernel/NetworkAdapter.h>
|
||||
#include <Kernel/StdLib.h>
|
||||
#include <Kernel/EthernetFrameHeader.h>
|
||||
#include <Kernel/kmalloc.h>
|
||||
|
||||
NetworkAdapter::NetworkAdapter()
|
||||
{
|
||||
memset(&m_mac_address, 0, sizeof(m_mac_address));
|
||||
}
|
||||
|
||||
NetworkAdapter::~NetworkAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
void NetworkAdapter::send(const MACAddress& destination, const ARPPacket& packet)
|
||||
{
|
||||
int size_in_bytes = sizeof(EthernetFrameHeader) + sizeof(ARPPacket) + 4;
|
||||
auto* eth = (EthernetFrameHeader*)kmalloc(size_in_bytes);
|
||||
eth->set_source(mac_address());
|
||||
eth->set_destination(destination);
|
||||
memcpy(eth->payload(), &packet, sizeof(ARPPacket));
|
||||
send_raw((byte*)eth, size_in_bytes);
|
||||
kfree(eth);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue