+#ifdef HAVE_LINUX
+ if(tun) {
+ in = out = open("/dev/net/tun", O_RDWR | O_NONBLOCK);
+ if(in < 0) {
+ fprintf(stderr, "Could not open tun device: %s\n", strerror(errno));
+ return 1;
+ }
+ struct ifreq ifr = {
+ .ifr_flags = IFF_TUN
+ };
+ if(ioctl(in, TUNSETIFF, &ifr)) {
+ fprintf(stderr, "Could not configure tun interface: %s\n", strerror(errno));
+ return 1;
+ }
+ ifr.ifr_name[IFNAMSIZ - 1] = 0;
+ fprintf(stderr, "Using tun interface %s\n", ifr.ifr_name);
+ }
+#endif
+