diff options
author | Robin Burchell <robin+git@viroteck.net> | 2019-05-28 11:53:16 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-28 17:31:20 +0200 |
commit | 0dc9af5f7e26b0dfa42cb75c900b9ef7a2192425 (patch) | |
tree | 93dbbbeb714f258bd7fb044633eb83bdcd908286 /Kernel/Net | |
parent | c11351ac507f863699d78aec46a77bd4d59e743c (diff) | |
download | serenity-0dc9af5f7e26b0dfa42cb75c900b9ef7a2192425.zip |
Add clang-format file
Also run it across the whole tree to get everything using the One True Style.
We don't yet run this in an automated fashion as it's a little slow, but
there is a snippet to do so in makeall.sh.
Diffstat (limited to 'Kernel/Net')
-rw-r--r-- | Kernel/Net/ARP.h | 23 | ||||
-rw-r--r-- | Kernel/Net/E1000NetworkAdapter.h | 13 | ||||
-rw-r--r-- | Kernel/Net/EtherType.h | 9 | ||||
-rw-r--r-- | Kernel/Net/EthernetFrameHeader.h | 10 | ||||
-rw-r--r-- | Kernel/Net/ICMP.h | 21 | ||||
-rw-r--r-- | Kernel/Net/IPv4.h | 11 | ||||
-rw-r--r-- | Kernel/Net/IPv4Socket.h | 10 | ||||
-rw-r--r-- | Kernel/Net/LocalSocket.h | 3 | ||||
-rw-r--r-- | Kernel/Net/MACAddress.h | 9 | ||||
-rw-r--r-- | Kernel/Net/NetworkAdapter.h | 14 | ||||
-rw-r--r-- | Kernel/Net/Socket.h | 25 | ||||
-rw-r--r-- | Kernel/Net/TCP.h | 24 | ||||
-rw-r--r-- | Kernel/Net/TCPSocket.h | 5 | ||||
-rw-r--r-- | Kernel/Net/UDP.h | 7 | ||||
-rw-r--r-- | Kernel/Net/UDPSocket.h | 3 |
15 files changed, 109 insertions, 78 deletions
diff --git a/Kernel/Net/ARP.h b/Kernel/Net/ARP.h index ddfcd54f63..2fecc2b0a0 100644 --- a/Kernel/Net/ARP.h +++ b/Kernel/Net/ARP.h @@ -1,23 +1,26 @@ #pragma once -#include <Kernel/Net/MACAddress.h> -#include <Kernel/Net/IPv4.h> #include <Kernel/Net/EtherType.h> +#include <Kernel/Net/IPv4.h> +#include <Kernel/Net/MACAddress.h> struct ARPOperation { -enum : word { - Request = 1, - Response = 2, -}; + enum : word + { + Request = 1, + Response = 2, + }; }; struct ARPHardwareType { -enum : word { - Ethernet = 1, -}; + enum : word + { + Ethernet = 1, + }; }; -class [[gnu::packed]] ARPPacket { +class [[gnu::packed]] ARPPacket +{ public: word hardware_type() const { return ntohs(m_hardware_type); } void set_hardware_type(word w) { m_hardware_type = htons(w); } diff --git a/Kernel/Net/E1000NetworkAdapter.h b/Kernel/Net/E1000NetworkAdapter.h index cf9bdb3ba5..e2050853d5 100644 --- a/Kernel/Net/E1000NetworkAdapter.h +++ b/Kernel/Net/E1000NetworkAdapter.h @@ -1,12 +1,13 @@ #pragma once +#include <AK/OwnPtr.h> +#include <Kernel/IRQHandler.h> #include <Kernel/Net/NetworkAdapter.h> #include <Kernel/PCI.h> #include <Kernel/VM/MemoryManager.h> -#include <Kernel/IRQHandler.h> -#include <AK/OwnPtr.h> -class E1000NetworkAdapter final : public NetworkAdapter, public IRQHandler { +class E1000NetworkAdapter final : public NetworkAdapter + , public IRQHandler { public: static E1000NetworkAdapter* the(); @@ -21,7 +22,8 @@ private: virtual void handle_irq() override; virtual const char* class_name() const override { return "E1000NetworkAdapter"; } - struct [[gnu::packed]] e1000_rx_desc { + struct [[gnu::packed]] e1000_rx_desc + { volatile uint64_t addr { 0 }; volatile uint16_t length { 0 }; volatile uint16_t checksum { 0 }; @@ -30,7 +32,8 @@ private: volatile uint16_t special { 0 }; }; - struct [[gnu::packed]] e1000_tx_desc { + struct [[gnu::packed]] e1000_tx_desc + { volatile uint64_t addr { 0 }; volatile uint16_t length { 0 }; volatile uint8_t cso { 0 }; diff --git a/Kernel/Net/EtherType.h b/Kernel/Net/EtherType.h index 027967ff77..42edc16427 100644 --- a/Kernel/Net/EtherType.h +++ b/Kernel/Net/EtherType.h @@ -3,8 +3,9 @@ #include <AK/Types.h> struct EtherType { -enum : word { - ARP = 0x0806, - IPv4 = 0x0800, -}; + enum : word + { + ARP = 0x0806, + IPv4 = 0x0800, + }; }; diff --git a/Kernel/Net/EthernetFrameHeader.h b/Kernel/Net/EthernetFrameHeader.h index 18afc9242b..137285230e 100644 --- a/Kernel/Net/EthernetFrameHeader.h +++ b/Kernel/Net/EthernetFrameHeader.h @@ -1,12 +1,13 @@ #pragma once -#include <Kernel/Net/MACAddress.h> #include <AK/NetworkOrdered.h> +#include <Kernel/Net/MACAddress.h> -class [[gnu::packed]] EthernetFrameHeader { +class [[gnu::packed]] EthernetFrameHeader +{ public: - EthernetFrameHeader() { } - ~EthernetFrameHeader() { } + EthernetFrameHeader() {} + ~EthernetFrameHeader() {} MACAddress destination() const { return m_destination; } void set_destination(const MACAddress& address) { m_destination = address; } @@ -28,4 +29,3 @@ private: }; static_assert(sizeof(EthernetFrameHeader) == 14); - diff --git a/Kernel/Net/ICMP.h b/Kernel/Net/ICMP.h index efc6cf4ca6..2433626a64 100644 --- a/Kernel/Net/ICMP.h +++ b/Kernel/Net/ICMP.h @@ -1,19 +1,21 @@ #pragma once -#include <Kernel/Net/MACAddress.h> #include <Kernel/Net/IPv4.h> +#include <Kernel/Net/MACAddress.h> struct ICMPType { -enum { - EchoReply = 0, - EchoRequest = 8, -}; + enum + { + EchoReply = 0, + EchoRequest = 8, + }; }; -class [[gnu::packed]] ICMPHeader { +class [[gnu::packed]] ICMPHeader +{ public: - ICMPHeader() { } - ~ICMPHeader() { } + ICMPHeader() {} + ~ICMPHeader() {} byte type() const { return m_type; } void set_type(byte b) { m_type = b; } @@ -36,7 +38,8 @@ private: static_assert(sizeof(ICMPHeader) == 4); -struct [[gnu::packed]] ICMPEchoPacket { +struct [[gnu::packed]] ICMPEchoPacket +{ ICMPHeader header; NetworkOrdered<word> identifier; NetworkOrdered<word> sequence_number; diff --git a/Kernel/Net/IPv4.h b/Kernel/Net/IPv4.h index 61232b78e2..0c858d94d0 100644 --- a/Kernel/Net/IPv4.h +++ b/Kernel/Net/IPv4.h @@ -5,7 +5,8 @@ #include <AK/NetworkOrdered.h> #include <AK/Types.h> -enum class IPv4Protocol : word { +enum class IPv4Protocol : word +{ ICMP = 1, TCP = 6, UDP = 17, @@ -13,9 +14,10 @@ enum class IPv4Protocol : word { NetworkOrdered<word> internet_checksum(const void*, size_t); -class [[gnu::packed]] IPv4Address { +class [[gnu::packed]] IPv4Address +{ public: - IPv4Address() { } + IPv4Address() {} IPv4Address(const byte data[4]) { m_data[0] = data[0]; @@ -64,7 +66,8 @@ struct Traits<IPv4Address> { } -class [[gnu::packed]] IPv4Packet { +class [[gnu::packed]] IPv4Packet +{ public: byte version() const { return (m_version_and_ihl >> 4) & 0xf; } void set_version(byte version) { m_version_and_ihl = (m_version_and_ihl & 0x0f) | (version << 4); } diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h index 33b4f9d420..4f18d63113 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -1,11 +1,11 @@ #pragma once -#include <Kernel/Net/Socket.h> -#include <Kernel/DoubleBuffer.h> -#include <Kernel/Net/IPv4.h> #include <AK/HashMap.h> -#include <Kernel/Lock.h> #include <AK/SinglyLinkedList.h> +#include <Kernel/DoubleBuffer.h> +#include <Kernel/Lock.h> +#include <Kernel/Net/IPv4.h> +#include <Kernel/Net/Socket.h> class IPv4SocketHandle; class TCPSocketHandle; @@ -86,7 +86,7 @@ private: class IPv4SocketHandle : public SocketHandle { public: - IPv4SocketHandle() { } + IPv4SocketHandle() {} IPv4SocketHandle(RetainPtr<IPv4Socket>&& socket) : SocketHandle(move(socket)) diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h index db481912f2..3328fd4eba 100644 --- a/Kernel/Net/LocalSocket.h +++ b/Kernel/Net/LocalSocket.h @@ -1,7 +1,7 @@ #pragma once -#include <Kernel/Net/Socket.h> #include <Kernel/DoubleBuffer.h> +#include <Kernel/Net/Socket.h> class FileDescriptor; @@ -39,4 +39,3 @@ private: DoubleBuffer m_for_client; DoubleBuffer m_for_server; }; - diff --git a/Kernel/Net/MACAddress.h b/Kernel/Net/MACAddress.h index 0c2de93b27..3cf906decb 100644 --- a/Kernel/Net/MACAddress.h +++ b/Kernel/Net/MACAddress.h @@ -1,18 +1,19 @@ #pragma once -#include <AK/Assertions.h> #include <AK/AKString.h> +#include <AK/Assertions.h> #include <AK/Types.h> #include <Kernel/StdLib.h> -class [[gnu::packed]] MACAddress { +class [[gnu::packed]] MACAddress +{ public: - MACAddress() { } + MACAddress() {} MACAddress(const byte data[6]) { memcpy(m_data, data, 6); } - ~MACAddress() { } + ~MACAddress() {} byte operator[](int i) const { diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h index 3a7d0755c7..fd24d7ca41 100644 --- a/Kernel/Net/NetworkAdapter.h +++ b/Kernel/Net/NetworkAdapter.h @@ -3,19 +3,23 @@ #include <AK/ByteBuffer.h> #include <AK/SinglyLinkedList.h> #include <AK/Types.h> -#include <Kernel/Net/MACAddress.h> -#include <Kernel/Net/IPv4.h> +#include <Kernel/Alarm.h> #include <Kernel/Net/ARP.h> #include <Kernel/Net/ICMP.h> -#include <Kernel/Alarm.h> +#include <Kernel/Net/IPv4.h> +#include <Kernel/Net/MACAddress.h> class NetworkAdapter; class PacketQueueAlarm final : public Alarm { public: - PacketQueueAlarm(NetworkAdapter& adapter) : m_adapter(adapter) { } - virtual ~PacketQueueAlarm() override { } + PacketQueueAlarm(NetworkAdapter& adapter) + : m_adapter(adapter) + { + } + virtual ~PacketQueueAlarm() override {} virtual bool is_ringing() const override; + private: NetworkAdapter& m_adapter; }; diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h index 0fb9544cbb..45693a2ffc 100644 --- a/Kernel/Net/Socket.h +++ b/Kernel/Net/Socket.h @@ -1,16 +1,27 @@ #pragma once -#include <Kernel/Lock.h> -#include <AK/Retainable.h> -#include <AK/RetainPtr.h> #include <AK/HashTable.h> +#include <AK/RetainPtr.h> +#include <AK/Retainable.h> #include <AK/Vector.h> #include <Kernel/File.h> -#include <Kernel/UnixTypes.h> #include <Kernel/KResult.h> +#include <Kernel/Lock.h> +#include <Kernel/UnixTypes.h> -enum class SocketRole : byte { None, Listener, Accepted, Connected, Connecting }; -enum class ShouldBlock { No = 0, Yes = 1 }; +enum class SocketRole : byte +{ + None, + Listener, + Accepted, + Connected, + Connecting +}; +enum class ShouldBlock +{ + No = 0, + Yes = 1 +}; class FileDescriptor; @@ -85,7 +96,7 @@ private: class SocketHandle { public: - SocketHandle() { } + SocketHandle() {} SocketHandle(RetainPtr<Socket>&& socket) : m_socket(move(socket)) diff --git a/Kernel/Net/TCP.h b/Kernel/Net/TCP.h index e2eac61449..8138ed3d52 100644 --- a/Kernel/Net/TCP.h +++ b/Kernel/Net/TCP.h @@ -3,20 +3,22 @@ #include <Kernel/Net/IPv4.h> struct TCPFlags { -enum : word { - FIN = 0x01, - SYN = 0x02, - RST = 0x04, - PUSH = 0x08, - ACK = 0x10, - URG = 0x20 -}; + enum : word + { + FIN = 0x01, + SYN = 0x02, + RST = 0x04, + PUSH = 0x08, + ACK = 0x10, + URG = 0x20 + }; }; -class [[gnu::packed]] TCPPacket { +class [[gnu::packed]] TCPPacket +{ public: - TCPPacket() { } - ~TCPPacket() { } + TCPPacket() {} + ~TCPPacket() {} size_t header_size() const { return data_offset() * sizeof(dword); } diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h index c248b9d9ba..35856d7ae8 100644 --- a/Kernel/Net/TCPSocket.h +++ b/Kernel/Net/TCPSocket.h @@ -7,7 +7,8 @@ public: static Retained<TCPSocket> create(int protocol); virtual ~TCPSocket() override; - enum class State { + enum class State + { Disconnected, Connecting, Connected, @@ -47,7 +48,7 @@ private: class TCPSocketHandle : public SocketHandle { public: - TCPSocketHandle() { } + TCPSocketHandle() {} TCPSocketHandle(RetainPtr<TCPSocket>&& socket) : SocketHandle(move(socket)) diff --git a/Kernel/Net/UDP.h b/Kernel/Net/UDP.h index ba6d02af37..7ec39719cd 100644 --- a/Kernel/Net/UDP.h +++ b/Kernel/Net/UDP.h @@ -2,10 +2,11 @@ #include <Kernel/Net/IPv4.h> -class [[gnu::packed]] UDPPacket { +class [[gnu::packed]] UDPPacket +{ public: - UDPPacket() { } - ~UDPPacket() { } + UDPPacket() {} + ~UDPPacket() {} word source_port() const { return m_source_port; } void set_source_port(word port) { m_source_port = port; } diff --git a/Kernel/Net/UDPSocket.h b/Kernel/Net/UDPSocket.h index ea94887754..a76eaa7fe7 100644 --- a/Kernel/Net/UDPSocket.h +++ b/Kernel/Net/UDPSocket.h @@ -25,7 +25,7 @@ private: class UDPSocketHandle : public SocketHandle { public: - UDPSocketHandle() { } + UDPSocketHandle() {} UDPSocketHandle(RetainPtr<UDPSocket>&& socket) : SocketHandle(move(socket)) @@ -46,4 +46,3 @@ public: UDPSocket& socket() { return static_cast<UDPSocket&>(SocketHandle::socket()); } const UDPSocket& socket() const { return static_cast<const UDPSocket&>(SocketHandle::socket()); } }; - |