2 * http_static.c - skeleton vpp-api-test plug-in
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <vlibapi/api.h>
19 #include <vlibmemory/api.h>
20 #include <vppinfra/error.h>
22 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
24 /* Declare message IDs */
25 #include <http_static/http_static.api_enum.h>
26 #include <http_static/http_static.api_types.h>
30 /* API message ID base */
33 } http_static_test_main_t;
35 http_static_test_main_t http_static_test_main;
37 #define __plugin_msg_base http_static_test_main.msg_id_base
38 #include <vlibapi/vat_helper_macros.h>
41 api_http_static_enable (vat_main_t * vam)
43 unformat_input_t *line_input = vam->input;
44 vl_api_http_static_enable_t *mp;
48 u32 prealloc_fifos = 0;
49 u32 private_segment_size = 0;
50 u32 fifo_size = 8 << 10;
51 u32 cache_size_limit = 1 << 20;
54 /* Parse args required to build the message */
55 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
57 if (unformat (line_input, "www-root %s", &www_root))
59 else if (unformat (line_input, "prealloc-fifos %d", &prealloc_fifos))
61 else if (unformat (line_input, "private-segment-size %U",
62 unformat_memory_size, &tmp))
64 if (tmp >= 0x100000000ULL)
66 errmsg ("private segment size %llu, too large", tmp);
69 private_segment_size = (u32) tmp;
71 else if (unformat (line_input, "fifo-size %U", unformat_memory_size,
74 fifo_size = (u32) tmp;
76 else if (unformat (line_input, "cache-size %U", unformat_memory_size,
79 if (tmp < (128ULL << 10))
81 errmsg ("cache-size must be at least 128kb");
84 cache_size_limit = (u32) tmp;
87 else if (unformat (line_input, "uri %s", &uri))
91 errmsg ("unknown input `%U'", format_unformat_error, line_input);
98 errmsg ("Must specify www-root");
103 uri = format (0, "tcp://0.0.0.0/80%c", 0);
107 /* Construct the API message */
108 M (HTTP_STATIC_ENABLE, mp);
109 vl_api_to_api_string (strnlen ((const char *) www_root, 256),
110 (const char *) www_root,
111 (vl_api_string_t *) & mp->www_root);
112 vl_api_to_api_string (strnlen ((const char *) uri, 256), (const char *) uri,
113 (vl_api_string_t *) & mp->uri);
114 mp->fifo_size = ntohl (fifo_size);
115 mp->cache_size_limit = ntohl (cache_size_limit);
116 mp->prealloc_fifos = ntohl (prealloc_fifos);
117 mp->private_segment_size = ntohl (private_segment_size);
122 /* Wait for a reply... */
127 #include <http_static/http_static.api_test.c>
130 * fd.io coding-style-patch-verification: ON
133 * eval: (c-set-style "gnu")