Skip to content

Commit

Permalink
[gsupplicant] Added missing KeyMgmt caps. JB#59693
Browse files Browse the repository at this point in the history
  • Loading branch information
monich committed Jan 13, 2023
1 parent 4e59a0e commit 60957be
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 27 deletions.
8 changes: 6 additions & 2 deletions include/gsupplicant_types.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2020 Jolla Ltd.
* Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
Expand Down Expand Up @@ -66,7 +66,11 @@ typedef enum gsupplicant_keymgmt {
GSUPPLICANT_KEYMGMT_WPA_EAP_SHA256 = (0x00000040),
GSUPPLICANT_KEYMGMT_IEEE8021X = (0x00000080),
GSUPPLICANT_KEYMGMT_WPA_NONE = (0x00000100),
GSUPPLICANT_KEYMGMT_WPS = (0x00000200)
GSUPPLICANT_KEYMGMT_WPS = (0x00000200),
GSUPPLICANT_KEYMGMT_SAE = (0x00000400), /* Since 1.0.27 */
GSUPPLICANT_KEYMGMT_SAE_EXT_KEY = (0x00000800), /* Since 1.0.27 */
GSUPPLICANT_KEYMGMT_FT_SAE = (0x00001000), /* Since 1.0.27 */
GSUPPLICANT_KEYMGMT_FT_SAE_EXT_KEY = (0x00002000) /* Since 1.0.27 */
} GSUPPLICANT_KEYMGMT;

typedef enum gsupplicant_protocol {
Expand Down
21 changes: 19 additions & 2 deletions src/gsupplicant.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2021 Jolla Ltd.
* Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2015-2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
Expand Down Expand Up @@ -190,7 +190,11 @@ static const GSupNameIntPair gsupplicant_keymgmt_suites [] = {
{ "wpa-eap-sha256", GSUPPLICANT_KEYMGMT_WPA_EAP_SHA256 },
{ "ieee8021x", GSUPPLICANT_KEYMGMT_IEEE8021X },
{ "wpa-none", GSUPPLICANT_KEYMGMT_WPA_NONE },
{ "wps", GSUPPLICANT_KEYMGMT_WPS }
{ "wps", GSUPPLICANT_KEYMGMT_WPS },
{ "sae", GSUPPLICANT_KEYMGMT_SAE },
{ "sae-ext-key", GSUPPLICANT_KEYMGMT_SAE_EXT_KEY },
{ "ft-sae", GSUPPLICANT_KEYMGMT_FT_SAE },
{ "ft-sae-ext-key", GSUPPLICANT_KEYMGMT_FT_SAE_EXT_KEY }
};

/*==========================================================================*
Expand Down Expand Up @@ -890,6 +894,19 @@ gsupplicant_keymgmt_suite_name(
gsupplicant_keymgmt_suites, G_N_ELEMENTS(gsupplicant_keymgmt_suites));
}

/*==========================================================================*
* Internal API
*==========================================================================*/

GSUPPLICANT_KEYMGMT
gsupplicant_parse_keymgmt_list(
const char* name,
GVariant* value)
{
return gsupplicant_parse_bits_array(0, name, value,
gsupplicant_keymgmt_suites, G_N_ELEMENTS(gsupplicant_keymgmt_suites));
}

/*==========================================================================*
* Internals
*==========================================================================*/
Expand Down
11 changes: 3 additions & 8 deletions src/gsupplicant_bss.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2021 Jolla Ltd.
* Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2015-2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
Expand Down Expand Up @@ -34,6 +34,7 @@

#include "gsupplicant_bss.h"
#include "gsupplicant_interface.h"
#include "gsupplicant_p.h"
#include "gsupplicant_util_p.h"
#include "gsupplicant_dbus.h"
#include "gsupplicant_log.h"
Expand Down Expand Up @@ -481,13 +482,7 @@ gsupplicant_bss_parse_wpa(
{
GSupplicantBSSWPA* wpa = data;
if (!g_strcmp0(name, "KeyMgmt")) {
static const GSupNameIntPair keymgmt_map [] = {
{ "wpa-psk", GSUPPLICANT_KEYMGMT_WPA_PSK },
{ "wpa-eap", GSUPPLICANT_KEYMGMT_WPA_EAP },
{ "wpa-none", GSUPPLICANT_KEYMGMT_WPA_NONE }
};
wpa->keymgmt = gsupplicant_parse_bits_array(0, name, value,
keymgmt_map, G_N_ELEMENTS(keymgmt_map));
wpa->keymgmt = gsupplicant_parse_keymgmt_list(name, value);
} else if (!g_strcmp0(name, "Pairwise")) {
static const GSupNameIntPair pairwise_map [] = {
{ "ccmp", GSUPPLICANT_CIPHER_CCMP },
Expand Down
18 changes: 3 additions & 15 deletions src/gsupplicant_interface.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2015-2021 Jolla Ltd.
* Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2015-2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
Expand Down Expand Up @@ -36,6 +36,7 @@
#include "gsupplicant_network.h"
#include "gsupplicant_bss.h"
#include "gsupplicant.h"
#include "gsupplicant_p.h"
#include "gsupplicant_util_p.h"
#include "gsupplicant_dbus.h"
#include "gsupplicant_log.h"
Expand Down Expand Up @@ -1477,20 +1478,7 @@ gsupplicant_interface_parse_cap(
caps->group = gsupplicant_parse_bits_array(0, name, value,
group_map, G_N_ELEMENTS(group_map));
} else if (!g_strcmp0(name, "KeyMgmt")) {
static const GSupNameIntPair keymgmt_map [] = {
{ "wpa-psk", GSUPPLICANT_KEYMGMT_WPA_PSK },
{ "wpa-ft-psk", GSUPPLICANT_KEYMGMT_WPA_FT_PSK },
{ "wpa-psk-sha256", GSUPPLICANT_KEYMGMT_WPA_PSK_SHA256 },
{ "wpa-eap", GSUPPLICANT_KEYMGMT_WPA_EAP },
{ "wpa-ft-eap", GSUPPLICANT_KEYMGMT_WPA_FT_EAP },
{ "wpa-eap-sha256", GSUPPLICANT_KEYMGMT_WPA_EAP_SHA256 },
{ "ieee8021x", GSUPPLICANT_KEYMGMT_IEEE8021X },
{ "wpa-none", GSUPPLICANT_KEYMGMT_WPA_NONE },
{ "wps", GSUPPLICANT_KEYMGMT_WPS },
{ "none", GSUPPLICANT_KEYMGMT_NONE }
};
caps->keymgmt = gsupplicant_parse_bits_array(0, name, value,
keymgmt_map, G_N_ELEMENTS(keymgmt_map));
caps->keymgmt = gsupplicant_parse_keymgmt_list(name, value);
} else if (!g_strcmp0(name, "Protocol")) {
static const GSupNameIntPair protocol_map [] = {
{ "rsn", GSUPPLICANT_PROTOCOL_RSN },
Expand Down
51 changes: 51 additions & 0 deletions src/gsupplicant_p.h
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef GSUPPLICANT_PRIVATE_H
#define GSUPPLICANT_PRIVATE_H

#include "gsupplicant_types_p.h"

GSUPPLICANT_KEYMGMT
gsupplicant_parse_keymgmt_list(
const char* name,
GVariant* value)
GSUPPLICANT_INTERNAL;

#endif /* GSUPPLICANT_PRIVATE_H */

/*
* Local Variables:
* mode: C
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

0 comments on commit 60957be

Please sign in to comment.