2 * Copyright (c) 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.
16 #ifndef SRC_PLUGINS_HTTP_HTTP_H_
17 #define SRC_PLUGINS_HTTP_HTTP_H_
19 #include <vnet/plugin/plugin.h>
20 #include <vpp/app/version.h>
22 #include <vppinfra/time_range.h>
24 #include <vnet/session/application_interface.h>
25 #include <vnet/session/application.h>
26 #include <http/http_buffer.h>
31 #define HTTP_DBG(_lvl, _fmt, _args...) \
32 if (_lvl <= HTTP_DEBUG) \
33 clib_warning (_fmt, ##_args)
35 #define HTTP_DBG(_lvl, _fmt, _args...)
38 typedef struct http_conn_id_
42 session_handle_t app_session_handle;
43 u32 parent_app_api_ctx;
45 session_handle_t tc_session_handle;
46 u32 parent_app_wrk_index;
49 STATIC_ASSERT (sizeof (http_conn_id_t) <= TRANSPORT_CONN_ID_LEN,
50 "ctx id must be less than TRANSPORT_CONN_ID_LEN");
52 typedef enum http_state_
54 HTTP_CONN_STATE_LISTEN,
55 HTTP_CONN_STATE_CONNECTING,
56 HTTP_CONN_STATE_ESTABLISHED,
57 HTTP_CONN_STATE_TRANSPORT_CLOSED,
58 HTTP_CONN_STATE_APP_CLOSED,
59 HTTP_CONN_STATE_CLOSED
62 typedef enum http_req_state_
64 HTTP_REQ_STATE_WAIT_METHOD,
65 HTTP_REQ_STATE_WAIT_APP,
66 HTTP_REQ_STATE_SEND_MORE_DATA,
70 typedef enum http_req_method_
76 typedef enum http_msg_type_
82 #define foreach_http_content_type \
83 _ (TEXT_HTML, "text/html") \
84 _ (TEXT_CSS, "text/css") \
85 _ (TEXT_JS, "text/javascript") \
86 _ (TEXT_JSON, "application/json")
88 typedef enum http_content_type_
90 #define _(s, str) HTTP_CONTENT_##s,
91 foreach_http_content_type
93 } http_content_type_t;
95 #define foreach_http_status_code \
96 _ (200, OK, "200 OK") \
97 _ (400, BAD_REQUEST, "400 Bad Request") \
98 _ (404, NOT_FOUND, "404 Not Found") \
99 _ (405, METHOD_NOT_ALLOWED, "405 Method Not Allowed") \
100 _ (500, INTERNAL_ERROR, "500 Internal Server Error")
102 typedef enum http_status_code_
104 #define _(c, s, str) HTTP_STATUS_##s,
105 foreach_http_status_code
108 } http_status_code_t;
110 typedef enum http_msg_data_type_
112 HTTP_MSG_DATA_INLINE,
114 } http_msg_data_type_t;
116 typedef struct http_msg_data_
118 http_msg_data_type_t type;
123 typedef struct http_msg_
125 http_msg_type_t type;
128 http_req_method_t method_type;
129 http_status_code_t code;
131 http_content_type_t content_type;
132 http_msg_data_t data;
135 typedef struct http_tc_
139 transport_connection_t connection;
140 http_conn_id_t c_http_conn_id;
142 #define h_tc_session_handle c_http_conn_id.tc_session_handle
143 #define h_pa_wrk_index c_http_conn_id.parent_app_wrk_index
144 #define h_pa_session_handle c_http_conn_id.app_session_handle
145 #define h_hc_index connection.c_index
147 http_conn_state_t state;
153 http_req_state_t req_state;
154 http_req_method_t method;
157 http_buffer_t tx_buf;
160 typedef struct http_worker_
162 http_conn_t *conn_pool;
165 typedef struct http_main_
168 http_conn_t *listener_ctx_pool;
171 clib_timebase_t timebase;
186 #endif /* SRC_PLUGINS_HTTP_HTTP_H_ */
189 * fd.io coding-style-patch-verification: ON
192 * eval: (c-set-style "gnu")