OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [autotest/] [current/] [tests/] [floodping.c] - Blame information for rev 825

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      autotest/current/tests/floodping.c
4
//
5
//      Flood pinging test, the server floods me and little else.
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
// ####BSDALTCOPYRIGHTBEGIN####                                             
40
// -------------------------------------------                              
41
// Portions of this software may have been derived from FreeBSD, OpenBSD,   
42
// or other sources, and if so are covered by the appropriate copyright     
43
// and license included herein.                                             
44
// -------------------------------------------                              
45
// ####BSDALTCOPYRIGHTEND####                                               
46
//==========================================================================
47
//#####DESCRIPTIONBEGIN####
48
//
49
// Author(s):    hmt,gthomas
50
// Contributors: hmt,gthomas
51
// Date:         2000-10-23
52
// Purpose:      
53
// Description:  
54
//              
55
//
56
//####DESCRIPTIONEND####
57
//
58
//==========================================================================
59
 
60
#include <pkgconf/system.h>
61
 
62
#include <cyg/infra/testcase.h>         // testing infrastructure
63
 
64
#include <pkgconf/net.h>
65
 
66
#ifdef CYGBLD_DEVS_ETH_DEVICE_H    // Get the device config if it exists
67
#include CYGBLD_DEVS_ETH_DEVICE_H  // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
68
#endif
69
 
70
#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
71
# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
72
#  include CYGTST_DEVS_ETH_TEST_NET_REALTIME
73
# endif
74
#endif
75
 
76
 
77
// Fill in the blanks if necessary
78
#ifndef TNR_OFF
79
# define TNR_OFF()
80
#endif
81
#ifndef TNR_ON
82
# define TNR_ON()
83
#endif
84
#ifndef TNR_INIT
85
# define TNR_INIT()
86
#endif
87
#ifndef TNR_PRINT_ACTIVITY
88
# define TNR_PRINT_ACTIVITY()
89
#endif
90
 
91
// ------------------------------------------------------------------------
92
 
93
#include <errno.h>
94
#include <network.h>
95
 
96
#include "autohost.inl"
97
 
98
#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
99
static char stack[STACK_SIZE];
100
static cyg_thread thread_data;
101
static cyg_handle_t thread_handle;
102
 
103
static void
104
do_ping_tests(struct bootp *bp, int testtime, int filesize)
105
{
106
    char order[256];
107
    diag_printf( "INFO: telling %s to run 1 flood ping for %d seconds, %d bytes\n",
108
          inet_ntoa(bp->bp_siaddr), testtime, filesize );
109
 
110
    sprintf( order, "%s %s %d %d", "FLOOD_PING",
111
             inet_ntoa(bp->bp_yiaddr),
112
             testtime,
113
             filesize );
114
    autohost_tell( bp, order );
115
}
116
 
117
#define TESTTIME (5 * 60) // Seconds
118
 
119
void
120
net_test(cyg_addrword_t param)
121
{
122
    CYG_TEST_INIT();
123
    CYG_TEST_INFO("Start PING server test");
124
    init_all_network_interfaces();
125
 
126
    autohost_init();
127
 
128
    TNR_INIT();
129
 
130
    // Now command the host to do ping to us...
131
#ifdef CYGHWR_NET_DRIVER_ETH0
132
    if (eth0_up) {
133
        do_ping_tests(&eth0_bootp_data, TESTTIME, 56);
134
    }
135
#endif
136
#ifdef CYGHWR_NET_DRIVER_ETH1
137
    if (eth1_up) {
138
        do_ping_tests(&eth1_bootp_data, TESTTIME, 56);
139
    }
140
#endif
141
 
142
    // Let the server run for 5 minutes
143
    cyg_thread_delay(2*100); // let the stuff start up first
144
    TNR_ON();
145
    cyg_thread_delay(TESTTIME*100); // FIXME - assume cS clock.
146
    // Additional delay 'cos host may be slower than us - and it has to
147
    // complete a transfer anyway:
148
    cyg_thread_delay(  30    *100); // FIXME - assume cS clock.
149
    TNR_OFF();
150
 
151
    autohost_end( 0
152
#ifdef CYGHWR_NET_DRIVER_ETH0
153
                  + eth0_up
154
#endif
155
#ifdef CYGHWR_NET_DRIVER_ETH1
156
                  + eth1_up
157
#endif
158
        ); // check for 2 pass messages from hosts
159
 
160
    TNR_PRINT_ACTIVITY();
161
    CYG_TEST_EXIT("Done");
162
}
163
 
164
void
165
cyg_start(void)
166
{
167
    // Create a main thread, so we can run the scheduler and have time 'pass'
168
    cyg_thread_create(10,                // Priority - just a number
169
                      net_test,          // entry
170
                      0,                 // entry parameter
171
                      "Network test",    // Name
172
                      &stack[0],         // Stack
173
                      STACK_SIZE,        // Size
174
                      &thread_handle,    // Handle
175
                      &thread_data       // Thread data structure
176
            );
177
    cyg_thread_resume(thread_handle);  // Start it
178
    cyg_scheduler_start();
179
}
180
 
181
// EOF floodping.c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.