DEV9: Correct Console Logs

This commit is contained in:
TheLastRar 2024-04-06 17:23:19 +01:00 committed by lightningterror
parent 889af7cf17
commit 569b93da51
3 changed files with 18 additions and 16 deletions

View File

@ -81,9 +81,9 @@ namespace Sessions
ret->destinationPort = srcPort; ret->destinationPort = srcPort;
ret->sequenceNumber = GetMyNumber(); ret->sequenceNumber = GetMyNumber();
//DevCon.WriteLn("With MySeq: %d", ret->sequenceNumber); //DevCon.WriteLn("With MySeq: %u", ret->sequenceNumber);
ret->acknowledgementNumber = expectedSeqNumber; ret->acknowledgementNumber = expectedSeqNumber;
//DevCon.WriteLn("With MyAck: %d", ret->acknowledgementNumber); //DevCon.WriteLn("With MyAck: %u", ret->acknowledgementNumber);
ret->windowSize = 2 * maxSegmentSize; ret->windowSize = 2 * maxSegmentSize;

View File

@ -80,7 +80,9 @@ namespace Sessions
int err = 0; int err = 0;
int recived; int recived;
unsigned long available; //FIONREAD uses unsigned long on windows and int on linux
//Zero init so we don't have bad data on any unused bytes
unsigned long available = 0;
#ifdef _WIN32 #ifdef _WIN32
err = ioctlsocket(client, FIONREAD, &available); err = ioctlsocket(client, FIONREAD, &available);
#elif defined(__POSIX__) #elif defined(__POSIX__)
@ -89,7 +91,7 @@ namespace Sessions
if (err != SOCKET_ERROR) if (err != SOCKET_ERROR)
{ {
if (available > maxSize) if (available > maxSize)
Console.WriteLn("DEV9: TCP: Got a lot of data: %d Using: %d", available, maxSize); Console.WriteLn("DEV9: TCP: Got a lot of data: %lu Using: %d", available, maxSize);
buffer = std::make_unique<u8[]>(maxSize); buffer = std::make_unique<u8[]>(maxSize);
recived = recv(client, (char*)buffer.get(), maxSize, 0); recived = recv(client, (char*)buffer.get(), maxSize, 0);

View File

@ -361,7 +361,7 @@ namespace Sessions
//Done send //Done send
} }
//ACK data //ACK data
//DevCon.WriteLn("[SRV] ACK Data: %d", expectedSeqNumber); //DevCon.WriteLn("[SRV] ACK Data: %u", expectedSeqNumber);
TCP_Packet* ret = CreateBasePacket(); TCP_Packet* ret = CreateBasePacket();
ret->SetACK(true); ret->SetACK(true);
@ -402,11 +402,11 @@ namespace Sessions
TCP_Session::NumCheckResult TCP_Session::CheckRepeatSYNNumbers(TCP_Packet* tcp) TCP_Session::NumCheckResult TCP_Session::CheckRepeatSYNNumbers(TCP_Packet* tcp)
{ {
//DevCon.WriteLn("DEV9: TCP: CHECK_REPEAT_SYN_NUMBERS"); //DevCon.WriteLn("DEV9: TCP: CHECK_REPEAT_SYN_NUMBERS");
//DevCon.WriteLn("DEV9: TCP: [SRV]CurrAckNumber = %d [PS2]Seq Number = %d", expectedSeqNumber, tcp->sequenceNumber); //DevCon.WriteLn("DEV9: TCP: [SRV] CurrAckNumber = %u [PS2] Seq Number = %u", expectedSeqNumber, tcp->sequenceNumber);
if (tcp->sequenceNumber != expectedSeqNumber - 1) if (tcp->sequenceNumber != expectedSeqNumber - 1)
{ {
Console.Error("DEV9: TCP: [PS2] Sent Unexpected Sequence Number From Repeated SYN Packet, Got %d Expected %d", tcp->sequenceNumber, (expectedSeqNumber - 1)); Console.Error("DEV9: TCP: [PS2] Sent Unexpected Sequence Number From Repeated SYN Packet, Got %u Expected %u", tcp->sequenceNumber, (expectedSeqNumber - 1));
return NumCheckResult::Bad; return NumCheckResult::Bad;
} }
return NumCheckResult::OK; return NumCheckResult::OK;
@ -419,24 +419,24 @@ namespace Sessions
std::tie(seqNum, oldSeqNums) = GetAllMyNumbers(); std::tie(seqNum, oldSeqNums) = GetAllMyNumbers();
//DevCon.WriteLn("DEV9: TCP: CHECK_NUMBERS"); //DevCon.WriteLn("DEV9: TCP: CHECK_NUMBERS");
//DevCon.WriteLn("DEV9: TCP: [SRV]CurrSeqNumber = %d [PS2]Ack Number = %d", seqNum, tcp->acknowledgementNumber); //DevCon.WriteLn("DEV9: TCP: [SRV] CurrSeqNumber = %u [PS2] Ack Number = %u", seqNum, tcp->acknowledgementNumber);
//DevCon.WriteLn("DEV9: TCP: [SRV]CurrAckNumber = %d [PS2]Seq Number = %d", expectedSeqNumber, tcp->sequenceNumber); //DevCon.WriteLn("DEV9: TCP: [SRV] CurrAckNumber = %u [PS2] Seq Number = %u", expectedSeqNumber, tcp->sequenceNumber);
//DevCon.WriteLn("DEV9: TCP: [PS2]Data Length = %d", tcp->GetPayload()->GetLength()); //DevCon.WriteLn("DEV9: TCP: [PS2] Data Length = %u", tcp->GetPayload()->GetLength());
if (tcp->acknowledgementNumber != seqNum) if (tcp->acknowledgementNumber != seqNum)
{ {
//DevCon.WriteLn("DEV9: TCP: [PS2]Sent Outdated Acknowledgement Number, Got %d Expected %d", tcp->acknowledgementNumber, seqNum); //DevCon.WriteLn("DEV9: TCP: [PS2] Sent Outdated Acknowledgement Number, Got %u Expected %u", tcp->acknowledgementNumber, seqNum);
//Check if oldSeqNums contains tcp->acknowledgementNumber //Check if oldSeqNums contains tcp->acknowledgementNumber
if (std::find(oldSeqNums.begin(), oldSeqNums.end(), tcp->acknowledgementNumber) == oldSeqNums.end()) if (std::find(oldSeqNums.begin(), oldSeqNums.end(), tcp->acknowledgementNumber) == oldSeqNums.end())
{ {
Console.Error("DEV9: TCP: [PS2] Sent Unexpected Acknowledgement Number, did not Match Old Numbers, Got %d Expected %d", tcp->acknowledgementNumber, seqNum); Console.Error("DEV9: TCP: [PS2] Sent Unexpected Acknowledgement Number, did not Match Old Numbers, Got %u Expected %u", tcp->acknowledgementNumber, seqNum);
return NumCheckResult::Bad; return NumCheckResult::Bad;
} }
} }
else else
{ {
//DevCon.WriteLn("[PS2]CurrSeqNumber Acknowleged By PS2"); //DevCon.WriteLn("[PS2] CurrSeqNumber Acknowleged By PS2");
myNumberACKed.store(true); myNumberACKed.store(true);
} }
@ -444,19 +444,19 @@ namespace Sessions
{ {
if (tcp->GetPayload()->GetLength() == 0) if (tcp->GetPayload()->GetLength() == 0)
{ {
Console.Error("DEV9: TCP: [PS2] Sent Unexpected Sequence Number From ACK Packet, Got %d Expected %d", tcp->sequenceNumber, expectedSeqNumber); Console.Error("DEV9: TCP: [PS2] Sent Unexpected Sequence Number From ACK Packet, Got %u Expected %u", tcp->sequenceNumber, expectedSeqNumber);
} }
else else
{ {
//Check if receivedPS2SeqNumbers contains tcp->sequenceNumber //Check if receivedPS2SeqNumbers contains tcp->sequenceNumber
if (std::find(receivedPS2SeqNumbers.begin(), receivedPS2SeqNumbers.end(), tcp->sequenceNumber) == receivedPS2SeqNumbers.end()) if (std::find(receivedPS2SeqNumbers.begin(), receivedPS2SeqNumbers.end(), tcp->sequenceNumber) == receivedPS2SeqNumbers.end())
{ {
Console.Error("DEV9: TCP: [PS2] Sent an Old Seq Number on an Data packet, Got %d Expected %d", tcp->sequenceNumber, expectedSeqNumber); Console.Error("DEV9: TCP: [PS2] Sent an Old Seq Number on an Data packet, Got %u Expected %u", tcp->sequenceNumber, expectedSeqNumber);
return NumCheckResult::GotOldData; return NumCheckResult::GotOldData;
} }
else else
{ {
Console.Error("DEV9: TCP: [PS2] Sent Unexpected Sequence Number From Data Packet, Got %d Expected %d", tcp->sequenceNumber, expectedSeqNumber); Console.Error("DEV9: TCP: [PS2] Sent Unexpected Sequence Number From Data Packet, Got %u Expected %u", tcp->sequenceNumber, expectedSeqNumber);
return NumCheckResult::Bad; return NumCheckResult::Bad;
} }
} }