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

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

Set the gateway address of a route to the specified address

  • route route to be changed
  • addr new gateway address
Assigns the new gateway 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.

0 on success or a negative error code.

Definition at line 1078 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_gateway)

      route->rt_gateway = addr;
      route->rt_mask |= (ROUTE_ATTR_GATEWAY | ROUTE_ATTR_FAMILY);

      return 0;

Generated by  Doxygen 1.6.0   Back to index