Skip to contentSkip to conversation

Question about TAP win32 programming

Openvpn-devel [email protected] 2 participants 2 messages Feb 22, 2005 – Feb 23, 2005

lore
Share & tools
lore
#0 lore raw

Hi to all,
i am disperately in need of some advices about a subject not strictly about OpenVPN, but maybe there is someone here who can help me..
I ve developed a tunnel-broker apps for Linux using TUN/TAP support, based on TUN virtual interfce like OpenVPN. In Linux, create (and open) a TUN device is easy, as i do:

#include <net/tun.h>
#include <linux/if_tun.h>

fp = fopen("/dev/net/tun",O_RDWR);
ioctl(fd, TUNSETIFF, &ifr);

and then i can read and write to and from TUN device with simple read() and write() calls.

Now, i'd like to port that software on win32. I have installed the TAP DRIVER on my machine, and now i have a TAP davide named "tap0801". Can someone explain me how i can do the same thing
under win32 ?

Thanks a lot

____________________________________________________________
Navighi a 2 MEGA e i primi 3 mesi sono GRATIS. Scegli Libero Adsl Flat senza limiti su http://www.libero.it

#1 lore raw
Quoted 14 lines · On Tue, 22 Feb 2005, [email protected]... wrote:

Hi to all,
i am disperately in need of some advices about a subject not strictly about OpenVPN, but maybe there is someone here who can help me..
I ve developed a tunnel-broker apps for Linux using TUN/TAP support, based on TUN virtual interfce like OpenVPN. In Linux, create (and open) a TUN device is easy, as i do:

#include <net/tun.h>
#include <linux/if_tun.h>

fp = fopen("/dev/net/tun",O_RDWR);
ioctl(fd, TUNSETIFF, &ifr);

Quoted 7 lines

and then i can read and write to and from TUN device with simple read() and write() calls.

Now, i'd like to port that software on win32. I have installed the TAP DRIVER on my machine, and now i have a TAP davide named "tap0801". Can someone explain me how i can do the same thing
under win32 ?

Look at the #ifdef WIN32 sections in tun.c.

Look especially for ReadFile, WriteFile, CreateFile, and DeviceIoControl calls, as these are used to interact with the TAP-Win32 driver.

James