87 "Content-Type: text/html\r\n" 88 "Expires: Mon, 11 Jan 1970 10:10:10 GMT\r\n" 89 "Connection: close\r\n" 90 "Pragma: no-cache\r\n" "Content-Length: %d\r\n\r\n%s";
94 "Content-Type: text/html\r\n" 95 "Expires: Mon, 11 Jan 1970 10:10:10 GMT\r\n" 96 "Connection: close\r\n" "Pragma: no-cache\r\n" "Content-Length: 0\r\n\r\n";
101 "</head><link rel=\"icon\" href=\"data:,\"><body><pre>";
108 u8 **output_vecp = (
u8 **) arg;
112 output_vec = *output_vecp;
116 clib_memcpy (output_vec + offset, buffer, buffer_bytes);
118 *output_vecp = output_vec;
124 session_fifo_event_t evt;
134 bytes_to_send =
vec_len (data);
137 while (bytes_to_send > 0)
142 (s->server_tx_fifo, bytes_to_send, data + offset);
145 if (actual_transfer <= 0)
161 offset += actual_transfer;
162 bytes_to_send -= actual_transfer;
167 evt.fifo = s->server_tx_fifo;
200 u8 *http = 0, *html = 0;
205 request = (
u8 *) (
void *) (args->
data);
212 for (i = 0; i <
vec_len (request) - 4; i++)
214 if (request[i] ==
'G' &&
215 request[i + 1] ==
'E' &&
216 request[i + 2] ==
'T' && request[i + 3] ==
' ')
231 if (request[i] ==
'/')
233 else if (request[i] ==
' ')
236 _vec_len (request) =
i;
255 html =
format (html,
"%v", reply);
295 .process_log2_n_stack_bytes = 16,
296 .runtime_data_bytes =
sizeof (
void *),
299 name = (
char *)
format (0,
"http-cli-%d", l);
332 rx_fifo = s->server_rx_fifo;
339 _vec_len (hsm->
rx_buf) = max_dequeue;
343 ASSERT (actual_transfer > 0);
344 _vec_len (hsm->
rx_buf) = actual_transfer;
354 session_fifo_event_t evt;
356 evt.rpc_args.arg = args;
408 const u8 * seg_name,
u32 seg_size)
450 u8 segment_name[128];
454 memset (a, 0,
sizeof (*a));
455 memset (options, 0,
sizeof (options));
459 a->options = options;
465 a->segment_name = segment_name;
466 a->segment_name_length =
ARRAY_LEN (segment_name);
482 memset (a, 0,
sizeof (*a));
484 a->uri =
"tcp://0.0.0.0/80";
540 .path =
"test http server",
541 .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_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
vlib_main_t vlib_global_main
sll srl srl sll sra u16x4 i
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
int vnet_bind_uri(vnet_bind_args_t *a)
unix_shared_memory_queue_t * vl_input_queue
static const char * http_error_template
static void alloc_http_process_callback(void *cb_args)
static f64 vlib_time_now(vlib_main_t *vm)
static int http_server_rx_callback(stream_session_t *s)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
struct _vlib_node_registration vlib_node_registration_t
static void free_http_process(builtin_http_server_args *args)
static int builtin_add_segment_callback(u32 client_index, const u8 *seg_name, u32 seg_size)
static const char * http_response
static int server_attach()
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.
unix_shared_memory_queue_t ** vpp_queue
static clib_error_t * server_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void alloc_http_process(builtin_http_server_args *args)
#define VLIB_INIT_FUNCTION(x)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
static int builtin_session_connected_callback(u32 app_index, u32 api_context, stream_session_t *s, u8 is_fail)
struct _stream_session_cb_vft session_cb_vft_t
#define clib_error_return(e, args...)
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
static int server_listen()
void stream_session_cleanup(stream_session_t *s)
Cleanup transport and session state.
struct _stream_session_t stream_session_t
static const char * html_header_template
struct _vnet_app_attach_args_t vnet_app_attach_args_t
http_server_main_t http_server_main
vl_shmem_hdr_t * shmem_hdr
int unix_shared_memory_queue_add(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
#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.
u32 node_index
Node index.
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 unix_shared_memory_queue_t * session_manager_get_vpp_event_queue(u32 thread_index)
static_always_inline uword vlib_get_thread_index(void)
#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)
u32 vl_api_memclnt_create_internal(char *, unix_shared_memory_queue_t *)
int vnet_disconnect_session(vnet_disconnect_args_t *a)
int svm_fifo_enqueue_nowait(svm_fifo_t *f, u32 max_bytes, u8 *copy_from_here)
static int builtin_session_accept_callback(stream_session_t *s)
static int builtin_redirect_connect_callback(u32 client_index, void *mp)
unix_shared_memory_queue_t * vl_input_queue
#define VLIB_CLI_COMMAND(x,...)
int vnet_application_attach(vnet_app_attach_args_t *a)
Attaches application.
#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)
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
static u64 stream_session_handle(stream_session_t *s)
static clib_error_t * builtin_http_server_main_init(vlib_main_t *vm)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void send_data(builtin_http_server_args *args, u8 *data)
static int create_api_loopback(vlib_main_t *vm)
static int server_create(vlib_main_t *vm)
static uword http_cli_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
struct clib_bihash_value offset
template key/value backing page structure
static const char * html_footer
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)
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 builtin_session_disconnect_callback(stream_session_t *s)
static stream_session_t * stream_session_get_from_handle(u64 handle)
static session_cb_vft_t builtin_session_cb_vft
static void builtin_session_reset_callback(stream_session_t *s)
u32 * free_http_cli_process_node_indices
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static void send_error(builtin_http_server_args *args, char *str)