#include <sys/types.h>
#include <sys/ioctl.h>
#include <net/if_tun.h>
#include <net/if_tap.h>
#include <assert.h>
#include <err.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
int
main(int argc, char *argv[])
{
unsigned long tunreq;
const char *tundev;
int one = 1, tunfd;
assert(argc > 1);
tundev = argv[1];
tunfd = open(tundev, O_RDWR);
assert(tunfd >= 0);
if (strstr(tundev, "tun") != NULL) {
tunreq = TUNSTRANSIENT;
} else {
assert(strstr(tundev, "tap") != NULL);
tunreq = TAPSTRANSIENT;
}
if (ioctl(tunfd, tunreq, &one) == -1)
err(1, "ioctl");
close(tunfd);
return (0);
}