static void modem_prepare_result (NMModem *modem, gboolean success, NMDeviceStateReason reason, gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); NMDeviceState state; state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (device)); g_return_if_fail (state == NM_DEVICE_STATE_CONFIG || state == NM_DEVICE_STATE_NEED_AUTH); if (success) { NMActRequest *req; NMActStageReturn ret; NMDeviceStateReason stage2_reason = NM_DEVICE_STATE_REASON_NONE; req = nm_device_get_act_request (device); g_assert (req); ret = nm_modem_act_stage2_config (modem, req, &stage2_reason); switch (ret) { case NM_ACT_STAGE_RETURN_POSTPONE: break; case NM_ACT_STAGE_RETURN_SUCCESS: nm_device_activate_schedule_stage3_ip_config_start (device); break; case NM_ACT_STAGE_RETURN_FAILURE: default: nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, stage2_reason); break; } } else nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason); }
static gboolean nas_update_cb (gpointer user_data) { NMDeviceAdsl *self = NM_DEVICE_ADSL (user_data); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); NMDevice *device = NM_DEVICE (self); g_assert (priv->nas_ifname); priv->nas_update_count++; if (priv->nas_update_count > 10) { priv->nas_update_id = 0; _LOGW (LOGD_ADSL, "failed to find br2684 interface %s ifindex after timeout", priv->nas_ifname); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_BR2684_FAILED); return G_SOURCE_REMOVE; } g_warn_if_fail (priv->nas_ifindex < 0); priv->nas_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->nas_ifname); if (priv->nas_ifindex < 0) { /* Keep waiting for it to appear */ return G_SOURCE_CONTINUE; } priv->nas_update_id = 0; _LOGD (LOGD_ADSL, "using br2684 iface '%s' index %d", priv->nas_ifname, priv->nas_ifindex); if (pppoe_vcc_config (self)) { nm_device_activate_schedule_stage3_ip_config_start (device); } else { nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_BR2684_FAILED); } return G_SOURCE_REMOVE; }
static void check_connect_continue (NMDeviceBt *self) { NMDevice *device = NM_DEVICE (self); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (self); gboolean pan = (priv->bt_type == NM_BT_CAPABILITY_NAP); gboolean dun = (priv->bt_type == NM_BT_CAPABILITY_DUN); if (!priv->connected || !priv->have_iface) return; nm_log_info (LOGD_BT, "Activation (%s %s/bluetooth) Stage 2 of 5 (Device Configure) " "successful. Will connect via %s.", nm_device_get_iface (device), nm_device_get_ip_iface (device), dun ? "DUN" : (pan ? "PAN" : "unknown")); /* Kill the connect timeout since we're connected now */ if (priv->timeout_id) { g_source_remove (priv->timeout_id); priv->timeout_id = 0; } if (pan) { /* Bluez says we're connected now. Start IP config. */ nm_device_activate_schedule_stage3_ip_config_start (device); } else if (dun) { /* Wait for ModemManager to find the modem */ priv->timeout_id = g_timeout_add_seconds (30, modem_find_timeout, self); nm_log_info (LOGD_BT | LOGD_MB, "Activation (%s/bluetooth) Stage 2 of 5 (Device Configure) " "waiting for modem to appear.", nm_device_get_iface (device)); } else g_assert_not_reached (); }
static void wmx_state_change_cb (struct wmxsdk *wmxsdk, WIMAX_API_DEVICE_STATUS new_status, WIMAX_API_DEVICE_STATUS old_status, WIMAX_API_STATUS_REASON reason, WIMAX_API_CONNECTION_PROGRESS_INFO progress, void *user_data) { NMDeviceWimax *self = NM_DEVICE_WIMAX (user_data); NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); NMDeviceState state; const char *iface; gboolean old_available = FALSE; const char *nsp_name = NULL; iface = nm_device_get_iface (NM_DEVICE (self)); nm_log_info (LOGD_WIMAX, "(%s): wimax state change %s -> %s (%s (%d))", iface, iwmx_sdk_dev_status_to_str (old_status), iwmx_sdk_dev_status_to_str (new_status), iwmx_sdk_con_progress_to_str (progress), progress); if (new_status == old_status) return; state = nm_device_get_state (NM_DEVICE (self)); old_available = nm_device_is_available (NM_DEVICE (self)); priv->status = new_status; if (priv->current_nsp) nsp_name = nm_wimax_nsp_get_name (priv->current_nsp); switch (new_status) { case WIMAX_API_DEVICE_STATUS_UnInitialized: case WIMAX_API_DEVICE_STATUS_RF_OFF_HW_SW: case WIMAX_API_DEVICE_STATUS_RF_OFF_HW: case WIMAX_API_DEVICE_STATUS_RF_OFF_SW: if (priv->wimaxd_enabled) { priv->wimaxd_enabled = FALSE; if (update_availability (self, old_available)) return; } break; case WIMAX_API_DEVICE_STATUS_Connecting: case WIMAX_API_DEVICE_STATUS_Data_Connected: /* If for some reason we're initially connected, force a disconnect here */ if (state < NM_DEVICE_STATE_DISCONNECTED) force_disconnect (self, wmxsdk); /* Fall through */ case WIMAX_API_DEVICE_STATUS_Ready: case WIMAX_API_DEVICE_STATUS_Scanning: if (priv->wimaxd_enabled == FALSE) { priv->wimaxd_enabled = TRUE; if (update_availability (self, old_available)) return; } break; default: nm_log_warn (LOGD_WIMAX, "(%s): unhandled WiMAX device state %d", iface, new_status); break; } /* Handle activation success and failure */ if (nm_device_is_activating (NM_DEVICE (self))) { if (new_status == WIMAX_API_DEVICE_STATUS_Data_Connected) { /* Success */ clear_activation_timeout (self); nm_log_info (LOGD_WIMAX, "(%s): connected to '%s'", iface, nsp_name); nm_device_activate_schedule_stage3_ip_config_start (NM_DEVICE (self)); return; } if (priv->connect_failed) { /* Connection attempt failed */ nm_log_info (LOGD_WIMAX, "(%s): connection to '%s' failed: (%d) %s", iface, nsp_name, reason, iwmx_sdk_reason_to_str (reason)); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CONFIG_FAILED); return; } /* If stage2 was postponed because the device was scanning or something, * then check if we need to move to stage2 now that the device might be * ready. */ if (state == NM_DEVICE_STATE_PREPARE && priv->prepare_done) { if ( new_status == WIMAX_API_DEVICE_STATUS_Ready || new_status == WIMAX_API_DEVICE_STATUS_Connecting) { nm_device_activate_schedule_stage2_device_config (NM_DEVICE (self)); return; } } } /* Handle disconnection */ if (state == NM_DEVICE_STATE_ACTIVATED) { if ( old_status == WIMAX_API_DEVICE_STATUS_Data_Connected && new_status < WIMAX_API_DEVICE_STATUS_Connecting) { nm_log_info (LOGD_WIMAX, "(%s): disconnected from '%s': (%d) %s", iface, nsp_name, reason, iwmx_sdk_reason_to_str (reason)); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CONFIG_FAILED); } } }