ladybird/Kernel/Net/LoopbackAdapter.cpp
Andreas Kling 718bea73b3 Kernel: Add a LoopbackAdapter for talking to yourself via 127.0.0.1.
Choosing adapter for transmit is done by adapter_for_route_to(IPv4Address).
This is just hard-coded logic right now but can be expanded to support a
proper routing table.

Also start moving kernel networking code into Kernel/Net/.
2019-04-02 15:46:44 +02:00

24 lines
471 B
C++

#include <Kernel/Net/LoopbackAdapter.h>
LoopbackAdapter& LoopbackAdapter::the()
{
static LoopbackAdapter* the;
if (!the)
the = new LoopbackAdapter;
return *the;
}
LoopbackAdapter::LoopbackAdapter()
{
set_ipv4_address({ 127, 0, 0, 1 });
}
LoopbackAdapter::~LoopbackAdapter()
{
}
void LoopbackAdapter::send_raw(const byte* data, int size)
{
dbgprintf("LoopbackAdapter: Sending %d byte(s) to myself.\n", size);
did_receive(data, size);
}