1 /* Copyright 2004 Renzo Davoli
2 * Reseased under the GPLv2 */
11 #include <linux/if_tun.h>
15 #include <vdecommon.h>
17 static int tun_alloc(char *dev
)
22 if( (fd
= open("/dev/net/tun", O_RDWR
)) < 0 )
25 memset(&ifr
, 0, sizeof(ifr
));
27 /* Flags: IFF_TUN - TUN device (no Ethernet headers)
28 * IFF_TAP - TAP device
30 * IFF_NO_PI - Do not provide packet information
32 ifr
.ifr_flags
= IFF_TAP
;
34 strncpy(ifr
.ifr_name
, dev
, IFNAMSIZ
);
36 if( (err
= ioctl(fd
, TUNSETIFF
, (void *) &ifr
)) < 0 ){
40 printf("ioctl returns\n");
41 strcpy(dev
, ifr
.ifr_name
);
42 printf("ioctl idev\n");
46 char interface
[IFNAMSIZ
]="tap0";