From: John Hodge Date: Wed, 14 Jul 2010 02:30:39 +0000 (+0800) Subject: Cleaning up a bit X-Git-Tag: rel0.06~110 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=be53e78f163ec7e0e5271d41650476bf5e1de571;p=tpg%2Facess2.git Cleaning up a bit --- diff --git a/Kernel/binary.c b/Kernel/binary.c index 193ff14b..eb7094d2 100644 --- a/Kernel/binary.c +++ b/Kernel/binary.c @@ -121,7 +121,7 @@ int Proc_Execve(char *File, char **ArgV, char **EnvP) // Allocate argenvBuf = malloc(argenvBytes); if(argenvBuf == NULL) { - Warning("Proc_Execve - What the hell? The kernel is out of heap space"); + Log_Error("BIN", "Proc_Execve - What the hell? The kernel is out of heap space"); return 0; } strBuf = argenvBuf + (argc+1)*sizeof(void*) + (envc+1)*sizeof(void*); @@ -158,7 +158,7 @@ int Proc_Execve(char *File, char **ArgV, char **EnvP) free(savedFile); if(bases[0] == 0) { - Warning("Proc_Execve - Unable to load '%s'", Threads_GetName(-1)); + Log_Warning("BIN", "Proc_Execve - Unable to load '%s'", Threads_GetName(-1)); Threads_Exit(0, 0); for(;;); } @@ -191,7 +191,7 @@ Uint Binary_Load(char *file, Uint *entryPoint) sTruePath = VFS_GetTruePath(file); if(sTruePath == NULL) { - Warning("[BIN ] '%s' does not exist.", file); + Log_Warning("BIN", "'%s' does not exist.", file); LEAVE('x', 0); return 0; } @@ -315,7 +315,7 @@ Uint Binary_MapIn(tBinary *binary) // Error Check if(base < BIN_LOWEST) { - Warning("[BIN ] Executable '%s' cannot be loaded, no space", binary->TruePath); + Log_Warning("BIN", "Executable '%s' cannot be loaded, no space", binary->TruePath); return 0; } @@ -411,7 +411,7 @@ tBinary *Binary_DoLoad(char *truePath) break; } if(!bt) { - Warning("[BIN ] '%s' is an unknown file type. (0x%x 0x%x 0x%x 0x%x)", + Log_Warning("BIN", "'%s' is an unknown file type. (%02x %02x %02x %02x)", truePath, ident&0xFF, (ident>>8)&0xFF, (ident>>16)&0xFF, (ident>>24)&0xFF); LEAVE('n'); return NULL; @@ -440,7 +440,7 @@ tBinary *Binary_DoLoad(char *truePath) tPAddr paddr; paddr = (Uint)MM_AllocPhys(); if(paddr == 0) { - Warning("Binary_DoLoad - Physical memory allocation failed"); + Log_Warning("BIN", "Binary_DoLoad - Physical memory allocation failed"); for( ; i--; ) { MM_DerefPhys( pBinary->Pages[i].Physical ); } @@ -505,7 +505,7 @@ void Binary_Unload(void *Base) if((Uint)Base < 0xC0000000) { // TODO: User Binaries - Warning("[BIN ] Unloading user binaries is currently unimplemented"); + Log_Warning("BIN", "Unloading user binaries is currently unimplemented"); return; } @@ -687,7 +687,7 @@ void *Binary_LoadKernel(char *File) // - Error Check if(base >= KLIB_HIGHEST) { - Warning("[BIN ] Executable '%s' cannot be loaded into kernel, no space", pBinary->TruePath); + Log_Warning("BIN", "Executable '%s' cannot be loaded into kernel, no space", pBinary->TruePath); Binary_Dereference( pBinary ); LEAVE('n'); return 0; @@ -750,7 +750,7 @@ Uint Binary_Relocate(void *Base) return bt->Relocate( (void*)Base); } - Warning("[BIN ] 0x%x is an unknown file type. (0x%x 0x%x 0x%x 0x%x)", + Log_Warning("BIN", "%p is an unknown file type. (%02x %02x %02x %02x)", Base, ident&0xFF, (ident>>8)&0xFF, (ident>>16)&0xFF, (ident>>24)&0xFF); return 0; } @@ -801,7 +801,7 @@ Uint Binary_GetSymbolEx(char *Name, Uint *Value) } } - Warning("[BIN ] Unable to find symbol '%s'", Name); + Log_Warning("BIN", "Unable to find symbol '%s'", Name); return 0; } @@ -823,7 +823,7 @@ Uint Binary_FindSymbol(void *Base, char *Name, Uint *Val) return bt->GetSymbol(Base, Name, Val); } - Warning("[BIN ] 0x%x is an unknown file type. (0x%x 0x%x 0x%x 0x%x)", + Log_Warning("BIN", "Binary_FindSymbol - %p is an unknown file type. (%02x %02x %02x %02x)", Base, ident&0xFF, ident>>8, ident>>16, ident>>24); return 0; } diff --git a/Modules/IPStack/arp.c b/Modules/IPStack/arp.c index d9f837cf..fab74f85 100644 --- a/Modules/IPStack/arp.c +++ b/Modules/IPStack/arp.c @@ -214,7 +214,7 @@ void ARP_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buffe return ; } if( ntohs(req4->Type) != 0x0800 ) { - Log_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 ) { @@ -248,14 +248,13 @@ void ARP_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buffe req4->SourceMac.B[0], req4->SourceMac.B[1], req4->SourceMac.B[2], req4->SourceMac.B[3], req4->SourceMac.B[4], req4->SourceMac.B[5]); - Log_Debug("ARP", "to MAC %02x:%02x:%02x:%02x:%02x:%02x", - req4->DestMac.B[0], req4->DestMac.B[1], - req4->DestMac.B[2], req4->DestMac.B[3], - req4->DestMac.B[4], req4->DestMac.B[5]); - Log_Debug("ARP", "ARP Request IPv4 Address %i.%i.%i.%i", + //Log_Debug("ARP", "to MAC %02x:%02x:%02x:%02x:%02x:%02x", + // req4->DestMac.B[0], req4->DestMac.B[1], + // req4->DestMac.B[2], req4->DestMac.B[3], + // req4->DestMac.B[4], req4->DestMac.B[5]); + Log_Debug("ARP", "ARP Request IPv4 Address %i.%i.%i.%i from %i.%i.%i.%i", req4->DestIP.B[0], req4->DestIP.B[1], req4->DestIP.B[2], - req4->DestIP.B[3]); - Log_Debug("ARP", "from %i.%i.%i.%i", + req4->DestIP.B[3], req4->SourceIP.B[0], req4->SourceIP.B[1], req4->SourceIP.B[2], req4->SourceIP.B[3]); iface = IPv4_GetInterface(Adapter, req4->DestIP, 0); @@ -269,8 +268,7 @@ void ARP_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buffe req4->SourceIP = iface->IP4.Address; req4->SourceMac = Adapter->MacAddr; req4->Request = htons(2); - Log_Debug("ARP", "Hey, That's us!"); - Log_Debug("ARP", "Sending back %02x:%02x:%02x:%02x:%02x:%02x", + Log_Debug("ARP", "Sending back us (%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]); @@ -279,9 +277,13 @@ void ARP_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buffe break; case 6: if( Length < sizeof(tArpRequest6) ) { - Log_Debug("ARP", "Recieved undersized packet (IPv6)"); + Log_Log("ARP", "Recieved undersized packet (IPv6)"); return ; } + Log_Debug("ARP", "ARP Request IPv6 Address %08x:%08x:%08x:%08x", + ntohl(req6->DestIP.L[0]), ntohl(req6->DestIP.L[1]), + ntohl(req6->DestIP.L[2]), ntohl(req6->DestIP.L[3]) + ); iface = IPv6_GetInterface(Adapter, req6->DestIP, 0); if( iface ) { @@ -290,6 +292,10 @@ void ARP_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buffe req6->SourceIP = iface->IP6.Address; req6->SourceMac = Adapter->MacAddr; req6->Request = htons(2); + Log_Debug("ARP", "Sending back us (%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]); Link_SendPacket(Adapter, 0x0806, req6->DestMac, sizeof(tArpRequest6), req6); } break; @@ -322,7 +328,7 @@ void ARP_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buffe break; default: - Warning("[ARP ] Unknown Request ID %i", ntohs(req4->Request)); + Log_Warning("ARP", "Unknown Request ID %i", ntohs(req4->Request)); break; } } diff --git a/Modules/IPStack/ipstack.h b/Modules/IPStack/ipstack.h index 78faf663..43953942 100644 --- a/Modules/IPStack/ipstack.h +++ b/Modules/IPStack/ipstack.h @@ -23,6 +23,7 @@ union uIPv4 { } __attribute__((packed)); union uIPv6 { + Uint16 W[8]; Uint32 L[4]; Uint8 B[16]; } __attribute__((packed)); @@ -35,7 +36,7 @@ struct sInterface { struct sInterface *Next; tVFS_Node Node; tAdapter *Adapter; - int TimeoutDelay; // Time in miliseconds before a connection times out + int TimeoutDelay; // Time in miliseconds before a packet times out int Type; // 0 for disabled, 4 for IPv4 and 6 for IPv6 union { struct { @@ -88,11 +89,11 @@ static const tMacAddr cMAC_BROADCAST = {{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}}; // === FUNCTIONS === #define htonb(v) (v) -#define htons(in) BigEndian16(in) -#define htonl(in) BigEndian32(in) +#define htons(v) BigEndian16(v) +#define htonl(v) BigEndian32(v) #define ntonb(v) (v) -#define ntohs(in) BigEndian16(in) -#define ntohl(in) BigEndian32(in) +#define ntohs(v) BigEndian16(v) +#define ntohl(v) BigEndian32(v) extern int IPStack_AddFile(tSocketFile *File);