Skip to content

Commit

Permalink
drivers/ethos: use luid_get_eui48()
Browse files Browse the repository at this point in the history
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 RIOT-OS#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.
  • Loading branch information
benpicco authored and bergzand committed Jul 15, 2020
1 parent 0fa925e commit b9c615a
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions drivers/ethos/ethos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b9c615a

Please sign in to comment.