cannot set TUN mode for TAP-Win32 driver programmatically

How to customize and extend your OpenVPN installation.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
sherwoodluo
OpenVpn Newbie
Posts: 1
Joined: Thu May 31, 2012 5:12 pm

cannot set TUN mode for TAP-Win32 driver programmatically

Post by sherwoodluo » Thu May 31, 2012 6:05 pm

I am developing a customized application which reads IP packets from TUN interface and then send it over peer-to-peer transports. For this purposed I installed OpenVPN 2.2.2 and used the TAP-Win32 driver coming along with it (version 9.9).

From the various posts I found online, the following steps were performed in my application to setup TUN interface:

1) Use the OpenVPN "Add New Tap Virtual Adapter" utility to add a tap device.
2) Manually configure the device IP address in Windows Control Panel.
3) Obtain the TAP device GUID.
4) Use this GUID and CreateFile() to obtain a device handle.
5) (Optional) Use TAP_IOCTL_GET_MTU to get the device supported MTU. (I used this to verify DeviceIoControl() can be successfully fulfilled.
6) Use TAP_IOCTL_CONFIG_TUN to set the device in TUN mode, with network/local address/netmask as parameters.
7) Use TAP_IOCTL_SET_MEDIA_STATUS to set the virtual interface as connected.
8) Use Windows "route" command to add subnet routes to the virtual interface.

While the return code from 4) to 8) were all successful. The device still behaves as a TAP rather than TUN. When I am issuing ping to the addresses within the subnet, I observed ARP inquiries on the virtual interface (using Wireshark) but no IP packets. What should I do to make sure it behaves as a TUN?

Appreciate the help.

vijayaplv
OpenVpn Newbie
Posts: 2
Joined: Thu Sep 20, 2012 8:18 pm

Re: cannot set TUN mode for TAP-Win32 driver programmaticall

Post by vijayaplv » Thu Sep 20, 2012 8:24 pm

Were you able to accomplish this? I am also facing the same issue. If so please share your approach.

ayoub
OpenVpn Newbie
Posts: 1
Joined: Wed Jun 27, 2018 8:05 am

Re: cannot set TUN mode for TAP-Win32 driver programmatically

Post by ayoub » Wed Jun 27, 2018 8:09 am

Were you able to accomplish this? I am also facing the same issue. If so please share your approach.

Post Reply