FD.io VPP  v19.04.4-rc0-5-ge88582fac
Vector Packet Processing
http_server.c File Reference
+ Include dependency graph for http_server.c:

Go to the source code of this file.

Data Structures

struct  http_server_args
 
struct  http_session_t
 
struct  http_server_main_t
 

Enumerations

enum  http_process_event_t { EVENT_WAKEUP = 1 }
 
enum  http_session_state_t { HTTP_STATE_CLOSED, HTTP_STATE_ESTABLISHED, HTTP_STATE_OK_SENT }
 

Functions

static void http_server_sessions_reader_lock (void)
 
static void http_server_sessions_reader_unlock (void)
 
static void http_server_sessions_writer_lock (void)
 
static void http_server_sessions_writer_unlock (void)
 
static http_session_thttp_server_session_alloc (u32 thread_index)
 
static http_session_thttp_server_session_get (u32 thread_index, u32 hs_index)
 
static void http_server_session_free (http_session_t *hs)
 
static void http_server_session_lookup_add (u32 thread_index, u32 s_index, u32 hs_index)
 
static void http_server_session_lookup_del (u32 thread_index, u32 s_index)
 
static http_session_thttp_server_session_lookup (u32 thread_index, u32 s_index)
 
static void http_server_session_timer_start (http_session_t *hs)
 
static void http_server_session_timer_stop (http_session_t *hs)
 
static void http_server_session_cleanup (http_session_t *hs)
 
static void http_server_session_disconnect (http_session_t *hs)
 
static void http_process_free (http_server_args *args)
 
static void http_cli_output (uword arg, u8 *buffer, uword buffer_bytes)
 
void send_data (http_session_t *hs, u8 *data)
 
static void send_error (http_session_t *hs, char *str)
 
static uword http_cli_process (vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
 
static void alloc_http_process (http_server_args *args)
 
static void alloc_http_process_callback (void *cb_args)
 
static int session_rx_request (http_session_t *hs)
 
static int http_server_rx_callback (session_t *s)
 
static int http_server_rx_callback_static (session_t *s)
 
static int http_server_session_accept_callback (session_t *s)
 
static void http_server_session_disconnect_callback (session_t *s)
 
static void http_server_session_reset_callback (session_t *s)
 
static int http_server_session_connected_callback (u32 app_index, u32 api_context, session_t *s, u8 is_fail)
 
static int http_server_add_segment_callback (u32 client_index, u64 segment_handle)
 
static int http_server_attach ()
 
static int http_server_listen ()
 
static void http_server_session_cleanup_cb (void *hs_handlep)
 
static void http_expired_timers_dispatch (u32 *expired_timers)
 
static uword http_server_process (vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
 
static int http_server_create (vlib_main_t *vm)
 
static clib_error_thttp_server_create_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_thttp_server_main_init (vlib_main_t *vm)
 

Variables

http_server_main_t http_server_main
 
static const char * http_ok
 
static const char * http_response
 
static const char * http_error_template
 
static const char * html_header_template
 
static const char * html_footer
 
static const char * html_header_static
 
static u8static_http
 
static u8static_ok
 
static session_cb_vft_t http_server_session_cb_vft
 
vlib_node_registration_t http_server_process_node
 (constructor) VLIB_REGISTER_NODE (http_server_process_node) More...
 
static vlib_cli_command_t http_server_create_command
 (constructor) VLIB_CLI_COMMAND (http_server_create_command) More...
 

Enumeration Type Documentation

◆ http_process_event_t

Enumerator
EVENT_WAKEUP 

Definition at line 22 of file http_server.c.

◆ http_session_state_t

Enumerator
HTTP_STATE_CLOSED 
HTTP_STATE_ESTABLISHED 
HTTP_STATE_OK_SENT 

Definition at line 34 of file http_server.c.

Function Documentation

◆ alloc_http_process()

static void alloc_http_process ( http_server_args args)
static

Definition at line 450 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ alloc_http_process_callback()

static void alloc_http_process_callback ( void *  cb_args)
static

Definition at line 494 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_cli_output()

static void http_cli_output ( uword  arg,
u8 buffer,
uword  buffer_bytes 
)
static

Definition at line 281 of file http_server.c.

◆ http_cli_process()

static uword http_cli_process ( vlib_main_t vm,
vlib_node_runtime_t rt,
vlib_frame_t f 
)
static

Definition at line 360 of file http_server.c.

+ Here is the call graph for this function:

◆ http_expired_timers_dispatch()

static void http_expired_timers_dispatch ( u32 expired_timers)
static

Definition at line 795 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_process_free()

static void http_process_free ( http_server_args args)
static

Definition at line 216 of file http_server.c.

+ Here is the call graph for this function:

◆ http_server_add_segment_callback()

static int http_server_add_segment_callback ( u32  client_index,
u64  segment_handle 
)
static

Definition at line 700 of file http_server.c.

◆ http_server_attach()

static int http_server_attach ( )
static

Definition at line 716 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_create()

static int http_server_create ( vlib_main_t vm)
static

Definition at line 846 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_create_command_fn()

static clib_error_t* http_server_create_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 884 of file http_server.c.

+ Here is the call graph for this function:

◆ http_server_listen()

static int http_server_listen ( )
static

Definition at line 768 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_main_init()

static clib_error_t* http_server_main_init ( vlib_main_t vm)
static

Definition at line 967 of file http_server.c.

◆ http_server_process()

static uword http_server_process ( vlib_main_t vm,
vlib_node_runtime_t rt,
vlib_frame_t f 
)
static

Definition at line 811 of file http_server.c.

◆ http_server_rx_callback()

static int http_server_rx_callback ( session_t s)
static

Definition at line 522 of file http_server.c.

+ Here is the call graph for this function:

◆ http_server_rx_callback_static()

static int http_server_rx_callback_static ( session_t s)
static

Definition at line 554 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_session_accept_callback()

static int http_server_session_accept_callback ( session_t s)
static

Definition at line 621 of file http_server.c.

+ Here is the call graph for this function:

◆ http_server_session_alloc()

static http_session_t* http_server_session_alloc ( u32  thread_index)
static

Definition at line 114 of file http_server.c.

+ Here is the caller graph for this function:

◆ http_server_session_cleanup()

static void http_server_session_cleanup ( http_session_t hs)
static

Definition at line 196 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_session_cleanup_cb()

static void http_server_session_cleanup_cb ( void *  hs_handlep)
static

Definition at line 781 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_session_connected_callback()

static int http_server_session_connected_callback ( u32  app_index,
u32  api_context,
session_t s,
u8  is_fail 
)
static

Definition at line 692 of file http_server.c.

◆ http_server_session_disconnect()

static void http_server_session_disconnect ( http_session_t hs)
static

Definition at line 207 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_session_disconnect_callback()

static void http_server_session_disconnect_callback ( session_t s)
static

Definition at line 650 of file http_server.c.

+ Here is the call graph for this function:

◆ http_server_session_free()

static void http_server_session_free ( http_session_t hs)
static

Definition at line 136 of file http_server.c.

+ Here is the caller graph for this function:

◆ http_server_session_get()

static http_session_t* http_server_session_get ( u32  thread_index,
u32  hs_index 
)
static

Definition at line 127 of file http_server.c.

+ Here is the caller graph for this function:

◆ http_server_session_lookup()

static http_session_t* http_server_session_lookup ( u32  thread_index,
u32  s_index 
)
static

Definition at line 160 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_session_lookup_add()

static void http_server_session_lookup_add ( u32  thread_index,
u32  s_index,
u32  hs_index 
)
static

Definition at line 145 of file http_server.c.

+ Here is the caller graph for this function:

◆ http_server_session_lookup_del()

static void http_server_session_lookup_del ( u32  thread_index,
u32  s_index 
)
static

Definition at line 153 of file http_server.c.

+ Here is the caller graph for this function:

◆ http_server_session_reset_callback()

static void http_server_session_reset_callback ( session_t s)
static

Definition at line 671 of file http_server.c.

+ Here is the call graph for this function:

◆ http_server_session_timer_start()

static void http_server_session_timer_start ( http_session_t hs)
static

Definition at line 175 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_session_timer_stop()

static void http_server_session_timer_stop ( http_session_t hs)
static

Definition at line 186 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_sessions_reader_lock()

static void http_server_sessions_reader_lock ( void  )
static

Definition at line 90 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_sessions_reader_unlock()

static void http_server_sessions_reader_unlock ( void  )
static

Definition at line 96 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_sessions_writer_lock()

static void http_server_sessions_writer_lock ( void  )
static

Definition at line 102 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ http_server_sessions_writer_unlock()

static void http_server_sessions_writer_unlock ( void  )
static

Definition at line 108 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_data()

void send_data ( http_session_t hs,
u8 data 
)

Definition at line 297 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_error()

static void send_error ( http_session_t hs,
char *  str 
)
static

Definition at line 350 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ session_rx_request()

static int session_rx_request ( http_session_t hs)
static

Definition at line 500 of file http_server.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ html_footer

const char* html_footer
static
Initial value:
=
"</pre></body></html>\r\n"

Definition at line 268 of file http_server.c.

◆ html_header_static

const char* html_header_static
static
Initial value:
=
"<html><head><title>static reply</title></head>"
"<link rel=\"icon\" href=\"data:,\">"
"<body><pre>hello</pre></body></html>\r\n"

Definition at line 271 of file http_server.c.

◆ html_header_template

const char* html_header_template
static
Initial value:
=
"<html><head><title>%v</title></head>"
"<link rel=\"icon\" href=\"data:,\">"
"<body><pre>"

Definition at line 263 of file http_server.c.

◆ http_error_template

const char* http_error_template
static
Initial value:
=
"HTTP/1.1 %s\r\n"
"Content-Type: text/html\r\n"
"Expires: Mon, 11 Jan 1970 10:10:10 GMT\r\n"
"Connection: close\r\n"
"Pragma: no-cache\r\n"
"Content-Length: 0\r\n\r\n"

Definition at line 254 of file http_server.c.

◆ http_ok

const char* http_ok
static
Initial value:
=
"HTTP/1.1 200 OK\r\n"

Definition at line 244 of file http_server.c.

◆ http_response

const char* http_response
static
Initial value:
=
"Content-Type: text/html\r\n"
"Expires: Mon, 11 Jan 1970 10:10:10 GMT\r\n"
"Connection: close \r\n"
"Pragma: no-cache\r\n"
"Content-Length: %d\r\n\r\n%s"

Definition at line 247 of file http_server.c.

◆ http_server_create_command

vlib_cli_command_t http_server_create_command
static
Initial value:
=
{
.path = "test http server",
.short_help = "test http server",
}
static clib_error_t * http_server_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: http_server.c:884

(constructor) VLIB_CLI_COMMAND (http_server_create_command)

Definition at line 958 of file http_server.c.

◆ http_server_main

http_server_main_t http_server_main

Definition at line 87 of file http_server.c.

◆ http_server_process_node

vlib_node_registration_t http_server_process_node
Initial value:
=
{
.function = http_server_process,
.name = "http-server-process",
.state = VLIB_NODE_STATE_DISABLED,
}
static uword http_server_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: http_server.c:811

(constructor) VLIB_REGISTER_NODE (http_server_process_node)

Definition at line 836 of file http_server.c.

◆ http_server_session_cb_vft

session_cb_vft_t http_server_session_cb_vft
static
Initial value:
= {
.session_accept_callback = http_server_session_accept_callback,
.session_disconnect_callback = http_server_session_disconnect_callback,
.session_connected_callback = http_server_session_connected_callback,
.add_segment_callback = http_server_add_segment_callback,
.builtin_app_rx_callback = http_server_rx_callback,
.session_reset_callback = http_server_session_reset_callback
}
static int http_server_session_connected_callback(u32 app_index, u32 api_context, session_t *s, u8 is_fail)
Definition: http_server.c:692
static int http_server_session_accept_callback(session_t *s)
Definition: http_server.c:621
static int http_server_rx_callback(session_t *s)
Definition: http_server.c:522
static int http_server_add_segment_callback(u32 client_index, u64 segment_handle)
Definition: http_server.c:700
static void http_server_session_reset_callback(session_t *s)
Definition: http_server.c:671
static void http_server_session_disconnect_callback(session_t *s)
Definition: http_server.c:650

Definition at line 706 of file http_server.c.

◆ static_http

u8* static_http
static

Definition at line 277 of file http_server.c.

◆ static_ok

u8* static_ok
static

Definition at line 278 of file http_server.c.