mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-07 22:05:21 +00:00
- outgoing packet source address is set in ether.cpp
- UDP tunnelling sends packets to Ethernet broadcast address as IP broadcasts
This commit is contained in:
parent
72c7f0db7a
commit
78c97c3f20
@ -585,10 +585,9 @@ static __saveds void net_func(void)
|
||||
}
|
||||
write_io->ios2_DataLength = len;
|
||||
|
||||
// Get destination address, set source address
|
||||
// Get destination address
|
||||
uint32 hdr = ReadMacInt32(wds + 2);
|
||||
Mac2Host_memcpy(write_io->ios2_DstAddr, hdr, 6);
|
||||
Host2Mac_memcpy(hdr + 6, ether_addr, 6);
|
||||
|
||||
// Get packet type
|
||||
uint32 type = ReadMacInt16(hdr + 12);
|
||||
|
@ -363,9 +363,6 @@ int16 ether_write(uint32 wds)
|
||||
// Copy packet to buffer
|
||||
int len = ether_wds_to_buffer(wds, p->data);
|
||||
|
||||
// Set source address
|
||||
memcpy(p->data + 6, ether_addr, 6);
|
||||
|
||||
#if MONITOR
|
||||
bug("Sending Ethernet packet:\n");
|
||||
for (int i=0; i<len; i++) {
|
||||
|
@ -280,10 +280,6 @@ int16 ether_detach_ph(uint16 type)
|
||||
|
||||
int16 ether_write(uint32 wds)
|
||||
{
|
||||
// Set source address
|
||||
uint32 hdr = ReadMacInt32(wds + 2);
|
||||
Host2Mac_memcpy(hdr + 6, ether_addr, 6);
|
||||
|
||||
// Copy packet to buffer
|
||||
uint8 packet[1516], *p = packet;
|
||||
int len = 0;
|
||||
|
@ -182,7 +182,7 @@ void EtherReset(void)
|
||||
|
||||
|
||||
/*
|
||||
* Check whether Ethernet address is AppleTalk broadcast address
|
||||
* Check whether Ethernet address is AppleTalk or Ethernet broadcast address
|
||||
*/
|
||||
|
||||
static inline bool is_apple_talk_broadcast(uint8 *p)
|
||||
@ -191,6 +191,12 @@ static inline bool is_apple_talk_broadcast(uint8 *p)
|
||||
&& p[3] == 0xff && p[4] == 0xff && p[5] == 0xff;
|
||||
}
|
||||
|
||||
static inline bool is_ethernet_broadcast(uint8 *p)
|
||||
{
|
||||
return p[0] == 0xff && p[1] == 0xff && p[2] == 0xff
|
||||
&& p[3] == 0xff && p[4] == 0xff && p[5] == 0xff;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Driver Open() routine
|
||||
@ -290,9 +296,15 @@ int16 EtherControl(uint32 pb, uint32 dce)
|
||||
|
||||
case kENetWrite: { // Transmit raw Ethernet packet
|
||||
uint32 wds = ReadMacInt32(pb + ePointer);
|
||||
D(bug(" EtherWrite\n"));
|
||||
D(bug(" EtherWrite "));
|
||||
if (ReadMacInt16(wds) < 14)
|
||||
return eLenErr; // Header incomplete
|
||||
|
||||
// Set source address
|
||||
uint32 hdr = ReadMacInt32(wds + 2);
|
||||
Host2Mac_memcpy(hdr + 6, ether_addr, 6);
|
||||
D(bug("to %08x%04x, type %04x\n", ReadMacInt32(hdr), ReadMacInt16(hdr + 4), ReadMacInt16(hdr + 12)));
|
||||
|
||||
if (net_open) {
|
||||
#if SUPPORTS_UDP_TUNNEL
|
||||
if (udp_tunnel) {
|
||||
@ -301,12 +313,11 @@ int16 EtherControl(uint32 pb, uint32 dce)
|
||||
uint8 packet[1514];
|
||||
int len = ether_wds_to_buffer(wds, packet);
|
||||
|
||||
// Set source address and extract destination address
|
||||
memcpy(packet + 6, ether_addr, 6);
|
||||
// Extract destination address
|
||||
uint32 dest_ip;
|
||||
if (packet[0] == 'B' && packet[1] == '2')
|
||||
dest_ip = (packet[2] << 24) | (packet[3] << 16) | (packet[4] << 8) | packet[5];
|
||||
else if (is_apple_talk_broadcast(packet))
|
||||
else if (is_apple_talk_broadcast(packet) || is_ethernet_broadcast(packet))
|
||||
dest_ip = INADDR_BROADCAST;
|
||||
else
|
||||
return eMultiErr;
|
||||
|
Loading…
Reference in New Issue
Block a user