summaryrefslogtreecommitdiff
path: root/src/shared/wifi-util.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-10-25 16:29:23 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-10-25 16:43:18 +0900
commit78404d22cca9cbbc8adb9dd7248da2f2725b1dbc (patch)
treef0d670431a758ec3161c2c70a0bc7d636dbd501a /src/shared/wifi-util.c
parentdf7c4eb62a22a5b131007d98ee49f57f6f95483e (diff)
downloadsystemd-78404d22cca9cbbc8adb9dd7248da2f2725b1dbc.tar.gz
network: support matching based on wifi interfece type
Diffstat (limited to 'src/shared/wifi-util.c')
-rw-r--r--src/shared/wifi-util.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/shared/wifi-util.c b/src/shared/wifi-util.c
index c301a306d3..2717db6507 100644
--- a/src/shared/wifi-util.c
+++ b/src/shared/wifi-util.c
@@ -9,7 +9,7 @@
#include "netlink-util.h"
#include "wifi-util.h"
-int wifi_get_ssid(sd_netlink *genl, int ifindex, char **ssid) {
+int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftype, char **ssid) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL, *reply = NULL;
sd_genl_family family;
int r;
@@ -40,14 +40,25 @@ int wifi_get_ssid(sd_netlink *genl, int ifindex, char **ssid) {
return 0;
}
- r = sd_netlink_message_read_string_strdup(reply, NL80211_ATTR_SSID, ssid);
- if (r < 0 && r != -ENODATA)
- return log_debug_errno(r, "Failed to get NL80211_ATTR_SSID attribute: %m");
+ if (iftype) {
+ uint32_t t;
+
+ r = sd_netlink_message_read_u32(reply, NL80211_ATTR_IFTYPE, &t);
+ if (r < 0)
+ return log_debug_errno(r, "Failed to get NL80211_ATTR_IFTYPE attribute: %m");
+ *iftype = t;
+ }
+
+ if (ssid) {
+ r = sd_netlink_message_read_string_strdup(reply, NL80211_ATTR_SSID, ssid);
+ if (r < 0 && r != -ENODATA)
+ return log_debug_errno(r, "Failed to get NL80211_ATTR_SSID attribute: %m");
+ }
return r == -ENODATA ? 0 : 1;
}
-int wifi_get_bssid(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
+int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL, *reply = NULL;
sd_genl_family family;
int r;