summaryrefslogtreecommitdiffstats
path: root/src/ctrl
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-08-04 11:07:08 +0200
committerMax <msuraev@sysmocom.de>2016-10-12 11:37:49 +0000
commitbc067eb0a20a7feadb5dbb3b4169cb8f9286a455 (patch)
tree8b7a5b5ea9e5725ca86ce78c80e9ca82b0d8de83 /src/ctrl
parent530736f3153da2cc6774ad0d070b8c6fbf432a98 (diff)
Add function to send TRAP over Control Interface
Change-Id: Ic0b8d88c4f5c4d42c3f8fb754f8eabf049c9e388 Related: OS#1646
Diffstat (limited to 'src/ctrl')
-rw-r--r--src/ctrl/control_if.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index 2ffc251e..df394867 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -117,6 +117,27 @@ int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd)
return ret;
}
+/*! \brief Send TRAP over given Control Interface
+ * \param[in] ctrl Control Interface over which TRAP will be sent
+ * \param[in] name Name of the TRAP variable
+ * \param[in] value Value of the TRAP variable
+ * \return Negative value on error, result of ctrl_cmd_send_to_all() otherwise
+ */
+int ctrl_cmd_send_trap(struct ctrl_handle *ctrl, const char *name, char *value)
+{
+ int r;
+ struct ctrl_cmd *cmd = ctrl_cmd_create(NULL, CTRL_TYPE_TRAP);
+ if (!cmd)
+ return -ENOMEM;
+
+ cmd->id = "0"; /* It's a TRAP! */
+ cmd->variable = name;
+ cmd->reply = value;
+ r = ctrl_cmd_send_to_all(ctrl, cmd);
+ talloc_free(cmd);
+ return r;
+}
+
struct ctrl_cmd *ctrl_cmd_trap(struct ctrl_cmd *cmd)
{
struct ctrl_cmd *trap;