mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/.../ip.c: fix ipv6_net_if_get_best_src_addr
This patch fixes ipv6_net_if_get_best_src_addr, the function seems not to be finished. The patch also adds a filter for the prefixes, it is necessary because the prefixes are stored in the same list as the addresses.
This commit is contained in:
parent
2bc7c4ba5f
commit
7087bdcb50
@ -729,6 +729,7 @@ void ipv6_net_if_get_best_src_addr(ipv6_addr_t *src, const ipv6_addr_t *dest)
|
|||||||
int if_id = 0; // TODO: get this somehow
|
int if_id = 0; // TODO: get this somehow
|
||||||
ipv6_net_if_addr_t *addr = NULL;
|
ipv6_net_if_addr_t *addr = NULL;
|
||||||
ipv6_net_if_addr_t *tmp_addr = NULL;
|
ipv6_net_if_addr_t *tmp_addr = NULL;
|
||||||
|
uint8_t bmatch = 0;
|
||||||
|
|
||||||
if (!(ipv6_addr_is_link_local(dest)) && !(ipv6_addr_is_multicast(dest))) {
|
if (!(ipv6_addr_is_link_local(dest)) && !(ipv6_addr_is_multicast(dest))) {
|
||||||
while ((addr = (ipv6_net_if_addr_t *) net_if_iter_addresses(if_id,
|
while ((addr = (ipv6_net_if_addr_t *) net_if_iter_addresses(if_id,
|
||||||
@ -739,11 +740,15 @@ void ipv6_net_if_get_best_src_addr(ipv6_addr_t *src, const ipv6_addr_t *dest)
|
|||||||
&& !ipv6_addr_is_unique_local_unicast(
|
&& !ipv6_addr_is_unique_local_unicast(
|
||||||
addr->addr_data)) {
|
addr->addr_data)) {
|
||||||
|
|
||||||
uint8_t bmatch = 0;
|
if (addr->addr_protocol == NET_IF_L3P_IPV6_PREFIX) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t tmp = ipv6_get_addr_match(dest, addr->addr_data);
|
uint8_t tmp = ipv6_get_addr_match(dest, addr->addr_data);
|
||||||
|
|
||||||
if (tmp >= bmatch) {
|
if (tmp >= bmatch) {
|
||||||
tmp_addr = addr;
|
tmp_addr = addr;
|
||||||
|
bmatch = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user