net/utils: Switch argument order of net_ipv6_pref2mask

When implementing IPv6-related logic, we found the `net_ipv6_pref2mask`
and `net_ipv6addr_copy` are using different argument order:
```
net_ipv6addr_copy(ifaddr->addr, addr);
net_ipv6_pref2mask(preflen, ifaddr->mask);
```
Change the order to:
```
net_ipv6addr_copy(ifaddr->addr, addr);
net_ipv6_pref2mask(ifaddr->mask, preflen);
```

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
Zhe Weng 2023-11-03 21:22:03 +08:00 committed by Xiang Xiao
parent 3e4d847f42
commit 4c99ad1ba9
4 changed files with 7 additions and 7 deletions

View File

@ -103,7 +103,7 @@ void icmpv6_setaddresses(FAR struct net_driver_s *dev,
preflen = 128;
}
net_ipv6_pref2mask(preflen, mask);
net_ipv6_pref2mask(mask, preflen);
ninfo("preflen=%d netmask=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
preflen,

View File

@ -142,7 +142,7 @@ int netdev_ipv6_add(FAR struct net_driver_s *dev, const net_ipv6addr_t addr,
* allows to override the address. But not sure if it's good.
*/
net_ipv6_pref2mask(preflen, ifaddr->mask);
net_ipv6_pref2mask(ifaddr->mask, preflen);
return OK;
}
@ -174,7 +174,7 @@ int netdev_ipv6_add(FAR struct net_driver_s *dev, const net_ipv6addr_t addr,
#endif /* CONFIG_NETDEV_MULTIPLE_IPv6 */
net_ipv6addr_copy(ifaddr->addr, addr);
net_ipv6_pref2mask(preflen, ifaddr->mask);
net_ipv6_pref2mask(ifaddr->mask, preflen);
return OK;
}

View File

@ -42,15 +42,15 @@
* specifies the number of MS bits under mask (0-128)
*
* Input Parameters:
* mask - The location to return the netmask.
* preflen - Determines the width of the netmask (in bits). Range 0-128
* mask - The location to return the netmask.
*
* Returned Value:
* None
*
****************************************************************************/
void net_ipv6_pref2mask(uint8_t preflen, net_ipv6addr_t mask)
void net_ipv6_pref2mask(net_ipv6addr_t mask, uint8_t preflen)
{
unsigned int bit;
unsigned int i;

View File

@ -242,8 +242,8 @@ uint8_t net_ipv6_mask2pref(FAR const uint16_t *mask);
* specifies the number of MS bits under mask (0-128)
*
* Input Parameters:
* mask - The location to return the netmask.
* preflen - Determines the width of the netmask (in bits). Range 0-128
* mask - The location to return the netmask.
*
* Returned Value:
* None
@ -251,7 +251,7 @@ uint8_t net_ipv6_mask2pref(FAR const uint16_t *mask);
****************************************************************************/
#ifdef CONFIG_NET_IPv6
void net_ipv6_pref2mask(uint8_t preflen, net_ipv6addr_t mask);
void net_ipv6_pref2mask(net_ipv6addr_t mask, uint8_t preflen);
#endif
/****************************************************************************