summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-04-14 10:34:48 +0200
committerThomas Haller <thaller@redhat.com>2015-04-14 13:06:53 +0200
commitdffb18cb34e616f4d10cb640e04d4970d6db74fa (patch)
treeab62f7e5c20477eca31d1196146ddb37be173149
parent34d82d0df19d73b30708dc4a3e9f8d91da3721c0 (diff)
downloadNetworkManager-dffb18cb34e616f4d10cb640e04d4970d6db74fa.tar.gz
platform/trivial: move udev_detect_link_type_from_device()
-rw-r--r--src/platform/nm-linux-platform.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 78164be424..004c943ad3 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -71,6 +71,12 @@
#define warning(...) nm_log_warn (LOGD_PLATFORM, __VA_ARGS__)
#define error(...) nm_log_err (LOGD_PLATFORM, __VA_ARGS__)
+#define return_type(t, name) \
+ G_STMT_START { \
+ if (out_name) \
+ *out_name = name; \
+ return t; \
+ } G_STMT_END
/******************************************************************
* libnl unility functions and wrappers
@@ -326,6 +332,35 @@ udev_get_driver (GUdevDevice *device, int ifindex)
return driver;
}
+static NMLinkType
+udev_detect_link_type_from_device (GUdevDevice *udev_device, const char *ifname, int arptype, const char **out_name)
+{
+ const char *prop, *sysfs_path;
+
+ g_assert (ifname);
+
+ if (!udev_device)
+ return_type (NM_LINK_TYPE_UNKNOWN, "unknown");
+
+ if ( g_udev_device_get_property (udev_device, "ID_NM_OLPC_MESH")
+ || g_udev_device_get_sysfs_attr (udev_device, "anycast_mask"))
+ return_type (NM_LINK_TYPE_OLPC_MESH, "olpc-mesh");
+
+ prop = g_udev_device_get_property (udev_device, "DEVTYPE");
+ sysfs_path = g_udev_device_get_sysfs_path (udev_device);
+ if (wifi_utils_is_wifi (ifname, sysfs_path, prop))
+ return_type (NM_LINK_TYPE_WIFI, "wifi");
+ else if (g_strcmp0 (prop, "wwan") == 0)
+ return_type (NM_LINK_TYPE_WWAN_ETHERNET, "wwan");
+ else if (g_strcmp0 (prop, "wimax") == 0)
+ return_type (NM_LINK_TYPE_WIMAX, "wimax");
+
+ if (arptype == ARPHRD_ETHER)
+ return_type (NM_LINK_TYPE_ETHERNET, "ethernet");
+
+ return_type (NM_LINK_TYPE_UNKNOWN, "unknown");
+}
+
/******************************************************************
* NMPlatform types and functions
******************************************************************/
@@ -789,42 +824,6 @@ type_to_string (NMLinkType type)
}
}
-#define return_type(t, name) \
- G_STMT_START { \
- if (out_name) \
- *out_name = name; \
- return t; \
- } G_STMT_END
-
-static NMLinkType
-udev_detect_link_type_from_device (GUdevDevice *udev_device, const char *ifname, int arptype, const char **out_name)
-{
- const char *prop, *sysfs_path;
-
- g_assert (ifname);
-
- if (!udev_device)
- return_type (NM_LINK_TYPE_UNKNOWN, "unknown");
-
- if ( g_udev_device_get_property (udev_device, "ID_NM_OLPC_MESH")
- || g_udev_device_get_sysfs_attr (udev_device, "anycast_mask"))
- return_type (NM_LINK_TYPE_OLPC_MESH, "olpc-mesh");
-
- prop = g_udev_device_get_property (udev_device, "DEVTYPE");
- sysfs_path = g_udev_device_get_sysfs_path (udev_device);
- if (wifi_utils_is_wifi (ifname, sysfs_path, prop))
- return_type (NM_LINK_TYPE_WIFI, "wifi");
- else if (g_strcmp0 (prop, "wwan") == 0)
- return_type (NM_LINK_TYPE_WWAN_ETHERNET, "wwan");
- else if (g_strcmp0 (prop, "wimax") == 0)
- return_type (NM_LINK_TYPE_WIMAX, "wimax");
-
- if (arptype == ARPHRD_ETHER)
- return_type (NM_LINK_TYPE_ETHERNET, "ethernet");
-
- return_type (NM_LINK_TYPE_UNKNOWN, "unknown");
-}
-
static const char *
ethtool_get_driver (const char *ifname)
{