[OpenVPN home] [Date Prev] [Date Index] [Date Next]
[OpenVPN mailing lists] [Thread Prev] [Thread Index] [Thread Next]
Web openvpn.net

[Openvpn-users] Problem opening TAP device on Win XP from Java

  • Subject: [Openvpn-users] Problem opening TAP device on Win XP from Java
  • From: "Harsha V. Madhyastha" <harsha@xxxxxxxxxxxxxxxxx>
  • Date: Sat, 15 Jan 2005 23:36:58 -0800 (PST)


I am a graduate student in Computer Science at the University of 
Washington. I have been trying to use the TUN/TAP device as a means of 
capturing incoming and outgoing packets. To make my system portable across 
Windows and Linux, I have been using Java for development, because of which 
I have run into a problem.

I installed v1.6 of the TUN/TAP device on my Windows XP machine. I then 
found from the registry that the key for the device on my machine is
{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2} (under the 
>From elsewhere on the web, I found that on Windows this device can be 
addressed as \\.\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap

I then wrote up a short C code,

char *tun_dev_name = "\\\\.\\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap";
FILE *f = fopen(tun_dev_name, "rw");
HANDLE h = CreateFile(tun_dev_name, GENERIC_WRITE | GENERIC_READ, 0, 0, \

In the above code, both the FILE* and the HANDLE returned are non-NULL.

However, when I try to do the same in Java using

String tun_dev_name = 
new String("\\\\.\\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap");
RandomAccessFile raf = new RandomAccessFile(tun_dev_name, "rw");

a java.io.IOException is thrown with the message "Invalid argument". In 
fact, when I invoke the above C code as a native method from within Java, 
though a valid HANDLE is still returned, the FILE* returned is NULL. I 
have tried giving all permissions to my codebase using Java's policytool, 
but that didn't help.

The above problem persists with any of the 2.0 beta versions as well.

I was unsure whether this problem is more pertinent to the devel or the 
users mailing list. So, I'm forwarding this on both. Sorry about that!

Any help in this regard would be greatly appreciated.

Harsha Madhyastha
Graduate Student
Department of CSE
University of Washington

The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Openvpn-users mailing list