diff --git a/sys/net/network_layer/fib/fib.c b/sys/net/network_layer/fib/fib.c index 976f438d75..a8475d5d3e 100644 --- a/sys/net/network_layer/fib/fib.c +++ b/sys/net/network_layer/fib/fib.c @@ -132,7 +132,8 @@ static int fib_find_entry(fib_table_t *table, uint8_t *dst, size_t dst_size, int ret_comp = universal_address_compare(table->data.entries[i].global, dst, &match_size); /* If we found an exact match */ - if ((ret_comp == 0) || (is_all_zeros_addr && (match_size == 0) && (ret_comp == 2))) { + if ((ret_comp == UNIVERSAL_ADDRESS_EQUAL) + || (is_all_zeros_addr && (ret_comp == UNIVERSAL_ADDRESS_IS_ALL_ZERO_ADDRESS))) { entry_arr[0] = &(table->data.entries[i]); *entry_arr_size = 1; /* we will not find a better one so we return */ @@ -140,7 +141,7 @@ static int fib_find_entry(fib_table_t *table, uint8_t *dst, size_t dst_size, } else { /* we try to find the most fitting prefix */ - if (ret_comp == 1) { + if (ret_comp == UNIVERSAL_ADDRESS_MATCHING_PREFIX) { if (table->data.entries[i].global_flags & FIB_FLAG_NET_PREFIX_MASK) { /* we shift the most upper flag byte back to get the number of prefix bits */ size_t global_prefix_len = (table->data.entries[i].global_flags @@ -157,7 +158,7 @@ static int fib_find_entry(fib_table_t *table, uint8_t *dst, size_t dst_size, } } } - else if (ret_comp == 2) { + else if (ret_comp == UNIVERSAL_ADDRESS_IS_ALL_ZERO_ADDRESS) { /* we found the default gateway entry, e.g. ::/0 for IPv6 * and we keep it only if there is no better one */ @@ -350,7 +351,7 @@ static int fib_signal_rp(fib_table_t *table, uint16_t type, uint8_t *dat, if (type != FIB_MSG_RP_SIGNAL_SOURCE_ROUTE_CREATED) { size_t dat_size_in_bits = dat_size<<3; if (universal_address_compare(table->prefix_rp[i], dat, - &dat_size_in_bits) == 1) { + &dat_size_in_bits) != -ENOENT) { /* the receiver, i.e. the RP, MUST copy the content value. * using the provided pointer after replying this message * will lead to errors @@ -365,7 +366,7 @@ static int fib_signal_rp(fib_table_t *table, uint16_t type, uint8_t *dat, size_t dat_size_in_bits = temp_sr->sr_dest->address->address_size << 3; if (universal_address_compare(table->prefix_rp[i], temp_sr->sr_dest->address->address, - &dat_size_in_bits) == 1) { + &dat_size_in_bits) != -ENOENT) { /* the receiver, i.e. the RP, MUST copy the content value. * using the provided pointer after replying this message * will lead to errors @@ -547,7 +548,7 @@ int fib_get_destination_set(fib_table_t *table, uint8_t *prefix, for (size_t i = 0; i < table->size; ++i) { if ((table->data.entries[i].global != NULL) && - (universal_address_compare_prefix(table->data.entries[i].global, prefix, prefix_size<<3) >= 0)) { + (universal_address_compare_prefix(table->data.entries[i].global, prefix, prefix_size<<3) >= UNIVERSAL_ADDRESS_EQUAL)) { if( (dst_set != NULL) && (found_entries < *dst_set_size) ) { /* set the size to full byte usage */ dst_set[found_entries].dest_size = sizeof(dst_set[found_entries].dest); @@ -921,7 +922,7 @@ int fib_sr_search(fib_table_t *table, fib_sr_t *fib_sr, uint8_t *addr, size_t ad fib_sr_entry_t *elt; LL_FOREACH(fib_sr->sr_path, elt) { size_t addr_size_match = addr_size << 3; - if (universal_address_compare(elt->address, addr, &addr_size_match) == 0) { + if (universal_address_compare(elt->address, addr, &addr_size_match) == UNIVERSAL_ADDRESS_EQUAL) { /* temporary workaround to calm compiler */ (void)sr_path_entry; @@ -954,7 +955,7 @@ int fib_sr_entry_append(fib_table_t *table, fib_sr_t *fib_sr, fib_sr_entry_t *elt; LL_FOREACH(fib_sr->sr_path, elt) { size_t addr_size_match = addr_size << 3; - if (universal_address_compare(elt->address, addr, &addr_size_match) == 0) { + if (universal_address_compare(elt->address, addr, &addr_size_match) == UNIVERSAL_ADDRESS_EQUAL) { mutex_unlock(&(table->mtx_access)); return -EINVAL; } @@ -1000,7 +1001,7 @@ int fib_sr_entry_add(fib_table_t *table, fib_sr_t *fib_sr, fib_sr_entry_t *elt; LL_FOREACH(fib_sr->sr_path, elt) { size_t addr_size_match = addr_size << 3; - if (universal_address_compare(elt->address, addr, &addr_size_match) == 0) { + if (universal_address_compare(elt->address, addr, &addr_size_match) == UNIVERSAL_ADDRESS_EQUAL) { mutex_unlock(&(table->mtx_access)); return -EINVAL; } @@ -1056,7 +1057,7 @@ int fib_sr_entry_delete(fib_table_t *table, fib_sr_t *fib_sr, uint8_t *addr, siz LL_FOREACH(fib_sr->sr_path, elt) { size_t addr_size_match = addr_size << 3; - if (universal_address_compare(elt->address, addr, &addr_size_match) == 0) { + if (universal_address_compare(elt->address, addr, &addr_size_match) == UNIVERSAL_ADDRESS_EQUAL) { universal_address_rem(elt->address); if (keep_remaining_route) { tmp->next = elt->next; @@ -1107,11 +1108,11 @@ int fib_sr_entry_overwrite(fib_table_t *table, fib_sr_t *fib_sr, LL_FOREACH(fib_sr->sr_path, elt) { size_t addr_old_size_match = addr_old_size << 3; size_t addr_new_size_match = addr_old_size << 3; - if (universal_address_compare(elt->address, addr_old, &addr_old_size_match) == 0) { + if (universal_address_compare(elt->address, addr_old, &addr_old_size_match) == UNIVERSAL_ADDRESS_EQUAL) { elt_repl = elt; } - if (universal_address_compare(elt->address, addr_new, &addr_new_size_match) == 0) { + if (universal_address_compare(elt->address, addr_new, &addr_new_size_match) == UNIVERSAL_ADDRESS_EQUAL) { mutex_unlock(&(table->mtx_access)); return -EINVAL; } @@ -1191,7 +1192,7 @@ fib_sr_t* hit = NULL; fib_sr_entry_t *elt; LL_FOREACH(table->data.source_routes->headers[i].sr_path, elt) { size_t addr_size_match = dst_size << 3; - if (universal_address_compare(elt->address, dst, &addr_size_match) == 0) { + if (universal_address_compare(elt->address, dst, &addr_size_match) == UNIVERSAL_ADDRESS_EQUAL) { /* we create a new sr */ if (check_free_entry == -1) { /* we have no room to create a new sr @@ -1320,7 +1321,7 @@ int fib_sr_get_route(fib_table_t *table, uint8_t *dst, size_t dst_size, kernel_p size_t addr_size_match = dst_size << 3; if (universal_address_compare(table->data.source_routes->headers[i].sr_dest->address, - dst, &addr_size_match) == 0) { + dst, &addr_size_match) == UNIVERSAL_ADDRESS_EQUAL) { if (*sr_flags == table->data.source_routes->headers[i].sr_flags) { /* found a perfect matching sr, no need to search further */ hit = &table->data.source_routes->headers[i]; @@ -1624,7 +1625,7 @@ int fib_devel_get_lifetime(fib_table_t *table, uint64_t *lifetime, uint8_t *dst, /* first hit wins here */ for (size_t i = 0; i < table->size; ++i) { if (universal_address_compare(table->data.source_routes->headers[i].sr_dest->address, - dst, &addr_size_match) == 0) { + dst, &addr_size_match) == UNIVERSAL_ADDRESS_EQUAL) { *lifetime = table->data.source_routes->headers[i].sr_lifetime; return 0; }