Skip to content

Commit

Permalink
DEV9: Correct alignment calculation in Sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLastRar authored and F0bes committed Dec 5, 2024
1 parent 00f4cd5 commit f317ba3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pcsx2/DEV9/PacketReader/IP/IP_Packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "IP_Packet.h"
#include "DEV9/PacketReader/NetLib.h"

#include "common/BitUtils.h"
#include "common/Console.h"

namespace PacketReader::IP
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions pcsx2/DEV9/PacketReader/IP/TCP/TCP_Packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f317ba3

Please sign in to comment.