From: Yu Watanabe Date: Mon, 20 Sep 2021 21:25:53 +0000 (+0900) Subject: wifi-util: move, rename, and expose wifi_iftype_to_string() X-Git-Tag: v250-rc1~599^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=abad436d4ce5507424dcca31990d392425de4486;p=thirdparty%2Fsystemd.git wifi-util: move, rename, and expose wifi_iftype_to_string() --- diff --git a/src/shared/net-condition.c b/src/shared/net-condition.c index 4742f374474..b78077f4c4d 100644 --- a/src/shared/net-condition.c +++ b/src/shared/net-condition.c @@ -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)) diff --git a/src/shared/wifi-util.c b/src/shared/wifi-util.c index 8d6c184be1e..308da82fce9 100644 --- a/src/shared/wifi-util.c +++ b/src/shared/wifi-util.c @@ -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); diff --git a/src/shared/wifi-util.h b/src/shared/wifi-util.h index 2d565b3fdac..332097c3489 100644 --- a/src/shared/wifi-util.h +++ b/src/shared/wifi-util.h @@ -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_;