Logo Search packages:      
Sourcecode: libnl2 version File versions  Download package

int rtnl_route_alloc_cache ( struct nl_sock *  sk,
int  family,
int  flags,
struct nl_cache **  result 
)

Build a route cache holding all routes currently configured in the kernel

  • sk Netlink socket.
  • family Address family of routes to cover or AF_UNSPEC
  • flags Flags
Allocates a new cache, initializes it properly and updates it to contain all routes currently configured in the kernel.

Note:
The caller is responsible for destroying and freeing the cache after using it.
Returns:
The cache or NULL if an error has occured.

Definition at line 75 of file route.c.

References nl_cache_alloc(), and nl_cache_refill().

{
      struct nl_cache *cache;
      int err;

      if (!(cache = nl_cache_alloc(&rtnl_route_ops)))
            return -NLE_NOMEM;

      cache->c_iarg1 = family;
      cache->c_iarg2 = flags;

      if (sk && (err = nl_cache_refill(sk, cache)) < 0) {
            free(cache);
            return err;
      }

      *result = cache;
      return 0;
}


Generated by  Doxygen 1.6.0   Back to index