Fixed some bugs in ARP and TCP Code
authorJohn Hodge <[email protected]>
Sat, 10 Apr 2010 02:10:54 +0000 (10:10 +0800)
committerJohn Hodge <[email protected]>
Sat, 10 Apr 2010 02:10:54 +0000 (10:10 +0800)
- also I need to learn not to use "git commit -a" when using git add.
- Last commit also had some huge changes to the Video architecture
 > Made the video mode only describe the resolution and colour depth.
 > Text/Framebuffer/3D are now controled via an IOCtl that swaps buffer modes
 > An IOCtl (still to be put in) will provide feature flags for the VTerm to read

Kernel/Makefile.BuildNum
Modules/IPStack/arp.c
Modules/IPStack/ipstack.h
Modules/IPStack/tcp.c

index a1e5f08..791d957 100644 (file)
@@ -1 +1 @@
-BUILD_NUM = 1811
+BUILD_NUM = 1815
index ec10f39..cedc0b3 100644 (file)
@@ -90,7 +90,7 @@ tMacAddr ARP_Resolve4(tInterface *Interface, tIPv4 Address)
        lastID = giARP_LastUpdateID;
        
        // Create request
-       Log("[ARP4 ] Asking for address %i.%i.%i.%i",
+       Log_Log("ARP4", "Asking for address %i.%i.%i.%i",
                Address.B[0], Address.B[1], Address.B[2], Address.B[3]
                );
        req.HWType = htons(0x0001);     // Ethernet
@@ -152,7 +152,7 @@ void ARP_UpdateCache4(tIPv4 SWAddr, tMacAddr HWAddr)
                gaARP_Cache4[i].IP = SWAddr;
        }
        
-       Log("[ARP  ] Caching %i.%i.%i.%i (%02x:%02x:%02x:%02x:%02x:%02x) in %i",
+       Log_Log("ARP4", "Caching %i.%i.%i.%i (%02x:%02x:%02x:%02x:%02x:%02x) in %i",
                SWAddr.B[0], SWAddr.B[1], SWAddr.B[2], SWAddr.B[3],
                HWAddr.B[0], HWAddr.B[1], HWAddr.B[2], HWAddr.B[3], HWAddr.B[4], HWAddr.B[5],
                i
@@ -210,19 +210,25 @@ void ARP_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buffe
        
        // Sanity Check Packet
        if( Length < sizeof(tArpRequest4) ) {
-               Log("[ARP  ] Recieved undersized packet");
+               Log_Log("ARP", "Recieved undersized packet");
                return ;
        }
        if( ntohs(req4->Type) != 0x0800 ) {
-               Log("[ARP  ] Recieved a packet with a bad type 0x%x", ntohs(req4->Type));
+               Log_Log("ARP", "Recieved a packet with a bad type 0x%x", ntohs(req4->Type));
                return ;
        }
        if( req4->HWSize != 6 ) {
-               Log("[ARP  ] Recieved a packet with HWSize != 6 (%i)", req4->HWSize);
+               Log_Log("ARP", "Recieved a packet with HWSize != 6 (%i)", req4->HWSize);
                return;
        }
        if( !MAC_EQU(req4->SourceMac, From) ) {
-               Log("[ARP  ] ARP spoofing detected", req4->HWSize);
+               Log_Log("ARP", "ARP spoofing detected "
+                       "(%02x%02x:%02x%02x:%02x%02x != %02x%02x:%02x%02x:%02x%02x)",
+                       req4->SourceMac.B[0], req4->SourceMac.B[1], req4->SourceMac.B[2],
+                       req4->SourceMac.B[3], req4->SourceMac.B[4], req4->SourceMac.B[5],
+                       From.B[0], From.B[1], From.B[2],
+                       From.B[3], From.B[4], From.B[5]
+                       );
                return;
        }
        
index 95f93c4..78faf66 100644 (file)
@@ -82,9 +82,9 @@ static const tMacAddr cMAC_BROADCAST = {{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}};
 #define IP4_SET(t,v)   (t).L = (v).L;
 #define IP6_SET(t,v)   memcpy(&(t),&(v),sizeof(tIPv6))
 
-#define MAC_EQU(a,b)   memcmp(&(a),&(b),sizeof(tMacAddr))
+#define MAC_EQU(a,b)   (memcmp(&(a),&(b),sizeof(tMacAddr))==0)
 #define IP4_EQU(a,b)   ((a).L==(b).L)
-#define IP6_EQU(a,b)   memcmp(&(a),&(b),sizeof(tIPv6))
+#define IP6_EQU(a,b)   (memcmp(&(a),&(b),sizeof(tIPv6))==0)
 
 // === FUNCTIONS ===
 #define htonb(v)       (v)
index 3db8230..1c9464c 100644 (file)
@@ -348,14 +348,14 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head
                // so that a single lost packet on one connection doesn't cause
                // all connections on the interface to lag.
                TCP_INT_UpdateRecievedFromFuture(Connection);
-       }
        
-       // TODO: Check ACK code validity
-       Header->AcknowlegementNumber = ntohl(pkt->Sequence) + dataLen;
-       Header->SequenceNumber = ntohl(Connection->NextSequenceSend);
-       Header->Flags &= TCP_FLAG_SYN;
-       Header->Flags = TCP_FLAG_ACK;
-       TCP_SendPacket( Connection, sizeof(tTCPHeader), Header );
+               // TODO: Check ACK code validity
+               Header->AcknowlegementNumber = ntohl(pkt->Sequence) + dataLen;
+               Header->SequenceNumber = ntohl(Connection->NextSequenceSend);
+               Header->Flags &= TCP_FLAG_SYN;
+               Header->Flags = TCP_FLAG_ACK;
+               TCP_SendPacket( Connection, sizeof(tTCPHeader), Header );
+       }
 }
 
 /**

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