mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-10 09:20:20 +01:00
wifi/utils: complete band and channel for mesh
To allow completion for mesh connections channel and band need to be set. This is only done if both values are absent. It does not check existing values against a given ap_freq. This maybe changed to throw an error and detect a possible conflict. Any other check is left to verify step of connection. This change allows to use ap freq during complete. For tests 0 is passed as frequency for now. This needs to be changed if completion of freq should be tested. [lkundrak@v3.sk, thaller@redhat.com: formatting fixes]
This commit is contained in:
parent
4dc375a068
commit
77b13c68de
4 changed files with 57 additions and 0 deletions
|
|
@ -1123,6 +1123,7 @@ nm_wifi_ap_complete_connection (NMWifiAP *self,
|
|||
return nm_wifi_utils_complete_connection (priv->ssid,
|
||||
priv->address,
|
||||
priv->mode,
|
||||
priv->freq,
|
||||
priv->flags,
|
||||
priv->wpa_flags,
|
||||
priv->rsn_flags,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "nm-utils.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
static gboolean
|
||||
verify_no_wep (NMSettingWirelessSecurity *s_wsec, const char *tag, GError **error)
|
||||
|
|
@ -526,6 +527,7 @@ gboolean
|
|||
nm_wifi_utils_complete_connection (GBytes *ap_ssid,
|
||||
const char *bssid,
|
||||
NM80211Mode ap_mode,
|
||||
guint32 ap_freq,
|
||||
guint32 ap_flags,
|
||||
guint32 ap_wpa_flags,
|
||||
guint32 ap_rsn_flags,
|
||||
|
|
@ -539,6 +541,7 @@ nm_wifi_utils_complete_connection (GBytes *ap_ssid,
|
|||
GBytes *ssid;
|
||||
const char *mode, *key_mgmt, *auth_alg, *leap_username;
|
||||
gboolean adhoc = FALSE;
|
||||
gboolean mesh = FALSE;
|
||||
|
||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||
g_assert (s_wifi);
|
||||
|
|
@ -575,6 +578,10 @@ nm_wifi_utils_complete_connection (GBytes *ap_ssid,
|
|||
if (ap_mode == NM_802_11_MODE_ADHOC)
|
||||
valid = TRUE;
|
||||
adhoc = TRUE;
|
||||
} else if (!strcmp (mode, NM_SETTING_WIRELESS_MODE_MESH)) {
|
||||
if (ap_mode == NM_802_11_MODE_MESH)
|
||||
valid = TRUE;
|
||||
mesh = TRUE;
|
||||
}
|
||||
|
||||
if (valid == FALSE) {
|
||||
|
|
@ -590,10 +597,57 @@ nm_wifi_utils_complete_connection (GBytes *ap_ssid,
|
|||
if (ap_mode == NM_802_11_MODE_ADHOC) {
|
||||
mode = NM_SETTING_WIRELESS_MODE_ADHOC;
|
||||
adhoc = TRUE;
|
||||
} else if (ap_mode == NM_802_11_MODE_MESH) {
|
||||
mode = NM_SETTING_WIRELESS_MODE_MESH;
|
||||
mesh = TRUE;
|
||||
}
|
||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_MODE, mode, NULL);
|
||||
}
|
||||
|
||||
/* For now mesh requires channel and band, fill them only if both not present.
|
||||
* Do not check existing values against an existing ap/mesh point,
|
||||
* mesh join will start a new network if required */
|
||||
if (mesh) {
|
||||
const char *band;
|
||||
guint32 channel;
|
||||
gboolean band_valid = TRUE;
|
||||
gboolean chan_valid = TRUE;
|
||||
gboolean valid;
|
||||
|
||||
band = nm_setting_wireless_get_band (s_wifi);
|
||||
channel = nm_setting_wireless_get_channel (s_wifi);
|
||||
|
||||
valid = ((band == NULL) && (channel == 0))
|
||||
|| ((band != NULL) && (channel != 0));
|
||||
|
||||
if ((band == NULL) && (channel == 0)) {
|
||||
channel = nm_utils_wifi_freq_to_channel (ap_freq);
|
||||
if (channel) {
|
||||
g_object_set (s_wifi,
|
||||
NM_SETTING_WIRELESS_CHANNEL, channel,
|
||||
NULL);
|
||||
} else {
|
||||
chan_valid = FALSE;
|
||||
}
|
||||
|
||||
band = nm_utils_wifi_freq_to_band (ap_freq);
|
||||
if (band) {
|
||||
g_object_set (s_wifi, NM_SETTING_WIRELESS_BAND, band, NULL);
|
||||
} else {
|
||||
band_valid = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid || !chan_valid || !band_valid) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("connection does not match mesh point"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MODE);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Security */
|
||||
|
||||
/* Open */
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ typedef enum {
|
|||
gboolean nm_wifi_utils_complete_connection (GBytes *ssid,
|
||||
const char *bssid,
|
||||
NM80211Mode mode,
|
||||
guint32 ap_freq,
|
||||
guint32 flags,
|
||||
guint32 wpa_flags,
|
||||
guint32 rsn_flags,
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ complete_connection (const char *ssid,
|
|||
return nm_wifi_utils_complete_connection (ssid_b,
|
||||
bssid,
|
||||
mode,
|
||||
0,
|
||||
flags,
|
||||
wpa_flags,
|
||||
rsn_flags,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue