DEV9: Improve support for sending multicast packets

This commit is contained in:
TheLastRar 2024-05-01 22:09:31 +01:00 committed by Connor McLaughlin
parent cf3ad3f855
commit b3bb40980e
2 changed files with 4 additions and 12 deletions

View File

@ -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())
{
@ -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;
@ -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)
@ -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);
@ -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;

View File

@ -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;