Пример #1
0
static void
real_connection_secrets_updated (NMDevice *device,
                                 NMConnection *connection,
                                 GSList *updated_settings,
                                 RequestSecretsCaller caller)
{
	NMDeviceBt *self = NM_DEVICE_BT (device);
	NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (self);
	NMActRequest *req;
	NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;

	g_return_if_fail (IS_ACTIVATING_STATE (nm_device_get_state (device)));

	req = nm_device_get_act_request (device);
	g_assert (req);

	if (!nm_modem_connection_secrets_updated (priv->modem,
                                              req,
                                              connection,
                                              updated_settings,
                                              caller)) {
		nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS);
		return;
	}

	/* PPP handles stuff itself... */
	if (caller == SECRETS_CALLER_PPP)
		return;

	/* Otherwise, on success for GSM/CDMA secrets we need to schedule modem stage1 again */
	g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH);
	if (!modem_stage1 (self, priv->modem, &reason))
		nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, reason);
}
static void
modem_auth_result (NMModem *modem, GError *error, gpointer user_data)
{
    NMDevice *device = NM_DEVICE (user_data);
    NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
    NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;

    if (error) {
        nm_device_state_changed (device,
                                 NM_DEVICE_STATE_FAILED,
                                 NM_DEVICE_STATE_REASON_NO_SECRETS);
    } else {
        /* Otherwise, on success for GSM/CDMA secrets we need to schedule modem stage1 again */
        g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH);
        if (!modem_stage1 (NM_DEVICE_BT (device), priv->modem, &reason))
            nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
    }
}
Пример #3
0
gboolean
nm_device_bt_modem_added (NMDeviceBt *self,
                          NMModem *modem,
                          const char *driver)
{
	NMDeviceBtPrivate *priv;
	const char *modem_iface;
	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_iface = nm_modem_get_iface (modem);
	g_return_val_if_fail (modem_iface != NULL, FALSE);

	if (!priv->rfcomm_iface)
		return FALSE;

	base = g_path_get_basename (priv->rfcomm_iface);
	if (strcmp (base, modem_iface)) {
		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_interface_get_state (NM_DEVICE_INTERFACE (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_NEED_AUTH, G_CALLBACK (modem_need_auth), 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;
}
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;
}