diff options
Diffstat (limited to 'openbsc/src/osmo-bsc')
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_api.c | 47 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_ctrl.c | 7 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_filter.c | 16 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_msc.c | 6 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_vty.c | 30 |
5 files changed, 47 insertions, 59 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c index bac5e4717..25d48c399 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_api.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c @@ -51,32 +51,20 @@ static int bsc_clear_request(struct gsm_subscriber_connection *conn, uint32_t ca static int complete_layer3(struct gsm_subscriber_connection *conn, struct msgb *msg, struct bsc_msc_data *msc); -static uint16_t get_network_code_for_msc(struct bsc_msc_data *msc) +static struct osmo_cell_global_id *cgi_for_msc(struct bsc_msc_data *msc, struct gsm_bts *bts) { - if (msc->core_mnc != -1) - return msc->core_mnc; - return msc->network->network_code; -} - -static uint16_t get_country_code_for_msc(struct bsc_msc_data *msc) -{ - if (msc->core_mcc != -1) - return msc->core_mcc; - return msc->network->country_code; -} - -static uint16_t get_lac_for_msc(struct bsc_msc_data *msc, struct gsm_bts *bts) -{ - if (msc->core_lac != -1) - return msc->core_lac; - return bts->location_area_code; -} + static struct osmo_cell_global_id cgi; + cgi.lai.plmn = msc->network->plmn; + if (msc->core_plmn.mcc != GSM_MCC_MNC_INVALID) + cgi.lai.plmn.mcc = msc->core_plmn.mcc; + if (msc->core_plmn.mnc != GSM_MCC_MNC_INVALID) { + cgi.lai.plmn.mnc = msc->core_plmn.mnc; + cgi.lai.plmn.mnc_3_digits = msc->core_plmn.mnc_3_digits; + } + cgi.lai.lac = (msc->core_lac != -1) ? msc->core_lac : bts->location_area_code; + cgi.cell_identity = (msc->core_ci != -1) ? msc->core_ci : bts->cell_identity; -static uint16_t get_ci_for_msc(struct bsc_msc_data *msc, struct gsm_bts *bts) -{ - if (msc->core_ci != -1) - return msc->core_ci; - return bts->cell_identity; + return &cgi; } static void bsc_maybe_lu_reject(struct gsm_subscriber_connection *conn, int con_type, int cause) @@ -239,10 +227,6 @@ static int complete_layer3(struct gsm_subscriber_connection *conn, char *imsi = NULL; struct timeval tv; struct msgb *resp; - uint16_t network_code; - uint16_t country_code; - uint16_t lac; - uint16_t ci; enum bsc_con ret; int send_ping = msc->advanced_ping; @@ -281,14 +265,9 @@ static int complete_layer3(struct gsm_subscriber_connection *conn, /* check return value, if failed check msg for and send USSD */ - network_code = get_network_code_for_msc(conn->sccp_con->msc); - country_code = get_country_code_for_msc(conn->sccp_con->msc); - lac = get_lac_for_msc(conn->sccp_con->msc, conn->bts); - ci = get_ci_for_msc(conn->sccp_con->msc, conn->bts); - bsc_scan_bts_msg(conn, msg); - resp = gsm0808_create_layer3(msg, network_code, country_code, lac, ci); + resp = gsm0808_create_layer3_2(msg, cgi_for_msc(conn->sccp_con->msc, conn->bts), NULL); if (!resp) { LOGP(DMSC, LOGL_DEBUG, "Failed to create layer3 message.\n"); sccp_connection_free(conn->sccp_con->sccp); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c index 423ed3458..54f2e0dd4 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c @@ -186,10 +186,11 @@ static void generate_location_state_trap(struct gsm_bts *bts, struct bsc_msc_con policy = osmo_bsc_rf_get_policy_name(osmo_bsc_rf_get_policy_by_bts(bts)); cmd->reply = talloc_asprintf_append(cmd->reply, - ",%s,%s,%s,%d,%d", + ",%s,%s,%s,%s,%s", oper, admin, policy, - bts->network->country_code, - bts->network->network_code); + osmo_mcc_name(bts->network->plmn.mcc), + osmo_mnc_name(bts->network->plmn.mnc, + bts->network->plmn.mnc_3_digits)); osmo_bsc_send_trap(cmd, msc_con); talloc_free(cmd); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index 2c84b169f..0c4b3e343 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -33,20 +33,16 @@ static void handle_lu_request(struct gsm_subscriber_connection *conn, struct gsm48_hdr *gh; struct gsm48_loc_upd_req *lu; struct gsm48_loc_area_id lai; - struct gsm_network *net; if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*lu)) { LOGP(DMSC, LOGL_ERROR, "LU too small to look at: %u\n", msgb_l3len(msg)); return; } - net = conn->bts->network; - gh = msgb_l3(msg); lu = (struct gsm48_loc_upd_req *) gh->data; - gsm48_generate_lai(&lai, net->country_code, net->network_code, - conn->bts->location_area_code); + gsm48_generate_lai2(&lai, bts_lai(conn->bts)); if (memcmp(&lai, &lu->lai, sizeof(lai)) != 0) { LOGP(DMSC, LOGL_DEBUG, "Marking con for welcome USSD.\n"); @@ -319,9 +315,9 @@ static int bsc_patch_mm_info(struct gsm_subscriber_connection *conn, static int has_core_identity(struct bsc_msc_data *msc) { - if (msc->core_mnc != -1) + if (msc->core_plmn.mnc != GSM_MCC_MNC_INVALID) return 1; - if (msc->core_mcc != -1) + if (msc->core_plmn.mcc != GSM_MCC_MNC_INVALID) return 1; if (msc->core_lac != -1) return 1; @@ -336,7 +332,6 @@ static int has_core_identity(struct bsc_msc_data *msc) int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct bsc_msc_data *msc; - struct gsm_network *net; struct gsm48_loc_area_id *lai; struct gsm48_hdr *gh; uint8_t pdisc; @@ -356,7 +351,6 @@ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) return 0; mtype = gsm48_hdr_msg_type(gh); - net = conn->bts->network; msc = conn->sccp_con->msc; if (mtype == GSM48_MT_MM_LOC_UPD_ACCEPT) { @@ -364,9 +358,7 @@ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) if (msgb_l3len(msg) >= sizeof(*gh) + sizeof(*lai)) { /* overwrite LAI in the message */ lai = (struct gsm48_loc_area_id *) &gh->data[0]; - gsm48_generate_lai(lai, net->country_code, - net->network_code, - conn->bts->location_area_code); + gsm48_generate_lai2(lai, bts_lai(conn->bts)); } } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c index 8d02624b4..b2f8806ae 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c @@ -570,8 +570,10 @@ struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *net, int nr) INIT_LLIST_HEAD(&msc_data->dests); msc_data->ping_timeout = 20; msc_data->pong_timeout = 5; - msc_data->core_mnc = -1; - msc_data->core_mcc = -1; + msc_data->core_plmn = (struct osmo_plmn_id){ + .mcc = GSM_MCC_MNC_INVALID, + .mnc = GSM_MCC_MNC_INVALID, + }; msc_data->core_ci = -1; msc_data->core_lac = -1; msc_data->rtp_base = 4000; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 7bb123dcf..e124b31fc 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -27,6 +27,7 @@ #include <openbsc/bsc_msg_filter.h> #include <osmocom/core/talloc.h> +#include <osmocom/gsm/gsm48.h> #include <osmocom/vty/logging.h> #include <time.h> @@ -110,12 +111,12 @@ static void write_msc(struct vty *vty, struct bsc_msc_data *msc) if (msc->bsc_key_present) vty_out(vty, " auth-key %s%s", osmo_hexdump(msc->bsc_key, sizeof(msc->bsc_key)), VTY_NEWLINE); - if (msc->core_mnc != -1) - vty_out(vty, " core-mobile-network-code %d%s", - msc->core_mnc, VTY_NEWLINE); - if (msc->core_mcc != -1) - vty_out(vty, " core-mobile-country-code %d%s", - msc->core_mcc, VTY_NEWLINE); + if (msc->core_plmn.mnc != GSM_MCC_MNC_INVALID) + vty_out(vty, " core-mobile-network-code %s%s", + osmo_mnc_name(msc->core_plmn.mnc, msc->core_plmn.mnc_3_digits), VTY_NEWLINE); + if (msc->core_plmn.mcc != GSM_MCC_MNC_INVALID) + vty_out(vty, " core-mobile-country-code %s%s", + osmo_mcc_name(msc->core_plmn.mcc), VTY_NEWLINE); if (msc->core_lac != -1) vty_out(vty, " core-location-area-code %d%s", msc->core_lac, VTY_NEWLINE); @@ -264,7 +265,15 @@ DEFUN(cfg_net_bsc_ncc, "Use this network code for the core network\n" "MNC value\n") { struct bsc_msc_data *data = bsc_msc_data(vty); - data->core_mnc = atoi(argv[0]); + uint16_t mnc; + bool mnc_3_digits; + + if (osmo_mnc_from_str(argv[0], &mnc, &mnc_3_digits)) { + vty_out(vty, "%% Error decoding MNC: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + data->core_plmn.mnc = mnc; + data->core_plmn.mnc_3_digits = mnc_3_digits; return CMD_SUCCESS; } @@ -273,8 +282,13 @@ DEFUN(cfg_net_bsc_mcc, "core-mobile-country-code <1-999>", "Use this country code for the core network\n" "MCC value\n") { + uint16_t mcc; struct bsc_msc_data *data = bsc_msc_data(vty); - data->core_mcc = atoi(argv[0]); + if (osmo_mcc_from_str(argv[0], &mcc)) { + vty_out(vty, "%% Error decoding MCC: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + data->core_plmn.mcc = mcc; return CMD_SUCCESS; } |