diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 19a0225a949..83faedd3300 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -13,7 +13,7 @@ #include #include -#define IPV4_SOCKET_DEBUG +//#define IPV4_SOCKET_DEBUG Lockable>& IPv4Socket::all_sockets() { diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index 09a14dba1f4..9f01fec0b74 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -14,10 +14,10 @@ #include //#define ETHERNET_DEBUG -#define IPV4_DEBUG +//#define IPV4_DEBUG //#define ICMP_DEBUG -#define UDP_DEBUG -#define TCP_DEBUG +//#define UDP_DEBUG +//#define TCP_DEBUG static void handle_arp(const EthernetFrameHeader&, int frame_size); static void handle_ipv4(const EthernetFrameHeader&, int frame_size); @@ -329,12 +329,14 @@ void handle_tcp(const EthernetFrameHeader& eth, int frame_size) } socket->set_ack_number(tcp_packet.sequence_number() + payload_size); +#ifdef TCP_DEBUG kprintf("Got packet with ack_no=%u, seq_no=%u, payload_size=%u, acking it with new ack_no=%u, seq_no=%u\n", tcp_packet.ack_number(), tcp_packet.sequence_number(), payload_size, socket->ack_number(), socket->sequence_number()); +#endif socket->send_tcp_packet(TCPFlags::ACK); if (payload_size != 0) diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index f5c371200e7..fe272ade9cb 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -6,6 +6,8 @@ #include #include +//#define TCP_SOCKET_DEBUG + Lockable>& TCPSocket::sockets_by_port() { static Lockable>* s_map; @@ -51,7 +53,9 @@ int TCPSocket::protocol_receive(const ByteBuffer& packet_buffer, void* buffer, s auto& ipv4_packet = *(const IPv4Packet*)(packet_buffer.pointer()); auto& tcp_packet = *static_cast(ipv4_packet.payload()); size_t payload_size = packet_buffer.size() - sizeof(IPv4Packet) - tcp_packet.header_size(); +#ifdef TCP_SOCKET_DEBUG kprintf("payload_size %u, will it fit in %u?\n", payload_size, buffer_size); +#endif ASSERT(buffer_size >= payload_size); memcpy(buffer, tcp_packet.payload(), payload_size); return payload_size; @@ -93,6 +97,7 @@ void TCPSocket::send_tcp_packet(u16 flags, const void* payload, int payload_size memcpy(tcp_packet.payload(), payload, payload_size); tcp_packet.set_checksum(compute_tcp_checksum(adapter->ipv4_address(), peer_address(), tcp_packet, payload_size)); +#ifdef TCP_SOCKET_DEBUG kprintf("sending tcp packet from %s:%u to %s:%u with (%s %s) seq_no=%u, ack_no=%u\n", adapter->ipv4_address().to_string().characters(), local_port(), @@ -102,6 +107,7 @@ void TCPSocket::send_tcp_packet(u16 flags, const void* payload, int payload_size tcp_packet.has_ack() ? "ACK" : "", tcp_packet.sequence_number(), tcp_packet.ack_number()); +#endif adapter->send_ipv4(MACAddress(), peer_address(), IPv4Protocol::TCP, move(buffer)); }