Skip to content

Commit

Permalink
DEV9: Improve support for sending multicast packets
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLastRar authored and stenzek committed May 9, 2024
1 parent cf3ad3f commit b3bb409
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 3 additions & 11 deletions pcsx2/DEV9/Sessions/UDP_Session/UDP_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace Sessions
UDP_Session::UDP_Session(ConnectionKey parKey, IP_Address parAdapterIP)
: UDP_BaseSession(parKey, parAdapterIP)
, isBroadcast(false)
, isMulticast(false)
, isFixedPort(false)
, deathClockStart(std::chrono::steady_clock::now())
{
Expand Down Expand Up @@ -180,7 +181,7 @@ namespace Sessions
if (!open)
return false;

if (isBroadcast || (parDestIP == destIP))
if (isBroadcast || isMulticast || (parDestIP == destIP))
{
deathClockStart.store(std::chrono::steady_clock::now());
return true;
Expand Down Expand Up @@ -210,13 +211,6 @@ namespace Sessions
destPort = udp.destinationPort;
srcPort = udp.sourcePort;

// Multicast address start with 0b1110
if ((destIP.bytes[0] & 0xF0) == 0xE0)
{
isMulticast = true;
Console.Error("DEV9: UDP: Unexpected multicast connection");
}

int ret;
client = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (client == INVALID_SOCKET)
Expand Down Expand Up @@ -259,8 +253,6 @@ namespace Sessions
#endif
}

pxAssert(isMulticast == false);

sockaddr_in endpoint{};
endpoint.sin_family = AF_INET;
endpoint.sin_addr = std::bit_cast<in_addr>(destIP);
Expand Down Expand Up @@ -297,7 +289,7 @@ namespace Sessions

ret = sendto(client, reinterpret_cast<const char*>(udpPayload->data), udpPayload->GetLength(), 0, reinterpret_cast<const sockaddr*>(&endpoint), sizeof(endpoint));
}
else if (isMulticast | isFixedPort)
else if (isFixedPort)
{
sockaddr_in endpoint{};
endpoint.sin_family = AF_INET;
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/DEV9/Sessions/UDP_Session/UDP_Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Sessions
u16 destPort = 0;
// UDP_Session flags
const bool isBroadcast;
bool isMulticast = false;
const bool isMulticast;
const bool isFixedPort;

std::atomic<std::chrono::steady_clock::time_point> deathClockStart;
Expand Down

0 comments on commit b3bb409

Please sign in to comment.