1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

Kernel+LibC+Userland: Yet more networking bringup hacking.

All ICMP sockets now receive all ICMP packets. All this buffering is gonna
need some limits and such.
This commit is contained in:
Andreas Kling 2019-03-12 17:27:07 +01:00
parent a017a77442
commit a7d5e9781a
14 changed files with 178 additions and 2 deletions

View file

@ -3,12 +3,16 @@
#include <Kernel/Socket.h>
#include <Kernel/DoubleBuffer.h>
#include <Kernel/IPv4.h>
#include <AK/Lock.h>
#include <AK/SinglyLinkedList.h>
class IPv4Socket final : public Socket {
public:
static Retained<IPv4Socket> create(int type, int protocol);
virtual ~IPv4Socket() override;
static Lockable<HashTable<IPv4Socket*>>& all_sockets();
virtual KResult bind(const sockaddr*, socklen_t) override;
virtual KResult connect(const sockaddr*, socklen_t) override;
virtual bool get_address(sockaddr*, socklen_t*) override;
@ -19,6 +23,11 @@ public:
virtual ssize_t write(SocketRole, const byte*, ssize_t) override;
virtual bool can_write(SocketRole) const override;
virtual ssize_t sendto(const void*, size_t, int, const sockaddr*, socklen_t) override;
virtual ssize_t recvfrom(void*, size_t, int flags, const sockaddr*, socklen_t) override;
void did_receive(ByteBuffer&&);
Lock& lock() { return m_lock; }
private:
IPv4Socket(int type, int protocol);
@ -30,5 +39,10 @@ private:
DoubleBuffer m_for_client;
DoubleBuffer m_for_server;
SinglyLinkedList<ByteBuffer> m_receive_queue;
Lock m_lock;
bool m_can_read { false };
};