diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-19 21:40:06 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-19 21:42:59 +0200 |
commit | 8cfb85936815a9de0fbfeeed1484f7f58ce8ea6d (patch) | |
tree | d1123e9b66a70eb1e593f8124198544f45ca01cd /Kernel/Net/IPv4Socket.h | |
parent | 482d5295f1a490b76e3e888cdca9b393a26dda73 (diff) | |
download | serenity-8cfb85936815a9de0fbfeeed1484f7f58ce8ea6d.zip |
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.
Diffstat (limited to 'Kernel/Net/IPv4Socket.h')
-rw-r--r-- | Kernel/Net/IPv4Socket.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h index ced971f1cf..2480634bee 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -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 }; }; |