DEV9: Correct alignment calculation in Sockets

This commit is contained in:
TheLastRar 2024-12-03 22:28:12 +00:00 committed by Ty
parent 00f4cd5252
commit f317ba327c
2 changed files with 6 additions and 4 deletions

View File

@ -4,6 +4,7 @@
#include "IP_Packet.h"
#include "DEV9/PacketReader/NetLib.h"
#include "common/BitUtils.h"
#include "common/Console.h"
namespace PacketReader::IP
@ -209,8 +210,8 @@ namespace PacketReader::IP
for (size_t i = 0; i < options.size(); i++)
opOffset += options[i]->GetLength();
opOffset += opOffset % 4; //needs to be a whole number of 32bits
headerLength = opOffset;
//needs to be a whole number of 32bits
headerLength = Common::AlignUpPow2(opOffset, 4);
}
void IP_Packet::CalculateChecksum()

View File

@ -4,6 +4,7 @@
#include "TCP_Packet.h"
#include "DEV9/PacketReader/NetLib.h"
#include "common/BitUtils.h"
#include "common/Console.h"
namespace PacketReader::IP::TCP
@ -232,8 +233,8 @@ namespace PacketReader::IP::TCP
for (size_t i = 0; i < options.size(); i++)
opOffset += options[i]->GetLength();
opOffset += opOffset % 4; //needs to be a whole number of 32bits
headerLength = opOffset;
//needs to be a whole number of 32bits
headerLength = Common::AlignUpPow2(opOffset, 4);
//Also write into dataOffsetAndNS_Flag
u8 ns = dataOffsetAndNS_Flag & 1;