are you sure the driver is loaded? GetAdaptersInfo uses iphlpapi, if I'm not mistaken. For there to be visibilty from taht lib's perspective, all the NDIS stuff will have needed to happen (it's not just plundering registry entries). (There are a couple methods in taputil that generate lists of TAP adapters according to various heuristics, including iphlpapi, and registry plundering -- you can see the difference, and are welcome to try but I don't think it will get you closer to the solution).
A quicky alternative test to see if the driver is loaded is to open the file TAP1: with CreateFile, and check the result (and GetLastError() if needed). This is the user-mode interface into the TAP device, and is a little easier that fiddling with NDIS (though you can do that too). I don't know your platform. It's possibly not relevant, but for Window Mobile 5 and up, the driver cannot be loaded automatically at system startup, as it can on WM 4.2 and lower. The reason has to do with the policy that the platform is built with, and on those platforms, the driver has to be signed with a 'priviledged certificate', which is ruinously expensive (and you pay per signing), and a bit bureaucratic to obtain. It is signed with a regular code signing certificate (or it wouldn't load at all), but not one of those special ones. Anyway, that is platform (not OS) specific and may not be pertinent for you. If it is the case, there is a work-around via StartAllTAPAdpaters(), which does some NDIS ioctls to cause the driver to be loaded. -dave -----Original Message----- From: jonathan openvpn [mailto:jonathan.open...@gmail.com] Sent: Monday, June 08, 2009 11:38 AM To: openvpn-devel@lists.sourceforge.net Subject: [Openvpn-devel] Cannot find TAP adapter Hello. I'm triying to execute a Windows CE port of OpenVPN in a custom hardware. First of all, let me say that I cannot use the connection manager due to the plattform i am using. I've been succesfull on open the socket and retrieve initial information from the OpenVPN server. I also have added a TAP interface to the Windows CE registry via the "AddTAPAdapterRegistration" function in "taputil.cpp". My problem comes when it's time to open the just registered TUN adapter. When it searches for the adapters on the device by the "GetAdaptersInfo" function, the TUN adapter is not present. Only the physical ethernet interface is present. I've compared the resgistry entries with a pocket PC running an OpenVPN client and they are identical! I've searched in internet looking for someone with a similar problem but i have found nothing. Have you any idea? What are the requirements for an adapter to be found by the "GetAdaptersInfo" function? Here are my registry entries: [HKEY_LOCAL_MACHINE\Comm\TAP Device] "ImagePath"="tap-ce.dll" "Group"="NDIS" "DisplayName"="TAP Virtual Ethernet Device" [HKEY_LOCAL_MACHINE\Comm\TAP Device\Linkage] "Route"=hex(7):\ 54,41,50,20,44,65,76,69,63,65,20,31,00,54,41,50,20,44,65,76,69,63,65,20, 32,\ 00,00 [HKEY_LOCAL_MACHINE\Comm\TAP Device 1] "ImagePath"="tap-ce.dll" "Group"="NDIS" "DisplayName"="TAP1: Virtual Ethernet Device" [HKEY_LOCAL_MACHINE\Comm\TAP Device 1\Parms] "StreamIndex"=dword:00000001 "StreamName"="TAP" "BusType"=dword:00000000 "BusNumber"=dword:00000000 Another doubt. In the tun.c file, in function "do_ifconfig", there is no entry for WIN32 or WIN_CE, instead of this it is an "elif 0" entry. Because of this, in WIN_CE systems no ifconfig is done. Isn't it necessary? Thank you very much. Jonathan.