wifi-util: move, rename, and expose wifi_iftype_to_string()
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "socket-util.h"
|
||||
#include "string-table.h"
|
||||
#include "strv.h"
|
||||
#include "wifi-util.h"
|
||||
|
||||
void net_match_clear(NetMatch *match) {
|
||||
if (!match)
|
||||
@@ -117,23 +118,6 @@ static int net_condition_test_property(char * const *match_property, sd_device *
|
||||
return true;
|
||||
}
|
||||
|
||||
static const char *const wifi_iftype_table[NL80211_IFTYPE_MAX+1] = {
|
||||
[NL80211_IFTYPE_ADHOC] = "ad-hoc",
|
||||
[NL80211_IFTYPE_STATION] = "station",
|
||||
[NL80211_IFTYPE_AP] = "ap",
|
||||
[NL80211_IFTYPE_AP_VLAN] = "ap-vlan",
|
||||
[NL80211_IFTYPE_WDS] = "wds",
|
||||
[NL80211_IFTYPE_MONITOR] = "monitor",
|
||||
[NL80211_IFTYPE_MESH_POINT] = "mesh-point",
|
||||
[NL80211_IFTYPE_P2P_CLIENT] = "p2p-client",
|
||||
[NL80211_IFTYPE_P2P_GO] = "p2p-go",
|
||||
[NL80211_IFTYPE_P2P_DEVICE] = "p2p-device",
|
||||
[NL80211_IFTYPE_OCB] = "ocb",
|
||||
[NL80211_IFTYPE_NAN] = "nan",
|
||||
};
|
||||
|
||||
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(wifi_iftype, enum nl80211_iftype);
|
||||
|
||||
int net_match_config(
|
||||
const NetMatch *match,
|
||||
sd_device *device,
|
||||
@@ -194,7 +178,7 @@ int net_match_config(
|
||||
if (!net_condition_test_property(match->property, device))
|
||||
return false;
|
||||
|
||||
if (!net_condition_test_strv(match->wifi_iftype, wifi_iftype_to_string(wifi_iftype)))
|
||||
if (!net_condition_test_strv(match->wifi_iftype, nl80211_iftype_to_string(wifi_iftype)))
|
||||
return false;
|
||||
|
||||
if (!net_condition_test_strv(match->ssid, ssid))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "log.h"
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
#include "wifi-util.h"
|
||||
|
||||
@@ -136,3 +137,20 @@ nodata:
|
||||
*ret_bssid = ETHER_ADDR_NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char * const nl80211_iftype_table[NUM_NL80211_IFTYPES] = {
|
||||
[NL80211_IFTYPE_ADHOC] = "ad-hoc",
|
||||
[NL80211_IFTYPE_STATION] = "station",
|
||||
[NL80211_IFTYPE_AP] = "ap",
|
||||
[NL80211_IFTYPE_AP_VLAN] = "ap-vlan",
|
||||
[NL80211_IFTYPE_WDS] = "wds",
|
||||
[NL80211_IFTYPE_MONITOR] = "monitor",
|
||||
[NL80211_IFTYPE_MESH_POINT] = "mesh-point",
|
||||
[NL80211_IFTYPE_P2P_CLIENT] = "p2p-client",
|
||||
[NL80211_IFTYPE_P2P_GO] = "p2p-go",
|
||||
[NL80211_IFTYPE_P2P_DEVICE] = "p2p-device",
|
||||
[NL80211_IFTYPE_OCB] = "ocb",
|
||||
[NL80211_IFTYPE_NAN] = "nan",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP_TO_STRING(nl80211_iftype, enum nl80211_iftype);
|
||||
|
||||
@@ -10,3 +10,5 @@
|
||||
|
||||
int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *ret_iftype, char **ret_ssid);
|
||||
int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *ret_bssid);
|
||||
|
||||
const char *nl80211_iftype_to_string(enum nl80211_iftype iftype) _const_;
|
||||
|
||||
Reference in New Issue
Block a user