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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [ppp/] [current/] [tests/] [ppp_up.c] - Blame information for rev 838

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

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      tests/ppp_up.c
4
//
5
//      Simple test of PPP and networking support
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 2003 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):    nickg
50
// Contributors: nickg
51
// Date:         2003-06-01
52
// Purpose:      
53
// Description:  This test just brings the PPP link up and waits for the
54
//               other end to bring it down. Meanwhile the other end can
55
//               ping us, or talk to the HTTPD if it is configured.
56
//              
57
//
58
//####DESCRIPTIONEND####
59
//
60
//==========================================================================
61
 
62
// PPP test code
63
 
64
#include "ppp_test_support.inl"
65
 
66
//==========================================================================
67
 
68
typedef int pr_fun(const char *fmt, ...);
69
 
70
externC void show_network_tables(pr_fun *pr);
71
 
72
//==========================================================================
73
 
74
 
75
#ifndef CYGPKG_LIBC_STDIO
76
#define perror(s) diag_printf(#s ": %s\n", strerror(errno))
77
#endif
78
 
79
#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000)
80
static char stack[STACK_SIZE];
81
static cyg_thread thread_data;
82
static cyg_handle_t thread_handle;
83
 
84
//==========================================================================
85
 
86
static void do_test( cyg_serial_baud_rate_t baud )
87
{
88
    cyg_ppp_options_t options;
89
    cyg_ppp_handle_t ppp_handle;
90
    int i = 0;
91
 
92
    ppp_test_announce( "PPP_UP" );
93
 
94
    cyg_ppp_options_init( &options );
95
 
96
//    options.debug = 1;
97
//    options.kdebugflag = 1;
98
 
99
    options.baud = baud;
100
 
101
    show_network_tables( diag_printf );
102
 
103
    ppp_handle = cyg_ppp_up( CYGPKG_PPP_TEST_DEVICE, &options );
104
 
105
    CYG_TEST_INFO( "Waiting for PPP to come up");
106
 
107
    cyg_ppp_wait_up( ppp_handle );
108
 
109
    CYG_TEST_INFO( "Waiting until remote end goes down");
110
 
111
    while( cyg_ppp_wait_up( ppp_handle ) == 0 )
112
    {
113
        i++;
114
 
115
        if( (i % 60) == 0 )
116
            show_network_tables( diag_printf );
117
 
118
        cyg_thread_delay(100);
119
    }
120
 
121
    cyg_ppp_wait_down( ppp_handle );
122
}
123
 
124
//==========================================================================
125
 
126
void
127
ppp_test(cyg_addrword_t p)
128
{
129
    cyg_serial_baud_rate_t old;
130
 
131
    CYG_TEST_INIT();
132
    diag_printf("Start PPP test\n");
133
 
134
    init_all_network_interfaces();
135
 
136
//    old = ppp_test_set_baud( CYGNUM_SERIAL_BAUD_115200 );
137
//    do_test( CYGNUM_SERIAL_BAUD_115200 );
138
 
139
    old = ppp_test_set_baud( CYGNUM_SERIAL_BAUD_19200 );
140
    do_test( CYGNUM_SERIAL_BAUD_19200 );
141
 
142
#ifdef CYGPKG_PPP_TESTS_AUTOMATE
143
 
144
    {
145
        static cyg_serial_baud_rate_t test_rates[] =
146
            { CYGDAT_PPP_TEST_BAUD_RATES, 0 };
147
 
148
        int i;
149
 
150
        for( i = 0; test_rates[i] != 0; i++ )
151
        {
152
            ppp_test_set_baud( test_rates[i] );
153
            do_test( test_rates[i] );
154
        }
155
 
156
        ppp_test_set_baud( old );
157
 
158
        ppp_test_finish();
159
 
160
    }
161
 
162
#endif
163
 
164
    CYG_TEST_PASS_FINISH("PPP test OK");
165
}
166
 
167
//==========================================================================
168
 
169
void
170
cyg_start(void)
171
{
172
    // Create a main thread, so we can run the scheduler and have time 'pass'
173
    cyg_thread_create(10,                // Priority - just a number
174
                      ppp_test,          // entry
175
                      0,                 // entry parameter
176
                      "PPP test",        // Name
177
                      &stack[0],         // Stack
178
                      STACK_SIZE,        // Size
179
                      &thread_handle,    // Handle
180
                      &thread_data       // Thread data structure
181
            );
182
    cyg_thread_resume(thread_handle);  // Start it
183
    cyg_scheduler_start();
184
}
185
 
186
//==========================================================================

powered by: WebSVN 2.1.0

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