1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

sixlowpan: fix ipv6_addr_init_prefix

This commit is contained in:
Martine Lenders 2014-10-08 18:52:14 +02:00
parent 3b56b6bf07
commit d63e98786e

View File

@ -651,16 +651,15 @@ void ipv6_addr_init_prefix(ipv6_addr_t *out, const ipv6_addr_t *prefix,
uint8_t bytes = bits / 8, mask; uint8_t bytes = bits / 8, mask;
if (bits % 8) { if (bits % 8) {
mask = 0xff << (bits - (bytes * 8)); mask = 0xff << (8 - (bits - (bytes * 8)));
} }
else { else {
mask = 0x00; mask = 0x00;
} }
bytes++;
memset(out, 0, 16);
memcpy(out, prefix, bytes); memcpy(out, prefix, bytes);
out->uint8[bytes] = prefix->uint8[bytes] & mask; out->uint8[bytes] = prefix->uint8[bytes] & mask;
memset(&(out[bytes + 1]), 0, 15 - bytes);
} }
void ipv6_net_if_get_best_src_addr(ipv6_addr_t *src, const ipv6_addr_t *dest) void ipv6_net_if_get_best_src_addr(ipv6_addr_t *src, const ipv6_addr_t *dest)