93 "Content-Type: text/html\r\n" 94 "Expires: Mon, 11 Jan 1970 10:10:10 GMT\r\n" 95 "Connection: keep-alive \r\n" 96 "Pragma: no-cache\r\n" 97 "Content-Length: %d\r\n\r\n%s";
101 "Content-Type: text/html\r\n" 102 "Expires: Mon, 11 Jan 1970 10:10:10 GMT\r\n" 103 "Connection: close\r\n" 104 "Pragma: no-cache\r\n" 105 "Content-Length: 0\r\n\r\n";
109 "<html><head><title>%v</title></head>" 110 "<link rel=\"icon\" href=\"data:,\">" 114 "</pre></body></html>\r\n";
117 "<html><head><title>static reply</title></head>" 118 "<link rel=\"icon\" href=\"data:,\">" 119 "<body><pre>hello</pre></body></html>\r\n";
127 u8 **output_vecp = (
u8 **) arg;
131 output_vec = *output_vecp;
135 clib_memcpy (output_vec + offset, buffer, buffer_bytes);
137 *output_vecp = output_vec;
149 bytes_to_send =
vec_len (data);
152 while (bytes_to_send > 0)
157 (s->server_tx_fifo, bytes_to_send, data + offset);
160 if (actual_transfer <= 0)
176 offset += actual_transfer;
177 bytes_to_send -= actual_transfer;
208 u8 *http = 0, *html = 0;
215 request = (
u8 *) (
void *) (args->
data);
222 for (i = 0; i <
vec_len (request) - 4; i++)
224 if (request[i] ==
'G' &&
225 request[i + 1] ==
'E' &&
226 request[i + 2] ==
'T' && request[i + 3] ==
' ')
241 if (request[i] ==
'/')
243 else if (request[i] ==
' ')
246 _vec_len (request) =
i;
265 html =
format (html,
"%v", reply);
305 .process_log2_n_stack_bytes = 16,
306 .runtime_data_bytes =
sizeof (
void *),
309 name = (
char *)
format (0,
"http-cli-%d", l);
341 rx_fifo = s->server_rx_fifo;
348 _vec_len (hsm->
rx_buf[s->thread_index]) = max_dequeue;
351 hsm->
rx_buf[s->thread_index]);
352 ASSERT (actual_transfer > 0);
353 _vec_len (hsm->
rx_buf[s->thread_index]) = actual_transfer;
393 request = hsm->
rx_buf[s->thread_index];
400 for (i = 0; i <
vec_len (request) - 4; i++)
402 if (request[i] ==
'G' &&
403 request[i + 1] ==
'E' &&
404 request[i + 2] ==
'T' && request[i + 3] ==
' ')
499 u32 segment_size = 128 << 20;
501 memset (a, 0,
sizeof (*a));
502 memset (options, 0,
sizeof (options));
509 a->options = options;
525 memset (a_cert, 0,
sizeof (*a_cert));
526 a_cert->app_index = a->app_index;
531 memset (a_key, 0,
sizeof (*a_key));
532 a_key->app_index = a->app_index;
545 memset (a, 0,
sizeof (*a));
547 a->uri =
"tcp://0.0.0.0/80";
549 a->uri = (
char *) hsm->
uri;
586 int rv, is_static = 0;
599 else if (
unformat (input,
"private-segment-size %U",
602 if (seg_size >= 0x100000000ULL)
644 .path =
"test http server",
645 .short_help =
"test http server",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void http_server_session_disconnect_callback(stream_session_t *s)
vlib_main_t vlib_global_main
static int http_server_create(vlib_main_t *vm)
u32 vl_api_memclnt_create_internal(char *name, svm_queue_t *q)
const u32 test_srv_crt_rsa_len
static const char * html_header_template
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
svm_queue_t * vl_input_queue
static const char * http_response
int vnet_bind_uri(vnet_bind_args_t *a)
const u32 test_srv_key_rsa_len
static f64 vlib_time_now(vlib_main_t *vm)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
void session_send_rpc_evt_to_thread(u32 thread_index, void *fp, void *rpc_args)
static int http_server_session_accept_callback(stream_session_t *s)
struct _vnet_application_add_tls_cert_args_t vnet_app_add_tls_cert_args_t
static stream_session_t * session_get_from_handle(session_handle_t handle)
clib_error_t * vnet_app_add_tls_cert(vnet_app_add_tls_cert_args_t *a)
static void alloc_http_process_callback(void *cb_args)
struct _svm_fifo svm_fifo_t
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
static void send_error(stream_session_t *s, char *str)
memset(h->entries, 0, sizeof(h->entries[0])*entries)
static svm_msg_q_t * session_manager_get_vpp_event_queue(u32 thread_index)
static int http_server_rx_callback_static(stream_session_t *s)
#define VLIB_INIT_FUNCTION(x)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
struct _stream_session_cb_vft session_cb_vft_t
static int http_server_listen()
#define clib_error_return(e, args...)
int svm_fifo_enqueue_nowait(svm_fifo_t *f, u32 max_bytes, const u8 *copy_from_here)
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
void stream_session_cleanup(stream_session_t *s)
Cleanup transport and session state.
struct _stream_session_t stream_session_t
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
vl_shmem_hdr_t * shmem_hdr
static session_cb_vft_t http_server_session_cb_vft
clib_error_t * vnet_app_add_tls_key(vnet_app_add_tls_key_args_t *a)
static void http_server_session_reset_callback(stream_session_t *s)
static const char * html_header_static
static session_handle_t session_handle(stream_session_t *s)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
static void svm_fifo_unset_event(svm_fifo_t *f)
Unsets fifo event flag.
static void free_http_process(http_server_args *args)
static const char * html_footer
u32 node_index
Node index.
const char test_srv_crt_rsa[]
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
API main structure, used by both vpp and binary API clients.
static u8 svm_fifo_set_event(svm_fifo_t *f)
Sets fifo event flag.
static int http_server_add_segment_callback(u32 client_index, const ssvm_private_t *sp)
static_always_inline uword vlib_get_thread_index(void)
static int http_server_session_connected_callback(u32 app_index, u32 api_context, stream_session_t *s, u8 is_fail)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
#define clib_memcpy(a, b, c)
int vnet_disconnect_session(vnet_disconnect_args_t *a)
svm_queue_t * vl_input_queue
void send_data(stream_session_t *s, u8 *data)
#define VLIB_CLI_COMMAND(x,...)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
u32 vlib_register_node(vlib_main_t *vm, vlib_node_registration_t *r)
static void clib_mem_free(void *p)
struct _vnet_application_add_tls_key_args_t vnet_app_add_tls_key_args_t
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
static void * clib_mem_alloc(uword size)
uword * handler_by_get_request
struct _vlib_node_registration vlib_node_registration_t
static clib_error_t * http_server_main_init(vlib_main_t *vm)
http_server_main_t http_server_main
static void alloc_http_process(http_server_args *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static int server_attach()
clib_error_t * vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
static int create_api_loopback(vlib_main_t *vm)
static clib_error_t * http_server_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
struct _svm_queue svm_queue_t
static const char * http_error_template
static int http_server_rx_callback(stream_session_t *s)
struct clib_bihash_value offset
template key/value backing page structure
static vlib_thread_main_t * vlib_get_thread_main()
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
void vlib_start_process(vlib_main_t *vm, uword process_index)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
int svm_fifo_dequeue_nowait(svm_fifo_t *f, u32 max_bytes, u8 *copy_here)
struct _vnet_bind_args_t vnet_bind_args_t
static void http_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
const char test_srv_key_rsa[]
u32 * free_http_cli_process_node_indices
static uword http_cli_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
static int session_rx_request(stream_session_t *s)