From d51d8b5b51c6a0286eb1f7952b81799f3b0ef3eb Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 31 Aug 2001 18:11:44 +0000 Subject: 2001-08-30 Joel Sherrill * 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. --- ChangeLog | 7 +++ README | 35 +++++++++++ http/Makefile | 5 +- http/init.c | 16 ++++++ netdemo/README | 35 +++++------ networkconfig.h | 8 +++ tftpTest/test.c | 176 +++++++++++--------------------------------------------- 7 files changed, 118 insertions(+), 164 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3cbe2a..4584313 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-08-30 Joel Sherrill + + * 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 * networkconfig.h: Default to using bootp host for tftp test. diff --git a/README b/README index e69de29..fd73bfe 100644 --- a/README +++ b/README @@ -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. + diff --git a/http/Makefile b/http/Makefile index cb05daf..2343b60 100644 --- a/http/Makefile +++ b/http/Makefile @@ -41,6 +41,7 @@ CFLAGS_DEBUG_V += -v -qrtems_debug LD_PATHS += LD_LIBS += +NATIVE_OBJ = $(shell $(OBJCOPY) 2>&1 | grep copy: | cut -d':' -f3 | cut -d' ' -f2) # # Add your list of files to delete here. The config files @@ -55,9 +56,9 @@ CLOBBER_ADDITIONS += all: ${ARCH} $(SRCS) $(PGM) ${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 $(RM) $(ARCH)/temp.o diff --git a/http/init.c b/http/init.c index eea4873..9ade8c4 100644 --- a/http/init.c +++ b/http/init.c @@ -5,6 +5,8 @@ * Don't forget to change the IP addresses */ +#define USE_HTTPD +#define USE_FTPD #define TEST_INIT #define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER @@ -57,6 +59,8 @@ * built optimized or debug. */ +#if defined(USE_FTPD) +/* #if defined(RTEMS_DEBUG) extern int _binary_o_debug_tarfile_start; extern int _binary_o_debug_tarfile_size; @@ -68,13 +72,21 @@ extern int _binary_o_optimize_tarfile_size; #define TARFILE_START _binary_o_optimize_tarfile_start #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 */ 1024, /* Maximum buffersize for hooks */ 21, /* Well-known port */ NULL /* List of hooks */ }; +#endif rtems_task Init( rtems_task_argument argument ) @@ -86,11 +98,15 @@ rtems_task Init( /* init_paging(); */ 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 ); } diff --git a/netdemo/README b/netdemo/README index 143b7b6..80bd7aa 100644 --- a/netdemo/README +++ b/netdemo/README @@ -2,31 +2,26 @@ # $Id$ # -A simple application to test some of the KA9Q networking code. +A simple application to test some of the RTEMS/FreeBSD networking code. ************************** * NOTES * ************************** -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. - -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. + 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. diff --git a/networkconfig.h b/networkconfig.h index e0b1bf5..1b0d1e9 100644 --- a/networkconfig.h +++ b/networkconfig.h @@ -12,6 +12,14 @@ #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 #warning "RTEMS_BSP_NETWORK_DRIVER_NAME is not defined" #define RTEMS_BSP_NETWORK_DRIVER_NAME "no_network1" diff --git a/tftpTest/test.c b/tftpTest/test.c index 8ef3119..75e4666 100644 --- a/tftpTest/test.c +++ b/tftpTest/test.c @@ -1,5 +1,5 @@ /* - * Test RTEMS/KA9Q TFTP device driver + * Test RTEMS TFTP Client Filesystem * * This program may be distributed and used for any purpose. * I ask only that you: @@ -22,24 +22,23 @@ #include #include #include -#include 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) { rtems_interval ticksPerSecond; 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)); } printf (".\n"); @@ -52,7 +51,7 @@ testRawRead (void) int nread; unsigned long totalRead = 0; - fd = open (readName, O_RDONLY); + fd = open (fullname, O_RDONLY); if (fd < 0) { printf ("Open failed: %s\n", strerror (errno)); return; @@ -82,7 +81,7 @@ testFread (void) int nread; unsigned long totalRead = 0; - fp = fopen (readName, "r"); + fp = fopen (fullname, "r"); if (fp == NULL) { printf ("Open failed: %s\n", strerror (errno)); return; @@ -105,148 +104,41 @@ testFread (void) showRate (totalRead); } -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; } void testTFTP (const char *hostname, const char *filename) { - printf ("*** Check that invalid file names are reported as such.\n"); - makeFullName (hostname, "", O_RDONLY); - testRawRead (); - testFread (); - - printf ("*** Check that non-existent files are reported as such.\n"); - makeFullName (hostname, "BAD-FILE-NAME", O_RDONLY); - testRawRead (); - testFread (); - - printf ("*** Check that file read operations work.\n"); - makeFullName (hostname, filename, O_RDONLY); - testRawRead (); - testFread (); + /* + * Check that invalid file names are reported as such + */ + if (makeFullname (hostname, "")) { + testRawRead (); + testFread (); + } - printf ("*** Check that file write operations work.\n"); - makeFullName (hostname, filename, O_WRONLY); - testRawWrite (); - testFwrite (); + /* + * Check that non-existent files are reported as such + */ + if (makeFullname (hostname, "BAD-FILE-NAME")) { + testRawRead (); + testFread (); + } - printf ("*** Check that file copy operations work.\n"); - makeFullName (hostname, filename, O_RDWR); - testFcopy (); + /* + * Check that read works + */ + if (makeFullname (hostname, filename)) { + testRawRead (); + testFread (); + } } -- cgit v1.2.3