Re: AD-Hoc network specify channel
- From: Jirka Klimes <jklimes redhat com>
- To: networkmanager-list gnome org
- Subject: Re: AD-Hoc network specify channel
- Date: Thu, 6 May 2010 10:49:29 +0200
On Wednesday 14 of April 2010 22:42:52 Dan Williams wrote:
> On Tue, 2010-04-13 at 21:36 +0200, Simon Schampijer wrote:
> > Hi,
> >
> > I am trying to create an Ad-Hoc Network with a specific channel. From
> > the spec [1] I know that I have to set the band as well. However the
> > created network always has channel 1. The nm-applet does not have an
> > option to set the channel, and is using channel one, too.
> >
> > Using iwconfig to create an Ad-Hoc network I can set a channel fine. Is
> > it fully implemented or do I miss something else?
>
> It should be, though it's likely not possible if you're using
> nm-connection-editor since the channel/band aren't accessible there.
> But looking at it now, they *should* be accessible for ad-hoc
> connections. So we'll need to whip up some code for page-wifi.c to
> hide/show them when ad-hoc is selected.
>
> (this is because wpa_supplicant only has the ability to set the channel
> for ad-hoc networks, not a limitation in NM. wpa_supplicant does not
> have the ability to set a band limitation for infrastructure networks,
> which means we can't let users limit particular connection to only
> 802.11a for example)
>
> See nm_supplicant_config_add_setting_wireless() in NM for where the
> frequency gets sent to the supplicant, and build_supplicant_config() for
> where the channel/band get translated into a frequency.
>
> Also check nm_ap_new_fake_from_connection() to ensure that the frequency
> is getting correctly set on the fake AP.
>
> This all should work as long as the connection dict has the band/freq
> specified.
>
> Dan
>
>
Patch for nm-connection-editor to shoe band&channel for Ad-Hoc connections.
It also corrects spin button behaviour.
Jirka
diff --git a/src/connection-editor/page-wireless.c b/src/connection-editor/page-wireless.c
index 078108c..0977ec0 100644
--- a/src/connection-editor/page-wireless.c
+++ b/src/connection-editor/page-wireless.c
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2008 Red Hat, Inc.
+ * (C) Copyright 2008 - 2010 Red Hat, Inc.
*/
#include <string.h>
@@ -126,7 +126,7 @@ channel_spin_input_cb (GtkSpinButton *spin, gdouble *new_val, gpointer user_data
return GTK_INPUT_ERROR;
*new_val = channel;
- return TRUE;
+ return 1;
}
static gint
@@ -147,23 +147,30 @@ channel_spin_output_cb (GtkSpinButton *spin, gpointer user_data)
if (channel == 0)
buf = g_strdup (_("default"));
else {
+ int direction = 0;
freq = utils_channel_to_freq (channel, aband ? "a" : "bg");
if (freq == -1) {
- int direction = 0;
-
if (priv->last_channel < channel)
direction = 1;
else if (priv->last_channel > channel)
direction = -1;
channel = utils_find_next_channel (channel, direction, aband ? "a" : "bg");
+ gtk_spin_button_set_value (spin, channel);
freq = utils_channel_to_freq (channel, aband ? "a" : "bg");
if (freq == -1) {
g_warning ("%s: invalid channel %d!", __func__, channel);
gtk_spin_button_set_value (spin, 0);
goto out;
}
+
}
- buf = g_strdup_printf (_("%u (%u MHz)"), channel, freq);
+ /* Set spin button to zero to go to "default" from the lowest channel */
+ if (direction == -1 && priv->last_channel == channel) {
+ buf = g_strdup_printf (_("default"));
+ gtk_spin_button_set_value (spin, 0);
+ channel = 0;
+ } else
+ buf = g_strdup_printf (_("%u (%u MHz)"), channel, freq);
}
priv->last_channel = channel;
}
@@ -173,7 +180,7 @@ channel_spin_output_cb (GtkSpinButton *spin, gpointer user_data)
out:
g_free (buf);
- return TRUE;
+ return 1;
}
static void
@@ -202,6 +209,44 @@ band_value_changed_cb (GtkComboBox *box, gpointer user_data)
}
static void
+mode_combo_changed_cb (GtkComboBox *combo,
+ gpointer user_data)
+{
+ CEPageWireless *self = CE_PAGE_WIRELESS (user_data);
+ CEPageWirelessPrivate *priv = CE_PAGE_WIRELESS_GET_PRIVATE (self);
+ CEPage *parent = CE_PAGE (self);
+ GtkWidget *widget;
+ gboolean show;
+
+ switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combo))) {
+ case 1: /* adhoc */
+ show = TRUE;
+ break;
+ default: /* infrastructure */
+ show = FALSE;
+ break;
+ }
+
+ if (show) {
+ widget = glade_xml_get_widget (parent->xml, "wireless_band_label");
+ gtk_widget_show (widget);
+ gtk_widget_show (GTK_WIDGET (priv->band));
+ widget = glade_xml_get_widget (parent->xml, "wireless_channel_label");
+ gtk_widget_show (widget);
+ gtk_widget_show (GTK_WIDGET (priv->channel));
+ } else {
+ widget = glade_xml_get_widget (parent->xml, "wireless_band_label");
+ gtk_widget_hide (widget);
+ gtk_widget_hide (GTK_WIDGET (priv->band));
+ widget = glade_xml_get_widget (parent->xml, "wireless_channel_label");
+ gtk_widget_hide (widget);
+ gtk_widget_hide (GTK_WIDGET (priv->channel));
+ }
+
+ ce_page_changed (CE_PAGE (self));
+}
+
+static void
populate_ui (CEPageWireless *self)
{
CEPageWirelessPrivate *priv = CE_PAGE_WIRELESS_GET_PRIVATE (self);
@@ -251,7 +296,8 @@ populate_ui (CEPageWireless *self)
gtk_combo_box_set_active (priv->mode, 0);
if (mode && !strcmp (mode, "adhoc"))
gtk_combo_box_set_active (priv->mode, 1);
- g_signal_connect_swapped (priv->mode, "changed", G_CALLBACK (ce_page_changed), self);
+ mode_combo_changed_cb (priv->mode, self);
+ g_signal_connect (priv->mode, "changed", G_CALLBACK (mode_combo_changed_cb), self);
g_signal_connect (priv->channel, "output",
G_CALLBACK (channel_spin_output_cb),
@@ -306,17 +352,6 @@ finish_setup (CEPageWireless *self, gpointer unused, GError *error, gpointer use
populate_ui (self);
- /* Hide widgets we don't yet support */
- widget = glade_xml_get_widget (parent->xml, "wireless_band_label");
- gtk_widget_hide (widget);
- widget = glade_xml_get_widget (parent->xml, "wireless_band");
- gtk_widget_hide (widget);
-
- widget = glade_xml_get_widget (parent->xml, "wireless_channel_label");
- gtk_widget_hide (widget);
- widget = glade_xml_get_widget (parent->xml, "wireless_channel");
- gtk_widget_hide (widget);
-
widget = glade_xml_get_widget (parent->xml, "wireless_tx_power_label");
gtk_widget_hide (widget);
widget = glade_xml_get_widget (parent->xml, "wireless_tx_power_hbox");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]