Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/ne2k.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,21 @@ export function Ne2k(cpu, bus, preserve_mac_from_state_image, mac_address_transl
dump_packet(data, "send");
}

if(this.mac_address_in_state)
if(this.mac_address_translation)
{
data = new Uint8Array(data); // make a copy

if(!this.mac_address_in_state)
{
this.mac_address_in_state = new Uint8Array(6);
}

// Forcefully learn the guest mac from the ethernet source field (bytes 6-11)
for(var i = 0; i < 6; i++)
{
this.mac_address_in_state[i] = data[6 + i];
}

translate_mac_address(data, this.mac_address_in_state, this.mac);
}

Expand Down Expand Up @@ -906,7 +918,15 @@ export function Ne2k(cpu, bus, preserve_mac_from_state_image, mac_address_transl
else if(pg === 1)
{
dbg_log("mac[3] = " + h(data_byte), LOG_NET);
this.mac[3] = data_byte;
if(this.mac_address_translation)
{
if(!this.mac_address_in_state) this.mac_address_in_state = new Uint8Array(6);
this.mac_address_in_state[3] = data_byte;
}
else
{
this.mac[3] = data_byte;
}
}
else
{
Expand Down Expand Up @@ -976,7 +996,7 @@ export function Ne2k(cpu, bus, preserve_mac_from_state_image, mac_address_transl
else if(pg === 1)
{
dbg_log("Read pg1/06 (mac[5])", LOG_NET);
return this.mac[5];
return this.mac_address_translation && this.mac_address_in_state ? this.mac_address_in_state[5] : this.mac[5];
}
else if(pg === 3)
{
Expand Down