#include <http/http.h>
#include <hs_apps/http_cli.h>
+#define HCC_DEBUG 0
+
+#if HCC_DEBUG
+#define HCC_DBG(_fmt, _args...) clib_warning (_fmt, ##_args)
+#else
+#define HCC_DBG(_fmt, _args...)
+#endif
+
typedef struct
{
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
vlib_main_t *vlib_main;
u32 cli_node_index;
u8 *http_response;
+ u8 *appns_id;
+ u64 appns_secret;
} hcc_main_t;
typedef enum
http_msg_t msg;
int rv;
+ HCC_DBG ("hc_index: %d", hc_index);
+
if (err)
{
clib_warning ("connected error: hc_index(%d): %U", hc_index,
return 0;
}
- if (!hs->to_recv)
+ if (hs->to_recv == 0)
{
rv = svm_fifo_dequeue (ts->rx_fifo, sizeof (msg), (u8 *) &msg);
ASSERT (rv == sizeof (msg));
rv = svm_fifo_dequeue (ts->rx_fifo, n_deq, hcm->http_response + curr);
if (rv < 0)
{
- clib_warning ("app dequeue failed");
+ clib_warning ("app dequeue(n=%d) failed; rv = %d", n_deq, rv);
return -1;
}
vec_set_len (hcm->http_response, curr + n_deq);
ASSERT (hs->to_recv >= rv);
hs->to_recv -= rv;
+ HCC_DBG ("app rcvd %d, remains %d", rv, hs->to_recv);
if (hs->to_recv == 0)
{
hcm->fifo_size ? hcm->fifo_size : 32 << 10;
a->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
a->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = hcm->prealloc_fifos;
+ if (hcm->appns_id)
+ {
+ a->namespace_id = hcm->appns_id;
+ a->options[APP_OPTIONS_NAMESPACE_SECRET] = hcm->appns_secret;
+ }
if ((rv = vnet_application_attach (a)))
return clib_error_return (0, "attach returned %d", rv);
unformat_input_t _line_input, *line_input = &_line_input;
hcc_main_t *hcm = &hcc_main;
u64 seg_size;
+ u8 *appns_id = 0;
clib_error_t *err = 0;
int rv;
hcm->fifo_size <<= 10;
else if (unformat (line_input, "uri %s", &hcm->uri))
;
+ else if (unformat (line_input, "appns %_%v%_", &appns_id))
+ ;
+ else if (unformat (line_input, "secret %lu", &hcm->appns_secret))
+ ;
else if (unformat (line_input, "query %s", &hcm->http_query))
;
else
}
}
+ vec_free (hcm->appns_id);
+ hcm->appns_id = appns_id;
hcm->cli_node_index = vlib_get_current_process (vm)->node_runtime.node_index;
if (!hcm->uri)
VLIB_CLI_COMMAND (hcc_command, static) = {
.path = "http cli client",
- .short_help = "uri http://<ip-addr> query <query-string>",
+ .short_help = "[appns <app-ns> secret <appns-secret>] uri http://<ip-addr> "
+ "query <query-string>",
.function = hcc_command_fn,
.is_mp_safe = 1,
};