Kernel/LibC: Implement basic socket binding

This commit is contained in:
2024-02-02 01:31:58 +02:00
parent cf28ecd5a6
commit ab150b458a
13 changed files with 119 additions and 7 deletions

View File

@@ -1,21 +1,28 @@
#pragma once
#include <BAN/WeakPtr.h>
#include <kernel/FS/TmpFS/Inode.h>
#include <kernel/Networking/NetworkInterface.h>
namespace Kernel
{
class NetworkSocket : public TmpInode
class NetworkSocket : public TmpInode, public BAN::Weakable<NetworkSocket>
{
public:
void bind_interface(NetworkInterface*);
void bind_interface_and_port(NetworkInterface*, uint16_t port);
~NetworkSocket();
protected:
NetworkSocket(mode_t mode, uid_t uid, gid_t gid);
virtual void on_close_impl() override;
virtual BAN::ErrorOr<void> bind_impl(const sockaddr* address, socklen_t address_len) override;
protected:
NetworkInterface* m_interface = nullptr;
NetworkInterface* m_interface = nullptr;
uint16_t m_port = 0;
};
}