#! /bin/sh /usr/share/dpatch/dpatch-run ## 98-tunctl-IFF_TAP.dpatch ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Allow creation of IFF_TUN devices @DPATCH@ # Author: nwf # Status: none --- ./tunctl/tunctl.c.orig 2008-01-24 00:26:35.000000000 -0500 +++ ./tunctl/tunctl.c 2008-01-24 00:42:03.000000000 -0500 @@ -28,6 +28,7 @@ fprintf(stderr, "The default tun clone device is /dev/net/tun - some systems" " use\n/dev/misc/net/tun instead\n\n"); fprintf(stderr, "-b will result in brief output (just the device name)\n"); + fprintf(stderr, "-3 will open the interface in TUN mode, not TAP mode.\n"); exit(1); } @@ -38,10 +39,10 @@ struct group *gr; uid_t owner = -1; gid_t group = -1; - int tap_fd, opt, delete = 0, brief = 0; + int tap_fd, opt, delete = 0, brief = 0, tun_mode = 0; char *tun = "", *file = "/dev/net/tun", *name = argv[0], *end; - while((opt = getopt(argc, argv, "bd:f:t:u:g:")) > 0){ + while((opt = getopt(argc, argv, "3bd:f:t:u:g:")) > 0){ switch(opt) { case 'b': brief = 1; @@ -83,6 +84,9 @@ case 't': tun = optarg; break; + case '3': + tun_mode = 1; + break; case 'h': default: Usage(name); @@ -102,8 +106,7 @@ } memset(&ifr, 0, sizeof(ifr)); - - ifr.ifr_flags = IFF_TAP | IFF_NO_PI; + ifr.ifr_flags = (tun_mode ? IFF_TUN : IFF_TAP) | IFF_NO_PI; strncpy(ifr.ifr_name, tun, sizeof(ifr.ifr_name) - 1); if(ioctl(tap_fd, TUNSETIFF, (void *) &ifr) < 0){ perror("TUNSETIFF");