mirror of https://github.com/PCSX2/pcsx2.git
DEV9: Move Tap's packet verification into NetAdapter
Make pcap use it for addition of bridge mode
This commit is contained in:
parent
82493343fa
commit
2e8ca89f3d
|
@ -310,7 +310,6 @@ bool TAPAdapter::isInitialised()
|
||||||
{
|
{
|
||||||
return (htap != NULL);
|
return (htap != NULL);
|
||||||
}
|
}
|
||||||
u8 broadcast_adddrrrr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
|
||||||
//gets a packet.rv :true success
|
//gets a packet.rv :true success
|
||||||
bool TAPAdapter::recv(NetPacket* pkt)
|
bool TAPAdapter::recv(NetPacket* pkt)
|
||||||
{
|
{
|
||||||
|
@ -340,23 +339,8 @@ bool TAPAdapter::recv(NetPacket* pkt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
return VerifyPkt(pkt, read_size);
|
||||||
if ((memcmp(pkt->buffer, dev9.eeprom, 6) != 0) && (memcmp(pkt->buffer, &broadcast_adddrrrr, 6) != 0))
|
|
||||||
{
|
|
||||||
//ignore strange packets
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (memcmp(pkt->buffer + 6, dev9.eeprom, 6) == 0)
|
|
||||||
{
|
|
||||||
//avoid pcap looping packets
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pkt->size = read_size;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,3 +177,20 @@ void NetAdapter::SetMACAddress(u8* mac)
|
||||||
//The checksum seems to be all the values of the mac added up in 16bit chunks
|
//The checksum seems to be all the values of the mac added up in 16bit chunks
|
||||||
dev9.eeprom[3] = (dev9.eeprom[0] + dev9.eeprom[1] + dev9.eeprom[2]) & 0xffff;
|
dev9.eeprom[3] = (dev9.eeprom[0] + dev9.eeprom[1] + dev9.eeprom[2]) & 0xffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NetAdapter::VerifyPkt(NetPacket* pkt, int read_size)
|
||||||
|
{
|
||||||
|
if ((memcmp(pkt->buffer, ps2MAC, 6) != 0) && (memcmp(pkt->buffer, &broadcastMAC, 6) != 0))
|
||||||
|
{
|
||||||
|
//ignore strange packets
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memcmp(pkt->buffer + 6, ps2MAC, 6) == 0)
|
||||||
|
{
|
||||||
|
//avoid pcap looping packets
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
pkt->size = read_size;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ class NetAdapter
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
u8 ps2MAC[6];
|
u8 ps2MAC[6];
|
||||||
|
const u8 broadcastMAC[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetAdapter();
|
NetAdapter();
|
||||||
|
@ -73,6 +74,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetMACAddress(u8* mac);
|
void SetMACAddress(u8* mac);
|
||||||
|
bool VerifyPkt(NetPacket* pkt, int read_size);
|
||||||
};
|
};
|
||||||
|
|
||||||
void tx_put(NetPacket* ptr);
|
void tx_put(NetPacket* ptr);
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
pcap_t* adhandle;
|
pcap_t* adhandle;
|
||||||
pcap_dumper_t* dump_pcap = nullptr;
|
pcap_dumper_t* dump_pcap = nullptr;
|
||||||
char errbuf[PCAP_ERRBUF_SIZE];
|
char errbuf[PCAP_ERRBUF_SIZE];
|
||||||
mac_address broadcast_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
|
||||||
|
|
||||||
int pcap_io_running = 0;
|
int pcap_io_running = 0;
|
||||||
extern u8 eeprom[];
|
extern u8 eeprom[];
|
||||||
|
@ -279,8 +278,7 @@ bool PCAPAdapter::recv(NetPacket* pkt)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pkt->size = size;
|
return VerifyPkt(pkt, size);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//sends the packet .rv :true success
|
//sends the packet .rv :true success
|
||||||
|
|
|
@ -148,9 +148,6 @@ typedef struct _full_arp_packet
|
||||||
|
|
||||||
#define ARP_REQUEST 0x0100 //values are big-endian
|
#define ARP_REQUEST 0x0100 //values are big-endian
|
||||||
|
|
||||||
extern mac_address virtual_mac;
|
|
||||||
extern mac_address broadcast_mac;
|
|
||||||
|
|
||||||
#define mac_compare(a, b) (memcmp(&(a), &(b), 6))
|
#define mac_compare(a, b) (memcmp(&(a), &(b), 6))
|
||||||
#define ip_compare(a, b) (memcmp(&(a), &(b), 4))
|
#define ip_compare(a, b) (memcmp(&(a), &(b), 4))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue