summaryrefslogtreecommitdiffhomepage
path: root/Kernel/NetworkKit/NetworkDevice.hpp
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-05-11 06:43:54 +0000
committerAmlal <amlalelmahrouss@icloud.com>2024-05-11 06:43:54 +0000
commitca675beb41dba8d7d16c5793b55d1672f38be3b4 (patch)
treec995ada42729ac2059a0ed87a4539d1a7e10b14a /Kernel/NetworkKit/NetworkDevice.hpp
parent2b4a4792abf51487ab4a16106f9376f43acf381a (diff)
parentbc57a29a24b98b00ba17710ba84ec2188ab73504 (diff)
Merged in MHR-23 (pull request #12)
MHR-23: Merge work.
Diffstat (limited to 'Kernel/NetworkKit/NetworkDevice.hpp')
-rw-r--r--Kernel/NetworkKit/NetworkDevice.hpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/Kernel/NetworkKit/NetworkDevice.hpp b/Kernel/NetworkKit/NetworkDevice.hpp
new file mode 100644
index 00000000..b00ce7a6
--- /dev/null
+++ b/Kernel/NetworkKit/NetworkDevice.hpp
@@ -0,0 +1,65 @@
+/* -------------------------------------------
+
+ Copyright SoftwareLabs
+
+------------------------------------------- */
+
+#ifndef __NETWORK_DEVICE__
+#define __NETWORK_DEVICE__
+
+#include <KernelKit/DeviceManager.hpp>
+#include <NetworkKit/IP.hpp>
+
+namespace NewOS
+{
+ struct NetworkDeviceCommand;
+ class NetworkDevice;
+
+ /**
+* \brief Network device interface, establishes a connection to the NIC.
+*/
+ class NetworkDevice final : public DeviceInterface<NetworkDeviceCommand>
+ {
+ public:
+ NetworkDevice(void (*out)(NetworkDeviceCommand),
+ void (*in)(NetworkDeviceCommand),
+ void (*onCleanup)(void) = nullptr);
+
+ ~NetworkDevice() override;
+
+ public:
+ NetworkDevice& operator=(const NetworkDevice&) = default;
+ NetworkDevice(const NetworkDevice&) = default;
+
+ public:
+ const char* Name() const override;
+
+ private:
+ void (*fCleanup)(void);
+ };
+
+ struct PACKED NetworkDeviceCommand final
+ {
+ UInt32 CommandName;
+ UInt32 CommandType;
+ UInt32 CommandFlags;
+ VoidPtr CommandBuffer;
+ SizeT CommandSizeBuffer;
+ };
+
+ /// @brief TCP device.
+ using TCPNetworkDevice = NetworkDevice;
+
+ /// @brief UDP device.
+ using UDPNetworkDevice = NetworkDevice;
+
+ /// @brief PPP device.
+ using PPPNetworkDevice = NetworkDevice;
+
+ /// @brief HPC device.
+ using HPCNetworkDevice = NetworkDevice;
+} // namespace NewOS
+
+#include <NetworkKit/NetworkDevice.inl>
+
+#endif // !__NETWORK_DEVICE__