2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
4 * FILE: include/titypes.h
5 * PURPOSE: TCP/IP protocol driver types
15 #define DEBUG_REFCHECK(Object) { \
16 if ((Object)->RefCount <= 0) { \
17 TI_DbgPrint(MIN_TRACE, ("Object at (0x%X) has invalid reference count (%d).\n", \
18 (Object), (Object)->RefCount)); \
24 #define DEBUG_REFCHECK(Object)
30 * VOID ReferenceObject(
33 #define ReferenceObject(Object) \
35 DEBUG_REFCHECK(Object); \
36 TI_DbgPrint(DEBUG_REFCOUNT, ("Referencing object at (0x%X). RefCount (%d).\n", \
37 (Object), (Object)->RefCount)); \
39 InterlockedIncrement(&((Object)->RefCount)); \
43 * VOID DereferenceObject(
46 #define DereferenceObject(Object) \
48 DEBUG_REFCHECK(Object); \
49 TI_DbgPrint(DEBUG_REFCOUNT, ("Dereferencing object at (0x%X). RefCount (%d).\n", \
50 (Object), (Object)->RefCount)); \
52 if (InterlockedDecrement(&((Object)->RefCount)) == 0) \
53 PoolFreeBuffer(Object); \
57 typedef NTSTATUS (*DATAGRAM_SEND_ROUTINE
)(
59 PTDI_CONNECTION_INFORMATION ConnInfo
,
63 /* Datagram completion handler prototype */
64 typedef VOID (*DATAGRAM_COMPLETION_ROUTINE
)(
69 typedef struct _DATAGRAM_RECEIVE_REQUEST
{
70 LIST_ENTRY ListEntry
; /* Entry on list */
71 PIP_ADDRESS RemoteAddress
; /* Remote address we receive from (NULL means any) */
72 USHORT RemotePort
; /* Remote port we receive from (0 means any) */
73 PTDI_CONNECTION_INFORMATION ReturnInfo
; /* Return information */
74 PNDIS_BUFFER Buffer
; /* Pointer to receive buffer */
75 ULONG BufferSize
; /* Size of Buffer */
76 DATAGRAM_COMPLETION_ROUTINE Complete
; /* Completion routine */
77 PVOID Context
; /* Pointer to context information */
78 } DATAGRAM_RECEIVE_REQUEST
, *PDATAGRAM_RECEIVE_REQUEST
;
80 /* Datagram build routine prototype */
81 typedef NTSTATUS (*DATAGRAM_BUILD_ROUTINE
)(
83 PIP_ADDRESS LocalAddress
,
85 PIP_PACKET
*IPPacket
);
87 typedef struct _DATAGRAM_SEND_REQUEST
{
88 LIST_ENTRY ListEntry
; /* Entry on list */
89 PIP_ADDRESS RemoteAddress
; /* Pointer to remote IP address */
90 USHORT RemotePort
; /* Remote port number */
91 PNDIS_BUFFER Buffer
; /* Pointer to NDIS buffer to send */
92 DWORD BufferSize
; /* Size of Buffer */
93 DATAGRAM_COMPLETION_ROUTINE Complete
; /* Completion routine */
94 PVOID Context
; /* Pointer to context information */
95 DATAGRAM_BUILD_ROUTINE Build
; /* Datagram build routine */
96 } DATAGRAM_SEND_REQUEST
, *PDATAGRAM_SEND_REQUEST
;
99 /* Transport (TCP/UDP) endpoint context structure. The FileObject->FsContext
100 field holds a pointer to this structure */
101 typedef struct _TRANSPORT_CONTEXT
{
103 HANDLE AddressHandle
;
104 CONNECTION_CONTEXT ConnectionContext
;
105 HANDLE ControlChannel
;
110 } TRANSPORT_CONTEXT
, *PTRANSPORT_CONTEXT
;
113 typedef struct _ADDRESS_FILE
{
114 LIST_ENTRY ListEntry
; /* Entry on list */
115 KSPIN_LOCK Lock
; /* Spin lock to manipulate this structure */
116 ULONG RefCount
; /* Number of references to this object */
117 USHORT Flags
; /* Flags for address file (see below) */
118 PADDRESS_ENTRY ADE
; /* Associated address entry */
119 USHORT Protocol
; /* Protocol number */
120 USHORT Port
; /* Network port (network byte order) */
121 WORK_QUEUE_ITEM WorkItem
; /* Work queue item handle */
122 DATAGRAM_COMPLETION_ROUTINE Complete
; /* Completion routine for delete request */
123 PVOID Context
; /* Delete request context */
124 DATAGRAM_SEND_ROUTINE Send
; /* Routine to send a datagram */
125 LIST_ENTRY ReceiveQueue
; /* List of outstanding receive requests */
126 LIST_ENTRY TransmitQueue
; /* List of outstanding transmit requests */
127 PIP_ADDRESS AddrCache
; /* One entry address cache (destination
128 address of last packet transmitted) */
130 /* The following members are used to control event notification */
132 /* Connection indication handler */
133 PTDI_IND_CONNECT ConnectionHandler
;
134 PVOID ConnectionHandlerContext
;
135 BOOL RegisteredConnectionHandler
;
136 /* Disconnect indication handler */
137 PTDI_IND_DISCONNECT DisconnectHandler
;
138 PVOID DisconnectHandlerContext
;
139 BOOL RegisteredDisconnectHandler
;
140 /* Receive indication handler */
141 PTDI_IND_RECEIVE ReceiveHandler
;
142 PVOID ReceiveHandlerContext
;
143 BOOL RegisteredReceiveHandler
;
144 /* Expedited receive indication handler */
145 PTDI_IND_RECEIVE_EXPEDITED ExpeditedReceiveHandler
;
146 PVOID ExpeditedReceiveHandlerContext
;
147 BOOL RegisteredExpeditedReceiveHandler
;
148 /* Receive datagram indication handler */
149 PTDI_IND_RECEIVE_DATAGRAM ReceiveDatagramHandler
;
150 PVOID ReceiveDatagramHandlerContext
;
151 BOOL RegisteredReceiveDatagramHandler
;
152 /* Error indication handler */
153 PTDI_IND_ERROR ErrorHandler
;
154 PVOID ErrorHandlerContext
;
155 PVOID ErrorHandlerOwner
;
156 BOOL RegisteredErrorHandler
;
157 } ADDRESS_FILE
, *PADDRESS_FILE
;
159 /* Address File Flag constants */
160 #define AFF_VALID 0x0001 /* Address file object is valid for use */
161 #define AFF_BUSY 0x0002 /* Address file object is exclusive to someone */
162 #define AFF_DELETE 0x0004 /* Address file object is sheduled to be deleted */
163 #define AFF_SEND 0x0008 /* A send request is pending */
164 #define AFF_RECEIVE 0x0010 /* A receive request is pending */
165 #define AFF_PENDING 0x001C /* A request is pending */
167 /* Macros for manipulating address file object flags */
169 #define AF_IS_VALID(ADF) ((ADF)->Flags & AFF_VALID)
170 #define AF_SET_VALID(ADF) ((ADF)->Flags |= AFF_VALID)
171 #define AF_CLR_VALID(ADF) ((ADF)->Flags &= ~AFF_VALID)
173 #define AF_IS_BUSY(ADF) ((ADF)->Flags & AFF_BUSY)
174 #define AF_SET_BUSY(ADF) ((ADF)->Flags |= AFF_BUSY)
175 #define AF_CLR_BUSY(ADF) ((ADF)->Flags &= ~AFF_BUSY)
177 #define AF_IS_PENDING(ADF, X) (ADF->Flags & X)
178 #define AF_SET_PENDING(ADF, X) (ADF->Flags |= X)
179 #define AF_CLR_PENDING(ADF, X) (ADF->Flags &= ~X)
182 /* Structure used to search through Address Files */
183 typedef struct _AF_SEARCH
{
184 PLIST_ENTRY Next
; /* Next address file to check */
185 PIP_ADDRESS Address
; /* Pointer to address to be found */
186 USHORT Port
; /* Network port */
187 USHORT Protocol
; /* Protocol number */
188 } AF_SEARCH
, *PAF_SEARCH
;
190 /* Transport connection context structure. The FileObject->FsContext2
191 field holds a pointer to this structure */
192 typedef struct _CONNECTION_ENDPOINT
{
193 LIST_ENTRY ListEntry
; /* Entry on list */
194 KSPIN_LOCK Lock
; /* Spin lock to protect this structure */
195 ULONG RefCount
; /* Number of references to this object */
196 } CONNECTION_ENDPOINT
, *PCONNECTION_ENDPOINT
;
198 /* Transport control channel context structure. The FileObject->FsContext2
199 field holds a pointer to this structure */
200 typedef struct _CONTROL_CHANNEL
{
201 LIST_ENTRY ListEntry
; /* Entry on list */
202 KSPIN_LOCK Lock
; /* Spin lock to protect this structure */
203 ULONG RefCount
; /* Number of references to this object */
204 } CONTROL_CHANNEL
, *PCONTROL_CHANNEL
;
206 typedef struct _TI_QUERY_CONTEXT
{
210 TCP_REQUEST_QUERY_INFORMATION_EX QueryInfo
;
211 } TI_QUERY_CONTEXT
, *PTI_QUERY_CONTEXT
;
213 #endif /* __TITYPES_H */