summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-04-14 10:34:48 +0200
committerLubomir Rintel <lkundrak@v3.sk>2015-05-28 11:51:09 +0200
commit068fb9d06ffc43abd838f021e0eb27ef65b3149f (patch)
treee4bce79455f326ce5549557f7bfe473ebb4f1543
parent48e0ac2e003c58464cc719014bd9dfaef4fa6813 (diff)
downloadNetworkManager-068fb9d06ffc43abd838f021e0eb27ef65b3149f.tar.gz
platform/trivial: move udev_detect_link_type_from_device()
(cherry picked from commit dffb18cb34e616f4d10cb640e04d4970d6db74fa)
-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 23baf14805..e1647011ab 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -70,6 +70,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
@@ -325,6 +331,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
******************************************************************/
@@ -787,42 +822,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)
{