diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-04-05 01:16:45 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-05 09:50:48 +0200 |
commit | 77191d82dc07319458442ff9905139e5789c9168 (patch) | |
tree | 45743d9a15bfae09be1eec6cffb1cdb38738270c /Kernel/Net/Socket.h | |
parent | 7d0bf9b5a9b635eb54f34843d17ea38d7c18092e (diff) | |
download | serenity-77191d82dc07319458442ff9905139e5789c9168.zip |
Kernel: Add the SO_BINDTODEVICE socket option
This patch adds a way for a socket to ask to be routed through a
specific interface.
Currently, this option only applies to sending, however, it should also
apply to receiving...somehow :^)
Diffstat (limited to 'Kernel/Net/Socket.h')
-rw-r--r-- | Kernel/Net/Socket.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h index 5e4feecdba..510b50eb37 100644 --- a/Kernel/Net/Socket.h +++ b/Kernel/Net/Socket.h @@ -33,6 +33,7 @@ #include <Kernel/FileSystem/File.h> #include <Kernel/KResult.h> #include <Kernel/Lock.h> +#include <Kernel/Net/NetworkAdapter.h> #include <Kernel/UnixTypes.h> namespace Kernel { @@ -57,9 +58,9 @@ public: bool is_shut_down_for_reading() const { return m_shut_down_for_reading; } enum class SetupState { - Unstarted, // we haven't tried to set the socket up yet + Unstarted, // we haven't tried to set the socket up yet InProgress, // we're in the process of setting things up - for TCP maybe we've sent a SYN packet - Completed, // the setup process is complete, but not necessarily successful + Completed, // the setup process is complete, but not necessarily successful }; enum class Role : u8 { @@ -118,6 +119,7 @@ public: pid_t acceptor_pid() const { return m_acceptor.pid; } uid_t acceptor_uid() const { return m_acceptor.uid; } gid_t acceptor_gid() const { return m_acceptor.gid; } + const RefPtr<NetworkAdapter> bound_interface() const { return m_bound_interface; } Lock& lock() { return m_lock; } @@ -165,13 +167,15 @@ private: bool m_shut_down_for_reading { false }; bool m_shut_down_for_writing { false }; + RefPtr<NetworkAdapter> m_bound_interface { nullptr }; + timeval m_receive_timeout { 0, 0 }; timeval m_send_timeout { 0, 0 }; NonnullRefPtrVector<Socket> m_pending; }; -template<typename SocketType> +template <typename SocketType> class SocketHandle { public: SocketHandle() {} |