summary refs log tree commit diff
path: root/src/nm-route-manager.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2017-01-17 20:25:09 +0100
committerMichael Biebl <biebl@debian.org>2017-01-17 20:25:09 +0100
commit58f8be580039b0575b197b9573a1c92745d96d30 (patch)
tree2c226233f623a0dcb529be0eb8cdf97e4a2ae0c0 /src/nm-route-manager.c
parent45cb5bb3c0e6edb887cf69b417fcaf7053814a9b (diff)
New upstream version 1.5.90 upstream/1.5.90
Diffstat (limited to 'src/nm-route-manager.c')
-rw-r--r--src/nm-route-manager.c68
1 files changed, 42 insertions, 26 deletions
diff --git a/src/nm-route-manager.c b/src/nm-route-manager.c
index 2d4c7d95..344ebc46 100644
--- a/src/nm-route-manager.c
+++ b/src/nm-route-manager.c
@@ -20,11 +20,12 @@
 
 #include "nm-default.h"
 
+#include "nm-route-manager.h"
+
 #include <string.h>
 
-#include "nm-route-manager.h"
-#include "nm-platform.h"
-#include "nmp-object.h"
+#include "platform/nm-platform.h"
+#include "platform/nmp-object.h"
 #include "nm-core-internal.h"
 #include "NetworkManagerUtils.h"
 
@@ -34,6 +35,8 @@
 
 #define IP4_DEVICE_ROUTES_GC_INTERVAL_SEC              (IP4_DEVICE_ROUTES_WAIT_TIME_NS * 2)
 
+/*****************************************************************************/
+
 typedef struct {
 	guint len;
 	NMPlatformIPXRoute *entries[1];
@@ -58,6 +61,12 @@ typedef struct {
 	NMPObject *obj;
 } IP4DeviceRoutePurgeEntry;
 
+/*****************************************************************************/
+
+NM_GOBJECT_PROPERTIES_DEFINE_BASE (
+	PROP_PLATFORM,
+);
+
 typedef struct {
 	NMPlatform *platform;
 
@@ -69,17 +78,24 @@ typedef struct {
 	} ip4_device_routes;
 } NMRouteManagerPrivate;
 
-#define NM_ROUTE_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ROUTE_MANAGER, NMRouteManagerPrivate))
+struct _NMRouteManager {
+	GObject parent;
+	NMRouteManagerPrivate _priv;
+};
+
+struct _NMRouteManagerClass {
+	GObjectClass parent;
+};
 
 G_DEFINE_TYPE (NMRouteManager, nm_route_manager, G_TYPE_OBJECT);
 
-NM_GOBJECT_PROPERTIES_DEFINE_BASE (
-	PROP_PLATFORM,
-);
+#define NM_ROUTE_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMRouteManager, NM_IS_ROUTE_MANAGER)
+
+/*****************************************************************************/
 
 NM_DEFINE_SINGLETON_GETTER (NMRouteManager, nm_route_manager_get, NM_TYPE_ROUTE_MANAGER);
 
-/*********************************************************************************************/
+/*****************************************************************************/
 
 typedef struct {
 	const NMPlatformVTableRoute *vt;
@@ -112,7 +128,7 @@ static const VTableIP vtable_v4, vtable_v6;
 			return 1; \
 	} G_STMT_END
 
-/*********************************************************************************************/
+/*****************************************************************************/
 
 #define _NMLOG_PREFIX_NAME   "route-mgr"
 #undef  _NMLOG_ENABLED
@@ -144,11 +160,11 @@ static const VTableIP vtable_v4, vtable_v6;
         } \
     } G_STMT_END
 
-/*********************************************************************************************/
+/*****************************************************************************/
 
 static gboolean _ip4_device_routes_cancel (NMRouteManager *self);
 
-/*********************************************************************************************/
+/*****************************************************************************/
 
 #if NM_MORE_ASSERTS && !defined (G_DISABLE_ASSERT)
 inline static void
@@ -202,7 +218,7 @@ ASSERT_route_index_valid (const VTableIP *vtable, const GArray *entries, const R
 #define ASSERT_route_index_valid(vtable, entries, index, unique_ifindexes) G_STMT_START { (void) 0; } G_STMT_END
 #endif
 
-/*********************************************************************************************/
+/*****************************************************************************/
 
 static int
 _v4_route_dest_cmp (const NMPlatformIP4Route *r1, const NMPlatformIP4Route *r2)
@@ -254,7 +270,7 @@ _v6_route_id_cmp (const NMPlatformIP6Route *r1, const NMPlatformIP6Route *r2)
 	return 0;
 }
 
-/*********************************************************************************************/
+/*****************************************************************************/
 
 static int
 _route_index_create_sort (const NMPlatformIPXRoute **p1, const NMPlatformIPXRoute ** p2, const VTableIP *vtable)
@@ -296,7 +312,7 @@ _route_index_find (const VTableIP *vtable, const RouteIndex *index, const NMPlat
 {
 	gssize idx, idx2;
 
-	idx = _nm_utils_ptrarray_find_binary_search ((gpointer *) index->entries, index->len, (gpointer) needle, (GCompareDataFunc) _vx_route_id_cmp_full, (gpointer) vtable);
+	idx = _nm_utils_ptrarray_find_binary_search ((gconstpointer *) index->entries, index->len, needle, (GCompareDataFunc) _vx_route_id_cmp_full, (gpointer) vtable);
 	if (idx < 0)
 		return idx;
 
@@ -340,7 +356,7 @@ _route_index_reverse_idx (const VTableIP *vtable, const RouteIndex *index, guint
 	return offset;
 }
 
-/*********************************************************************************************/
+/*****************************************************************************/
 
 static gboolean
 _route_equals_ignoring_ifindex (const VTableIP *vtable, const NMPlatformIPXRoute *r1, const NMPlatformIPXRoute *r2, gint64 r2_metric)
@@ -431,7 +447,7 @@ _sort_indexes_cmp (guint *a, guint *b)
 	g_return_val_if_reached (0);
 }
 
-/*********************************************************************************************/
+/*****************************************************************************/
 
 static gboolean
 _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const GArray *known_routes, gboolean ignore_kernel_routes, gboolean full_sync)
@@ -951,7 +967,7 @@ nm_route_manager_route_flush (NMRouteManager *self, int ifindex)
 	return success;
 }
 
-/*********************************************************************************************/
+/*****************************************************************************/
 
 static gboolean
 _ip4_device_routes_entry_expired (const IP4DeviceRoutePurgeEntry *entry, gint64 now)
@@ -1011,12 +1027,13 @@ _ip4_device_routes_idle_cb (IP4DeviceRoutePurgeEntry *entry)
 
 static void
 _ip4_device_routes_ip4_route_changed (NMPlatform *platform,
-                                      NMPObjectType obj_type,
+                                      int obj_type_i,
                                       int ifindex,
                                       const NMPlatformIP4Route *route,
-                                      NMPlatformSignalChangeType change_type,
+                                      int change_type_i,
                                       NMRouteManager *self)
 {
+	const NMPlatformSignalChangeType change_type = change_type_i;
 	NMRouteManagerPrivate *priv;
 	NMPObject obj_needle;
 	IP4DeviceRoutePurgeEntry *entry;
@@ -1126,7 +1143,7 @@ nm_route_manager_ip4_route_register_device_route_purge_list (NMRouteManager *sel
 	}
 }
 
-/*********************************************************************************************/
+/*****************************************************************************/
 
 static const VTableIP vtable_v4 = {
 	.vt                             = &nm_platform_vtable_route_v4,
@@ -1140,7 +1157,7 @@ static const VTableIP vtable_v6 = {
 	.route_id_cmp                   = (int (*) (const NMPlatformIPXRoute *, const NMPlatformIPXRoute *)) _v6_route_id_cmp,
 };
 
-/*********************************************************************************************/
+/*****************************************************************************/
 
 static void
 set_property (GObject *object, guint prop_id,
@@ -1163,6 +1180,8 @@ set_property (GObject *object, guint prop_id,
 	}
 }
 
+/*****************************************************************************/
+
 static void
 nm_route_manager_init (NMRouteManager *self)
 {
@@ -1194,7 +1213,7 @@ static void
 dispose (GObject *object)
 {
 	NMRouteManager *self = NM_ROUTE_MANAGER (object);
-	NMRouteManagerPrivate *priv = NM_ROUTE_MANAGER_GET_PRIVATE (object);
+	NMRouteManagerPrivate *priv = NM_ROUTE_MANAGER_GET_PRIVATE (self);
 
 	g_hash_table_remove_all (priv->ip4_device_routes.entries);
 	_ip4_device_routes_cancel (self);
@@ -1205,7 +1224,7 @@ dispose (GObject *object)
 static void
 finalize (GObject *object)
 {
-	NMRouteManagerPrivate *priv = NM_ROUTE_MANAGER_GET_PRIVATE (object);
+	NMRouteManagerPrivate *priv = NM_ROUTE_MANAGER_GET_PRIVATE ((NMRouteManager *) object);
 
 	g_array_free (priv->ip4_routes.entries, TRUE);
 	g_array_free (priv->ip6_routes.entries, TRUE);
@@ -1228,9 +1247,6 @@ nm_route_manager_class_init (NMRouteManagerClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	g_type_class_add_private (klass, sizeof (NMRouteManagerPrivate));
-
-	/* virtual methods */
 	object_class->set_property = set_property;
 	object_class->dispose = dispose;
 	object_class->finalize = finalize;