Exemple #1
0
static void create_tun(GAtRawIP *rawip)
{
	GIOChannel *channel;
	struct ifreq ifr;
	int fd, err;

	fd = open("/dev/net/tun", O_RDWR);
	if (fd < 0)
		return;

	memset(&ifr, 0, sizeof(ifr));
	ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
	strcpy(ifr.ifr_name, "gprs%d");

	err = ioctl(fd, TUNSETIFF, (void *) &ifr);
	if (err < 0) {
		close(fd);
		return;
	}

	rawip->ifname = g_strdup(ifr.ifr_name);

	channel = g_io_channel_unix_new(fd);
	if (channel == NULL) {
		close(fd);
		return;
	}

	rawip->tun_io = g_at_io_new(channel);

	g_io_channel_unref(channel);
}
Exemple #2
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;
}
Exemple #3
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;
}