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

sys/drivers: renamed uuid module to luid

This commit is contained in:
Hauke Petersen 2017-02-24 08:57:11 +01:00
parent 3f57790c47
commit 79a113d1ba
11 changed files with 64 additions and 64 deletions

View File

@ -8,7 +8,7 @@ endif
ifneq (,$(filter at86rf2%,$(USEMODULE))) ifneq (,$(filter at86rf2%,$(USEMODULE)))
USEMODULE += at86rf2xx USEMODULE += at86rf2xx
USEMODULE += xtimer USEMODULE += xtimer
USEMODULE += uuid USEMODULE += luid
USEMODULE += netif USEMODULE += netif
USEMODULE += ieee802154 USEMODULE += ieee802154
USEMODULE += netdev2_ieee802154 USEMODULE += netdev2_ieee802154
@ -21,7 +21,7 @@ endif
ifneq (,$(filter mrf24j40,$(USEMODULE))) ifneq (,$(filter mrf24j40,$(USEMODULE)))
USEMODULE += xtimer USEMODULE += xtimer
USEMODULE += uuid USEMODULE += luid
USEMODULE += netif USEMODULE += netif
USEMODULE += ieee802154 USEMODULE += ieee802154
USEMODULE += netdev2_ieee802154 USEMODULE += netdev2_ieee802154
@ -49,7 +49,7 @@ endif
ifneq (,$(filter cc110x,$(USEMODULE))) ifneq (,$(filter cc110x,$(USEMODULE)))
USEMODULE += ieee802154 USEMODULE += ieee802154
USEMODULE += uuid USEMODULE += luid
USEMODULE += xtimer USEMODULE += xtimer
ifneq (,$(filter gnrc_netdev_default,$(USEMODULE))) ifneq (,$(filter gnrc_netdev_default,$(USEMODULE)))
USEMODULE += gnrc_cc110x USEMODULE += gnrc_cc110x
@ -61,7 +61,7 @@ endif
ifneq (,$(filter cc2420,$(USEMODULE))) ifneq (,$(filter cc2420,$(USEMODULE)))
USEMODULE += xtimer USEMODULE += xtimer
USEMODULE += uuid USEMODULE += luid
USEMODULE += netif USEMODULE += netif
USEMODULE += ieee802154 USEMODULE += ieee802154
USEMODULE += netdev2_ieee802154 USEMODULE += netdev2_ieee802154
@ -82,7 +82,7 @@ endif
ifneq (,$(filter enc28j60,$(USEMODULE))) ifneq (,$(filter enc28j60,$(USEMODULE)))
USEMODULE += netdev2_eth USEMODULE += netdev2_eth
USEMODULE += xtimer USEMODULE += xtimer
USEMODULE += uuid USEMODULE += luid
endif endif
ifneq (,$(filter encx24j600,$(USEMODULE))) ifneq (,$(filter encx24j600,$(USEMODULE)))
@ -114,7 +114,7 @@ ifneq (,$(filter jc42,$(USEMODULE)))
endif endif
ifneq (,$(filter kw2xrf,$(USEMODULE))) ifneq (,$(filter kw2xrf,$(USEMODULE)))
USEMODULE += uuid USEMODULE += luid
USEMODULE += netif USEMODULE += netif
USEMODULE += ieee802154 USEMODULE += ieee802154
USEMODULE += netdev2_ieee802154 USEMODULE += netdev2_ieee802154
@ -186,7 +186,7 @@ endif
ifneq (,$(filter w5100,$(USEMODULE))) ifneq (,$(filter w5100,$(USEMODULE)))
USEMODULE += netdev2_eth USEMODULE += netdev2_eth
USEMODULE += uuid USEMODULE += luid
endif endif
ifneq (,$(filter xbee,$(USEMODULE))) ifneq (,$(filter xbee,$(USEMODULE)))

View File

@ -24,7 +24,7 @@
*/ */
#include "uuid.h" #include "luid.h"
#include "byteorder.h" #include "byteorder.h"
#include "net/ieee802154.h" #include "net/ieee802154.h"
#include "net/gnrc.h" #include "net/gnrc.h"
@ -62,7 +62,7 @@ void at86rf2xx_reset(at86rf2xx_t *dev)
dev->netdev.flags = 0; dev->netdev.flags = 0;
/* get an 8-byte unique ID to use as hardware address */ /* get an 8-byte unique ID to use as hardware address */
uuid_get(addr_long.uint8, IEEE802154_LONG_ADDRESS_LEN); luid_get(addr_long.uint8, IEEE802154_LONG_ADDRESS_LEN);
/* make sure we mark the address as non-multicast and not globally unique */ /* make sure we mark the address as non-multicast and not globally unique */
addr_long.uint8[0] &= ~(0x01); addr_long.uint8[0] &= ~(0x01);
addr_long.uint8[0] |= (0x02); addr_long.uint8[0] |= (0x02);

View File

@ -20,7 +20,7 @@
* @} * @}
*/ */
#include "uuid.h" #include "luid.h"
#include "board.h" #include "board.h"
#include "periph/gpio.h" #include "periph/gpio.h"
#include "periph/spi.h" #include "periph/spi.h"
@ -82,7 +82,7 @@ int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params)
/* set default node id */ /* set default node id */
uint8_t addr; uint8_t addr;
uuid_get(&addr, 1); luid_get(&addr, 1);
cc110x_set_address(dev, addr); cc110x_set_address(dev, addr);
LOG_INFO("cc110x: initialized with address=%u and channel=%i\n", LOG_INFO("cc110x: initialized with address=%u and channel=%i\n",

View File

@ -20,7 +20,7 @@
* @} * @}
*/ */
#include "uuid.h" #include "luid.h"
#include "byteorder.h" #include "byteorder.h"
#include "net/ieee802154.h" #include "net/ieee802154.h"
#include "net/gnrc.h" #include "net/gnrc.h"
@ -54,7 +54,7 @@ int cc2420_init(cc2420_t *dev)
dev->netdev.flags = 0; dev->netdev.flags = 0;
/* set default address, channel, PAN ID, and TX power */ /* set default address, channel, PAN ID, and TX power */
uuid_get(addr, sizeof(addr)); luid_get(addr, sizeof(addr));
/* make sure we mark the address as non-multicast and not globally unique */ /* make sure we mark the address as non-multicast and not globally unique */
addr[0] &= ~(0x01); addr[0] &= ~(0x01);
addr[0] |= 0x02; addr[0] |= 0x02;

View File

@ -21,7 +21,7 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include "uuid.h" #include "luid.h"
#include "mutex.h" #include "mutex.h"
#include "xtimer.h" #include "xtimer.h"
#include "assert.h" #include "assert.h"
@ -373,7 +373,7 @@ static int nd_init(netdev2_t *netdev)
cmd_wcr(dev, REG_B2_MAIPGL, 2, MAIPGL_FD); cmd_wcr(dev, REG_B2_MAIPGL, 2, MAIPGL_FD);
/* set default MAC address */ /* set default MAC address */
uint8_t macbuf[ETHERNET_ADDR_LEN]; uint8_t macbuf[ETHERNET_ADDR_LEN];
uuid_get(macbuf, ETHERNET_ADDR_LEN); luid_get(macbuf, ETHERNET_ADDR_LEN);
macbuf[0] |= 0x02; /* locally administered address */ macbuf[0] |= 0x02; /* locally administered address */
macbuf[0] &= ~0x01; /* unicast address */ macbuf[0] &= ~0x01; /* unicast address */
mac_set(dev, macbuf); mac_set(dev, macbuf);

View File

@ -28,7 +28,7 @@
#include "periph/cpuid.h" #include "periph/cpuid.h"
#include "net/gnrc.h" #include "net/gnrc.h"
#include "net/ieee802154.h" #include "net/ieee802154.h"
#include "uuid.h" #include "luid.h"
#include "kw2xrf.h" #include "kw2xrf.h"
#include "kw2xrf_spi.h" #include "kw2xrf_spi.h"
@ -45,7 +45,7 @@ static void kw2xrf_set_address(kw2xrf_t *dev)
DEBUG("[kw2xrf] set MAC addresses\n"); DEBUG("[kw2xrf] set MAC addresses\n");
eui64_t addr_long; eui64_t addr_long;
/* get an 8-byte unique ID to use as hardware address */ /* get an 8-byte unique ID to use as hardware address */
uuid_get(addr_long.uint8, IEEE802154_LONG_ADDRESS_LEN); luid_get(addr_long.uint8, IEEE802154_LONG_ADDRESS_LEN);
/* make sure we mark the address as non-multicast and not globally unique */ /* make sure we mark the address as non-multicast and not globally unique */
addr_long.uint8[0] &= ~(0x01); addr_long.uint8[0] &= ~(0x01);
addr_long.uint8[0] |= (0x02); addr_long.uint8[0] |= (0x02);

View File

@ -20,7 +20,7 @@
* @} * @}
*/ */
#include "uuid.h" #include "luid.h"
#include "byteorder.h" #include "byteorder.h"
#include "net/gnrc.h" #include "net/gnrc.h"
#include "mrf24j40_registers.h" #include "mrf24j40_registers.h"
@ -51,7 +51,7 @@ void mrf24j40_reset(mrf24j40_t *dev)
dev->netdev.flags = 0; dev->netdev.flags = 0;
/* get an 8-byte unique ID to use as hardware address */ /* get an 8-byte unique ID to use as hardware address */
uuid_get(addr_long.uint8, IEEE802154_LONG_ADDRESS_LEN); luid_get(addr_long.uint8, IEEE802154_LONG_ADDRESS_LEN);
addr_long.uint8[0] &= ~(0x01); addr_long.uint8[0] &= ~(0x01);
addr_long.uint8[0] |= (0x02); addr_long.uint8[0] |= (0x02);
/* set short and long address */ /* set short and long address */

View File

@ -22,7 +22,7 @@
#include <string.h> #include <string.h>
#include "log.h" #include "log.h"
#include "uuid.h" #include "luid.h"
#include "assert.h" #include "assert.h"
#include "net/ethernet.h" #include "net/ethernet.h"
@ -148,7 +148,7 @@ static int init(netdev2_t *netdev)
while (rreg(dev, REG_MODE) & MODE_RESET) {}; while (rreg(dev, REG_MODE) & MODE_RESET) {};
/* initialize the device, start with writing the MAC address */ /* initialize the device, start with writing the MAC address */
uuid_get(hwaddr, ETHERNET_ADDR_LEN); luid_get(hwaddr, ETHERNET_ADDR_LEN);
hwaddr[0] &= ~0x03; /* no group address and not globally unique */ hwaddr[0] &= ~0x03; /* no group address and not globally unique */
wchunk(dev, REG_SHAR0, hwaddr, ETHERNET_ADDR_LEN); wchunk(dev, REG_SHAR0, hwaddr, ETHERNET_ADDR_LEN);

View File

@ -7,13 +7,13 @@
*/ */
/** /**
* @defgroup sys_uuid (Locally) Unique ID Generator * @defgroup sys_luid Locally Unique ID Generator
* @ingroup sys * @ingroup sys
* @brief Generate system wide unique IDs * @brief Generate system wide (locally) unique IDs
* *
* This module generates system wide, variable length unique IDs based on on the * This module generates system wide, variable length unique IDs based on on the
* cpuid module. If the cpuid module is not present, the module falls back to a * cpuid module. If the cpuid module is not present, the module falls back to a
* pre-defined, constant seed for creating unique ids. * pre-defined, constant seed for creating unique IDs.
* *
* The main purpose of this module is to have a unified way for e.g. creating * The main purpose of this module is to have a unified way for e.g. creating
* hardware addresses and similar. * hardware addresses and similar.
@ -24,24 +24,24 @@
* base ID is created by simple 'memsetting' the base ID with the defined * base ID is created by simple 'memsetting' the base ID with the defined
* backup seed value. * backup seed value.
* *
* Once the base ID is generated, a UUID is generated by (i) XORing a counter * Once the base ID is generated, a LUID is generated by (i) XORing a counter
* value with the LSB of the base ID, or (ii) by XORing the least significant * value with the LSB of the base ID, or (ii) by XORing the least significant
* byes with a value given by the user. * byes with a value given by the user.
* *
* Example: Calling `uuid_base(&buf, 8)` will always yield an identical value, * Example: Calling `luid_base(&buf, 8)` will always yield an identical value,
* independent how often the function is called. But calling * independent how often the function is called. But calling
* `uuid_base(&buf, 2)` afterwards will results in a different value, if the * `luid_base(&buf, 2)` afterwards will results in a different value, if the
* cpuid module is present, and in the same (but shorter) value if not. * cpuid module is present, and in the same (but shorter) value if not.
* *
* Example: Calling `uuid_get(&buf, 8)` four times in a row, will yield four * Example: Calling `luid_get(&buf, 8)` four times in a row, will yield four
* different IDs, differing in their LSB. * different IDs, differing in their LSB.
* *
* Example: Calling `uuid_custom(&buf, 8, 123)` will always yield the same * Example: Calling `luid_custom(&buf, 8, 123)` will always yield the same
* value, but calling `uuid_custom(&buf, 8, 124)` will differ. * value, but calling `luid_custom(&buf, 8, 124)` will differ.
* *
* @note This module generates unique IDs without any guarantees on their * @note This module generates locally unique IDs without any guarantees
* structure. These UUIDs are not compatible nor conform to the * on their structure. These LUIDs are not compatible nor conform
* UUIDs as defined in RFC4122. * to UUIDs as defined in RFC4122.
* *
* @{ * @{
* @file * @file
@ -50,8 +50,8 @@
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/ */
#ifndef UUID_H_ #ifndef LUID_H_
#define UUID_H_ #define LUID_H_
#include <stddef.h> #include <stddef.h>
@ -60,27 +60,27 @@ extern "C" {
#endif #endif
/** /**
* @brief Value used as based for the UUIDs in case the cpuid module is not * @brief Value used as based for the LUIDs in case the cpuid module is not
* present * present
*/ */
#ifndef UUID_BACKUP_SEED #ifndef LUID_BACKUP_SEED
#define UUID_BACKUP_SEED 0x23 #define LUID_BACKUP_SEED 0x23
#endif #endif
/** /**
* @brief Get a unique ID * @brief Get a unique ID
* *
* The resulting ID is built from the base ID generated with uuid_base(), which * The resulting ID is built from the base ID generated with luid_base(), which
* isXORed with an 8-bit incrementing counter value into the most significant * isXORed with an 8-bit incrementing counter value into the most significant
* byte. * byte.
* *
* @note The resulting UUID will repeat after 255 calls. * @note The resulting LUID will repeat after 255 calls.
* *
* @param[out] buf memory location to copy the UUID into. MUST be able to * @param[out] buf memory location to copy the LUID into. MUST be able to
* hold at least @p len bytes * hold at least @p len bytes
* @param[in] len length of the UUID in bytes * @param[in] len length of the LUID in bytes
*/ */
void uuid_get(void *buf, size_t len); void luid_get(void *buf, size_t len);
/** /**
* @brief Get a custom unique ID based on a user given generator value * @brief Get a custom unique ID based on a user given generator value
@ -89,31 +89,31 @@ void uuid_get(void *buf, size_t len);
* ID's most significant bytes. * ID's most significant bytes.
* *
* @note Calling this function with identical values for @p gen and @p len * @note Calling this function with identical values for @p gen and @p len
* will always result in identical UUIDs. * will always result in identical LUIDs.
* *
* @param[out] buf memory location to copy the UUID into. MUST be able to * @param[out] buf memory location to copy the LUID into. MUST be able to
* hold at least @p len bytes * hold at least @p len bytes
* @param[in] len length of the UUID in bytes * @param[in] len length of the LUID in bytes
* @param[in] gen custom UUID generator value * @param[in] gen custom LUID generator value
*/ */
void uuid_custom(void *buf, size_t len, int gen); void luid_custom(void *buf, size_t len, int gen);
/** /**
* @brief Get a UUID base value * @brief Get a LUID base value
* *
* The uuid module creates the value dependent on the given @p len value using * The luid module creates the value dependent on the given @p len value using
* the cpuid module if present or a static seed value (@ref UUID_BACKUP_SEED) if * the cpuid module if present or a static seed value (@ref LUID_BACKUP_SEED) if
* not. * not.
* *
* @param[out] buf memory location to copy the UUID into. MUST be able to * @param[out] buf memory location to copy the LUID into. MUST be able to
* hold at least @p len bytes * hold at least @p len bytes
* @param[in] len length of the UUID in bytes * @param[in] len length of the LUID in bytes
*/ */
void uuid_base(void *buf, size_t len); void luid_base(void *buf, size_t len);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* UUID_H_ */ #endif /* LUID_H_ */
/** @} */ /** @} */

View File

@ -7,11 +7,11 @@
*/ */
/** /**
* @ingroup sys_uuid * @ingroup sys_luid
* @{ * @{
* *
* @file * @file
* @brief UUID module implementation * @brief LUID module implementation
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* *
@ -24,31 +24,31 @@
#include "assert.h" #include "assert.h"
#include "periph/cpuid.h" #include "periph/cpuid.h"
#include "uuid.h" #include "luid.h"
static uint8_t lastused = 1; static uint8_t lastused = 1;
void uuid_get(void *buf, size_t len) void luid_get(void *buf, size_t len)
{ {
uuid_base(buf, len); luid_base(buf, len);
((uint8_t *)buf)[0] ^= lastused++; ((uint8_t *)buf)[0] ^= lastused++;
} }
void uuid_custom(void *buf, size_t len, int gen) void luid_custom(void *buf, size_t len, int gen)
{ {
uuid_base(buf, len); luid_base(buf, len);
for (size_t i = 0; i < sizeof(gen); i++) { for (size_t i = 0; i < sizeof(gen); i++) {
((uint8_t *)buf)[i % len] ^= ((gen >> (i * 8)) & 0xff); ((uint8_t *)buf)[i % len] ^= ((gen >> (i * 8)) & 0xff);
} }
} }
void uuid_base(void *buf, size_t len) void luid_base(void *buf, size_t len)
{ {
assert(buf && (len > 0)); assert(buf && (len > 0));
memset(buf, UUID_BACKUP_SEED, len); memset(buf, LUID_BACKUP_SEED, len);
#if CPUID_LEN #if CPUID_LEN
uint8_t *out = (uint8_t *)buf; uint8_t *out = (uint8_t *)buf;