3 * http_static.h - skeleton vpp engine plug-in header file
5 * Copyright (c) <current-year> <your-organization>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 #ifndef __included_http_static_h__
19 #define __included_http_static_h__
21 #include <vnet/vnet.h>
22 #include <vnet/session/application.h>
23 #include <vnet/session/application_interface.h>
24 #include <vnet/session/session.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/ethernet/ethernet.h>
28 #include <vppinfra/hash.h>
29 #include <vppinfra/error.h>
30 #include <vppinfra/time_range.h>
31 #include <vppinfra/tw_timer_2t_1w_2048sl.h>
32 #include <vppinfra/bihash_vec8_8.h>
34 /** @file http_static.h
35 * Static http server definitions
40 /* API message ID base */
44 vlib_main_t *vlib_main;
45 vnet_main_t *vnet_main;
48 extern http_static_main_t http_static_main;
50 /** \brief Session States
55 /** Session is closed */
57 /** Session is established */
58 HTTP_STATE_ESTABLISHED,
59 /** Session has sent an OK response */
61 /** Session has sent an HTML response */
62 HTTP_STATE_SEND_MORE_DATA,
63 /** Number of states */
65 } http_session_state_t;
69 HTTP_BUILTIN_METHOD_GET = 0,
70 HTTP_BUILTIN_METHOD_POST,
71 } http_builtin_method_type_t;
73 /** \brief Application session
77 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
78 /** Base class instance variables */
79 #define _(type, name) type name;
80 foreach_app_session_field
82 /** rx thread index */
86 /** vpp session index, handle */
87 u32 vpp_session_index;
88 u64 vpp_session_handle;
89 /** Timeout timer handle */
91 /** Fully-resolved file path */
93 /** File data, a vector */
95 /** Current data send offset */
97 /** Need to free data in detach_cache_entry */
100 /** File cache pool index */
101 u32 cache_pool_index;
104 /** \brief In-memory file data cache entry
108 /** Name of the file */
110 /** Contents of the file, as a u8 * vector */
112 /** Last time the cache entry was used */
114 /** Cache LRU links */
117 /** Reference count, so we don't recycle while referenced */
121 /** \brief Main data structure
126 /** Per thread vector of session pools */
127 http_session_t **sessions;
128 /** Session pool reader writer lock */
129 clib_spinlock_t cache_lock;
131 /** Enable debug messages */
134 /** Unified file data cache pool */
135 file_data_cache_t *cache_pool;
136 /** Hash table which maps file name to file data */
137 BVT (clib_bihash) name_to_data;
139 /** Hash tables for built-in GET and POST handlers */
140 uword *get_url_handlers;
141 uword *post_url_handlers;
143 /** Current cache size */
145 /** Max cache size in bytes */
147 /** Number of cache evictions */
150 /** Cache LRU listheads */
154 /** root path to be served */
157 /** Application index */
160 /** Cert and key pair for tls */
163 vlib_main_t *vlib_main;
169 /** Number of preallocated fifos, usually 0 */
171 /** Private segment size, usually 0 */
172 u32 private_segment_size;
173 /** Size of the allocated rx, tx fifos, roughly 8K or so */
175 /** The bind URI, defaults to tcp://0.0.0.0/80 */
177 /** Threshold for switching to ptr data in http msgs */
181 extern hss_main_t hss_main;
183 int hss_enable_api (u32 fifo_size, u32 cache_limit, u32 prealloc_fifos,
184 u32 private_segment_size, u8 *www_root, u8 *uri);
186 void http_static_server_register_builtin_handler
187 (void *fp, char *url, int type);
189 #endif /* __included_http_static_h__ */
192 * fd.io coding-style-patch-verification: ON
195 * eval: (c-set-style "gnu")