Skip to contentSkip to conversation

TUN/TAP Windows

Openvpn-devel Bernhard Fischer 2 participants 3 messages Dec 16, 2008 – Dec 21, 2008 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 7 lines · you

...

Quoted 5 lines

I'm working on a project (www.abenteuerland.at/onioncat) that needs a TUN
device. I'm now trying to port the software to Windows (Cygwin).

Quoted 7 lines
Quoted 4 lines

...........

How do I compile and install the TUN/TAP driver?

You will need the DDK, but here's a silly question: can you not use the existing (built) one? Are you making modifications to the driver itself?

No, I don't need any modification. I know, that the pre-built one works with openvpn.
But if I start the Cygwin shell there's no /dev/tun. Hence, I thought that I have to compile and install it from source.
But maybe I need another method (than /dev/tun) to access the driver on Windows. I tried to find the right code parts within the Opnevpn source but unfortunately I didn't know where to look...the code base isn't small ;)

Quoted 6 lines

I admittedly did not read thoroughly your project page, but it looks like you are wanting to replace the user-mode openvpn component (which does the encryption and tunnelling) with TOR to provide a kind of transparent TOR proxy. I would expect you can do this with the existing TAP driver because it's a little like not caring so much about the remote VPN network, but rather caring more about your default gateway. Just a guess.

Yes, you're right. OnionCat is a transparent VPN (like OpenVPN) based on TOR's hidden services. That's why I use the TUN/TAP device. It works very well on Linux und other Unixoids but now I'd like to port it to Windows. My biggest problem seems to be this TUN/TAP driver, hence my posting ;) Maybe you could give me some hints.

Thanks,
Berhard

#2 lore raw

...

Quoted 12 lines

No, I don't need any modification. I know, that the pre-built one works with
openvpn.
But if I start the Cygwin shell there's no /dev/tun. Hence, I thought that I
have to compile and install it from source.
But maybe I need another method (than /dev/tun) to access the driver on
Windows. I tried to find the right code parts within the Opnevpn source but
unfortunately I didn't know where to look...the code base isn't small ;)

...

Quoted 6 lines

hidden services. That's why I use the TUN/TAP device. It works very well on
Linux und other Unixoids but now I'd like to port it to Windows. My biggest
problem seems to be this TUN/TAP driver, hence my posting ;) Maybe you could give me some hints.

Here's some hints:
* the TAP usage for Windows is quite different than for the Unices. The work is done in tap.c.
* In Windows, ioctls are used for configuration and control, and ReadFile() and WriteFile() are used for io
* there is no /dev/tun in Windows -- even under Cygwin's emulation. You will need to be familiar with how the Windows object namespace works, and the filename for the device will be something like \\.\Global\{ECFBAB2D-479B-4FE8-87B1-A66FC8DB0EF5}.tap
the funky 'filename' is the GUID of the driver instance, and is not a constant installation-to-installation. Fortunately all the code to figure that stuff out is tun.c as well.
* the Windows mechanism is implemented via an asynchronous IO mechanism called 'overlapped io'. You'll need to be familiar with this mechanism to make heads-or-tails of what's going on, but short story is that WriteFile and ReadFile don't block as you might usually expect, but rather return immediately. The request is queued to be completed in the kernel later. When they are completed an 'event' is signaled, which can be waited upon, which indicates data is available or that the write completed (I believe that Writes complete immediately in this implementation and are effectively synchronous, but reads are not).

Other than that, it is fairly straightforward: open the device, configure the device-specific parameters, and read/write packets to it to your heart's content.

-Dave

#3 lore raw
Quoted 46 lines · Dave

...

Quoted 12 lines

No, I don't need any modification. I know, that the pre-built one works with
openvpn.
But if I start the Cygwin shell there's no /dev/tun. Hence, I thought that I
have to compile and install it from source.
But maybe I need another method (than /dev/tun) to access the driver on
Windows. I tried to find the right code parts within the Opnevpn source but
unfortunately I didn't know where to look...the code base isn't small ;)

...

Quoted 6 lines

hidden services. That's why I use the TUN/TAP device. It works very well on
Linux und other Unixoids but now I'd like to port it to Windows. My biggest
problem seems to be this TUN/TAP driver, hence my posting ;) Maybe you could give me some hints.

Here's some hints:
* the TAP usage for Windows is quite different than for the Unices. The work is done in tap.c.
* In Windows, ioctls are used for configuration and control, and ReadFile() and WriteFile() are used for io
* there is no /dev/tun in Windows -- even under Cygwin's emulation. You will need to be familiar with how the Windows object namespace works, and the filename for the device will be something like \\.\Global\{ECFBAB2D-479B-4FE8-87B1-A66FC8DB0EF5}.tap
the funky 'filename' is the GUID of the driver instance, and is not a constant installation-to-installation. Fortunately all the code to figure that stuff out is tun.c as well.
* the Windows mechanism is implemented via an asynchronous IO mechanism called 'overlapped io'. You'll need to be familiar with this mechanism to make heads-or-tails of what's going on, but short story is that WriteFile and ReadFile don't block as you might usually expect, but rather return immediately. The request is queued to be completed in the kernel later. When they are completed an 'event' is signaled, which can be waited upon, which indicates data is available or that the write completed (I believe that Writes complete immediately in this implementation and are effectively synchronous, but reads are not).

Quoted 5 lines

Other than that, it is fairly straightforward: open the device, configure the device-specific parameters, and read/write packets to it to your heart's content.

-Dave

Wow, thanks a lot!
That sounds great. I'll immediately try those things.

Thanks,
Bernhard