source: network-demos/http/init.c @ 5d2c26f

4.11network-demos-4-10-branch
Last change on this file since 5d2c26f was 5d2c26f, checked in by Joel Sherrill <joel.sherrill@…>, on May 13, 2009 at 6:54:45 PM

2009-05-13 Joel Sherrill <joel.sherrill@…>

  • Makefile, init.c, system.h: Allow overrides from invoking environment. Also move RTEMS Configuration to bottom of init.c.
  • Property mode set to 100644
File size: 4.8 KB
Line 
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#include "system.h"
9#include <bsp.h>
10
11#include <errno.h>
12#include <time.h>
13
14#include <stdio.h>
15#include <rtems/rtems_bsdnet.h>
16#include <rtems/ftpd.h>
17#include <rtems/untar.h>
18
19     
20#include <rtems/error.h>
21#include <rpc/rpc.h>
22#include <netinet/in.h>
23#include <time.h>
24
25#include <arpa/inet.h>
26#include <sys/socket.h>
27#include "../networkconfig.h"
28
29#include <rtems_webserver.h>
30
31#define ARGUMENT 0
32
33/*
34 *  The tarfile image is built automatically externally.
35 */
36#include "FilesystemImage.h"
37
38#if defined(USE_FTPD)
39  bool FTPD_enabled = true;
40  struct rtems_ftpd_configuration rtems_ftpd_configuration = {
41    10,                     /* FTPD task priority            */
42    1024,                   /* Maximum buffersize for hooks  */
43    21,                     /* Well-known port     */
44    NULL,                   /* List of hooks       */
45    NULL,                   /* Root for FTPD or 0 for / */
46    0,                      /* Max. connections    */
47    0,                      /* Idle timeout in seoconds
48                               or 0 for no (inf) timeout */
49    0,                      /* 0 - r/w, 1 - read-only,
50                               2 - write-only,
51                               3 - browse-only */
52 };
53
54#else
55 bool FTPD_enabled = false;
56#endif
57
58#if defined(USE_GOAHEAD_HTTPD) && !defined(RTEMS_POSIX_API)
59  #warning "GoAhead server requires POSIX API - switching to SHTTPD"
60  #undef USE_GOAHEAD_HTTPD
61  #undef USE_SIMPLE_HTTPD
62#endif
63
64#if defined(USE_GOAHEAD_HTTPD)
65  bool GoAhead_HTTPD_enabled = true;
66
67  /* GoAhead Trace Handler */
68  #include <goahead/uemf.h>
69  void quietTraceHandler(int level, char *buf)
70  {
71    /* do nothing */
72  }
73#else
74  bool GoAhead_HTTPD_enabled = false;
75#endif
76
77#if defined(USE_SIMPLE_HTTPD)
78  bool Simple_HTTPD_enabled = true;
79
80  #include <shttpd/shttpd.h>
81#else
82  bool Simple_HTTPD_enabled = false;
83#endif
84
85#define bool2string(_b) ((_b) ? "true" : "false")
86
87#if defined(USE_SIMPLE_HTTPD)
88extern void example_shttpd_addpages(struct shttpd_ctx *ctx);
89#endif
90
91rtems_task Init(
92  rtems_task_argument argument
93)
94{
95  rtems_status_code status;
96
97  printf("\n\n*** HTTP TEST ***\n\r" );
98  printf("GoAhead HTTPD Enabled: %s\n", bool2string(GoAhead_HTTPD_enabled) );
99  printf("Simple HTTPD Enabled: %s\n", bool2string(Simple_HTTPD_enabled) );
100  printf("FTPD Enabled: %s\n", bool2string(FTPD_enabled) );
101  printf("\n");
102
103  /*
104   * Load filesystem image
105   */
106  printf("Loading filesystem image\n");
107  status = Untar_FromMemory( (char *)FilesystemImage, FilesystemImage_size );
108   
109  printf("Initializing Network\n");
110  rtems_bsdnet_initialize_network ();
111
112  #if defined(USE_FTPD)
113    printf( "Initializing FTPD\n" );
114    rtems_initialize_ftpd();
115  #endif
116
117  #if defined(USE_GOAHEAD_HTTPD)
118    printf( "Initializing GoAhead HTTPD\n" );
119    status = rtems_initialize_webserver();
120    if ( status )
121      printf( "ERROR -- failed to initialize webserver\n" );
122
123    traceSetHandler( quietTraceHandler );
124  #endif
125
126  #if defined(USE_SIMPLE_HTTPD)
127    /*
128     *  SHTTPD uses about 37K of stack even in this test on a PowerPC.
129     *  There is no point in doing math for the stack size.  Bump it
130     *  until there isn't a problem.
131     */
132    printf( "Initializing Simple HTTPD\n" );
133    status = rtems_initialize_webserver(
134      100,                             /* initial priority */
135      (48 * 1024),                     /* stack size */
136      RTEMS_DEFAULT_MODES,             /* initial modes */
137      RTEMS_DEFAULT_ATTRIBUTES,        /* attributes */
138      NULL,                            /* init_callback */
139      example_shttpd_addpages,         /* addpages_callback */
140      "/",                             /* initial priority */
141      80                               /* port to listen on */
142    );
143    if ( status )
144      printf( "ERROR -- failed to initialize webserver\n" );
145
146  #endif
147
148  status = rtems_task_delete( RTEMS_SELF );
149}
150
151
152/*
153 *  Configuration
154 */
155#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
156#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
157#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
158#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS        20
159#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
160
161#define CONFIGURE_EXECUTIVE_RAM_SIZE    (512*1024)
162#define CONFIGURE_MAXIMUM_SEMAPHORES    20
163#define CONFIGURE_MAXIMUM_TASKS         20
164
165#define CONFIGURE_MICROSECONDS_PER_TICK 10000
166
167#define CONFIGURE_INIT_TASK_STACK_SIZE  (10*1024)
168#define CONFIGURE_INIT_TASK_PRIORITY    120
169#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
170                                           RTEMS_NO_TIMESLICE | \
171                                           RTEMS_NO_ASR | \
172                                           RTEMS_INTERRUPT_LEVEL(0))
173
174#define CONFIGURE_STACK_CHECKER_ENABLED
175#define CONFIGURE_INIT
176
177#include <rtems/confdefs.h>
178
Note: See TracBrowser for help on using the repository browser.