Index: ChangeLog
===================================================================
--- ChangeLog	(revision d37a99d444fcadc7574cab26cf9c081e7d0c6ab3)
+++ ChangeLog	(revision d51d8b5b51c6a0286eb1f7952b81799f3b0ef3eb)
@@ -1,2 +1,9 @@
+2001-08-30	Joel Sherrill <joel@OARcorp.com>
+
+	* README, networkconfig.h, netdemo/README, tftpTest/test.c: Merged
+	missing stuff from 4.5 branch.
+	* http/Makefile, http/init.c: Minor modifications to improve
+	buildability.
+
 2000-12-14	Eric Norum <eric.norum@usask.ca>
 
Index: README
===================================================================
--- README	(revision d37a99d444fcadc7574cab26cf9c081e7d0c6ab3)
+++ README	(revision d51d8b5b51c6a0286eb1f7952b81799f3b0ef3eb)
@@ -0,0 +1,35 @@
+#
+# $Id$
+#
+
+This directory contains a set of network tests and demonstrations
+programs.  
+
+    netdemo  - simplest test, echos data on sockets
+    dnstest  - test of DNS client
+    http     - test of GoAhead web server
+    netlink  - link only test to evaluate code space requirement
+               of network stack, ftpd, and httpd
+    ntp      - test of network time protocol client
+    rpc_demo - test of RPC library
+    select   - test of select() routine functionality
+    tftpTest - test of TFTP (Trivial FTP) client filesystem 
+    ttcp     - TTCP throughput test
+
+The file networkconfig.h MUST be configured to reflect your local
+network according to the included Configuration Notes.
+
+CONFIGURATION NOTES
+===================
+
+1. Make sure you change the definition of MY_ETHERNET_ADDRESS in 
+   networkconfig.h before you try to use any of the network
+   demonstration programs.
+
+2. If you do not use BOOTP (i.e. the `#define USE_BOOTP 1' in init.c is
+   removed), make sure you change the definition of MY_INTERNET_ADDRESS
+   before you try to use the programs.
+
+FAILURE TO FOLLOW THE ABOVE INSTRUCTIONS MAY PROVOKE YOUR NETWORK
+ADMINISTRATOR TO THE POINT WHERE VICIOUS ATTACKS WILL BE MADE UPON YOU.
+
Index: http/Makefile
===================================================================
--- http/Makefile	(revision d37a99d444fcadc7574cab26cf9c081e7d0c6ab3)
+++ http/Makefile	(revision d51d8b5b51c6a0286eb1f7952b81799f3b0ef3eb)
@@ -42,4 +42,5 @@
 LD_PATHS  +=
 LD_LIBS   +=
+NATIVE_OBJ = $(shell $(OBJCOPY) 2>&1  | grep copy: | cut -d':' -f3 | cut -d' ' -f2)
 
 #
@@ -56,7 +57,7 @@
 
 ${PGM}: $(OBJS) $(LINK_FILES)
- 	cd rootfs ; tar cf ../$(ARCH)/tarfile web etc
+	cd rootfs ; tar cf ../$(ARCH)/tarfile web etc
 	cp $(ARCH)/tarfile .
-	$(OBJCOPY) -I binary -O elf32-powerpc tarfile $(ARCH)/tarfile.o
+	$(OBJCOPY) -I binary -O $(NATIVE_OBJ) tarfile $(ARCH)/tarfile.o
 	$(LD) -r -o $(ARCH)/temp.o  $(ARCH)/init.o $(ARCH)/tarfile.o
 	$(MV) $(ARCH)/temp.o  $(ARCH)/init.o
Index: http/init.c
===================================================================
--- http/init.c	(revision d37a99d444fcadc7574cab26cf9c081e7d0c6ab3)
+++ http/init.c	(revision d51d8b5b51c6a0286eb1f7952b81799f3b0ef3eb)
@@ -6,4 +6,6 @@
  */
 
+#define USE_HTTPD
+#define USE_FTPD
 #define TEST_INIT
 
@@ -58,4 +60,6 @@
  */
 
+#if defined(USE_FTPD)
+/*
 #if defined(RTEMS_DEBUG)
 extern int _binary_o_debug_tarfile_start;
@@ -69,5 +73,12 @@
 #define TARFILE_SIZE _binary_o_optimize_tarfile_size
 #endif
+*/
+extern int _binary_tarfile_start;
+extern int _binary_tarfile_size;
+#define TARFILE_START _binary_tarfile_start
+#define TARFILE_SIZE _binary_tarfile_size
+#endif
 
+#if defined(USE_FTPD)
 struct rtems_ftpd_configuration rtems_ftpd_configuration = {
    10,                     /* FTPD task priority            */
@@ -76,4 +87,5 @@
    NULL                    /* List of hooks       */
 };
+#endif
 rtems_task Init(
   rtems_task_argument argument
@@ -87,9 +99,13 @@
 
   rtems_bsdnet_initialize_network ();
+#if defined(USE_FTPD)
   rtems_initialize_ftpd();
 
   status = Untar_FromMemory((unsigned char *)(&TARFILE_START), &TARFILE_SIZE);
+#endif
    
+#if defined(USE_HTTPD)
   rtems_initialize_webserver();
+#endif
 
   status = rtems_task_delete( RTEMS_SELF );
Index: netdemo/README
===================================================================
--- netdemo/README	(revision d37a99d444fcadc7574cab26cf9c081e7d0c6ab3)
+++ netdemo/README	(revision d51d8b5b51c6a0286eb1f7952b81799f3b0ef3eb)
@@ -3,5 +3,5 @@
 #
 
-A simple application to test some of the KA9Q networking code.
+A simple application to test some of the RTEMS/FreeBSD networking code.
 
     **************************
@@ -9,24 +9,19 @@
     **************************
 
-1. Make sure you change the definition of MY_ETHERNET_ADDRESS in init.c
-   before you try to use this program.
+BE SURE TO LOCALIZE networkconfig.h.  FAILURE TO DO SO MAY PROVOKE YOUR
+NETWORK ADMINISTRATOR TO THE POINT WHERE VICIOUS ATTACKS WILL BE MADE
+UPON YOU.
 
-2. If you do not use BOOTP (i.e. the `#define USE_BOOTP 1' in init.c is
-   removed), make sure you change the definition of MY_INTERNET_ADDRESS
-   before you try to use the program.
+Once this program is running on the target machine, you can test
+the network code by:
 
-FAILURE TO FOLLOW THE ABOVE INSTRUCTIONS MAY PROVOKE YOUR NETWORK
-ADMINISTRATOR TO THE POINT WHERE VICIOUS ATTACKS WILL BE MADE UPON YOU.
+ Typing commands at the target console:
+    - show network statistics
+    - transmit TCP packets
+    - transmit UDP packets
+    Run `telnet target_machine 24742' on another machines.
+ Everything you type should be echoed back and noted on
+ the target console.
+ You can run more than one telnet session at once.
+ You can use port number 24743 as well.
 
-3. Once this program is running on the target machine, you can test
-   the network code by:
-	a) Typing commands at the target console:
-		s - show network statistics
-		t - transmit TCP packets
-		u - transmit UDP packets
-	b) Run `telnet target_machine 24742' on another machines.
-	   Everything you type should be echoed back and noted on
-	   the target console.
-	   You can run more than one telnet session at once.
-	   You can use port number 24743 as well.
-
Index: networkconfig.h
===================================================================
--- networkconfig.h	(revision d37a99d444fcadc7574cab26cf9c081e7d0c6ab3)
+++ networkconfig.h	(revision d51d8b5b51c6a0286eb1f7952b81799f3b0ef3eb)
@@ -12,4 +12,12 @@
 #ifndef _RTEMS_NETWORKCONFIG_H_
 #define _RTEMS_NETWORKCONFIG_H_
+
+/*
+ *  The following will normally be set by the BSP if it supports
+ *  a single network device driver.  In the event, it supports
+ *  multiple network device drivers, then the user's default
+ *  network device driver will have to be selected by a BSP
+ *  specific mechanism.
+ */
 
 #ifndef RTEMS_BSP_NETWORK_DRIVER_NAME
Index: tftpTest/test.c
===================================================================
--- tftpTest/test.c	(revision d37a99d444fcadc7574cab26cf9c081e7d0c6ab3)
+++ tftpTest/test.c	(revision d51d8b5b51c6a0286eb1f7952b81799f3b0ef3eb)
@@ -1,4 +1,4 @@
 /*
- * Test RTEMS/KA9Q TFTP device driver
+ * Test RTEMS TFTP Client Filesystem
  *
  * This program may be distributed and used for any purpose.
@@ -23,16 +23,15 @@
 #include <sys/fcntl.h>
 #include <unistd.h>
-#include <malloc.h>
 
 static char cbuf[1024];
-static char *readName, *writeName;
+static char *fullname;
 static rtems_interval then, now;
 
 static void
-showRate (unsigned long byteCount)
+showRate (unsigned long totalRead)
 {
 	int elapsed;
 
-	printf ("Transferred %lu bytes", byteCount);
+	printf ("Read %lu bytes", totalRead);
 	elapsed = now - then;
 	if (elapsed) {
@@ -40,5 +39,5 @@
 		rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
 		printf (" (%ld bytes/sec)",
-				(long)(((long long)byteCount * ticksPerSecond)
+				(long)(((long long)totalRead * ticksPerSecond)
 								/ elapsed));
 	}
@@ -53,5 +52,5 @@
 	unsigned long totalRead = 0;
 
-	fd = open (readName, O_RDONLY);
+	fd = open (fullname, O_RDONLY);
 	if (fd < 0) {
 		printf ("Open failed: %s\n", strerror (errno));
@@ -83,5 +82,5 @@
 	unsigned long totalRead = 0;
 
-	fp = fopen (readName, "r");
+	fp = fopen (fullname, "r");
 	if (fp == NULL) {
 		printf ("Open failed: %s\n", strerror (errno));
@@ -106,120 +105,13 @@
 }
 
-static void
-testRawWrite (void)
-{
-	int fd;
-	int nwrite;
-	unsigned long totalWrite = 0;
-
-	fd = open (writeName, O_WRONLY|O_CREAT);
-	if (fd < 0) {
-		printf ("Open failed: %s\n", strerror (errno));
-		return;
-	}
-
-	rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &then);
-	while (totalWrite < (100 * 1024)) {
-		nwrite = write (fd, cbuf, sizeof cbuf);
-		if (nwrite != sizeof cbuf) {
-			printf ("Write failed: %s\n", strerror (errno));
-			close (fd);
-			return;
-		}
-		totalWrite += nwrite;
-	}
-	rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now);
-	close (fd);
-	showRate (totalWrite);
-}
-
-static void
-testFwrite (void)
-{
-	FILE *fp;
-	int nwrite;
-	unsigned long totalWrite = 0;
-
-	fp = fopen (writeName, "w");
-	if (fp == NULL) {
-		printf ("Open failed: %s\n", strerror (errno));
-		return;
-	}
-
-	rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &then);
-	while (totalWrite < (100 * 1024)) {
-		nwrite = fwrite (cbuf, sizeof cbuf[0], sizeof cbuf, fp);
-		if (nwrite != sizeof cbuf) {
-			printf ("Write failed: %s\n", strerror (errno));
-			fclose (fp);
-			return;
-		}
-		totalWrite += nwrite;
-	}
-	rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now);
-	fclose (fp);
-	showRate (totalWrite);
-}
-
-static void
-testFcopy (void)
-{
-	FILE *fin, *fout;
-	int nread, nwrite;
-	unsigned long totalRead = 0;
-
-	fin = fopen (readName, "r");
-	if (fin == NULL) {
-		printf ("Open (%s) failed: %s\n", readName, strerror (errno));
-		return;
-	}
-	fout = fopen (writeName, "w");
-	if (fout == NULL) {
-		printf ("Open (%s) failed: %s\n", writeName, strerror (errno));
-		fclose (fin);
-		return;
-	}
-
-	rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &then);
-	for (;;) {
-		nread = fread (cbuf, sizeof cbuf[0], sizeof cbuf, fin);
-		if (nread < 0) {
-			printf ("Read failed: %s\n", strerror (errno));
-			fclose (fin);
-			fclose (fout);
-			return;
-		}
-		if (nread == 0)
-			break;
-		nwrite = fwrite (cbuf, sizeof cbuf[0], nread, fout);
-		if (nwrite != nread) {
-			printf ("Write failed: %s\n", strerror (errno));
-			fclose (fin);
-			fclose (fout);
-			return;
-		}
-		totalRead += nread;
-	}
-	rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now);
-	fclose (fin);
-	fclose (fout);
-	showRate (totalRead);
-}
-
-static void
-makeFullName (const char *hostname, const char *file, int flags)
+static int
+makeFullname (const char *hostname, const char *file)
 {
 	if (hostname == NULL)
 		hostname = "";
-	if ((flags == O_RDONLY) || (flags == O_RDWR)) {
-		readName = realloc (readName, 8 + strlen (file) + strlen (hostname));
-		sprintf (readName, "/TFTP/%s/%s", hostname, file);
-		printf ("Read `%s'.\n", readName);
-	}
-	if ((flags == O_WRONLY) || (flags == O_RDWR)) {
-		writeName = realloc (writeName, 12 + strlen (file) + strlen (hostname));
-		sprintf (writeName, "/TFTP/%s/%s.tmp", hostname, file);
-		printf ("Write `%s'.\n", writeName);
-	}
+	fullname = realloc (fullname, 8 + strlen (file) + strlen (hostname));
+	sprintf (fullname, "/TFTP/%s/%s", hostname, file);
+	printf ("Read `%s'.\n", fullname);
+	return 1;
 }
 
@@ -227,26 +119,26 @@
 testTFTP (const char *hostname, const char *filename)
 {
-	printf ("*** Check that invalid file names are reported as such.\n");
-	makeFullName (hostname, "", O_RDONLY);
-	testRawRead ();
-	testFread ();
+	/*
+	 * Check that invalid file names are reported as such
+	 */
+	if (makeFullname (hostname, "")) {
+		testRawRead ();
+		testFread ();
+	}
 
-	printf ("*** Check that non-existent files are reported as such.\n");
-	makeFullName (hostname, "BAD-FILE-NAME", O_RDONLY);
-	testRawRead ();
-	testFread ();
+	/*
+	 * Check that non-existent files are reported as such
+	 */
+	if (makeFullname (hostname, "BAD-FILE-NAME")) {
+		testRawRead ();
+		testFread ();
+	}
 
-	printf ("*** Check that file read operations work.\n");
-	makeFullName (hostname, filename, O_RDONLY);
-	testRawRead ();
-	testFread ();
-
-	printf ("*** Check that file write operations work.\n");
-	makeFullName (hostname, filename, O_WRONLY);
-	testRawWrite ();
-	testFwrite ();
-
-	printf ("*** Check that file copy operations work.\n");
-	makeFullName (hostname, filename, O_RDWR);
-	testFcopy ();
+	/*
+	 * Check that read works
+	 */
+	if (makeFullname (hostname, filename)) {
+		testRawRead ();
+		testFread ();
+	}
 }
