void nm_supplicant_manager_iface_release (NMSupplicantManager *self, NMSupplicantInterface *iface) { NMSupplicantManagerPrivate *priv; const char *ifname, *op; g_return_if_fail (NM_IS_SUPPLICANT_MANAGER (self)); g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (iface)); ifname = nm_supplicant_interface_get_ifname (iface); g_assert (ifname); priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); g_return_if_fail (g_hash_table_lookup (priv->ifaces, ifname) == iface); /* Ask wpa_supplicant to remove this interface */ op = nm_supplicant_interface_get_object_path (iface); if (priv->running && priv->proxy && op) { g_dbus_proxy_call (priv->proxy, "RemoveInterface", g_variant_new ("(o)", op), G_DBUS_CALL_FLAGS_NONE, 3000, NULL, NULL, NULL); } g_hash_table_remove (priv->ifaces, ifname); }
void nm_supplicant_manager_iface_release (NMSupplicantManager *self, NMSupplicantInterface *iface) { NMSupplicantManagerPrivate *priv; const char *ifname, *op; g_return_if_fail (NM_IS_SUPPLICANT_MANAGER (self)); g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (iface)); ifname = nm_supplicant_interface_get_ifname (iface); g_assert (ifname); priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); g_return_if_fail (g_hash_table_lookup (priv->ifaces, ifname) == iface); /* Ask wpa_supplicant to remove this interface */ op = nm_supplicant_interface_get_object_path (iface); if (priv->running && priv->proxy && op) { dbus_g_proxy_call_no_reply (priv->proxy, "RemoveInterface", DBUS_TYPE_G_OBJECT_PATH, op, G_TYPE_INVALID); } g_hash_table_remove (priv->ifaces, ifname); }
/** * nm_supplicant_manager_create_interface: * @self: the #NMSupplicantManager * @ifname: the interface for which to obtain the supplicant interface * @is_wireless: whether the interface is supposed to be wireless. * * Note: the manager owns a reference to the instance and the only way to * get the manager to release it, is by dropping all other references * to the supplicant-interface (or destroying the manager). * * Retruns: (transfer-full): returns a #NMSupplicantInterface or %NULL. * Must be unrefed at the end. * */ NMSupplicantInterface * nm_supplicant_manager_create_interface (NMSupplicantManager *self, const char *ifname, gboolean is_wireless) { NMSupplicantManagerPrivate *priv; NMSupplicantInterface *iface; GSList *ifaces; g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), NULL); g_return_val_if_fail (ifname != NULL, NULL); priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); nm_log_dbg (LOGD_SUPPLICANT, "(%s): creating new supplicant interface", ifname); /* assert against not requesting duplicate interfaces. */ for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) { if (g_strcmp0 (nm_supplicant_interface_get_ifname (ifaces->data), ifname) == 0) g_return_val_if_reached (NULL); } iface = nm_supplicant_interface_new (ifname, is_wireless, priv->fast_supported, priv->ap_support); priv->ifaces = g_slist_prepend (priv->ifaces, iface); g_object_add_toggle_ref ((GObject *) iface, _sup_iface_last_ref, self); /* If we're making the supplicant take a time out for a bit, don't * let the supplicant interface start immediately, just let it hang * around in INIT state until we're ready to talk to the supplicant * again. */ if (is_available (self)) nm_supplicant_interface_set_supplicant_available (iface, TRUE); return iface; }
NMSupplicantInterface * nm_supplicant_manager_iface_get (NMSupplicantManager * self, const char *ifname, gboolean is_wireless) { NMSupplicantManagerPrivate *priv; NMSupplicantInterface *iface = NULL; gboolean start_now; g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), NULL); g_return_val_if_fail (ifname != NULL, NULL); priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); iface = g_hash_table_lookup (priv->ifaces, ifname); if (!iface) { /* If we're making the supplicant take a time out for a bit, don't * let the supplicant interface start immediately, just let it hang * around in INIT state until we're ready to talk to the supplicant * again. */ start_now = !die_count_exceeded (priv->die_count); nm_log_dbg (LOGD_SUPPLICANT, "(%s): creating new supplicant interface", ifname); iface = nm_supplicant_interface_new (ifname, is_wireless, priv->fast_supported, priv->ap_support, start_now); if (iface) { g_hash_table_insert (priv->ifaces, (char *) nm_supplicant_interface_get_ifname (iface), iface); } } else { nm_log_dbg (LOGD_SUPPLICANT, "(%s): returning existing supplicant interface", ifname); } return iface; }