summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <daniel@totalueberwachung.de>2012-06-04 13:56:29 +0100
committerDaniel Willmann <daniel@totalueberwachung.de>2012-06-04 13:58:37 +0100
commit37df8bfa0b7fd71982b19f751fd5b8373710e4ef (patch)
treee30fc8f81d46557fada5aa323dae66df927e584a
parentc8455bc6f3bdd5256e8b7e3c89b8ab0b3c197743 (diff)
osmo-bsc: Add VTY command to set the locationdaniel/ow-vty-cmds
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_ctrl.c7
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_vty.c44
2 files changed, 50 insertions, 1 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
index 13ddbeec4..1903ea1d2 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
@@ -274,7 +274,7 @@ static int get_bts_loc(struct ctrl_cmd *cmd, void *data)
return CTRL_CMD_REPLY;
}
-static int set_bts_loc(struct ctrl_cmd *cmd, void *data)
+int osmo_bsc_set_bts_loc(struct ctrl_cmd *cmd, void *data)
{
char *saveptr, *lat, *lon, *height, *tstamp, *valid, *tmp;
struct bts_location *curloc, *lastloc;
@@ -334,6 +334,11 @@ oom:
return CTRL_CMD_ERROR;
}
+static int set_bts_loc(struct ctrl_cmd *cmd, void *data)
+{
+ return osmo_bsc_set_bts_loc(cmd, data);
+}
+
static int verify_bts_loc(struct ctrl_cmd *cmd, const char *value, void *data)
{
char *saveptr, *latstr, *lonstr, *heightstr, *tstampstr, *validstr, *tmp;
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
index 909cc5e26..dffca8104 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
@@ -18,6 +18,7 @@
*
*/
+#include <openbsc/control_cmd.h>
#include <openbsc/gsm_data.h>
#include <openbsc/osmo_msc_data.h>
#include <openbsc/vty.h>
@@ -553,6 +554,48 @@ DEFUN(show_pos,
return CMD_SUCCESS;
}
+int osmo_bsc_set_bts_loc(struct ctrl_cmd *cmd, void *data);
+
+DEFUN(set_pos,
+ set_pos_cmd,
+ "set bts NR fix (invalid|fix2d|fix3d) lat LAT lon LON",
+ SHOW_STR "Set position for the BTS\n")
+{
+ int bts_nr, ret;
+ const char *fixstate;
+ float lat, lon, height;
+
+ struct ctrl_cmd *cmd;
+ struct gsm_bts *bts;
+
+ bts_nr = atoi(argv[0]);
+ fixstate = argv[1];
+ lat = atof(argv[2]);
+ lon = atof(argv[3]);
+ height = 0;
+
+ llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
+ if (bts->nr != bts_nr) {
+ continue;
+ }
+
+ cmd = ctrl_cmd_create(vty, CTRL_TYPE_SET);
+ if (!cmd)
+ return CMD_WARNING;
+
+ cmd->node = bts;
+ cmd->value = talloc_asprintf(cmd, "%lu,%s,%f,%f,%f", 0l, fixstate,
+ lat, lon, height);
+ ret = osmo_bsc_set_bts_loc(cmd, bsc_gsmnet);
+ talloc_free(cmd);
+
+ break;
+
+ }
+
+ return CMD_SUCCESS;
+}
+
int bsc_vty_init_extra(void)
{
install_element(CONFIG_NODE, &cfg_net_msc_cmd);
@@ -593,6 +636,7 @@ int bsc_vty_init_extra(void)
install_element_ve(&show_statistics_cmd);
install_element_ve(&show_mscs_cmd);
install_element_ve(&show_pos_cmd);
+ install_element_ve(&set_pos_cmd);
return 0;
}