[MERGED] osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Neels Hofmeyr has submitted this change and it was merged. Change subject: implement support for 3-digit MNC with leading zeros .. implement support for 3-digit MNC with leading zeros Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). The changes to abis_test and gsm0408_test show that this code now handles 3-digit MNC correctly, by not dropping the leading zero as 0xf in the encoded PLMN. Re-implement CTRL commands 'mcc', 'mnc' and 'mcc-mnc-apply' to preserve the presence of the third digit of the MNC. Always reply with all leading zeros. Adjust the expected results in ctrl_test_runner.py, to show that it works. In VTY and CTRL, the parsing of MCC and MNC is inherently made stricter by use of osmo_{mcc,mnc}_from_str() -- they will no longer allow surplus characters and detect errno returned by strtol() (in contrast to atoi()). Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore), I020a4f11791c61742a3d795f782805f7b7e8733e (libosmocore) Change-Id: I8e722103344186fde118b26d8353db95a4581daa --- M include/osmocom/bsc/bsc_msc_data.h M include/osmocom/bsc/gsm_data.h M src/libbsc/bsc_ctrl_commands.c M src/libbsc/bsc_init.c M src/libbsc/bsc_vty.c M src/libbsc/gsm_data.c M src/libbsc/net_init.c M src/libbsc/pcu_sock.c M src/libbsc/system_information.c M src/osmo-bsc/osmo_bsc_api.c M src/osmo-bsc/osmo_bsc_bssap.c M src/osmo-bsc/osmo_bsc_ctrl.c M src/osmo-bsc/osmo_bsc_filter.c M src/osmo-bsc/osmo_bsc_msc.c M src/osmo-bsc/osmo_bsc_vty.c M tests/abis/abis_test.c M tests/abis/abis_test.ok M tests/bssap/bssap_test.err M tests/ctrl_test_runner.py M tests/gsm0408/gsm0408_test.c M tests/gsm0408/gsm0408_test.ok M tests/nanobts_omlattr/nanobts_omlattr_test.c 22 files changed, 225 insertions(+), 171 deletions(-) Approvals: Neels Hofmeyr: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h index a3e0106..a04e632 100644 --- a/include/osmocom/bsc/bsc_msc_data.h +++ b/include/osmocom/bsc/bsc_msc_data.h @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -78,8 +79,7 @@ struct osmo_timer_list pong_timer; int advanced_ping; struct bsc_msc_connection *msc_con; - int core_mnc; - int core_mcc; + struct osmo_plmn_id core_plmn; int core_lac; int core_ci; int rtp_base; diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 8692469..27aa261 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -1197,9 +1198,8 @@ * these have in common, like country and network code, put in yet * separate structs and placed as members in osmo_bsc and osmo_msc. */ - /* global parameters */ - uint16_t country_code; - uint16_t network_code; + struct osmo_plmn_id plmn; + /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ uint8_t a5_encryption_mask; int neci; @@ -1275,6 +1275,16 @@ } mgw; }; +static inline const struct osmo_location_area_id *bts_lai(struct gsm_bts *bts) +{ + static struct osmo_location_area_id lai; + lai = (struct osmo_location_area_id){ + .plmn = bts->network->plmn, + .lac = bts->location_area_code, + }; + return +} + extern void talloc_ctx_init(void *ctx_root); int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); diff --git a/src/libbsc/bsc_ctrl_commands.c b/src/libbsc/bsc_ctrl_commands.c index 41d2361..64f4589 100644 --- a/src/libbsc/bsc_ctrl_commands.c +++ b/src/libbsc/bsc_ctrl_commands.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -30,8 +31,61 @@ #include #include -CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, network_code, 0, 999); -CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, country_code, 1, 999); +CTRL_CMD_DEFINE(net_mcc, "mcc"); +static int get_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + cmd->reply = talloc_asprintf(cmd, "%s", osmo_mcc_name(net->plmn.mcc)); + if (!cmd->reply) { + cmd->reply = "OOM"; + return CTRL_CMD_ERROR; + } + return CTRL_CMD_REPLY; +} +static int set_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + uint16_t mcc; + if (osmo_mcc_from_str(cmd->value, )) + return -1; + net->plmn.mcc = mcc; + return get_net_mcc(cmd, _data); +} +static int verify_net_mcc(struct ctrl_cmd *cmd, const char *value, void *_data) +{
osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Patch Set 11: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/6668 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8e722103344186fde118b26d8353db95a4581daa Gerrit-PatchSet: 11 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
[PATCH] osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/6668 to look at the new patch set (#11). implement support for 3-digit MNC with leading zeros Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). The changes to abis_test and gsm0408_test show that this code now handles 3-digit MNC correctly, by not dropping the leading zero as 0xf in the encoded PLMN. Re-implement CTRL commands 'mcc', 'mnc' and 'mcc-mnc-apply' to preserve the presence of the third digit of the MNC. Always reply with all leading zeros. Adjust the expected results in ctrl_test_runner.py, to show that it works. In VTY and CTRL, the parsing of MCC and MNC is inherently made stricter by use of osmo_{mcc,mnc}_from_str() -- they will no longer allow surplus characters and detect errno returned by strtol() (in contrast to atoi()). Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore), I020a4f11791c61742a3d795f782805f7b7e8733e (libosmocore) Change-Id: I8e722103344186fde118b26d8353db95a4581daa --- M include/osmocom/bsc/bsc_msc_data.h M include/osmocom/bsc/gsm_data.h M src/libbsc/bsc_ctrl_commands.c M src/libbsc/bsc_init.c M src/libbsc/bsc_vty.c M src/libbsc/gsm_data.c M src/libbsc/net_init.c M src/libbsc/pcu_sock.c M src/libbsc/system_information.c M src/osmo-bsc/osmo_bsc_api.c M src/osmo-bsc/osmo_bsc_bssap.c M src/osmo-bsc/osmo_bsc_ctrl.c M src/osmo-bsc/osmo_bsc_filter.c M src/osmo-bsc/osmo_bsc_msc.c M src/osmo-bsc/osmo_bsc_vty.c M tests/abis/abis_test.c M tests/abis/abis_test.ok M tests/bssap/bssap_test.err M tests/ctrl_test_runner.py M tests/gsm0408/gsm0408_test.c M tests/gsm0408/gsm0408_test.ok M tests/nanobts_omlattr/nanobts_omlattr_test.c 22 files changed, 225 insertions(+), 171 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/68/6668/11 diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h index a3e0106..a04e632 100644 --- a/include/osmocom/bsc/bsc_msc_data.h +++ b/include/osmocom/bsc/bsc_msc_data.h @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -78,8 +79,7 @@ struct osmo_timer_list pong_timer; int advanced_ping; struct bsc_msc_connection *msc_con; - int core_mnc; - int core_mcc; + struct osmo_plmn_id core_plmn; int core_lac; int core_ci; int rtp_base; diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 8692469..27aa261 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -1197,9 +1198,8 @@ * these have in common, like country and network code, put in yet * separate structs and placed as members in osmo_bsc and osmo_msc. */ - /* global parameters */ - uint16_t country_code; - uint16_t network_code; + struct osmo_plmn_id plmn; + /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ uint8_t a5_encryption_mask; int neci; @@ -1275,6 +1275,16 @@ } mgw; }; +static inline const struct osmo_location_area_id *bts_lai(struct gsm_bts *bts) +{ + static struct osmo_location_area_id lai; + lai = (struct osmo_location_area_id){ + .plmn = bts->network->plmn, + .lac = bts->location_area_code, + }; + return +} + extern void talloc_ctx_init(void *ctx_root); int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); diff --git a/src/libbsc/bsc_ctrl_commands.c b/src/libbsc/bsc_ctrl_commands.c index 41d2361..64f4589 100644 --- a/src/libbsc/bsc_ctrl_commands.c +++ b/src/libbsc/bsc_ctrl_commands.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -30,8 +31,61 @@ #include #include -CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, network_code, 0, 999); -CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, country_code, 1, 999); +CTRL_CMD_DEFINE(net_mcc, "mcc"); +static int get_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + cmd->reply = talloc_asprintf(cmd, "%s", osmo_mcc_name(net->plmn.mcc)); + if (!cmd->reply) { + cmd->reply = "OOM"; + return CTRL_CMD_ERROR; + } + return CTRL_CMD_REPLY; +} +static int set_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + uint16_t mcc; + if (osmo_mcc_from_str(cmd->value, )) + return -1; + net->plmn.mcc = mcc; + return get_net_mcc(cmd, _data); +} +static int verify_net_mcc(struct ctrl_cmd *cmd, const char *value, void *_data) +{ + if (osmo_mcc_from_str(value, NULL)) +
osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Patch Set 10: (1 comment) https://gerrit.osmocom.org/#/c/6668/10/include/osmocom/bsc/gsm_data.h File include/osmocom/bsc/gsm_data.h: PS10, Line 1280: ; :lai = (struct osmo_location_area_id) > weird, makes me wonder "what was my motivation" NOW I remember: the lai is static. If I init on the static definition, I fear that it will not be updated in each function call but only once. Maybe it doesn't even work to init statics with function args. -- To view, visit https://gerrit.osmocom.org/6668 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8e722103344186fde118b26d8353db95a4581daa Gerrit-PatchSet: 10 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes
osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Patch Set 10: (2 comments) https://gerrit.osmocom.org/#/c/6668/10/include/osmocom/bsc/gsm_data.h File include/osmocom/bsc/gsm_data.h: PS10, Line 1280: ; :lai = (struct osmo_location_area_id) > why not simply have the '=' one line above, no typecast and no need to rest weird, makes me wonder "what was my motivation" https://gerrit.osmocom.org/#/c/6668/10/src/osmo-bsc/osmo_bsc_vty.c File src/osmo-bsc/osmo_bsc_vty.c: Line 242: > whitespace, not critical vim has a way of removing these obsolete tabs, but for some reason it doesn't always work. That in combination with my external patch colorizer .. I should teach it to also mark whitespace errors. -- To view, visit https://gerrit.osmocom.org/6668 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8e722103344186fde118b26d8353db95a4581daa Gerrit-PatchSet: 10 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes
osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Patch Set 10: Code-Review+2 (2 comments) https://gerrit.osmocom.org/#/c/6668/10/include/osmocom/bsc/gsm_data.h File include/osmocom/bsc/gsm_data.h: PS10, Line 1280: ; :lai = (struct osmo_location_area_id) why not simply have the '=' one line above, no typecast and no need to restate the 'lai'? Super cosmetic, but I can't help to wonder "what was his motivation". https://gerrit.osmocom.org/#/c/6668/10/src/osmo-bsc/osmo_bsc_vty.c File src/osmo-bsc/osmo_bsc_vty.c: Line 242: whitespace, not critical -- To view, visit https://gerrit.osmocom.org/6668 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8e722103344186fde118b26d8353db95a4581daa Gerrit-PatchSet: 10 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes
[PATCH] osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/6668 to look at the new patch set (#10). implement support for 3-digit MNC with leading zeros Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). The changes to abis_test and gsm0408_test show that this code now handles 3-digit MNC correctly, by not dropping the leading zero as 0xf in the encoded PLMN. Re-implement CTRL commands 'mcc', 'mnc' and 'mcc-mnc-apply' to preserve the presence of the third digit of the MNC. Always reply with all leading zeros. Adjust the expected results in ctrl_test_runner.py, to show that it works. In VTY and CTRL, the parsing of MCC and MNC is inherently made stricter by use of osmo_{mcc,mnc}_from_str() -- they will no longer allow surplus characters and detect errno returned by strtol() (in contrast to atoi()). Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore), I020a4f11791c61742a3d795f782805f7b7e8733e (libosmocore) Change-Id: I8e722103344186fde118b26d8353db95a4581daa --- M include/osmocom/bsc/bsc_msc_data.h M include/osmocom/bsc/gsm_data.h M src/libbsc/bsc_ctrl_commands.c M src/libbsc/bsc_init.c M src/libbsc/bsc_vty.c M src/libbsc/gsm_data.c M src/libbsc/net_init.c M src/libbsc/pcu_sock.c M src/libbsc/system_information.c M src/osmo-bsc/osmo_bsc_api.c M src/osmo-bsc/osmo_bsc_bssap.c M src/osmo-bsc/osmo_bsc_ctrl.c M src/osmo-bsc/osmo_bsc_filter.c M src/osmo-bsc/osmo_bsc_msc.c M src/osmo-bsc/osmo_bsc_vty.c M tests/abis/abis_test.c M tests/abis/abis_test.ok M tests/bssap/bssap_test.err M tests/ctrl_test_runner.py M tests/gsm0408/gsm0408_test.c M tests/gsm0408/gsm0408_test.ok M tests/nanobts_omlattr/nanobts_omlattr_test.c 22 files changed, 225 insertions(+), 171 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/68/6668/10 diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h index a3e0106..a04e632 100644 --- a/include/osmocom/bsc/bsc_msc_data.h +++ b/include/osmocom/bsc/bsc_msc_data.h @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -78,8 +79,7 @@ struct osmo_timer_list pong_timer; int advanced_ping; struct bsc_msc_connection *msc_con; - int core_mnc; - int core_mcc; + struct osmo_plmn_id core_plmn; int core_lac; int core_ci; int rtp_base; diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 8692469..27aa261 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -1197,9 +1198,8 @@ * these have in common, like country and network code, put in yet * separate structs and placed as members in osmo_bsc and osmo_msc. */ - /* global parameters */ - uint16_t country_code; - uint16_t network_code; + struct osmo_plmn_id plmn; + /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ uint8_t a5_encryption_mask; int neci; @@ -1275,6 +1275,16 @@ } mgw; }; +static inline const struct osmo_location_area_id *bts_lai(struct gsm_bts *bts) +{ + static struct osmo_location_area_id lai; + lai = (struct osmo_location_area_id){ + .plmn = bts->network->plmn, + .lac = bts->location_area_code, + }; + return +} + extern void talloc_ctx_init(void *ctx_root); int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); diff --git a/src/libbsc/bsc_ctrl_commands.c b/src/libbsc/bsc_ctrl_commands.c index 41d2361..64f4589 100644 --- a/src/libbsc/bsc_ctrl_commands.c +++ b/src/libbsc/bsc_ctrl_commands.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -30,8 +31,61 @@ #include #include -CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, network_code, 0, 999); -CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, country_code, 1, 999); +CTRL_CMD_DEFINE(net_mcc, "mcc"); +static int get_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + cmd->reply = talloc_asprintf(cmd, "%s", osmo_mcc_name(net->plmn.mcc)); + if (!cmd->reply) { + cmd->reply = "OOM"; + return CTRL_CMD_ERROR; + } + return CTRL_CMD_REPLY; +} +static int set_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + uint16_t mcc; + if (osmo_mcc_from_str(cmd->value, )) + return -1; + net->plmn.mcc = mcc; + return get_net_mcc(cmd, _data); +} +static int verify_net_mcc(struct ctrl_cmd *cmd, const char *value, void *_data) +{ + if (osmo_mcc_from_str(value, NULL)) +
osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Patch Set 9: > Build Successful finally! -- To view, visit https://gerrit.osmocom.org/6668 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8e722103344186fde118b26d8353db95a4581daa Gerrit-PatchSet: 9 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
[PATCH] osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/6668 to look at the new patch set (#8). implement support for 3-digit MNC with leading zeros Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). The changes to abis_test and gsm0408_test show that this code now handles 3-digit MNC correctly, by not dropping the leading zero as 0xf in the encoded PLMN. Re-implement CTRL commands 'mcc', 'mnc' and 'mcc-mnc-apply' to preserve the presence of the third digit of the MNC. Always reply with all leading zeros. Adjust the expected results in ctrl_test_runner.py, to show that it works. In VTY and CTRL, the parsing of MCC and MNC is inherently made stricter by use of osmo_{mcc,mnc}_from_str() -- they will no longer allow surplus characters and detect errno returned by strtol() (in contrast to atoi()). Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore), I020a4f11791c61742a3d795f782805f7b7e8733e (libosmocore) Change-Id: I8e722103344186fde118b26d8353db95a4581daa --- M include/osmocom/bsc/bsc_msc_data.h M include/osmocom/bsc/gsm_data.h M src/libbsc/bsc_ctrl_commands.c M src/libbsc/bsc_init.c M src/libbsc/bsc_vty.c M src/libbsc/gsm_data.c M src/libbsc/net_init.c M src/libbsc/pcu_sock.c M src/libbsc/system_information.c M src/osmo-bsc/osmo_bsc_api.c M src/osmo-bsc/osmo_bsc_bssap.c M src/osmo-bsc/osmo_bsc_ctrl.c M src/osmo-bsc/osmo_bsc_filter.c M src/osmo-bsc/osmo_bsc_msc.c M src/osmo-bsc/osmo_bsc_vty.c M tests/abis/abis_test.c M tests/abis/abis_test.ok M tests/bssap/bssap_test.err M tests/ctrl_test_runner.py M tests/gsm0408/gsm0408_test.c M tests/gsm0408/gsm0408_test.ok M tests/nanobts_omlattr/nanobts_omlattr_test.c 22 files changed, 225 insertions(+), 171 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/68/6668/8 diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h index a3e0106..a04e632 100644 --- a/include/osmocom/bsc/bsc_msc_data.h +++ b/include/osmocom/bsc/bsc_msc_data.h @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -78,8 +79,7 @@ struct osmo_timer_list pong_timer; int advanced_ping; struct bsc_msc_connection *msc_con; - int core_mnc; - int core_mcc; + struct osmo_plmn_id core_plmn; int core_lac; int core_ci; int rtp_base; diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 8692469..27aa261 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -1197,9 +1198,8 @@ * these have in common, like country and network code, put in yet * separate structs and placed as members in osmo_bsc and osmo_msc. */ - /* global parameters */ - uint16_t country_code; - uint16_t network_code; + struct osmo_plmn_id plmn; + /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ uint8_t a5_encryption_mask; int neci; @@ -1275,6 +1275,16 @@ } mgw; }; +static inline const struct osmo_location_area_id *bts_lai(struct gsm_bts *bts) +{ + static struct osmo_location_area_id lai; + lai = (struct osmo_location_area_id){ + .plmn = bts->network->plmn, + .lac = bts->location_area_code, + }; + return +} + extern void talloc_ctx_init(void *ctx_root); int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); diff --git a/src/libbsc/bsc_ctrl_commands.c b/src/libbsc/bsc_ctrl_commands.c index 41d2361..64f4589 100644 --- a/src/libbsc/bsc_ctrl_commands.c +++ b/src/libbsc/bsc_ctrl_commands.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -30,8 +31,61 @@ #include #include -CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, network_code, 0, 999); -CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, country_code, 1, 999); +CTRL_CMD_DEFINE(net_mcc, "mcc"); +static int get_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + cmd->reply = talloc_asprintf(cmd, "%s", osmo_mcc_name(net->plmn.mcc)); + if (!cmd->reply) { + cmd->reply = "OOM"; + return CTRL_CMD_ERROR; + } + return CTRL_CMD_REPLY; +} +static int set_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + uint16_t mcc; + if (osmo_mcc_from_str(cmd->value, )) + return -1; + net->plmn.mcc = mcc; + return get_net_mcc(cmd, _data); +} +static int verify_net_mcc(struct ctrl_cmd *cmd, const char *value, void *_data) +{ + if (osmo_mcc_from_str(value, NULL)) +
osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Patch Set 7: -Code-Review ok fixed it; but it won't build because of an added dependency on I020a4f11791c61742a3d795f782805f7b7e8733e -- To view, visit https://gerrit.osmocom.org/6668 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8e722103344186fde118b26d8353db95a4581daa Gerrit-PatchSet: 7 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Patch Set 7: Code-Review-2 ok can verify the failure now with address sanitizer on. Still need to fix something apparently. -- To view, visit https://gerrit.osmocom.org/6668 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8e722103344186fde118b26d8353db95a4581daa Gerrit-PatchSet: 7 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
[PATCH] osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/6668 to look at the new patch set (#7). implement support for 3-digit MNC with leading zeros Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). The changes to abis_test and gsm0408_test show that this code now handles 3-digit MNC correctly, by not dropping the leading zero as 0xf in the encoded PLMN. Re-implement CTRL commands 'mcc', 'mnc' and 'mcc-mnc-apply' to preserve the presence of the third digit of the MNC. Always reply with all leading zeros. Adjust the expected results in ctrl_test_runner.py, to show that it works. Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore) Change-Id: I8e722103344186fde118b26d8353db95a4581daa --- M include/osmocom/bsc/bsc_msc_data.h M include/osmocom/bsc/gsm_data.h M src/libbsc/bsc_ctrl_commands.c M src/libbsc/bsc_init.c M src/libbsc/bsc_vty.c M src/libbsc/gsm_data.c M src/libbsc/net_init.c M src/libbsc/pcu_sock.c M src/libbsc/system_information.c M src/osmo-bsc/osmo_bsc_api.c M src/osmo-bsc/osmo_bsc_bssap.c M src/osmo-bsc/osmo_bsc_ctrl.c M src/osmo-bsc/osmo_bsc_filter.c M src/osmo-bsc/osmo_bsc_msc.c M src/osmo-bsc/osmo_bsc_vty.c M tests/abis/abis_test.c M tests/abis/abis_test.ok M tests/bssap/bssap_test.err M tests/ctrl_test_runner.py M tests/gsm0408/gsm0408_test.c M tests/gsm0408/gsm0408_test.ok M tests/nanobts_omlattr/nanobts_omlattr_test.c 22 files changed, 235 insertions(+), 167 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/68/6668/7 diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h index a3e0106..cbda10d 100644 --- a/include/osmocom/bsc/bsc_msc_data.h +++ b/include/osmocom/bsc/bsc_msc_data.h @@ -78,8 +78,9 @@ struct osmo_timer_list pong_timer; int advanced_ping; struct bsc_msc_connection *msc_con; - int core_mnc; - int core_mcc; + uint16_t core_mcc; + uint16_t core_mnc; + bool core_mnc_3_digits; int core_lac; int core_ci; int rtp_base; diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 8692469..27aa261 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -1197,9 +1198,8 @@ * these have in common, like country and network code, put in yet * separate structs and placed as members in osmo_bsc and osmo_msc. */ - /* global parameters */ - uint16_t country_code; - uint16_t network_code; + struct osmo_plmn_id plmn; + /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ uint8_t a5_encryption_mask; int neci; @@ -1275,6 +1275,16 @@ } mgw; }; +static inline const struct osmo_location_area_id *bts_lai(struct gsm_bts *bts) +{ + static struct osmo_location_area_id lai; + lai = (struct osmo_location_area_id){ + .plmn = bts->network->plmn, + .lac = bts->location_area_code, + }; + return +} + extern void talloc_ctx_init(void *ctx_root); int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); diff --git a/src/libbsc/bsc_ctrl_commands.c b/src/libbsc/bsc_ctrl_commands.c index 41d2361..091b7c9 100644 --- a/src/libbsc/bsc_ctrl_commands.c +++ b/src/libbsc/bsc_ctrl_commands.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -30,8 +31,65 @@ #include #include -CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, network_code, 0, 999); -CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, country_code, 1, 999); +CTRL_CMD_DEFINE(net_mcc, "mcc"); +static int get_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + cmd->reply = talloc_asprintf(cmd, "%s", osmo_mcc_name(net->plmn.mcc)); + if (!cmd->reply) { + cmd->reply = "OOM"; + return CTRL_CMD_ERROR; + } + return CTRL_CMD_REPLY; +} +static int set_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + uint16_t mcc; + /* re-use the string parsing logic from osmo_mnc_from_str(), we just don't need the 3-digits +* indicator. */ + if (osmo_mnc_from_str(cmd->value, , NULL)) + return -1; + net->plmn.mcc = mcc; + return get_net_mcc(cmd, _data); +} +static int verify_net_mcc(struct ctrl_cmd *cmd, const char *value, void *_data) +{ + /* re-use the string parsing logic from osmo_mnc_from_str(), we just don't need the 3-digits +* indicator. */ + if (osmo_mnc_from_str(value, NULL, NULL)) + return -1; + return 0; +} +
osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Patch Set 6: meh, can't reproduce the ctrl test failure! -- To view, visit https://gerrit.osmocom.org/6668 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8e722103344186fde118b26d8353db95a4581daa Gerrit-PatchSet: 6 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
[PATCH] osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/6668 to look at the new patch set (#6). implement support for 3-digit MNC with leading zeros Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). The changes to abis_test and gsm0408_test show that this code now handles 3-digit MNC correctly, by not dropping the leading zero as 0xf in the encoded PLMN. Re-implement CTRL commands 'mcc', 'mnc' and 'mcc-mnc-apply' to preserve the presence of the third digit of the MNC. Always reply with all leading zeros. Adjust the expected results in ctrl_test_runner.py, to show that it works. Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore) Change-Id: I8e722103344186fde118b26d8353db95a4581daa --- M include/osmocom/bsc/bsc_msc_data.h M include/osmocom/bsc/gsm_data.h M src/libbsc/bsc_ctrl_commands.c M src/libbsc/bsc_init.c M src/libbsc/bsc_vty.c M src/libbsc/gsm_data.c M src/libbsc/net_init.c M src/libbsc/pcu_sock.c M src/libbsc/system_information.c M src/osmo-bsc/osmo_bsc_api.c M src/osmo-bsc/osmo_bsc_bssap.c M src/osmo-bsc/osmo_bsc_ctrl.c M src/osmo-bsc/osmo_bsc_filter.c M src/osmo-bsc/osmo_bsc_msc.c M src/osmo-bsc/osmo_bsc_vty.c M tests/abis/abis_test.c M tests/abis/abis_test.ok M tests/bssap/bssap_test.err M tests/ctrl_test_runner.py M tests/gsm0408/gsm0408_test.c M tests/gsm0408/gsm0408_test.ok M tests/nanobts_omlattr/nanobts_omlattr_test.c 22 files changed, 231 insertions(+), 167 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/68/6668/6 diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h index a3e0106..cbda10d 100644 --- a/include/osmocom/bsc/bsc_msc_data.h +++ b/include/osmocom/bsc/bsc_msc_data.h @@ -78,8 +78,9 @@ struct osmo_timer_list pong_timer; int advanced_ping; struct bsc_msc_connection *msc_con; - int core_mnc; - int core_mcc; + uint16_t core_mcc; + uint16_t core_mnc; + bool core_mnc_3_digits; int core_lac; int core_ci; int rtp_base; diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 8692469..27aa261 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -1197,9 +1198,8 @@ * these have in common, like country and network code, put in yet * separate structs and placed as members in osmo_bsc and osmo_msc. */ - /* global parameters */ - uint16_t country_code; - uint16_t network_code; + struct osmo_plmn_id plmn; + /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ uint8_t a5_encryption_mask; int neci; @@ -1275,6 +1275,16 @@ } mgw; }; +static inline const struct osmo_location_area_id *bts_lai(struct gsm_bts *bts) +{ + static struct osmo_location_area_id lai; + lai = (struct osmo_location_area_id){ + .plmn = bts->network->plmn, + .lac = bts->location_area_code, + }; + return +} + extern void talloc_ctx_init(void *ctx_root); int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); diff --git a/src/libbsc/bsc_ctrl_commands.c b/src/libbsc/bsc_ctrl_commands.c index 41d2361..b5aa77d 100644 --- a/src/libbsc/bsc_ctrl_commands.c +++ b/src/libbsc/bsc_ctrl_commands.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -30,8 +31,65 @@ #include #include -CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, network_code, 0, 999); -CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, country_code, 1, 999); +CTRL_CMD_DEFINE(net_mcc, "mcc"); +static int get_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + cmd->reply = talloc_asprintf(cmd, "%s", osmo_mcc_name(net->plmn.mcc)); + if (!cmd->reply) { + cmd->reply = "OOM"; + return CTRL_CMD_ERROR; + } + return CTRL_CMD_REPLY; +} +static int set_net_mcc(struct ctrl_cmd *cmd, void *_data) +{ + struct gsm_network *net = cmd->node; + uint16_t mcc; + /* re-use the string parsing logic from osmo_mnc_from_str(), we just don't need the 3-digits +* indicator. */ + if (osmo_mnc_from_str(cmd->value, , NULL)) + return -1; + net->plmn.mcc = mcc; + return get_net_mcc(cmd, _data); +} +static int verify_net_mcc(struct ctrl_cmd *cmd, const char *value, void *_data) +{ + /* re-use the string parsing logic from osmo_mnc_from_str(), we just don't need the 3-digits +* indicator. */ + if (osmo_mnc_from_str(value, NULL, NULL)) + return -1; + return 0; +} +
[PATCH] osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/6668 to look at the new patch set (#5). implement support for 3-digit MNC with leading zeros Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). The changes to abis_test and gsm0408_test show that this code now handles 3-digit MNC correctly, by not dropping the leading zero as 0xf in the encoded PLMN. Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore) Change-Id: I8e722103344186fde118b26d8353db95a4581daa --- M include/osmocom/bsc/bsc_msc_data.h M include/osmocom/bsc/gsm_data.h M src/libbsc/bsc_ctrl_commands.c M src/libbsc/bsc_init.c M src/libbsc/bsc_vty.c M src/libbsc/gsm_data.c M src/libbsc/net_init.c M src/libbsc/pcu_sock.c M src/libbsc/system_information.c M src/osmo-bsc/osmo_bsc_api.c M src/osmo-bsc/osmo_bsc_bssap.c M src/osmo-bsc/osmo_bsc_ctrl.c M src/osmo-bsc/osmo_bsc_filter.c M src/osmo-bsc/osmo_bsc_msc.c M src/osmo-bsc/osmo_bsc_vty.c M tests/abis/abis_test.c M tests/abis/abis_test.ok M tests/bssap/bssap_test.err M tests/gsm0408/gsm0408_test.c M tests/gsm0408/gsm0408_test.ok M tests/nanobts_omlattr/nanobts_omlattr_test.c 21 files changed, 143 insertions(+), 155 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/68/6668/5 diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h index a3e0106..cbda10d 100644 --- a/include/osmocom/bsc/bsc_msc_data.h +++ b/include/osmocom/bsc/bsc_msc_data.h @@ -78,8 +78,9 @@ struct osmo_timer_list pong_timer; int advanced_ping; struct bsc_msc_connection *msc_con; - int core_mnc; - int core_mcc; + uint16_t core_mcc; + uint16_t core_mnc; + bool core_mnc_3_digits; int core_lac; int core_ci; int rtp_base; diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 8692469..27aa261 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -1197,9 +1198,8 @@ * these have in common, like country and network code, put in yet * separate structs and placed as members in osmo_bsc and osmo_msc. */ - /* global parameters */ - uint16_t country_code; - uint16_t network_code; + struct osmo_plmn_id plmn; + /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ uint8_t a5_encryption_mask; int neci; @@ -1275,6 +1275,16 @@ } mgw; }; +static inline const struct osmo_location_area_id *bts_lai(struct gsm_bts *bts) +{ + static struct osmo_location_area_id lai; + lai = (struct osmo_location_area_id){ + .plmn = bts->network->plmn, + .lac = bts->location_area_code, + }; + return +} + extern void talloc_ctx_init(void *ctx_root); int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); diff --git a/src/libbsc/bsc_ctrl_commands.c b/src/libbsc/bsc_ctrl_commands.c index 41d2361..18fd26b 100644 --- a/src/libbsc/bsc_ctrl_commands.c +++ b/src/libbsc/bsc_ctrl_commands.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -30,8 +31,8 @@ #include #include -CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, network_code, 0, 999); -CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, country_code, 1, 999); +CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, plmn.mnc, 0, 999); +CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, plmn.mcc, 1, 999); static int set_net_apply_config(struct ctrl_cmd *cmd, void *data) { @@ -75,6 +76,10 @@ if (!mcc || !mnc) return 1; + + if (osmo_mnc_from_str(mnc, NULL, NULL)) + return 1; + return 0; } @@ -82,28 +87,29 @@ { struct gsm_network *net = cmd->node; char *tmp, *saveptr, *mcc_str, *mnc_str; - int mcc, mnc; + struct osmo_plmn_id plmn; tmp = talloc_strdup(cmd, cmd->value); if (!tmp) goto oom; - mcc_str = strtok_r(tmp, ",", ); mnc_str = strtok_r(NULL, ",", ); - mcc = atoi(mcc_str); - mnc = atoi(mnc_str); + plmn.mcc = atoi(mcc_str); + if (osmo_mnc_from_str(mnc_str, , _3_digits)) { + cmd->reply = "Error while decoding MNC"; + return CTRL_CMD_ERROR; + } talloc_free(tmp); - if (net->network_code == mnc && net->country_code == mcc) { + if (!osmo_plmn_cmp(>plmn, )) { cmd->reply = "Nothing changed"; return CTRL_CMD_REPLY; } - net->network_code = mnc; - net->country_code = mcc; + net->plmn = plmn;
osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Patch Set 4: Code-Review+1 What wie need now is proper coverage in the ttcn3 testsuite: usw vty to changfe config and verify the Encoded value in all messages containing MNC/lai/rai -- To view, visit https://gerrit.osmocom.org/6668 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8e722103344186fde118b26d8353db95a4581daa Gerrit-PatchSet: 4 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/6668 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8e722103344186fde118b26d8353db95a4581daa Gerrit-PatchSet: 3 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[PATCH] osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/6668 to look at the new patch set (#3). implement support for 3-digit MNC with leading zeros Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore) Change-Id: I8e722103344186fde118b26d8353db95a4581daa --- M include/osmocom/bsc/bsc_msc_data.h M include/osmocom/bsc/gsm_data.h M src/libbsc/bsc_ctrl_commands.c M src/libbsc/bsc_init.c M src/libbsc/bsc_vty.c M src/libbsc/gsm_data.c M src/libbsc/net_init.c M src/libbsc/pcu_sock.c M src/libbsc/system_information.c M src/osmo-bsc/osmo_bsc_api.c M src/osmo-bsc/osmo_bsc_bssap.c M src/osmo-bsc/osmo_bsc_ctrl.c M src/osmo-bsc/osmo_bsc_filter.c M src/osmo-bsc/osmo_bsc_msc.c M src/osmo-bsc/osmo_bsc_vty.c M tests/bssap/bssap_test.err M tests/nanobts_omlattr/nanobts_omlattr_test.c 17 files changed, 129 insertions(+), 136 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/68/6668/3 diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h index a3e0106..cbda10d 100644 --- a/include/osmocom/bsc/bsc_msc_data.h +++ b/include/osmocom/bsc/bsc_msc_data.h @@ -78,8 +78,9 @@ struct osmo_timer_list pong_timer; int advanced_ping; struct bsc_msc_connection *msc_con; - int core_mnc; - int core_mcc; + uint16_t core_mcc; + uint16_t core_mnc; + bool core_mnc_3_digits; int core_lac; int core_ci; int rtp_base; diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index a8d7a0b..a624610 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -1192,9 +1193,8 @@ * these have in common, like country and network code, put in yet * separate structs and placed as members in osmo_bsc and osmo_msc. */ - /* global parameters */ - uint16_t country_code; - uint16_t network_code; + struct osmo_plmn_id plmn; + /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ uint8_t a5_encryption_mask; int neci; @@ -1270,6 +1270,16 @@ } mgw; }; +static inline const struct osmo_location_area_id *bts_lai(struct gsm_bts *bts) +{ + static struct osmo_location_area_id lai; + lai = (struct osmo_location_area_id){ + .plmn = bts->network->plmn, + .lac = bts->location_area_code, + }; + return +} + extern void talloc_ctx_init(void *ctx_root); int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); diff --git a/src/libbsc/bsc_ctrl_commands.c b/src/libbsc/bsc_ctrl_commands.c index 41d2361..18fd26b 100644 --- a/src/libbsc/bsc_ctrl_commands.c +++ b/src/libbsc/bsc_ctrl_commands.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -30,8 +31,8 @@ #include #include -CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, network_code, 0, 999); -CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, country_code, 1, 999); +CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, plmn.mnc, 0, 999); +CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, plmn.mcc, 1, 999); static int set_net_apply_config(struct ctrl_cmd *cmd, void *data) { @@ -75,6 +76,10 @@ if (!mcc || !mnc) return 1; + + if (osmo_mnc_from_str(mnc, NULL, NULL)) + return 1; + return 0; } @@ -82,28 +87,29 @@ { struct gsm_network *net = cmd->node; char *tmp, *saveptr, *mcc_str, *mnc_str; - int mcc, mnc; + struct osmo_plmn_id plmn; tmp = talloc_strdup(cmd, cmd->value); if (!tmp) goto oom; - mcc_str = strtok_r(tmp, ",", ); mnc_str = strtok_r(NULL, ",", ); - mcc = atoi(mcc_str); - mnc = atoi(mnc_str); + plmn.mcc = atoi(mcc_str); + if (osmo_mnc_from_str(mnc_str, , _3_digits)) { + cmd->reply = "Error while decoding MNC"; + return CTRL_CMD_ERROR; + } talloc_free(tmp); - if (net->network_code == mnc && net->country_code == mcc) { + if (!osmo_plmn_cmp(>plmn, )) { cmd->reply = "Nothing changed"; return CTRL_CMD_REPLY; } - net->network_code = mnc; - net->country_code = mcc; + net->plmn = plmn; return set_net_apply_config(cmd, data); diff --git a/src/libbsc/bsc_init.c b/src/libbsc/bsc_init.c index df30a0f..7160977 100644 --- a/src/libbsc/bsc_init.c +++ b/src/libbsc/bsc_init.c @@ -326,9 +326,10 @@ unsigned int i; LOGP(DRSL, LOGL_NOTICE, "bootstrapping RSL for
osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Patch Set 2: Are there any ttcn3 tests for this? Seems like an ideal opportunity -- To view, visit https://gerrit.osmocom.org/6668 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8e722103344186fde118b26d8353db95a4581daa Gerrit-PatchSet: 2 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Neels HofmeyrGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[PATCH] osmo-bsc[master]: implement support for 3-digit MNC with leading zeros
Review at https://gerrit.osmocom.org/6668 implement support for 3-digit MNC with leading zeros Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore) Change-Id: I8e722103344186fde118b26d8353db95a4581daa --- M include/osmocom/bsc/bsc_msc_data.h M include/osmocom/bsc/gsm_data.h M src/libbsc/bsc_ctrl_commands.c M src/libbsc/bsc_init.c M src/libbsc/bsc_vty.c M src/libbsc/system_information.c M src/osmo-bsc/osmo_bsc_api.c M src/osmo-bsc/osmo_bsc_bssap.c M src/osmo-bsc/osmo_bsc_ctrl.c M src/osmo-bsc/osmo_bsc_filter.c M src/osmo-bsc/osmo_bsc_msc.c M src/osmo-bsc/osmo_bsc_vty.c M tests/bssap/bssap_test.err 13 files changed, 124 insertions(+), 65 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/68/6668/1 diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h index a3e0106..cbda10d 100644 --- a/include/osmocom/bsc/bsc_msc_data.h +++ b/include/osmocom/bsc/bsc_msc_data.h @@ -78,8 +78,9 @@ struct osmo_timer_list pong_timer; int advanced_ping; struct bsc_msc_connection *msc_con; - int core_mnc; - int core_mcc; + uint16_t core_mcc; + uint16_t core_mnc; + bool core_mnc_3_digits; int core_lac; int core_ci; int rtp_base; diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index a8d7a0b..8fc0901 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -1195,6 +1196,8 @@ /* global parameters */ uint16_t country_code; uint16_t network_code; + bool network_code_3_digits; + /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ uint8_t a5_encryption_mask; int neci; @@ -1270,6 +1273,11 @@ } mgw; }; +static inline const char *gsmnet_mcc_mnc_name(struct gsm_network *net) +{ + return osmo_mcc_mnc_name2(net->country_code, net->network_code, net->network_code_3_digits); +} + extern void talloc_ctx_init(void *ctx_root); int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); diff --git a/src/libbsc/bsc_ctrl_commands.c b/src/libbsc/bsc_ctrl_commands.c index 41d2361..cac3ba9 100644 --- a/src/libbsc/bsc_ctrl_commands.c +++ b/src/libbsc/bsc_ctrl_commands.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -75,6 +76,10 @@ if (!mcc || !mnc) return 1; + + if (gsm48_mnc_from_str(mnc, NULL, NULL)) + return 1; + return 0; } @@ -82,7 +87,8 @@ { struct gsm_network *net = cmd->node; char *tmp, *saveptr, *mcc_str, *mnc_str; - int mcc, mnc; + uint16_t mcc, mnc; + bool mnc_3_digits; tmp = talloc_strdup(cmd, cmd->value); if (!tmp) @@ -93,16 +99,22 @@ mnc_str = strtok_r(NULL, ",", ); mcc = atoi(mcc_str); - mnc = atoi(mnc_str); + if (gsm48_mnc_from_str(mnc_str, , _3_digits)) { + cmd->reply = "Error while decoding MNC"; + return CTRL_CMD_ERROR; + } talloc_free(tmp); - if (net->network_code == mnc && net->country_code == mcc) { + if (!gsm48_mnc_cmp(net->network_code, net->network_code_3_digits, + mnc, mnc_3_digits) + && net->country_code == mcc) { cmd->reply = "Nothing changed"; return CTRL_CMD_REPLY; } net->network_code = mnc; + net->network_code_3_digits = mnc_3_digits; net->country_code = mcc; return set_net_apply_config(cmd, data); diff --git a/src/libbsc/bsc_init.c b/src/libbsc/bsc_init.c index 2b1d53b..04a8ef5 100644 --- a/src/libbsc/bsc_init.c +++ b/src/libbsc/bsc_init.c @@ -326,9 +326,10 @@ unsigned int i; LOGP(DRSL, LOGL_NOTICE, "bootstrapping RSL for BTS/TRX (%u/%u) " - "on ARFCN %u using MCC=%u MNC=%u LAC=%u CID=%u BSIC=%u\n", - trx->bts->nr, trx->nr, trx->arfcn, bsc_gsmnet->country_code, - bsc_gsmnet->network_code, trx->bts->location_area_code, + "on ARFCN %u using MCC-MNC %s LAC=%u CID=%u BSIC=%u\n", + trx->bts->nr, trx->nr, trx->arfcn, + gsmnet_mcc_mnc_name(bsc_gsmnet), + trx->bts->location_area_code, trx->bts->cell_identity, trx->bts->bsic); if (trx->bts->type == GSM_BTS_TYPE_NOKIA_SITE) { diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c index 36c849d..1f13606 100644 --- a/src/libbsc/bsc_vty.c +++ b/src/libbsc/bsc_vty.c @@ -194,9 +194,8 @@ struct pchan_load pl; int i; - vty_out(vty, "BSC is on Country Code %u, Network Code %u