1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 13:21:23 +01:00

make generates MAC addr compliant with the IEEE standard by setting the Locally Administered bit and clearing the Group Adress bit

This commit is contained in:
Harald Barth 2021-03-14 22:15:48 +01:00
parent 25c2f06574
commit f2891ee348
2 changed files with 9 additions and 2 deletions

View File

@ -81,6 +81,8 @@ INTERRUPT_CALLBACK interruptHandler=0;
void DCCTimer::getSimulatedMacAddress(byte mac[6]) {
memcpy(mac,(void *) &SIGROW.SERNUM0,6); // serial number
mac[0] &= 0xFE;
mac[0] |= 0x02;
}
#else
@ -139,7 +141,12 @@ INTERRUPT_CALLBACK interruptHandler=0;
#include <avr/boot.h>
void DCCTimer::getSimulatedMacAddress(byte mac[6]) {
for (byte i=0; i<6; i++) mac[i]=boot_signature_byte_get(0x0E + i);
for (byte i=0; i<6; i++) {
mac[i]=boot_signature_byte_get(0x0E + i);
}
mac[0] &= 0xFE;
mac[0] |= 0x02;
}
#endif

View File

@ -54,7 +54,7 @@ EthernetInterface::EthernetInterface()
DCCTimer::getSimulatedMacAddress(mac);
DIAG(F("\n+++++ Ethernet Setup. Simulatd mac="));
for (byte i=0;i<sizeof(mac); i++) {
DIAG(F("%x:"),mac[i]);
DIAG(F("%s%x:"),mac[i] < 0x10 ? "0" : "", mac[i]);
}
DIAG(F("\n"));