static void modem_ip4_config_result (NMModem *self, const char *iface, NMIP4Config *config, GError *error, 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_IP_CONFIG); if (error) { nm_log_warn (LOGD_MB | LOGD_IP4, "retrieving IP4 configuration failed: (%d) %s", error ? error->code : -1, error && error->message ? error->message : "(unknown)"); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); } else { if (iface) nm_device_set_ip_iface (device, iface); nm_device_activate_schedule_stage4_ip4_config_get (device); } }
static void data_port_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data) { NMDevice *self = NM_DEVICE (user_data); nm_device_set_ip_iface (self, nm_modem_get_data_port (modem)); }
static void ppp_ip4_config (NMPPPManager *ppp_manager, const char *iface, NMIP4Config *config, gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); /* Ignore PPP IP4 events that come in after initial configuration */ if (nm_device_activate_ip4_state_in_conf (device)) { nm_device_set_ip_iface (device, iface); nm_device_activate_schedule_ip4_config_result (device, config); } }
static void bluez_connect_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, void *user_data) { NMDeviceBt *self = NM_DEVICE_BT (user_data); NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (self); GError *error = NULL; char *device; if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_STRING, &device, G_TYPE_INVALID) == FALSE) { nm_log_warn (LOGD_BT, "Error connecting with bluez: %s", error && error->message ? error->message : "(unknown)"); g_clear_error (&error); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_BT_FAILED); return; } if (!device || !strlen (device)) { nm_log_warn (LOGD_BT, "Invalid network device returned by bluez"); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_BT_FAILED); } if (priv->bt_type == NM_BT_CAPABILITY_DUN) { g_free (priv->rfcomm_iface); priv->rfcomm_iface = device; } else if (priv->bt_type == NM_BT_CAPABILITY_NAP) { nm_device_set_ip_iface (NM_DEVICE (self), device); g_free (device); } nm_log_dbg (LOGD_BT, "(%s): connect request successful", nm_device_get_iface (NM_DEVICE (self))); /* Stage 3 gets scheduled when Bluez says we're connected */ priv->have_iface = TRUE; check_connect_continue (self); }
gboolean nm_device_bt_modem_added (NMDeviceBt *self, NMModem *modem, const char *driver) { NMDeviceBtPrivate *priv; const gchar *modem_data_port; const gchar *modem_control_port; char *base; NMDeviceState state; NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE; g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (NM_IS_DEVICE_BT (self), FALSE); g_return_val_if_fail (modem != NULL, FALSE); g_return_val_if_fail (NM_IS_MODEM (modem), FALSE); priv = NM_DEVICE_BT_GET_PRIVATE (self); modem_data_port = nm_modem_get_data_port (modem); modem_control_port = nm_modem_get_control_port (modem); g_return_val_if_fail (modem_data_port != NULL || modem_control_port != NULL, FALSE); if (!priv->rfcomm_iface) return FALSE; base = g_path_get_basename (priv->rfcomm_iface); if (g_strcmp0 (base, modem_data_port) && g_strcmp0 (base, modem_control_port)) { g_free (base); return FALSE; } g_free (base); /* Got the modem */ if (priv->timeout_id) { g_source_remove (priv->timeout_id); priv->timeout_id = 0; } /* Can only accept the modem in stage2, but since the interface matched * what we were expecting, don't let anything else claim the modem either. */ state = nm_device_get_state (NM_DEVICE (self)); if (state != NM_DEVICE_STATE_CONFIG) { nm_log_warn (LOGD_BT | LOGD_MB, "(%s): modem found but device not in correct state (%d)", nm_device_get_iface (NM_DEVICE (self)), nm_device_get_state (NM_DEVICE (self))); return TRUE; } nm_log_info (LOGD_BT | LOGD_MB, "Activation (%s/bluetooth) Stage 2 of 5 (Device Configure) modem found.", nm_device_get_iface (NM_DEVICE (self))); if (priv->modem) { g_warn_if_reached (); g_object_unref (priv->modem); } priv->modem = g_object_ref (modem); g_signal_connect (modem, NM_MODEM_PPP_STATS, G_CALLBACK (ppp_stats), self); g_signal_connect (modem, NM_MODEM_PPP_FAILED, G_CALLBACK (ppp_failed), self); g_signal_connect (modem, NM_MODEM_PREPARE_RESULT, G_CALLBACK (modem_prepare_result), self); g_signal_connect (modem, NM_MODEM_IP4_CONFIG_RESULT, G_CALLBACK (modem_ip4_config_result), self); g_signal_connect (modem, NM_MODEM_AUTH_REQUESTED, G_CALLBACK (modem_auth_requested), self); g_signal_connect (modem, NM_MODEM_AUTH_RESULT, G_CALLBACK (modem_auth_result), self); /* In the old ModemManager the data port is known from the very beginning; * while in the new ModemManager the data port is set afterwards when the bearer gets * created */ if (modem_data_port) nm_device_set_ip_iface (NM_DEVICE (self), modem_data_port); g_signal_connect (modem, "notify::" NM_MODEM_DATA_PORT, G_CALLBACK (data_port_changed_cb), self); /* Kick off the modem connection */ if (!modem_stage1 (self, modem, &reason)) nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, reason); return TRUE; }