Search code examples
windows-cedriverndis

How to use NDIS protocol driver?


I write a NDIS protocol driver. I can register my protocol with NdisRegisterProtocol.

How does the application typically access this driver? Is there a way to uses windows sockets or do I need to provide a StreamDriver interface?

The socket function has a third parameter 'protocol' that usually something like IPPROTO_UDP. Can I select my protocol driver using this parameter?


Solution

  • Protocol drivers aren't automatically exposed in the Windows Sockets API (and this is a good thing, since it gives you the most architectural flexibility). But you can get it to work by implementing a couple extra pieces.

    1. You need to implement some channel to communicate with your driver. I'm not too familiar with Windows CE, but StreamDriver sounds like a plausible way to do that.

    2. You need to expose that channel through Winsock. Write a "Transport Service Provider" library that takes requests from Winsock and translates them into something your protocol driver can understand.

    This is how TCPIP (the protocol driver) shows up as IPPROTO_UDP (the Winsock protocol type) — the OS includes a TSP for TCP, UDP, and Raw IP.

    The CE-specific documentation is here, but the NT documentation is worth reading too for the overview section.