summaryrefslogtreecommitdiff
path: root/Kernel/IPv4Socket.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-13 03:26:01 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-13 03:26:01 +0100
commitcf250e12450a140173be2a06ddeed5f30520af1c (patch)
treeeb64abc33492a7cdee1641afa456a837071426c2 /Kernel/IPv4Socket.cpp
parentce7c302933be69e5937f9cac5cf79385d5434a02 (diff)
downloadserenity-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.cpp11
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;
}