summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-10-18 16:47:29 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-10-18 16:50:23 +0200
commite08991319a264dc84740b0cba852b93b7142a7ec (patch)
tree9d36fcb9cf2cb5a57bc3995611d8b023f74be62e /Kernel
parentec65b8db2e48ccbd1804dce594a43a67b1bf5a24 (diff)
downloadserenity-e08991319a264dc84740b0cba852b93b7142a7ec.zip
Net: Put a bunch of socket debug logging behind FOO_DEBUG
Also remove an unused Socket::listen() implementation.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Net/IPv4Socket.cpp8
-rw-r--r--Kernel/Net/LocalSocket.cpp2
-rw-r--r--Kernel/Net/Socket.cpp11
3 files changed, 10 insertions, 11 deletions
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index e888eae6aa..cbfd7dea8e 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -37,7 +37,9 @@ NonnullRefPtr<IPv4Socket> IPv4Socket::create(int type, int protocol)
IPv4Socket::IPv4Socket(int type, int protocol)
: Socket(AF_INET, type, protocol)
{
+#ifdef IPV4_SOCKET_DEBUG
kprintf("%s(%u) IPv4Socket{%p} created with type=%u, protocol=%d\n", current->process().name().characters(), current->pid(), this, type, protocol);
+#endif
LOCKER(all_sockets().lock());
all_sockets().resource().set(this);
}
@@ -95,7 +97,9 @@ KResult IPv4Socket::bind(const sockaddr* address, socklen_t address_size)
m_local_address = IPv4Address((const u8*)&ia.sin_addr.s_addr);
m_local_port = requested_local_port;
+#ifdef IPV4_SOCKET_DEBUG
dbgprintf("IPv4Socket::bind %s{%p} to %s:%u\n", class_name(), this, m_local_address.to_string().characters(), m_local_port);
+#endif
return protocol_bind();
}
@@ -109,7 +113,9 @@ KResult IPv4Socket::listen(int backlog)
set_backlog(backlog);
m_role = Role::Listener;
+#ifdef IPV4_SOCKET_DEBUG
kprintf("IPv4Socket{%p} listening with backlog=%d\n", this, backlog);
+#endif
return protocol_listen();
}
@@ -253,7 +259,9 @@ ssize_t IPv4Socket::recvfrom(FileDescription& description, void* buffer, size_t
auto& ipv4_packet = *(const IPv4Packet*)(packet.data.value().data());
if (addr) {
+#ifdef IPV4_SOCKET_DEBUG
dbgprintf("Incoming packet is from: %s:%u\n", packet.peer_address.to_string().characters(), packet.peer_port);
+#endif
auto& ia = *(sockaddr_in*)addr;
memcpy(&ia.sin_addr, &packet.peer_address, sizeof(IPv4Address));
ia.sin_port = htons(packet.peer_port);
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index c59ab67699..542daada86 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -158,7 +158,9 @@ KResult LocalSocket::listen(int backlog)
return KResult(-EOPNOTSUPP);
set_backlog(backlog);
m_connect_side_role = m_role = Role::Listener;
+#ifdef DEBUG_LOCAL_SOCKET
kprintf("LocalSocket{%p} listening with backlog=%d\n", this, backlog);
+#endif
return KSuccess;
}
diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp
index 0749d0ee2e..b174cba69b 100644
--- a/Kernel/Net/Socket.cpp
+++ b/Kernel/Net/Socket.cpp
@@ -43,17 +43,6 @@ void Socket::set_setup_state(SetupState new_setup_state)
m_setup_state = new_setup_state;
}
-KResult Socket::listen(int backlog)
-{
- LOCKER(m_lock);
- if (m_type != SOCK_STREAM)
- return KResult(-EOPNOTSUPP);
- m_backlog = backlog;
- m_role = Role::Listener;
- kprintf("Socket{%p} listening with backlog=%d\n", this, m_backlog);
- return KSuccess;
-}
-
RefPtr<Socket> Socket::accept()
{
LOCKER(m_lock);