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

int rtnl_route_set_src ( struct rtnl_route *  route,
struct nl_addr *  addr 

Set the source address of a route to the specified address

  • route route to be changed
  • addr new source address
Assigns the new source address to the specified route, overwrites the source address length (rtnl_route::rt_src_len), 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.

0 on success or a negative error code.

Definition at line 1031 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_src)

      route->rt_src = addr;

      return 0;

Generated by  Doxygen 1.6.0   Back to index