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 dri开发者_开发问答ver using this parameter?
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.
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.
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.
精彩评论