-----Original Message-----
From: openvpn-devel-boun...@lists.sourceforge.net
[mailto:openvpn-devel-boun...@lists.sourceforge.net] On Behalf Of Jon
Sent: Wednesday, August 16, 2006 2:40 AM
To: openvpn-devel@lists.sourceforge.net
Subject: [Openvpn-devel] hello,everyone.i have a question about tap-win32
driver, thinks



I am reading tap-win32/tapdrvr.c code. I found in DriverEntry function,
before call NdisMRegisterMiniport, have two lines:
  l_Properties->TransferDataHandler = AdapterReceive;      /*
DISPATCH_LEVEL */
  l_Properties->SendHandler = AdapterTransmit;             /*
DISPATCH_LEVEL */

But I found AdapterReceive function have nothing, AdapterTransmit function
recv data from  network card。
i can't understand. Who send data in this driver?
thinks
--
It is the tears of the earth that keep here smiles in bloom.

Dont forget:

The top-edge of the Win32 TAP driver connects (though NDIS) to the TCP/IP
stack.  The bottom-edge would normally talk to hardware sending data over
the wire, but instead it goes to a queue which another app, through api
calls, will pick up (namely openvpn) and send out via it's own mechanism.
Bearing that in mind....

AdapterTransmit does indeed do something with the packet.  Instead of
sending it to hardware, it checks for any pending read requests that
openvpn.exe had queued and satisfies them.  This happens around the
comment:

    // Cycle through IRPs and packets, try to satisfy each pending
    // IRP with a queued packet.

OK, that takes care of one direction of data flow (from application X,
through network stack, to tap driver, and on to openvpn).  Then there's
the reverse direction (from openvpn, to tap driver, up network stack, and
on to application X)....

AdapterReceive is for a different purpose than you might think, and is
required to exist by NDIS, but is not used and so is stubbed.  Check out
msdn if you're more curious about the detail.

Transmitting occurs in a slightly less obvious place.  In the function
TapDeviceHook(), at the case IRP_MJ_WRITE, the packet is sent up the
network stack via the calls NdisMEthIndicateReceive() and
NdisMEthIndicateReceiveComplete().

The TAP device is sort of two devices in one:  An NDIS miniport, and also
a typical custom device that you can open and do ReadFile() and
WriteFile() with.  The network stack uses the former interface, and
openvpn.exe uses the later.

-Dave

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to