[PATCH] osmo-msc[master]: implement support for 3-digit MNC with leading zeros
Review at https://gerrit.osmocom.org/6671 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: I82f0016d9512ee8722a3489a3cb4b6c704a271fc --- M include/osmocom/msc/gsm_data.h M src/libcommon-cs/common_cs_vty.c M src/libmsc/a_iface_bssap.c M src/libmsc/gsm_04_08.c M src/libmsc/msc_vty.c M src/libvlr/vlr_lu_fsm.c M src/osmo-msc/msc_main.c 7 files changed, 27 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/71/6671/1 diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h index 67b657a..18f92af 100644 --- a/include/osmocom/msc/gsm_data.h +++ b/include/osmocom/msc/gsm_data.h @@ -226,6 +226,7 @@ /* global parameters */ uint16_t country_code; uint16_t network_code; + bool network_code_3_digits; char *name_long; char *name_short; /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ diff --git a/src/libcommon-cs/common_cs_vty.c b/src/libcommon-cs/common_cs_vty.c index 01c6b35..0d39e9c 100644 --- a/src/libcommon-cs/common_cs_vty.c +++ b/src/libcommon-cs/common_cs_vty.c @@ -75,8 +75,16 @@ "Mobile Network Code to use\n") { struct gsm_network *gsmnet = gsmnet_from_vty(vty); + uint16_t mnc; + bool mnc_3_digits; - gsmnet->network_code = atoi(argv[0]); + if (gsm48_mnc_from_str(argv[0], &mnc, &mnc_3_digits)) { + vty_out(vty, "%% Error decoding MNC: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + gsmnet->network_code = mnc; + gsmnet->network_code_3_digits = mnc_3_digits; return CMD_SUCCESS; } diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c index 224c5c9..37a4255 100644 --- a/src/libmsc/a_iface_bssap.c +++ b/src/libmsc/a_iface_bssap.c @@ -265,6 +265,7 @@ } __attribute__ ((packed)) lai_ci; uint16_t mcc; uint16_t mnc; + bool mnc_3_digits; uint16_t lac; uint8_t data_length; const uint8_t *data; @@ -301,11 +302,12 @@ "Unable to parse element CELL IDENTIFIER (wrong cell identification discriminator) -- discarding message!\n"); return -EINVAL; } - if (gsm48_decode_lai(&lai_ci.lai, &mcc, &mnc, &lac) != 0) { + if (gsm48_decode_lai2(&lai_ci.lai, &mcc, &mnc, &mnc_3_digits, &lac) != 0) { LOGP(DBSSAP, LOGL_ERROR, "Unable to parse element CELL IDENTIFIER (lai decoding failed) -- discarding message!\n"); return -EINVAL; } + /* FIXME: Actually compare the MCC-MNC to the local network config?? */ /* Parse Layer 3 Information element */ msg->l3h = (uint8_t*)TLVP_VAL(tp, GSM0808_IE_LAYER_3_INFORMATION); diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c index b928171..0a61c09 100644 --- a/src/libmsc/gsm_04_08.c +++ b/src/libmsc/gsm_04_08.c @@ -228,9 +228,9 @@ gh->msg_type = GSM48_MT_MM_LOC_UPD_ACCEPT; lai = (struct gsm48_loc_area_id *) msgb_put(msg, sizeof(*lai)); - gsm48_generate_lai(lai, conn->network->country_code, - conn->network->network_code, - conn->lac); + gsm48_generate_lai2(lai, conn->network->country_code, + conn->network->network_code, conn->network->network_code_3_digits, + conn->lac); if (send_tmsi == GSM_RESERVED_TMSI) { /* we did not allocate a TMSI to the MS, so we need to @@ -381,10 +381,11 @@ break; } - gsm48_decode_lai(&lu->lai, &old_lai.plmn.mcc, -&old_lai.plmn.mnc, &old_lai.lac); + gsm48_decode_lai2(&lu->lai, &old_lai.plmn.mcc, + &old_lai.plmn.mnc, &old_lai.plmn.mnc_3_digits, &old_lai.lac); new_lai.plmn.mcc = conn->network->country_code; new_lai.plmn.mnc = conn->network->network_code; + new_lai.plmn.mnc_3_digits = conn->network->network_code_3_digits; new_lai.lac = conn->lac; DEBUGP(DMM, "LU/new-LAC: %u/%u\n", old_lai.lac, new_lai.lac); @@ -703,6 +704,7 @@ lai.plmn.mcc = conn->network->country_code; lai.plmn.mnc = conn->network->network_code; + lai.plmn.mnc_3_digits = conn->network->network_code_3_digits; lai.lac = conn->lac; DEBUGP(DMM, "<- CM SERVICE REQUEST "); @@ -1154,6 +1156,7 @@ lai.plmn.mcc = conn->network->country_code; lai.plmn.mnc = conn->network->network_code; + lai.plmn.mnc_3_digits = conn->network->network_code_3_digits; lai.lac = conn->lac; resp = (struct gsm48_pa
[PATCH] osmo-msc[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/6671 to look at the new patch set (#2). 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: I82f0016d9512ee8722a3489a3cb4b6c704a271fc --- M include/osmocom/msc/gsm_data.h M src/libcommon-cs/common_cs_vty.c M src/libmsc/a_iface_bssap.c M src/libmsc/gsm_04_08.c M src/libmsc/msc_vty.c M src/libvlr/vlr_lu_fsm.c M src/osmo-msc/msc_main.c 7 files changed, 32 insertions(+), 29 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/71/6671/2 diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h index 67b657a..18f92af 100644 --- a/include/osmocom/msc/gsm_data.h +++ b/include/osmocom/msc/gsm_data.h @@ -226,6 +226,7 @@ /* global parameters */ uint16_t country_code; uint16_t network_code; + bool network_code_3_digits; char *name_long; char *name_short; /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ diff --git a/src/libcommon-cs/common_cs_vty.c b/src/libcommon-cs/common_cs_vty.c index 01c6b35..97795bd 100644 --- a/src/libcommon-cs/common_cs_vty.c +++ b/src/libcommon-cs/common_cs_vty.c @@ -75,8 +75,16 @@ "Mobile Network Code to use\n") { struct gsm_network *gsmnet = gsmnet_from_vty(vty); + uint16_t mnc; + bool mnc_3_digits; - gsmnet->network_code = atoi(argv[0]); + 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; + } + + gsmnet->network_code = mnc; + gsmnet->network_code_3_digits = mnc_3_digits; return CMD_SUCCESS; } diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c index 224c5c9..d281c0b 100644 --- a/src/libmsc/a_iface_bssap.c +++ b/src/libmsc/a_iface_bssap.c @@ -263,9 +263,7 @@ struct gsm48_loc_area_id lai; uint16_t ci; } __attribute__ ((packed)) lai_ci; - uint16_t mcc; - uint16_t mnc; - uint16_t lac; + struct osmo_location_area_id lai; uint8_t data_length; const uint8_t *data; int rc; @@ -301,18 +299,15 @@ "Unable to parse element CELL IDENTIFIER (wrong cell identification discriminator) -- discarding message!\n"); return -EINVAL; } - if (gsm48_decode_lai(&lai_ci.lai, &mcc, &mnc, &lac) != 0) { - LOGP(DBSSAP, LOGL_ERROR, -"Unable to parse element CELL IDENTIFIER (lai decoding failed) -- discarding message!\n"); - return -EINVAL; - } + osmo_decode_lai(&lai_ci.lai, &lai); + /* FIXME: Actually compare the MCC-MNC to the local network config?? */ /* Parse Layer 3 Information element */ msg->l3h = (uint8_t*)TLVP_VAL(tp, GSM0808_IE_LAYER_3_INFORMATION); msgb_l3trim(msg, TLVP_LEN(tp, GSM0808_IE_LAYER_3_INFORMATION)); /* Create new subscriber context */ - conn = subscr_conn_allocate_a(a_conn_info, network, lac, scu, a_conn_info->conn_id); + conn = subscr_conn_allocate_a(a_conn_info, network, lai.lac, scu, a_conn_info->conn_id); /* Handover location update to the MSC code */ rc = msc_compl_l3(conn, msg, 0); diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c index b928171..681c6f6 100644 --- a/src/libmsc/gsm_04_08.c +++ b/src/libmsc/gsm_04_08.c @@ -222,15 +222,21 @@ struct gsm48_hdr *gh; struct gsm48_loc_area_id *lai; uint8_t *mid; + struct osmo_location_area_id laid = { + .plmn = { + .mcc = conn->network->country_code, + .mnc = conn->network->network_code, + .mnc_3_digits = conn->network->network_code_3_digits, + }, + .lac = conn->lac, + }; gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh)); gh->proto_discr = GSM48_PDISC_MM; gh->msg_type = GSM48_MT_MM_LOC_UPD_ACCEPT; lai = (struct gsm48_loc_area_id *) msgb_put(msg, sizeof(*lai)); - gsm48_generate_lai(lai, conn->network->country_code, - conn->network->network_code, - conn->lac); + osmo_generate_lai(lai, &laid); if (send_tmsi == GSM_RESERVED_TMSI) { /* we did not allocate a TMSI to the MS, so we need to @@ -381,10 +387,10 @@ break; } - gsm48_decode_lai(&lu->lai, &old_lai.plmn.mcc, -&old_lai.plmn.mnc, &old_lai.lac); + osmo_decode_
[PATCH] osmo-msc[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/6671 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: I82f0016d9512ee8722a3489a3cb4b6c704a271fc --- M include/osmocom/msc/gsm_data.h M src/libcommon-cs/common_cs.c M src/libcommon-cs/common_cs_vty.c M src/libmsc/a_iface_bssap.c M src/libmsc/gsm_04_08.c M src/libmsc/msc_vty.c M src/libvlr/vlr_lu_fsm.c M src/osmo-msc/msc_main.c 8 files changed, 33 insertions(+), 41 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/71/6671/3 diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h index 67b657a..2d1d20c 100644 --- a/include/osmocom/msc/gsm_data.h +++ b/include/osmocom/msc/gsm_data.h @@ -223,11 +223,11 @@ * 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; + char *name_long; char *name_short; + /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ uint8_t a5_encryption_mask; bool authentication_required; diff --git a/src/libcommon-cs/common_cs.c b/src/libcommon-cs/common_cs.c index c64719b..a1d2298 100644 --- a/src/libcommon-cs/common_cs.c +++ b/src/libcommon-cs/common_cs.c @@ -45,8 +45,8 @@ if (!net) return NULL; - net->country_code = 1; - net->network_code = 1; + net->plmn = (struct osmo_plmn_id){ .mcc=1, .mnc=1 }; + /* Permit a compile-time default of A5/3 and A5/1 */ net->a5_encryption_mask = (1 << 3) | (1 << 1); diff --git a/src/libcommon-cs/common_cs_vty.c b/src/libcommon-cs/common_cs_vty.c index 01c6b35..d59f31c 100644 --- a/src/libcommon-cs/common_cs_vty.c +++ b/src/libcommon-cs/common_cs_vty.c @@ -61,7 +61,7 @@ { struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->country_code = atoi(argv[0]); + gsmnet->plmn.mcc = atoi(argv[0]); return CMD_SUCCESS; } @@ -75,8 +75,16 @@ "Mobile Network Code to use\n") { struct gsm_network *gsmnet = gsmnet_from_vty(vty); + uint16_t mnc; + bool mnc_3_digits; - gsmnet->network_code = atoi(argv[0]); + 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; + } + + gsmnet->plmn.mnc = mnc; + gsmnet->plmn.mnc_3_digits = mnc_3_digits; return CMD_SUCCESS; } diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c index 224c5c9..7b86764 100644 --- a/src/libmsc/a_iface_bssap.c +++ b/src/libmsc/a_iface_bssap.c @@ -263,9 +263,7 @@ struct gsm48_loc_area_id lai; uint16_t ci; } __attribute__ ((packed)) lai_ci; - uint16_t mcc; - uint16_t mnc; - uint16_t lac; + struct osmo_location_area_id lai; uint8_t data_length; const uint8_t *data; int rc; @@ -301,18 +299,15 @@ "Unable to parse element CELL IDENTIFIER (wrong cell identification discriminator) -- discarding message!\n"); return -EINVAL; } - if (gsm48_decode_lai(&lai_ci.lai, &mcc, &mnc, &lac) != 0) { - LOGP(DBSSAP, LOGL_ERROR, -"Unable to parse element CELL IDENTIFIER (lai decoding failed) -- discarding message!\n"); - return -EINVAL; - } + gsm48_decode_lai2(&lai_ci.lai, &lai); + /* FIXME: Actually compare the MCC-MNC to the local network config?? */ /* Parse Layer 3 Information element */ msg->l3h = (uint8_t*)TLVP_VAL(tp, GSM0808_IE_LAYER_3_INFORMATION); msgb_l3trim(msg, TLVP_LEN(tp, GSM0808_IE_LAYER_3_INFORMATION)); /* Create new subscriber context */ - conn = subscr_conn_allocate_a(a_conn_info, network, lac, scu, a_conn_info->conn_id); + conn = subscr_conn_allocate_a(a_conn_info, network, lai.lac, scu, a_conn_info->conn_id); /* Handover location update to the MSC code */ rc = msc_compl_l3(conn, msg, 0); diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c index b928171..18f8412 100644 --- a/src/libmsc/gsm_04_08.c +++ b/src/libmsc/gsm_04_08.c @@ -222,15 +222,17 @@ struct gsm48_hdr *gh; struct gsm48_loc_area_id *lai; uint8_t *mid; + struct osmo_location_area_id laid = { + .plmn = conn->network->plmn, + .la