typedef struct
{
u8 **rx_buf;
- svm_queue_t **vpp_queue;
+ svm_msg_q_t **vpp_queue;
u64 byte_index;
uword *handler_by_get_request;
u32 prealloc_fifos;
u32 private_segment_size;
u32 fifo_size;
+ u8 *uri;
vlib_main_t *vlib_main;
} http_server_main_t;
vec_add1 (hsm->free_http_cli_process_node_indices, node_index);
}
-static const char
- *http_response = "HTTP/1.1 200 OK\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: %d\r\n\r\n%s";
-
-static const char
- *http_error_template = "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";
+/* *INDENT-OFF* */
+static const char *http_response =
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Type: text/html\r\n"
+ "Expires: Mon, 11 Jan 1970 10:10:10 GMT\r\n"
+ "Connection: keep-alive \r\n"
+ "Pragma: no-cache\r\n"
+ "Content-Length: %d\r\n\r\n%s";
+
+static const char *http_error_template =
+ "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";
/* Header, including incantation to suppress favicon.ico requests */
-static const char
- *html_header_template = "<html><head><title>%v</title>"
- "</head><link rel=\"icon\" href=\"data:,\"><body><pre>";
-
-static const char *html_footer = "</pre></body></html>\r\n";
-
-static const char
- *html_header_static = "<html><head><title>static reply</title></head>"
- "<link rel=\"icon\" href=\"data:,\"><body><pre>hello</pre></body>"
- "</html>\r\n";
+static const char *html_header_template =
+ "<html><head><title>%v</title></head>"
+ "<link rel=\"icon\" href=\"data:,\">"
+ "<body><pre>";
+
+static const char *html_footer =
+ "</pre></body></html>\r\n";
+
+static const char *html_header_static =
+ "<html><head><title>static reply</title></head>"
+ "<link rel=\"icon\" href=\"data:,\">"
+ "<body><pre>hello</pre></body></html>\r\n";
+/* *INDENT-ON* */
static u8 *static_http;
offset = vec_len (output_vec);
vec_validate (output_vec, offset + buffer_bytes - 1);
- clib_memcpy (output_vec + offset, buffer, buffer_bytes);
+ clib_memcpy_fast (output_vec + offset, buffer, buffer_bytes);
*output_vecp = output_vec;
}
void
send_data (stream_session_t * s, u8 * data)
{
- session_fifo_event_t evt;
u32 offset, bytes_to_send;
f64 delay = 10e-3;
http_server_main_t *hsm = &http_server_main;
bytes_to_send -= actual_transfer;
if (svm_fifo_set_event (s->server_tx_fifo))
- {
- /* Fabricate TX event, send to vpp */
- evt.fifo = s->server_tx_fifo;
- evt.event_type = FIFO_EVENT_APP_TX;
-
- svm_queue_add (hsm->vpp_queue[s->thread_index],
- (u8 *) & evt, 0 /* do wait for mutex */ );
- }
+ session_send_io_evt_to_thread (s->server_tx_fifo,
+ FIFO_EVENT_APP_TX);
delay = 10e-3;
}
}
/* Send an RPC request via the thread-0 input node */
if (vlib_get_thread_index () != 0)
- {
- session_fifo_event_t evt;
- evt.rpc_args.fp = alloc_http_process_callback;
- evt.rpc_args.arg = args;
- evt.event_type = FIFO_EVENT_RPC;
- svm_queue_add
- (session_manager_get_vpp_event_queue (0 /* main thread */ ),
- (u8 *) & evt, 0 /* do wait for mutex */ );
- }
+ session_send_rpc_evt_to_thread (0, alloc_http_process_callback, args);
else
alloc_http_process (args);
return 0;
.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_server_rx_callback = http_server_rx_callback,
+ .builtin_app_rx_callback = http_server_rx_callback,
.session_reset_callback = http_server_session_reset_callback
};
static int
server_attach ()
{
+ vnet_app_add_tls_cert_args_t _a_cert, *a_cert = &_a_cert;
+ vnet_app_add_tls_key_args_t _a_key, *a_key = &_a_key;
http_server_main_t *hsm = &http_server_main;
u64 options[APP_OPTIONS_N_OPTIONS];
vnet_app_attach_args_t _a, *a = &_a;
u32 segment_size = 128 << 20;
- memset (a, 0, sizeof (*a));
- memset (options, 0, sizeof (options));
+ clib_memset (a, 0, sizeof (*a));
+ clib_memset (options, 0, sizeof (options));
if (hsm->private_segment_size)
segment_size = hsm->private_segment_size;
return -1;
}
hsm->app_index = a->app_index;
+
+ clib_memset (a_cert, 0, sizeof (*a_cert));
+ a_cert->app_index = a->app_index;
+ vec_validate (a_cert->cert, test_srv_crt_rsa_len);
+ clib_memcpy_fast (a_cert->cert, test_srv_crt_rsa, test_srv_crt_rsa_len);
+ vnet_app_add_tls_cert (a_cert);
+
+ clib_memset (a_key, 0, sizeof (*a_key));
+ a_key->app_index = a->app_index;
+ vec_validate (a_key->key, test_srv_key_rsa_len);
+ clib_memcpy_fast (a_key->key, test_srv_key_rsa, test_srv_key_rsa_len);
+ vnet_app_add_tls_key (a_key);
+
return 0;
}
{
http_server_main_t *hsm = &http_server_main;
vnet_bind_args_t _a, *a = &_a;
- memset (a, 0, sizeof (*a));
+ clib_memset (a, 0, sizeof (*a));
a->app_index = hsm->app_index;
a->uri = "tcp://0.0.0.0/80";
+ if (hsm->uri)
+ a->uri = (char *) hsm->uri;
return vnet_bind_uri (a);
}
}
else if (unformat (input, "fifo-size %d", &hsm->fifo_size))
hsm->fifo_size <<= 10;
+ else if (unformat (input, "uri %s", &hsm->uri))
+ ;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
if (is_static)
{
- http_server_session_cb_vft.builtin_server_rx_callback =
+ http_server_session_cb_vft.builtin_app_rx_callback =
http_server_rx_callback_static;
html = format (0, html_header_static);
static_http = format (0, http_response, vec_len (html), html);