core: use nmp_utils_sysctl_open_netdir() to detect link-type
This commit is contained in:
@@ -183,39 +183,19 @@ wifi_utils_deinit (WifiData *data)
|
||||
}
|
||||
|
||||
gboolean
|
||||
wifi_utils_is_wifi (int ifindex, const char *ifname)
|
||||
wifi_utils_is_wifi (int dirfd, const char *ifname)
|
||||
{
|
||||
int fd_sysnet;
|
||||
int fd_phy80211;
|
||||
char ifname_verified[IFNAMSIZ];
|
||||
g_return_val_if_fail (dirfd >= 0, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
|
||||
fd_sysnet = nmp_utils_sysctl_open_netdir (ifindex, ifname, ifname_verified);
|
||||
if (fd_sysnet < 0)
|
||||
return FALSE;
|
||||
|
||||
/* there might have been a race and ifname might be wrong. Below for checking
|
||||
* wext, use the possibly improved name that we just verified. */
|
||||
ifname = ifname_verified;
|
||||
|
||||
fd_phy80211 = openat (fd_sysnet, "phy80211", O_CLOEXEC);
|
||||
close (fd_sysnet);
|
||||
|
||||
if (fd_phy80211 >= 0) {
|
||||
close (fd_phy80211);
|
||||
if (faccessat (dirfd, "phy80211", F_OK, 0) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if HAVE_WEXT
|
||||
if (wifi_wext_is_wifi (ifname))
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* OLPC Mesh-only functions */
|
||||
|
||||
guint32
|
||||
|
Reference in New Issue
Block a user