network: support matching based on wifi interfece type

This commit is contained in:
Yu Watanabe
2019-10-25 16:43:18 +09:00
parent df7c4eb62a
commit 78404d22cc
17 changed files with 6648 additions and 30 deletions
File diff suppressed because it is too large Load Diff
+16 -5
View File
@@ -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;
+4 -2
View File
@@ -2,7 +2,9 @@
#pragma once
#include <linux/nl80211.h>
#include "netlink-util.h"
int wifi_get_ssid(sd_netlink *genl, int ifindex, char **ssid);
int wifi_get_bssid(sd_netlink *genl, int ifindex, struct ether_addr *bssid);
int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftype, char **ssid);
int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid);