Modules/IPStack - TCP minor bugfixes, arp semaphore name
authorJohn Hodge <[email protected]>
Fri, 8 Feb 2013 10:50:20 +0000 (18:50 +0800)
committerJohn Hodge <[email protected]>
Fri, 8 Feb 2013 10:50:20 +0000 (18:50 +0800)
KernelLand/Modules/IPStack/arp.c
KernelLand/Modules/IPStack/tcp.c

index 43c3425..5ca128b 100644 (file)
@@ -67,6 +67,7 @@ int ARP_Initialise()
        #endif
        
        Link_RegisterType(0x0806, ARP_int_GetPacket);
+       Semaphore_Init(&gARP_Cache4Semaphore, 0, 0, "ARP4", "Cache Changes");
        return 1;
 }
 
@@ -171,6 +172,7 @@ tMacAddr ARP_Resolve4(tInterface *Interface, tIPv4 Address)
                        Log_Log("ARP4", "Timeout");
                        break;
                }
+               Log_Debug("ARP4", "Cache change");
                
                Mutex_Acquire( &glARP_Cache4 );
                for( i = 0; i < giARP_Cache4Space; i++ )
index f1eee65..28dc2c5 100644 (file)
@@ -350,7 +350,7 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head
        // Get length of data
        dataLen = Length - (Header->DataOffset>>4)*4;
        LOG("dataLen = %i", dataLen);
-//     Log_Debug("TCP", "State %i, dataLen = %x", Connection->State, dataLen);
+       Log_Debug("TCP", "State %i, dataLen = %x", Connection->State, dataLen);
        
        // 
        // State Machine
@@ -368,14 +368,6 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head
                if( Header->Flags & TCP_FLAG_SYN )
                {
                        Connection->NextSequenceRcv ++;
-                       Header->DestPort = Header->SourcePort;
-                       Header->SourcePort = htons(Connection->LocalPort);
-                       Header->AcknowlegementNumber = htonl(Connection->NextSequenceRcv);
-                       Header->SequenceNumber = htonl(Connection->NextSequenceSend);
-                       Header->WindowSize = htons(TCP_WINDOW_SIZE);
-                       Header->Flags = TCP_FLAG_ACK;
-                       Header->DataOffset = (sizeof(tTCPHeader)/4) << 4;
-                       TCP_SendPacket( Connection, Header, 0, NULL );
                        
                        if( Header->Flags & TCP_FLAG_ACK )
                        {       
@@ -388,6 +380,14 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head
                                Log_Log("TCP", "ACKing SYN");
                                Connection->State = TCP_ST_SYN_RCVD;
                        }
+                       Header->DestPort = Header->SourcePort;
+                       Header->SourcePort = htons(Connection->LocalPort);
+                       Header->AcknowlegementNumber = htonl(Connection->NextSequenceRcv);
+                       Header->SequenceNumber = htonl(Connection->NextSequenceSend);
+                       Header->WindowSize = htons(TCP_WINDOW_SIZE);
+                       Header->Flags = TCP_FLAG_ACK;
+                       Header->DataOffset = (sizeof(tTCPHeader)/4) << 4;
+                       TCP_SendPacket( Connection, Header, 0, NULL );
                }
                break;
        
@@ -426,12 +426,15 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head
                        }
                        Connection->NextSequenceRcv ++; // TODO: Is this right? (empty packet counts as one byte)
                        Log_Log("TCP", "Empty Packet, inc and ACK the current sequence number");
+                       TCP_INT_SendACK(Connection);
+                       #if 0
                        Header->DestPort = Header->SourcePort;
                        Header->SourcePort = htons(Connection->LocalPort);
                        Header->AcknowlegementNumber = htonl(Connection->NextSequenceRcv);
                        Header->SequenceNumber = htonl(Connection->NextSequenceSend);
                        Header->Flags |= TCP_FLAG_ACK;
                        TCP_SendPacket( Connection, Header, 0, NULL );
+                       #endif
                        return ;
                }
                
@@ -442,7 +445,7 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head
                
                sequence_num = ntohl(Header->SequenceNumber);
                
-               LOG("TCP", "0x%08x <= 0x%08x < 0x%08x",
+               LOG("0x%08x <= 0x%08x < 0x%08x",
                        Connection->NextSequenceRcv,
                        ntohl(Header->SequenceNumber),
                        Connection->NextSequenceRcv + TCP_WINDOW_SIZE

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