Ejemplo n.º 1
0
static gboolean can_write_data(gpointer data)
{
	GAtHDLC *hdlc = data;
	unsigned int len;
	unsigned char *buf;
	gsize bytes_written;

	len = ring_buffer_len_no_wrap(hdlc->write_buffer);
	buf = ring_buffer_read_ptr(hdlc->write_buffer, 0);

	bytes_written = g_at_io_write(hdlc->io, (gchar *) buf, len);
	hdlc_record(hdlc->record_fd, FALSE, buf, bytes_written);
	ring_buffer_drain(hdlc->write_buffer, bytes_written);

	if (ring_buffer_len(hdlc->write_buffer) > 0)
		return TRUE;

	return FALSE;
}
Ejemplo n.º 2
0
static gboolean tun_write_data(gpointer data)
{
	GAtRawIP *rawip = data;
	unsigned int len;
	unsigned char *buf;
	gsize bytes_written;

	if (rawip->tun_write_buffer == NULL)
		return FALSE;

	len = ring_buffer_len_no_wrap(rawip->tun_write_buffer);
	buf = ring_buffer_read_ptr(rawip->tun_write_buffer, 0);

	bytes_written = g_at_io_write(rawip->tun_io, (gchar *) buf, len);
	ring_buffer_drain(rawip->tun_write_buffer, bytes_written);

	if (ring_buffer_len(rawip->tun_write_buffer) > 0)
		return TRUE;

	rawip->tun_write_buffer = NULL;

	return FALSE;
}