X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=Modules%2FIPStack%2Ftcp.h;h=492e035fe1834fce2f3a4d77e2e7347e213bc918;hb=f87b0ab247466133ae7a6be7ac72b95462ab2b81;hp=cd6caf09dfe4c4bca970632c002796e6113ecaad;hpb=845ed09f3edef0c836200df6afbd6bfbc7b3fef6;p=tpg%2Facess2.git diff --git a/Modules/IPStack/tcp.h b/Modules/IPStack/tcp.h index cd6caf09..492e035f 100644 --- a/Modules/IPStack/tcp.h +++ b/Modules/IPStack/tcp.h @@ -9,6 +9,7 @@ typedef struct sTCPHeader tTCPHeader; typedef struct sTCPListener tTCPListener; +typedef struct sTCPStoredPacket tTCPStoredPacket; typedef struct sTCPConnection tTCPConnection; struct sTCPHeader @@ -18,7 +19,7 @@ struct sTCPHeader Uint32 SequenceNumber; Uint32 AcknowlegementNumber; #if 0 - struct { + struct { // Lowest to highest unsigned Reserved: 4; unsigned DataOffset: 4; // Size of the header in 32-bit words } __attribute__ ((packed)); @@ -61,50 +62,85 @@ enum eTCPFlags struct sTCPListener { - struct sTCPListener *Next; - Uint16 Port; - tInterface *Interface; - tVFS_Node Node; - int NextID; - tTCPConnection *Connections; + struct sTCPListener *Next; //!< Next server in the list + Uint16 Port; //!< Listening port (0 disables the server) + tInterface *Interface; //!< Listening Interface + tVFS_Node Node; //!< Server Directory node + int NextID; //!< Name of the next connection + tSpinlock lConnections; //!< Spinlock for connections + tTCPConnection *Connections; //!< Connections (linked list) + tTCPConnection *volatile NewConnections; + tTCPConnection *ConnectionsTail; +}; + +struct sTCPStoredPacket +{ + struct sTCPStoredPacket *Next; + size_t Length; + Uint32 Sequence; + Uint8 Data[]; }; struct sTCPConnection { struct sTCPConnection *Next; - int State; - Uint16 LocalPort; - Uint16 RemotePort; - tVFS_Node Node; + int State; //!< Connection state (see ::eTCPConnectionState) + Uint16 LocalPort; //!< Local port + Uint16 RemotePort; //!< Remote port + tInterface *Interface; //!< Listening Interface + tVFS_Node Node; //!< Node - int NextSequenceSend; - int NextSequenceRcv; + Uint32 NextSequenceSend; //!< Next sequence value for outbound packets + Uint32 NextSequenceRcv; //!< Next expected sequence value for inbound - int nQueuedPackets; - struct { - int Sequence; - void *Data; - } *QueuedPackets; + /** + * \brief Non-ACKed packets + * \note FIFO list + * \{ + */ + tSpinlock lQueuedPackets; + tTCPStoredPacket *QueuedPackets; //!< Non-ACKed packets + /** + * \} + */ + /** + * \brief Unread Packets + * \note Ring buffer + * \{ + */ + tSpinlock lRecievedPackets; + tRingBuffer *RecievedBuffer; + /** + * \} + */ - int nFuturePackets; - struct { - int SequenceNum; - void *Data; - } **FuturePackets; + /** + * \brief Out of sequence packets + * \note Sorted list to improve times + * \{ + */ + tSpinlock lFuturePackets; //!< Future packets spinlock + tTCPStoredPacket *FuturePackets; //!< Out of sequence packets + /** + * \} + */ - tInterface *Interface; union { tIPv4 v4; tIPv6 v6; - } RemoteIP; // Type is determined by LocalInterface->Type + } RemoteIP; //!< Remote IP Address + // Type is determined by LocalInterface->Type }; enum eTCPConnectionState { TCP_ST_CLOSED, + TCP_ST_SYN_SENT, TCP_ST_HALFOPEN, - TCP_ST_OPEN + TCP_ST_OPEN, + TCP_ST_FIN_SENT, + TCP_ST_FINISHED }; #endif