A.3.3 Opening a Network Interface Card

As Figure A.3.3 shows, a transport driver can open any network interface card to which it is bound by calling MacOpenAdapter through NdisOpenAdapter. The transport driver must furnish a list of the NIC media types that it can use and a network interface card binding context. Typically the driver obtains this information from the Configuration Registry during driver initialization.

A NIC driver for a new network interface card can handle the network type of the card as well as possibly emulate a more popular network type, such as Ethernet. When the transport driver passes a list of NIC media types, NdisOpenAdapter calls MacOpenAdapter to allow the NIC driver to select a medium. NdisOpenAdapter then accepts the chosen name and notifies the operating system that the appropriate network interface card is being opened.

Figure A.3.3 Opening a network interface card

NdisOpenAdapter writes an NDIS binding handle to the transport driver. The transport driver must keep track of this handle, which is its only link to the NIC driver and which the transport driver must use in all future calls to the NDIS interface library.

NdisOpenAdapter calls MacOpenAdapter to inform the NIC driver that a transport driver has been bound to the associated network interface card. In response, the NIC driver activates the network interface card if it is not already physically enabled and then writes a binding context that the NDIS interface library wrapper stores in the NIC binding block. The NIC driver will not disable this network interface card until the reference count of open bindings returns to zero.

MacOpenAdapter completes synchronously if it finishes the NIC open operation before it returns. The function returns a status code other than NDIS_STATUS_PENDING in this case. Alternatively, MacOpenAdapter can return NDIS_STATUS_PENDING, which indicates that the function is asynchronous and cannot complete its operation before returning. To indicate completion, the NIC driver must call ProtocolOpenAdapterComplete through NdisCompleteOpenAdapter. The NDIS interface library links the binding block into the NIC and transport driver block binding lists.

ProtocolOpenAdapterComplete makes appropriate indications to the transport driver bound to the open network interface card. The driver can then request a number of network activities involving the network interface card, such as sending data, copying data received by the network interface card, querying and setting NIC driver capabilities, and closing the network interface card. For more information about these activities, see Sections A.3.4 through A.3.9.