[PATCH 3/5] libctrl: Add a new function to send commands through an osmo_wqueue

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Daniel Willmann daniel at totalueberwachung.de
Thu Sep 15 14:04:51 UTC 2011


This is essentially the old ctrl_cmd_send function with a different
name. As long as the connection between nat and osmo-bsc is not using
the generic socket infrastructure from libosmo-abis it is still needed.
---
 openbsc/include/openbsc/control_cmd.h |    1 +
 openbsc/src/libctrl/control_if.c      |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/openbsc/include/openbsc/control_cmd.h b/openbsc/include/openbsc/control_cmd.h
index 87db33f..8eeed99 100644
--- a/openbsc/include/openbsc/control_cmd.h
+++ b/openbsc/include/openbsc/control_cmd.h
@@ -61,6 +61,7 @@ struct ctrl_cmd_map {
 int ctrl_cmd_exec(vector vline, struct ctrl_cmd *command, vector node, void *data);
 int ctrl_cmd_install(enum ctrl_node_type node, struct ctrl_cmd_element *cmd);
 int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data);
+int ctrl_cmd_send_wqueue(struct osmo_wqueue *queue, struct ctrl_cmd *cmd);
 int ctrl_cmd_send(struct ipa_server_conn *ipa_server_conn, struct ctrl_cmd *cmd);
 struct ctrl_cmd *ctrl_cmd_parse(void *ctx, struct msgb *msg);
 struct msgb *ctrl_cmd_make(struct ctrl_cmd *cmd);
diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c
index 99e4ccf..5476179 100644
--- a/openbsc/src/libctrl/control_if.c
+++ b/openbsc/src/libctrl/control_if.c
@@ -86,6 +86,28 @@ int ctrl_cmd_send(struct ipa_server_conn *ipa_server_conn, struct ctrl_cmd *cmd)
 	return 0;
 }
 
+int ctrl_cmd_send_wqueue(struct osmo_wqueue *queue, struct ctrl_cmd *cmd)
+{
+	int ret;
+	struct msgb *msg;
+
+	msg = ctrl_cmd_make(cmd);
+	if (!msg) {
+		LOGP(DCTRL, LOGL_ERROR, "Could not generate msg\n");
+		return -1;
+	}
+
+	ipaccess_prepend_header_ext(msg, IPAC_PROTO_EXT_CTRL);
+	ipaccess_prepend_header(msg, IPAC_PROTO_OSMO);
+
+	ret = osmo_wqueue_enqueue(queue, msg);
+	if (ret != 0) {
+		LOGP(DCTRL, LOGL_ERROR, "Failed to enqueue the command");
+		msgb_free(msg);
+	}
+	return ret;
+}
+
 int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data)
 {
 	char *token, *request;
-- 
1.7.6.1





More information about the OpenBSC mailing list