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 (self, ifname, is_wireless, start_now); if (iface) g_hash_table_insert (priv->ifaces, g_strdup (ifname), iface); } else { nm_log_dbg (LOGD_SUPPLICANT, "(%s): returning existing supplicant interface", ifname); } return iface; }
static gboolean is_available (NMSupplicantManager *self) { NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); return priv->running && !die_count_exceeded (priv->die_count); }
static gboolean is_available (NMSupplicantManager *self) { g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), FALSE); if (die_count_exceeded (NM_SUPPLICANT_MANAGER_GET_PRIVATE (self)->die_count)) return FALSE; return NM_SUPPLICANT_MANAGER_GET_PRIVATE (self)->running; }
static void name_owner_changed (NMDBusManager *dbus_mgr, const char *name, const char *old_owner, const char *new_owner, gpointer user_data) { NMSupplicantManager *self = NM_SUPPLICANT_MANAGER (user_data); NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); gboolean old_owner_good = (old_owner && strlen (old_owner)); gboolean new_owner_good = (new_owner && strlen (new_owner)); /* We only care about the supplicant here */ if (strcmp (WPAS_DBUS_SERVICE, name) != 0) return; if (!old_owner_good && new_owner_good) { nm_log_info (LOGD_SUPPLICANT, "wpa_supplicant started"); set_running (self, TRUE); } else if (old_owner_good && !new_owner_good) { nm_log_info (LOGD_SUPPLICANT, "wpa_supplicant stopped"); /* Reschedule the die count reset timeout. Every time the supplicant * dies we wait 10 seconds before resetting the counter. If the * supplicant died more than twice before the timer is reset, then * we don't try to talk to the supplicant for a while. */ if (priv->die_count_reset_id) g_source_remove (priv->die_count_reset_id); priv->die_count_reset_id = g_timeout_add_seconds (10, wpas_die_count_reset_cb, self); set_die_count (self, priv->die_count + 1); if (die_count_exceeded (priv->die_count)) { nm_log_info (LOGD_SUPPLICANT, "wpa_supplicant die count %d; ignoring for 10 seconds", priv->die_count); } set_running (self, FALSE); } }
static void name_owner_cb (GDBusProxy *proxy, GParamSpec *pspec, gpointer user_data) { NMSupplicantManager *self = NM_SUPPLICANT_MANAGER (user_data); NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); char *owner; g_return_if_fail (proxy == priv->proxy); owner = g_dbus_proxy_get_name_owner (proxy); nm_log_info (LOGD_SUPPLICANT, "wpa_supplicant %s", owner ? "running" : "stopped"); if (owner) { set_running (self, TRUE); update_capabilities (self); } else if (priv->running) { /* Reschedule the die count reset timeout. Every time the supplicant * dies we wait 10 seconds before resetting the counter. If the * supplicant died more than twice before the timer is reset, then * we don't try to talk to the supplicant for a while. */ if (priv->die_count_reset_id) g_source_remove (priv->die_count_reset_id); priv->die_count_reset_id = g_timeout_add_seconds (10, wpas_die_count_reset_cb, self); set_die_count (self, priv->die_count + 1); if (die_count_exceeded (priv->die_count)) { nm_log_info (LOGD_SUPPLICANT, "wpa_supplicant die count %d; ignoring for 10 seconds", priv->die_count); } set_running (self, FALSE); priv->fast_supported = FALSE; } g_free (owner); }