IP to Serial

Hi,

I’m trying to write a driver that will create a virtual LAN adapter and connect it to a serial port for which I already have a driver. Do I need a miniport, layered miniport or an intermediate driver? Based on the documentation, I should be writing an intermediate driver. Also, for the “adapter” I/O, can I simply use ReadFile and WriteFile calls on the COM port? Is there an example anywhere that uses such high level I/O on the lower edge? The only examples I am able to find are based off interrupts.

Thanks,
Manu

Did you look in the WDK for Win 7 RC1?

wrote in message news:xxxxx@ntdev…
> Hi,
>
> I’m trying to write a driver that will create a virtual LAN adapter and
> connect it to a serial port for which I already have a driver. Do I need a
> miniport, layered miniport or an intermediate driver? Based on the
> documentation, I should be writing an intermediate driver. Also, for the
> “adapter” I/O, can I simply use ReadFile and WriteFile calls on the COM
> port? Is there an example anywhere that uses such high level I/O on the
> lower edge? The only examples I am able to find are based off interrupts.
>
> Thanks,
> Manu
>

I did, after your suggestion. It has almost the same example as on the XP
DDK. The problem is that I don’t see an example that uses the win32 api for
serial port. I already have a usb/virtual serial port driver for my device
which creates a COM port and allows access through ReadFile, WriteFile. I
don’t see a reason to use lower level communication on the lower edge of the
driver. The only drivers that seem to use the win32 api are those in user
space (UMDF), but I’m not sure if I can create a virtual network adapter
from a user space driver.

Also, the task of creating a network adapter from a serial port should be a
pretty frequent requirement. Is there a generic driver that I’m missing?
Modem drivers do not serve the purpose because they need a SLIP/PPP speaking
DCE while Remote NDIS DCE’s again need to speak RNDIS protocol. I have a
serial device with a custom protocol.

Thanks,
Manu

On Fri, Jul 17, 2009 at 10:38 PM, David Craig wrote:

> Did you look in the WDK for Win 7 RC1?
>
> wrote in message news:xxxxx@ntdev…
> > Hi,
> >
> > I’m trying to write a driver that will create a virtual LAN adapter and
> > connect it to a serial port for which I already have a driver. Do I need
> a
> > miniport, layered miniport or an intermediate driver? Based on the
> > documentation, I should be writing an intermediate driver. Also, for the
> > “adapter” I/O, can I simply use ReadFile and WriteFile calls on the COM
> > port? Is there an example anywhere that uses such high level I/O on the
> > lower edge? The only examples I am able to find are based off interrupts.
> >
> > Thanks,
> > Manu
> >
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


The problem is that I don’t see an example that uses the win32 api for
serial port.

Network drivers are always kernel mode. Using the Win32 API is only
usermode.


I don’t see a reason to use lower level communication on the lower edge of
the driver.

You may not see a reason but then again you don’t see how to solve your
problem. The driver level interface to a system supplied COM port is well
defined. One needs only to look at the serenum sample, the serial sample or
the fakemodem sample. The entirety of the serial port I/O interface is well
covered in the WDK documentation in the Design Guide / Serial Devices and
Drivers.


Also, the task of creating a network adapter from a serial port should be a
pretty frequent requirement.

Well, no, not so frequent to do so with some arbitrary protocol where a
serial port device is the attachment link to the network defvice. Very
frequent where the serial communications link *is* the network and uses the
standard SLIP or PPP framing. There is this little feature of the OS known
as Remote Access (RAS / NDISWAN) that handles that just fine. And guess
what? It communicates with serial ports using kernel mode I/O.

And of course there is a set of standard drivers in Windows such that if
your device adheres to the RNDIS over USB specification, the standard
drivers handle the entire thing.


I have a serial device with a custom protocol.

And so you will be writing a custom driver with an upper edge as an NDIS
Miniport and a lower edge as a WDM (or WDF) driver which opens a serial port
device and sends it the appropriate requests to setup the DTE/DCE link
parameters and then read and write data to implement your protocol.

If you did not have a ‘custom protocol’ then you might have far less work to
do.

Good Luck,
Dave Cattley

David R. Cattley wrote:

And so you will be writing a custom driver with an upper
edge as an NDIS Miniport and a lower edge as a WDM
(or WDF) driver which opens a serial port device and
sends it the appropriate requests to setup the DTE/DCE
link parameters and then read and write data to implement
your protocol.

I could see a design where he handles all the serial “complexity” in a user-mode “bridge” that talks to both the COM port (using his favored usermode serial API’s) and some NDIS control device (through DeviceIoControl(), I suppose), but I admit this is totally unnecessary.

Sure, I can see a grand experiment in KMDF/UMDF programming that would make
any college professor proud (of the incredibly complex, inefficient, but
intoxicatingly panoramic embrace of windows programming).

Student: I wish to do the following for my project this semester.
Professor: Why, that sounds fine. {snicker: he will be my grader for the
next four years while trying to make that work.}

NDIS/WDF miniport ‘function’ driver.
UMDF lower filter to pickup reads & writes into usermode and send them down
the Win32 API using the COM port.

Maybe we can find a way to convince the OPto use kernel threads, named
pipes, and occasional undocumented LPC port, and any number of other things
too (like TAPI maybe just to make it really fun).

Or something like that :wink:

I wish I could get paid to build such a Rube Goldberg. It would surely be
more fun and educational than trying to squeeze a bazillion I/Os/sec down
some incredibly narrow device stack path by painstakingly inspecting every
last twiddle, lock scheme, data access, and encoding technique. Alas, the
real world intercedes…

Cheers,
-dave

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Tuesday, July 21, 2009 10:32 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] IP to Serial

David R. Cattley wrote:

And so you will be writing a custom driver with an upper
edge as an NDIS Miniport and a lower edge as a WDM
(or WDF) driver which opens a serial port device and
sends it the appropriate requests to setup the DTE/DCE
link parameters and then read and write data to implement
your protocol.

I could see a design where he handles all the serial “complexity” in a
user-mode “bridge” that talks to both the COM port (using his favored
usermode serial API’s) and some NDIS control device (through
DeviceIoControl(), I suppose), but I admit this is totally unnecessary.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

David R. Cattley wrote:

I wish I could get paid to build such a Rube Goldberg. It would surely
be more fun and educational than trying to squeeze a bazillion
I/Os/sec down some incredibly narrow device stack path by
painstakingly inspecting every last twiddle, lock scheme, data access,
and encoding technique. Alas, the real world intercedes…

What is it you’re trying to say, exactly???

:slight_smile: