Changeset d51d8b5 in network-demos
- Timestamp:
- Aug 31, 2001, 6:11:44 PM (19 years ago)
- Branches:
- 4.11, master, network-demos-4-10-branch, network-demos-4-6-branch, network-demos-4-7-branch, network-demos-4-8-branch, network-demos-4-9-branch
- Children:
- f2c5ef8
- Parents:
- d37a99d
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
rd37a99d rd51d8b5 1 2001-08-30 Joel Sherrill <joel@OARcorp.com> 2 3 * README, networkconfig.h, netdemo/README, tftpTest/test.c: Merged 4 missing stuff from 4.5 branch. 5 * http/Makefile, http/init.c: Minor modifications to improve 6 buildability. 7 1 8 2000-12-14 Eric Norum <eric.norum@usask.ca> 2 9 -
README
rd37a99d rd51d8b5 1 # 2 # $Id$ 3 # 4 5 This directory contains a set of network tests and demonstrations 6 programs. 7 8 netdemo - simplest test, echos data on sockets 9 dnstest - test of DNS client 10 http - test of GoAhead web server 11 netlink - link only test to evaluate code space requirement 12 of network stack, ftpd, and httpd 13 ntp - test of network time protocol client 14 rpc_demo - test of RPC library 15 select - test of select() routine functionality 16 tftpTest - test of TFTP (Trivial FTP) client filesystem 17 ttcp - TTCP throughput test 18 19 The file networkconfig.h MUST be configured to reflect your local 20 network according to the included Configuration Notes. 21 22 CONFIGURATION NOTES 23 =================== 24 25 1. Make sure you change the definition of MY_ETHERNET_ADDRESS in 26 networkconfig.h before you try to use any of the network 27 demonstration programs. 28 29 2. If you do not use BOOTP (i.e. the `#define USE_BOOTP 1' in init.c is 30 removed), make sure you change the definition of MY_INTERNET_ADDRESS 31 before you try to use the programs. 32 33 FAILURE TO FOLLOW THE ABOVE INSTRUCTIONS MAY PROVOKE YOUR NETWORK 34 ADMINISTRATOR TO THE POINT WHERE VICIOUS ATTACKS WILL BE MADE UPON YOU. 35 -
http/Makefile
rd37a99d rd51d8b5 42 42 LD_PATHS += 43 43 LD_LIBS += 44 NATIVE_OBJ = $(shell $(OBJCOPY) 2>&1 | grep copy: | cut -d':' -f3 | cut -d' ' -f2) 44 45 45 46 # … … 56 57 57 58 ${PGM}: $(OBJS) $(LINK_FILES) 58 59 cd rootfs ; tar cf ../$(ARCH)/tarfile web etc 59 60 cp $(ARCH)/tarfile . 60 $(OBJCOPY) -I binary -O elf32-powerpctarfile $(ARCH)/tarfile.o61 $(OBJCOPY) -I binary -O $(NATIVE_OBJ) tarfile $(ARCH)/tarfile.o 61 62 $(LD) -r -o $(ARCH)/temp.o $(ARCH)/init.o $(ARCH)/tarfile.o 62 63 $(MV) $(ARCH)/temp.o $(ARCH)/init.o -
http/init.c
rd37a99d rd51d8b5 6 6 */ 7 7 8 #define USE_HTTPD 9 #define USE_FTPD 8 10 #define TEST_INIT 9 11 … … 58 60 */ 59 61 62 #if defined(USE_FTPD) 63 /* 60 64 #if defined(RTEMS_DEBUG) 61 65 extern int _binary_o_debug_tarfile_start; … … 69 73 #define TARFILE_SIZE _binary_o_optimize_tarfile_size 70 74 #endif 75 */ 76 extern int _binary_tarfile_start; 77 extern int _binary_tarfile_size; 78 #define TARFILE_START _binary_tarfile_start 79 #define TARFILE_SIZE _binary_tarfile_size 80 #endif 71 81 82 #if defined(USE_FTPD) 72 83 struct rtems_ftpd_configuration rtems_ftpd_configuration = { 73 84 10, /* FTPD task priority */ … … 76 87 NULL /* List of hooks */ 77 88 }; 89 #endif 78 90 rtems_task Init( 79 91 rtems_task_argument argument … … 87 99 88 100 rtems_bsdnet_initialize_network (); 101 #if defined(USE_FTPD) 89 102 rtems_initialize_ftpd(); 90 103 91 104 status = Untar_FromMemory((unsigned char *)(&TARFILE_START), &TARFILE_SIZE); 105 #endif 92 106 107 #if defined(USE_HTTPD) 93 108 rtems_initialize_webserver(); 109 #endif 94 110 95 111 status = rtems_task_delete( RTEMS_SELF ); -
netdemo/README
rd37a99d rd51d8b5 3 3 # 4 4 5 A simple application to test some of the KA9Qnetworking code.5 A simple application to test some of the RTEMS/FreeBSD networking code. 6 6 7 7 ************************** … … 9 9 ************************** 10 10 11 1. Make sure you change the definition of MY_ETHERNET_ADDRESS in init.c 12 before you try to use this program. 11 BE SURE TO LOCALIZE networkconfig.h. FAILURE TO DO SO MAY PROVOKE YOUR 12 NETWORK ADMINISTRATOR TO THE POINT WHERE VICIOUS ATTACKS WILL BE MADE 13 UPON YOU. 13 14 14 2. If you do not use BOOTP (i.e. the `#define USE_BOOTP 1' in init.c is 15 removed), make sure you change the definition of MY_INTERNET_ADDRESS 16 before you try to use the program. 15 Once this program is running on the target machine, you can test 16 the network code by: 17 17 18 FAILURE TO FOLLOW THE ABOVE INSTRUCTIONS MAY PROVOKE YOUR NETWORK 19 ADMINISTRATOR TO THE POINT WHERE VICIOUS ATTACKS WILL BE MADE UPON YOU. 18 Typing commands at the target console: 19 - show network statistics 20 - transmit TCP packets 21 - transmit UDP packets 22 Run `telnet target_machine 24742' on another machines. 23 Everything you type should be echoed back and noted on 24 the target console. 25 You can run more than one telnet session at once. 26 You can use port number 24743 as well. 20 27 21 3. Once this program is running on the target machine, you can test22 the network code by:23 a) Typing commands at the target console:24 s - show network statistics25 t - transmit TCP packets26 u - transmit UDP packets27 b) Run `telnet target_machine 24742' on another machines.28 Everything you type should be echoed back and noted on29 the target console.30 You can run more than one telnet session at once.31 You can use port number 24743 as well.32 -
networkconfig.h
rd37a99d rd51d8b5 12 12 #ifndef _RTEMS_NETWORKCONFIG_H_ 13 13 #define _RTEMS_NETWORKCONFIG_H_ 14 15 /* 16 * The following will normally be set by the BSP if it supports 17 * a single network device driver. In the event, it supports 18 * multiple network device drivers, then the user's default 19 * network device driver will have to be selected by a BSP 20 * specific mechanism. 21 */ 14 22 15 23 #ifndef RTEMS_BSP_NETWORK_DRIVER_NAME -
tftpTest/test.c
rd37a99d rd51d8b5 1 1 /* 2 * Test RTEMS /KA9Q TFTP device driver2 * Test RTEMS TFTP Client Filesystem 3 3 * 4 4 * This program may be distributed and used for any purpose. … … 23 23 #include <sys/fcntl.h> 24 24 #include <unistd.h> 25 #include <malloc.h>26 25 27 26 static char cbuf[1024]; 28 static char * readName, *writeName;27 static char *fullname; 29 28 static rtems_interval then, now; 30 29 31 30 static void 32 showRate (unsigned long byteCount)31 showRate (unsigned long totalRead) 33 32 { 34 33 int elapsed; 35 34 36 printf (" Transferred %lu bytes", byteCount);35 printf ("Read %lu bytes", totalRead); 37 36 elapsed = now - then; 38 37 if (elapsed) { … … 40 39 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond); 41 40 printf (" (%ld bytes/sec)", 42 (long)(((long long) byteCount* ticksPerSecond)41 (long)(((long long)totalRead * ticksPerSecond) 43 42 / elapsed)); 44 43 } … … 53 52 unsigned long totalRead = 0; 54 53 55 fd = open ( readName, O_RDONLY);54 fd = open (fullname, O_RDONLY); 56 55 if (fd < 0) { 57 56 printf ("Open failed: %s\n", strerror (errno)); … … 83 82 unsigned long totalRead = 0; 84 83 85 fp = fopen ( readName, "r");84 fp = fopen (fullname, "r"); 86 85 if (fp == NULL) { 87 86 printf ("Open failed: %s\n", strerror (errno)); … … 106 105 } 107 106 108 static void 109 testRawWrite (void) 110 { 111 int fd; 112 int nwrite; 113 unsigned long totalWrite = 0; 114 115 fd = open (writeName, O_WRONLY|O_CREAT); 116 if (fd < 0) { 117 printf ("Open failed: %s\n", strerror (errno)); 118 return; 119 } 120 121 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &then); 122 while (totalWrite < (100 * 1024)) { 123 nwrite = write (fd, cbuf, sizeof cbuf); 124 if (nwrite != sizeof cbuf) { 125 printf ("Write failed: %s\n", strerror (errno)); 126 close (fd); 127 return; 128 } 129 totalWrite += nwrite; 130 } 131 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now); 132 close (fd); 133 showRate (totalWrite); 134 } 135 136 static void 137 testFwrite (void) 138 { 139 FILE *fp; 140 int nwrite; 141 unsigned long totalWrite = 0; 142 143 fp = fopen (writeName, "w"); 144 if (fp == NULL) { 145 printf ("Open failed: %s\n", strerror (errno)); 146 return; 147 } 148 149 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &then); 150 while (totalWrite < (100 * 1024)) { 151 nwrite = fwrite (cbuf, sizeof cbuf[0], sizeof cbuf, fp); 152 if (nwrite != sizeof cbuf) { 153 printf ("Write failed: %s\n", strerror (errno)); 154 fclose (fp); 155 return; 156 } 157 totalWrite += nwrite; 158 } 159 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now); 160 fclose (fp); 161 showRate (totalWrite); 162 } 163 164 static void 165 testFcopy (void) 166 { 167 FILE *fin, *fout; 168 int nread, nwrite; 169 unsigned long totalRead = 0; 170 171 fin = fopen (readName, "r"); 172 if (fin == NULL) { 173 printf ("Open (%s) failed: %s\n", readName, strerror (errno)); 174 return; 175 } 176 fout = fopen (writeName, "w"); 177 if (fout == NULL) { 178 printf ("Open (%s) failed: %s\n", writeName, strerror (errno)); 179 fclose (fin); 180 return; 181 } 182 183 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &then); 184 for (;;) { 185 nread = fread (cbuf, sizeof cbuf[0], sizeof cbuf, fin); 186 if (nread < 0) { 187 printf ("Read failed: %s\n", strerror (errno)); 188 fclose (fin); 189 fclose (fout); 190 return; 191 } 192 if (nread == 0) 193 break; 194 nwrite = fwrite (cbuf, sizeof cbuf[0], nread, fout); 195 if (nwrite != nread) { 196 printf ("Write failed: %s\n", strerror (errno)); 197 fclose (fin); 198 fclose (fout); 199 return; 200 } 201 totalRead += nread; 202 } 203 rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now); 204 fclose (fin); 205 fclose (fout); 206 showRate (totalRead); 207 } 208 209 static void 210 makeFullName (const char *hostname, const char *file, int flags) 107 static int 108 makeFullname (const char *hostname, const char *file) 211 109 { 212 110 if (hostname == NULL) 213 111 hostname = ""; 214 if ((flags == O_RDONLY) || (flags == O_RDWR)) { 215 readName = realloc (readName, 8 + strlen (file) + strlen (hostname)); 216 sprintf (readName, "/TFTP/%s/%s", hostname, file); 217 printf ("Read `%s'.\n", readName); 218 } 219 if ((flags == O_WRONLY) || (flags == O_RDWR)) { 220 writeName = realloc (writeName, 12 + strlen (file) + strlen (hostname)); 221 sprintf (writeName, "/TFTP/%s/%s.tmp", hostname, file); 222 printf ("Write `%s'.\n", writeName); 223 } 112 fullname = realloc (fullname, 8 + strlen (file) + strlen (hostname)); 113 sprintf (fullname, "/TFTP/%s/%s", hostname, file); 114 printf ("Read `%s'.\n", fullname); 115 return 1; 224 116 } 225 117 … … 227 119 testTFTP (const char *hostname, const char *filename) 228 120 { 229 printf ("*** Check that invalid file names are reported as such.\n"); 230 makeFullName (hostname, "", O_RDONLY); 231 testRawRead (); 232 testFread (); 121 /* 122 * Check that invalid file names are reported as such 123 */ 124 if (makeFullname (hostname, "")) { 125 testRawRead (); 126 testFread (); 127 } 233 128 234 printf ("*** Check that non-existent files are reported as such.\n"); 235 makeFullName (hostname, "BAD-FILE-NAME", O_RDONLY); 236 testRawRead (); 237 testFread (); 129 /* 130 * Check that non-existent files are reported as such 131 */ 132 if (makeFullname (hostname, "BAD-FILE-NAME")) { 133 testRawRead (); 134 testFread (); 135 } 238 136 239 printf ("*** Check that file read operations work.\n"); 240 makeFullName (hostname, filename, O_RDONLY); 241 testRawRead (); 242 testFread (); 243 244 printf ("*** Check that file write operations work.\n"); 245 makeFullName (hostname, filename, O_WRONLY); 246 testRawWrite (); 247 testFwrite (); 248 249 printf ("*** Check that file copy operations work.\n"); 250 makeFullName (hostname, filename, O_RDWR); 251 testFcopy (); 137 /* 138 * Check that read works 139 */ 140 if (makeFullname (hostname, filename)) { 141 testRawRead (); 142 testFread (); 143 } 252 144 }
Note: See TracChangeset
for help on using the changeset viewer.