Пример #1
0
static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
{
    DBusConnection *conn = ofono_dbus_get_connection();
    struct dundee_device *device = user_data;

    DBG("%p", device);
    DBG("PPP Link down: %d\n", reason);

    g_at_ppp_unref(device->ppp);
    device->ppp = NULL;

    g_at_chat_resume(device->chat);

    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;

    device->active = FALSE;

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

    device->driver->disconnect(device, disconnect_callback, device);
}
Пример #2
0
static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
{
	struct ofono_gprs_context *gc = user_data;
	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);

	DBG("");

	g_at_ppp_unref(gcd->ppp);
	gcd->ppp = NULL;

	switch (gcd->state) {
	case STATE_ENABLING:
		CALLBACK_WITH_FAILURE(gcd->up_cb, NULL, FALSE, NULL,
					NULL, NULL, NULL, gcd->cb_data);
		break;
	case STATE_DISABLING:
		CALLBACK_WITH_SUCCESS(gcd->down_cb, gcd->cb_data);
		break;
	default:
		ofono_gprs_context_deactivated(gc, gcd->active_context);
		break;
	}

	gcd->active_context = 0;
	gcd->state = STATE_IDLE;
	/*
	 * If the channel of gcd->chat is NULL, it might cause
	 * gprs_context_remove get called and the gprs context will be
	 * removed.
	 */
	g_at_chat_resume(gcd->chat);
}
Пример #3
0
static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
{
	struct ofono_cdma_connman *cm = user_data;
	struct connman_data *cd = ofono_cdma_connman_get_data(cm);

	DBG("");

	g_at_ppp_unref(cd->ppp);
	cd->ppp = NULL;

	switch (cd->state) {
	case STATE_ENABLING:
		CALLBACK_WITH_FAILURE(cd->up_cb, NULL, FALSE, NULL,
					NULL, NULL, NULL, cd->cb_data);
		break;
	case STATE_DISABLING:
		CALLBACK_WITH_SUCCESS(cd->down_cb, cd->cb_data);
		break;
	default:
		/* TODO: Handle network initiated disconnection */
		break;
	}

	cd->state = STATE_IDLE;
	g_at_chat_resume(cd->chat);
}
Пример #4
0
static void kill_ppp(gboolean ok, GAtResult *result, gpointer user_data)
{
	g_print("kill_ppp: %d\n", ok);

	if (ok == FALSE)
		return;

	g_at_ppp_unref(ppp);
	ppp = NULL;
}
Пример #5
0
static void at_gprs_context_remove(struct ofono_gprs_context *gc)
{
	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);

	DBG("");

	if (gcd->state != STATE_IDLE && gcd->ppp) {
		g_at_ppp_unref(gcd->ppp);
		g_at_chat_resume(gcd->chat);
	}

	ofono_gprs_context_set_data(gc, NULL);
	g_free(gcd);
}
Пример #6
0
static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
{
	g_print("PPP Link down: %d\n", reason);

	g_at_ppp_unref(ppp);
	ppp = NULL;

	if (option_modem == NULL)
		g_at_chat_set_debug(modem, gsmdial_debug, "");
	else
		g_at_chat_set_debug(modem, gsmdial_debug, "Modem");

	g_at_chat_register(modem, "NO CARRIER", no_carrier_notify,
					FALSE, NULL, NULL);
	g_at_chat_resume(modem);
}
Пример #7
0
static void cdma_connman_remove(struct ofono_cdma_connman *cm)
{
	struct connman_data *cd = ofono_cdma_connman_get_data(cm);

	DBG("");

	if (cd->state != STATE_IDLE && cd->ppp) {
		g_at_ppp_unref(cd->ppp);
		g_at_chat_resume(cd->chat);
	}

	ofono_cdma_connman_set_data(cm, NULL);

	g_at_chat_unref(cd->chat);
	g_free(cd);
}
Пример #8
0
static gboolean server_cleanup(void)
{
	if (server_watch)
		g_source_remove(server_watch);

	if (ppp) {
		g_at_ppp_unref(ppp);
		ppp = NULL;
	}

	g_at_server_unref(server);
	server = NULL;

	unlink(DEFAULT_SOCK_PATH);

	g_main_loop_quit(mainloop);

	return FALSE;
}
Пример #9
0
static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user)
{
	GAtServer *server = user;

	g_print("PPP Link down: %d\n", reason);

	g_at_ppp_unref(ppp);
	ppp = NULL;

	if (reason == G_AT_PPP_REASON_LINK_DEAD) {
		g_at_server_unref(server);
		server = NULL;
		return;
	}

	g_at_server_resume(server);
	g_at_server_set_debug(server, server_debug, "Server");

	g_at_server_send_final(server, G_AT_SERVER_RESULT_NO_CARRIER);
	data_mode = FALSE;
}
Пример #10
0
static void destroy_device(gpointer user)
{
    struct dundee_device *device = user;

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

    if (device->ppp != NULL)
        g_at_ppp_unref(device->ppp);

    if (device->pending)
        dbus_message_unref(device->pending);

    g_free(device->settings.interface);
    g_free(device->settings.ip);
    g_strfreev(device->settings.nameservers);

    g_free(device->path);
    g_free(device->name);

    g_free(device);
}
Пример #11
0
int main(int argc, char **argv)
{
	GOptionContext *context;
	GError *err = NULL;
	sigset_t mask;
	int signal_fd;
	GIOChannel *signal_io;
	int signal_source;

	context = g_option_context_new(NULL);
	g_option_context_add_main_entries(context, options, NULL);

	if (g_option_context_parse(context, &argc, &argv, &err) == FALSE) {
		if (err != NULL) {
			g_printerr("%s\n", err->message);
			g_error_free(err);
			return 1;
		}

		g_printerr("An unknown error occurred\n");
		return 1;
	}

	g_option_context_free(context);

	if (option_control) {
		int ret;

		g_print("Control: %s\n", option_control);
		if (option_modem)
			g_print("Modem: %s\n", option_modem);

		ret = open_serial();
		g_free(option_control);
		g_free(option_modem);

		if (ret < 0)
			goto out;
	} else {
		int ret;

		g_print("IP: %s\n", option_ip);
		g_print("Port: %d\n", option_port);
		ret = open_ip();
		g_free(option_ip);

		if (ret < 0)
			goto out;
	}

	g_print("APN: %s\n", option_apn);
	g_print("CID: %d\n", option_cid);

	sigemptyset(&mask);
	sigaddset(&mask, SIGTERM);
	sigaddset(&mask, SIGINT);
	sigaddset(&mask, SIGUSR1);
	sigaddset(&mask, SIGUSR2);
	sigaddset(&mask, SIGPIPE);

	if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
		perror("Can't set signal mask");
		return 1;
	}

	signal_fd = signalfd(-1, &mask, 0);
	if (signal_fd < 0) {
		perror("Can't create signal filedescriptor");
		return 1;
	}

	signal_io = g_io_channel_unix_new(signal_fd);
	g_io_channel_set_close_on_unref(signal_io, TRUE);
	signal_source = g_io_add_watch(signal_io,
			G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
			signal_cb, GINT_TO_POINTER(signal_fd));
	g_io_channel_unref(signal_io);

	event_loop = g_main_loop_new(NULL, FALSE);

	if (option_bluetooth) {
		g_at_chat_send(control, "ATD*99#", none_prefix, connect_cb,
				NULL, NULL);
	} else {
		g_at_chat_send(control, "ATE0Q0V1", NULL, NULL, NULL, NULL);
		g_at_chat_send(control, "AT+CFUN?", cfun_prefix,
							check_mode, NULL, NULL);
	}

	g_main_loop_run(event_loop);
	g_source_remove(signal_source);
	g_main_loop_unref(event_loop);

out:
	if (ppp == NULL) {
		g_at_chat_unref(control);
		g_at_chat_unref(modem);
	} else
		g_at_ppp_unref(ppp);

	g_free(option_apn);

	return 0;
}