4.5 TDI Library Functions and Macros
Windows NT provides a small set of TDI library functions as a kernel-mode dynamic-link library (the tdi.sys export library) with which TDI drivers and kernel-mode clients link themselves. However, most of the system-supplied TdiBuildXxx called by kernel-mode clients are implemented as macros in the tdikrnl.h header that both clients and transports include.
Any kernel-mode TDI client can use the TdiBuildXxx macros as needed in preparing the TDI_XXX IOCTL IRPs, already mentioned in Section 4.3. After the client has set up such an IRP with a TdiBuildXxx macro, it submits the request to the underlying TDI driver by passing the IRP to IoCallDriver. Each of these macros fills in the relevant members of the client-provided IRP, except for the Status and Information members, which the underlying transport fills in after processing its client's request. Before using one of TdiBuildXxx IOCTL macros, a client can call TdiBuildInternalDeviceControlIrp to allocate the IRP if it has not already been allocated by a still higher level network component and given to the client.
A transport driver never uses the TdiBuildXxx macros. However, a TDI driver can use some of the remaining TDI library routines, such as TdiCompleteRequest and TdiCopyBufferToMdl, for assistance in processing client requests.
TDI library routines and macros include the following:
TdiBuildInternalDeviceControlIrp
Allocates an IRP if the client does not receive an IRP from a higher network layer.
Sets up an IRP for a client-submitted TDI_ACCEPT request.
Sets up an IRP for a client-submitted TDI_ACTION request.
Sets up an IRP for a client-submitted TDI_ASSOCIATE_ADDRESS request.
Sets up an IRP for a client-submitted TDI_CONNECT request.
Sets up an IRP for a client-submitted TDI_DISASSOCIATE_ADDRESS request.
Sets up an IRP for a client-submitted TDI_LISTEN request.
Sets up an IRP for a client-submitted TDI_QUERY_INFORMATION request.
Sets up an IRP for a client-submitted TDI_RECEIVE request.
Sets up an IRP for a client-submitted TDI_RECEIVE_DATAGRAM request.
Sets up an IRP for a client-submitted TDI_SEND request.
Sets up an IRP for a client-submitted TDI_SEND_DATAGRAM request.
Sets up an IRP for a client-submitted TDI_SET_EVENT_HANDLER request.
Sets up an IRP for a client-submitted TDI_SET_INFORMATION request.
Sets up a NetBIOS address for a client.
Sets up a buffered NetBIOS address that a client can pass subsequently to ZwCreateFile to open the address.
Relinquishes control of the buffer that was passed to a ClientEventChainedReceive(Xxx) handler after the client has consumed the received TSDU.
Copies a range of buffered data into a destination buffer mapped by a given MDL.
Both clients and transports can use this function.
Copies data from buffer(s) mapped by a given MDL into a caller-supplied destination buffer.
Both clients and transports can use this function.
Safely copies received data indicated to the transport by a NIC driver, whatever the nature of the memory (including mapped device memory) the NIC is using.
Converts an IRP passed in to a transport's TdiDispatchDeviceControl routine into a TDI_XXX IOCTL IRP if TdiMapUserRequest recognizes the minor function code specified in the input IRP.
Completes an IRP with the system-defined network-specific priority boost for a transport driver.