1 | /* Init |
---|
2 | * |
---|
3 | * This routine is the initialization task for this test program. |
---|
4 | * |
---|
5 | * Don't forget to change the IP addresses |
---|
6 | */ |
---|
7 | |
---|
8 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
9 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
10 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
11 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20 |
---|
12 | #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM |
---|
13 | |
---|
14 | #define CONFIGURE_EXECUTIVE_RAM_SIZE (512*1024) |
---|
15 | #define CONFIGURE_MAXIMUM_SEMAPHORES 20 |
---|
16 | #define CONFIGURE_MAXIMUM_TASKS 20 |
---|
17 | |
---|
18 | #define CONFIGURE_MICROSECONDS_PER_TICK 10000 |
---|
19 | |
---|
20 | #define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024) |
---|
21 | #define CONFIGURE_INIT_TASK_PRIORITY 120 |
---|
22 | #define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \ |
---|
23 | RTEMS_NO_TIMESLICE | \ |
---|
24 | RTEMS_NO_ASR | \ |
---|
25 | RTEMS_INTERRUPT_LEVEL(0)) |
---|
26 | |
---|
27 | #define STACK_CHECKER_ON |
---|
28 | #define CONFIGURE_INIT |
---|
29 | |
---|
30 | #include "system.h" |
---|
31 | #include <bsp.h> |
---|
32 | |
---|
33 | #include <errno.h> |
---|
34 | #include <time.h> |
---|
35 | |
---|
36 | #include <rtems/confdefs.h> |
---|
37 | #include <stdio.h> |
---|
38 | #include <rtems/rtems_bsdnet.h> |
---|
39 | #include <rtems/ftpd.h> |
---|
40 | #include <rtems/untar.h> |
---|
41 | |
---|
42 | |
---|
43 | #include <rtems/error.h> |
---|
44 | #include <rpc/rpc.h> |
---|
45 | #include <netinet/in.h> |
---|
46 | #include <time.h> |
---|
47 | |
---|
48 | #include <arpa/inet.h> |
---|
49 | #include <sys/socket.h> |
---|
50 | #include "../networkconfig.h" |
---|
51 | |
---|
52 | #include <rtems_webserver.h> |
---|
53 | |
---|
54 | #define ARGUMENT 0 |
---|
55 | |
---|
56 | /* |
---|
57 | * The tarfile image is built automatically externally. |
---|
58 | */ |
---|
59 | #include "FilesystemImage.h" |
---|
60 | |
---|
61 | #if defined(USE_FTPD) |
---|
62 | boolean FTPD_enabled = TRUE; |
---|
63 | struct rtems_ftpd_configuration rtems_ftpd_configuration = { |
---|
64 | 10, /* FTPD task priority */ |
---|
65 | 1024, /* Maximum buffersize for hooks */ |
---|
66 | 21, /* Well-known port */ |
---|
67 | NULL /* List of hooks */ |
---|
68 | }; |
---|
69 | #else |
---|
70 | boolean FTPD_enabled = FALSE; |
---|
71 | #endif |
---|
72 | |
---|
73 | #if defined(USE_GOAHEAD_HTTPD) |
---|
74 | boolean GoAhead_HTTPD_enabled = TRUE; |
---|
75 | |
---|
76 | /* GoAhead Trace Handler */ |
---|
77 | #include <goahead/uemf.h> |
---|
78 | void quietTraceHandler(int level, char *buf) |
---|
79 | { |
---|
80 | /* do nothing */ |
---|
81 | } |
---|
82 | #else |
---|
83 | boolean GoAhead_HTTPD_enabled = FALSE; |
---|
84 | #endif |
---|
85 | |
---|
86 | #if defined(USE_SIMPLE_HTTPD) |
---|
87 | boolean Simple_HTTPD_enabled = TRUE; |
---|
88 | |
---|
89 | #include <shttpd/shttpd.h> |
---|
90 | #else |
---|
91 | boolean Simple_HTTPD_enabled = FALSE; |
---|
92 | #endif |
---|
93 | |
---|
94 | #define bool2string(_b) ((_b) ? "true" : "false") |
---|
95 | |
---|
96 | #if defined(USE_SIMPLE_HTTPD) |
---|
97 | extern void example_shttpd_addpages(struct shttpd_ctx *ctx); |
---|
98 | #endif |
---|
99 | |
---|
100 | rtems_task Init( |
---|
101 | rtems_task_argument argument |
---|
102 | ) |
---|
103 | { |
---|
104 | rtems_status_code status; |
---|
105 | |
---|
106 | printf("\n\n*** HTTP TEST ***\n\r" ); |
---|
107 | printf("GoAhead HTTPD Enabled: %s\n", bool2string(GoAhead_HTTPD_enabled) ); |
---|
108 | printf("Simple HTTPD Enabled: %s\n", bool2string(Simple_HTTPD_enabled) ); |
---|
109 | printf("FTPD Enabled: %s\n", bool2string(FTPD_enabled) ); |
---|
110 | printf("\n"); |
---|
111 | |
---|
112 | /* |
---|
113 | * Load filesystem image |
---|
114 | */ |
---|
115 | printf("Loading filesystem image\n"); |
---|
116 | status = Untar_FromMemory( (char *)FilesystemImage, FilesystemImage_size ); |
---|
117 | |
---|
118 | printf("Initializing Network\n"); |
---|
119 | rtems_bsdnet_initialize_network (); |
---|
120 | |
---|
121 | #if defined(USE_FTPD) |
---|
122 | printf( "Initializing FTPD\n" ); |
---|
123 | rtems_initialize_ftpd(); |
---|
124 | #endif |
---|
125 | |
---|
126 | #if defined(USE_GOAHEAD_HTTPD) |
---|
127 | printf( "Initializing GoAhead HTTPD\n" ); |
---|
128 | status = rtems_initialize_webserver(); |
---|
129 | if ( status ) |
---|
130 | printf( "ERROR -- failed to initialize webserver\n" ); |
---|
131 | |
---|
132 | traceSetHandler( quietTraceHandler ); |
---|
133 | #endif |
---|
134 | |
---|
135 | #if defined(USE_SIMPLE_HTTPD) |
---|
136 | printf( "Initializing Simple HTTPD\n" ); |
---|
137 | status = rtems_initialize_webserver( |
---|
138 | 100, /* initial priority */ |
---|
139 | RTEMS_MINIMUM_STACK_SIZE * 4, /* stack size */ |
---|
140 | RTEMS_DEFAULT_MODES, /* initial modes */ |
---|
141 | RTEMS_DEFAULT_ATTRIBUTES, /* attributes */ |
---|
142 | NULL, /* init_callback */ |
---|
143 | example_shttpd_addpages, /* addpages_callback */ |
---|
144 | "/", /* initial priority */ |
---|
145 | 80 /* port to listen on */ |
---|
146 | ); |
---|
147 | if ( status ) |
---|
148 | printf( "ERROR -- failed to initialize webserver\n" ); |
---|
149 | |
---|
150 | #endif |
---|
151 | |
---|
152 | status = rtems_task_delete( RTEMS_SELF ); |
---|
153 | } |
---|
154 | |
---|
155 | |
---|
156 | |
---|
157 | |
---|