Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentitypes.h
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS TCP/IP protocol driver 00004 * FILE: include/titypes.h 00005 * PURPOSE: TCP/IP protocol driver types 00006 */ 00007 00008 #pragma once 00009 00010 /* 00011 * VOID ReferenceObject( 00012 * PVOID Object) 00013 */ 00014 #define ReferenceObject(Object) \ 00015 { \ 00016 InterlockedIncrement(&((Object)->RefCount)); \ 00017 } 00018 00019 /* 00020 * VOID DereferenceObject( 00021 * PVOID Object) 00022 */ 00023 #define DereferenceObject(Object) \ 00024 { \ 00025 if (InterlockedDecrement(&((Object)->RefCount)) == 0) \ 00026 (((Object)->Free)(Object)); \ 00027 } 00028 00029 /* 00030 * VOID LockObject(PVOID Object, PKIRQL OldIrql) 00031 */ 00032 #define LockObject(Object, Irql) \ 00033 { \ 00034 ReferenceObject(Object); \ 00035 KeAcquireSpinLock(&((Object)->Lock), Irql); \ 00036 memcpy(&(Object)->OldIrql, Irql, sizeof(KIRQL)); \ 00037 } 00038 00039 /* 00040 * VOID LockObjectAtDpcLevel(PVOID Object) 00041 */ 00042 #define LockObjectAtDpcLevel(Object) \ 00043 { \ 00044 ReferenceObject(Object); \ 00045 KeAcquireSpinLockAtDpcLevel(&((Object)->Lock)); \ 00046 (Object)->OldIrql = DISPATCH_LEVEL; \ 00047 } 00048 00049 /* 00050 * VOID UnlockObject(PVOID Object, KIRQL OldIrql) 00051 */ 00052 #define UnlockObject(Object, OldIrql) \ 00053 { \ 00054 KeReleaseSpinLock(&((Object)->Lock), OldIrql); \ 00055 DereferenceObject(Object); \ 00056 } 00057 00058 /* 00059 * VOID UnlockObjectFromDpcLevel(PVOID Object) 00060 */ 00061 #define UnlockObjectFromDpcLevel(Object) \ 00062 { \ 00063 KeReleaseSpinLockFromDpcLevel(&((Object)->Lock)); \ 00064 DereferenceObject(Object); \ 00065 } 00066 00067 00068 00069 #include <ip.h> 00070 00071 struct _ADDRESS_FILE; 00072 00073 /*************************************************** 00074 * Connection-less communication support structures * 00075 ***************************************************/ 00076 00077 typedef NTSTATUS (*DATAGRAM_SEND_ROUTINE)( 00078 struct _ADDRESS_FILE *AddrFile, 00079 PTDI_CONNECTION_INFORMATION ConnInfo, 00080 PCHAR Buffer, 00081 ULONG DataSize, 00082 PULONG DataUsed); 00083 00084 /* Datagram completion handler prototype */ 00085 typedef VOID (*DATAGRAM_COMPLETION_ROUTINE)( 00086 PVOID Context, 00087 NDIS_STATUS Status, 00088 ULONG Count); 00089 00090 typedef DATAGRAM_COMPLETION_ROUTINE PDATAGRAM_COMPLETION_ROUTINE; 00091 00092 typedef struct _DATAGRAM_RECEIVE_REQUEST { 00093 struct _ADDRESS_FILE *AddressFile; /* AddressFile on behalf of */ 00094 LIST_ENTRY ListEntry; /* Entry on list */ 00095 IP_ADDRESS RemoteAddress; /* Remote address we receive from (NULL means any) */ 00096 USHORT RemotePort; /* Remote port we receive from (0 means any) */ 00097 PTDI_CONNECTION_INFORMATION ReturnInfo;/* Return information */ 00098 PCHAR Buffer; /* Pointer to receive buffer */ 00099 ULONG BufferSize; /* Size of Buffer */ 00100 DATAGRAM_COMPLETION_ROUTINE Complete; /* Completion routine */ 00101 PVOID Context; /* Pointer to context information */ 00102 DATAGRAM_COMPLETION_ROUTINE UserComplete; /* Completion routine */ 00103 PVOID UserContext; /* Pointer to context information */ 00104 PIRP Irp; /* IRP on behalf of */ 00105 } DATAGRAM_RECEIVE_REQUEST, *PDATAGRAM_RECEIVE_REQUEST; 00106 00107 /* Datagram build routine prototype */ 00108 typedef NTSTATUS (*DATAGRAM_BUILD_ROUTINE)( 00109 PVOID Context, 00110 PIP_ADDRESS LocalAddress, 00111 USHORT LocalPort, 00112 PIP_PACKET *IPPacket); 00113 00114 typedef struct _DATAGRAM_SEND_REQUEST { 00115 LIST_ENTRY ListEntry; 00116 PNDIS_PACKET PacketToSend; 00117 DATAGRAM_COMPLETION_ROUTINE Complete; /* Completion routine */ 00118 PVOID Context; /* Pointer to context information */ 00119 IP_PACKET Packet; 00120 UINT BufferSize; 00121 IP_ADDRESS RemoteAddress; 00122 USHORT RemotePort; 00123 ULONG Flags; /* Protocol specific flags */ 00124 } DATAGRAM_SEND_REQUEST, *PDATAGRAM_SEND_REQUEST; 00125 00126 /* Transport address file context structure. The FileObject->FsContext2 00127 field holds a pointer to this structure */ 00128 typedef struct _ADDRESS_FILE { 00129 LIST_ENTRY ListEntry; /* Entry on list */ 00130 LONG RefCount; /* Reference count */ 00131 OBJECT_FREE_ROUTINE Free; /* Routine to use to free resources for the object */ 00132 KSPIN_LOCK Lock; /* Spin lock to manipulate this structure */ 00133 KIRQL OldIrql; /* Currently not used */ 00134 IP_ADDRESS Address; /* Address of this address file */ 00135 USHORT Family; /* Address family */ 00136 USHORT Protocol; /* Protocol number */ 00137 USHORT Port; /* Network port (network byte order) */ 00138 UCHAR TTL; /* Time to live stored in packets sent from this address file */ 00139 UINT DF; /* Don't fragment */ 00140 UINT BCast; /* Receive broadcast packets */ 00141 UINT HeaderIncl; /* Include header in RawIP packets */ 00142 WORK_QUEUE_ITEM WorkItem; /* Work queue item handle */ 00143 DATAGRAM_COMPLETION_ROUTINE Complete; /* Completion routine for delete request */ 00144 PVOID Context; /* Delete request context */ 00145 DATAGRAM_SEND_ROUTINE Send; /* Routine to send a datagram */ 00146 LIST_ENTRY ReceiveQueue; /* List of outstanding receive requests */ 00147 LIST_ENTRY TransmitQueue; /* List of outstanding transmit requests */ 00148 struct _CONNECTION_ENDPOINT *Connection; 00149 /* Associated connection or NULL if no associated connection exist */ 00150 struct _CONNECTION_ENDPOINT *Listener; 00151 /* Associated listener (see transport/tcp/accept.c) */ 00152 IP_ADDRESS AddrCache; /* One entry address cache (destination 00153 address of last packet transmitted) */ 00154 00155 /* The following members are used to control event notification */ 00156 00157 /* Connection indication handler */ 00158 PTDI_IND_CONNECT ConnectHandler; 00159 PVOID ConnectHandlerContext; 00160 BOOLEAN RegisteredConnectHandler; 00161 /* Disconnect indication handler */ 00162 PTDI_IND_DISCONNECT DisconnectHandler; 00163 PVOID DisconnectHandlerContext; 00164 BOOLEAN RegisteredDisconnectHandler; 00165 /* Error indication handler */ 00166 PTDI_IND_ERROR ErrorHandler; 00167 PVOID ErrorHandlerContext; 00168 PVOID ErrorHandlerOwner; 00169 BOOLEAN RegisteredErrorHandler; 00170 /* Receive indication handler */ 00171 PTDI_IND_RECEIVE ReceiveHandler; 00172 PVOID ReceiveHandlerContext; 00173 BOOLEAN RegisteredReceiveHandler; 00174 /* Receive datagram indication handler */ 00175 PTDI_IND_RECEIVE_DATAGRAM ReceiveDatagramHandler; 00176 PVOID ReceiveDatagramHandlerContext; 00177 BOOLEAN RegisteredReceiveDatagramHandler; 00178 /* Expedited receive indication handler */ 00179 PTDI_IND_RECEIVE_EXPEDITED ExpeditedReceiveHandler; 00180 PVOID ExpeditedReceiveHandlerContext; 00181 BOOLEAN RegisteredExpeditedReceiveHandler; 00182 /* Chained receive indication handler */ 00183 PTDI_IND_CHAINED_RECEIVE ChainedReceiveHandler; 00184 PVOID ChainedReceiveHandlerContext; 00185 BOOLEAN RegisteredChainedReceiveHandler; 00186 /* Chained receive datagram indication handler */ 00187 PTDI_IND_CHAINED_RECEIVE_DATAGRAM ChainedReceiveDatagramHandler; 00188 PVOID ChainedReceiveDatagramHandlerContext; 00189 BOOLEAN RegisteredChainedReceiveDatagramHandler; 00190 /* Chained expedited receive indication handler */ 00191 PTDI_IND_CHAINED_RECEIVE_EXPEDITED ChainedReceiveExpeditedHandler; 00192 PVOID ChainedReceiveExpeditedHandlerContext; 00193 BOOLEAN RegisteredChainedReceiveExpeditedHandler; 00194 } ADDRESS_FILE, *PADDRESS_FILE; 00195 00196 /* Structure used to search through Address Files */ 00197 typedef struct _AF_SEARCH { 00198 PLIST_ENTRY Next; /* Next address file to check */ 00199 PIP_ADDRESS Address; /* Pointer to address to be found */ 00200 USHORT Port; /* Network port */ 00201 USHORT Protocol; /* Protocol number */ 00202 } AF_SEARCH, *PAF_SEARCH; 00203 00204 /******************************************************* 00205 * Connection-oriented communication support structures * 00206 *******************************************************/ 00207 00208 typedef struct _TCP_RECEIVE_REQUEST { 00209 LIST_ENTRY ListEntry; /* Entry on list */ 00210 PNDIS_BUFFER Buffer; /* Pointer to receive buffer */ 00211 ULONG BufferSize; /* Size of Buffer */ 00212 DATAGRAM_COMPLETION_ROUTINE Complete; /* Completion routine */ 00213 PVOID Context; /* Pointer to context information */ 00214 } TCP_RECEIVE_REQUEST, *PTCP_RECEIVE_REQUEST; 00215 00216 /* Connection states */ 00217 typedef enum { 00218 ctListen = 0, /* Waiting for incoming connection requests */ 00219 ctSynSent, /* Waiting for matching connection request */ 00220 ctSynReceived, /* Waiting for connection request acknowledgment */ 00221 ctEstablished, /* Connection is open for data transfer */ 00222 ctFinWait1, /* Waiting for termination request or ack. for same */ 00223 ctFinWait2, /* Waiting for termination request from remote TCP */ 00224 ctCloseWait, /* Waiting for termination request from local user */ 00225 ctClosing, /* Waiting for termination ack. from remote TCP */ 00226 ctLastAck, /* Waiting for termination request ack. from remote TCP */ 00227 ctTimeWait, /* Waiting for enough time to pass to be sure the remote TCP 00228 received the ack. of its connection termination request */ 00229 ctClosed /* Represents a closed connection */ 00230 } CONNECTION_STATE, *PCONNECTION_STATE; 00231 00232 00233 /* Structure for an TCP segment */ 00234 typedef struct _TCP_SEGMENT { 00235 LIST_ENTRY ListEntry; 00236 PIP_PACKET IPPacket; /* Pointer to IP packet */ 00237 PVOID SegmentData; /* Pointer to segment data */ 00238 ULONG SequenceNumber; /* Sequence number of first byte in segment */ 00239 ULONG Length; /* Number of bytes in segment */ 00240 ULONG BytesDelivered; /* Number of bytes already delivered to the client */ 00241 } TCP_SEGMENT, *PTCP_SEGMENT; 00242 00243 typedef struct _TDI_BUCKET { 00244 LIST_ENTRY Entry; 00245 struct _CONNECTION_ENDPOINT *AssociatedEndpoint; 00246 TDI_REQUEST Request; 00247 NTSTATUS Status; 00248 ULONG Information; 00249 } TDI_BUCKET, *PTDI_BUCKET; 00250 00251 /* Transport connection context structure A.K.A. Transmission Control Block 00252 (TCB) in TCP terminology. The FileObject->FsContext2 field holds a pointer 00253 to this structure */ 00254 typedef struct _CONNECTION_ENDPOINT { 00255 PVOID SocketContext; /* Context for lower layer (MUST be first member in struct) */ 00256 LIST_ENTRY ListEntry; /* Entry on list */ 00257 LONG RefCount; /* Reference count */ 00258 OBJECT_FREE_ROUTINE Free; /* Routine to use to free resources for the object */ 00259 KSPIN_LOCK Lock; /* Spin lock to protect this structure */ 00260 KIRQL OldIrql; /* The old irql is stored here for use in HandleSignalledConnection */ 00261 PVOID ClientContext; /* Pointer to client context information */ 00262 PADDRESS_FILE AddressFile; /* Associated address file object (NULL if none) */ 00263 00264 /* Requests */ 00265 LIST_ENTRY ConnectRequest; /* Queued connect rqueusts */ 00266 LIST_ENTRY ListenRequest; /* Queued listen requests */ 00267 LIST_ENTRY ReceiveRequest; /* Queued receive requests */ 00268 LIST_ENTRY SendRequest; /* Queued send requests */ 00269 LIST_ENTRY ShutdownRequest;/* Queued shutdown requests */ 00270 00271 LIST_ENTRY PacketQueue; /* Queued received packets waiting to be processed */ 00272 00273 /* Disconnect Timer */ 00274 KTIMER DisconnectTimer; 00275 KDPC DisconnectDpc; 00276 00277 /* Socket state */ 00278 BOOLEAN SendShutdown; 00279 BOOLEAN ReceiveShutdown; 00280 00281 struct _CONNECTION_ENDPOINT *Next; /* Next connection in address file list */ 00282 } CONNECTION_ENDPOINT, *PCONNECTION_ENDPOINT; 00283 00284 00285 00286 /************************* 00287 * TDI support structures * 00288 *************************/ 00289 00290 /* Transport control channel context structure. The FileObject->FsContext2 00291 field holds a pointer to this structure */ 00292 typedef struct _CONTROL_CHANNEL { 00293 LIST_ENTRY ListEntry; /* Entry on list */ 00294 LONG RefCount; /* Reference count */ 00295 OBJECT_FREE_ROUTINE Free; /* Routine to use to free resources for the object */ 00296 KSPIN_LOCK Lock; /* Spin lock to protect this structure */ 00297 } CONTROL_CHANNEL, *PCONTROL_CHANNEL; 00298 00299 /* Transport (TCP/UDP) endpoint context structure. The FileObject->FsContext 00300 field holds a pointer to this structure */ 00301 typedef struct _TRANSPORT_CONTEXT { 00302 union { 00303 HANDLE AddressHandle; 00304 CONNECTION_CONTEXT ConnectionContext; 00305 HANDLE ControlChannel; 00306 } Handle; 00307 BOOLEAN CancelIrps; 00308 KEVENT CleanupEvent; 00309 } TRANSPORT_CONTEXT, *PTRANSPORT_CONTEXT; 00310 00311 typedef struct _TI_QUERY_CONTEXT { 00312 PIRP Irp; 00313 PMDL InputMdl; 00314 PMDL OutputMdl; 00315 TCP_REQUEST_QUERY_INFORMATION_EX QueryInfo; 00316 } TI_QUERY_CONTEXT, *PTI_QUERY_CONTEXT; 00317 00318 /* EOF */ Generated on Sun May 27 2012 04:28:07 for ReactOS by
1.7.6.1
|