mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 11:00:09 +01:00
platform: add nm_platform_ip_route_add() function
This commit is contained in:
parent
abaaf3a693
commit
35ed678cc6
2 changed files with 46 additions and 21 deletions
|
|
@ -3471,23 +3471,56 @@ nm_platform_address_flush (NMPlatform *self, int ifindex)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_platform_ip4_route_add (NMPlatform *self,
|
||||
NMPNlmFlags flags,
|
||||
const NMPlatformIP4Route *route)
|
||||
static gboolean
|
||||
_ip_route_add (NMPlatform *self,
|
||||
NMPNlmFlags flags,
|
||||
int addr_family,
|
||||
gconstpointer route)
|
||||
{
|
||||
char sbuf[sizeof (_nm_utils_to_string_buffer)];
|
||||
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (route, FALSE);
|
||||
g_return_val_if_fail (route->plen <= 32, FALSE);
|
||||
nm_assert (route);
|
||||
nm_assert (NM_IN_SET (addr_family, AF_INET, AF_INET6));
|
||||
|
||||
_LOGD ("route: %-10s IPv4 route: %s",
|
||||
_LOGD ("route: %-10s IPv%c route: %s",
|
||||
_nmp_nlm_flag_to_string (flags),
|
||||
nm_platform_ip4_route_to_string (route, sbuf, sizeof (sbuf)));
|
||||
addr_family == AF_INET ? '4' : '6',
|
||||
addr_family == AF_INET
|
||||
? nm_platform_ip4_route_to_string (route, sbuf, sizeof (sbuf))
|
||||
: nm_platform_ip6_route_to_string (route, sbuf, sizeof (sbuf)));
|
||||
|
||||
return klass->ip_route_add (self, flags, AF_INET, (const NMPlatformIPRoute *) route);
|
||||
return klass->ip_route_add (self, flags, addr_family, route);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_ip_route_add (NMPlatform *self,
|
||||
NMPNlmFlags flags,
|
||||
const NMPObject *route)
|
||||
{
|
||||
int addr_family;
|
||||
|
||||
switch (NMP_OBJECT_GET_TYPE (route)) {
|
||||
case NMP_OBJECT_TYPE_IP4_ROUTE:
|
||||
addr_family = AF_INET;
|
||||
break;
|
||||
case NMP_OBJECT_TYPE_IP6_ROUTE:
|
||||
addr_family = AF_INET6;
|
||||
break;
|
||||
default:
|
||||
g_return_val_if_reached (FALSE);
|
||||
}
|
||||
|
||||
return _ip_route_add (self, flags, addr_family, NMP_OBJECT_CAST_IP_ROUTE (route));
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_ip4_route_add (NMPlatform *self,
|
||||
NMPNlmFlags flags,
|
||||
const NMPlatformIP4Route *route)
|
||||
{
|
||||
return _ip_route_add (self, flags, AF_INET, route);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -3495,18 +3528,7 @@ nm_platform_ip6_route_add (NMPlatform *self,
|
|||
NMPNlmFlags flags,
|
||||
const NMPlatformIP6Route *route)
|
||||
{
|
||||
char sbuf[sizeof (_nm_utils_to_string_buffer)];
|
||||
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (route, FALSE);
|
||||
g_return_val_if_fail (route->plen <= 128, FALSE);
|
||||
|
||||
_LOGD ("route: %-10s IPv6 route: %s",
|
||||
_nmp_nlm_flag_to_string (flags),
|
||||
nm_platform_ip6_route_to_string (route, sbuf, sizeof (sbuf)));
|
||||
|
||||
return klass->ip_route_add (self, flags, AF_INET6, (const NMPlatformIPRoute *) route);
|
||||
return _ip_route_add (self, flags, AF_INET6, route);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
|
|
@ -1112,6 +1112,9 @@ gboolean nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, GPtrArray
|
|||
gboolean nm_platform_ip6_address_sync (NMPlatform *self, int ifindex, const GPtrArray *known_addresses, gboolean keep_link_local);
|
||||
gboolean nm_platform_address_flush (NMPlatform *self, int ifindex);
|
||||
|
||||
gboolean nm_platform_ip_route_add (NMPlatform *self,
|
||||
NMPNlmFlags flags,
|
||||
const NMPObject *route);
|
||||
gboolean nm_platform_ip4_route_add (NMPlatform *self, NMPNlmFlags flags, const NMPlatformIP4Route *route);
|
||||
gboolean nm_platform_ip6_route_add (NMPlatform *self, NMPNlmFlags flags, const NMPlatformIP6Route *route);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue