2 * Copyright (c) 2017-2022 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #ifndef __included_http_static_h__
16 #define __included_http_static_h__
18 #include <vnet/session/application_interface.h>
19 #include <vnet/session/session.h>
20 #include <http/http.h>
22 #include <vppinfra/hash.h>
23 #include <vppinfra/error.h>
24 #include <vppinfra/bihash_vec8_8.h>
26 /** @file http_static.h
27 * Static http server definitions
30 /** \brief Application session
34 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
36 /** rx thread index */
38 /** vpp session index, handle */
39 u32 vpp_session_index;
40 session_handle_t vpp_session_handle;
41 /** Fully-resolved file path */
43 /** File data, a vector */
45 /** Current data send offset */
47 /** Need to free data in detach_cache_entry */
49 /** File cache pool index */
53 /** \brief In-memory file data cache entry
57 /** Name of the file */
59 /** Contents of the file, as a u8 * vector */
61 /** Last time the cache entry was used */
63 /** Cache LRU links */
66 /** Reference count, so we don't recycle while referenced */
70 /** \brief Main data structure
75 /** Per thread vector of session pools */
76 hss_session_t **sessions;
77 /** Session pool reader writer lock */
78 clib_spinlock_t cache_lock;
80 /** Unified file data cache pool */
81 hss_cache_entry_t *cache_pool;
82 /** Hash table which maps file name to file data */
83 BVT (clib_bihash) name_to_data;
85 /** Hash tables for built-in GET and POST handlers */
86 uword *get_url_handlers;
87 uword *post_url_handlers;
89 /** Current cache size */
91 /** Max cache size in bytes */
93 /** Number of cache evictions */
96 /** Cache LRU listheads */
100 /** root path to be served */
103 /** Application index */
106 /** Cert and key pair for tls */
109 /* API message ID base */
112 vlib_main_t *vlib_main;
118 /** Enable debug messages */
120 /** Number of preallocated fifos, usually 0 */
122 /** Private segment size, usually 0 */
123 u64 private_segment_size;
124 /** Size of the allocated rx, tx fifos, roughly 8K or so */
126 /** The bind URI, defaults to tcp://0.0.0.0/80 */
128 /** Threshold for switching to ptr data in http msgs */
132 extern hss_main_t hss_main;
134 int hss_create (vlib_main_t *vm);
136 void http_static_server_register_builtin_handler (void *fp, char *url,
137 http_req_method_t type);
139 #endif /* __included_http_static_h__ */
142 * fd.io coding-style-patch-verification: ON
145 * eval: (c-set-style "gnu")