Example #1
0
GAtHDLC *g_at_hdlc_new(GIOChannel *channel)
{
	GAtIO *io;
	GAtHDLC *hdlc;

	io = g_at_io_new(channel);
	if (io == NULL)
		return NULL;

	hdlc = g_at_hdlc_new_from_io(io);
	g_at_io_unref(io);

	return hdlc;
}
Example #2
0
GAtRawIP *g_at_rawip_new(GIOChannel *channel)
{
	GAtRawIP *rawip;
	GAtIO *io;

	io = g_at_io_new(channel);
	if (io == NULL)
		return NULL;

	rawip = g_at_rawip_new_from_io(io);

	g_at_io_unref(io);

	return rawip;
}
Example #3
0
void g_at_rawip_shutdown(GAtRawIP *rawip)
{
	if (rawip == NULL)
		return;

	if (rawip->tun_io == NULL)
		return;

	g_at_io_set_read_handler(rawip->io, NULL, NULL);
	g_at_io_set_read_handler(rawip->tun_io, NULL, NULL);

	rawip->write_buffer = NULL;
	rawip->tun_write_buffer = NULL;

	g_at_io_unref(rawip->tun_io);
	rawip->tun_io = NULL;
}
Example #4
0
void g_at_rawip_unref(GAtRawIP *rawip)
{
	if (rawip == NULL)
		return;

	if (g_atomic_int_dec_and_test(&rawip->ref_count) == FALSE)
		return;

	g_at_rawip_shutdown(rawip);

	g_at_io_unref(rawip->io);
	rawip->io = NULL;

	g_free(rawip->ifname);
	rawip->ifname = NULL;

	g_free(rawip);
}
Example #5
0
void g_at_hdlc_unref(GAtHDLC *hdlc)
{
	if (!hdlc)
		return;

	if (g_atomic_int_dec_and_test(&hdlc->ref_count) == FALSE)
		return;

	if (hdlc->record_fd > fileno(stderr)) {
		close(hdlc->record_fd);
		hdlc->record_fd = -1;
	}

	g_at_io_unref(hdlc->io);
	hdlc->io = NULL;

	ring_buffer_free(hdlc->write_buffer);
	g_free(hdlc->decode_buffer);

	if (hdlc->in_read_handler)
		hdlc->destroyed = TRUE;
	else
		g_free(hdlc);
}