📄 tdi.h
字号:
// it is so we can do fast rcv's} TDI_REQUEST, *PTDI_REQUEST;//// Structure for information returned by the TDI provider. This structure is// filled in upon request completion.//typedef struct _TDI_REQUEST_STATUS { TDI_STATUS Status; // status of request completion PVOID RequestContext; // the request Context ULONG BytesTransferred; // number of bytes transferred in the request} TDI_REQUEST_STATUS, *PTDI_REQUEST_STATUS;//// connection primitives information structure. This is passed to the TDI calls// (Accept, Connect, xxx) that do connecting sorts of things.//typedef struct _TDI_CONNECTION_INFORMATION { LONG UserDataLength; // length of user data buffer PVOID UserData; // pointer to user data buffer LONG OptionsLength; // length of follwoing buffer PVOID Options; // pointer to buffer containing options LONG RemoteAddressLength; // length of following buffer PVOID RemoteAddress; // buffer containing the remote address} TDI_CONNECTION_INFORMATION, *PTDI_CONNECTION_INFORMATION;//// structure defining a counted string is defined in// \nt\public\sdk\inc\ntdefs.h as// typedef struct _STRING {// USHORT Length;// USHORT MaximumLength;// PCHAR Buffer;// } STRING;// typedef STRING *PSTRING;// typedef STRING ANSI_STRING;// typedef PSTRING PANSI_STRING;////// Event types that are known//#define TDI_EVENT_CONNECT ((USHORT)0) // TDI_IND_CONNECT event handler.#define TDI_EVENT_DISCONNECT ((USHORT)1) // TDI_IND_DISCONNECT event handler.#define TDI_EVENT_ERROR ((USHORT)2) // TDI_IND_ERROR event handler.#define TDI_EVENT_RECEIVE ((USHORT)3) // TDI_IND_RECEIVE event handler.#define TDI_EVENT_RECEIVE_DATAGRAM ((USHORT)4) // TDI_IND_RECEIVE_DATAGRAM event handler.#define TDI_EVENT_RECEIVE_EXPEDITED ((USHORT)5) // TDI_IND_RECEIVE_EXPEDITED event handler.#define TDI_EVENT_SEND_POSSIBLE ((USHORT)6) // TDI_IND_SEND_POSSIBLE event handler//// Associate Address is done through NtDeviceIoControlFile, which passes this// structure as its input buffer. The Handle specified in the// NtDeviceIoControlFile is the handle of the connection returned in the// NtCreateFile call.//typedef struct _TDI_REQUEST_ASSOCIATE { TDI_REQUEST Request; HANDLE AddressHandle;} TDI_REQUEST_ASSOCIATE_ADDRESS, *PTDI_REQUEST_ASSOCIATE_ADDRESS;//// Disassociate Address passes no structure, uses the request code// IOCTL_TDI_DISASSOCIATE_ADDRESS. This call will never pend.////// Connect is done through NtDeviceIoControlFile, which passes this// structure as its input buffer. The Handle specified in the// NtDeviceIoControlFile is the handle of the connection returned in the// NtCreateFile call.//typedef struct _TDI_CONNECT_REQUEST { TDI_REQUEST Request; PTDI_CONNECTION_INFORMATION RequestConnectionInformation; PTDI_CONNECTION_INFORMATION ReturnConnectionInformation; LARGE_INTEGER Timeout;} TDI_REQUEST_CONNECT, *PTDI_REQUEST_CONNECT;//// Accept is done through NtDeviceIoControlFile, which passes this// structure as its input buffer. The Handle specified in the// NtDeviceIoControlFile is the handle of the connection returned in the// NtCreateFile call. Accept is called by the user when a listen completes,// before any activity can occur on a connection. AcceptConnectionId specifies// the connection on which the connection is accepted; in most cases, this// will be null, which that the connection is to be accepted on the// connection on which the listen completed. If the transport provider supports// "forwarding" of connections (the idea that a particular connection listens// all the time, and creates new connections as needed for incoming connection// requests and attaches them to the listen), this is the mechanism used to// associate connections with the listen.//typedef struct _TDI_REQUEST_ACCEPT { TDI_REQUEST Request; PTDI_CONNECTION_INFORMATION RequestConnectionInformation; PTDI_CONNECTION_INFORMATION ReturnConnectionInformation;} TDI_REQUEST_ACCEPT, *PTDI_REQUEST_ACCEPT;//// Listen is done through NtDeviceIoControlFile, which passes this// structure as its input buffer. The Handle specified in the// NtDeviceIoControlFile is the handle of the connection returned in the// NtCreateFile call. RequestConnectionInformation contains information about// the remote address to be listen for connections from; if NULL, any address// is accepted. ReturnConnectionInformation returns information about the// remote node that actually connected.//typedef struct _TDI_REQUEST_LISTEN { TDI_REQUEST Request; PTDI_CONNECTION_INFORMATION RequestConnectionInformation; PTDI_CONNECTION_INFORMATION ReturnConnectionInformation; USHORT ListenFlags;} TDI_REQUEST_LISTEN, *PTDI_REQUEST_LISTEN;//// Disconnect is done through NtDeviceIoControlFile, which passes this// structure as its input buffer. The Handle specified in the// NtDeviceIoControlFile is the handle of the connection returned in the// NtCreateFile call. Disconnect differs from Close in offering more options.// For example, Close terminates all activity on a connection (immediately),// failing all outstanding requests, and tearing down the connection. With// some providers, Disconnect allows a "graceful" disconnect, causing new activity// to be rejected but allowing old activity to run down to completion.//typedef struct _TDI_DISCONNECT_REQUEST { TDI_REQUEST Request; LARGE_INTEGER Timeout;} TDI_REQUEST_DISCONNECT, *PTDI_REQUEST_DISCONNECT;//// Send is done through NtDeviceIoControlFile, which passes this// structure as its input buffer. The Handle specified in the// NtDeviceIoControlFile is the handle of the connection returned in the// NtCreateFile call. Note that it is possible to Send using the file system's// Write call. This will have the same effect as doing a Send with all flags// set to null.//typedef struct _TDI_REQUEST_SEND { TDI_REQUEST Request; USHORT SendFlags;} TDI_REQUEST_SEND, *PTDI_REQUEST_SEND;//// Receive is done through NtDeviceIoControlFile, which passes this// structure as its input buffer. The Handle specified in the// NtDeviceIoControlFile is the handle of the connection returned in the// NtCreateFile call. Note that it is possible to Receive using the file// system's Read call. Note further that receive returns a number of TDI_STATUS// values, which indicate things such as partial receives.//typedef struct _TDI_REQUEST_RECEIVE { TDI_REQUEST Request; USHORT ReceiveFlags;} TDI_REQUEST_RECEIVE, *PTDI_REQUEST_RECEIVE;//// SendDatagram is done through NtDeviceIoControlFile, which passes this// structure as its input buffer. The Handle specified in the// NtDeviceIoControlFile is the handle of the ADDRESS (note this is// different than above!!) returned in the NtCreateFile call. Send Datagram// specifies the address of the receiver through the SendDatagramInformation// structure, using RemoteAddress to point to the transport address of the// destination of the datagram.//typedef struct _TDI_REQUEST_SEND_DATAGRAM { TDI_REQUEST Request; PTDI_CONNECTION_INFORMATION SendDatagramInformation;} TDI_REQUEST_SEND_DATAGRAM, *PTDI_REQUEST_SEND_DATAGRAM;//// ReceiveDatagram is done through NtDeviceIoControlFile, which passes this// structure as its input buffer. The Handle specified in the// NtDeviceIoControlFile is the handle of the ADDRESS (note this is// different than above!!) returned in the NtCreateFile call. Receive Datagram// specifies the address from which to receive a datagram through the// ReceiveDatagramInformation structure, using RemoteAddress to point to the// transport address of the origin of the datagram. (Broadcast datagrams are// received by making the pointer NULL.) The actual address of the sender of// the datagram is returned in ReturnInformation.//// for the receive datagram call//typedef struct _TDI_REQUEST_RECEIVE_DATAGRAM { TDI_REQUEST Request; PTDI_CONNECTION_INFORMATION ReceiveDatagramInformation; PTDI_CONNECTION_INFORMATION ReturnInformation; USHORT ReceiveFlags;} TDI_REQUEST_RECEIVE_DATAGRAM, *PTDI_REQUEST_RECEIVE_DATAGRAM;//// SetEventHandler is done through NtDeviceIoControlFile, which passes this// structure as its input buffer. The Handle specified in the// NtDeviceIoControlFile is the handle of the ADDRESS (note this is// different than above!!) returned in the NtCreateFile call.typedef struct _TDI_REQUEST_SET_EVENT { TDI_REQUEST Request; LONG EventType; PVOID EventHandler; PVOID EventContext;} TDI_REQUEST_SET_EVENT_HANDLER, *PTDI_REQUEST_SET_EVENT_HANDLER;//// ReceiveIndicator values (from TdiReceive and TdiReceiveDatagram requests,// and also presented at TDI_IND_RECEIVE and TDI_IND_RECEIVE_DATAGRAM time).//// The TDI_RECEIVE_PARTIAL bit is no longer used at the kernel level// interface. TDI_RECEIVE_ENTIRE_MESSAGE has replaced it. Providers// may continue to set TDI_RECEIVE_PARTIAL when appropriate if they so// desire, but the TDI_RECEIVE_ENTIRE_MESSAGE bit must be set or// cleared as appropriate on all receive indications.//#if 0#define TDI_RECEIVE_TRUNCATED 0x00000001 // received TSDU was truncated.#define TDI_RECEIVE_FRAGMENT 0x00000002 // received TSDU was fragmented.#endif#define TDI_RECEIVE_BROADCAST 0x00000004 // received TSDU was broadcast.#define TDI_RECEIVE_MULTICAST 0x00000008 // received TSDU was multicast.#define TDI_RECEIVE_PARTIAL 0x00000010 // received TSDU is not fully presented.#define TDI_RECEIVE_NORMAL 0x00000020 // received TSDU is normal data#define TDI_RECEIVE_EXPEDITED 0x00000040 // received TSDU is expedited data#define TDI_RECEIVE_PEEK 0x00000080 // received TSDU is not released#define TDI_RECEIVE_NO_RESPONSE_EXP 0x00000100 // HINT: no back-traffic expected#define TDI_RECEIVE_COPY_LOOKAHEAD 0x00000200 // for kernel-mode indications#define TDI_RECEIVE_ENTIRE_MESSAGE 0x00000400 // opposite of RECEIVE_PARTIAL // (for kernel-mode indications)#define TDI_RECEIVE_AT_DISPATCH_LEVEL 0x00000800 // receive indication called // at dispatch level//// Listen Flags//#define TDI_QUERY_ACCEPT 0x00000001 // complete TdiListen // without accepting // connection//// Options which are used for both SendOptions and ReceiveIndicators.//#define TDI_SEND_EXPEDITED ((USHORT)0x0020) // TSDU is/was urgent/expedited.#define TDI_SEND_PARTIAL ((USHORT)0x0040) // TSDU is/was terminated by an EOR.#define TDI_SEND_NO_RESPONSE_EXPECTED ((USHORT)0x0080) // HINT: no back traffic expected.#define TDI_SEND_NON_BLOCKING ((USHORT)0x0100) // don't block if no buffer space in protocol//// Disconnect Flags//#define TDI_DISCONNECT_WAIT ((USHORT)0x0001) // used for disconnect // notification#define TDI_DISCONNECT_ABORT ((USHORT)0x0002) // immediately terminate // connection#define TDI_DISCONNECT_RELEASE ((USHORT)0x0004) // initiate graceful // disconnect#define TDI_DISCONNECT_CONFIRM ((USHORT)0x0008) // confirm a graceful // close#define TDI_DISCONNECT_ASYNC ((USHORT)0x0010) // asynchronous // graceful disconnect//// TdiRequest structure for TdiQueryInformation request.//typedef struct _TDI_REQUEST_QUERY_INFORMATION { TDI_REQUEST Request; ULONG QueryType; // class of information to be queried. PTDI_CONNECTION_INFORMATION RequestConnectionInformation;} TDI_REQUEST_QUERY_INFORMATION, *PTDI_REQUEST_QUERY_INFORMATION;//// TdiRequest structure for TdiSetInformation request.//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -