Skip to content
Snippets Groups Projects
Commit de19411a authored by Martine Lenders's avatar Martine Lenders
Browse files

Merge pull request #5180 from authmillenon/cc110x/fix/iid

cc110x: cc110x generates IID from CPUID, not from hardware address
parents 6aacfa8a 69b63b7c
No related branches found
No related tags found
No related merge requests found
...@@ -70,30 +70,18 @@ static int _recv(netdev2_t *dev, char* buf, int len, void *info) ...@@ -70,30 +70,18 @@ static int _recv(netdev2_t *dev, char* buf, int len, void *info)
static inline int _get_iid(netdev2_t *netdev, eui64_t *value, size_t max_len) static inline int _get_iid(netdev2_t *netdev, eui64_t *value, size_t max_len)
{ {
if (max_len < sizeof(eui64_t)) { cc110x_t *cc110x = &((netdev2_cc110x_t*) dev)->cc110x;
return -EOVERFLOW;
}
uint8_t *eui64 = (uint8_t*) value; uint8_t *eui64 = (uint8_t*) value;
#ifdef CPUID_LEN
int n = (CPUID_LEN < sizeof(eui64_t))
? CPUID_LEN
: sizeof(eui64_t);
char cpuid[CPUID_LEN]; if (max_len < sizeof(eui64_t)) {
cpuid_get(cpuid); return -EOVERFLOW;
memcpy(eui64 + 8 - n, cpuid, n);
#else
for (int i = 0; i < 8; i++) {
eui64[i] = i;
} }
#endif
/* make sure we mark the address as non-multicast and not globally unique */ /* make address compatible to https://tools.ietf.org/html/rfc6282#section-3.2.2*/
eui64[0] &= ~(0x01); memset(eui64, 0, sizeof(eui64_t));
eui64[0] |= 0x02; eui64[3] = 0xff;
eui64[4] = 0xfe;
eui64[7] = cc110x->radio_address;
return sizeof(eui64_t); return sizeof(eui64_t);
} }
......
...@@ -88,10 +88,13 @@ int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params) ...@@ -88,10 +88,13 @@ int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params)
/* set default node id */ /* set default node id */
#ifdef CPUID_LEN #ifdef CPUID_LEN
if (CPUID_LEN>0) { if (CPUID_LEN > 0) {
char cpuid[CPUID_LEN]; char cpuid[CPUID_LEN];
cpuid_get(cpuid); cpuid_get(cpuid);
cc110x_set_address(dev, (uint8_t) cpuid[CPUID_LEN-1]); for (int i = 1; i < CPUID_LEN; i++) {
cpuid[0] ^= cpuid[i]
}
cc110x_set_address(dev, (uint8_t) cpuid[0]);
} }
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment