From 59a434cdeaf3b3bb2aeb0b93816abfef43cbcac7 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 25 Feb 2010 21:35:27 +0800 Subject: [PATCH] More fixups to ARP and UDP (udp still buggy) --- Kernel/Makefile.BuildNum | 2 +- Modules/IPStack/arp.c | 12 ++++++++++++ Modules/IPStack/ipv4.c | 7 +++++++ Modules/IPStack/udp.c | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Kernel/Makefile.BuildNum b/Kernel/Makefile.BuildNum index e082886e..51a99bb5 100644 --- a/Kernel/Makefile.BuildNum +++ b/Kernel/Makefile.BuildNum @@ -1 +1 @@ -BUILD_NUM = 1447 +BUILD_NUM = 1450 diff --git a/Modules/IPStack/arp.c b/Modules/IPStack/arp.c index 2b246cd5..40649284 100644 --- a/Modules/IPStack/arp.c +++ b/Modules/IPStack/arp.c @@ -152,8 +152,15 @@ 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", + 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 + ); + gaARP_Cache4[i].MAC = HWAddr; gaARP_Cache4[i].LastUpdate = now(); + giARP_LastUpdateID ++; RELEASE(&glARP_Cache4); } @@ -187,6 +194,7 @@ void ARP_UpdateCache6(tIPv6 SWAddr, tMacAddr HWAddr) gaARP_Cache6[i].IP = SWAddr; gaARP_Cache6[i].LastUpdate = now(); + giARP_LastUpdateID ++; RELEASE(&glARP_Cache6); } @@ -304,5 +312,9 @@ void ARP_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buffe } break; + + default: + Warning("[ARP ] Unknown Request ID %i", ntohs(req4->Request)); + break; } } diff --git a/Modules/IPStack/ipv4.c b/Modules/IPStack/ipv4.c index 15cf65f8..89f56713 100644 --- a/Modules/IPStack/ipv4.c +++ b/Modules/IPStack/ipv4.c @@ -69,6 +69,13 @@ int IPv4_SendPacket(tInterface *Iface, tIPv4 Address, int Protocol, int ID, int hdr->Version = 4; hdr->HeaderLength = sizeof(tIPv4Header)/4; hdr->DiffServices = 0; // TODO: Check + + hdr->Reserved = 0; + hdr->DontFragment = 0; + hdr->MoreFragments = 0; + hdr->FragOffLow = 0; + hdr->FragOffHi = 0; + hdr->TotalLength = htons( bufSize ); hdr->Identifcation = htons( ID ); // TODO: Check hdr->TTL = DEFAULT_TTL; diff --git a/Modules/IPStack/udp.c b/Modules/IPStack/udp.c index f014c557..fe13a3e1 100644 --- a/Modules/IPStack/udp.c +++ b/Modules/IPStack/udp.c @@ -125,7 +125,7 @@ void UDP_SendPacket(tUDPChannel *Channel, void *Data, size_t Length) hdr = malloc(sizeof(tUDPHeader)+Length); hdr->SourcePort = htons( Channel->LocalPort ); hdr->DestPort = htons( Channel->RemotePort ); - hdr->Length = htons( Length ); + hdr->Length = htons( sizeof(tUDPHeader) + Length ); hdr->Checksum = 0; // Checksum can be zero on IPv4 memcpy(hdr->Data, Data, Length); // Pass on the the IPv4 Layer -- 2.20.1