summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-09-05 17:42:47 +0200
committerMarcel Holtmann <marcel@holtmann.org>2009-09-05 17:42:47 +0200
commit54ae4802821159d072cf5134da2f2c832c42c954 (patch)
tree27bd1f3a1b3215a0cc4d6b73196026eabdf8b442
parent13796884240b7919976a36c4b899f87a5558cb54 (diff)
downloadconnman-54ae4802821159d072cf5134da2f2c832c42c954.tar.gz
connman-54ae4802821159d072cf5134da2f2c832c42c954.tar.bz2
connman-54ae4802821159d072cf5134da2f2c832c42c954.zip
Add helper to check if it is a mac80211 interface
-rw-r--r--include/inet.h1
-rw-r--r--src/inet.c30
2 files changed, 31 insertions, 0 deletions
diff --git a/include/inet.h b/include/inet.h
index d943a262..119fca21 100644
--- a/include/inet.h
+++ b/include/inet.h
@@ -38,6 +38,7 @@ int connman_inet_ifup(int index);
int connman_inet_ifdown(int index);
struct connman_device *connman_inet_create_device(int index);
+connman_bool_t connman_inet_is_mac80211(int index);
int connman_inet_set_address(int index, struct connman_ipaddress *ipaddress);
int connman_inet_clear_address(int index);
diff --git a/src/inet.c b/src/inet.c
index 62f23d4a..1261c5fa 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -288,6 +288,36 @@ static char *index2ident(int index, const char *prefix)
return str;
}
+connman_bool_t connman_inet_is_mac80211(int index)
+{
+ connman_bool_t result = FALSE;
+ char phy80211_path[PATH_MAX];
+ struct stat st;
+ struct ifreq ifr;
+ int sk;
+
+ sk = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sk < 0)
+ return FALSE;
+
+ memset(&ifr, 0, sizeof(ifr));
+ ifr.ifr_ifindex = index;
+
+ if (ioctl(sk, SIOCGIFNAME, &ifr) < 0)
+ goto done;
+
+ snprintf(phy80211_path, PATH_MAX,
+ "/sys/class/net/%s/phy80211", ifr.ifr_name);
+
+ if (stat(phy80211_path, &st) == 0 && (st.st_mode & S_IFDIR))
+ result = TRUE;
+
+done:
+ close(sk);
+
+ return result;
+}
+
enum connman_device_type __connman_inet_get_device_type(int index)
{
enum connman_device_type devtype = CONNMAN_DEVICE_TYPE_UNKNOWN;