From f455b6ec83e9b9e3842f0c7a5e56fa8161301eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0imerda?= Date: Thu, 14 Mar 2013 17:27:27 +0100 Subject: [PATCH] wifi: use nm-platform for ifindex/ifname translation --- src/wifi/wifi-utils-nl80211.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/wifi/wifi-utils-nl80211.c b/src/wifi/wifi-utils-nl80211.c index 486a695198..5f65aef0e2 100644 --- a/src/wifi/wifi-utils-nl80211.c +++ b/src/wifi/wifi-utils-nl80211.c @@ -33,12 +33,12 @@ #include #include #include -#include #include #include "wifi-utils-private.h" #include "wifi-utils-nl80211.h" +#include "nm-platform.h" #include "nm-logging.h" #include "nm-utils.h" @@ -820,27 +820,6 @@ error: return NULL; } -static int -iface_to_index (struct nl_sock *nl_sock, const char *iface) -{ - struct nl_cache *link_cache = NULL; - int err, ifindex; - - /* name to index */ - err = rtnl_link_alloc_cache (nl_sock, AF_UNSPEC, &link_cache); - if (err < 0) { - nm_log_warn (LOGD_HW, "failed to allocate link cache: (%d) %s", - err, nl_geterror (err)); - return -1; - } - nl_cache_mngt_provide (link_cache); - nl_cache_refill (nl_sock, link_cache); - ifindex = rtnl_link_name2i (link_cache, iface); - nl_cache_free (link_cache); - - return ifindex; -} - gboolean wifi_nl80211_is_wifi (const char *iface) { @@ -860,7 +839,7 @@ wifi_nl80211_is_wifi (const char *iface) if (genl_connect (nl_sock)) goto error; - ifindex = iface_to_index (nl_sock, iface); + ifindex = nm_platform_link_get_ifindex (iface); if (ifindex < 0) goto error;