diff options
author | Conrad Pankoff <deoxxa@fknsrs.biz> | 2019-08-09 12:34:32 +1000 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-09 07:09:26 +0200 |
commit | 54ceabd48d49fdc44a70a2ff66f98d9bb1ff2ee2 (patch) | |
tree | 7ae4005bb07bb0c9af40a7387d95991e7dc68e44 /Kernel/Net/TCPSocket.cpp | |
parent | d6bce37756273948a59a7bada52643186f9090ee (diff) | |
download | serenity-54ceabd48d49fdc44a70a2ff66f98d9bb1ff2ee2.zip |
Kernel: Use WeakPtr<NetworkAdapter> instead of NetworkAdapter* in net code
Diffstat (limited to 'Kernel/Net/TCPSocket.cpp')
-rw-r--r-- | Kernel/Net/TCPSocket.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index b6c1b726af..df998389f4 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -80,7 +80,16 @@ int TCPSocket::protocol_send(const void* data, int data_length) void TCPSocket::send_tcp_packet(u16 flags, const void* payload, int payload_size) { - ASSERT(m_adapter); + if (!m_adapter) { + if (has_specific_local_address()) { + m_adapter = NetworkAdapter::from_ipv4_address(local_address()); + } else { + m_adapter = adapter_for_route_to(peer_address()); + if (m_adapter) + set_local_address(m_adapter->ipv4_address()); + } + } + ASSERT(!!m_adapter); auto buffer = ByteBuffer::create_zeroed(sizeof(TCPPacket) + payload_size); auto& tcp_packet = *(TCPPacket*)(buffer.pointer()); |