Fix firefox exit. Implement a simple work queue for possibly dispatch level
[reactos.git] / reactos / drivers / net / tcpip / include / titypes.h
index b2cbfc3..c75586d 100644 (file)
@@ -65,7 +65,7 @@
 #else /* DBG */
 
 #define DEFINE_TAG
-#define INIT_TAG (Object, Tag)
+#define INIT_TAG(Object, Tag)
 
 /*
  * VOID ReferenceObject(
 
 #include <ip.h>
 
+struct _ADDRESS_FILE;
 
 /***************************************************
 * Connection-less communication support structures *
 ***************************************************/
 
 typedef NTSTATUS (*DATAGRAM_SEND_ROUTINE)(
-    PTDI_REQUEST Request,
+    struct _ADDRESS_FILE *AddrFile,
     PTDI_CONNECTION_INFORMATION ConnInfo,
-    PNDIS_BUFFER Buffer,
-    ULONG DataSize);
+    PCHAR Buffer,
+    ULONG DataSize,
+    PULONG DataUsed);
 
 /* Datagram completion handler prototype */
 typedef VOID (*DATAGRAM_COMPLETION_ROUTINE)(
@@ -108,15 +110,19 @@ typedef VOID (*DATAGRAM_COMPLETION_ROUTINE)(
     NDIS_STATUS Status,
     ULONG Count);
 
+typedef DATAGRAM_COMPLETION_ROUTINE PDATAGRAM_COMPLETION_ROUTINE;
+
 typedef struct _DATAGRAM_RECEIVE_REQUEST {
-    LIST_ENTRY ListEntry;                   /* Entry on list */
-    PIP_ADDRESS RemoteAddress;              /* Remote address we receive from (NULL means any) */
-    USHORT RemotePort;                      /* Remote port we receive from (0 means any) */
-    PTDI_CONNECTION_INFORMATION ReturnInfo; /* Return information */
-    PNDIS_BUFFER Buffer;                    /* Pointer to receive buffer */
-    ULONG BufferSize;                       /* Size of Buffer */
-    DATAGRAM_COMPLETION_ROUTINE Complete;   /* Completion routine */
-    PVOID Context;                          /* Pointer to context information */
+    LIST_ENTRY ListEntry;                  /* Entry on list */
+    IP_ADDRESS RemoteAddress;              /* Remote address we receive from (NULL means any) */
+    USHORT RemotePort;                     /* Remote port we receive from (0 means any) */
+    PTDI_CONNECTION_INFORMATION ReturnInfo;/* Return information */
+    PCHAR Buffer;                          /* Pointer to receive buffer */
+    ULONG BufferSize;                      /* Size of Buffer */
+    DATAGRAM_COMPLETION_ROUTINE Complete;  /* Completion routine */
+    PVOID Context;                         /* Pointer to context information */
+    DATAGRAM_COMPLETION_ROUTINE UserComplete;   /* Completion routine */
+    PVOID UserContext;                     /* Pointer to context information */
 } DATAGRAM_RECEIVE_REQUEST, *PDATAGRAM_RECEIVE_REQUEST;
 
 /* Datagram build routine prototype */
@@ -127,47 +133,27 @@ typedef NTSTATUS (*DATAGRAM_BUILD_ROUTINE)(
     PIP_PACKET *IPPacket);
 
 typedef struct _DATAGRAM_SEND_REQUEST {
-    LIST_ENTRY ListEntry;                 /* Entry on list */
-    PIP_ADDRESS RemoteAddress;            /* Pointer to remote IP address */
-    USHORT RemotePort;                    /* Remote port number */
-    PNDIS_BUFFER Buffer;                  /* Pointer to NDIS buffer to send */
-    DWORD BufferSize;                     /* Size of Buffer */
+    LIST_ENTRY ListEntry;
+    PNDIS_PACKET PacketToSend;
     DATAGRAM_COMPLETION_ROUTINE Complete; /* Completion routine */
     PVOID Context;                        /* Pointer to context information */
-    DATAGRAM_BUILD_ROUTINE Build;         /* Datagram build routine */
+    IP_PACKET Packet;
+    UINT BufferSize;
+    IP_ADDRESS RemoteAddress;
+    USHORT RemotePort;
     ULONG Flags;                          /* Protocol specific flags */
 } DATAGRAM_SEND_REQUEST, *PDATAGRAM_SEND_REQUEST;
 
-#define InitializeDatagramSendRequest( \
-  _SendRequest, \
-  _RemoteAddress, \
-  _RemotePort, \
-  _Buffer, \
-  _BufferSize, \
-  _Complete, \
-  _Context, \
-  _Build, \
-  _Flags) { \
-    (_SendRequest)->RemoteAddress = (_RemoteAddress); \
-    (_SendRequest)->RemotePort = (_RemotePort); \
-    (_SendRequest)->Buffer = (_Buffer); \
-    (_SendRequest)->BufferSize = (_BufferSize); \
-    (_SendRequest)->Complete = (_Complete); \
-    (_SendRequest)->Context = (_Context); \
-    (_SendRequest)->Build = (_Build); \
-    (_SendRequest)->Flags = (_Flags); \
-  }
-
 /* Transport address file context structure. The FileObject->FsContext2
    field holds a pointer to this structure */
 typedef struct _ADDRESS_FILE {
     DEFINE_TAG
     LIST_ENTRY ListEntry;                 /* Entry on list */
     KSPIN_LOCK Lock;                      /* Spin lock to manipulate this structure */
-    ULONG RefCount;                       /* Number of references to this object */
     OBJECT_FREE_ROUTINE Free;             /* Routine to use to free resources for the object */
     USHORT Flags;                         /* Flags for address file (see below) */
-    PADDRESS_ENTRY ADE;                   /* Associated address entry */
+    IP_ADDRESS Address;                   /* Address of this address file */
+    USHORT Family;                        /* Address family */
     USHORT Protocol;                      /* Protocol number */
     USHORT Port;                          /* Network port (network byte order) */
     WORK_QUEUE_ITEM WorkItem;             /* Work queue item handle */
@@ -177,9 +163,10 @@ typedef struct _ADDRESS_FILE {
     LIST_ENTRY ReceiveQueue;              /* List of outstanding receive requests */
     LIST_ENTRY TransmitQueue;             /* List of outstanding transmit requests */
     struct _CONNECTION_ENDPOINT *Connection;
-                                          /* Associated connection or NULL if no
-                                             associated connection exist */
-    PIP_ADDRESS AddrCache;                /* One entry address cache (destination
+    /* Associated connection or NULL if no associated connection exist */
+    struct _CONNECTION_ENDPOINT *Listener;
+    /* Associated listener (see transport/tcp/accept.c) */
+    IP_ADDRESS AddrCache;                 /* One entry address cache (destination
                                              address of last packet transmitted) */
 
     /* The following members are used to control event notification */
@@ -254,32 +241,17 @@ typedef struct _AF_SEARCH {
     USHORT Protocol;        /* Protocol number */
 } AF_SEARCH, *PAF_SEARCH;
 
-
-
 /*******************************************************
 * Connection-oriented communication support structures *
 *******************************************************/
 
-typedef struct _TCP_SEND_REQUEST {
+typedef struct _TCP_RECEIVE_REQUEST {
   LIST_ENTRY ListEntry;                 /* Entry on list */
+  PNDIS_BUFFER Buffer;                  /* Pointer to receive buffer */
+  ULONG BufferSize;                     /* Size of Buffer */
   DATAGRAM_COMPLETION_ROUTINE Complete; /* Completion routine */
   PVOID Context;                        /* Pointer to context information */
-  PVOID ProtocolContext;                /* Protocol specific context */
-  ULONG Flags;                          /* Protocol specific flags */
-  ULONG SequenceNumber;                 /* Sequence number (network byte order) */
-  ULONG AckNumber;                      /* Acknowledgement number (network byte order) */
-} TCP_SEND_REQUEST, *PTCP_SEND_REQUEST;
-
-#define InitializeTCPSendRequest( \
-  _SendRequest, \
-  _Complete, \
-  _Context, \
-  _ProtocolContext) { \
-    (_SendRequest)->Complete = (_Complete); \
-    (_SendRequest)->Context = (_Context); \
-    (_SendRequest)->ProtocolContext = (_ProtocolContext); \
-  }
-
+} TCP_RECEIVE_REQUEST, *PTCP_RECEIVE_REQUEST;
 
 /* Connection states */
 typedef enum {
@@ -302,54 +274,42 @@ typedef enum {
 typedef struct _TCP_SEGMENT {
   LIST_ENTRY ListEntry;
   PIP_PACKET IPPacket;        /* Pointer to IP packet */
+  PVOID SegmentData;          /* Pointer to segment data */
   ULONG SequenceNumber;       /* Sequence number of first byte in segment */
   ULONG Length;               /* Number of bytes in segment */
+  ULONG BytesDelivered;       /* Number of bytes already delivered to the client */
 } TCP_SEGMENT, *PTCP_SEGMENT;
 
+typedef struct _TDI_BUCKET {
+    LIST_ENTRY Entry;
+    struct _CONNECTION_ENDPOINT *AssociatedEndpoint;
+    TDI_REQUEST Request;
+} TDI_BUCKET, *PTDI_BUCKET;
 
 /* Transport connection context structure A.K.A. Transmission Control Block
    (TCB) in TCP terminology. The FileObject->FsContext2 field holds a pointer
    to this structure */
 typedef struct _CONNECTION_ENDPOINT {
-  LIST_ENTRY ListEntry;       /* Entry on list */
-  KSPIN_LOCK Lock;            /* Spin lock to protect this structure */
-  ULONG RefCount;             /* Number of references to this object */
-  PVOID ClientContext;        /* Pointer to client context information */
-  PADDRESS_FILE AddressFile;  /* Associated address file object (NULL if none) */
-
-  CONNECTION_STATE State;     /* Connection state */
-
-  PIP_ADDRESS LocalAddress;   /* Pointer to local IP address */
-  USHORT LocalPort;           /* Local port number (network byte order) */
-
-  PIP_ADDRESS RemoteAddress;  /* Pointer to remote IP address */
-  USHORT RemotePort;          /* Remote port number (network byte order) */
-
-  /* Send sequence variables */
-  ULONG SendUnacknowledged;   /* Highest sequence number that is acknowledged */
-  ULONG SendNext;             /* Sequence number of last data block sent */
-  ULONG SendWindow;           /* Maximum allowed number of octets in a segment */
-  ULONG SendUrgentPointer;    /* Sequence number of start of urgent data */
-  ULONG SendWL1;              /* Sequence number used for last window update */
-  ULONG SendWL2;              /* Acknowledgment number used for last window update */
-  ULONG SendISS;              /* Initial send sequence number */
-
-  /* Receive sequence variables */
-  ULONG ReceiveNext;          /* Sequence number of last data block received */
-  ULONG ReceiveWindow;        /* Maximum allowed number of octets in a segment */
-  ULONG ReceiveUrgentPointer; /* Sequence number of start of urgent data */
-  ULONG ReceiveIRS;           /* Initial receive sequence number */
-
-  /* Statistics for computing the retransmission timeout */
-  ULONG TimestampSend;        /* Timestamp when sending a segment */
-  ULONG TimestampAck;         /* Timestamp when receiving acknowledgment */
-
-  /* Requests */
-  PTDI_REQUEST ListenRequest; /* Queued listen request */
-
-  /* Queues */
-  LIST_ENTRY ReceivedSegments;
-
+    LIST_ENTRY ListEntry;       /* Entry on list */
+    KSPIN_LOCK Lock;            /* Spin lock to protect this structure */
+    PVOID ClientContext;        /* Pointer to client context information */
+    PADDRESS_FILE AddressFile;  /* Associated address file object (NULL if none) */
+    PVOID SocketContext;        /* Context for lower layer */
+
+    UINT State;                 /* Socket state W.R.T. oskit */
+
+    /* Requests */
+    LIST_ENTRY ConnectRequest; /* Queued connect rqueusts */
+    LIST_ENTRY ListenRequest;  /* Queued listen requests */
+    LIST_ENTRY ReceiveRequest; /* Queued receive requests */
+
+    /* Signals */
+    LIST_ENTRY SignalList;     /* Entry in the list of sockets waiting for
+                               * notification service to the client */
+    UINT    SignalState;       /* Active signals from oskit */
+    BOOLEAN Signalled;         /* Are we a member of the signal list */
+    BOOLEAN Disconnecting;     /* Cancelling an irp .. we need to leave it 
+                               * alone for now */
 } CONNECTION_ENDPOINT, *PCONNECTION_ENDPOINT;
 
 
@@ -363,7 +323,6 @@ typedef struct _CONNECTION_ENDPOINT {
 typedef struct _CONTROL_CHANNEL {
     LIST_ENTRY ListEntry;       /* Entry on list */
     KSPIN_LOCK Lock;            /* Spin lock to protect this structure */
-    ULONG RefCount;             /* Number of references to this object */
 } CONTROL_CHANNEL, *PCONTROL_CHANNEL;
 
 /* Transport (TCP/UDP) endpoint context structure. The FileObject->FsContext
@@ -374,7 +333,6 @@ typedef struct _TRANSPORT_CONTEXT {
         CONNECTION_CONTEXT ConnectionContext;
         HANDLE ControlChannel;
     } Handle;
-    ULONG RefCount;
     BOOL CancelIrps;
     KEVENT CleanupEvent;
 } TRANSPORT_CONTEXT, *PTRANSPORT_CONTEXT;