mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 05:57:41 +00:00
Net: Put a bunch of socket debug logging behind FOO_DEBUG
Also remove an unused Socket::listen() implementation.
This commit is contained in:
parent
ec65b8db2e
commit
e08991319a
3 changed files with 10 additions and 11 deletions
|
@ -37,7 +37,9 @@ NonnullRefPtr<IPv4Socket> IPv4Socket::create(int type, int protocol)
|
||||||
IPv4Socket::IPv4Socket(int type, int protocol)
|
IPv4Socket::IPv4Socket(int type, int protocol)
|
||||||
: Socket(AF_INET, type, 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);
|
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());
|
LOCKER(all_sockets().lock());
|
||||||
all_sockets().resource().set(this);
|
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_address = IPv4Address((const u8*)&ia.sin_addr.s_addr);
|
||||||
m_local_port = requested_local_port;
|
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);
|
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();
|
return protocol_bind();
|
||||||
}
|
}
|
||||||
|
@ -109,7 +113,9 @@ KResult IPv4Socket::listen(int backlog)
|
||||||
set_backlog(backlog);
|
set_backlog(backlog);
|
||||||
m_role = Role::Listener;
|
m_role = Role::Listener;
|
||||||
|
|
||||||
|
#ifdef IPV4_SOCKET_DEBUG
|
||||||
kprintf("IPv4Socket{%p} listening with backlog=%d\n", this, backlog);
|
kprintf("IPv4Socket{%p} listening with backlog=%d\n", this, backlog);
|
||||||
|
#endif
|
||||||
|
|
||||||
return protocol_listen();
|
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());
|
auto& ipv4_packet = *(const IPv4Packet*)(packet.data.value().data());
|
||||||
|
|
||||||
if (addr) {
|
if (addr) {
|
||||||
|
#ifdef IPV4_SOCKET_DEBUG
|
||||||
dbgprintf("Incoming packet is from: %s:%u\n", packet.peer_address.to_string().characters(), packet.peer_port);
|
dbgprintf("Incoming packet is from: %s:%u\n", packet.peer_address.to_string().characters(), packet.peer_port);
|
||||||
|
#endif
|
||||||
auto& ia = *(sockaddr_in*)addr;
|
auto& ia = *(sockaddr_in*)addr;
|
||||||
memcpy(&ia.sin_addr, &packet.peer_address, sizeof(IPv4Address));
|
memcpy(&ia.sin_addr, &packet.peer_address, sizeof(IPv4Address));
|
||||||
ia.sin_port = htons(packet.peer_port);
|
ia.sin_port = htons(packet.peer_port);
|
||||||
|
|
|
@ -158,7 +158,9 @@ KResult LocalSocket::listen(int backlog)
|
||||||
return KResult(-EOPNOTSUPP);
|
return KResult(-EOPNOTSUPP);
|
||||||
set_backlog(backlog);
|
set_backlog(backlog);
|
||||||
m_connect_side_role = m_role = Role::Listener;
|
m_connect_side_role = m_role = Role::Listener;
|
||||||
|
#ifdef DEBUG_LOCAL_SOCKET
|
||||||
kprintf("LocalSocket{%p} listening with backlog=%d\n", this, backlog);
|
kprintf("LocalSocket{%p} listening with backlog=%d\n", this, backlog);
|
||||||
|
#endif
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,17 +43,6 @@ void Socket::set_setup_state(SetupState new_setup_state)
|
||||||
m_setup_state = 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()
|
RefPtr<Socket> Socket::accept()
|
||||||
{
|
{
|
||||||
LOCKER(m_lock);
|
LOCKER(m_lock);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue