mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-27 07:46:33 +00:00
Fixed PCNet DE index rollover packet buffer bug.
Added few more networking tests and changed variables in some of them for making it easier to differentiate them in Wireshark .pcap results.
This commit is contained in:
parent
fc0bf860b1
commit
3ef48c1e28
9 changed files with 82 additions and 4 deletions
Binary file not shown.
|
@ -23,5 +23,6 @@ if (Fs != zenith_task)
|
|||
|
||||
#include "C:/Home/Net/NetHandlerTask" // needs IPV4, UDP, ICMP
|
||||
|
||||
"\nNow run $FG,0$NetConfigure;$FG$ or run one of the $MA,"Tests",LM="Cd(\"C:/Home/Net/Tests\");Dir;\n"$.\n\n";
|
||||
NetConfigure;
|
||||
|
||||
"\nNow run one of the $MA,"Tests",LM="Cd(\"C:/Home/Net/Tests\");Dir;\n"$.\n\n";
|
|
@ -496,6 +496,8 @@ I64 PCNetAllocateTransmitPacket(U8 **packet_buffer_out, I64 length)
|
|||
buffer_byte_count = -length; // Sets up as 2s complement of the desired length.
|
||||
buffer_byte_count &= 0x0FFF; // Masks 0 over everything except bits 0-11.
|
||||
|
||||
entry->status1 &= 0xFFFFF000; // Clear first 12 bits and retain other bits in DE TMD1.
|
||||
|
||||
entry->status1 |= buffer_byte_count; // Sets BCNT reg (first 12 bits) in DE TMD1.
|
||||
entry->status1 |= 0xF000; // Sets bits 12-15 (ONES) in DE TMD1 as all ones.
|
||||
|
||||
|
@ -503,6 +505,8 @@ I64 PCNetAllocateTransmitPacket(U8 **packet_buffer_out, I64 length)
|
|||
|
||||
*packet_buffer_out = pcnet.tx_buffer_addr + (de_index * ETHERNET_FRAME_SIZE);
|
||||
|
||||
MemSet(*packet_buffer_out, 0, ETHERNET_FRAME_SIZE); // Clear buffer contents in advance.
|
||||
|
||||
ZenithLog("PCNET ALLOCATE TX PACKET: de_index: %X.\n", de_index);
|
||||
return de_index;
|
||||
}
|
||||
|
|
13
src/Home/Net/Tests/DHCPSendTrash0.CC
Executable file
13
src/Home/Net/Tests/DHCPSendTrash0.CC
Executable file
|
@ -0,0 +1,13 @@
|
|||
|
||||
U0 DHCPSendTrash()
|
||||
{
|
||||
while (TRUE)
|
||||
{
|
||||
DHCPSendDiscover(0xDEADBEEF);
|
||||
Sleep(300);
|
||||
DHCPSendRequest(0xDEADBEEF, 0xC0DEFADE, 0xFEEDFACE);
|
||||
Sleep(300);
|
||||
}
|
||||
}
|
||||
|
||||
DHCPSendTrash;
|
27
src/Home/Net/Tests/DHCPSendTrash1.CC
Executable file
27
src/Home/Net/Tests/DHCPSendTrash1.CC
Executable file
|
@ -0,0 +1,27 @@
|
|||
U8 dst_mac[6] = {0xF0, 0x0D, 0xBE, 0xAD, 0xDE, 0xAF};
|
||||
|
||||
U32 dst_ip = 0x01020304;
|
||||
|
||||
U0 DHCPSendTrash()
|
||||
{ // DHCPConfigure, then send UDP trash.
|
||||
|
||||
U8 *udp_payload;
|
||||
I64 de_index;
|
||||
|
||||
ARPCachePut(dst_ip, dst_mac); // Force entry into ARP Cache so IPV4 can match it with GetMACAddressForIP
|
||||
|
||||
DHCPConfigure;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
|
||||
de_index = UDPPacketAllocate(&udp_payload, arp_globals.local_ipv4, 0xDEAD, dst_ip, 0xBEEF, 8);
|
||||
|
||||
*(udp_payload(U64 *)) = EndianU64(0xDEADBEEFC0DEFADE);
|
||||
|
||||
UDPPacketFinish(de_index);
|
||||
Sleep(300);
|
||||
}
|
||||
}
|
||||
|
||||
DHCPSendTrash;
|
33
src/Home/Net/Tests/DHCPSendTrash2.CC
Executable file
33
src/Home/Net/Tests/DHCPSendTrash2.CC
Executable file
|
@ -0,0 +1,33 @@
|
|||
U8 src[6] = {0xDE, 0xAD, 0xBE, 0xEF, 0xC0, 0xDE};
|
||||
U8 dst[6] = {0xF0, 0x0D, 0xBE, 0xAD, 0xDE, 0xAF};
|
||||
|
||||
U0 DHCPSendTrash()
|
||||
{
|
||||
CUDPSocket *udp_socket = UDPSocket(AF_INET);
|
||||
U32 your_ip;
|
||||
U32 dns_ip;
|
||||
U32 router_ip;
|
||||
U32 subnet_mask;
|
||||
U8 *packet_buffer;
|
||||
I64 de_index;
|
||||
|
||||
|
||||
DHCPConfigureInner(udp_socket, &your_ip, &dns_ip, &router_ip, &subnet_mask);
|
||||
|
||||
UDPSocketClose(udp_socket);
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
de_index = EthernetFrameAllocate(&packet_buffer, src, dst, 0x0000, 8);
|
||||
|
||||
*(packet_buffer(U64 *)) = EndianU64(0xDEADBEEFC0DEFADE);
|
||||
|
||||
EthernetFrameFinish(de_index);
|
||||
|
||||
Sleep(300);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
DHCPSendTrash;
|
|
@ -11,7 +11,7 @@ U0 EthernetSendTrash()
|
|||
{
|
||||
de_index = EthernetFrameAllocate(&packet_buffer, src, dst, 0x0000, 8);
|
||||
|
||||
*(packet_buffer(U64 *)) = EndianU64(0xDEADBEEFC0DEFADE);
|
||||
*(packet_buffer(U64 *)) = EndianU64(0xC0DEFADEDEADBEEF);
|
||||
|
||||
EthernetFrameFinish(de_index);
|
||||
Sleep(300);
|
||||
|
|
|
@ -7,7 +7,7 @@ U0 ICMPSendTrash()
|
|||
{
|
||||
U8 *data_payload = CAlloc(8);
|
||||
|
||||
*(data_payload(U64 *)) = EndianU64(0xDEADBEEFC0DEFADE);
|
||||
*(data_payload(U64 *)) = EndianU64(0xDEADC0DEBEEFFADE);
|
||||
|
||||
ARPCachePut(dst_ip, dst_mac); // Force entry into ARP Cache so IPV4 can match it with GetMACAddressForIP
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ U0 IPV4SendTrash()
|
|||
{
|
||||
de_index = IPV4PacketAllocate(&ipv4_packet_buffer, 0xFF, src_ip, dst_ip, 8);
|
||||
|
||||
*(ipv4_packet_buffer(U64 *)) = EndianU64(0xDEADBEEFC0DEFADE);
|
||||
*(ipv4_packet_buffer(U64 *)) = EndianU64(0xBEEFDEADFADEC0DE);
|
||||
|
||||
IPV4PacketFinish(de_index);
|
||||
Sleep(300);
|
||||
|
|
Loading…
Reference in a new issue