]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use a shared helper function for RSN supplicant capabilities
authorJouni Malinen <j@w1.fi>
Sun, 22 Mar 2020 22:08:38 +0000 (00:08 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 23 Mar 2020 09:47:31 +0000 (11:47 +0200)
Avoid practically copy-pasted code for determining local RSN
capabilities.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/rsn_supp/wpa_ft.c
src/rsn_supp/wpa_ie.c
src/rsn_supp/wpa_ie.h

index bec5eb0b2fa730e0861caef87a91db12e644a1ad..203a61c786a76f9796dfd87d40cff6768157c862 100644 (file)
@@ -178,7 +178,6 @@ static u8 * wpa_ft_gen_req_ies(struct wpa_sm *sm, size_t *len,
        u8 *buf, *pos, *ftie_len, *ftie_pos, *fte_mic, *elem_count;
        struct rsn_mdie *mdie;
        struct rsn_ie_hdr *rsnie;
-       u16 capab;
        int mdie_len;
        u8 rsnxe[10];
        size_t rsnxe_len;
@@ -258,16 +257,7 @@ static u8 * wpa_ft_gen_req_ies(struct wpa_sm *sm, size_t *len,
        pos += RSN_SELECTOR_LEN;
 
        /* RSN Capabilities */
-       capab = 0;
-       if (sm->mfp)
-               capab |= WPA_CAPABILITY_MFPC;
-       if (sm->mfp == 2)
-               capab |= WPA_CAPABILITY_MFPR;
-       if (sm->ocv)
-               capab |= WPA_CAPABILITY_OCVC;
-       if (sm->ext_key_id)
-               capab |= WPA_CAPABILITY_EXT_KEY_ID_FOR_UNICAST;
-       WPA_PUT_LE16(pos, capab);
+       WPA_PUT_LE16(pos, rsn_supp_capab(sm));
        pos += 2;
 
        /* PMKID Count */
index e8a040a2b055dd0b0523aad06bfbf51a21a6787b..9068781b1f9a280b16212d819bb376fcaea1f15e 100644 (file)
@@ -105,6 +105,23 @@ static int wpa_gen_wpa_ie_wpa(u8 *wpa_ie, size_t wpa_ie_len,
 }
 
 
+u16 rsn_supp_capab(struct wpa_sm *sm)
+{
+       u16 capab = 0;
+
+       if (sm->mfp)
+               capab |= WPA_CAPABILITY_MFPC;
+       if (sm->mfp == 2)
+               capab |= WPA_CAPABILITY_MFPR;
+       if (sm->ocv)
+               capab |= WPA_CAPABILITY_OCVC;
+       if (sm->ext_key_id)
+               capab |= WPA_CAPABILITY_EXT_KEY_ID_FOR_UNICAST;
+
+       return capab;
+}
+
+
 static int wpa_gen_wpa_ie_rsn(u8 *rsn_ie, size_t rsn_ie_len,
                              int pairwise_cipher, int group_cipher,
                              int key_mgmt, int mgmt_group_cipher,
@@ -112,7 +129,6 @@ static int wpa_gen_wpa_ie_rsn(u8 *rsn_ie, size_t rsn_ie_len,
 {
        u8 *pos;
        struct rsn_ie_hdr *hdr;
-       u16 capab;
        u32 suite;
 
        if (rsn_ie_len < sizeof(*hdr) + RSN_SELECTOR_LEN +
@@ -214,16 +230,7 @@ static int wpa_gen_wpa_ie_rsn(u8 *rsn_ie, size_t rsn_ie_len,
        pos += RSN_SELECTOR_LEN;
 
        /* RSN Capabilities */
-       capab = 0;
-       if (sm->mfp)
-               capab |= WPA_CAPABILITY_MFPC;
-       if (sm->mfp == 2)
-               capab |= WPA_CAPABILITY_MFPR;
-       if (sm->ocv)
-               capab |= WPA_CAPABILITY_OCVC;
-       if (sm->ext_key_id)
-               capab |= WPA_CAPABILITY_EXT_KEY_ID_FOR_UNICAST;
-       WPA_PUT_LE16(pos, capab);
+       WPA_PUT_LE16(pos, rsn_supp_capab(sm));
        pos += 2;
 
        if (sm->cur_pmksa) {
index 6dc6cf560df938d07a77334000795df9a2309302..83a6727fe014cba5e9006959ef1fba2c6587730e 100644 (file)
@@ -13,5 +13,6 @@ struct wpa_sm;
 
 int wpa_gen_wpa_ie(struct wpa_sm *sm, u8 *wpa_ie, size_t wpa_ie_len);
 int wpa_gen_rsnxe(struct wpa_sm *sm, u8 *rsnxe, size_t rsnxe_len);
+u16 rsn_supp_capab(struct wpa_sm *sm);
 
 #endif /* WPA_IE_H */