From d955836187b31267a28c284ab51b6fcb464814d6 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 24 Apr 2020 21:18:21 +0200 Subject: [PATCH] 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. --- drivers/ethos/ethos.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/ethos/ethos.c b/drivers/ethos/ethos.c index 8e70610c07..e12fa6bfa6 100644 --- a/drivers/ethos/ethos.c +++ b/drivers/ethos/ethos.c @@ -22,11 +22,11 @@ #include #include -#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);