From ad1c2214ef79ddd7f90b745704ad33b91ccd190a Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 18 Feb 2023 04:07:40 +0200 Subject: [PATCH] Show more debug messages --- Network/AddressResolutionProtocol.cpp | 2 ++ Network/DomainNameSystem.cpp | 2 ++ Network/DynamicHostConfigurationProtocol.cpp | 2 ++ Network/Ethernet.cpp | 11 +++++++++-- Network/InternetControlMessageProtocol.cpp | 12 ++++++++++-- Network/InternetProtocol.cpp | 2 ++ Network/NetworkController.cpp | 12 +++++------- Network/NetworkTimeProtocol.cpp | 12 ++++++++++-- Network/UserDatagramProtocol.cpp | 6 +++++- 9 files changed, 47 insertions(+), 14 deletions(-) diff --git a/Network/AddressResolutionProtocol.cpp b/Network/AddressResolutionProtocol.cpp index 0621458..0ef7836 100644 --- a/Network/AddressResolutionProtocol.cpp +++ b/Network/AddressResolutionProtocol.cpp @@ -64,11 +64,13 @@ namespace NetworkARP ARP::ARP(NetworkEthernet::Ethernet *Ethernet) : NetworkEthernet::EthernetEvents(NetworkEthernet::TYPE_ARP) { + debug("ARP interface %#lx created.", this); this->Ethernet = Ethernet; } ARP::~ARP() { + debug("ARP interface %#lx destroyed.", this); } MediaAccessControl InvalidMAC; diff --git a/Network/DomainNameSystem.cpp b/Network/DomainNameSystem.cpp index 994883b..2845d5c 100644 --- a/Network/DomainNameSystem.cpp +++ b/Network/DomainNameSystem.cpp @@ -7,10 +7,12 @@ namespace NetworkDNS { DNS::DNS(NetworkUDP::Socket *Socket) : NetworkUDP::UDPEvents() { + debug("DNS interface %#lx created.", this); this->UDPSocket = Socket; } DNS::~DNS() { + debug("DNS interface %#lx destroyed.", this); } } diff --git a/Network/DynamicHostConfigurationProtocol.cpp b/Network/DynamicHostConfigurationProtocol.cpp index 94ded41..7b7e596 100644 --- a/Network/DynamicHostConfigurationProtocol.cpp +++ b/Network/DynamicHostConfigurationProtocol.cpp @@ -7,6 +7,7 @@ namespace NetworkDHCP { DHCP::DHCP(NetworkUDP::Socket *Socket, NetworkInterfaceManager::DeviceInterface *Interface) { + debug("DHCP interface %#lx created.", this); this->UDPSocket = Socket; this->Interface = Interface; Socket->LocalPort = b16(68); @@ -29,6 +30,7 @@ namespace NetworkDHCP DHCP::~DHCP() { + debug("DHCP interface %#lx destroyed.", this); } void DHCP::CreatePacket(DHCPHeader *Packet, uint8_t MessageType, uint32_t RequestIP) diff --git a/Network/Ethernet.cpp b/Network/Ethernet.cpp index 92ef04e..21b3c1f 100644 --- a/Network/Ethernet.cpp +++ b/Network/Ethernet.cpp @@ -13,8 +13,15 @@ namespace NetworkEthernet Vector RegisteredEvents; - Ethernet::Ethernet(NetworkInterfaceManager::DeviceInterface *Interface) : NetworkInterfaceManager::Events(Interface) { this->Interface = Interface; } - Ethernet::~Ethernet() {} + Ethernet::Ethernet(NetworkInterfaceManager::DeviceInterface *Interface) : NetworkInterfaceManager::Events(Interface) + { + debug("Ethernet interface %#lx created.", this); + this->Interface = Interface; + } + Ethernet::~Ethernet() + { + debug("Ethernet interface %#lx destroyed.", this); + } void Ethernet::Send(MediaAccessControl MAC, FrameType Type, uint8_t *Data, uint64_t Length) { diff --git a/Network/InternetControlMessageProtocol.cpp b/Network/InternetControlMessageProtocol.cpp index 214fc34..60fcb0b 100644 --- a/Network/InternetControlMessageProtocol.cpp +++ b/Network/InternetControlMessageProtocol.cpp @@ -6,8 +6,16 @@ namespace NetworkICMPv4 { - ICMPv4::ICMPv4(NetworkInterfaceManager::DeviceInterface *Interface) { this->Interface = Interface; } - ICMPv4::~ICMPv4() {} + ICMPv4::ICMPv4(NetworkInterfaceManager::DeviceInterface *Interface) + { + debug("ICMPv4 interface %#lx created.", this); + this->Interface = Interface; + } + + ICMPv4::~ICMPv4() + { + debug("ICMPv4 interface %#lx destroyed.", this); + } void ICMPv4::Send(/* ???? */) { diff --git a/Network/InternetProtocol.cpp b/Network/InternetProtocol.cpp index 2ff10eb..ddba175 100644 --- a/Network/InternetProtocol.cpp +++ b/Network/InternetProtocol.cpp @@ -7,12 +7,14 @@ namespace NetworkIPv4 { IPv4::IPv4(NetworkARP::ARP *ARP, NetworkEthernet::Ethernet *Ethernet) : NetworkEthernet::EthernetEvents(NetworkEthernet::TYPE_IPV4) { + debug("IPv4 interface %#lx created.", this); this->ARP = ARP; this->Ethernet = Ethernet; } IPv4::~IPv4() { + debug("IPv4 interface %#lx destroyed.", this); } void IPv4::Send(uint8_t *Data, uint64_t Length, uint8_t Protocol, InternetProtocol DestinationIP) diff --git a/Network/NetworkController.cpp b/Network/NetworkController.cpp index 1576cac..f70fedf 100644 --- a/Network/NetworkController.cpp +++ b/Network/NetworkController.cpp @@ -13,6 +13,8 @@ #include "../DAPI.hpp" #include "../Fex.hpp" +/* FIXME: The functions MUST have little endian parameters and return values. */ + namespace NetworkInterfaceManager { Vector RegisteredEvents; @@ -96,6 +98,7 @@ namespace NetworkInterfaceManager NetworkUDP::UDP *udp = new NetworkUDP::UDP(ipv4, DefaultDevice); NetworkUDP::Socket *DHCP_Socket = udp->Connect(InternetProtocol() /* Default value is 255.255.255.255 */, 67); NetworkDHCP::DHCP *dhcp = new NetworkDHCP::DHCP(DHCP_Socket, DefaultDevice); + debug("eth: %p; arp: %p; ipv4: %p; udp: %p; dhcp: %p", eth, arp, ipv4, udp, dhcp); udp->Bind(DHCP_Socket, dhcp); dhcp->Request(); @@ -110,13 +113,6 @@ namespace NetworkInterfaceManager DbgWriteScreen("DNS: %s", dhcp->DomainNameSystem.v4.ToStringLittleEndian()); TaskManager->Sleep(200); - /* - I HAVE TO REWRITE THE ENTIRE NETWORK STACK BECAUSE IT'S A MESS. I HATE BYTE SWAPPING!!!!! - - Rules to follow: - - The functions MUST have little endian parameters and return values. - */ - /* TODO: This is a quick workaround we need DNS resolver asap. IP is time-a-g.nist.gov; https://tf.nist.gov/tf-cgi/servers.cgi */ InternetProtocol ip = {.v4 = {.Address = {129, 6, 15, 28}}, .v6 = {.Address = {}}}; @@ -158,8 +154,10 @@ namespace NetworkInterfaceManager void NetworkInterface::StartService() { + CPU::Interrupts(CPU::Disable); this->NetSvcThread = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (Tasking::IP)CallStartNetworkStackWrapper); this->NetSvcThread->Rename("Network Service"); + CPU::Interrupts(CPU::Enable); } void NetworkInterface::DrvSend(unsigned int DriverID, unsigned char *Data, unsigned short Size) diff --git a/Network/NetworkTimeProtocol.cpp b/Network/NetworkTimeProtocol.cpp index a4d55af..77e81d8 100644 --- a/Network/NetworkTimeProtocol.cpp +++ b/Network/NetworkTimeProtocol.cpp @@ -12,8 +12,16 @@ namespace NetworkNTP netdbg("Received UDP packet for NTP."); } - NTP::NTP(NetworkUDP::Socket *Socket) : NetworkUDP::UDPEvents() { this->UDPSocket = Socket; } - NTP::~NTP() {} + NTP::NTP(NetworkUDP::Socket *Socket) : NetworkUDP::UDPEvents() + { + debug("NTP interface %#lx created.", this); + this->UDPSocket = Socket; + } + + NTP::~NTP() + { + debug("NTP interface %#lx destroyed.", this); + } int NTP::ReadTime() { diff --git a/Network/UserDatagramProtocol.cpp b/Network/UserDatagramProtocol.cpp index d329e10..c7b7ffb 100644 --- a/Network/UserDatagramProtocol.cpp +++ b/Network/UserDatagramProtocol.cpp @@ -20,11 +20,15 @@ namespace NetworkUDP UDP::UDP(NetworkIPv4::IPv4 *ipv4, NetworkInterfaceManager::DeviceInterface *Interface) : NetworkIPv4::IPv4Events(NetworkIPv4::PROTOCOL_UDP) { + debug("UDP interface %#lx created.", this); this->ipv4 = ipv4; this->Interface = Interface; } - UDP::~UDP() {} + UDP::~UDP() + { + debug("UDP interface %#lx destroyed.", this); + } uint16_t UsablePort = 0x200;