FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
http_static.c
Go to the documentation of this file.
1 /*
2  * http_static.c - skeleton vpp engine plug-in
3  *
4  * Copyright (c) <current-year> <your-organization>
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <vnet/vnet.h>
19 #include <vnet/plugin/plugin.h>
21 
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vpp/app/version.h>
25 
26 /* define message IDs */
27 #include <http_static/http_static.api_enum.h>
28 #include <http_static/http_static.api_types.h>
29 
30 #include <vpp/api/types.h>
31 
32 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
33 
34 #define REPLY_MSG_ID_BASE hmp->msg_id_base
36 
38 
39 /* API message handler */
42 {
43  vl_api_http_static_enable_reply_t *rmp;
45  int rv;
46 
47  mp->uri[ARRAY_LEN (mp->uri) - 1] = 0;
48  mp->www_root[ARRAY_LEN (mp->www_root) - 1] = 0;
49 
51  (ntohl (mp->fifo_size),
52  ntohl (mp->cache_size_limit),
53  ntohl (mp->prealloc_fifos),
54  ntohl (mp->private_segment_size), mp->www_root, mp->uri);
55 
56  REPLY_MACRO (VL_API_HTTP_STATIC_ENABLE_REPLY);
57 }
58 
59 #include <http_static/http_static.api.c>
60 static clib_error_t *
62 {
64 
65  hmp->vlib_main = vm;
66  hmp->vnet_main = vnet_get_main ();
67 
68  /* Ask for a correctly-sized block of API message decode slots */
70 
71  return 0;
72 }
73 
75 
76 /* *INDENT-OFF* */
78 {
79  .version = VPP_BUILD_VER,
80  .description = "HTTP Static Server"
81 };
82 /* *INDENT-ON* */
83 
84 /*
85  * fd.io coding-style-patch-verification: ON
86  *
87  * Local Variables:
88  * eval: (c-set-style "gnu")
89  * End:
90  */
http_static_main_t::vnet_main
vnet_main_t * vnet_main
Definition: http_static.h:45
api.h
http_static_main_t::vlib_main
vlib_main_t * vlib_main
Definition: http_static.h:44
vl_api_http_static_enable_t::private_segment_size
u32 private_segment_size
Definition: http_static.api:29
http_static_main_t
Definition: http_static.h:38
http_static.h
vl_api_http_static_enable_t::www_root
string www_root[256]
Definition: http_static.api:32
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vl_api_http_static_enable_t_handler
static void vl_api_http_static_enable_t_handler(vl_api_http_static_enable_t *mp)
Definition: http_static.c:41
api.h
vl_api_http_static_enable_t
Configure and enable the static http server.
Definition: http_static.api:18
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: bfd_api.c:451
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vl_api_http_static_enable_t::uri
string uri[256]
Definition: http_static.api:34
VLIB_PLUGIN_REGISTER
VLIB_PLUGIN_REGISTER()
http_static_init
static clib_error_t * http_static_init(vlib_main_t *vm)
Definition: http_static.c:61
plugin.h
http_static_main_t::msg_id_base
u16 msg_id_base
Definition: http_static.h:41
vl_api_http_static_enable_t::cache_size_limit
u32 cache_size_limit
Definition: http_static.api:26
types.h
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
api_helper_macros.h
vl_api_http_static_enable_t::fifo_size
u32 fifo_size
Definition: http_static.api:25
vl_api_http_static_enable_t::prealloc_fifos
u32 prealloc_fifos
Definition: http_static.api:28
http_static_main
http_static_main_t http_static_main
Definition: http_static.c:37
vlib_main_t
Definition: main.h:102
clib_error_t
Definition: clib_error.h:21
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
rv
int __clib_unused rv
Definition: application.c:491
http_static_server_enable_api
int http_static_server_enable_api(u32 fifo_size, u32 cache_limit, u32 prealloc_fifos, u32 private_segment_size, u8 *www_root, u8 *uri)
API helper function for vl_api_http_static_enable_t messages.
Definition: static_server.c:1348
vnet.h