1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:47:34 +00:00

Kernel: Send RST/ACK if no socket is available

Previously there was no way for Serenity to send a packet without an
established socket connection, and there was no way to appropriately
respond to a SYN packet on a non-listening port. This patch will respond
to any non-established socket attempts with the appropraite RST/ACK,
letting the client know to close the connection.
This commit is contained in:
brapru 2021-07-18 18:19:25 -04:00 committed by Gunnar Beutner
parent 63a15ed19d
commit 9c3e6f3f63
2 changed files with 38 additions and 16 deletions

View file

@ -159,6 +159,8 @@ public:
virtual bool can_write(const FileDescription&, size_t) const override;
static NetworkOrdered<u16> compute_tcp_checksum(IPv4Address const& source, IPv4Address const& destination, TCPPacket const&, u16 payload_size);
protected:
void set_direction(Direction direction) { m_direction = direction; }
@ -166,8 +168,6 @@ private:
explicit TCPSocket(int protocol);
virtual StringView class_name() const override { return "TCPSocket"; }
static NetworkOrdered<u16> compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket&, u16 payload_size);
virtual void shut_down_for_writing() override;
virtual KResultOr<size_t> protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags) override;