1.2 Dynamic Binding in an Intermediate Driver

A PnP-ready intermediate driver can support dynamic binding to underlying NICs by providing both a ProtocolBindAdapter and a ProtocolUnbindAdapter function. NDIS calls the ProtocolBindAdapter function of any intermediate driver that can bind to a NIC when that NIC becomes available.

VOID
    ProtocolBindAdapter(
        OUT PNDIS_STATUS
Status,
        IN NDIS_HANDLE
BindContext,
        IN PNDIS_STRING
DeviceName,
        IN PVOID
SystemSpecific1,
        IN PVOID
SystemSpecific2
        );

The handle at BindContext represents NDIS’ context for the bind request. The intermediate driver must retain this handle and pass it back to NDIS as a parameter to NdisCompleteBindAdapter when the intermediate driver has completed its binding-related activities and is ready to accept transmit requests.

Binding-time actions include allocating and initializing a NIC-specific context area for the binding, and calling NdisOpenAdapter to bind to the adapter passed at DeviceName. DeviceName can refer to a NIC managed by an underlying NIC driver, or it can be the name of a virtual NIC exported by an intermediate NDIS driver that is layered between the called intermediate driver and the NIC driver managing the adapter to which transmit requests are directed. Usually, only one intermediate NDIS driver is layered over a NIC driver, perhaps to translate between the format of the medium supported by an overlying legacy protocol driver and the format of the medium supported by an underlying NIC driver.

The intermediate driver can store the BindContext in the allocated binding-related context area or in another driver-accessible location. The BindContext value must be stored if NdisOpenAdapter can return NDIS_STATUS_PENDING. In this case, the intermediate driver cannot call NdisCompleteBindAdapter until the open-adapter operation is complete and the intermediate driver is called at its ProtocolOpenAdapterComplete function. BindContext must then be retrieved from a known location and passed by ProtocolOpenAdapterComplete to NdisCompleteBindAdapter.

SystemSpecific1 points to a registry path if the intermediate driver stores adapter-specific information in the registry. This value is passed to NdisOpenProtocolConfiguration to obtain a handle used to read and possibly write such information.

SystemSpecific2 is reserved for system use.

If an intermediate driver converts incoming packets from one medium format to another, ProtocolBindAdapter can allocate a pool of packet descriptors and buffer descriptors it will need on a per-binding basis. See Section 1.3 for information about the requirement to allocate and manage packets. Also, if an intermediate driver receives incoming data only at its ProtocolReceive function, it should allocate packet pool and buffer pool to copy received data.