Parcourir la source

D-Bus: Add a dbus handler for expected disconnection

Add a global D-Bus handler ExpectDisconnect for setting
wpa_s->own_disconnect_req flag. This flag will prevent wpa_supplicant
from adding blacklists and requesting incomplete scan upon the incoming
disconnection. This is mainly meant for a case where suspend/resume is
used and some external component knows about that and can provide the
information to wpa_supplicant before the disconnection happens.

Signed-off-by: Ningyuan Wang <nywang@google.com>
Ningyuan Wang il y a 9 ans
Parent
commit
c143c3b72a

+ 5 - 0
doc/dbus.doxygen

@@ -97,6 +97,11 @@ registered in the bus with fi.w1.wpa_supplicant1 name.
 	  <dd>Getting an interface object path failed for an unknown reason.</dd>
 	</dl>
       </li>
+
+      <li>
+	<h3>ExpectDisconnect ( ) --> nothing</h3>
+	<p>Notify wpa_supplicant of an externally triggered disconnection, e.g., due to system suspend.</p>
+      </li>
     </ul>
 
 \subsection dbus_main_properties Properties

+ 6 - 0
wpa_supplicant/dbus/dbus_new.c

@@ -2172,6 +2172,12 @@ static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
 		  END_ARGS
 	  }
 	},
+	{ "ExpectDisconnect", WPAS_DBUS_NEW_INTERFACE,
+	  (WPADBusMethodHandler) wpas_dbus_handler_expect_disconnect,
+	  {
+		END_ARGS
+	  }
+	},
 	{ NULL, NULL, NULL, { END_ARGS } }
 };
 

+ 21 - 0
wpa_supplicant/dbus/dbus_new_handlers.c

@@ -1579,6 +1579,27 @@ DBusMessage * wpas_dbus_handler_reassociate(DBusMessage *message,
 }
 
 
+/**
+ * wpas_dbus_handler_expect_disconnect - ExpectDisconnect
+ * @message: Pointer to incoming dbus message
+ * @global: %wpa_supplicant global data structure
+ * Returns: NULL
+ *
+ * Handler function for notifying system there will be a expected disconnect.
+ * This will prevent wpa_supplicant from adding blacklists upon next disconnect..
+ */
+DBusMessage * wpas_dbus_handler_expect_disconnect(DBusMessage *message,
+						  struct wpa_global *global)
+{
+	struct wpa_supplicant *wpa_s = global->ifaces;
+
+	for (; wpa_s; wpa_s = wpa_s->next)
+		if (wpa_s->wpa_state >= WPA_ASSOCIATED)
+			wpa_s->own_disconnect_req = 1;
+	return NULL;
+}
+
+
 /**
  * wpas_dbus_handler_reattach - Reattach to current AP
  * @message: Pointer to incoming dbus message

+ 3 - 0
wpa_supplicant/dbus/dbus_new_handlers.h

@@ -50,6 +50,9 @@ DBusMessage * wpas_dbus_handler_remove_interface(DBusMessage *message,
 DBusMessage * wpas_dbus_handler_get_interface(DBusMessage *message,
 					      struct wpa_global *global);
 
+DBusMessage * wpas_dbus_handler_expect_disconnect(DBusMessage *message,
+						  struct wpa_global *global);
+
 dbus_bool_t wpas_dbus_getter_debug_level(DBusMessageIter *iter,
 					 DBusError *error,
 					 void *user_data);