1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:28:11 +00:00

IPv4: Support overriding the default TTL (64)

Made getsockopt() and setsockopt() virtual so we can handle them in the
various Socket subclasses. The subclasses map kinda nicely to "levels".

This will allow us to implement things like "traceroute", although..
I spent some time trying to do that, but then hit a wall when it turned
out that the user-mode networking in QEMU doesn't preserve TTL in the
ICMP packets passing through.
This commit is contained in:
Andreas Kling 2019-09-19 21:40:06 +02:00
parent 482d5295f1
commit 8cfb859368
11 changed files with 58 additions and 10 deletions

View file

@ -31,6 +31,8 @@ public:
virtual bool can_write(FileDescription&) const override;
virtual ssize_t sendto(FileDescription&, const void*, size_t, int, const sockaddr*, socklen_t) override;
virtual ssize_t recvfrom(FileDescription&, void*, size_t, int flags, sockaddr*, socklen_t*) override;
virtual KResult setsockopt(int level, int option, const void*, socklen_t) override;
virtual KResult getsockopt(int level, int option, void*, socklen_t*) override;
void did_receive(const IPv4Address& peer_address, u16 peer_port, KBuffer&&);
@ -47,6 +49,8 @@ public:
String absolute_path(const FileDescription& description) const override;
u8 ttl() const { return m_ttl; }
protected:
IPv4Socket(int type, int protocol);
virtual const char* class_name() const override { return "IPv4Socket"; }
@ -83,5 +87,7 @@ private:
u32 m_bytes_received { 0 };
u8 m_ttl { 64 };
bool m_can_read { false };
};