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>
30 #define HTTP_DBG(_lvl, _fmt, _args...) \
31 if (_lvl <= HTTP_DEBUG) \
32 clib_warning (_fmt, ##_args)
34 #define HTTP_DBG(_lvl, _fmt, _args...)
37 typedef struct http_conn_id_
41 session_handle_t app_session_handle;
42 u32 parent_app_api_ctx;
44 session_handle_t tc_session_handle;
45 u32 parent_app_wrk_index;
48 STATIC_ASSERT (sizeof (http_conn_id_t) <= TRANSPORT_CONN_ID_LEN,
49 "ctx id must be less than TRANSPORT_CONN_ID_LEN");
51 typedef enum http_state_
53 HTTP_CONN_STATE_LISTEN,
54 HTTP_CONN_STATE_CONNECTING,
55 HTTP_CONN_STATE_ESTABLISHED,
56 HTTP_CONN_STATE_TRANSPORT_CLOSED,
57 HTTP_CONN_STATE_APP_CLOSED,
58 HTTP_CONN_STATE_CLOSED
61 typedef enum http_req_state_
63 HTTP_REQ_STATE_WAIT_METHOD,
64 HTTP_REQ_STATE_WAIT_APP,
65 HTTP_REQ_STATE_SEND_MORE_DATA,
69 typedef enum http_req_method_
75 typedef enum http_msg_type_
81 #define foreach_http_content_type \
82 _ (TEXT_HTML, "text/html") \
83 _ (TEXT_CSS, "text/css") \
84 _ (TEXT_JS, "text/javascript") \
85 _ (TEXT_JSON, "application/json")
87 typedef enum http_content_type_
89 #define _(s, str) HTTP_CONTENT_##s,
90 foreach_http_content_type
92 } http_content_type_t;
94 #define foreach_http_status_code \
95 _ (200, OK, "200 OK") \
96 _ (400, BAD_REQUEST, "400 Bad Request") \
97 _ (405, METHOD_NOT_ALLOWED, "405 Method Not Allowed") \
98 _ (500, INTERNAL_ERROR, "500 Internal Server Error")
100 typedef enum http_status_code_
102 #define _(c, s, str) HTTP_STATUS_##s,
103 foreach_http_status_code
106 } http_status_code_t;
108 typedef struct http_msg_data_
110 http_content_type_t content_type;
116 typedef struct http_msg_
118 http_msg_type_t type;
121 http_req_method_t method_type;
122 http_status_code_t code;
124 http_msg_data_t data;
127 typedef struct http_buffer_
130 svm_fifo_seg_t *segs;
136 typedef struct http_tc_
140 transport_connection_t connection;
141 http_conn_id_t c_http_conn_id;
143 #define h_tc_session_handle c_http_conn_id.tc_session_handle
144 #define h_pa_wrk_index c_http_conn_id.parent_app_wrk_index
145 #define h_pa_session_handle c_http_conn_id.app_session_handle
146 #define h_hc_index connection.c_index
148 http_conn_state_t state;
154 http_req_state_t req_state;
155 http_req_method_t method;
158 http_buffer_t tx_buf;
161 typedef struct http_worker_
163 http_conn_t *conn_pool;
166 typedef struct http_main_
169 http_conn_t *listener_ctx_pool;
172 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")