annotate packages/net/ppp/current/tests/ppp_auth.c @ 2729:74dbf4c3f2e1 after-copyright-change-20090129

Update all copyright banners to reflect FSF ownership; fix and improve licence text.
author jlarmour
date Thu, 29 Jan 2009 17:47:46 +0000
parents e0d88dc6a92f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1586
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
1 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
2 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
3 // tests/ppp_auth.c
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
4 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
5 // Simple test of PPP authentication support
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
6 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
7 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
8 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
9 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
11 // Copyright (C) 2003 Free Software Foundation, Inc.
1586
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
12 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
14 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
16 // version.
1586
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
17 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
21 // for more details.
1586
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
22 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
23 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
24 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1586
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
26 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
27 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
28 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
29 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
30 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
31 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
32 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
33 // General Public License v2.
1586
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
34 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
35 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
36 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
37 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
38 // ####ECOSGPLCOPYRIGHTEND####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
39 // ####BSDALTCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
40 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
41 // Portions of this software may have been derived from FreeBSD, OpenBSD,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
42 // or other sources, and if so are covered by the appropriate copyright
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
43 // and license included herein.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
44 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1586
diff changeset
45 // ####BSDALTCOPYRIGHTEND####
1586
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
46 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
47 //#####DESCRIPTIONBEGIN####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
48 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
49 // Author(s): nickg
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
50 // Contributors: nickg
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
51 // Date: 2003-06-01
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
52 // Purpose:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
53 // Description: This test just brings the PPP link up and waits for the
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
54 // other end to bring it down. Meanwhile the other end can
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
55 // ping us, or talk to the HTTPD if it is configured.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
56 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
57 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
58 //####DESCRIPTIONEND####
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
59 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
60 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
61
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
62 // PPP test code
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
63
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
64 #include "ppp_test_support.inl"
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
65
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
66 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
67
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
68 typedef void pr_fun(char *fmt, ...);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
69
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
70 externC void show_network_tables(pr_fun *pr);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
71
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
72 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
73
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
74
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
75 #ifndef CYGPKG_LIBC_STDIO
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
76 #define perror(s) diag_printf(#s ": %s\n", strerror(errno))
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
77 #endif
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
78
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
79 #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
80 static char stack[STACK_SIZE];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
81 static cyg_thread thread_data;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
82 static cyg_handle_t thread_handle;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
83
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
84 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
85 // Tests
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
86 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
87 // The following table contains parameters for various tests permuting
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
88 // the authentication requirements of the peer, the authentication
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
89 // requirements of this end and the user name and password used.
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
90 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
91 // For this test to work the /etc/ppp/pap-secrets file on the remote
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
92 // end should contain the following two lines:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
93 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
94 // eCos * secret *
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
95 // eCosPAP * secretPAP *
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
96 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
97 // The /etc/ppp/chap-secrets file should contain:
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
98 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
99 // eCos * secret *
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
100 // eCosCHAP * secretCHAP *
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
101 //
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
102
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
103 static struct auth_info
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
104 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
105 char *name;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
106 cyg_serial_baud_rate_t baud;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
107 int refuse_pap;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
108 int refuse_chap;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
109 char user[MAXNAMELEN];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
110 char passwd[MAXSECRETLEN];
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
111 cyg_int32 result;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
112 } tests[] =
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
113 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
114 // PPP_AUTH_1 just tries the default auth mechanism for the server
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
115 { "PPP_AUTH_1", CYGNUM_SERIAL_BAUD_115200, 0, 0, "eCos", "secret", 0 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
116 { "PPP_AUTH_1", CYGNUM_SERIAL_BAUD_115200, 0, 0, "eCos", "secretX", -1 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
117 { "PPP_AUTH_1", CYGNUM_SERIAL_BAUD_115200, 0, 0, "eCosX", "secret", -1 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
118
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
119 // PPP_AUTH_2 requires PAP authentication only
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
120 { "PPP_AUTH_2", CYGNUM_SERIAL_BAUD_115200, 1, 0, "eCosCHAP", "secretCHAP", -1 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
121 { "PPP_AUTH_2", CYGNUM_SERIAL_BAUD_115200, 1, 0, "eCosPAP", "secretPAP", -1 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
122 { "PPP_AUTH_2", CYGNUM_SERIAL_BAUD_115200, 1, 0, "eCos", "secret", -1 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
123 { "PPP_AUTH_2", CYGNUM_SERIAL_BAUD_115200, 0, 1, "eCosCHAP", "secretCHAP", -1 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
124 { "PPP_AUTH_2", CYGNUM_SERIAL_BAUD_115200, 0, 1, "eCosPAP", "secretPAP", 0 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
125 { "PPP_AUTH_2", CYGNUM_SERIAL_BAUD_115200, 0, 1, "eCos", "secret", 0 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
126
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
127 // PPP_AUTH_3 requires CHAP authentication only
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
128 { "PPP_AUTH_3", CYGNUM_SERIAL_BAUD_115200, 0, 1, "eCosPAP", "secretPAP", -1 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
129 { "PPP_AUTH_3", CYGNUM_SERIAL_BAUD_115200, 0, 1, "eCosCHAP", "secretCHAP", -1 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
130 { "PPP_AUTH_3", CYGNUM_SERIAL_BAUD_115200, 0, 1, "eCos", "secret", -1 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
131 { "PPP_AUTH_3", CYGNUM_SERIAL_BAUD_115200, 1, 0, "eCosPAP", "secretPAP", -1 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
132 { "PPP_AUTH_3", CYGNUM_SERIAL_BAUD_115200, 1, 0, "eCosCHAP", "secretCHAP", 0 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
133 { "PPP_AUTH_3", CYGNUM_SERIAL_BAUD_115200, 1, 0, "eCos", "secret", 0 },
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
134
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
135 { NULL }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
136 };
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
137
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
138 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
139
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
140
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
141 static int do_test( struct auth_info *test )
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
142 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
143 cyg_ppp_options_t options;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
144 cyg_ppp_handle_t ppp_handle;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
145 int i = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
146 cyg_int32 result;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
147
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
148 CYG_TEST_INFO( test->name );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
149
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
150 ppp_test_set_baud( test->baud );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
151
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
152 ppp_test_announce( test->name );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
153
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
154 cyg_ppp_options_init( &options );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
155
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
156 // options.debug = 1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
157 // options.kdebugflag = 1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
158
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
159 options.baud = test->baud;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
160 options.refuse_pap = test->refuse_pap;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
161 options.refuse_chap = test->refuse_chap;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
162 strncpy( options.user, test->user, MAXNAMELEN );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
163 strncpy( options.passwd, test->passwd, MAXNAMELEN );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
164
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
165 // show_network_tables( diag_printf );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
166
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
167 ppp_handle = cyg_ppp_up( CYGPKG_PPP_TEST_DEVICE, &options );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
168
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
169 CYG_TEST_INFO( "Waiting for PPP to come up");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
170
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
171 result = cyg_ppp_wait_up( ppp_handle );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
172
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
173 if( result != test->result )
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
174 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
175 CYG_TEST_INFO( "Failed" );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
176
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
177 return 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
178 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
179 else
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
180 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
181 CYG_TEST_INFO( "Waiting until remote end goes down");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
182
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
183 while( cyg_ppp_wait_up( ppp_handle ) == 0 )
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
184 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
185 i++;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
186
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
187 // if( (i % 60) == 0 )
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
188 // show_network_tables( diag_printf );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
189
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
190 cyg_thread_delay(100);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
191 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
192
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
193 cyg_ppp_wait_down( ppp_handle );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
194
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
195 return 1;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
196 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
197
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
198 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
199
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
200 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
201
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
202 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
203 ppp_test(cyg_addrword_t p)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
204 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
205 cyg_serial_baud_rate_t old;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
206 struct auth_info *test;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
207 int failures = 0;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
208
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
209 CYG_TEST_INIT();
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
210 diag_printf("Start PPP test\n");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
211
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
212 init_all_network_interfaces();
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
213
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
214 old = ppp_test_set_baud( CYGNUM_SERIAL_BAUD_38400 );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
215
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
216
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
217 for( test = &tests[0]; test->name != NULL; test++ )
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
218 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
219 if( !do_test( test ) )
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
220 failures++;
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
221
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
222 cyg_thread_delay(300);
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
223 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
224
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
225 ppp_test_set_baud( old );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
226
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
227 ppp_test_finish();
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
228
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
229 if( failures > 0 )
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
230 CYG_TEST_FAIL("Some tests failed");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
231 else
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
232 CYG_TEST_PASS("OK");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
233
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
234 CYG_TEST_FINISH("PPP auth test");
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
235 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
236
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
237 //==========================================================================
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
238
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
239 void
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
240 cyg_start(void)
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
241 {
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
242 // Create a main thread, so we can run the scheduler and have time 'pass'
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
243 cyg_thread_create(10, // Priority - just a number
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
244 ppp_test, // entry
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
245 0, // entry parameter
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
246 "PPP test", // Name
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
247 &stack[0], // Stack
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
248 STACK_SIZE, // Size
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
249 &thread_handle, // Handle
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
250 &thread_data // Thread data structure
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
251 );
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
252 cyg_thread_resume(thread_handle); // Start it
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
253 cyg_scheduler_start();
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
254 }
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
255
e0d88dc6a92f Added PPP network support.
nickg
parents:
diff changeset
256 //==========================================================================