mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-01 15:20:11 +01:00
cli: show warning when setting band/channel for infra mode (rh #1000096)
The band/channel property is not considered when connecting to an access point. Print a warning, when setting one of these values in edit mode. For now, don't forbid the user to make such setting. Also, because in the future, wpa_supplicant might support this. https://bugzilla.redhat.com/show_bug.cgi?id=999997 https://bugzilla.redhat.com/show_bug.cgi?id=1000096 Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
2ca7c89298
commit
c52decbfcb
3 changed files with 60 additions and 4 deletions
|
|
@ -7570,14 +7570,19 @@ editor_init_new_connection (NmCli *nmc, NMConnection *connection)
|
|||
NM_SETTING_GSM_NUMBER, "*99#",
|
||||
NULL);
|
||||
|
||||
/* For Wi-Fi set mode to "infrastructure". Even though mode == NULL
|
||||
* is regarded as "infrastructure", explicit value makes no doubts.
|
||||
*/
|
||||
if (g_strcmp0 (con_type, NM_SETTING_WIRELESS_SETTING_NAME) == 0)
|
||||
/* Wi-Fi */
|
||||
if (g_strcmp0 (con_type, NM_SETTING_WIRELESS_SETTING_NAME) == 0) {
|
||||
/* For Wi-Fi set mode to "infrastructure". Even though mode == NULL
|
||||
* is regarded as "infrastructure", explicit value makes no doubts.
|
||||
*/
|
||||
g_object_set (NM_SETTING_WIRELESS (base_setting),
|
||||
NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA,
|
||||
NULL);
|
||||
|
||||
/* Do custom initialization for wifi setting */
|
||||
nmc_setting_custom_init (base_setting);
|
||||
}
|
||||
|
||||
/* Always add IPv4 and IPv6 settings for non-slave connections */
|
||||
setting = nm_setting_ip4_config_new ();
|
||||
nmc_setting_custom_init (setting);
|
||||
|
|
@ -7594,14 +7599,18 @@ editor_init_existing_connection (NMConnection *connection)
|
|||
{
|
||||
NMSettingIP4Config *s_ip4;
|
||||
NMSettingIP6Config *s_ip6;
|
||||
NMSettingWireless *s_wireless;
|
||||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||
s_wireless = nm_connection_get_setting_wireless (connection);
|
||||
|
||||
if (s_ip4)
|
||||
nmc_setting_ip4_connect_handlers (s_ip4);
|
||||
if (s_ip6)
|
||||
nmc_setting_ip6_connect_handlers (s_ip6);
|
||||
if (s_wireless)
|
||||
nmc_setting_wireless_connect_handlers (s_wireless);
|
||||
}
|
||||
|
||||
static NMCResultCode
|
||||
|
|
|
|||
|
|
@ -1751,6 +1751,36 @@ ipv6_method_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
|
|||
g_signal_handlers_unblock_by_func (object, G_CALLBACK (ipv6_addresses_changed_cb), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
wireless_band_channel_changed_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
|
||||
{
|
||||
const char *value = NULL, *mode;
|
||||
char str[16];
|
||||
NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (object);
|
||||
|
||||
if (strcmp (g_param_spec_get_name (pspec), NM_SETTING_WIRELESS_BAND) == 0) {
|
||||
value = nm_setting_wireless_get_band (s_wireless);
|
||||
if (!value)
|
||||
return;
|
||||
} else {
|
||||
guint32 channel = nm_setting_wireless_get_channel (s_wireless);
|
||||
|
||||
if (channel == 0)
|
||||
return;
|
||||
|
||||
snprintf (str, sizeof (str), "%d", nm_setting_wireless_get_channel (s_wireless));
|
||||
str[sizeof (str)-1] = 0;
|
||||
value = str;
|
||||
}
|
||||
|
||||
mode = nm_setting_wireless_get_mode (NM_SETTING_WIRELESS (object));
|
||||
if (!mode || !*mode || strcmp (mode, NM_SETTING_WIRELESS_MODE_INFRA) == 0) {
|
||||
printf (_("Warning: %s.%s set to '%s', but it might be ignored in infrastructure mode\n"),
|
||||
nm_setting_get_name (NM_SETTING (s_wireless)), g_param_spec_get_name (pspec),
|
||||
value);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nmc_setting_ip4_connect_handlers (NMSettingIP4Config *setting)
|
||||
{
|
||||
|
|
@ -1773,6 +1803,17 @@ nmc_setting_ip6_connect_handlers (NMSettingIP6Config *setting)
|
|||
G_CALLBACK (ipv6_method_changed_cb), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
nmc_setting_wireless_connect_handlers (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_if_fail (NM_IS_SETTING_WIRELESS (setting));
|
||||
|
||||
g_signal_connect (setting, "notify::" NM_SETTING_WIRELESS_BAND,
|
||||
G_CALLBACK (wireless_band_channel_changed_cb), NULL);
|
||||
g_signal_connect (setting, "notify::" NM_SETTING_WIRELESS_CHANNEL,
|
||||
G_CALLBACK (wireless_band_channel_changed_cb), NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Customize some properties of the setting so that the setting has sensible
|
||||
* values.
|
||||
|
|
@ -1792,6 +1833,11 @@ nmc_setting_custom_init (NMSetting *setting)
|
|||
NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
||||
NULL);
|
||||
nmc_setting_ip6_connect_handlers (NM_SETTING_IP6_CONFIG (setting));
|
||||
} else if (NM_IS_SETTING_WIRELESS (setting)) {
|
||||
g_object_set (NM_SETTING_WIRELESS (setting),
|
||||
NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA,
|
||||
NULL);
|
||||
nmc_setting_wireless_connect_handlers (NM_SETTING_WIRELESS (setting));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ NMSetting *nmc_setting_new_for_name (const char *name);
|
|||
void nmc_setting_custom_init (NMSetting *setting);
|
||||
void nmc_setting_ip4_connect_handlers (NMSettingIP4Config *setting);
|
||||
void nmc_setting_ip6_connect_handlers (NMSettingIP6Config *setting);
|
||||
void nmc_setting_wireless_connect_handlers (NMSettingWireless *setting);
|
||||
|
||||
char **nmc_setting_get_valid_properties (NMSetting *setting);
|
||||
char *nmc_setting_get_property_desc (NMSetting *setting, const char *prop);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue