keith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/40917?usp=email )
Change subject: * Add functions to set LAC/CI on a BTS and update hashtables. * Use these function from both the vty and the control interface. ...................................................................... * Add functions to set LAC/CI on a BTS and update hashtables. * Use these function from both the vty and the control interface. This commit fixes the issue where an update to LAC or CI via the control interface was not resulting in updated hashtables and therefore the BTS was not found during paging. Related: OS#6840 Fixes: 15284337ece94e3ff3ebf9575096290f67d69a88 Change-Id: If9509534bd4a75f8ed8fb3e0a6bec701c7596861 --- M include/osmocom/bsc/bts.h M src/osmo-bsc/bts.c M src/osmo-bsc/bts_ctrl.c M src/osmo-bsc/bts_vty.c 4 files changed, 94 insertions(+), 19 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/17/40917/1 diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h index 0264dcf..4cf1e1f 100644 --- a/include/osmocom/bsc/bts.h +++ b/include/osmocom/bsc/bts.h @@ -825,6 +825,9 @@ int gsm_set_bts_model(struct gsm_bts *bts, struct gsm_bts_model *model); int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); +int gsm_bts_set_lac(struct gsm_bts *bts, int lac); +int gsm_bts_set_ci(struct gsm_bts *bts, int lac); + struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num); int bts_gprs_mode_is_compat(struct gsm_bts *bts, enum bts_gprs_mode mode); diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c index dd60ef8..6af7ab1 100644 --- a/src/osmo-bsc/bts.c +++ b/src/osmo-bsc/bts.c @@ -758,6 +758,30 @@ return 0; } +int gsm_bts_set_lac(struct gsm_bts *bts, int lac) { + + bts->location_area_code = lac; + hash_del(&bts->node_by_lac); + hash_del(&bts->node_by_lac_ci); + hash_add(bts->network->bts_by_lac, &bts->node_by_lac, bts->location_area_code); + hash_add(bts->network->bts_by_lac_ci, &bts->node_by_lac_ci, + LAC_CI_HASHTABLE_KEY(bts->location_area_code, bts->cell_identity)); + return 0; +} + +int gsm_bts_set_ci(struct gsm_bts *bts, int ci) { + + bts->cell_identity = ci; + hash_del(&bts->node_by_ci); + hash_add(bts->network->bts_by_ci, &bts->node_by_ci, bts->cell_identity); + if (bts->location_area_code != GSM_LAC_RESERVED_DETACHED) { + hash_del(&bts->node_by_lac_ci); + hash_add(bts->network->bts_by_lac_ci, &bts->node_by_lac_ci, + LAC_CI_HASHTABLE_KEY(bts->location_area_code, bts->cell_identity)); + } + return 0; +} + int bts_gprs_mode_is_compat(struct gsm_bts *bts, enum bts_gprs_mode mode) { if (mode != BTS_GPRS_NONE && diff --git a/src/osmo-bsc/bts_ctrl.c b/src/osmo-bsc/bts_ctrl.c index 2efa661..bca146c 100644 --- a/src/osmo-bsc/bts_ctrl.c +++ b/src/osmo-bsc/bts_ctrl.c @@ -244,9 +244,70 @@ return 1; } +static int get_bts_lac(struct ctrl_cmd *cmd, void *data) { + struct gsm_bts *bts = cmd->node; + cmd->reply = talloc_asprintf(cmd, "%d", bts->location_area_code); + if (!cmd->reply) { + cmd->reply = "OOM"; + return CTRL_CMD_ERROR; + } + return CTRL_CMD_REPLY; +} + +static int set_bts_lac(struct ctrl_cmd *cmd, void *data) { + struct gsm_bts *bts = cmd->node; + int lac; + + osmo_str_to_int(&lac, cmd->value, 0, 0, 0xffff); + gsm_bts_set_lac(bts, lac); + return get_bts_lac(cmd, data); +} + +static int verify_bts_lac(struct ctrl_cmd *cmd, const char *value, void *data) { + int lac; + + if (osmo_str_to_int(&lac, cmd->value, 0, 0, 0xffff) < 0) { + cmd->reply = "LAC is not within the valid range (0-65535)"; + return -1; + } + if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) { + cmd->reply = talloc_asprintf(cmd, "LAC %d is reserved by GSM 04.08", lac); + return -1; + } + return 0; +} + +static int get_bts_ci(struct ctrl_cmd *cmd, void *data) { + struct gsm_bts *bts = cmd->node; + cmd->reply = talloc_asprintf(cmd, "%d", bts->cell_identity); + if (!cmd->reply) { + cmd->reply = "OOM"; + return CTRL_CMD_ERROR; + } + return CTRL_CMD_REPLY; +} + +static int set_bts_ci(struct ctrl_cmd *cmd, void *data) { + struct gsm_bts *bts = cmd->node; + int ci; + + osmo_str_to_int(&ci, cmd->value, 0, 0, 0xffff); + gsm_bts_set_ci(bts, ci); + return get_bts_ci(cmd, data); +} + +static int verify_bts_ci(struct ctrl_cmd *cmd, const char *value, void *data) { + int ci; + + if (osmo_str_to_int(&ci, cmd->value, 0, 0, 0xffff) < 0) { + cmd->reply = "CI is not within the valid range (0-65535)"; + return -1; + } + return 0; +} /* BTS related commands below */ -CTRL_CMD_DEFINE_RANGE(bts_lac, "location-area-code", struct gsm_bts, location_area_code, 0, 65535); -CTRL_CMD_DEFINE_RANGE(bts_ci, "cell-identity", struct gsm_bts, cell_identity, 0, 65535); +CTRL_CMD_DEFINE(bts_lac, "location-area-code"); +CTRL_CMD_DEFINE(bts_ci, "cell-identity"); CTRL_CMD_DEFINE_RANGE(bts_bsic, "bsic", struct gsm_bts, bsic, 0, 63); CTRL_CMD_DEFINE_RANGE(bts_rach_max_delay, "rach-max-delay", struct gsm_bts, rach_max_delay, 1, 127); CTRL_CMD_DEFINE_RANGE(bts_rach_expiry_timeout, "rach-expiry-timeout", struct gsm_bts, rach_expiry_timeout, 4, 64); diff --git a/src/osmo-bsc/bts_vty.c b/src/osmo-bsc/bts_vty.c index b2b1247..b412910 100644 --- a/src/osmo-bsc/bts_vty.c +++ b/src/osmo-bsc/bts_vty.c @@ -274,16 +274,9 @@ ci, VTY_NEWLINE); return CMD_WARNING; } - bts->cell_identity = ci; - hash_del(&bts->node_by_ci); - hash_add(bts->network->bts_by_ci, &bts->node_by_ci, bts->cell_identity); - if (bts->location_area_code != GSM_LAC_RESERVED_DETACHED) { - hash_del(&bts->node_by_lac_ci); - hash_add(bts->network->bts_by_lac_ci, &bts->node_by_lac_ci, - LAC_CI_HASHTABLE_KEY(bts->location_area_code, bts->cell_identity)); - } - return CMD_SUCCESS; + if (gsm_bts_set_ci(bts, ci)) + return CMD_SUCCESS; } DEFUN_USRATTR(cfg_bts_lac, @@ -305,14 +298,8 @@ return CMD_WARNING; } - bts->location_area_code = lac; - hash_del(&bts->node_by_lac); - hash_del(&bts->node_by_lac_ci); - hash_add(bts->network->bts_by_lac, &bts->node_by_lac, bts->location_area_code); - hash_add(bts->network->bts_by_lac_ci, &bts->node_by_lac_ci, - LAC_CI_HASHTABLE_KEY(bts->location_area_code, bts->cell_identity)); - - return CMD_SUCCESS; + if (gsm_bts_set_lac(bts, lac)) + return CMD_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/40917?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: If9509534bd4a75f8ed8fb3e0a6bec701c7596861 Gerrit-Change-Number: 40917 Gerrit-PatchSet: 1 Gerrit-Owner: keith <ke...@rhizomatica.org>