Possible fix to TCP Acknowlegement Numbers
authorJohn Hodge <[email protected]>
Wed, 14 Apr 2010 04:20:52 +0000 (12:20 +0800)
committerJohn Hodge <[email protected]>
Wed, 14 Apr 2010 04:20:52 +0000 (12:20 +0800)
- Also changed Sequence number variables to Uint32, not int

Kernel/include/tpl_drv_disk.h
Modules/IPStack/tcp.c
Modules/IPStack/tcp.h

index d459ace..2af6f55 100644 (file)
@@ -3,6 +3,10 @@
  * \brief Disk Driver Interface Definitions\r
  * \author John Hodge (thePowersGang)\r
  * \r
+ * \section Nomeclature\r
+ * All addreses are 64-bit counts of bytes from the logical beginning of\r
+ * the disk unless explicitly stated.\r
+ * \r
  * \section dirs VFS Layout\r
  * Disk drivers have a flexible directory layout. The root directory can\r
  * contain subdirectories, with the only conditions being that all nodes\r
@@ -33,13 +37,84 @@ enum eTplDisk_IOCtl {
         * \brief Get the block size\r
         * \return Size of a hardware block for this device\r
         */\r
-       DISK_IOCTL_GETBLOCKSIZE = 4\r
+       DISK_IOCTL_GETBLOCKSIZE = 4,\r
+       \r
+       /**\r
+        * ioctl(..., tTplDisk_CacheRegion *Region)\r
+        * \brief Sets the cache importantce and protocol for a section of\r
+        *        memory.\r
+        * \param Region        Pointer to a region information structure\r
+        * \return Boolean failure\r
+        */\r
+       DISK_IOCTL_SETCACHEREGION,\r
+       \r
+       /**\r
+        * ioctl(..., Uint64 *Info[2])\r
+        * \brief Asks the driver to precache a region of disk.\r
+        * \param Info  64-bit Address and Size pair describing the area to cache\r
+        * \return Number of blocks cached\r
+        */\r
+       DISK_IOCTL_PRECACHE\r
+};\r
+\r
+typedef struct sTplDisk_CacheRegion\r
+{\r
+       Uint64  Base;   //!< Base of cache region\r
+       Uint64  Length; //!< Size of cache region\r
+       /**\r
+        * \brief Cache Protocol & Flags\r
+        * \r
+        * The low 4 bits denot the cache protocol to be used by the\r
+        * region (see ::eTplDisk_CacheProtocols for a list).\r
+        * The high 4 bits denote flags to apply to the cache (see\r
+        * ::eTplDisk_CacheFlags)\r
+        */\r
+       Uint8   Flags;\r
+       Uint8   Priority;       //!< Lower is a higher proritory\r
+       Uint16  CacheSize;      //!< Maximum size of cache, in blocks\r
+}      tTplDisk_CacheRegion;\r
+\r
+/**\r
+ * \brief Cache protocols to use\r
+ */\r
+enum eTplDisk_CacheProtocols\r
+{\r
+       /**\r
+        * \brief Region is not cached\r
+        */\r
+       DISK_CACHEPROTO_DONTCACHE,\r
+       /**\r
+        * \brief Most recently used blocks cached\r
+        * \note This is the default action for undefined regions\r
+        */\r
+       DISK_CACHEPROTO_RECENTLYUSED,\r
+       /**\r
+        * \brief Cache the entire region in memory\r
+        * \r
+        * This is a faster version of setting Length to CacheSize*BlockSize\r
+        */\r
+       DISK_CACHEPROTO_FULLCACHE,\r
+       \r
+       /**\r
+        * \brief Cache only on demand\r
+        * \r
+        * Only cache when the ::DISK_IOCTL_PRECACHE ioctl is used\r
+        */\r
+       DISK_CACHEPROTO_EXPLICIT\r
+};\r
+enum eTplDisk_CacheFlags\r
+{\r
+       DISK_CACHEFLAG_WRITETHROUGH\r
 };\r
 \r
 /**\r
  * \brief IOCtl name strings\r
  */\r
-#define        DRV_DISK_IOCTLNAMES     "get_block_size"\r
+#define        DRV_DISK_IOCTLNAMES     "get_block_size", "set_cache_region"\r
+\r
+/**\r
+ * \section Disk Driver Utilities\r
+ */\r
 \r
 /**\r
  * \brief Callback function type used by DrvUtil_ReadBlock and DrvUtil_WriteBlock\r
index e7cded3..9ce0f20 100644 (file)
@@ -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;
        }
 }
 
index c2ca893..10a65ef 100644 (file)
@@ -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

UCC git Repository :: git.ucc.asn.au