public static Route RequestRoute(nl_sock *socket, Subnet destinationSubnet) { nl_cache *cache; var family = AddressFamily.Convert(destinationSubnet.NetworkAddress.AddressFamily); LibNLRoute3.rtnl_route_alloc_cache(socket, family, 0, &cache); //Check that the number of items is not 0 int count = LibNL3.nl_cache_nitems(cache); if (count == 0) { return(null); } nl_addr *destinationNetwork; fixed(byte *bytes = destinationSubnet.NetworkAddress.GetAddressBytes()) { destinationNetwork = LibNL3.nl_addr_build(family, bytes, AddressFamily.Size(family)); } nl_object *current = LibNL3.nl_cache_get_first(cache); for (int i = 0; i < count; i++) { nl_addr *dAddr = LibNLRoute3.rtnl_route_get_dst((rtnl_route *)current); if (LibNL3.nl_addr_get_prefixlen(dAddr) == destinationSubnet.NetmaskLength && LibNL3.nl_addr_cmp_prefix(dAddr, destinationNetwork) == 0) { return(new Route(current)); } current = LibNL3.nl_cache_get_next(current); } return(null); }