1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/ethos: use luid_get_eui48()

Previously the MAC address of the border router was entirely random.
That meant that as a DHCPv6 client it would get a new prefix with every
reboot.

Due to #12210 the nodes will never use the new address.

Fix this by using luid_get_eui48() which will always return the same
address across reboots.

It also makes the code simpler.
This commit is contained in:
Benjamin Valentin 2020-04-24 21:18:21 +02:00
parent 0beb48a286
commit d955836187

View File

@ -22,11 +22,11 @@
#include <errno.h>
#include <string.h>
#include "random.h"
#include "ethos.h"
#include "periph/uart.h"
#include "tsrb.h"
#include "irq.h"
#include "luid.h"
#include "net/netdev.h"
#include "net/netdev/eth.h"
@ -67,13 +67,7 @@ void ethos_setup(ethos_t *dev, const ethos_params_t *params)
tsrb_init(&dev->inbuf, params->buf, params->bufsize);
mutex_init(&dev->out_mutex);
uint32_t a = random_uint32();
memcpy(dev->mac_addr, (char*)&a, 4);
a = random_uint32();
memcpy(dev->mac_addr+4, (char*)&a, 2);
dev->mac_addr[0] &= (0x2); /* unset globally unique bit */
dev->mac_addr[0] &= ~(0x1); /* set unicast bit*/
luid_get_eui48((eui48_t *) &dev->mac_addr);
uart_init(params->uart, params->baudrate, ethos_isr, (void*)dev);