49e2d7e37a348d32ae85eed1c039319893b03bc7
[vsys-scripts.git] / support / pltun.c
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <sys/socket.h>
4 #include <linux/if.h>
5 #include <linux/if_tun.h>
6
7 #include "tunalloc.h"
8
9 int main(void)
10 {
11     printf("Allocating tap device via VSYS\n");
12
13     char if_name[IFNAMSIZ];
14
15     int tun_fd = tun_alloc(IFF_TAP, if_name);
16
17     printf("Allocated tap device: %s fd=%d\n", if_name, tun_fd);
18
19     printf("Sleeping for 120 secs...\n");
20
21     while (1)
22         sleep(120);
23
24     printf("Closing\n");
25
26     return 0;
27 }