aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/http_static/http_static.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2022-01-26 16:28:58 -0800
committerDamjan Marion <dmarion@me.com>2022-01-27 20:01:18 +0000
commitae0e3e748f04a1fb9ad2393533a164611c417103 (patch)
treed3fcf457d7acc875871baeca63cb6d919427738a /src/plugins/http_static/http_static.h
parentaedcfaf80c8a7dd55dc2a7d85a0e9bd0d3d97569 (diff)
http_static: code cleanup
Type: refactor Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ic8838c8ef558d671740094a98b5a627a18c8c808
Diffstat (limited to 'src/plugins/http_static/http_static.h')
-rw-r--r--src/plugins/http_static/http_static.h84
1 files changed, 17 insertions, 67 deletions
diff --git a/src/plugins/http_static/http_static.h b/src/plugins/http_static/http_static.h
index bc0d937d21a..a1eaa6e1144 100644
--- a/src/plugins/http_static/http_static.h
+++ b/src/plugins/http_static/http_static.h
@@ -1,8 +1,5 @@
-
/*
- * http_static.h - skeleton vpp engine plug-in header file
- *
- * Copyright (c) <current-year> <your-organization>
+ * Copyright (c) 2017-2022 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -18,76 +15,29 @@
#ifndef __included_http_static_h__
#define __included_http_static_h__
-#include <vnet/vnet.h>
-#include <vnet/session/application.h>
#include <vnet/session/application_interface.h>
#include <vnet/session/session.h>
-#include <vnet/ip/ip.h>
-#include <vnet/ethernet/ethernet.h>
+#include <http/http.h>
#include <vppinfra/hash.h>
#include <vppinfra/error.h>
-#include <vppinfra/time_range.h>
-#include <vppinfra/tw_timer_2t_1w_2048sl.h>
#include <vppinfra/bihash_vec8_8.h>
/** @file http_static.h
* Static http server definitions
*/
-typedef struct
-{
- /* API message ID base */
- u16 msg_id_base;
-
- /* convenience */
- vlib_main_t *vlib_main;
- vnet_main_t *vnet_main;
-} http_static_main_t;
-
-extern http_static_main_t http_static_main;
-
-/** \brief Session States
- */
-
-typedef enum
-{
- /** Session is closed */
- HTTP_STATE_CLOSED,
- /** Session is established */
- HTTP_STATE_ESTABLISHED,
- /** Session has sent an OK response */
- HTTP_STATE_OK_SENT,
- /** Session has sent an HTML response */
- HTTP_STATE_SEND_MORE_DATA,
- /** Number of states */
- HTTP_STATE_N_STATES,
-} http_session_state_t;
-
-typedef enum
-{
- HTTP_BUILTIN_METHOD_GET = 0,
- HTTP_BUILTIN_METHOD_POST,
-} http_builtin_method_type_t;
-
/** \brief Application session
*/
typedef struct
{
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
- /** Base class instance variables */
-#define _(type, name) type name;
- foreach_app_session_field
-#undef _
+ u32 session_index;
/** rx thread index */
u32 thread_index;
- /** rx buffer */
- u8 *rx_buf;
/** vpp session index, handle */
u32 vpp_session_index;
- u64 vpp_session_handle;
- /** Timeout timer handle */
- u32 timer_handle;
+ session_handle_t vpp_session_handle;
/** Fully-resolved file path */
u8 *path;
/** File data, a vector */
@@ -96,10 +46,9 @@ typedef struct
u32 data_offset;
/** Need to free data in detach_cache_entry */
int free_data;
-
/** File cache pool index */
u32 cache_pool_index;
-} http_session_t;
+} hss_session_t;
/** \brief In-memory file data cache entry
*/
@@ -116,7 +65,7 @@ typedef struct
u32 prev_index;
/** Reference count, so we don't recycle while referenced */
int inuse;
-} file_data_cache_t;
+} hss_cache_entry_t;
/** \brief Main data structure
*/
@@ -124,15 +73,12 @@ typedef struct
typedef struct
{
/** Per thread vector of session pools */
- http_session_t **sessions;
+ hss_session_t **sessions;
/** Session pool reader writer lock */
clib_spinlock_t cache_lock;
- /** Enable debug messages */
- int debug_level;
-
/** Unified file data cache pool */
- file_data_cache_t *cache_pool;
+ hss_cache_entry_t *cache_pool;
/** Hash table which maps file name to file data */
BVT (clib_bihash) name_to_data;
@@ -160,16 +106,21 @@ typedef struct
/** Cert and key pair for tls */
u32 ckpair_index;
+ /* API message ID base */
+ u16 msg_id_base;
+
vlib_main_t *vlib_main;
/*
* Config
*/
+ /** Enable debug messages */
+ int debug_level;
/** Number of preallocated fifos, usually 0 */
u32 prealloc_fifos;
/** Private segment size, usually 0 */
- u32 private_segment_size;
+ u64 private_segment_size;
/** Size of the allocated rx, tx fifos, roughly 8K or so */
u32 fifo_size;
/** The bind URI, defaults to tcp://0.0.0.0/80 */
@@ -180,11 +131,10 @@ typedef struct
extern hss_main_t hss_main;
-int hss_enable_api (u32 fifo_size, u32 cache_limit, u32 prealloc_fifos,
- u32 private_segment_size, u8 *www_root, u8 *uri);
+int hss_create (vlib_main_t *vm);
-void http_static_server_register_builtin_handler
- (void *fp, char *url, int type);
+void http_static_server_register_builtin_handler (void *fp, char *url,
+ http_req_method_t type);
#endif /* __included_http_static_h__ */