]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Map internal TDLS_PEER_* to NL80211_TDLS_PEER_*
authorJouni Malinen <jouni@codeaurora.org>
Fri, 23 Apr 2021 09:40:07 +0000 (12:40 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 23 Apr 2021 09:40:07 +0000 (12:40 +0300)
Even though these enum definitions are currently identical, it is better
to explicitly map these bits to the kernel interface instead of using
the internal definition for this. This makes it much clearer that new
enum tdls_peer_capability value needs to be assigned in nl80211 before
they can be added into wpa_supplicant.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/drivers/driver_nl80211.c

index ed194be2a8a6fce1d4a8d372f2ae2f2d37475387..c050586800c6c36b0ff916b51156b62ae2dcb95e 100644 (file)
@@ -9200,6 +9200,28 @@ static int nl80211_start_radar_detection(void *priv,
 
 #ifdef CONFIG_TDLS
 
+static int nl80211_add_peer_capab(struct nl_msg *msg,
+                                 enum tdls_peer_capability capa)
+{
+       u32 peer_capab = 0;
+
+       if (!capa)
+               return 0;
+
+       if (capa & TDLS_PEER_HT)
+               peer_capab |= NL80211_TDLS_PEER_HT;
+       if (capa & TDLS_PEER_VHT)
+               peer_capab |= NL80211_TDLS_PEER_VHT;
+       if (capa & TDLS_PEER_WMM)
+               peer_capab |= NL80211_TDLS_PEER_WMM;
+       if (capa & TDLS_PEER_HE)
+               peer_capab |= NL80211_TDLS_PEER_HE;
+
+       return nla_put_u32(msg, NL80211_ATTR_TDLS_PEER_CAPABILITY,
+                          peer_capab);
+}
+
+
 static int nl80211_send_tdls_mgmt(void *priv, const u8 *dst, u8 action_code,
                                  u8 dialog_token, u16 status_code,
                                  u32 peer_capab, int initiator, const u8 *buf,
@@ -9219,21 +9241,9 @@ static int nl80211_send_tdls_mgmt(void *priv, const u8 *dst, u8 action_code,
            nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, dst) ||
            nla_put_u8(msg, NL80211_ATTR_TDLS_ACTION, action_code) ||
            nla_put_u8(msg, NL80211_ATTR_TDLS_DIALOG_TOKEN, dialog_token) ||
-           nla_put_u16(msg, NL80211_ATTR_STATUS_CODE, status_code))
-               goto fail;
-       if (peer_capab) {
-               /*
-                * The internal enum tdls_peer_capability definition is
-                * currently identical with the nl80211 enum
-                * nl80211_tdls_peer_capability, so no conversion is needed
-                * here.
-                */
-               if (nla_put_u32(msg, NL80211_ATTR_TDLS_PEER_CAPABILITY,
-                               peer_capab))
-                       goto fail;
-       }
-       if ((initiator &&
-            nla_put_flag(msg, NL80211_ATTR_TDLS_INITIATOR)) ||
+           nla_put_u16(msg, NL80211_ATTR_STATUS_CODE, status_code) ||
+           nl80211_add_peer_capab(msg, peer_capab) ||
+           (initiator && nla_put_flag(msg, NL80211_ATTR_TDLS_INITIATOR)) ||
            nla_put(msg, NL80211_ATTR_IE, len, buf))
                goto fail;