summaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs/sgsn_ctrl.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2014-08-21 15:10:13 +0200
committerHarald Welte <laforge@gnumonks.org>2014-08-21 15:34:28 +0200
commit02cc2b668a8e3fac7167d279cd72a436eccd185f (patch)
treec137b99329c791513846fab8fb329be797506ae7 /openbsc/src/gprs/sgsn_ctrl.c
parenta67455f8d8a647611993d09aae656df448da0b0e (diff)
libctrl: Move bulk of node lookup code into libosmocore
Now that the bulk of the control interface node lookup has no reference to the BSC specific data structures, we are moving it into libosmocore. A control interface user now only registers an optional small node lookup function like bsc_ctrl_node_lookup()
Diffstat (limited to 'openbsc/src/gprs/sgsn_ctrl.c')
-rw-r--r--openbsc/src/gprs/sgsn_ctrl.c62
1 files changed, 1 insertions, 61 deletions
diff --git a/openbsc/src/gprs/sgsn_ctrl.c b/openbsc/src/gprs/sgsn_ctrl.c
index aa5816325..276a790de 100644
--- a/openbsc/src/gprs/sgsn_ctrl.c
+++ b/openbsc/src/gprs/sgsn_ctrl.c
@@ -73,67 +73,7 @@ int sgsn_ctrl_cmds_install(void)
return rc;
}
-static int sgsn_cmd_handle(struct ctrl_cmd *cmd, void *data)
-{
- char *request;
- cmd->reply = NULL;
- cmd->node = NULL;
- vector vline, cmdvec, cmds_vec;
- int i, ret;
-
- ret = CTRL_CMD_ERROR;
-
- request = talloc_strdup(tall_bsc_ctx, cmd->variable);
- if (!request)
- goto err;
-
- for (i = 0; i < strlen(request); ++i) {
- if (request[i] == '.')
- request[i] = ' ';
- }
-
- vline = cmd_make_strvec(request);
- talloc_free(request);
- if (!vline) {
- cmd->reply = "cmd_make_strvec failed.";
- goto err;
- }
-
- /* If we're here the rest must be the command */
- cmdvec = vector_init(vector_active(vline));
- for (i = 0 ; i < vector_active(vline); ++i) {
- vector_set(cmdvec, vector_slot(vline, i));
- }
-
- /* Get the command vector of the right node */
- cmds_vec = vector_lookup(ctrl_node_vec, CTRL_NODE_ROOT);
-
- if (!cmds_vec) {
- cmd->reply = "Command not found.";
- vector_free(cmdvec);
- goto err;
- }
-
- ret = ctrl_cmd_exec(cmdvec, cmd, cmds_vec, data);
-
- vector_free(cmdvec);
- cmd_free_strvec(vline);
-
-err:
- if (!cmd->reply) {
- LOGP(DCTRL, LOGL_ERROR, "cmd->reply has not been set.\n");
- if (ret == CTRL_CMD_ERROR)
- cmd->reply = "An error has occured.";
- else
- cmd->reply = "Command has been handled.";
- }
-
- if (ret == CTRL_CMD_ERROR)
- cmd->type = CTRL_TYPE_ERROR;
- return ret;
-}
-
struct ctrl_handle *sgsn_controlif_setup(struct gsm_network *net, uint16_t port)
{
- return controlif_setup(net, port, sgsn_cmd_handle);
+ return controlif_setup(net, port, NULL);
}