aboutsummaryrefslogtreecommitdiff
path: root/helper/include
diff options
context:
space:
mode:
authorJere Leppänen <jere.leppanen@nokia.com>2021-01-15 16:26:33 +0200
committerPetri Savolainen <petri.savolainen@nokia.com>2021-02-23 11:01:07 +0200
commit84b6587531ea50a9de473587af52cdf39f7e9dd9 (patch)
treed3bc629718d344f786aafe42a39f8a4a6c41c720 /helper/include
parentee9a6a9a9e46aac337b8b105ef5d2c7e754ce3c0 (diff)
helper: add CLI helper API and implementation
CLI helper API allows starting and stopping ODP CLI server, which may be connected to using a telnet client. CLI commands may be used to get information from an ODP instance, for debugging purposes. This implementation depends on libcli. If libcli is not available, CLI helper is automatically excluded. Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com> Reviewed-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'helper/include')
-rw-r--r--helper/include/odp/helper/autoheader_external.h.in3
-rw-r--r--helper/include/odp/helper/cli.h92
-rw-r--r--helper/include/odp/helper/odph_api.h6
3 files changed, 101 insertions, 0 deletions
diff --git a/helper/include/odp/helper/autoheader_external.h.in b/helper/include/odp/helper/autoheader_external.h.in
index 987b1027e..6f5187a5b 100644
--- a/helper/include/odp/helper/autoheader_external.h.in
+++ b/helper/include/odp/helper/autoheader_external.h.in
@@ -2,6 +2,9 @@
#ifndef ODPH_AUTOHEADER_EXTERNAL_H_
#define ODPH_AUTOHEADER_EXTERNAL_H_
+/* Define to 1 to enable CLI helper */
+#undef ODPH_CLI
+
/* Define to 1 to include additional helper debug code */
#undef ODPH_DEBUG
diff --git a/helper/include/odp/helper/cli.h b/helper/include/odp/helper/cli.h
new file mode 100644
index 000000000..41e438857
--- /dev/null
+++ b/helper/include/odp/helper/cli.h
@@ -0,0 +1,92 @@
+/* Copyright (c) 2021, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP CLI helper API
+ *
+ * This API allows control of ODP CLI server, which may be connected to
+ * using a telnet client. CLI commands may be used to get information
+ * from an ODP instance, for debugging purposes.
+ *
+ * Many CLI commands output the information to the console, or wherever
+ * ODP logs have been directed to in global init.
+ */
+
+#ifndef ODPH_CLI_H_
+#define ODPH_CLI_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp_api.h>
+#include <odp/helper/ip.h>
+#include <stdint.h>
+
+/**
+ * @addtogroup odph_cli ODPH CLI
+ * @{
+ */
+
+/** ODP CLI server parameters */
+typedef struct {
+ /**
+ * A character string containing an IP address. Default is
+ * "127.0.0.1".
+ */
+ const char *address;
+ /** TCP port. Default is 55555. */
+ uint16_t port;
+} odph_cli_param_t;
+
+/**
+ * Initialize CLI server params
+ *
+ * Initialize an odph_cli_param_t to its default values for all
+ * fields.
+ *
+ * @param[out] param Pointer to parameter structure
+ */
+void odph_cli_param_init(odph_cli_param_t *param);
+
+/**
+ * Start CLI server
+ *
+ * Upon successful return from this function, the CLI server will be
+ * accepting client connections. This function spawns a new thread of
+ * type ODP_THREAD_CONTROL using odp_cpumask_default_control().
+ *
+ * @param instance ODP instance
+ * @param param CLI server parameters to use
+ * @retval 0 Success
+ * @retval <0 Failure
+ */
+int odph_cli_start(const odp_instance_t instance,
+ const odph_cli_param_t *param);
+
+/**
+ * Stop CLI server
+ *
+ * Stop accepting new client connections and disconnect currently
+ * connected client. This function terminates the control thread
+ * created in odph_cli_start().
+ *
+ * @retval 0 Success
+ * @retval <0 Failure
+ */
+int odph_cli_stop(void);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/helper/include/odp/helper/odph_api.h b/helper/include/odp/helper/odph_api.h
index f3bcde208..7ab875c6e 100644
--- a/helper/include/odp/helper/odph_api.h
+++ b/helper/include/odp/helper/odph_api.h
@@ -38,6 +38,12 @@ extern "C" {
#include <odp/helper/udp.h>
#include <odp/helper/version.h>
+#include <odp/helper/autoheader_external.h>
+
+#ifdef ODPH_CLI
+#include <odp/helper/cli.h>
+#endif
+
#ifdef __cplusplus
}
#endif