1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 12:05:07 +00:00

Kernel: Use WeakPtr<NetworkAdapter> instead of NetworkAdapter* in net code

This commit is contained in:
Conrad Pankoff 2019-08-09 12:34:32 +10:00 committed by Andreas Kling
parent d6bce37756
commit 54ceabd48d
9 changed files with 28 additions and 16 deletions

View file

@ -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());