Skip to content

Commit

Permalink
DEV9: Drop looped IP packets
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLastRar committed Nov 21, 2024
1 parent 5a37e3a commit 5f134a1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pcsx2/DEV9/pcap_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,17 @@ bool PCAPAdapter::recv(NetPacket* pkt)
continue;
}

// Avoid pcap looping packets by checking IP
IP_Packet ipPkt(const_cast<u_char*>(pkt_data), header->len);
if (ipPkt.sourceIP == ps2IP)
{
continue;
}

pxAssert(header->len == header->caplen);

// Build EtherFrame using captured packet
PayloadPtr* pl = new PayloadPtr(const_cast<u_char*>(pkt_data), header->len);
IP_Packet test(const_cast<u_char*>(pkt_data), header->len, false);
EthernetFrame frame(pl);
frame.sourceMAC = internalMAC;
frame.destinationMAC = ps2MAC;
Expand Down Expand Up @@ -238,6 +244,11 @@ bool PCAPAdapter::send(NetPacket* pkt)
PayloadPtr* payload = frame.GetPayload();
IP_Packet pkt(payload->data, payload->GetLength());

if (pkt.sourceIP != IP_Address{{{0, 0, 0, 0}}})
{
ps2IP = pkt.sourceIP;
}

if (pcap_sendpacket(hpcap, payload->data, pkt.GetLength()))
return false;
else
Expand Down

0 comments on commit 5f134a1

Please sign in to comment.