diff --git a/sim_ether.c b/sim_ether.c index ef3126e..be67be3 100644 --- a/sim_ether.c +++ b/sim_ether.c @@ -576,7 +576,7 @@ int eth_get_packet_crc32_data(const uint8 *msg, int len, uint8 *crcdata) uint32 crc = eth_crc32(0, msg, len); /* calculate CRC */ uint32 ncrc = htonl(crc); /* CRC in network order */ int size = sizeof(ncrc); /* size of crc field */ - memcpy(crcdata, &crc, size); /* append crc to packet */ + memcpy(crcdata, &ncrc, size); /* append crc to packet */ crc_len = len + size; /* set packet crc length */ } else { crc_len = 0; /* appending crc would destroy packet */ @@ -2458,6 +2458,13 @@ char mac_string[32]; eth_mac_fmt(mac, mac_string); sim_debug(dev->dbit, dev->dptr, "Determining Address Conflict for MAC address: %s\n", mac_string); +/* 00:00:00:00:00:00 or any address with a multi-cast address is invalid */ +if ((((*mac)[0] == 0) && ((*mac)[1] == 0) && ((*mac)[2] == 0) && + ((*mac)[3] == 0) && ((*mac)[4] == 0) && ((*mac)[5] == 0)) || + ((*mac)[0] & 1)) { + return sim_messagef (SCPE_ARG, "%s: Invalid NIC MAC Address: %s\n", sim_dname(dev->dptr), mac_string); + } + /* The process of checking address conflicts is used in two ways: 1) to determine the behavior of the currently running packet delivery facility regarding whether it may receive copies @@ -2542,13 +2549,12 @@ status = _eth_write (dev, &send, NULL); if (status != SCPE_OK) { const char *msg; msg = (dev->eth_api == ETH_API_PCAP) ? - "Eth: Error Transmitting packet: %s\n" + "%s: Eth: Error Transmitting packet: %s\n" "You may need to run as root, or install a libpcap version\n" "which is at least 0.9 from your OS vendor or www.tcpdump.org\n" : - "Eth: Error Transmitting packet: %s\n" + "%s: Eth: Error Transmitting packet: %s\n" "You may need to run as root.\n"; - sim_printf(msg, strerror(errno)); - return status; + return sim_messagef (SCPE_ARG, msg, sim_dname (dev->dptr), strerror(errno)); } sim_os_ms_sleep (300); /* time for a conflicting host to respond */ @@ -2572,6 +2578,8 @@ do { } while (recv.len > 0); sim_debug(dev->dbit, dev->dptr, "Address Conflict = %d\n", responses); +if (responses) + return sim_messagef (SCPE_ARG, "%s: MAC Address Conflict on LAN for address %s, change the MAC address to a unique value\n", sim_dname (dev->dptr), mac_string); return responses; } diff --git a/sim_ether.h b/sim_ether.h index 0fac824..2c95ff8 100644 --- a/sim_ether.h +++ b/sim_ether.h @@ -355,7 +355,6 @@ t_stat eth_set_async (ETH_DEV* dev, int latency); /* set read behavior to t_stat eth_clr_async (ETH_DEV* dev); /* set read behavior to be not async */ t_stat eth_set_throttle (ETH_DEV* dev, uint32 time, uint32 burst, uint32 delay); /* set transmit throttle parameters */ uint32 eth_crc32(uint32 crc, const void* vbuf, size_t len); /* Compute Ethernet Autodin II CRC for buffer */ -int eth_add_packet_crc32(uint8 *msg, int len); void eth_packet_trace (ETH_DEV* dev, const uint8 *msg, int len, const char* txt); /* trace ethernet packet header+crc */ void eth_packet_trace_ex (ETH_DEV* dev, const uint8 *msg, int len, const char* txt, int detail, uint32 reason); /* trace ethernet packet */