if (vec_len (m->locals))
{
hi = vec_len (m->locals) - 1;
rand = 1 + (random_u32 (&sm->random_seed) % m->locals[hi].prefix);
while (lo < hi)
{
mid = ((hi - 1) >> 1) + lo; ----Mabe there is some mistake here, it should be hi -lo, or it will couse dead loop here.
(rand > m->locals[mid].prefix) ? (lo = mid + 1) : (hi = mid);
}
if (!(m->locals[lo].prefix >= rand))
return 1;
mapping->addr = m->locals[lo].addr;
mapping->port = clib_host_to_net_u16 (m->locals[lo].port);
}