From: John Hodge Date: Sat, 10 Apr 2010 02:10:54 +0000 (+0800) Subject: Fixed some bugs in ARP and TCP Code X-Git-Tag: rel0.06~250 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=46a4b5e282c7c37f2091e7ced4db0190248a5d28;p=tpg%2Facess2.git Fixed some bugs in ARP and TCP Code - 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 --- diff --git a/Kernel/Makefile.BuildNum b/Kernel/Makefile.BuildNum index a1e5f087..791d957d 100644 --- a/Kernel/Makefile.BuildNum +++ b/Kernel/Makefile.BuildNum @@ -1 +1 @@ -BUILD_NUM = 1811 +BUILD_NUM = 1815 diff --git a/Modules/IPStack/arp.c b/Modules/IPStack/arp.c index ec10f396..cedc0b31 100644 --- a/Modules/IPStack/arp.c +++ b/Modules/IPStack/arp.c @@ -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; } diff --git a/Modules/IPStack/ipstack.h b/Modules/IPStack/ipstack.h index 95f93c47..78faf663 100644 --- a/Modules/IPStack/ipstack.h +++ b/Modules/IPStack/ipstack.h @@ -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) diff --git a/Modules/IPStack/tcp.c b/Modules/IPStack/tcp.c index 3db8230a..1c9464c1 100644 --- a/Modules/IPStack/tcp.c +++ b/Modules/IPStack/tcp.c @@ -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 ); + } } /**