BBA/BuiltIn: Rename m_fake_mac to m_router_mac
This commit is contained in:
parent
b029b468cd
commit
7e9711d738
|
@ -66,7 +66,6 @@ bool CEXIETHERNET::BuiltInBBAInterface::Activate()
|
||||||
m_active = true;
|
m_active = true;
|
||||||
for (auto& buf : m_queue_data)
|
for (auto& buf : m_queue_data)
|
||||||
buf.reserve(2048);
|
buf.reserve(2048);
|
||||||
m_fake_mac = Common::GenerateMacAddress(Common::MACConsumer::BBA);
|
|
||||||
|
|
||||||
// Workaround to get the host IP (might not be accurate)
|
// Workaround to get the host IP (might not be accurate)
|
||||||
const u32 ip = m_local_ip.empty() ? sf::IpAddress::getLocalAddress().toInteger() :
|
const u32 ip = m_local_ip.empty() ? sf::IpAddress::getLocalAddress().toInteger() :
|
||||||
|
@ -74,6 +73,7 @@ bool CEXIETHERNET::BuiltInBBAInterface::Activate()
|
||||||
m_current_ip = htonl(ip);
|
m_current_ip = htonl(ip);
|
||||||
m_current_mac = Common::BitCastPtr<Common::MACAddress>(&m_eth_ref->mBbaMem[BBA_NAFR_PAR0]);
|
m_current_mac = Common::BitCastPtr<Common::MACAddress>(&m_eth_ref->mBbaMem[BBA_NAFR_PAR0]);
|
||||||
m_router_ip = (m_current_ip & 0xFFFFFF) | 0x01000000;
|
m_router_ip = (m_current_ip & 0xFFFFFF) | 0x01000000;
|
||||||
|
m_router_mac = Common::GenerateMacAddress(Common::MACConsumer::BBA);
|
||||||
|
|
||||||
// clear all ref
|
// clear all ref
|
||||||
for (auto& ref : network_ref)
|
for (auto& ref : network_ref)
|
||||||
|
@ -127,7 +127,7 @@ void CEXIETHERNET::BuiltInBBAInterface::WriteToQueue(const std::vector<u8>& data
|
||||||
void CEXIETHERNET::BuiltInBBAInterface::HandleARP(const Common::ARPPacket& packet)
|
void CEXIETHERNET::BuiltInBBAInterface::HandleARP(const Common::ARPPacket& packet)
|
||||||
{
|
{
|
||||||
const auto& [hwdata, arpdata] = packet;
|
const auto& [hwdata, arpdata] = packet;
|
||||||
Common::ARPPacket response(m_current_mac, m_fake_mac);
|
Common::ARPPacket response(m_current_mac, m_router_mac);
|
||||||
|
|
||||||
if (arpdata.target_ip == m_current_ip)
|
if (arpdata.target_ip == m_current_ip)
|
||||||
{
|
{
|
||||||
|
@ -183,7 +183,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleDHCP(const Common::UDPPacket& pack
|
||||||
reply.AddOption(3, ip_part); // router ip
|
reply.AddOption(3, ip_part); // router ip
|
||||||
reply.AddOption(255, {}); // end
|
reply.AddOption(255, {}); // end
|
||||||
|
|
||||||
const Common::UDPPacket response(m_current_mac, m_fake_mac, from, to, reply.Build());
|
const Common::UDPPacket response(m_current_mac, m_router_mac, from, to, reply.Build());
|
||||||
|
|
||||||
WriteToQueue(response.Build());
|
WriteToQueue(response.Build());
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ void CEXIETHERNET::BuiltInBBAInterface::InitUDPPort(u16 port)
|
||||||
ref->remote = htons(port);
|
ref->remote = htons(port);
|
||||||
ref->type = IPPROTO_UDP;
|
ref->type = IPPROTO_UDP;
|
||||||
ref->bba_mac = m_current_mac;
|
ref->bba_mac = m_current_mac;
|
||||||
ref->my_mac = m_fake_mac;
|
ref->my_mac = m_router_mac;
|
||||||
ref->from.sin_addr.s_addr = 0;
|
ref->from.sin_addr.s_addr = 0;
|
||||||
ref->from.sin_port = htons(port);
|
ref->from.sin_port = htons(port);
|
||||||
ref->to.sin_addr.s_addr = m_current_ip;
|
ref->to.sin_addr.s_addr = m_current_ip;
|
||||||
|
@ -453,7 +453,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleUDPFrame(const Common::UDPPacket&
|
||||||
ref->remote = udp_header.destination_port;
|
ref->remote = udp_header.destination_port;
|
||||||
ref->type = IPPROTO_UDP;
|
ref->type = IPPROTO_UDP;
|
||||||
ref->bba_mac = m_current_mac;
|
ref->bba_mac = m_current_mac;
|
||||||
ref->my_mac = m_fake_mac;
|
ref->my_mac = m_router_mac;
|
||||||
ref->from.sin_addr.s_addr = destination_addr;
|
ref->from.sin_addr.s_addr = destination_addr;
|
||||||
ref->from.sin_port = udp_header.destination_port;
|
ref->from.sin_port = udp_header.destination_port;
|
||||||
ref->to.sin_addr.s_addr = Common::BitCast<u32>(ip_header.source_addr);
|
ref->to.sin_addr.s_addr = Common::BitCast<u32>(ip_header.source_addr);
|
||||||
|
|
|
@ -447,6 +447,7 @@ private:
|
||||||
u32 m_current_ip = 0;
|
u32 m_current_ip = 0;
|
||||||
Common::MACAddress m_current_mac{};
|
Common::MACAddress m_current_mac{};
|
||||||
u32 m_router_ip = 0;
|
u32 m_router_ip = 0;
|
||||||
|
Common::MACAddress m_router_mac{};
|
||||||
std::map<u32, Common::MACAddress> m_arp_table;
|
std::map<u32, Common::MACAddress> m_arp_table;
|
||||||
#if defined(WIN32) || defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
|
#if defined(WIN32) || defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
|
||||||
defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__)
|
defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__)
|
||||||
|
@ -455,7 +456,6 @@ private:
|
||||||
std::thread m_read_thread;
|
std::thread m_read_thread;
|
||||||
Common::Flag m_read_enabled;
|
Common::Flag m_read_enabled;
|
||||||
Common::Flag m_read_thread_shutdown;
|
Common::Flag m_read_thread_shutdown;
|
||||||
Common::MACAddress m_fake_mac{};
|
|
||||||
static void ReadThreadHandler(BuiltInBBAInterface* self);
|
static void ReadThreadHandler(BuiltInBBAInterface* self);
|
||||||
#endif
|
#endif
|
||||||
void WriteToQueue(const std::vector<u8>& data);
|
void WriteToQueue(const std::vector<u8>& data);
|
||||||
|
|
Loading…
Reference in New Issue