X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FIPStack%2Ftcp.h;h=cf5d8de9033a0a5fb8d3f66539132035f9bc0551;hb=4f1a9b430a3fa57bbe52a6a2fe546f6fe93c389d;hp=cdd3a8f0e99909f3eb49eaa005ebf6f8919ef325;hpb=ede46f1819c8b3c51d04829cac8bd95bcc602d8f;p=tpg%2Facess2.git diff --git a/Modules/IPStack/tcp.h b/Modules/IPStack/tcp.h index cdd3a8f0..cf5d8de9 100644 --- a/Modules/IPStack/tcp.h +++ b/Modules/IPStack/tcp.h @@ -67,7 +67,7 @@ struct sTCPListener tInterface *Interface; //!< Listening Interface tVFS_Node Node; //!< Server Directory node int NextID; //!< Name of the next connection - tSpinlock lConnections; //!< Spinlock for connections + tShortSpinlock lConnections; //!< Spinlock for connections tTCPConnection *Connections; //!< Connections (linked list) tTCPConnection *volatile NewConnections; tTCPConnection *ConnectionsTail; @@ -81,10 +81,30 @@ struct sTCPStoredPacket Uint8 Data[]; }; +enum eTCPConnectionState +{ + TCP_ST_CLOSED, // 0 - Connection invalid + + TCP_ST_SYN_SENT, // 1 - SYN sent by local, waiting for SYN-ACK + TCP_ST_SYN_RCVD, // 2 - SYN recieved, SYN-ACK sent + + TCP_ST_OPEN, // 3 - Connection open + + // Local Close + TCP_ST_FIN_WAIT1, // 4 - FIN sent, waiting for reply (ACK or FIN) + TCP_ST_FIN_WAIT2, // 5 - sent FIN acked, waiting for FIN from peer + TCP_ST_CLOSING, // 6 - Waiting for ACK of FIN (FIN sent and recieved) + TCP_ST_TIME_WAIT, // 7 - Waiting for timeout after local close + // Remote close + TCP_ST_CLOSE_WAIT, // 8 - FIN recieved, waiting for user to close (error set, wait for node close) + TCP_ST_LAST_ACK, // 9 - FIN sent and recieved, waiting for ACK + TCP_ST_FINISHED // 10 - Essentially closed, all packets are invalid +}; + struct sTCPConnection { struct sTCPConnection *Next; - int State; //!< Connection state (see ::eTCPConnectionState) + enum eTCPConnectionState State; //!< Connection state (see ::eTCPConnectionState) Uint16 LocalPort; //!< Local port Uint16 RemotePort; //!< Remote port tInterface *Interface; //!< Listening Interface @@ -93,23 +113,25 @@ struct sTCPConnection Uint32 NextSequenceSend; //!< Next sequence value for outbound packets Uint32 NextSequenceRcv; //!< Next expected sequence value for inbound + #if 0 /** * \brief Non-ACKed packets - * \note FIFO list + * \note Ring buffer * \{ */ - tSpinlock lQueuedPackets; - tTCPStoredPacket *QueuedPackets; //!< Non-ACKed packets + tMutex lNonACKedPackets; + tTCPStoredPacket *SentPackets; //!< Non-acknowleged packets /** * \} */ + #endif /** * \brief Unread Packets * \note Ring buffer * \{ */ - tSpinlock lRecievedPackets; + tMutex lRecievedPackets; tRingBuffer *RecievedBuffer; /** * \} @@ -118,10 +140,17 @@ struct sTCPConnection /** * \brief Out of sequence packets * \note Sorted list to improve times + * \todo Convert this to a ring buffer and a bitmap of valid bytes * \{ */ - tSpinlock lFuturePackets; //!< Future packets spinlock + #if CACHE_FUTURE_PACKETS_OR_BYTES == bytes + Uint32 HighestSequenceRcvd; //!< Highest sequence number (within window) recieved + Uint8 *FuturePacketData; //!< Future packet data (indexed by sequence number) + Uint8 *FuturePacketValidBytes; //!< Valid byte bitmap (WINDOW_SIZE/8 bytes) + #else + tShortSpinlock lFuturePackets; //!< Future packets spinlock tTCPStoredPacket *FuturePackets; //!< Out of sequence packets + #endif /** * \} */ @@ -133,11 +162,4 @@ struct sTCPConnection // Type is determined by LocalInterface->Type }; -enum eTCPConnectionState -{ - TCP_ST_CLOSED, - TCP_ST_HALFOPEN, - TCP_ST_OPEN -}; - #endif