Changeset 0c9330e in network-demos


Ignore:
Timestamp:
Aug 21, 1998, 1:22:35 PM (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master, netdemos-4-5-branch, 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, rtems-4-5-branch
Children:
7ba2ac5
Parents:
4cfe89f
Message:

KA9Q -> FreeBSD changes from Eric Norum

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • netdemo/Makefile

    r4cfe89f r0c9330e  
    1 #
    2 #  $Id$
    3 #
    4 
    51SAMPLE=netdemo
    62PGM=${ARCH}/$(SAMPLE).exe
    73
    8 MANAGERS=io message event semaphore timer rate_monotonic region
     4MANAGERS=io event semaphore
    95
    106# C source names, if any, go here -- minus the .c
    11 C_PIECES= init test
     7C_PIECES= init  test
    128C_FILES=$(C_PIECES:%=%.c)
    139C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
     
    3632CPPFLAGS +=
    3733CFLAGS   +=
    38 CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0xC0000  # KA9Q needs more space
     34CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0xC0000 
    3935CFLAGS_OPTIMIZE_V   +=
    4036CFLAGS_DEBUG_V   += -v -qrtems_debug
  • netdemo/init.c

    r4cfe89f r0c9330e  
    1212 * Saskatoon, Saskatchewan, CANADA
    1313 * eric@skatter.usask.ca
    14  *
    15  * $Id$
    1614 */
    17 
    18 /*
    19  *  Include user provided information
    20  */
    21 
    22 #include "../usercfg.h"
    2315
    2416#include <bsp.h>
     
    3123#define CONFIGURE_MAXIMUM_SEMAPHORES    20
    3224#define CONFIGURE_MAXIMUM_TASKS         20
    33 #define CONFIGURE_MAXIMUM_TIMERS        10
    34 #define CONFIGURE_MAXIMUM_PERIODS       1
    3525
    3626#define CONFIGURE_MICROSECONDS_PER_TICK 10486
    3727
    3828#define CONFIGURE_INIT_TASK_STACK_SIZE  (10*1024)
    39 #define CONFIGURE_INIT_TASK_PRIORITY    100
     29#define CONFIGURE_INIT_TASK_PRIORITY    120
    4030#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
    4131                                           RTEMS_NO_TIMESLICE | \
     
    4939
    5040#include <stdio.h>
    51 #include <rtems_ka9q.h>
    52 
    53 
    54 #if (defined (USE_BOOTP))
    55 #include <bootp.h>
    56 #endif
    57 
    58 /*
    59  * Suspend execution for the specified number of seconds
    60  */
    61 static void
    62 delay_task (int seconds)
    63 {
    64         rtems_interval ticksPerSecond;
    65 
    66         rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
    67         rtems_task_wake_after (seconds * ticksPerSecond);
    68 }
     41#include <rtems/rtems_bsdnet.h>
     42#include "../networkconfig.h"
    6943
    7044/*
     
    7448Init (rtems_task_argument ignored)
    7549{
    76         printf( "\n\n*** ETHERNET DEMO TEST ***\n" );
     50        int doSocket(void);
    7751
    78         /*
    79          * Start KA9Q
    80          */
    81         puts( "Starting KA9Q" );
    82         rtems_ka9q_start (50);
    83 
    84         /*
    85          * Hook up drivers
    86          */
    87         puts( "Attaching to the network" );
    88         if (rtems_ka9q_execute_command ("attach rtems broadcast y"
    89 #if !(defined (USE_BOOTP))
    90                                         " ip " MY_IP_ADDRESS
    91 #endif
    92                                         " ether " MY_ETHERNET_ADDRESS))
    93                 rtems_panic ("Can't attach Ethernet driver.\n");
    94 
    95 #if (defined (TRACE_NETWORK_DRIVER))
    96         /*
    97          * Turn on debugging
    98          */
    99         puts( "Enabling debug mode of KA9Q" );
    100         if (rtems_ka9q_execute_command ("trace rtems input <stdout>")
    101          || rtems_ka9q_execute_command ("trace rtems output <stdout>")
    102          || rtems_ka9q_execute_command ("trace rtems ascii <stdout>"))
    103                 rtems_panic ("Can't set tracing for Ethernet driver.\n");
    104 #endif
    105 
    106         /*
    107          * Configure the driver
    108          */
    109         if (rtems_ka9q_execute_command ("ifconfig rtems broadcast 255.255.255.255"))
    110                 rtems_panic ("Can't configure Ethernet driver.\n");
    111 
    112         /*
    113          * Add the ethernet broadcast address to the ARP table.
    114          */
    115         if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF"))
    116                 rtems_panic ("Can't add broadcast entry to ARP table.\n");
    117 
    118 #if (defined (USE_BOOTP))
    119         {
    120         int i;
    121         /*
    122          * Get BOOTP information
    123          */
    124         for (i = 0 ; ; ) {
    125                 if (rtems_ka9q_execute_command ("bootp") == 0)
    126                         break;
    127                 if (++i == 10)
    128                         rtems_panic ("Can't get information from BOOTP server.\n");
    129                 delay_task (i);
    130         }
    131         if (BootpFileName)
    132                 printf ("BOOTP filename: `%s'\n", BootpFileName);
    133         else
    134                 printf ("BOOTP -- No filename!\n");
    135         }
    136 #else
    137         if (rtems_ka9q_execute_command ("ifconfig rtems netmask 255.255.255.0"))
    138                 rtems_panic ("Can't set netmask.\n");
    139         if (rtems_ka9q_execute_command ("route add default rtems"))
    140                 rtems_panic ("Can't add default route.\n");
    141         printf ("Routing table after adding default route\n");
    142         rtems_ka9q_execute_command ("route");
    143 #endif
    144 
    145         /*
    146          * Issue a gratuitous ARP request to update tables in
    147          * other hosts on this network.
    148          */
    149         if (rtems_ka9q_execute_command ("arp gratuitous rtems"))
    150                 rtems_panic ("Can't send gratuitous ARP.\n");
    151        
    152         /*
    153          * Everything is now running
    154          */
    155         printf ("NETWORK INITIALIZED!\n");
    156 
    157         /*
    158          * See if sockets work properly
    159          */
     52        rtems_bsdnet_initialize_network ();
    16053        doSocket ();
    161 
    162         /*
    163          * Wind things up
    164          */
    165         delay_task (2);
    166         rtems_ka9q_execute_command ("detach rtems");
    16754        exit (0);
    16855}
  • netdemo/test.c

    r4cfe89f r0c9330e  
    11/*
    2  * Test KA9Q networking
     2 * Test RTEMS networking
    33 *
    44 * This program may be distributed and used for any purpose.
     
    1212 * Saskatoon, Saskatchewan, CANADA
    1313 * eric@skatter.usask.ca
    14  *
    15  * $Id$
    16  */
    17 
     14 */
    1815#include <stdio.h>
     16#include <string.h>
     17#include <errno.h>
    1918#include <unistd.h>
    2019#include <rtems.h>
     20#include <rtems/rtems_bsdnet.h>
    2121#include <rtems/error.h>
    22 #include <socket.h>
    23 #include <sockaddr.h>
    24 #include <netuser.h>
    25 #include <rtems_ka9q.h>
    26 
    27 #include "../usercfg.h"
    28 
    29 /*
    30  * Display the contents of several KA9Q tables
    31  */
    32 static void
    33 show_ka9q_tables (void)
    34 {
    35         printf ("\n****************** MALLOC Statistics ***************\n");
    36         malloc_dump ();
    37         printf ("\n****************** MBUF Statistics ***************\n");
    38         mbufstat ();
    39         mbufsizes ();
    40         printf ("\n****************** Routing Table ***************\n");
    41         rtems_ka9q_execute_command ("route");
    42         printf ("\n****************** ARP Table ***************\n");
    43         rtems_ka9q_execute_command ("arp");
    44         printf ("\n****************** Driver Statistics ***************\n");
    45         rtems_ka9q_execute_command ("ifconfig rtems");
    46         printf ("\n****************** Ip Statistics ***************\n");
    47         rtems_ka9q_execute_command ("ip status");
    48         printf ("\n****************** ICMP Statistics ***************\n");
    49         rtems_ka9q_execute_command ("icmp status");
    50         printf ("\n****************** UDP Statistics ***************\n");
    51         rtems_ka9q_execute_command ("udp status");
    52         printf ("\n****************** TCP Statistics ***************\n");
    53         rtems_ka9q_execute_command ("tcp status");
     22#include <sys/types.h>
     23#include <sys/socket.h>
     24#include <netinet/in.h>
     25
     26#define NSERVER         2
     27#define BASE_PORT       24742
     28
     29#define DATA_SINK_HOST  ((128 << 24) | (233 << 16) | (14 << 8) | 60)
     30
     31void showbroad(int s)
     32{
     33        int opt;
     34        int optlen = sizeof opt;
     35
     36        if (getsockopt (s, SOL_SOCKET, SO_BROADCAST, &opt, &optlen) < 0)
     37                printf ("getsockopt failed: %s\n", strerror (errno));
     38        printf ("Opt:%d    Optlen:%d\n", opt, optlen);
     39}
     40
     41static
     42void
     43showStatistics (void)
     44{
     45        rtems_bsdnet_show_inet_routes ();
     46        rtems_bsdnet_show_mbuf_stats ();
     47        rtems_bsdnet_show_if_stats ();
     48        rtems_bsdnet_show_ip_stats ();
     49        rtems_bsdnet_show_icmp_stats ();
     50        rtems_bsdnet_show_udp_stats ();
     51        rtems_bsdnet_show_tcp_stats ();
    5452}
    5553
     
    5957static void
    6058transmitUdp (void)
     59{
     60        int s;
     61        int i;
     62        int opt;
     63        static struct sockaddr_in myAddr, farAddr;
     64        static char cbuf[800];
     65        static char bigbuf[9000];
     66
     67        printf ("Create socket.\n");
     68        s = socket (AF_INET, SOCK_DGRAM, 0);
     69        if (s < 0)
     70                rtems_panic ("Can't create socket: %s", strerror (errno));
     71        myAddr.sin_family = AF_INET;
     72        myAddr.sin_port = htons (1234);
     73        myAddr.sin_addr.s_addr = htonl (INADDR_ANY);
     74        printf ("Bind socket.\n");
     75        if (bind (s, (struct sockaddr *)&myAddr, sizeof myAddr) < 0)
     76                rtems_panic ("Can't bind socket: %s", strerror (errno));
     77        farAddr.sin_family = AF_INET;
     78        farAddr.sin_port = htons (9);   /* The `discard' port */
     79#if 1
     80        farAddr.sin_addr.s_addr = htonl (0xFFFFFFFF);
     81        if (sendto (s, cbuf, sizeof cbuf, 0, (struct sockaddr *)&farAddr, sizeof farAddr) >= 0)
     82                printf ("Broadcast succeeded, but should not have!\n");
     83showbroad (s);
     84        opt = 1;
     85        if (setsockopt (s, SOL_SOCKET, SO_BROADCAST, &opt, sizeof opt) < 0)
     86                rtems_panic ("Can't set socket broadcast: %s", strerror (errno));
     87showbroad (s);
     88        for (i = 0 ; i < 5 ; i++) {
     89                if (sendto (s, cbuf, sizeof cbuf, 0, (struct sockaddr *)&farAddr, sizeof farAddr) < 0)
     90                        rtems_panic ("Can't broadcast: %s", strerror (errno));
     91        }
     92#endif
     93        farAddr.sin_addr.s_addr = htonl (DATA_SINK_HOST);
     94#if 1
     95        for (i = 0 ; i < 500 ; i++) {
     96                if (sendto (s, cbuf, sizeof cbuf, 0, (struct sockaddr *)&farAddr, sizeof farAddr) < 0)
     97                        rtems_panic ("Can't send: %s", strerror (errno));
     98                if (sendto (s, cbuf, sizeof cbuf, 0, (struct sockaddr *)&farAddr, sizeof farAddr) < 0)
     99                        rtems_panic ("Can't send: %s", strerror (errno));
     100        }
     101#endif
     102#if 1
     103        for (i = 0 ; i < 2 ; i++) {
     104                if (sendto (s, bigbuf, sizeof bigbuf, 0, (struct sockaddr *)&farAddr, sizeof farAddr) < 0)
     105                        rtems_panic ("Can't send: %s", strerror (errno));
     106                if (sendto (s, bigbuf, sizeof bigbuf, 0, (struct sockaddr *)&farAddr, sizeof farAddr) < 0)
     107                        rtems_panic ("Can't send: %s", strerror (errno));
     108        }
     109#endif
     110        close (s);
     111}
     112       
     113/*
     114 * Stress the transmit queue -- send a large number of TCP packets
     115 */
     116static void
     117transmitTcp (void)
    61118{
    62119        int s;
     
    67124
    68125        printf ("Create socket.\n");
    69         s = socket (AF_INET, SOCK_DGRAM, 0);
     126        s = socket (AF_INET, SOCK_STREAM, 0);
    70127        if (s < 0)
    71128                rtems_panic ("Can't create socket: %s", strerror (errno));
    72129        myAddr.sin_family = AF_INET;
    73         myAddr.sin_port = 1234;
    74         myAddr.sin_addr.s_addr = INADDR_ANY;
     130        myAddr.sin_port = htons (1234);
     131        myAddr.sin_addr.s_addr = htonl (INADDR_ANY);
    75132        printf ("Bind socket.\n");
    76133        if (bind (s, (struct sockaddr *)&myAddr, sizeof myAddr) < 0)
    77134                rtems_panic ("Can't bind socket: %s", strerror (errno));
    78135        farAddr.sin_family = AF_INET;
    79         farAddr.sin_port = 9;   /* The `discard' port */
    80         farAddr.sin_addr.s_addr = 0xFFFFFFFF;
    81         for (i = 0 ; i < 5 ; i++) {
    82                 if (sendto (s, cbuf, sizeof cbuf, 0, (struct sockaddr *)&farAddr, sizeof farAddr) < 0)
    83                         rtems_panic ("Can't broadcast: %s", strerror (errno));
    84         }
    85         farAddr.sin_addr.s_addr = aton (DATA_SINK_HOST);
    86         for (i = 0 ; i < 500 ; i++) {
    87                 if (sendto (s, cbuf, sizeof cbuf, 0, (struct sockaddr *)&farAddr, sizeof farAddr) < 0)
    88                         rtems_panic ("Can't send: %s", strerror (errno));
    89                 if (sendto (s, cbuf, sizeof cbuf, 0, (struct sockaddr *)&farAddr, sizeof farAddr) < 0)
    90                         rtems_panic ("Can't send: %s", strerror (errno));
    91         }
    92         for (i = 0 ; i < 2 ; i++) {
    93                 if (sendto (s, bigbuf, sizeof bigbuf, 0, (struct sockaddr *)&farAddr, sizeof farAddr) < 0)
    94                         rtems_panic ("Can't send: %s", strerror (errno));
    95                 if (sendto (s, bigbuf, sizeof bigbuf, 0, (struct sockaddr *)&farAddr, sizeof farAddr) < 0)
    96                         rtems_panic ("Can't send: %s", strerror (errno));
    97         }
    98         close (s);
    99 }
    100        
    101 /*
    102  * Stress the transmit queue -- send a large number of TCP packets
    103  */
    104 static void
    105 transmitTcp (void)
    106 {
    107         int s;
    108         int i;
    109         static struct sockaddr_in myAddr, farAddr;
    110         static char cbuf[800];
    111         static char bigbuf[20000];
    112 
    113         printf ("Create socket.\n");
    114         s = socket (AF_INET, SOCK_STREAM, 0);
    115         if (s < 0)
    116                 rtems_panic ("Can't create socket: %s", strerror (errno));
    117         myAddr.sin_family = AF_INET;
    118         myAddr.sin_port = 1234;
    119         myAddr.sin_addr.s_addr = INADDR_ANY;
    120         printf ("Bind socket.\n");
    121         if (bind (s, (struct sockaddr *)&myAddr, sizeof myAddr) < 0)
    122                 rtems_panic ("Can't bind socket: %s", strerror (errno));
    123         farAddr.sin_family = AF_INET;
    124         farAddr.sin_port = 9;   /* The `discard' port */
    125         farAddr.sin_addr.s_addr = aton (DATA_SINK_HOST);
     136        farAddr.sin_port = htons (9);   /* The `discard' port */
     137        farAddr.sin_addr.s_addr = htonl (DATA_SINK_HOST);
     138        printf ("Connect socket.\n");
    126139        if (connect (s, (struct sockaddr *)&farAddr, sizeof farAddr) < 0) {
    127140                printf ("Can't connect socket: %s\n", strerror (errno));
     
    129142                return;
    130143        }
     144        printf ("Write to socket.\n");
    131145        for (i = 0 ; i < 500 ; i++) {
    132146                if (write (s, cbuf, sizeof cbuf) < 0)
     
    155169        rtems_status_code sc;
    156170
    157   printf( "echoTask on %d\n", fd );
    158171        for (;;) {
    159 #if 0
     172#if 1
    160173                n = read (fd, cbuf, sizeof cbuf);
    161174#else
     
    172185                if (send (fd, cbuf, n, 0) < 0)
    173186                        rtems_panic ("Error sending message: %s", strerror (errno));
    174                 if (cbuf[0] == '\007')
    175                         show_ka9q_tables ();
    176187                if (cbuf[0] == 'Q')
    177188                        break;
     
    199210                rtems_panic ("Can't create socket: %s", strerror (errno));
    200211        myAddr.sin_family = AF_INET;
    201         myAddr.sin_port = port;
     212        myAddr.sin_port = htons (port);
    202213        myAddr.sin_addr.s_addr = INADDR_ANY;
    203214        memset (myAddr.sin_zero, '\0', sizeof myAddr.sin_zero);
     
    215226                        rtems_panic ("Can't accept connection: %s", strerror (errno));
    216227                else
    217                         printf ("ACCEPTED:%lX\n", farAddr.sin_addr.s_addr);
     228                        printf ("ACCEPTED:%lX\n", ntohl (farAddr.sin_addr.s_addr));
    218229
    219230                /*
     
    259270        rtems_task_priority my_priority;
    260271
     272#if 1
    261273        /*
    262274         * Spawn other servers
     
    281293                }
    282294        }
     295#endif
    283296
    284297        /*
     
    288301                switch (getchar ()) {
    289302                case '\004':
    290                         printf( "Exiting test\n" );
    291303                        return;
    292304
     
    306318
    307319                case 's':
    308                         /*
    309                          * Show what's been accomplished
    310                          */
    311                         show_ka9q_tables ();
    312                         break;
    313                 }
    314         }
    315 }
     320                        showStatistics ();
     321                        break;
     322                }
     323        }
     324}
  • tftpTest/Makefile

    r4cfe89f r0c9330e  
    22PGM=${ARCH}/$(SAMPLE).exe
    33
    4 MANAGERS=io event semaphore timer rate_monotonic
     4MANAGERS=io event semaphore
    55
    66# C source names, if any, go here -- minus the .c
     
    3232CPPFLAGS +=
    3333CFLAGS   +=
    34 CFLAGS_LD +=  -Wl,--defsym -Wl,HeapSize=0x40000 # KA9Q needs more space
     34CFLAGS_LD +=  -Wl,--defsym -Wl,HeapSize=0x40000
    3535CFLAGS_OPTIMIZE_V   +=
    3636CFLAGS_DEBUG_V   += -qrtems_debug # -v
  • tftpTest/init.c

    r4cfe89f r0c9330e  
    11/*
    2  * Test RTEMS/KA9Q TFTP device driver
    3  *
     2 * RTEMS configuration/initialization
     3 * 
    44 * This program may be distributed and used for any purpose.
    55 * I ask only that you:
    6  *      1. Leave this author information intact.
    7  *      2. Document any changes you make.
     6 *      1. Leave this author information intact.
     7 *      2. Document any changes you make.
    88 *
    99 * W. Eric Norum
     
    1414 */
    1515
    16 #include "../usercfg.h"
     16#include <bsp.h>
     17#include <rtems/tftp.h>
    1718
    18 #include <bsp.h>
    19 #include <rtems/error.h>
    20 #include <tftp.h>
    21 #include <rtems_ka9q.h>
    22 #include <stdio.h>
    23 
     19#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
     20#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
    2421#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
    2522
    26 #define CONFIGURE_EXECUTIVE_RAM_SIZE    (128*1024)
    27 #define CONFIGURE_MAXIMUM_SEMAPHORES    10
    28 #define CONFIGURE_MAXIMUM_TIMERS        5
    29 #define CONFIGURE_MAXIMUM_PERIODS       1
     23#define CONFIGURE_EXECUTIVE_RAM_SIZE    (512*1024)
     24#define CONFIGURE_MAXIMUM_SEMAPHORES    20
     25#define CONFIGURE_MAXIMUM_TASKS         20
    3026
    3127#define CONFIGURE_MICROSECONDS_PER_TICK 10486
     28
     29#define CONFIGURE_INIT_TASK_STACK_SIZE  (10*1024)
     30#define CONFIGURE_INIT_TASK_PRIORITY    100
     31#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
     32                                           RTEMS_NO_TIMESLICE | \
     33                                           RTEMS_NO_ASR | \
     34                                           RTEMS_INTERRUPT_LEVEL(0))
    3235
    3336#define CONFIGURE_INIT
     
    4346#include <confdefs.h>
    4447
    45 #if (defined (USE_BOOTP))
    46 #include <bootp.h>
    47 #endif
    48 extern void testTFTP (void);
     48#include <stdio.h>
     49#include <rtems/rtems_bsdnet.h>
     50#include "../networkconfig.h"
    4951
    5052/*
     
    5456Init (rtems_task_argument ignored)
    5557{
    56         int i;
    57         rtems_task_priority oldPri;
    58         rtems_interval ticksPerSecond;
     58        const char *hostname, *filename;
    5959
    60         /*
    61          * Get some timing information
    62          */
    63         rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
     60        rtems_bsdnet_initialize_network ();
    6461
    65         /*
    66          * Start KA9Q
    67          */
    68         rtems_task_set_priority (RTEMS_SELF, 30, &oldPri);
    69         rtems_ka9q_start (20);
    70 
    71         /*
    72          * Hook up drivers
    73          */
    74 #if (defined (USE_BOOTP))
    75         if (rtems_ka9q_execute_command ("attach rtems broadcast y"
    76                                         " ether " MY_ETHERNET_ADDRESS))
     62#if (defined (RTEMS_USE_BOOTP))
     63        hostname = NULL;
     64        filename = rtems_bsdnet_bootp_boot_file_name;
    7765#else
    78         if (rtems_ka9q_execute_command ("attach rtems broadcast y"
    79                                         " ip " MY_IP_ADDRESS
    80                                         " ether " MY_ETHERNET_ADDRESS))
    81 #endif
    82                 rtems_panic ("Can't attach Ethernet driver.\n");
    83 
    84         /*
    85          * Configure the driver
    86          */
    87         if (rtems_ka9q_execute_command ("ifconfig rtems broadcast 255.255.255.255"))
    88                 rtems_panic ("Can't configure Ethernet driver.\n");
    89 
    90         /*
    91          * Add the ethernet broadcast address to the ARP table.
    92          */
    93         if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF"))
    94                 rtems_panic ("Can't add broadcast entry to ARP table.\n");
    95 
    96 #if (defined (USE_BOOTP))
    97         {
    98         int i;
    99         /*
    100          * Get BOOTP information
    101          */
    102         for (i = 0 ; ; ) {
    103                 if (rtems_ka9q_execute_command ("bootp") == 0)
    104                         break;
    105                 if (++i == 10)
    106                         rtems_panic ("Can't get information from BOOTP server.\n");
    107                 delay_task (i);
    108         }
    109         if (BootpFileName)
    110                 printf ("BOOTP filename: `%s'\n", BootpFileName);
    111         else
    112                 printf ("BOOTP -- No filename!\n");
    113         }
    114 #else
    115         if (rtems_ka9q_execute_command ("ifconfig rtems netmask 255.255.255.0"))
    116                 rtems_panic ("Can't set netmask.\n");
    117         if (rtems_ka9q_execute_command ("route add default rtems"))
    118                 rtems_panic ("Can't add default route.\n");
    119         printf ("Routing table after adding default route\n");
    120         rtems_ka9q_execute_command ("route");
     66        hostname = RTEMS_TFTP_TEST_HOST_NAME;
     67        filename = RTEMS_TFTP_TEST_FILE_NAME;
    12168#endif
    12269
    123         /*
    124          * Issue a gratuitous ARP request to update tables in
    125          * other hosts on this network.
    126          */
    127 
    128         if (rtems_ka9q_execute_command ("arp gratuitous rtems"))
    129                 rtems_panic ("Can't send gratuitous ARP.\n");
    130 
    131 
    132         /*
    133          * Test TFTP driver
    134          */
    135         testTFTP ();
    136 
    137         /*
    138          * Wind things up
    139          */
    140         rtems_task_wake_after (2 * ticksPerSecond);
    141         rtems_ka9q_execute_command ("detach rtems");
     70        testTFTP (hostname, filename);
    14271        exit (0);
    14372}
  • tftpTest/test.c

    r4cfe89f r0c9330e  
    1515
    1616#include <stdio.h>
     17#include <errno.h>
     18#include <string.h>
    1719#include <rtems.h>
    1820#include <rtems/error.h>
    1921#include <sys/fcntl.h>
    2022#include <unistd.h>
    21 #include <bootp.h>
    22 #include <netuser.h>
    23 
    24 #include "../usercfg.h"
    2523
    2624static char cbuf[1024];
     
    4341        }
    4442        printf (".\n");
    45 rtems_ka9q_execute_command ("ifconfig rtems");
    4643}
    4744
     
    107104
    108105static int
    109 makeFullname (rtems_unsigned32 host, const char *file)
     106makeFullname (const char *hostname, const char *file)
    110107{
    111         const char *hostname;
    112 #if !defined(USE_BOOTP)
    113         static char name[16];
    114 #endif
    115 
    116 #if 0
    117         printf( "makeFullname(0x08%x, %s)\n", host, file);
    118 #endif
    119 
    120 #if (defined (USE_BOOTP))
    121         if (host) {
    122                 hostname = rtems_hostname_for_address (BootpHost.s_addr, 0);
    123                 if (hostname == NULL) {
    124                         printf ("No host to read from!\n");
    125                         return 0;
    126                 }
    127         } else {
     108        if (hostname == NULL)
    128109                hostname = "";
    129         }
    130 #else
    131         if (host) {
    132                 sprintf( name, "%d.%d.%d.%d", host >> 24, (host >> 16) & 0xff,
    133                         (host >> 8) & 0xff, host & 0xff
    134                 );
    135                 hostname = name;
    136         } else {
    137                 hostname = "";
    138         }
    139 #endif
    140110        fullname = realloc (fullname, 8 + strlen (file) + strlen (hostname));
    141111        sprintf (fullname, "/TFTP/%s/%s", hostname, file);
     
    145115
    146116void
    147 testTFTP (void)
     117testTFTP (const char *hostname, const char *filename)
    148118{
    149119        /*
    150120         * Check that invalid file names are reported as such
    151121         */
    152         if (makeFullname (0, "")) {
     122        if (makeFullname (hostname, "")) {
    153123                testRawRead ();
    154124                testFread ();
     
    158128         * Check that non-existent files are reported as such
    159129         */
    160         if (makeFullname (0, "BAD-FILE-NAME")) {
     130        if (makeFullname (hostname, "BAD-FILE-NAME")) {
    161131                testRawRead ();
    162132                testFread ();
     
    164134
    165135        /*
    166          * Check read speed
     136         * Check that read works
    167137         */
    168 #if (defined (USE_BOOTP))
    169         if (BootpFileName == NULL) {
    170                 printf ("Nothing to read!\n");
    171                 return;
    172         }
    173         if (makeFullname (BootpHost.s_addr, BootpFileName)) {
    174 #else
    175         if (makeFullname (aton (DATA_SOURCE_HOST), DATA_SOURCE_FILE)) {
    176 #endif
    177 
     138        if (makeFullname (hostname, filename)) {
    178139                testRawRead ();
    179140                testFread ();
  • ttcp/Makefile

    r4cfe89f r0c9330e  
    1 #
    2 # $Revision$    $Date$    $Author$
    3 #
    4 
    51SAMPLE=ttcp
    62PGM=${ARCH}/$(SAMPLE).exe
    73
    8 MANAGERS=io event message rate_monotonic semaphore timer
     4MANAGERS=io event semaphore
    95
    106# C source names, if any, go here -- minus the .c
    11 C_PIECES= init rtems_ttcp
     7C_PIECES= init  rtems_ttcp
    128C_FILES=$(C_PIECES:%=%.c)
    139C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
    1410
    15 H_FILES= 
     11H_FILES=
    1612
    1713DOCTYPES=
     
    3531DEFINES  +=
    3632CPPFLAGS +=
    37 CFLAGS   += -I./include
    38 CFLAGS_LD   += -Wl,--defsym -Wl,HeapSize=0x200000 # KA9Q needs more space
     33CFLAGS   +=
     34CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0xC0000
    3935CFLAGS_OPTIMIZE_V   +=
     36CFLAGS_DEBUG_V   += -v -qrtems_debug
    4037
    4138LD_PATHS  +=
     
    4946#
    5047
    51 CLEAN_ADDITIONS += 
     48CLEAN_ADDITIONS +=
    5249CLOBBER_ADDITIONS +=
    5350
     
    5754        $(make-exe)
    5855
    59 install: $(INSTALL_TARGET)
    60 
    61 $(INSTALL_TARGET): all
    62         cp ${PGM} $(INSTALL_TARGET)
     56# Install the program(s), appending _g or _p as appropriate.
     57# for include files, just use $(INSTALL)
     58install: all
     59        $(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/tests
  • ttcp/README

    r4cfe89f r0c9330e  
    1 #
    2 #  $Id$
    3 #
    4 
    51This directory contains an RTEMS application for measuring TCP/UDP
    62network throughput.   The ttcp_orig subdirectory contains the original
    73UNIX program which can be compiled and run on your host machine.
    8 
    9 The RTEMS version of the test program is a little clumsy to use.  You
    10 have to edit the rtems_ttcp.c source file and change the ttcp_argv
    11 array of strings to set the arguments you want passed to the ttcp
    12 task.
    13 
    14 It does work, though.  The best throughputs I've seen so far are:
    15         68360 card can transmit a TCP stream at 198 kbytes/second.
    16         68360 card can receive a TCP stream at 119 kbytes/second.
    17 In both cases, the other end of the transfer was a 486DX2/66 running
    18 OPENSTEP/MACH 4.1. 
    194
    205One noteworthy item is that I was able to get the UNIX test program
  • ttcp/init.c

    r4cfe89f r0c9330e  
    44 * This program may be distributed and used for any purpose.
    55 * I ask only that you:
    6  *      1. Leave this author information intact.
    7  *      2. Document any changes you make.
     6 *      1. Leave this author information intact.
     7 *      2. Document any changes you make.
    88 *
    99 * W. Eric Norum
     
    1414 */
    1515
    16 #include "../usercfg.h"
    17 
    1816#include <bsp.h>
    1917
     
    2220#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
    2321
    24 #define CONFIGURE_EXECUTIVE_RAM_SIZE    (512*1024)
    25 #define CONFIGURE_MAXIMUM_SEMAPHORES    20
    26 #define CONFIGURE_MAXIMUM_TASKS         20
    27 #define CONFIGURE_MAXIMUM_TIMERS        10
    28 #define CONFIGURE_MAXIMUM_PERIODS       1
    29 #define CONFIGURE_MICROSECONDS_PER_TICK 10486
     22#define CONFIGURE_EXECUTIVE_RAM_SIZE    (512*1024)
     23#define CONFIGURE_MAXIMUM_SEMAPHORES    20
     24#define CONFIGURE_MAXIMUM_TASKS         20
     25
     26#define CONFIGURE_MICROSECONDS_PER_TICK 10486
     27
     28#define CONFIGURE_INIT_TASK_STACK_SIZE  (10*1024)
     29#define CONFIGURE_INIT_TASK_PRIORITY    100
     30#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
     31                                           RTEMS_NO_TIMESLICE | \
     32                                           RTEMS_NO_ASR | \
     33                                           RTEMS_INTERRUPT_LEVEL(0))
    3034
    3135#define CONFIGURE_INIT
     
    3539
    3640#include <stdio.h>
    37 #include <rtems_ka9q.h>
    38 
    39 #if (defined (USE_BOOTP))
    40 #include <bootp.h>
    41 #endif
    42 
    43 volatile int ttcp_running;
    44 
    45 /*
    46  * Suspend execution for the specified number of seconds
    47  */
    48 static void
    49 delay_task (int seconds)
    50 {
    51         rtems_task_wake_after ((seconds * 1000000) / BSP_Configuration.microseconds_per_tick);
    52 }
    53 
    54 /*
    55  * Display the contents of several KA9Q tables
    56  */
    57 void
    58 show_ka9q_tables (void)
    59 {
    60         printf ("\n****************** MALLOC Statistics ***************\n");
    61         malloc_dump ();
    62         printf ("\n****************** MBUF Statistics ***************\n");
    63         mbufstat ();
    64         mbufsizes ();
    65         printf ("\n****************** Routing Table ***************\n");
    66         rtems_ka9q_execute_command ("route");
    67         printf ("\n****************** ARP Table ***************\n");
    68         rtems_ka9q_execute_command ("arp");
    69         printf ("\n****************** Driver Statistics ***************\n");
    70         rtems_ka9q_execute_command ("ifconfig rtems");
    71         printf ("\n****************** Ip Statistics ***************\n");
    72         rtems_ka9q_execute_command ("ip status");
    73         printf ("\n****************** ICMP Statistics ***************\n");
    74         rtems_ka9q_execute_command ("icmp status");
    75         printf ("\n****************** UDP Statistics ***************\n");
    76         rtems_ka9q_execute_command ("udp status");
    77         printf ("\n****************** TCP Statistics ***************\n");
    78         rtems_ka9q_execute_command ("tcp status");
    79 }
     41#include <rtems/rtems_bsdnet.h>
     42#include "../networkconfig.h"
    8043
    8144/*
     
    8548Init (rtems_task_argument ignored)
    8649{
    87         rtems_task_priority oldPri;
    88         rtems_mode old_mode;
    89 
    90 #if (defined (m68040))
    91         /*
    92          * Hook up FPSP
    93          */
    94         M68kFPSPInstallExceptionHandlers ();
    95 
    96         /*
    97          * Turn on instruction cache
    98          */
    99         asm volatile ("cinva bc");
    100         asm volatile ("movec %0,itt0" : : "d" (0x00ffc004));
    101         asm volatile ("movec %0,dtt0" : : "d" (0x00ffc040));
    102         asm volatile ("cinva bc\n\t"
    103                         "movec %0,cacr" : : "d" (0x80008000));
    104 #endif
    105 
    106         ttcp_running = 0;
    107 
    108         /*
    109          * Start KA9Q
    110          */
    111         rtems_task_set_priority (RTEMS_SELF, 30, &oldPri);
    112         rtems_ka9q_start (30);
    113 
    114         /*
    115          * Hook up drivers
    116          */
    117         if (rtems_ka9q_execute_command ("attach rtems"
    118                                         /* " rbuf 24 tbuf 5" */
    119                                         " rbuf 100 tbuf 10"
    120 #if !(defined (USE_BOOTP))
    121                                         " ip " MY_IP_ADDRESS
    122 #endif
    123                                         " ether " MY_ETHERNET_ADDRESS))
    124                 rtems_panic ("Can't attach Ethernet driver.\n");
    125 
    126 #if (defined (TRACE_NETWORK_DRIVER))
    127         /*
    128          * Turn on debugging
    129          */
    130         puts( "Enabling debug mode of KA9Q" );
    131         if (rtems_ka9q_execute_command ("trace rtems input <stdout>")
    132          || rtems_ka9q_execute_command ("trace rtems output <stdout>")
    133          || rtems_ka9q_execute_command ("trace rtems ascii <stdout>"))
    134                 rtems_panic ("Can't set tracing for Ethernet driver.\n");
    135 #endif
    136 
    137 
    138         /*
    139          * Configure the driver
    140          */
    141         if (rtems_ka9q_execute_command ("ifconfig rtems broadcast 255.255.255.255"))
    142                 rtems_panic ("Can't configure Ethernet driver.\n");
    143 
    144         /*
    145          * Add the ethernet broadcast address to the ARP table.
    146          */
    147         if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF"))
    148                 rtems_panic ("Can't add broadcast entry to ARP table.\n");
    149 
    150 #if (defined (USE_BOOTP))
    151         {
    152         int i;
    153         /*
    154          * Get BOOTP information
    155          */
    156         for (i = 0 ; ; ) {
    157                 if (rtems_ka9q_execute_command ("bootp") == 0)
    158                         break;
    159                 if (++i == 10)
    160                         rtems_panic ("Can't get information from BOOTP server.\n");
    161                 delay_task (i);
    162         }
    163         if (BootpFileName)
    164                 printf ("BOOTP filename: `%s'\n", BootpFileName);
    165         else
    166                 printf ("BOOTP -- No filename!\n");
    167         }
    168 #else
    169         if (rtems_ka9q_execute_command ("ifconfig rtems netmask 255.255.255.0"))
    170                 rtems_panic ("Can't set netmask.\n");
    171         if (rtems_ka9q_execute_command ("route add default rtems"))
    172                 rtems_panic ("Can't add default route.\n");
    173         printf ("Routing table after adding default route\n");
    174         rtems_ka9q_execute_command ("route");
    175 #endif
    176         /*
    177          * Issue a gratuitous ARP request to update tables in
    178          * other hosts on this network.
    179          */
    180         if (rtems_ka9q_execute_command ("arp gratuitous rtems"))
    181                 rtems_panic ("Can't send gratuitous ARP.\n");
    182        
    183         rtems_ka9q_execute_command ("tcp window");
    184         rtems_ka9q_execute_command ("tcp window 4096");
    185         rtems_ka9q_execute_command ("tcp window");
    186 
    187         /*
    188          * Whew!
    189          */
    190         printf ("NETWORK INITIALIZED!\n");
    191 
    192         /*
    193          * Let other tasks preempt this one
    194          */
    195         rtems_task_mode (RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode);
    196 
    197         /*
    198          * See if sockets work properly
    199          */
     50        rtems_bsdnet_initialize_network ();
    20051        test_network ();
    201 
    202         /*
    203          * Wait for characters from console terminal
    204          */
    205         do {
    206                 rtems_task_wake_after( 1 );
    207         } while ( !ttcp_running );
    208         printf( "Now accepting input from the console\n" );
    209         for (;;) {
    210                 switch (getchar ()) {
    211                 case '\004':
    212                         printf( "Exiting test\n" );
    213                         return;
    214 
    215                 case 's':
    216                         /*
    217                          * Show what's been accomplished
    218                          */
    219                         show_ka9q_tables ();
    220                         break;
    221                 }
    222         }
    22352        exit (0);
    22453}
  • ttcp/rtems_ttcp.c

    r4cfe89f r0c9330e  
    33 * provide a `UNIX-like' environment to ttcp.
    44 *
    5  * Some of the code here should migrate to the libc
     5 * Some of the code here may migrate to the libc
    66 * support routines some day.  Some of the more sleazy
    77 * hacks should never make it outside this file!
     
    2020
    2121#include <stdio.h>
     22#include <ctype.h>
    2223#include <rtems.h>
    23 #include <rtems_ka9q.h>
     24#include <rtems/rtems_bsdnet.h>
    2425#include <rtems/error.h>
    25 #include <socket.h>
    26 #include <sockaddr.h>
    27 #include <netuser.h>
     26#include <sys/types.h>
     27#include <sys/socket.h>
     28#include <netinet/in.h>
     29#include <netdb.h>
    2830#include <sys/time.h>
    2931
     
    3234 */
    3335int rtems_ttcp_main (int argc, char **argv);
    34 
    35 #define ENOBUFS 2000
    36 
    37 struct  hostent {
    38         char    *h_name;        /* official name of host */
    39         char    **h_aliases;    /* alias list */
    40         int     h_addrtype;     /* host address type */
    41         int     h_length;       /* length of address */
    42         char    **h_addr_list;  /* list of addresses from name server */
    43         #define h_addr  h_addr_list[0]  /* address, for backward compatiblity */
    44 };
    45 
    46 #define SOL_SOCKET      0
    47 #define SO_DEBUG        0
    48 
    49 static struct hostent *
    50 gethostbyname (const char *cp)
    51 {
    52         rtems_panic ("gethostbyname()");
    53 }
    5436
    5537static int
     
    6446        return 0;;
    6547}
    66 
    67 static char *
    68 rtems_inet_ntoa (struct in_addr in)
    69 {
    70         return inet_ntoa (in.s_addr);
    71 }
    72 #define inet_ntoa rtems_inet_ntoa
    73 #define inet_addr(cp)   resolve(cp)
    7448
    7549int
     
    12094}
    12195
    122 void show_ka9q_tables (void);
    123 
    12496static void
    12597rtems_ttcp_exit (int code)
    12698{
    127         rtems_interval ticksPerSecond;
    128 
    129         rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
    130         rtems_task_wake_after (ticksPerSecond * 2);
    131         show_ka9q_tables ();
     99        rtems_bsdnet_show_mbuf_stats ();
     100        rtems_bsdnet_show_if_stats ();
     101        rtems_bsdnet_show_ip_stats ();
     102        rtems_bsdnet_show_tcp_stats ();
    132103        exit (code);
    133104}
    134 
    135 extern volatile int ttcp_running;
    136105
    137106/*
     
    158127                argv[0] = __progname = arg0;
    159128
     129#if (defined (WRITE_TEST_ONLY))
     130                strcpy (linebuf, "-s -t crux");
     131#elif (defined (READ_TEST_ONLY))
     132                strcpy (linebuf, "-s -r");
     133#else
    160134                /*
    161135                 * Read a line
     
    164138                fflush (stdout);
    165139                fgets (linebuf, sizeof linebuf, stdin);
     140#endif
    166141
    167142                /*
     
    196171                printf ("         -t destination.internet.address\n");
    197172        }
    198         ttcp_running = 1;
    199173        code = rtems_ttcp_main (argc, argv);
    200174        rtems_ttcp_exit (code);
    201 }
    202 
    203 static int
    204 rtems_ttcp_bind (int s, struct sockaddr *name, int namelen)
    205 {
    206         struct sockaddr_in *in = (struct sockaddr_in *)name;
    207         /*
    208          * KA9Q doesn't like 0 port numbers
    209          */
    210         if (in->sin_port == 0)
    211                 in->sin_port = 2662;
    212         return bind (s, name, namelen);
    213175}
    214176
     
    259221                return;
    260222        }
    261         /* rtems_task_suspend (RTEMS_SELF); */
     223        rtems_task_suspend (RTEMS_SELF);
    262224}
    263225
    264226#define main            rtems_ttcp_main
    265227#define exit(code)      close(fd),rtems_ttcp_exit(code)
    266 #define bind            rtems_ttcp_bind
    267228#define read_timer      rtems_read_timer
    268229
    269 /*
    270  * RTEMS/KA9Q code expects port numbers in host byte order!
    271  */
    272 #define htons(x)        (x)
    273 
    274 #undef delay
    275 
    276230#include "ttcp_orig/ttcp.c"
Note: See TracChangeset for help on using the changeset viewer.