summaryrefslogtreecommitdiff
path: root/Kernel/Net/IPv4Socket.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-04 03:27:50 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-04 03:27:50 +0200
commit780d2a08c488e5e8a61f7508f7cc31f35bdf8b26 (patch)
tree1c91597b2b92fbae9bf9c91a41425375f58b956c /Kernel/Net/IPv4Socket.h
parentc4bb9a3ccbbd0538472d7a6ea025c17bfaec9e8d (diff)
downloadserenity-780d2a08c488e5e8a61f7508f7cc31f35bdf8b26.zip
IPv4: Save the source address/port together with incoming packet payloads.
We need the address/port to fill in the out-params in recvfrom(). It should now be more or less possible to create a UDP server. :^)
Diffstat (limited to 'Kernel/Net/IPv4Socket.h')
-rw-r--r--Kernel/Net/IPv4Socket.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h
index f011182621..47ec8804f3 100644
--- a/Kernel/Net/IPv4Socket.h
+++ b/Kernel/Net/IPv4Socket.h
@@ -32,7 +32,7 @@ public:
virtual ssize_t sendto(FileDescriptor&, const void*, size_t, int, const sockaddr*, socklen_t) override;
virtual ssize_t recvfrom(FileDescriptor&, void*, size_t, int flags, sockaddr*, socklen_t*) override;
- void did_receive(ByteBuffer&&);
+ void did_receive(const IPv4Address& source_address, word source_port, ByteBuffer&&);
const IPv4Address& source_address() const;
word source_port() const { return m_source_port; }
@@ -67,7 +67,13 @@ private:
DoubleBuffer m_for_client;
DoubleBuffer m_for_server;
- SinglyLinkedList<ByteBuffer> m_receive_queue;
+ struct ReceivedPacket {
+ IPv4Address source_address;
+ word source_port;
+ ByteBuffer data;
+ };
+
+ SinglyLinkedList<ReceivedPacket> m_receive_queue;
word m_source_port { 0 };
word m_destination_port { 0 };