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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [common/] [v2_0/] [tests/] [tftp_server_test.c] - Blame information for rev 307

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

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      tests/tftp_server_test.c
4
//
5
//      Simple TFTP server test
6
//
7
//==========================================================================
8
//####BSDCOPYRIGHTBEGIN####
9
//
10
// -------------------------------------------
11
//
12
// Portions of this software may have been derived from OpenBSD or other sources,
13
// and are covered by the appropriate copyright disclaimers included herein.
14
//
15
// -------------------------------------------
16
//
17
//####BSDCOPYRIGHTEND####
18
//==========================================================================
19
//#####DESCRIPTIONBEGIN####
20
//
21
// Author(s):    gthomas
22
// Contributors: gthomas
23
// Date:         2000-04-07
24
// Purpose:      
25
// Description:  
26
//              
27
//
28
//####DESCRIPTIONEND####
29
//
30
//==========================================================================
31
// TFTP test code
32
 
33
#include <pkgconf/system.h>
34
#include <pkgconf/net.h>
35
 
36
#ifdef CYGBLD_DEVS_ETH_DEVICE_H    // Get the device config if it exists
37
#include CYGBLD_DEVS_ETH_DEVICE_H  // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
38
#endif
39
 
40
#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
41
# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
42
#  include CYGTST_DEVS_ETH_TEST_NET_REALTIME
43
# endif
44
#endif
45
 
46
 
47
// Fill in the blanks if necessary
48
#ifndef TNR_OFF
49
# define TNR_OFF()
50
#endif
51
#ifndef TNR_ON
52
# define TNR_ON()
53
#endif
54
#ifndef TNR_INIT
55
# define TNR_INIT()
56
#endif
57
#ifndef TNR_PRINT_ACTIVITY
58
# define TNR_PRINT_ACTIVITY()
59
#endif
60
 
61
// ------------------------------------------------------------------------
62
 
63
#include <network.h>
64
#include <tftp_support.h>
65
 
66
#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000)
67
static char stack[STACK_SIZE];
68
static cyg_thread thread_data;
69
static cyg_handle_t thread_handle;
70
 
71
extern void
72
cyg_test_exit(void);
73
 
74
void
75
pexit(char *s)
76
{
77
    perror(s);
78
    cyg_test_exit();
79
}
80
 
81
static void
82
tftp_test(struct bootp *bp)
83
{
84
    int server_id, res;
85
    extern struct tftpd_fileops dummy_fileops;
86
    server_id = tftpd_start(0, &dummy_fileops);
87
    if (server_id > 0) {
88
        diag_printf("TFTP server created - id: %x\n", server_id);
89
        // Only let the server run for 5 minutes
90
        cyg_thread_delay(2*100); // let the tftpd start up first
91
        TNR_ON();
92
        cyg_thread_delay(5*60*100);
93
        TNR_OFF();
94
        res = tftpd_stop(server_id);
95
        diag_printf("TFTP server stopped - res: %d\n", res);
96
    } else {
97
        diag_printf("Couldn't create a server!\n");
98
    }
99
}
100
 
101
void
102
net_test(cyg_addrword_t param)
103
{
104
    diag_printf("Start TFTP server test\n");
105
    init_all_network_interfaces();
106
    TNR_INIT();
107
#ifdef CYGHWR_NET_DRIVER_ETH0
108
    if (eth0_up) {
109
        tftp_test(&eth0_bootp_data);
110
    }
111
#else
112
    if ( 0 ) ;
113
#endif
114
#ifdef CYGHWR_NET_DRIVER_ETH1
115
    else if (eth1_up) {
116
        tftp_test(&eth1_bootp_data);
117
    }
118
#endif
119
    TNR_PRINT_ACTIVITY();
120
    cyg_test_exit();
121
}
122
 
123
void
124
cyg_start(void)
125
{
126
    // Create a main thread, so we can run the scheduler and have time 'pass'
127
    cyg_thread_create(10,                // Priority - just a number
128
                      net_test,          // entry
129
                      0,                 // entry parameter
130
                      "Network test",    // Name
131
                      &stack[0],         // Stack
132
                      STACK_SIZE,        // Size
133
                      &thread_handle,    // Handle
134
                      &thread_data       // Thread data structure
135
            );
136
    cyg_thread_resume(thread_handle);  // Start it
137
    cyg_scheduler_start();
138
}
139
 
140
// EOF tftp_server_test.c

powered by: WebSVN 2.1.0

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