diff options
author | Thomas Haller <thaller@redhat.com> | 2014-02-13 12:20:52 +0100 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2014-02-13 12:22:52 +0100 |
commit | c52decbfcb14dbf3fb2357742fb0df3c12486aa7 (patch) | |
tree | e11ec700fc5865379733da2e9511b9a96e92f5b4 | |
parent | 2ca7c892988bfc5f0ac68d69a03faf13256872bb (diff) | |
download | NetworkManager-c52decbfcb14dbf3fb2357742fb0df3c12486aa7.tar.gz |
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>
-rw-r--r-- | cli/src/connections.c | 17 | ||||
-rw-r--r-- | cli/src/settings.c | 46 | ||||
-rw-r--r-- | cli/src/settings.h | 1 |
3 files changed, 60 insertions, 4 deletions
diff --git a/cli/src/connections.c b/cli/src/connections.c index ba448855a3..0ab43bdf39 100644 --- a/cli/src/connections.c +++ b/cli/src/connections.c @@ -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 diff --git a/cli/src/settings.c b/cli/src/settings.c index c756dcd4e2..c8670b0729 100644 --- a/cli/src/settings.c +++ b/cli/src/settings.c @@ -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)); } } diff --git a/cli/src/settings.h b/cli/src/settings.h index e60cabdf0f..709c8977fa 100644 --- a/cli/src/settings.h +++ b/cli/src/settings.h @@ -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); |