/*-1* Copyright (c) 2024 Kyle Evans <[email protected]>2*3* SPDX-License-Identifier: BSD-2-Clause4*/56/*7* This test simply configures the tunnel as transient and exits. By the time8* we return, the tunnel should be gone because the last reference disappears.9*/1011#include <sys/types.h>12#include <sys/ioctl.h>13#include <net/if_tun.h>14#include <net/if_tap.h>1516#include <assert.h>17#include <err.h>18#include <fcntl.h>19#include <string.h>20#include <unistd.h>2122int23main(int argc, char *argv[])24{25unsigned long tunreq;26const char *tundev;27int one = 1, tunfd;2829assert(argc > 1);30tundev = argv[1];3132tunfd = open(tundev, O_RDWR);33assert(tunfd >= 0);3435/*36* These are technically the same request, but we'll use the technically37* correct one just in case.38*/39if (strstr(tundev, "tun") != NULL) {40tunreq = TUNSTRANSIENT;41} else {42assert(strstr(tundev, "tap") != NULL);43tunreq = TAPSTRANSIENT;44}4546if (ioctl(tunfd, tunreq, &one) == -1)47err(1, "ioctl");4849/* Final close should destroy the tunnel automagically. */50close(tunfd);5152return (0);53}545556