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

int rtnl_route_set_pref_src ( struct rtnl_route *  route,
struct nl_addr *  addr 
)

Set the preferred source address of a route to the specified address

  • route route to be changed
  • addr new preferred source address
Assigns the new preferred source address to the specified route, and sets the route's address family to the new address's family if it is not set already.

If a address family has been specified already via either calling rtnl_route_set_family() or by setting one of the other addresses, the specified addr is automatically validated against this family and the assignment fails in case of a mismatch.

Returns:
0 on success or a negative error code.

Definition at line 1125 of file route.c.

References nl_addr_get(), and nl_addr_put().

{
      if (route->rt_mask & ROUTE_ATTR_FAMILY) {
            if (addr->a_family != route->rt_family)
                  return nl_error(EINVAL, "Address family mismatch");
      } else
            route->rt_family = addr->a_family;

      if (route->rt_pref_src)
            nl_addr_put(route->rt_pref_src);

      nl_addr_get(addr);
      route->rt_pref_src = addr;
      route->rt_mask |= (ROUTE_ATTR_PREF_SRC | ROUTE_ATTR_FAMILY);

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index