summaryrefslogtreecommitdiff
path: root/Kernel/Net
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-16 01:27:42 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-16 01:27:42 +0100
commita356e4815098e5398e103aa69865bd6c88f7ad36 (patch)
tree50437c6444405f12671bce7f04a8c1b10cff70f8 /Kernel/Net
parentd42f0f46616168bdff492f880b3ea432a49f7345 (diff)
downloadserenity-a356e4815098e5398e103aa69865bd6c88f7ad36.zip
Kernel: Move all code into the Kernel namespace
Diffstat (limited to 'Kernel/Net')
-rw-r--r--Kernel/Net/ARP.h4
-rw-r--r--Kernel/Net/E1000NetworkAdapter.cpp4
-rw-r--r--Kernel/Net/E1000NetworkAdapter.h4
-rw-r--r--Kernel/Net/IPv4.h4
-rw-r--r--Kernel/Net/IPv4Socket.cpp4
-rw-r--r--Kernel/Net/IPv4Socket.h4
-rw-r--r--Kernel/Net/LocalSocket.cpp4
-rw-r--r--Kernel/Net/LocalSocket.h4
-rw-r--r--Kernel/Net/LoopbackAdapter.cpp4
-rw-r--r--Kernel/Net/LoopbackAdapter.h4
-rw-r--r--Kernel/Net/NetworkAdapter.cpp4
-rw-r--r--Kernel/Net/NetworkAdapter.h4
-rw-r--r--Kernel/Net/NetworkTask.cpp4
-rw-r--r--Kernel/Net/NetworkTask.h4
-rw-r--r--Kernel/Net/RTL8139NetworkAdapter.cpp4
-rw-r--r--Kernel/Net/RTL8139NetworkAdapter.h4
-rw-r--r--Kernel/Net/Routing.cpp5
-rw-r--r--Kernel/Net/Routing.h4
-rw-r--r--Kernel/Net/Socket.cpp4
-rw-r--r--Kernel/Net/Socket.h4
-rw-r--r--Kernel/Net/TCP.h4
-rw-r--r--Kernel/Net/TCPSocket.cpp4
-rw-r--r--Kernel/Net/TCPSocket.h4
-rw-r--r--Kernel/Net/UDP.h4
-rw-r--r--Kernel/Net/UDPSocket.cpp4
-rw-r--r--Kernel/Net/UDPSocket.h4
26 files changed, 104 insertions, 1 deletions
diff --git a/Kernel/Net/ARP.h b/Kernel/Net/ARP.h
index 743ecc0fd5..37e6faa140 100644
--- a/Kernel/Net/ARP.h
+++ b/Kernel/Net/ARP.h
@@ -31,6 +31,8 @@
#include <Kernel/Net/IPv4.h>
#include <Kernel/Net/MACAddress.h>
+namespace Kernel {
+
struct ARPOperation {
enum : u16 {
Request = 1,
@@ -87,3 +89,5 @@ private:
};
static_assert(sizeof(ARPPacket) == 28);
+
+}
diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp
index 57ad91620b..169e0a8fe4 100644
--- a/Kernel/Net/E1000NetworkAdapter.cpp
+++ b/Kernel/Net/E1000NetworkAdapter.cpp
@@ -30,6 +30,8 @@
//#define E1000_DEBUG
+namespace Kernel {
+
#define REG_CTRL 0x0000
#define REG_STATUS 0x0008
#define REG_EEPROM 0x0014
@@ -420,3 +422,5 @@ void E1000NetworkAdapter::receive()
out32(REG_RXDESCTAIL, rx_current);
}
}
+
+}
diff --git a/Kernel/Net/E1000NetworkAdapter.h b/Kernel/Net/E1000NetworkAdapter.h
index f1b8667ee7..0738ccd010 100644
--- a/Kernel/Net/E1000NetworkAdapter.h
+++ b/Kernel/Net/E1000NetworkAdapter.h
@@ -31,6 +31,8 @@
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/PCI/Access.h>
+namespace Kernel {
+
class E1000NetworkAdapter final : public NetworkAdapter
, public IRQHandler {
public:
@@ -102,3 +104,5 @@ private:
WaitQueue m_wait_queue;
};
+
+}
diff --git a/Kernel/Net/IPv4.h b/Kernel/Net/IPv4.h
index 4221f3afe5..534e065c19 100644
--- a/Kernel/Net/IPv4.h
+++ b/Kernel/Net/IPv4.h
@@ -32,6 +32,8 @@
#include <AK/NetworkOrdered.h>
#include <AK/Types.h>
+namespace Kernel {
+
enum class IPv4Protocol : u16 {
ICMP = 1,
TCP = 6,
@@ -110,3 +112,5 @@ inline NetworkOrdered<u16> internet_checksum(const void* ptr, size_t count)
checksum = (checksum & 0xffff) + (checksum >> 16);
return ~checksum & 0xffff;
}
+
+}
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index 7d427941b6..c3259a051c 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -43,6 +43,8 @@
//#define IPV4_SOCKET_DEBUG
+namespace Kernel {
+
Lockable<HashTable<IPv4Socket*>>& IPv4Socket::all_sockets()
{
static Lockable<HashTable<IPv4Socket*>>* s_table;
@@ -511,3 +513,5 @@ void IPv4Socket::shut_down_for_reading()
Socket::shut_down_for_reading();
m_can_read = true;
}
+
+}
diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h
index 96650fdea2..8f45a34ad6 100644
--- a/Kernel/Net/IPv4Socket.h
+++ b/Kernel/Net/IPv4Socket.h
@@ -35,6 +35,8 @@
#include <Kernel/Net/IPv4SocketTuple.h>
#include <Kernel/Net/Socket.h>
+namespace Kernel {
+
class NetworkAdapter;
class TCPPacket;
class TCPSocket;
@@ -137,3 +139,5 @@ private:
Optional<KBuffer> m_scratch_buffer;
};
+
+}
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index c1dbbe05b0..e9ea963f9b 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -35,6 +35,8 @@
//#define DEBUG_LOCAL_SOCKET
+namespace Kernel {
+
Lockable<InlineLinkedList<LocalSocket>>& LocalSocket::all_sockets()
{
static Lockable<InlineLinkedList<LocalSocket>>* s_list;
@@ -394,3 +396,5 @@ KResult LocalSocket::chown(uid_t uid, gid_t gid)
m_prebind_gid = gid;
return KSuccess;
}
+
+}
diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h
index e989884cc2..0929b0d90f 100644
--- a/Kernel/Net/LocalSocket.h
+++ b/Kernel/Net/LocalSocket.h
@@ -30,6 +30,8 @@
#include <Kernel/DoubleBuffer.h>
#include <Kernel/Net/Socket.h>
+namespace Kernel {
+
class FileDescription;
class LocalSocket final : public Socket, public InlineLinkedListNode<LocalSocket> {
@@ -100,3 +102,5 @@ private:
LocalSocket* m_prev { nullptr };
LocalSocket* m_next { nullptr };
};
+
+}
diff --git a/Kernel/Net/LoopbackAdapter.cpp b/Kernel/Net/LoopbackAdapter.cpp
index bb32410d1c..4adfa43749 100644
--- a/Kernel/Net/LoopbackAdapter.cpp
+++ b/Kernel/Net/LoopbackAdapter.cpp
@@ -26,6 +26,8 @@
#include <Kernel/Net/LoopbackAdapter.h>
+namespace Kernel {
+
LoopbackAdapter& LoopbackAdapter::the()
{
static LoopbackAdapter* the;
@@ -50,3 +52,5 @@ void LoopbackAdapter::send_raw(const u8* data, size_t size)
dbgprintf("LoopbackAdapter: Sending %d byte(s) to myself.\n", size);
did_receive(data, size);
}
+
+}
diff --git a/Kernel/Net/LoopbackAdapter.h b/Kernel/Net/LoopbackAdapter.h
index 9bb83151d6..bf67a164b5 100644
--- a/Kernel/Net/LoopbackAdapter.h
+++ b/Kernel/Net/LoopbackAdapter.h
@@ -28,6 +28,8 @@
#include <Kernel/Net/NetworkAdapter.h>
+namespace Kernel {
+
class LoopbackAdapter final : public NetworkAdapter {
AK_MAKE_ETERNAL
public:
@@ -41,3 +43,5 @@ public:
private:
LoopbackAdapter();
};
+
+}
diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp
index ff34fe03eb..255c6698bc 100644
--- a/Kernel/Net/NetworkAdapter.cpp
+++ b/Kernel/Net/NetworkAdapter.cpp
@@ -34,6 +34,8 @@
#include <Kernel/Net/NetworkAdapter.h>
#include <LibBareMetal/StdLib.h>
+namespace Kernel {
+
static Lockable<HashTable<NetworkAdapter*>>& all_adapters()
{
static Lockable<HashTable<NetworkAdapter*>>* table;
@@ -193,3 +195,5 @@ void NetworkAdapter::set_interface_name(const StringView& basename)
builder.append('0');
m_name = builder.to_string();
}
+
+}
diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h
index 12bac4207e..4e875eb8b1 100644
--- a/Kernel/Net/NetworkAdapter.h
+++ b/Kernel/Net/NetworkAdapter.h
@@ -38,6 +38,8 @@
#include <Kernel/Net/IPv4.h>
#include <Kernel/Net/MACAddress.h>
+namespace Kernel {
+
class NetworkAdapter;
class NetworkAdapter : public RefCounted<NetworkAdapter> {
@@ -99,3 +101,5 @@ private:
u32 m_bytes_out { 0 };
u32 m_mtu { 1500 };
};
+
+}
diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp
index 0d93f2bd0e..a2fbd6a18e 100644
--- a/Kernel/Net/NetworkTask.cpp
+++ b/Kernel/Net/NetworkTask.cpp
@@ -48,6 +48,8 @@
//#define UDP_DEBUG
//#define TCP_DEBUG
+namespace Kernel {
+
static void handle_arp(const EthernetFrameHeader&, size_t frame_size);
static void handle_ipv4(const EthernetFrameHeader&, size_t frame_size);
static void handle_icmp(const EthernetFrameHeader&, const IPv4Packet&);
@@ -622,3 +624,5 @@ void handle_tcp(const IPv4Packet& ipv4_packet)
}
}
}
+
+}
diff --git a/Kernel/Net/NetworkTask.h b/Kernel/Net/NetworkTask.h
index 3f2f32548b..c126fae314 100644
--- a/Kernel/Net/NetworkTask.h
+++ b/Kernel/Net/NetworkTask.h
@@ -26,4 +26,8 @@
#pragma once
+namespace Kernel {
+
void NetworkTask_main();
+
+}
diff --git a/Kernel/Net/RTL8139NetworkAdapter.cpp b/Kernel/Net/RTL8139NetworkAdapter.cpp
index 407c42bc66..670a838b06 100644
--- a/Kernel/Net/RTL8139NetworkAdapter.cpp
+++ b/Kernel/Net/RTL8139NetworkAdapter.cpp
@@ -29,6 +29,8 @@
//#define RTL8139_DEBUG
+namespace Kernel {
+
#define REG_MAC 0x00
#define REG_MAR0 0x08
#define REG_MAR4 0x12
@@ -394,3 +396,5 @@ u32 RTL8139NetworkAdapter::in32(u16 address)
{
return IO::in32(m_io_base + address);
}
+
+}
diff --git a/Kernel/Net/RTL8139NetworkAdapter.h b/Kernel/Net/RTL8139NetworkAdapter.h
index 0f05512dfa..ad154f4db4 100644
--- a/Kernel/Net/RTL8139NetworkAdapter.h
+++ b/Kernel/Net/RTL8139NetworkAdapter.h
@@ -31,6 +31,8 @@
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/PCI/Access.h>
+namespace Kernel {
+
#define RTL8139_TX_BUFFER_COUNT 4
class RTL8139NetworkAdapter final : public NetworkAdapter
@@ -70,3 +72,5 @@ private:
u32 m_packet_buffer { 0 };
bool m_link_up { false };
};
+
+}
diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp
index cb0d2b5e13..207ce754af 100644
--- a/Kernel/Net/Routing.cpp
+++ b/Kernel/Net/Routing.cpp
@@ -30,6 +30,8 @@
//#define ROUTING_DEBUG
+namespace Kernel {
+
Lockable<HashMap<IPv4Address, MACAddress>>& arp_table()
{
static Lockable<HashMap<IPv4Address, MACAddress>>* the;
@@ -68,7 +70,6 @@ RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source)
gateway_adapter = adapter;
});
-
if (local_adapter && target == local_adapter->ipv4_address())
return { local_adapter, local_adapter->mac_address() };
@@ -161,3 +162,5 @@ RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source)
return { nullptr, {} };
}
+
+}
diff --git a/Kernel/Net/Routing.h b/Kernel/Net/Routing.h
index 11d661420d..e12276d5b1 100644
--- a/Kernel/Net/Routing.h
+++ b/Kernel/Net/Routing.h
@@ -28,6 +28,8 @@
#include <Kernel/Net/NetworkAdapter.h>
+namespace Kernel {
+
struct RoutingDecision
{
RefPtr<NetworkAdapter> adapter;
@@ -39,3 +41,5 @@ struct RoutingDecision
RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source);
Lockable<HashMap<IPv4Address, MACAddress>>& arp_table();
+
+}
diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp
index 9adfd9278a..3e279047ae 100644
--- a/Kernel/Net/Socket.cpp
+++ b/Kernel/Net/Socket.cpp
@@ -35,6 +35,8 @@
//#define SOCKET_DEBUG
+namespace Kernel {
+
KResultOr<NonnullRefPtr<Socket>> Socket::create(int domain, int type, int protocol)
{
switch (domain) {
@@ -175,3 +177,5 @@ KResult Socket::shutdown(int how)
m_shut_down_for_writing |= (how & SHUT_WR) != 0;
return KSuccess;
}
+
+}
diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h
index c74b0f8b3b..1639e79d13 100644
--- a/Kernel/Net/Socket.h
+++ b/Kernel/Net/Socket.h
@@ -35,6 +35,8 @@
#include <Kernel/Lock.h>
#include <Kernel/UnixTypes.h>
+namespace Kernel {
+
enum class ShouldBlock {
No = 0,
Yes = 1
@@ -207,3 +209,5 @@ public:
private:
RefPtr<SocketType> m_socket;
};
+
+}
diff --git a/Kernel/Net/TCP.h b/Kernel/Net/TCP.h
index daecfb1b4f..84cf2c25c7 100644
--- a/Kernel/Net/TCP.h
+++ b/Kernel/Net/TCP.h
@@ -28,6 +28,8 @@
#include <Kernel/Net/IPv4.h>
+namespace Kernel {
+
struct TCPFlags {
enum : u16 {
FIN = 0x01,
@@ -95,3 +97,5 @@ private:
};
static_assert(sizeof(TCPPacket) == 20);
+
+}
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index e31ccc0362..8f3f809cee 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -36,6 +36,8 @@
//#define TCP_SOCKET_DEBUG
+namespace Kernel {
+
void TCPSocket::for_each(Function<void(TCPSocket&)> callback)
{
LOCKER(sockets_by_tuple().lock());
@@ -465,3 +467,5 @@ void TCPSocket::close()
LOCKER(closing_sockets().lock());
closing_sockets().resource().set(tuple(), *this);
}
+
+}
diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h
index 257c3804ac..9aef25eb0c 100644
--- a/Kernel/Net/TCPSocket.h
+++ b/Kernel/Net/TCPSocket.h
@@ -32,6 +32,8 @@
#include <AK/WeakPtr.h>
#include <Kernel/Net/IPv4Socket.h>
+namespace Kernel {
+
class TCPSocket final : public IPv4Socket
, public Weakable<TCPSocket> {
public:
@@ -207,3 +209,5 @@ private:
Lock m_not_acked_lock { "TCPSocket unacked packets" };
SinglyLinkedList<OutgoingPacket> m_not_acked;
};
+
+}
diff --git a/Kernel/Net/UDP.h b/Kernel/Net/UDP.h
index a463e00387..b3cbc72ca4 100644
--- a/Kernel/Net/UDP.h
+++ b/Kernel/Net/UDP.h
@@ -28,6 +28,8 @@
#include <Kernel/Net/IPv4.h>
+namespace Kernel {
+
class [[gnu::packed]] UDPPacket
{
public:
@@ -57,3 +59,5 @@ private:
};
static_assert(sizeof(UDPPacket) == 8);
+
+}
diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp
index 3609ef826c..c3d02d8421 100644
--- a/Kernel/Net/UDPSocket.cpp
+++ b/Kernel/Net/UDPSocket.cpp
@@ -32,6 +32,8 @@
#include <Kernel/Process.h>
#include <Kernel/Random.h>
+namespace Kernel {
+
void UDPSocket::for_each(Function<void(UDPSocket&)> callback)
{
LOCKER(sockets_by_port().lock());
@@ -147,3 +149,5 @@ KResult UDPSocket::protocol_bind()
sockets_by_port().resource().set(local_port(), this);
return KSuccess;
}
+
+}
diff --git a/Kernel/Net/UDPSocket.h b/Kernel/Net/UDPSocket.h
index 3cc416e63f..e272254227 100644
--- a/Kernel/Net/UDPSocket.h
+++ b/Kernel/Net/UDPSocket.h
@@ -28,6 +28,8 @@
#include <Kernel/Net/IPv4Socket.h>
+namespace Kernel {
+
class UDPSocket final : public IPv4Socket {
public:
static NonnullRefPtr<UDPSocket> create(int protocol);
@@ -47,3 +49,5 @@ private:
virtual int protocol_allocate_local_port() override;
virtual KResult protocol_bind() override;
};
+
+}