mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-26 15:26:43 +00:00
Implement NetRep for full network data report.
Implement IPV4Rep to report local, router, and subnet IPV4 addresses. Expand UDPRep to report socket timeout and info about messages queued at the socket.
This commit is contained in:
parent
91f380b0b6
commit
3df5dd4a9f
8 changed files with 106 additions and 10 deletions
Binary file not shown.
|
@ -213,7 +213,13 @@ U0 ARPRep()
|
|||
CARPHash *temp_hash;
|
||||
U32 address;
|
||||
|
||||
"\n";
|
||||
"$$LTBLUE$$ARP Report:$$FG$$\n\n";
|
||||
"ARP Local Address: $FG,6$%d.%d.%d.%d$FG$\n\n",
|
||||
arp_globals.local_ipv4.u8[0],
|
||||
arp_globals.local_ipv4.u8[1],
|
||||
arp_globals.local_ipv4.u8[2],
|
||||
arp_globals.local_ipv4.u8[3];
|
||||
|
||||
for (i = 0; i <= arp_cache->mask; i++)
|
||||
{
|
||||
temp_hash = arp_cache->body[i];
|
||||
|
|
|
@ -526,3 +526,12 @@ U0 NetConfigure()
|
|||
else
|
||||
NetLog("$$BG,2$$$$FG,15$$==== Network Configure Success ====$$FG$$$$BG$$");
|
||||
}
|
||||
|
||||
U0 NetRep()
|
||||
{
|
||||
"\n$$LTGREEN$$Network Report:$$FG$$\n\n";
|
||||
UDPRep;
|
||||
DNSRep;
|
||||
ARPRep;
|
||||
IPV4Rep;
|
||||
}
|
|
@ -654,7 +654,7 @@ U0 DNSRep()
|
|||
I64 i;
|
||||
CDNSHash *temp_hash;
|
||||
|
||||
"\n";
|
||||
"$$LTBLUE$$DNS Report:$$FG$$\n\n";
|
||||
for (i = 0; i <= dns_cache->mask; i++)
|
||||
{
|
||||
temp_hash = dns_cache->body[i];
|
||||
|
@ -663,8 +663,8 @@ U0 DNSRep()
|
|||
{
|
||||
|
||||
"DNS Hash @ $FG,3$0x%X$FG$:\n", temp_hash;
|
||||
" Hostname: $FG,6$%s$FG$\n", temp_hash->str;
|
||||
" Address: $FG,6$%s$FG$\n",
|
||||
" Hostname: $FG,6$%s$FG$\n", temp_hash->str;
|
||||
" IP Address: $FG,6$%s$FG$\n",
|
||||
NetworkToPresentation(temp_hash->info.family,
|
||||
&temp_hash->info.address(CSocketAddressIPV4 *)->address);
|
||||
// TODO: IPV4 kludge
|
||||
|
@ -673,7 +673,6 @@ U0 DNSRep()
|
|||
temp_hash = temp_hash->next;
|
||||
}
|
||||
}
|
||||
"\n";
|
||||
}
|
||||
|
||||
DNSCacheInit;
|
|
@ -259,5 +259,27 @@ U0 IPV4PacketParse(CIPV4Packet *packet_out, CEthernetFrame *ethernet_frame)
|
|||
// return 0;
|
||||
}
|
||||
|
||||
U0 IPV4Rep()
|
||||
{
|
||||
"$$LTBLUE$$IPV4 Report:$$FG$$\n\n";
|
||||
|
||||
"Local IPV4:$FG,6$ %d.%d.%d.%d$FG$\n",
|
||||
ipv4_globals.local_ip.u8[3],
|
||||
ipv4_globals.local_ip.u8[2],
|
||||
ipv4_globals.local_ip.u8[1],
|
||||
ipv4_globals.local_ip.u8[0];
|
||||
"Router IPV4:$FG,6$ %d.%d.%d.%d$FG$\n",
|
||||
ipv4_globals.ipv4_router_address.u8[3],
|
||||
ipv4_globals.ipv4_router_address.u8[2],
|
||||
ipv4_globals.ipv4_router_address.u8[1],
|
||||
ipv4_globals.ipv4_router_address.u8[0];
|
||||
"Subnet IPV4:$FG,6$ %d.%d.%d.%d$FG$\n",
|
||||
ipv4_globals.ipv4_subnet_mask.u8[3],
|
||||
ipv4_globals.ipv4_subnet_mask.u8[2],
|
||||
ipv4_globals.ipv4_subnet_mask.u8[1],
|
||||
ipv4_globals.ipv4_subnet_mask.u8[0];
|
||||
"\n";
|
||||
}
|
||||
|
||||
// IPV4 handler moved to NetHandlerTask file.
|
||||
IPV4GlobalsInit;
|
|
@ -25,6 +25,8 @@ if (Fs != zenith_task)
|
|||
{
|
||||
if (ipv4_globals.local_ip != 0) // is set if NetConfigure is successful
|
||||
{
|
||||
NetRep;
|
||||
|
||||
"\nNow run one of the $MA,"Tests",LM="Cd(\"C:/Home/Net/Tests\");Dir;\n"$.\n";
|
||||
|
||||
"\nIf a test crashes to Debug, try typing $FG,0$G2;$FG$\n\n";
|
||||
|
|
23
src/Home/Net/Tests/UDPSocketTest2.CC
Executable file
23
src/Home/Net/Tests/UDPSocketTest2.CC
Executable file
|
@ -0,0 +1,23 @@
|
|||
U0 UDPSocketTest()
|
||||
{
|
||||
CUDPSocket *u = UDPSocket(AF_INET);
|
||||
CSocketAddressIPV4 *i = CAlloc(sizeof(CSocketAddressIPV4));
|
||||
|
||||
i->port = EndianU16(64222);
|
||||
i->family = AF_INET;
|
||||
i->address.address = INADDR_ANY;
|
||||
|
||||
UDPSocketBind(u, i);
|
||||
|
||||
"UDP Socket bound at port %d.\n", EndianU16(i->port);
|
||||
"Send UDP data to the VM, then run UDPRep to see received message data in report.\n";
|
||||
|
||||
while (!CharScan)
|
||||
Refresh;
|
||||
|
||||
UDPSocketClose(u);
|
||||
|
||||
Free(i);
|
||||
}
|
||||
|
||||
UDPSocketTest;
|
|
@ -804,8 +804,9 @@ U0 UDPTreeNodeRep(CUDPTreeNode *node)
|
|||
CSocketAddressIPV4 *ipv4_addr;
|
||||
CSocketAddressIPV6 *ipv6_addr;
|
||||
U8 *string;
|
||||
CUDPMessageQueue *message;
|
||||
|
||||
"Port $$YELLOW$$%d$$FG$$:\n", node->port;
|
||||
"Port $$YELLOW$$%d$$FG$$ (UDP Node @ $$CYAN$$0x%X$$FG$$):\n", node->port, node;
|
||||
|
||||
while (queue != node->queue)
|
||||
{
|
||||
|
@ -820,13 +821,13 @@ U0 UDPTreeNodeRep(CUDPTreeNode *node)
|
|||
|
||||
case AF_INET:
|
||||
ipv4_addr = &socket->receive_address;
|
||||
string = MStrPrint("%d.%d.%d.%d$FG$",
|
||||
string = MStrPrint("%d.%d.%d.%d",
|
||||
ipv4_addr->address.address.u8[3],
|
||||
ipv4_addr->address.address.u8[2],
|
||||
ipv4_addr->address.address.u8[1],
|
||||
ipv4_addr->address.address.u8[0]); // todo: kludge, endianness...
|
||||
|
||||
" $$LTGREEN$$%s$$FG$$\n", string;
|
||||
" $$BROWN$$%s$$FG$$ (UDP Tree Queue @ $$CYAN$$0x%X$$FG$$):\n", string, queue;
|
||||
Free(string);
|
||||
|
||||
break;
|
||||
|
@ -841,11 +842,43 @@ U0 UDPTreeNodeRep(CUDPTreeNode *node)
|
|||
|
||||
}
|
||||
|
||||
" Timeout: %dms\n", socket->receive_timeout_ms;
|
||||
if (socket->receive_queue) // todo: move socket messages Queue alloc from bind to creation to avoid check?
|
||||
{
|
||||
message = socket->receive_queue->next;
|
||||
while (message != socket->receive_queue)
|
||||
{
|
||||
" Queued Message @ $$CYAN$$0x%X$$FG$$:\n", message;
|
||||
switch (message->from_address.family)
|
||||
{
|
||||
case AF_UNSPEC:
|
||||
string = StrNew("AF_UNSPEC");
|
||||
break;
|
||||
case AF_INET:
|
||||
ipv4_addr = &message->from_address;
|
||||
string = NetworkToPresentation(ipv4_addr->family, &ipv4_addr->address);
|
||||
break;
|
||||
case AF_INET6:
|
||||
string = StrNew("IPV6");
|
||||
break;
|
||||
default:
|
||||
string = StrNew("INVALID");
|
||||
break;
|
||||
}
|
||||
" From Address: $$BROWN$$%s$$FG$$\n", string;
|
||||
" Data length: %d\n", message->data_length;
|
||||
" Received data length: %d\n", message->received_length;
|
||||
|
||||
Free(string);
|
||||
|
||||
message = message->next;
|
||||
}
|
||||
}
|
||||
|
||||
queue = queue->next;
|
||||
}
|
||||
|
||||
"\n";
|
||||
|
||||
}
|
||||
|
||||
U0 UDPRep()
|
||||
|
@ -855,6 +888,8 @@ U0 UDPRep()
|
|||
CUDPRepEntry *entry;
|
||||
CUDPRepEntry *temp_entry;
|
||||
|
||||
"$$LTBLUE$$UDP Report:$$FG$$\n\n";
|
||||
|
||||
if (node)
|
||||
{
|
||||
head = CAlloc(sizeof(CUDPRepEntry));
|
||||
|
@ -936,7 +971,7 @@ U0 UDPRep()
|
|||
Free(head);
|
||||
}
|
||||
else
|
||||
"No UDP Sockets currently bound.\n";
|
||||
"No UDP Sockets currently bound.\n\n";
|
||||
}
|
||||
|
||||
UDPGlobalsInit;
|
Loading…
Reference in a new issue