Exemplo n.º 1
0
static void ppp_connect(const char *iface, const char *local, const char *peer,
                        const char *dns1, const char *dns2,
                        gpointer user_data)
{
    DBusConnection *conn = ofono_dbus_get_connection();
    struct dundee_device *device = user_data;
    const char *dns[3] = { dns1, dns2, 0 };

    DBG("%p", device);
    DBG("Network Device: %s\n", iface);
    DBG("IP Address: %s\n", local);
    DBG("Peer IP Address: %s\n", peer);
    DBG("Primary DNS Server: %s\n", dns1);
    DBG("Secondary DNS Server: %s\n", dns2);

    if (device->connect_timeout > 0) {
        g_source_remove(device->connect_timeout);
        device->connect_timeout = 0;
    }

    g_free(device->settings.interface);
    device->settings.interface = g_strdup(iface);
    if (device->settings.interface == NULL)
        goto err;

    g_free(device->settings.ip);
    device->settings.ip = g_strdup(local);
    if (device->settings.ip == NULL)
        goto err;

    g_strfreev(device->settings.nameservers);
    device->settings.nameservers = g_strdupv((gchar **)dns);
    if (device->settings.nameservers == NULL)
        goto err;

    __ofono_dbus_pending_reply(&device->pending,
                               dbus_message_new_method_return(device->pending));
    device->pending = NULL;

    device->active = TRUE;

    settings_changed(device);
    ofono_dbus_signal_property_changed(conn, device->path,
                                       DUNDEE_DEVICE_INTERFACE, "Active",
                                       DBUS_TYPE_BOOLEAN, &device->active);

    return;

err:
    g_free(device->settings.interface);
    g_free(device->settings.ip);
    g_strfreev(device->settings.nameservers);
    device->settings.interface = NULL;
    device->settings.ip = NULL;
    device->settings.nameservers = NULL;

    __ofono_dbus_pending_reply(&device->pending,
                               __dundee_error_failed(device->pending));
    device->pending = NULL;
}
Exemplo n.º 2
0
void dundee_device_disconnect(const struct dundee_error *error,
                              struct dundee_device *device)
{
    if (device == NULL)
        return;

    DBG("%s", device->path);

    g_at_chat_unref(device->chat);
    device->chat = NULL;

    if (device->pending == NULL)
        return;

    if (error->type != DUNDEE_ERROR_TYPE_NO_ERROR) {
        __ofono_dbus_pending_reply(&device->pending,
                                   __dundee_error_failed(device->pending));
        goto out;
    }

    __ofono_dbus_pending_reply(&device->pending,
                               dbus_message_new_method_return(device->pending));

out:
    device->pending = NULL;
}
Exemplo n.º 3
0
static void dial_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
    struct dundee_device *device = user_data;
    GAtIO *io;

    if (!ok) {
        DBG("Unable to define context\n");
        goto err;
    }

    /* get the data IO channel */
    io = g_at_chat_get_io(device->chat);

    /*
     * shutdown gatchat or else it tries to take all the input
     * from the modem and does not let PPP get it.
     */
    g_at_chat_suspend(device->chat);

    /* open ppp */
    device->ppp = g_at_ppp_new();
    if (device->ppp == NULL) {
        DBG("Unable to create PPP object\n");
        goto err;
    }
    g_at_ppp_set_debug(device->ppp, debug, "PPP");

    device->connect_timeout = g_timeout_add_seconds(PPP_TIMEOUT,
                              ppp_connect_timeout, device);

    /* set connect and disconnect callbacks */
    g_at_ppp_set_connect_function(device->ppp, ppp_connect, device);
    g_at_ppp_set_disconnect_function(device->ppp, ppp_disconnect, device);

    /* open the ppp connection */
    g_at_ppp_open(device->ppp, io);

    return;

err:
    __ofono_dbus_pending_reply(&device->pending,
                               __dundee_error_failed(device->pending));
    device->pending = NULL;

    device->driver->disconnect(device, disconnect_callback, device);
}
Exemplo n.º 4
0
static void connect_callback(const struct dundee_error *error,
                             int fd, void *data)
{
    struct dundee_device *device = data;
    int err;

    DBG("%p", device);

    if (error->type != DUNDEE_ERROR_TYPE_NO_ERROR)
        goto err;

    err = device_dial_setup(device, fd);
    if (err < 0)
        goto err;

    return;

err:
    __ofono_dbus_pending_reply(&device->pending,
                               __dundee_error_failed(device->pending));
    device->pending = NULL;
}
Exemplo n.º 5
0
static void disconnect_callback(const struct dundee_error *error, void *data)
{
	struct dundee_device *device = data;

	DBG("%p", device);

	g_at_chat_unref(device->chat);
	device->chat = NULL;

	if (device->pending == NULL)
		return;

	if (error->type != DUNDEE_ERROR_TYPE_NO_ERROR) {
		__ofono_dbus_pending_reply(&device->pending,
					__dundee_error_failed(device->pending));
		goto out;
	}

	__ofono_dbus_pending_reply(&device->pending,
		dbus_message_new_method_return(device->pending));

out:
	device->pending = NULL;
}