Re: [Openvpn-devel] [PATCH] IPv6 support for TUN/TAP driver on windows

2010-03-07 Thread Peter Stuge
Gert Doering wrote:
> -!define PRODUCT_TAP_RELDATE "06/22/2009"
> +!define PRODUCT_TAP_RELDATE "07/03/2010"

Seems month/date are swapped.


//Peter



Re: [Openvpn-devel] [PATCH] IPv6 support for TUN/TAP driver on windows

2010-03-07 Thread Gert Doering
Hi,

On Sun, Feb 28, 2010 at 11:23:26PM +0100, Gert Doering wrote:
> to follow up on this...

Next round of "do things on windows" :-)

> [ TUN / TAP driver on windows ]
> 
> Now... is there someone who has worked on this before, and can help
> me a bit with it?  
> 
> Initial questions:
> 
>  - can it be cross-compiled?  If yes, how?  If no, what needs to be
>done on Windows to compile it?  (I have *no* experience with Windows,
>but I can follow instructions and read documentation).

It does not seem to be possible to cross-compile this.

For the archives:

Fairly detailed instructions how to compile on windows are contained in 
"domake-win" in the OpenVPN distribution - unfortunately, this is lacking
some of the important details, like "what to do if Microsoft is not willing
to ship WDK 6001* anymore, but you need to adjust to 7.1.0" or "don't
even try to build this from a drive that is not C:".

Anyway:

 - get MinGW and MSYS
 - get the Windows Driver Kit (WDK) from Microsoft
 - put everything on C:, not on different drive letters(!!)
 - follow the instructions in domake-win
 - adjust install-win32/settings.in if you use a different WDK version
 - adjust install-win32/maketap, "w2ktarget=..." for current WDK versions
 - build, pray, curse, fix scripts, ...

So far, I have been successful in building the tap driver, and ignored
all the rest.  I will give this another fight on a machine with enough
disk space on C: next week.


>  - what needs to be done to install the driver / replace the existing
>driver?

If you have OpenVPN installed in the normal location, just copy the
driver sources (tap0901.sys, tap0901.cap, OemWin2k.inf) to
C:\...\openvpn\driver and run "deltapall.bat" and "addtap.bat" from
...\openvpn\bin.

Make sure OpenVPN isn't active while replacing the driver, because you
might end up using the driver that's still in memory.

>  - how does one debug Windows drivers?  Is there a printf() as in Linux
>that goes to console / syslog?

I have not yet figured out that part.  I did my debugging with Wireshark
("see what packets move back and forth and stare at the packet details").


Attached below is the patch to the TUN/TAP driver that is required to
make OpenVPN work with IPv6 in TUN mode on windows.  The magic for IPv6
is modelled similar to the way ARP is handled for IPv4:

 - all routes are set up with a next-hop of fe80::8
 - if the tapdrvr notices a neighbor-discovery packet for fe80::8, it
   will grab the packet and synthesize a neighbor-advertisement response
 - windows is happy and sends the data packets to the tap driver :-)

(The patch is 175e17a5abd5969f6803a9cc9587b7959e1100ae in my git tree
- David, could you please git-pull to feat_ipv6_payload?)


What needs to happen next?

 - "someone who understands" needs to look at the diff, and ACK it
   (or tell me where i misunderstood things, and what to fix)

 - it whould be highly appreciated if Samuli could get OpenVPN Tech
   to provide Windows binaries for the "openvpn-testing" tree, so that
   we can get decent testing by the windows user base

 - if someone is willing to risk the stability of his system, you can
   test my binaries:

http://www.greenie.net/ipv6/tap0901-ipv6-20100307.tar.gz
http://www.greenie.net/ipv6/openvpn-win-ipv6-20100307.tgz

   (extract in ...\openvpn\driver and ...\openvpn\bin, respectively,
   then run deltapall.bat / addtap.bat)

   DO NOT DO THIS ON A PRODUCTION SYSTEM.  Really.  This has been tested 
   on two different Windows XP systems, and no adverse effects have been
   observed - but this is my first attemt at Windows driver programming, 
   and I would not trust that yet.


gert


diff --git a/install-win32/settings.in b/install-win32/settings.in
index 643ef99..202f782 100644
--- a/install-win32/settings.in
+++ b/install-win32/settings.in
@@ -42,8 +42,8 @@
 !define PRODUCT_TAP_DEVICE_DESCRIPTION  "TAP-Win32 Adapter V9"
 !define PRODUCT_TAP_PROVIDER"TAP-Win32 Provider V9"
 !define PRODUCT_TAP_MAJOR_VER   9
-!define PRODUCT_TAP_MINOR_VER   6
-!define PRODUCT_TAP_RELDATE "06/22/2009"
+!define PRODUCT_TAP_MINOR_VER   7
+!define PRODUCT_TAP_RELDATE "07/03/2010"

 # TAP adapter icon -- visible=0x81 or hidden=0x89
 !define PRODUCT_TAP_CHARACTERISTICS 0x81
diff --git a/tap-win32/proto.h b/tap-win32/proto.h
index e059772..ffb9ac9 100755
--- a/tap-win32/proto.h
+++ b/tap-win32/proto.h
@@ -29,9 +29,11 @@
 #pragma pack(1)

 #define IP_HEADER_SIZE 20
+#define IPV6_HEADER_SIZE 40

 typedef unsigned char MACADDR [6];
 typedef unsigned long IPADDR;
+typedef unsigned char IPV6ADDR [16];

 //-
 // Ethernet address
@@ -55,6 +57,7 @@ typedef struct
   MACADDR src;/* source ether addr */

 # define ETH_P_IP