|
|
|
@ -91,8 +91,8 @@ static uint16_t _calc_fcs(uint16_t fcs, const uint8_t *frame, uint8_t frame_len)
|
|
|
|
|
kernel_pid_t gnrc_zep_init(gnrc_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst, |
|
|
|
|
uint16_t dst_port) |
|
|
|
|
{ |
|
|
|
|
#if CPUID_ID_LEN |
|
|
|
|
uint8_t cpuid[CPUID_ID_LEN]; |
|
|
|
|
#if CPUID_LEN |
|
|
|
|
uint8_t cpuid[CPUID_LEN]; |
|
|
|
|
uint32_t hash1, hash2; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
@ -120,18 +120,18 @@ kernel_pid_t gnrc_zep_init(gnrc_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
|
|
|
|
dev->chan = GNRC_ZEP_DEFAULT_CHANNEL; |
|
|
|
|
dev->pan = byteorder_btols(byteorder_htons(GNRC_ZEP_DEFAULT_PANID)); |
|
|
|
|
dev->flags = GNRC_ZEP_FLAGS_USE_SRC_PAN; |
|
|
|
|
#if CPUID_ID_LEN |
|
|
|
|
#if CPUID_LEN |
|
|
|
|
/* initialize dev->addr and dev->eui64 from cpuid if available */ |
|
|
|
|
cpuid_get(cpuid); |
|
|
|
|
|
|
|
|
|
hash1 = djb2_hash(cpuid, CPUID_ID_LEN / 2); |
|
|
|
|
hash1 = djb2_hash(cpuid, CPUID_LEN / 2); |
|
|
|
|
dev->addr.u16 = (uint16_t)((hash1 >> 16) ^ (hash1 & 0xffff)); |
|
|
|
|
|
|
|
|
|
if (CPUID_ID_LEN % 2) { |
|
|
|
|
hash2 = djb2_hash(cpuid + (CPUID_ID_LEN / 2), (CPUID_ID_LEN / 2) - 1); |
|
|
|
|
if (CPUID_LEN % 2) { |
|
|
|
|
hash2 = djb2_hash(cpuid + (CPUID_LEN / 2), (CPUID_LEN / 2) - 1); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
hash2 = djb2_hash(cpuid + (CPUID_ID_LEN / 2), CPUID_ID_LEN / 2); |
|
|
|
|
hash2 = djb2_hash(cpuid + (CPUID_LEN / 2), CPUID_LEN / 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dev->eui64.u32[0] = hash1; |
|
|
|
|