From a9f9a331e2ee25ff68be6987fd645671038cbbde Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 14 Apr 2010 12:20:52 +0800 Subject: [PATCH] Possible fix to TCP Acknowlegement Numbers - Also changed Sequence number variables to Uint32, not int --- Kernel/include/tpl_drv_disk.h | 79 ++++++++++++++++++++++++++++++++++- Modules/IPStack/tcp.c | 4 +- Modules/IPStack/tcp.h | 4 +- 3 files changed, 81 insertions(+), 6 deletions(-) diff --git a/Kernel/include/tpl_drv_disk.h b/Kernel/include/tpl_drv_disk.h index d459aced..2af6f551 100644 --- a/Kernel/include/tpl_drv_disk.h +++ b/Kernel/include/tpl_drv_disk.h @@ -3,6 +3,10 @@ * \brief Disk Driver Interface Definitions * \author John Hodge (thePowersGang) * + * \section Nomeclature + * All addreses are 64-bit counts of bytes from the logical beginning of + * the disk unless explicitly stated. + * * \section dirs VFS Layout * Disk drivers have a flexible directory layout. The root directory can * contain subdirectories, with the only conditions being that all nodes @@ -33,13 +37,84 @@ enum eTplDisk_IOCtl { * \brief Get the block size * \return Size of a hardware block for this device */ - DISK_IOCTL_GETBLOCKSIZE = 4 + DISK_IOCTL_GETBLOCKSIZE = 4, + + /** + * ioctl(..., tTplDisk_CacheRegion *Region) + * \brief Sets the cache importantce and protocol for a section of + * memory. + * \param Region Pointer to a region information structure + * \return Boolean failure + */ + DISK_IOCTL_SETCACHEREGION, + + /** + * ioctl(..., Uint64 *Info[2]) + * \brief Asks the driver to precache a region of disk. + * \param Info 64-bit Address and Size pair describing the area to cache + * \return Number of blocks cached + */ + DISK_IOCTL_PRECACHE +}; + +typedef struct sTplDisk_CacheRegion +{ + Uint64 Base; //!< Base of cache region + Uint64 Length; //!< Size of cache region + /** + * \brief Cache Protocol & Flags + * + * The low 4 bits denot the cache protocol to be used by the + * region (see ::eTplDisk_CacheProtocols for a list). + * The high 4 bits denote flags to apply to the cache (see + * ::eTplDisk_CacheFlags) + */ + Uint8 Flags; + Uint8 Priority; //!< Lower is a higher proritory + Uint16 CacheSize; //!< Maximum size of cache, in blocks +} tTplDisk_CacheRegion; + +/** + * \brief Cache protocols to use + */ +enum eTplDisk_CacheProtocols +{ + /** + * \brief Region is not cached + */ + DISK_CACHEPROTO_DONTCACHE, + /** + * \brief Most recently used blocks cached + * \note This is the default action for undefined regions + */ + DISK_CACHEPROTO_RECENTLYUSED, + /** + * \brief Cache the entire region in memory + * + * This is a faster version of setting Length to CacheSize*BlockSize + */ + DISK_CACHEPROTO_FULLCACHE, + + /** + * \brief Cache only on demand + * + * Only cache when the ::DISK_IOCTL_PRECACHE ioctl is used + */ + DISK_CACHEPROTO_EXPLICIT +}; +enum eTplDisk_CacheFlags +{ + DISK_CACHEFLAG_WRITETHROUGH }; /** * \brief IOCtl name strings */ -#define DRV_DISK_IOCTLNAMES "get_block_size" +#define DRV_DISK_IOCTLNAMES "get_block_size", "set_cache_region" + +/** + * \section Disk Driver Utilities + */ /** * \brief Callback function type used by DrvUtil_ReadBlock and DrvUtil_WriteBlock diff --git a/Modules/IPStack/tcp.c b/Modules/IPStack/tcp.c index e7cded3e..9ce0f209 100644 --- a/Modules/IPStack/tcp.c +++ b/Modules/IPStack/tcp.c @@ -350,7 +350,7 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head TCP_INT_UpdateRecievedFromFuture(Connection); // TODO: Check ACK code validity - Header->AcknowlegementNumber = ntohl(pkt->Sequence) + dataLen; + Header->AcknowlegementNumber = ntohl(Connection->NextSequenceRcv); Header->SequenceNumber = ntohl(Connection->NextSequenceSend); Header->Flags &= TCP_FLAG_SYN; Header->Flags = TCP_FLAG_ACK; @@ -416,7 +416,7 @@ void TCP_INT_UpdateRecievedFromFuture(tTCPConnection *Connection) // Looks like we found one TCP_INT_AppendRecieved(Connection, pkt); - Connection->NextSequenceRcv ++; + Connection->NextSequenceRcv += pkt->Length; } } diff --git a/Modules/IPStack/tcp.h b/Modules/IPStack/tcp.h index c2ca8930..10a65efa 100644 --- a/Modules/IPStack/tcp.h +++ b/Modules/IPStack/tcp.h @@ -90,8 +90,8 @@ struct sTCPConnection tInterface *Interface; //!< Listening Interface tVFS_Node Node; //!< Node - int NextSequenceSend; //!< Next sequence value for outbound packets - int NextSequenceRcv; //!< Next expected sequence value for inbound + Uint32 NextSequenceSend; //!< Next sequence value for outbound packets + Uint32 NextSequenceRcv; //!< Next expected sequence value for inbound /** * \brief Non-ACKed packets -- 2.20.1