182 |
|
|
183 |
|
|
184 |
|
/* |
185 |
< |
* Check whether Ethernet address is AppleTalk broadcast address |
185 |
> |
* Check whether Ethernet address is AppleTalk or Ethernet broadcast address |
186 |
|
*/ |
187 |
|
|
188 |
|
static inline bool is_apple_talk_broadcast(uint8 *p) |
191 |
|
&& p[3] == 0xff && p[4] == 0xff && p[5] == 0xff; |
192 |
|
} |
193 |
|
|
194 |
+ |
static inline bool is_ethernet_broadcast(uint8 *p) |
195 |
+ |
{ |
196 |
+ |
return p[0] == 0xff && p[1] == 0xff && p[2] == 0xff |
197 |
+ |
&& p[3] == 0xff && p[4] == 0xff && p[5] == 0xff; |
198 |
+ |
} |
199 |
+ |
|
200 |
|
|
201 |
|
/* |
202 |
|
* Driver Open() routine |
296 |
|
|
297 |
|
case kENetWrite: { // Transmit raw Ethernet packet |
298 |
|
uint32 wds = ReadMacInt32(pb + ePointer); |
299 |
< |
D(bug(" EtherWrite\n")); |
299 |
> |
D(bug(" EtherWrite ")); |
300 |
|
if (ReadMacInt16(wds) < 14) |
301 |
|
return eLenErr; // Header incomplete |
302 |
+ |
|
303 |
+ |
// Set source address |
304 |
+ |
uint32 hdr = ReadMacInt32(wds + 2); |
305 |
+ |
Host2Mac_memcpy(hdr + 6, ether_addr, 6); |
306 |
+ |
D(bug("to %08x%04x, type %04x\n", ReadMacInt32(hdr), ReadMacInt16(hdr + 4), ReadMacInt16(hdr + 12))); |
307 |
+ |
|
308 |
|
if (net_open) { |
309 |
|
#if SUPPORTS_UDP_TUNNEL |
310 |
|
if (udp_tunnel) { |
313 |
|
uint8 packet[1514]; |
314 |
|
int len = ether_wds_to_buffer(wds, packet); |
315 |
|
|
316 |
< |
// Set source address and extract destination address |
305 |
< |
memcpy(packet + 6, ether_addr, 6); |
316 |
> |
// Extract destination address |
317 |
|
uint32 dest_ip; |
318 |
|
if (packet[0] == 'B' && packet[1] == '2') |
319 |
|
dest_ip = (packet[2] << 24) | (packet[3] << 16) | (packet[4] << 8) | packet[5]; |
320 |
< |
else if (is_apple_talk_broadcast(packet)) |
320 |
> |
else if (is_apple_talk_broadcast(packet) || is_ethernet_broadcast(packet)) |
321 |
|
dest_ip = INADDR_BROADCAST; |
322 |
|
else |
323 |
|
return eMultiErr; |