From 0df427777a3ab005eaeebc1ee4a326c8dfe91b29 Mon Sep 17 00:00:00 2001
From: John Hodge <tpg@prelude.(none)>
Date: Wed, 3 Feb 2010 11:57:48 +0800
Subject: [PATCH] Fixed and improved Ping support - BUG: ARP requests time out
 for some reason, todo check on other networks - Also updated the readme for
 better support when building

---
 Kernel/Makefile.BuildNum |  2 +-
 Makefile                 |  2 +-
 Modules/IPStack/icmp.c   | 15 ++++++++++++---
 README                   |  1 +
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/Kernel/Makefile.BuildNum b/Kernel/Makefile.BuildNum
index 62bf9325..be8bd603 100644
--- a/Kernel/Makefile.BuildNum
+++ b/Kernel/Makefile.BuildNum
@@ -1 +1 @@
-BUILD_NUM = 1422
+BUILD_NUM = 1423
diff --git a/Makefile b/Makefile
index 56878c1f..ae98e80b 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@
 SUBMAKE = $(MAKE) --no-print-directory
 
 MODULES += $(DYNMODS)
-USRLIBS = ld-acess.so libacess.so libgcc.so libc.so
+USRLIBS = crt0.o ld-acess.so libacess.so libgcc.so libc.so
 USRAPPS = init login CLIShell cat ls mount ifconfig
 
 ALL_MODULES = $(addprefix all-,$(MODULES))
diff --git a/Modules/IPStack/icmp.c b/Modules/IPStack/icmp.c
index 90ef7cbf..34e6eda4 100644
--- a/Modules/IPStack/icmp.c
+++ b/Modules/IPStack/icmp.c
@@ -52,7 +52,7 @@ void ICMP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buff
 			Warning("[ICMP ] Code == %i for ICMP Echo Reply, should be 0", hdr->Code);
 			return ;
 		}
-		if(hdr->ID != ~hdr->Sequence) {
+		if(hdr->ID != (Uint16)~hdr->Sequence) {
 			Warning("[ICMP ] ID and Sequence values do not match");
 			return ;
 		}
@@ -82,7 +82,8 @@ void ICMP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buff
  */
 int ICMP_Ping(tInterface *Interface, tIPv4 Addr)
 {
-	//Sint64	ts;
+	Sint64	ts;
+	Sint64	end;
 	char	buf[32] = "\x8\0\0\0\0\0\0\0Acess2 I"
                       "P/TCP Stack 1.0\0";
 	tICMPHeader	*hdr = (void*)buf;
@@ -104,5 +105,13 @@ int ICMP_Ping(tInterface *Interface, tIPv4 Addr)
 	hdr->Checksum = htons( IPv4_Checksum(hdr, sizeof(buf)) );
 	IPv4_SendPacket(Interface, Addr, 1, i, sizeof(buf), buf);
 	
-	return -1;
+	ts = now();
+	end = ts + Interface->TimeoutDelay;
+	while( !gICMP_PingSlots[i].bArrived && now() < end)	Threads_Yield();
+	
+	ts = now() - ts;
+	if(ts > Interface->TimeoutDelay)
+		return -1;
+	
+	return (int)ts;
 }
diff --git a/README b/README
index 4fb8be16..5680779d 100644
--- a/README
+++ b/README
@@ -29,6 +29,7 @@ The /Kernel tree contains the kernel sources.
  /Usermode/include - Required include files for the shared libraries.
 
 === Building ===
+Required Tools: GNU Toolchain (GCC,Gas,binutils), NASM, mtools, GNU calc
 Compiling Acess is relatively simple (at the moment)
 First edit /Makefile.cfg and set the build programs (making sure they match
   the architecture you are building for).
-- 
GitLab