FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
http_static.h
Go to the documentation of this file.
1 
2 /*
3  * http_static.h - skeleton vpp engine plug-in header file
4  *
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:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  */
18 #ifndef __included_http_static_h__
19 #define __included_http_static_h__
20 
21 #include <vnet/vnet.h>
24 #include <vnet/session/session.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/ethernet/ethernet.h>
27 
28 #include <vppinfra/hash.h>
29 #include <vppinfra/error.h>
30 #include <vppinfra/time_range.h>
32 #include <vppinfra/bihash_vec8_8.h>
33 
34 /** @file Static http server definitions
35 */
36 
37 typedef struct
38 {
39  /* API message ID base */
41 
42  /* convenience */
46 
48 
49 /** \brief Session States
50  */
51 
52 typedef enum
53 {
54  /** Session is closed */
56  /** Session is established */
58  /** Session has sent an OK response */
60  /** Session has sent an HTML response */
62  /** Number of states */
65 
66 typedef enum
67 {
72 
73 typedef enum
74 {
78 
79 
80 /** \brief Application session
81  */
82 typedef struct
83 {
84  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
85  /** Base class instance variables */
86 #define _(type, name) type name;
88 #undef _
89  /** rx thread index */
90  u32 thread_index;
91  /** rx buffer */
92  u8 *rx_buf;
93  /** vpp session index, handle */
94  u32 vpp_session_index;
95  u64 vpp_session_handle;
96  /** Timeout timer handle */
97  u32 timer_handle;
98  /** Fully-resolved file path */
99  u8 *path;
100  /** File data, a vector */
102  /** Current data send offset */
104  /** Need to free data in detach_cache_entry */
106 
107  /** File cache pool index */
109  /** state machine called from... */
112 
113 /** \brief In-memory file data cache entry
114  */
115 typedef struct
116 {
117  /** Name of the file */
119  /** Contents of the file, as a u8 * vector */
121  /** Last time the cache entry was used */
123  /** Cache LRU links */
126  /** Reference count, so we don't recycle while referenced */
127  int inuse;
129 
130 /** \brief Main data structure
131  */
132 
133 typedef struct
134 {
135  /** Per thread vector of session pools */
137  /** Session pool reader writer lock */
139  /** vpp session to http session index map */
141 
142  /** Enable debug messages */
144 
145  /** vpp message/event queue */
147 
148  /** Unified file data cache pool */
150  /** Hash table which maps file name to file data */
151  BVT (clib_bihash) name_to_data;
152 
153  /** Hash tables for built-in GET and POST handlers */
156 
157  /** Current cache size */
159  /** Max cache size in bytes */
161  /** Number of cache evictions */
163 
164  /** Cache LRU listheads */
167 
168  /** root path to be served */
170 
171  /** Server's event queue */
173 
174  /** API client handle */
176 
177  /** Application index */
179 
180  /** Process node index for event scheduling */
182 
183  /** Session cleanup timer wheel */
184  tw_timer_wheel_2t_1w_2048sl_t tw;
186 
187  /** Time base, so we can generate browser cache control http spew */
189 
190  /** Number of preallocated fifos, usually 0 */
192  /** Private segment size, usually 0 */
194  /** Size of the allocated rx, tx fifos, roughly 8K or so */
196  /** The bind URI, defaults to tcp://0.0.0.0/80 */
197  u8 *uri;
200 
202 
203 int http_static_server_enable_api (u32 fifo_size, u32 cache_limit,
204  u32 prealloc_fifos,
205  u32 private_segment_size,
206  u8 * www_root, u8 * uri);
207 
209  (void *fp, char *url, int type);
210 
211 #endif /* __included_http_static_h__ */
212 
213 /*
214  * fd.io coding-style-patch-verification: ON
215  *
216  * Local Variables:
217  * eval: (c-set-style "gnu")
218  * End:
219  */
#define foreach_app_session_field
flag for dgram mode
u8 * filename
Name of the file.
Definition: http_static.h:118
u32 node_index
Process node index for event scheduling.
Definition: http_static.h:181
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:60
http_static_main_t http_static_main
Definition: http_static.c:55
unsigned long u64
Definition: types.h:89
u32 fifo_size
Size of the allocated rx, tx fifos, roughly 8K or so.
Definition: http_static.h:195
u32 data_offset
Current data send offset.
Definition: http_static.h:103
Main data structure.
Definition: http_static.h:133
u32 private_segment_size
Private segment size, usually 0.
Definition: http_static.h:193
int debug_level
Enable debug messages.
Definition: http_static.h:143
clib_timebase_t timebase
Time base, so we can generate browser cache control http spew.
Definition: http_static.h:188
u8 * path
Fully-resolved file path.
Definition: http_static.h:99
u32 prealloc_fifos
Number of preallocated fifos, usually 0.
Definition: http_static.h:191
unsigned char u8
Definition: types.h:56
double f64
Definition: types.h:142
svm_msg_q_t ** vpp_queue
vpp message/event queue
Definition: http_static.h:146
vnet_main_t * vnet_main
Definition: http_static.h:44
static BVT(clib_bihash)
Definition: adj_nbr.c:28
http_static_server_main_t http_static_server_main
Definition: static_server.c:33
u64 cache_size
Current cache size.
Definition: http_static.h:158
Number of states.
Definition: http_static.h:63
unsigned int u32
Definition: types.h:88
vlib_main_t * vlib_main
Definition: http_static.h:43
int free_data
Need to free data in detach_cache_entry.
Definition: http_static.h:105
vl_api_fib_path_type_t type
Definition: fib_types.api:123
u8 * data
Contents of the file, as a u8 * vector.
Definition: http_static.h:120
file_data_cache_t * cache_pool
Unified file data cache pool.
Definition: http_static.h:149
Session is closed.
Definition: http_static.h:55
u8 * data
File data, a vector.
Definition: http_static.h:101
unsigned short u16
Definition: types.h:57
http_state_machine_called_from_t
Definition: http_static.h:66
Application session.
Definition: http_server.c:40
uword * get_url_handlers
Hash tables for built-in GET and POST handlers.
Definition: http_static.h:154
http_session_state_t
Session States.
Definition: http_static.h:52
int http_static_server_enable_api(u32 fifo_size, u32 cache_limit, u32 prealloc_fifos, u32 private_segment_size, u8 *www_root, u8 *uri)
API helper function for vl_api_http_static_enable_t messages.
f64 last_used
Last time the cache entry was used.
Definition: http_static.h:122
u32 ** session_to_http_session
vpp session to http session index map
Definition: http_static.h:140
http_session_t ** sessions
Per thread vector of session pools.
Definition: http_static.h:136
clib_rwlock_t sessions_lock
Session pool reader writer lock.
Definition: http_static.h:138
u32 cache_pool_index
File cache pool index.
Definition: http_static.h:108
u32 app_index
Application index.
Definition: http_static.h:178
u32 my_client_index
API client handle.
Definition: http_static.h:175
Session has sent an HTML response.
Definition: http_static.h:61
void http_static_server_register_builtin_handler(void *fp, char *url, int type)
Register a builtin GET or POST handler.
http_state_machine_called_from_t called_from
state machine called from...
Definition: http_static.h:110
u32 first_index
Cache LRU listheads.
Definition: http_static.h:165
http_builtin_method_type_t
Definition: http_static.h:73
svm_queue_t * vl_input_queue
Server&#39;s event queue.
Definition: http_static.h:172
tw_timer_wheel_2t_1w_2048sl_t tw
Session cleanup timer wheel.
Definition: http_static.h:184
Session is established.
Definition: http_static.h:57
u32 next_index
Cache LRU links.
Definition: http_static.h:124
Session has sent an OK response.
Definition: http_static.h:59
u64 uword
Definition: types.h:112
int inuse
Reference count, so we don&#39;t recycle while referenced.
Definition: http_static.h:127
u8 * uri
The bind URI, defaults to tcp://0.0.0.0/80.
Definition: http_static.h:197
struct _svm_queue svm_queue_t
u64 cache_evictions
Number of cache evictions.
Definition: http_static.h:162
clib_spinlock_t tw_lock
Definition: http_static.h:185
In-memory file data cache entry.
Definition: http_static.h:115
u8 * www_root
root path to be served
Definition: http_static.h:169
u64 cache_limit
Max cache size in bytes.
Definition: http_static.h:160