Hello all. Currently, tunctl only creates IFF_TAP devices. I would like to create persistant IFF_TUN devices, and so propose the attached patch. Comments are, of course, welcome.
Thanks. --nwf;
--- tunctl.c.orig 2008-01-24 00:26:35.000000000 -0500
+++ tunctl.c 2008-01-24 00:42:03.000000000 -0500
@@ -22,6 +22,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);
}
@@ -30,10 +31,10 @@
struct ifreq ifr;
struct passwd *pw;
long owner = geteuid();
- 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:")) > 0){
+ while((opt = getopt(argc, argv, "3bd:f:t:u:")) > 0){
switch(opt) {
case 'b':
brief = 1;
@@ -61,6 +62,9 @@
case 't':
tun = optarg;
break;
+ case '3':
+ tun_mode = 1;
+ break;
case 'h':
default:
Usage(name);
@@ -80,8 +84,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");
pgp1LHB2oQqNC.pgp
Description: PGP signature
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ User-mode-linux-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user
