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 <http_static/http_cache.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 */
47 /** Current data send offset */
49 /** Need to free data in detach_cache_entry */
51 /** File cache pool index */
55 typedef struct hss_session_handle_
66 } hss_session_handle_t;
68 STATIC_ASSERT_SIZEOF (hss_session_handle_t, sizeof (u64));
71 typedef struct hss_url_handler_args_
73 hss_session_handle_t sh;
81 http_req_method_t reqtype;
90 http_status_code_t sc;
93 } hss_url_handler_args_t;
95 typedef enum hss_url_handler_rc_
98 HSS_URL_HANDLER_ERROR,
99 HSS_URL_HANDLER_ASYNC,
100 } hss_url_handler_rc_t;
102 typedef hss_url_handler_rc_t (*hss_url_handler_fn) (hss_url_handler_args_t *);
103 typedef void (*hss_register_url_fn) (hss_url_handler_fn, char *, int);
104 typedef void (*hss_session_send_fn) (hss_url_handler_args_t *args);
106 /** \brief Main data structure
110 /** Per thread vector of session pools */
111 hss_session_t **sessions;
113 /** Hash tables for built-in GET and POST handlers */
114 uword *get_url_handlers;
115 uword *post_url_handlers;
119 /** root path to be served */
122 /** Application index */
125 /** Cert and key pair for tls */
128 /* API message ID base */
131 vlib_main_t *vlib_main;
137 /** Enable debug messages */
139 /** Number of preallocated fifos, usually 0 */
141 /** Private segment size, usually 0 */
142 u64 private_segment_size;
143 /** Size of the allocated rx, tx fifos, roughly 8K or so */
145 /** The bind URI, defaults to tcp://0.0.0.0/80 */
147 /** Threshold for switching to ptr data in http msgs */
149 /** Enable the use of builtinurls */
150 u8 enable_url_handlers;
151 /** Max cache size before LRU occurs */
155 extern hss_main_t hss_main;
157 int hss_create (vlib_main_t *vm);
160 * Register a GET or POST URL handler
162 void hss_register_url_handler (hss_url_handler_fn fp, const char *url,
163 http_req_method_t type);
164 void hss_session_send_data (hss_url_handler_args_t *args);
165 void hss_builtinurl_json_handlers_init (void);
167 #endif /* __included_http_static_h__ */
170 * fd.io coding-style-patch-verification: ON
173 * eval: (c-set-style "gnu")