]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
wifi-util: move, rename, and expose wifi_iftype_to_string()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 20 Sep 2021 21:25:53 +0000 (06:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 29 Sep 2021 06:38:59 +0000 (15:38 +0900)
src/shared/net-condition.c
src/shared/wifi-util.c
src/shared/wifi-util.h

index 4742f374474f6bcb3d0bccd78d4ea4af9bfaf198..b78077f4c4d431c91a0aab5b1437067085506e8d 100644 (file)
@@ -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))
index 8d6c184be1e2be4f7dbcd787b69f269200da86ac..308da82fce93d50081a5106a8dda1428c9f08052 100644 (file)
@@ -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);
index 2d565b3fdacf338d82db12f67681f7b37ca35ca5..332097c348977b77b4b01f7624d32e1a82dba0d4 100644 (file)
@@ -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_;