Changeset d51d8b5 in network-demos


Ignore:
Timestamp:
Aug 31, 2001, 6:11:44 PM (18 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
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
Message:

2001-08-30 Joel Sherrill <joel@…>

  • 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.
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rd37a99d rd51d8b5  
     12001-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
    182000-12-14      Eric Norum <eric.norum@usask.ca>
    29
  • README

    rd37a99d rd51d8b5  
     1#
     2# $Id$
     3#
     4
     5This directory contains a set of network tests and demonstrations
     6programs. 
     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
     19The file networkconfig.h MUST be configured to reflect your local
     20network according to the included Configuration Notes.
     21
     22CONFIGURATION NOTES
     23===================
     24
     251. 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
     292. 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
     33FAILURE TO FOLLOW THE ABOVE INSTRUCTIONS MAY PROVOKE YOUR NETWORK
     34ADMINISTRATOR TO THE POINT WHERE VICIOUS ATTACKS WILL BE MADE UPON YOU.
     35
  • http/Makefile

    rd37a99d rd51d8b5  
    4242LD_PATHS  +=
    4343LD_LIBS   +=
     44NATIVE_OBJ = $(shell $(OBJCOPY) 2>&1  | grep copy: | cut -d':' -f3 | cut -d' ' -f2)
    4445
    4546#
     
    5657
    5758${PGM}: $(OBJS) $(LINK_FILES)
    58         cd rootfs ; tar cf ../$(ARCH)/tarfile web etc
     59        cd rootfs ; tar cf ../$(ARCH)/tarfile web etc
    5960        cp $(ARCH)/tarfile .
    60         $(OBJCOPY) -I binary -O elf32-powerpc tarfile $(ARCH)/tarfile.o
     61        $(OBJCOPY) -I binary -O $(NATIVE_OBJ) tarfile $(ARCH)/tarfile.o
    6162        $(LD) -r -o $(ARCH)/temp.o  $(ARCH)/init.o $(ARCH)/tarfile.o
    6263        $(MV) $(ARCH)/temp.o  $(ARCH)/init.o
  • http/init.c

    rd37a99d rd51d8b5  
    66 */
    77
     8#define USE_HTTPD
     9#define USE_FTPD
    810#define TEST_INIT
    911
     
    5860 */
    5961
     62#if defined(USE_FTPD)
     63/*
    6064#if defined(RTEMS_DEBUG)
    6165extern int _binary_o_debug_tarfile_start;
     
    6973#define TARFILE_SIZE _binary_o_optimize_tarfile_size
    7074#endif
     75*/
     76extern int _binary_tarfile_start;
     77extern int _binary_tarfile_size;
     78#define TARFILE_START _binary_tarfile_start
     79#define TARFILE_SIZE _binary_tarfile_size
     80#endif
    7181
     82#if defined(USE_FTPD)
    7283struct rtems_ftpd_configuration rtems_ftpd_configuration = {
    7384   10,                     /* FTPD task priority            */
     
    7687   NULL                    /* List of hooks       */
    7788};
     89#endif
    7890rtems_task Init(
    7991  rtems_task_argument argument
     
    8799
    88100  rtems_bsdnet_initialize_network ();
     101#if defined(USE_FTPD)
    89102  rtems_initialize_ftpd();
    90103
    91104  status = Untar_FromMemory((unsigned char *)(&TARFILE_START), &TARFILE_SIZE);
     105#endif
    92106   
     107#if defined(USE_HTTPD)
    93108  rtems_initialize_webserver();
     109#endif
    94110
    95111  status = rtems_task_delete( RTEMS_SELF );
  • netdemo/README

    rd37a99d rd51d8b5  
    33#
    44
    5 A simple application to test some of the KA9Q networking code.
     5A simple application to test some of the RTEMS/FreeBSD networking code.
    66
    77    **************************
     
    99    **************************
    1010
    11 1. Make sure you change the definition of MY_ETHERNET_ADDRESS in init.c
    12    before you try to use this program.
     11BE SURE TO LOCALIZE networkconfig.h.  FAILURE TO DO SO MAY PROVOKE YOUR
     12NETWORK ADMINISTRATOR TO THE POINT WHERE VICIOUS ATTACKS WILL BE MADE
     13UPON YOU.
    1314
    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.
     15Once this program is running on the target machine, you can test
     16the network code by:
    1717
    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.
    2027
    21 3. Once this program is running on the target machine, you can test
    22    the network code by:
    23         a) Typing commands at the target console:
    24                 s - show network statistics
    25                 t - transmit TCP packets
    26                 u - transmit UDP packets
    27         b) Run `telnet target_machine 24742' on another machines.
    28            Everything you type should be echoed back and noted on
    29            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  
    1212#ifndef _RTEMS_NETWORKCONFIG_H_
    1313#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 */
    1422
    1523#ifndef RTEMS_BSP_NETWORK_DRIVER_NAME
  • tftpTest/test.c

    rd37a99d rd51d8b5  
    11/*
    2  * Test RTEMS/KA9Q TFTP device driver
     2 * Test RTEMS TFTP Client Filesystem
    33 *
    44 * This program may be distributed and used for any purpose.
     
    2323#include <sys/fcntl.h>
    2424#include <unistd.h>
    25 #include <malloc.h>
    2625
    2726static char cbuf[1024];
    28 static char *readName, *writeName;
     27static char *fullname;
    2928static rtems_interval then, now;
    3029
    3130static void
    32 showRate (unsigned long byteCount)
     31showRate (unsigned long totalRead)
    3332{
    3433        int elapsed;
    3534
    36         printf ("Transferred %lu bytes", byteCount);
     35        printf ("Read %lu bytes", totalRead);
    3736        elapsed = now - then;
    3837        if (elapsed) {
     
    4039                rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
    4140                printf (" (%ld bytes/sec)",
    42                                 (long)(((long long)byteCount * ticksPerSecond)
     41                                (long)(((long long)totalRead * ticksPerSecond)
    4342                                                                / elapsed));
    4443        }
     
    5352        unsigned long totalRead = 0;
    5453
    55         fd = open (readName, O_RDONLY);
     54        fd = open (fullname, O_RDONLY);
    5655        if (fd < 0) {
    5756                printf ("Open failed: %s\n", strerror (errno));
     
    8382        unsigned long totalRead = 0;
    8483
    85         fp = fopen (readName, "r");
     84        fp = fopen (fullname, "r");
    8685        if (fp == NULL) {
    8786                printf ("Open failed: %s\n", strerror (errno));
     
    106105}
    107106
    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)
     107static int
     108makeFullname (const char *hostname, const char *file)
    211109{
    212110        if (hostname == NULL)
    213111                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;
    224116}
    225117
     
    227119testTFTP (const char *hostname, const char *filename)
    228120{
    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        }
    233128
    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        }
    238136
    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        }
    252144}
Note: See TracChangeset for help on using the changeset viewer.