diff options
-rw-r--r-- | TODO-RELEASE | 1 | ||||
-rw-r--r-- | include/osmocom/ctrl/control_if.h | 7 | ||||
-rw-r--r-- | src/ctrl/control_if.c | 4 |
3 files changed, 12 insertions, 0 deletions
diff --git a/TODO-RELEASE b/TODO-RELEASE index e8fb32be..501f25b6 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -12,3 +12,4 @@ libosmogsm ABI change struct osmo_gprs_cell_options size changed (new field at libosmogsm API change struct ipac_preproc_ave_cfg: new zero-sized flexible array member at end libosmovty ABI change struct cmd_element: add a field for program specific attributes libosmovty ABI change struct vty_app_info: optional program specific attributes description +libosmoctrl ABI change struct ctrl_handle changed size (new field "reply_cb" at the end) diff --git a/include/osmocom/ctrl/control_if.h b/include/osmocom/ctrl/control_if.h index 5fa9588d..b73296f6 100644 --- a/include/osmocom/ctrl/control_if.h +++ b/include/osmocom/ctrl/control_if.h @@ -9,6 +9,7 @@ int ctrl_parse_get_num(vector vline, int i, long *num); typedef int (*ctrl_cmd_lookup)(void *data, vector vline, int *node_type, void **node_data, int *i); +typedef void (*ctrl_cmd_reply_cb)(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, void *data); struct ctrl_handle { struct osmo_fd listen_fd; @@ -18,6 +19,12 @@ struct ctrl_handle { /* List of control connections */ struct llist_head ccon_list; + + /* User defined GET/SET REPLY handler. User can set cmd->defer to 1 in + order to own and keep the cmd pointer and free it after the function + returns. "data" param is the user data pointer supplied during + ctrl_handle allocation */ + ctrl_cmd_reply_cb reply_cb; }; diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c index ce2e3676..9e3e3a9e 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -221,6 +221,10 @@ int ctrl_cmd_handle(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, if (cmd->type == CTRL_TYPE_SET_REPLY || cmd->type == CTRL_TYPE_GET_REPLY) { + if (ctrl->reply_cb) { + ctrl->reply_cb(ctrl, cmd, data); + return CTRL_CMD_HANDLED; + } if (strncmp(cmd->reply, "OK", 2) == 0) { LOGP(DLCTRL, LOGL_DEBUG, "%s <%s> for %s is OK\n", get_value_string(ctrl_type_vals, cmd->type), |