net/utils: Fix the wrong mask calculation in net_ipv6_pref2mask
This commit is contained in:
parent
174df6b793
commit
b80fb6befc
@ -39,9 +39,6 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "utils/utils.h"
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
@ -71,7 +68,7 @@ static const uint8_t g_nibblemap[16] =
|
||||
|
||||
static inline uint8_t net_msbits4(uint8_t nibble)
|
||||
{
|
||||
/* Return the number of leading zeroes: 0-4) */
|
||||
/* Return the number of leading ones: 0-4) */
|
||||
|
||||
return g_nibblemap[nibble];
|
||||
}
|
||||
|
@ -41,8 +41,6 @@
|
||||
|
||||
#include <nuttx/net/ip.h>
|
||||
|
||||
#include "utils/utils.h"
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -101,12 +101,12 @@ void net_ipv6_pref2mask(uint8_t preflen, net_ipv6addr_t mask)
|
||||
else
|
||||
{
|
||||
/* Eg. preflen = 38, bit = {32}
|
||||
* bit - preflen = 6
|
||||
* preflen - bit = 6
|
||||
* mask = 0xffff << (16-6)
|
||||
* = 0xfc00
|
||||
*/
|
||||
|
||||
mask[i] = 0xffff << (16 - (bit - preflen));
|
||||
mask[i] = 0xffff << (16 - (preflen - bit));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user