diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-13 03:26:01 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-13 03:26:01 +0100 |
commit | cf250e12450a140173be2a06ddeed5f30520af1c (patch) | |
tree | eb64abc33492a7cdee1641afa456a837071426c2 /Kernel/IPv4Socket.cpp | |
parent | ce7c302933be69e5937f9cac5cf79385d5434a02 (diff) | |
download | serenity-cf250e12450a140173be2a06ddeed5f30520af1c.zip |
More work on IPv4 sockets and /bin/ping.
It's now actually possible to ping other hosts on the network! :^)
I've switched the "run" script over to starting QEMU with user networking
since that works better for my testing needs right now.
Diffstat (limited to 'Kernel/IPv4Socket.cpp')
-rw-r--r-- | Kernel/IPv4Socket.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Kernel/IPv4Socket.cpp b/Kernel/IPv4Socket.cpp index 239cf3edd3..9e0cec8882 100644 --- a/Kernel/IPv4Socket.cpp +++ b/Kernel/IPv4Socket.cpp @@ -143,15 +143,16 @@ ssize_t IPv4Socket::recvfrom(void* buffer, size_t buffer_length, int flags, cons } auto peer_address = IPv4Address((const byte*)&((const sockaddr_in*)addr)->sin_addr.s_addr); +#ifdef IPV4_SOCKET_DEBUG kprintf("recvfrom: peer_address=%s\n", peer_address.to_string().characters()); +#endif ByteBuffer packet_buffer; - { LOCKER(m_lock); if (!m_receive_queue.is_empty()) { packet_buffer = m_receive_queue.take_first(); - m_can_read = m_receive_queue.is_empty(); + m_can_read = !m_receive_queue.is_empty(); } } if (packet_buffer.is_null()) { @@ -163,7 +164,7 @@ ssize_t IPv4Socket::recvfrom(void* buffer, size_t buffer_length, int flags, cons ASSERT(m_can_read); ASSERT(!m_receive_queue.is_empty()); packet_buffer = m_receive_queue.take_first(); - m_can_read = m_receive_queue.is_empty(); + m_can_read = !m_receive_queue.is_empty(); } ASSERT(!packet_buffer.is_null()); auto& ipv4_packet = *(const IPv4Packet*)(packet_buffer.pointer()); @@ -174,8 +175,10 @@ ssize_t IPv4Socket::recvfrom(void* buffer, size_t buffer_length, int flags, cons void IPv4Socket::did_receive(ByteBuffer&& packet) { +#ifdef IPV4_SOCKET_DEBUG + kprintf("IPv4Socket(%p): did_receive %d bytes\n", this, packet.size()); +#endif LOCKER(m_lock); - kprintf("IPv4Socket(%p): did_receive %d bytes\n", packet.size()); m_receive_queue.append(move(packet)); m_can_read = true; } |