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 typedef int (*hss_url_handler_t) (http_req_method_t, u8 *, hss_session_t *);
72 /** \brief Main data structure
76 /** Per thread vector of session pools */
77 hss_session_t **sessions;
78 /** Session pool reader writer lock */
79 clib_spinlock_t cache_lock;
81 /** Unified file data cache pool */
82 hss_cache_entry_t *cache_pool;
83 /** Hash table which maps file name to file data */
84 BVT (clib_bihash) name_to_data;
86 /** Hash tables for built-in GET and POST handlers */
87 uword *get_url_handlers;
88 uword *post_url_handlers;
90 /** Current cache size */
92 /** Max cache size in bytes */
94 /** Number of cache evictions */
97 /** Cache LRU listheads */
101 /** root path to be served */
104 /** Application index */
107 /** Cert and key pair for tls */
110 /* API message ID base */
113 vlib_main_t *vlib_main;
119 /** Enable debug messages */
121 /** Number of preallocated fifos, usually 0 */
123 /** Private segment size, usually 0 */
124 u64 private_segment_size;
125 /** Size of the allocated rx, tx fifos, roughly 8K or so */
127 /** The bind URI, defaults to tcp://0.0.0.0/80 */
129 /** Threshold for switching to ptr data in http msgs */
131 /** Enable the use of builtinurls */
132 u8 enable_url_handlers;
135 extern hss_main_t hss_main;
137 int hss_create (vlib_main_t *vm);
140 * Register a GET or POST URL handler
142 void hss_register_url_handler (hss_url_handler_t fp, const char *url,
143 http_req_method_t type);
144 void hss_builtinurl_json_handlers_init (void);
146 #endif /* __included_http_static_h__ */
149 * fd.io coding-style-patch-verification: ON
152 * eval: (c-set-style "gnu")