65oo2/vm/net/tap-linux.c

33 lines
477 B
C
Raw Permalink Normal View History

2024-02-29 12:01:58 +00:00
#include <linux/if_tun.h>
/*
* man 7 netdevice
* man 4 tap
*/
void
tap_new(void)
{
int fd;
struct ifreq req;
fd = open("/dev/net/tun", O_RDWR);
if (fd < 0)
{
return;
}
memset(&req, 0, sizeof(struct ifreq));
req.ifr_flags = IFF_TAP | IFF_NO_PI;
/*
* malloc(IFNAMSIZ);
* tun_alloc(xxxx, IFF_TAP);
*/
strncpy(req.ifr_name, "todo", 5);
if (ioctl(fd, TUNSETIFF, &req) < 0)
{
return;
}
}