summaryrefslogtreecommitdiffstats
path: root/src/ctrl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ctrl')
-rw-r--r--src/ctrl/control_cmd.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/ctrl/control_cmd.c b/src/ctrl/control_cmd.c
index f6164795..c2ce2be4 100644
--- a/src/ctrl/control_cmd.c
+++ b/src/ctrl/control_cmd.c
@@ -269,8 +269,23 @@ err:
return NULL;
}
+/*! Parse CTRL command struct from msgb, return NULL on any error.
+ * The caller is responsible to talloc_free() the returned struct pointer. */
struct ctrl_cmd *ctrl_cmd_parse(void *ctx, struct msgb *msg)
{
+ struct ctrl_cmd *res = ctrl_cmd_parse2(ctx, msg);
+ if (res->type == CTRL_TYPE_ERROR) {
+ talloc_free(res);
+ return NULL;
+ }
+ return res;
+}
+
+/*! Parse CTRL command struct from msgb, return ctrl->type == CTRL_TYPE_ERROR and an error message in
+ * ctrl->reply on any error.
+ * The caller is responsible to talloc_free() the returned struct pointer. */
+struct ctrl_cmd *ctrl_cmd_parse2(void *ctx, struct msgb *msg)
+{
char *str, *tmp, *saveptr = NULL;
char *var, *val;
struct ctrl_cmd *cmd;
@@ -382,8 +397,7 @@ oom:
cmd->id = "err";
cmd->reply = "OOM";
err:
- talloc_free(cmd);
- return NULL;
+ return cmd;
}
struct msgb *ctrl_cmd_make(struct ctrl_cmd *cmd)