aboutsummaryrefslogtreecommitdiffstats
path: root/packages/networkmanager/files/avoid_frequent_scan.patch
diff options
context:
space:
mode:
Diffstat (limited to 'packages/networkmanager/files/avoid_frequent_scan.patch')
-rw-r--r--packages/networkmanager/files/avoid_frequent_scan.patch226
1 files changed, 226 insertions, 0 deletions
diff --git a/packages/networkmanager/files/avoid_frequent_scan.patch b/packages/networkmanager/files/avoid_frequent_scan.patch
new file mode 100644
index 0000000000..43f84f7674
--- /dev/null
+++ b/packages/networkmanager/files/avoid_frequent_scan.patch
@@ -0,0 +1,226 @@
+Index: NetworkManager-0.6.6/src/nm-device-802-11-wireless.c
+===================================================================
+--- NetworkManager-0.6.6.orig/src/nm-device-802-11-wireless.c 2008-09-05 15:01:32.000000000 -0300
++++ NetworkManager-0.6.6/src/nm-device-802-11-wireless.c 2008-09-08 11:37:23.000000000 -0300
+@@ -624,9 +624,12 @@
+ NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
+ GSource * source;
+ guint source_id;
++ NMData * app_data;
++
++ app_data = nm_device_get_app_data (NM_DEVICE (self));
+
+ /* Start the scanning timeout for devices that can do scanning */
+- if (nm_device_get_capabilities (dev) & NM_DEVICE_CAP_WIRELESS_SCAN) {
++ if (!app_data->no_scan && nm_device_get_capabilities (dev) & NM_DEVICE_CAP_WIRELESS_SCAN) {
+ /* Stupid orinoco has problems scanning immediately after being up,
+ * so wait a bit before triggering a scan.
+ */
+@@ -1063,9 +1066,14 @@
+ NMWirelessScanInterval interval)
+ {
+ guint8 seconds = nm_wireless_scan_interval_to_seconds (interval);
++ NMData *app_data;
+
+ g_return_if_fail (self != NULL);
+
++ app_data = nm_device_get_app_data (NM_DEVICE (self));
++ if (app_data->no_scan)
++ return;
++
+ self->priv->scan_interval = seconds;
+
+ if (interval == NM_WIRELESS_SCAN_INTERVAL_ACTIVE && !self->priv->scanning) {
+@@ -1974,9 +1982,13 @@
+ scan_results_timeout (NMDevice80211Wireless *self)
+ {
+ GTimeVal cur_time;
++ NMData * app_data;
+
+ g_return_val_if_fail (self != NULL, FALSE);
+
++ app_data = nm_device_get_app_data (NM_DEVICE (self));
++ g_assert (app_data);
++
+ request_and_convert_scan_results (self);
+
+ self->priv->scanning = FALSE;
+@@ -1984,11 +1996,39 @@
+ g_get_current_time (&cur_time);
+ self->priv->last_scan = cur_time.tv_sec;
+
+- /* After the first successful scan back down to the ACTIVE scan interval */
+- if (self->priv->scan_interval == nm_wireless_scan_interval_to_seconds (NM_WIRELESS_SCAN_INTERVAL_INIT))
+- nm_device_802_11_wireless_set_scan_interval (self, NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
+- else
+- schedule_scan (self, 0);
++ if (!app_data->no_scan)
++ {
++ /* After the first successful scan back down to the ACTIVE scan interval */
++ if (self->priv->scan_interval == nm_wireless_scan_interval_to_seconds (NM_WIRELESS_SCAN_INTERVAL_INIT))
++ nm_device_802_11_wireless_set_scan_interval (self, NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
++ else
++ schedule_scan (self, 0);
++ }
++ else
++ {
++ /* If we're in "no scan" mode, lets always signalize that we've performed a scan */
++ DBusMessage *message;
++ char *dev_path = NULL;
++
++ if (!(dev_path = nm_dbus_get_object_path_for_device (NM_DEVICE (self))))
++ goto out;
++
++ if (!(message = dbus_message_new_signal (NM_DBUS_PATH, NM_DBUS_INTERFACE, "ScanPerformed")))
++ {
++ nm_warning ("scan_results_timeout(): Not enough memory for new dbus message!");
++ goto out;
++ }
++
++ dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID);
++
++ if (!dbus_connection_send (app_data->dbus_connection, message, NULL))
++ nm_warning ("scan_results_timeout(): Could not raise the ScanPerformed signal!");
++
++ dbus_message_unref (message);
++
++out:
++ g_free (dev_path);
++ }
+
+ return FALSE;
+ }
+@@ -2134,7 +2174,7 @@
+ }
+ schedule_scan_results_timeout (self, 10);
+ }
+- return FALSE;
++ return TRUE;
+
+ reschedule:
+ schedule_scan (self, 0);
+@@ -2156,6 +2196,13 @@
+ }
+
+
++gboolean
++nm_device_802_11_wireless_perform_scan (NMDevice80211Wireless *self)
++{
++ return nm_device_802_11_wireless_scan ((gpointer) self);
++}
++
++
+ /*
+ * schedule_scan
+ *
+Index: NetworkManager-0.6.6/src/NetworkManager.c
+===================================================================
+--- NetworkManager-0.6.6.orig/src/NetworkManager.c 2008-03-06 17:14:39.000000000 -0300
++++ NetworkManager-0.6.6/src/NetworkManager.c 2008-09-05 15:01:32.000000000 -0300
+@@ -929,6 +929,7 @@
+ gboolean become_daemon = FALSE;
+ gboolean enable_test_devices = FALSE;
+ gboolean show_usage = FALSE;
++ gboolean no_scan = FALSE;
+ char * owner;
+ char * pidfile = NULL;
+ char * user_pidfile = NULL;
+@@ -951,6 +952,7 @@
+ {"pid-file", 0, 0, G_OPTION_ARG_STRING, &user_pidfile, "Specify the location of a PID file", NULL},
+ {"enable-test-devices", 0, 0, G_OPTION_ARG_NONE, &enable_test_devices, "Allow dummy devices to be created via DBUS methods [DEBUG]", NULL},
+ {"info", 0, 0, G_OPTION_ARG_NONE, &show_usage, "Show application information", NULL},
++ {"no-scan", 0, 0, G_OPTION_ARG_NONE, &no_scan, "Prevent background scan", NULL},
+ {NULL}
+ };
+ opt_ctx = g_option_context_new("");
+@@ -1009,6 +1011,8 @@
+ exit (EXIT_FAILURE);
+ }
+
++ nm_data->no_scan = no_scan;
++
+ /* Create our dbus service */
+ nm_data->dbus_connection = nm_dbus_init (nm_data);
+ if (!nm_data->dbus_connection)
+Index: NetworkManager-0.6.6/src/NetworkManagerMain.h
+===================================================================
+--- NetworkManager-0.6.6.orig/src/NetworkManagerMain.h 2008-03-06 17:14:39.000000000 -0300
++++ NetworkManager-0.6.6/src/NetworkManagerMain.h 2008-09-05 15:01:32.000000000 -0300
+@@ -87,6 +87,7 @@
+ gboolean modem_active;
+ gboolean asleep;
+ gboolean disconnected;
++ gboolean no_scan;
+
+ GSList * dialup_list;
+ GMutex * dialup_list_mutex;
+Index: NetworkManager-0.6.6/src/nm-dbus-device.c
+===================================================================
+--- NetworkManager-0.6.6.orig/src/nm-dbus-device.c 2008-03-06 17:14:39.000000000 -0300
++++ NetworkManager-0.6.6/src/nm-dbus-device.c 2008-09-08 15:12:43.000000000 -0300
+@@ -500,6 +500,44 @@
+ }
+
+
++static DBusMessage *nm_dbus_device_perform_scan (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
++{
++ NMDevice *dev;
++ DBusMessage *reply = NULL;
++ NMData * app_data;
++
++ g_return_val_if_fail (data && data->data && data->dev && connection && message, NULL);
++
++ dev = data->dev;
++
++ app_data = nm_device_get_app_data (NM_DEVICE (dev));
++ if (!app_data->no_scan)
++ {
++ nm_warning ("You cannot ask for a scan if you're not in 'No scan' mode");
++ reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "Cannot perform scan", "You cannot ask for a scan if you're not in 'No scan' mode");
++ goto out;
++ }
++
++ if (!nm_device_is_802_11_wireless (dev))
++ {
++ reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "DeviceNotWireless",
++ "Wired devices cannot scan for wireless networks.");
++ goto out;
++ }
++
++ if (nm_device_802_11_wireless_perform_scan ((NMDevice80211Wireless *) dev))
++ reply = dbus_message_new_method_return (message); /* Success */
++ else
++ reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "Cannot perform scan", "The device cannot perform network scanning.");
++
++out:
++ if (!reply)
++ nm_warning ("Could not allocate dbus message.");
++
++ return reply;
++}
++
++
+ /*
+ * nm_dbus_device_methods_setup
+ *
+@@ -523,6 +561,7 @@
+ nm_dbus_method_list_add_method (list, "setLinkActive", nm_dbus_device_set_link_active);
+ nm_dbus_method_list_add_method (list, "getCapabilities", nm_dbus_device_get_capabilities);
+ nm_dbus_method_list_add_method (list, "getDriver", nm_dbus_device_get_driver);
++ nm_dbus_method_list_add_method (list, "performScan", nm_dbus_device_perform_scan);
+
+ return (list);
+ }
+Index: NetworkManager-0.6.6/src/nm-device-802-11-wireless.h
+===================================================================
+--- NetworkManager-0.6.6.orig/src/nm-device-802-11-wireless.h 2008-03-06 17:14:39.000000000 -0300
++++ NetworkManager-0.6.6/src/nm-device-802-11-wireless.h 2008-09-05 15:01:32.000000000 -0300
+@@ -110,6 +110,8 @@
+
+ gint8 nm_device_802_11_wireless_get_signal_strength (NMDevice80211Wireless *self);
+
++gboolean nm_device_802_11_wireless_perform_scan (NMDevice80211Wireless *self);
++
+
+ G_END_DECLS
+