gerrit-log
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
May 2023
- 1 participants
- 2583 discussions
22 May '23
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/32913 )
Change subject: unbloat: drop context_map_check_released()
......................................................................
unbloat: drop context_map_check_released()
When I implemented it, I thought context_map_check_released() would help
clarify context map deallocation, but instead it just bloats. Simplify
and tweak related comment.
Change-Id: I535780de0d3b09893ba89d66804e5e36b26db049
---
M include/osmocom/hnbgw/context_map.h
M src/osmo-hnbgw/context_map.c
M src/osmo-hnbgw/context_map_rua.c
M src/osmo-hnbgw/context_map_sccp.c
4 files changed, 22 insertions(+), 18 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/13/32913/1
diff --git a/include/osmocom/hnbgw/context_map.h b/include/osmocom/hnbgw/context_map.h
index 2b60958..a2e76c3 100644
--- a/include/osmocom/hnbgw/context_map.h
+++ b/include/osmocom/hnbgw/context_map.h
@@ -156,6 +156,6 @@
bool map_rua_is_active(struct hnbgw_context_map *map);
bool map_sccp_is_active(struct hnbgw_context_map *map);
-void context_map_check_released(struct hnbgw_context_map *map);
+void context_map_free(struct hnbgw_context_map *map);
unsigned int msg_has_l2_data(const struct msgb *msg);
diff --git a/src/osmo-hnbgw/context_map.c b/src/osmo-hnbgw/context_map.c
index c9507be..f610087 100644
--- a/src/osmo-hnbgw/context_map.c
+++ b/src/osmo-hnbgw/context_map.c
@@ -247,12 +247,3 @@
LOG_MAP(map, DMAIN, LOGL_INFO, "Deallocating\n");
talloc_free(map);
}
-
-void context_map_check_released(struct hnbgw_context_map *map)
-{
- if (map_rua_is_active(map) || map_sccp_is_active(map)) {
- /* still active, do not release yet. */
- return;
- }
- context_map_free(map);
-}
diff --git a/src/osmo-hnbgw/context_map_rua.c b/src/osmo-hnbgw/context_map_rua.c
index 5a715c4..f50f711 100644
--- a/src/osmo-hnbgw/context_map_rua.c
+++ b/src/osmo-hnbgw/context_map_rua.c
@@ -294,13 +294,13 @@
static void map_rua_disconnected_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
struct hnbgw_context_map *map = fi->priv;
- /* For sanity, always tell SCCP to disconnect, if it hasn't done so. Dispatching MAP_SCCP_EV_RAN_DISC may send
- * SCCP into MAP_RUA_ST_DISCONNECTED, which calls context_map_check_released() and frees the hnbgw_context_map,
- * so don't free it a second time. If SCCP stays active, calling context_map_check_released() has no effect. */
+ /* From RUA's POV, we can now free the hnbgw_context_map.
+ * If SCCP is still active, tell it to disconnect -- in that case the SCCP side will call context_map_free().
+ * If SCCP is no longer active, free this map. */
if (map_sccp_is_active(map))
map_sccp_dispatch(map, MAP_SCCP_EV_RAN_DISC, NULL);
else
- context_map_check_released(map);
+ context_map_free(map);
}
static void map_rua_disconnected_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
diff --git a/src/osmo-hnbgw/context_map_sccp.c b/src/osmo-hnbgw/context_map_sccp.c
index 8e04fba..132d03e 100644
--- a/src/osmo-hnbgw/context_map_sccp.c
+++ b/src/osmo-hnbgw/context_map_sccp.c
@@ -419,13 +419,13 @@
static void map_sccp_disconnected_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
struct hnbgw_context_map *map = fi->priv;
- /* For sanity, always tell RUA to disconnect, if it hasn't done so. Dispatching MAP_RUA_EV_CN_DISC may send
- * RUA into MAP_RUA_ST_DISCONNECTED, which calls context_map_check_released() and frees the hnbgw_context_map,
- * so don't free it a second time. If RUA stays active, calling context_map_check_released() has no effect. */
+ /* From SCCP's POV, we can now free the hnbgw_context_map.
+ * If RUA is still active, tell it to disconnect -- in that case the RUA side will call context_map_free().
+ * If RUA is no longer active, free this map. */
if (map_rua_is_active(map))
map_rua_dispatch(map, MAP_RUA_EV_CN_DISC, NULL);
else
- context_map_check_released(map);
+ context_map_free(map);
}
static void map_sccp_disconnected_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/32913
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I535780de0d3b09893ba89d66804e5e36b26db049
Gerrit-Change-Number: 32913
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: newchange
1
0
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/32911 )
Change subject: drop dead code: cnlink.T_RafC
......................................................................
drop dead code: cnlink.T_RafC
This looks like working RANAP RESET handling, but is in fact dead code.
Instead of testing and completing this implementation, I will copy the
RESET handling FSM from osmo-bsc, which is proven to work well.
See Id3eefdea889a736fd5957b80280fa45b9547b792
"detect in/active CN links by RANAP RESET"
The future patch will start to use transmit_rst(). So instead of
dropping now and resurrecting later, let's keep the code -- but it has
to be '#if 0'-ed to avoid compiler complaints about the unused function.
Related: SYS#6412
Change-Id: I7cacaec631051cf5420202f2f0dd9665a5565b17
---
M include/osmocom/hnbgw/hnbgw.h
M src/osmo-hnbgw/hnbgw_cn.c
2 files changed, 28 insertions(+), 55 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/11/32911/1
diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index e3ec38b..e67a86a 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -61,24 +61,9 @@
uint32_t cid; /*!< Cell ID */
};
-enum hnbgw_cnlink_state {
- /* we have just been initialized or were disconnected */
- CNLINK_S_NULL,
- /* establishment of the SUA/SCCP link is pending */
- CNLINK_S_EST_PEND,
- /* establishment of the SUA/SCCP link was confirmed */
- CNLINK_S_EST_CONF,
- /* we have esnt the RANAP RESET and wait for the ACK */
- CNLINK_S_EST_RST_TX_WAIT_ACK,
- /* we have received the RANAP RESET ACK and are active */
- CNLINK_S_EST_ACTIVE,
-};
-
struct hnbgw_cnlink {
struct llist_head list;
- enum hnbgw_cnlink_state state;
- /* timer for re-transmitting the RANAP Reset */
- struct osmo_timer_list T_RafC;
+
/* reference to the SCCP User SAP by which we communicate */
struct osmo_sccp_instance *sccp;
struct osmo_sccp_user *sccp_user;
diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c
index a256b24..3e95528 100644
--- a/src/osmo-hnbgw/hnbgw_cn.c
+++ b/src/osmo-hnbgw/hnbgw_cn.c
@@ -37,14 +37,9 @@
#include <osmocom/ranap/ranap_msg_factory.h>
#include <osmocom/hnbgw/context_map.h>
-/***********************************************************************
- * Outbound RANAP RESET to CN
- ***********************************************************************/
-
-void hnbgw_cnlink_change_state(struct hnbgw_cnlink *cnlink, enum hnbgw_cnlink_state state);
-
-static int transmit_rst(RANAP_CN_DomainIndicator_t domain,
- struct osmo_sccp_addr *remote_addr)
+#if 0
+-- this code will soon move to new file cnlink.c --
+static int transmit_rst(struct hnbgw_cnlink *cnlink)
{
struct msgb *msg;
RANAP_Cause_t cause = {
@@ -63,6 +58,7 @@
remote_addr,
msg);
}
+#endif
static int transmit_reset_ack(RANAP_CN_DomainIndicator_t domain,
const struct osmo_sccp_addr *remote_addr)
@@ -81,35 +77,6 @@
msg);
}
-/* Timer callback once T_RafC expires */
-static void cnlink_trafc_cb(void *unused)
-{
- transmit_rst(RANAP_CN_DomainIndicator_cs_domain, &g_hnbgw->sccp.iucs_remote_addr);
- transmit_rst(RANAP_CN_DomainIndicator_ps_domain, &g_hnbgw->sccp.iups_remote_addr);
- hnbgw_cnlink_change_state(g_hnbgw->sccp.cnlink, CNLINK_S_EST_RST_TX_WAIT_ACK);
- /* The spec states that we should abandon after a configurable
- * number of times. We decide to simply continue trying */
-}
-
-/* change the state of a CN Link */
-void hnbgw_cnlink_change_state(struct hnbgw_cnlink *cnlink, enum hnbgw_cnlink_state state)
-{
- switch (state) {
- case CNLINK_S_NULL:
- case CNLINK_S_EST_PEND:
- break;
- case CNLINK_S_EST_CONF:
- cnlink_trafc_cb(NULL);
- break;
- case CNLINK_S_EST_RST_TX_WAIT_ACK:
- osmo_timer_schedule(&cnlink->T_RafC, 5, 0);
- break;
- case CNLINK_S_EST_ACTIVE:
- osmo_timer_del(&cnlink->T_RafC);
- break;
- }
-}
-
/***********************************************************************
* Incoming primitives from SCCP User SAP
***********************************************************************/
@@ -148,7 +115,8 @@
rc = ranap_decode_resetacknowledgeies(&ies, &omsg->value);
- hnbgw_cnlink_change_state(cnlink, CNLINK_S_EST_ACTIVE);
+ /* FUTURE: will do something useful in commit 'detect in/active CN links by RANAP RESET'
+ * Id3eefdea889a736fd5957b80280fa45b9547b792 */
ranap_free_resetacknowledgeies(&ies);
return rc;
@@ -527,7 +495,6 @@
cnlink = talloc_zero(g_hnbgw, struct hnbgw_cnlink);
INIT_LLIST_HEAD(&cnlink->map_list);
- cnlink->T_RafC.cb = cnlink_trafc_cb;
cnlink->next_conn_id = 1000;
cnlink->sccp_user = osmo_sccp_user_bind_pc(g_hnbgw->sccp.client, "OsmoHNBGW", sccp_sap_up,
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/32911
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I7cacaec631051cf5420202f2f0dd9665a5565b17
Gerrit-Change-Number: 32911
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: newchange
1
0
22 May '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32910 )
Change subject: gmm: Initial implementation of T3312
......................................................................
gmm: Initial implementation of T3312
The RAU procedure triggered by T3312 expiration will be implemented
in a follow-up patch.
Change-Id: If1ca164b7a6c7f7750e2e2f0812d6fde828ed4a4
---
M include/osmocom/gprs/gmm/gmm_private.h
M src/gmm/gmm.c
M src/gmm/gmm_ms_fsm.c
3 files changed, 86 insertions(+), 10 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-gprs refs/changes/10/32910/1
diff --git a/include/osmocom/gprs/gmm/gmm_private.h b/include/osmocom/gprs/gmm/gmm_private.h
index 0ae4df4..daa967f 100644
--- a/include/osmocom/gprs/gmm/gmm_private.h
+++ b/include/osmocom/gprs/gmm/gmm_private.h
@@ -66,7 +66,6 @@
char imei[GSM23003_IMEI_NUM_DIGITS + 1];
char imeisv[GSM23003_IMEISV_NUM_DIGITS+1];
- uint8_t ra_upd_timer; /* TS 24.008 10.5.7.3 */
uint8_t radio_prio; /* TS 24.008 10.5.7.2 */
struct gprs_ra_id ra; /* TS 24.008 10.5.5.15 (decoded) */
@@ -87,6 +86,8 @@
/* READY timer, TS 24.008 4.7.2.1.1 */
struct osmo_timer_list t3314;
unsigned long t3314_assigned_sec; /* value assigned by the network */
+ struct osmo_timer_list t3312; /* periodic RAU, in seconds */
+ unsigned long t3312_assigned_sec; /* value assigned by the network */
};
/* gmm_prim.c: */
@@ -116,6 +117,8 @@
void gprs_gmm_gmme_ready_timer_start(struct gprs_gmm_entity *gmme);
void gprs_gmm_gmme_ready_timer_stop(struct gprs_gmm_entity *gmme);
bool gprs_gmm_gmme_ready_timer_running(const struct gprs_gmm_entity *gmme);
+void gprs_gmm_gmme_t3312_start(struct gprs_gmm_entity *gmme);
+void gprs_gmm_gmme_t3312_stop(struct gprs_gmm_entity *gmme);
int gprs_gmm_rx(struct gprs_gmm_entity *gmme, struct gsm48_hdr *gh, unsigned int len);
int gprs_gmm_tx_att_req(struct gprs_gmm_entity *gmme,
enum osmo_gprs_gmm_attach_type attach_type,
diff --git a/src/gmm/gmm.c b/src/gmm/gmm.c
index 5a3b0c0..6184a01 100644
--- a/src/gmm/gmm.c
+++ b/src/gmm/gmm.c
@@ -79,6 +79,7 @@
};
static void t3314_ready_timer_cb(void *data);
+static void t3312_periodic_rau_timer_cb(void *data);
static void gprs_gmm_ctx_free(void)
{
@@ -176,6 +177,7 @@
gmme->t3346 = osmo_tdef_get(g_gmm_ctx->T_defs, 3346, OSMO_TDEF_S, -1);
osmo_timer_setup(&gmme->t3314, t3314_ready_timer_cb, gmme);
+ osmo_timer_setup(&gmme->t3312, t3312_periodic_rau_timer_cb, gmme);
llist_add(&gmme->list, &g_gmm_ctx->gmme_list);
@@ -190,6 +192,8 @@
LOGGMME(gmme, LOGL_DEBUG, "free()\n");
if (osmo_timer_pending(&gmme->t3314))
osmo_timer_del(&gmme->t3314);
+ if (osmo_timer_pending(&gmme->t3312))
+ osmo_timer_del(&gmme->t3312);
gprs_gmm_ms_fsm_ctx_release(&gmme->ms_fsm);
llist_del(&gmme->list);
talloc_free(gmme);
@@ -295,20 +299,23 @@
LOGGMME(gmme, LOGL_INFO, "READY timer started\n");
osmo_timer_schedule(&gmme->t3314, gmme->t3314_assigned_sec, 0);
- /* TODO: "Timer T3312 is stopped and shall be set to its initial value
- * for the next start when the READY timer is started." */
+ /* "Timer T3312 is stopped and shall be set to its initial value
+ * for the next start when the READY timer is started.": */
+ gprs_gmm_gmme_t3312_stop(gmme);
}
/* Ready timer is stopped: */
void gprs_gmm_gmme_ready_timer_stop(struct gprs_gmm_entity *gmme)
{
- /* TODO: "In A/Gb mode, the timer T3312 is reset and started with its
- * initial value, when the READY timer is stopped or expires."
- */
if (!osmo_timer_pending(&gmme->t3314))
return;
LOGGMME(gmme, LOGL_INFO, "READY timer stopped\n");
osmo_timer_del(&gmme->t3314);
+
+ /* "In A/Gb mode, the timer T3312 is reset and started with its
+ * initial value, when the READY timer is stopped or expires."
+ */
+ gprs_gmm_gmme_t3312_start(gmme);
}
bool gprs_gmm_gmme_ready_timer_running(const struct gprs_gmm_entity *gmme)
@@ -325,10 +332,54 @@
struct gprs_gmm_entity *gmme = (struct gprs_gmm_entity *)data;
LOGGMME(gmme, LOGL_INFO, "READY timer expired\n");
- /* TODO: "In A/Gb mode, the timer T3312 is reset and started with its
- *initial value, when the READY timer is stopped or expires."
+ /* "In A/Gb mode, the timer T3312 is reset and started with its
+ * initial value, when the READY timer is stopped or expires.":
*/
+ gprs_gmm_gmme_t3312_start(gmme);
+}
+/* T3312 (Periodic RAU) is started: */
+void gprs_gmm_gmme_t3312_start(struct gprs_gmm_entity *gmme)
+{
+ unsigned long t3312_sec;
+
+ t3312_sec = osmo_tdef_get(g_gmm_ctx->T_defs, 3312, OSMO_TDEF_S, -1);
+ if (t3312_sec == 0)
+ return;
+
+ LOGGMME(gmme, LOGL_INFO, "T3312 started\n");
+ osmo_timer_schedule(&gmme->t3312, t3312_sec, 0);
+}
+
+/* T3312 (Periodic RAU) is stopped: */
+void gprs_gmm_gmme_t3312_stop(struct gprs_gmm_entity *gmme)
+{
+ if (!osmo_timer_pending(&gmme->t3312))
+ return;
+
+ LOGGMME(gmme, LOGL_INFO, "T3312 stopped\n");
+ osmo_timer_del(&gmme->t3312);
+}
+
+/* T3312 (Periodic RAU) timer expiration: */
+static void t3312_periodic_rau_timer_cb(void *data)
+{
+ struct gprs_gmm_entity *gmme = (struct gprs_gmm_entity *)data;
+ LOGGMME(gmme, LOGL_INFO, "T3312 Periodic RAU timer expired\n");
+
+ /* TODO:
+ * - "Initiation of the Periodic RAU procedure if the MS is not
+ * attached for emergency bearer services or T3323 started under the
+ * conditions as specified in subclause 4.7.2.2.
+ * - Implicit detach from network if the MS is attached for emergency
+ * bearer services."
+ * - "If the MS is in a state other than GMM-REGISTERED.NORMAL-SERVICE
+ * when timer T3312 expires, the periodic routing area updating procedure
+ * is delayed until the MS returns to GMM-REGISTERED.NORMAL-SERVICE."
+ * "If timer T3323 expires, the MS shall memorize that it has to initiate a
+ * routing area updating procedure when it returns to state
+ * GMM-REGISTERED.NORMAL-SERVICE."
+ */
}
int gprs_gmm_submit_gmmreg_attach_cnf(struct gprs_gmm_entity *gmme, bool accepted, uint8_t cause)
@@ -595,6 +646,7 @@
struct gsm48_attach_ack *aa;
struct tlv_parsed tp;
int rc;
+ int periodic_rau_sec;
if (len < sizeof(*gh) + sizeof(*aa)) {
LOGGMME(gmme, LOGL_ERROR, "Rx GMM ATTACH ACCEPT with wrong size %u\n", len);
@@ -604,8 +656,11 @@
LOGGMME(gmme, LOGL_INFO, "Rx GMM ATTACH ACCEPT\n");
aa = (struct gsm48_attach_ack *)&gh->data[0];
- gmme->ra_upd_timer = aa->ra_upd_timer;
+ periodic_rau_sec = gprs_gmm_gprs_tmr_to_secs(aa->ra_upd_timer);
gmme->radio_prio = aa->radio_prio;
+ gmme->t3312_assigned_sec = periodic_rau_sec >= 0 ? periodic_rau_sec : 0;
+ if (gmme->t3312_assigned_sec == 0)
+ gprs_gmm_gmme_t3312_stop(gmme);
gsm48_parse_ra(&gmme->ra, (const uint8_t *)&aa->ra_id);
if (len > sizeof(*gh) + sizeof(*aa)) {
@@ -632,8 +687,13 @@
gmme->t3314_assigned_sec = osmo_tdef_get(g_gmm_ctx->T_defs, 3314, OSMO_TDEF_S, -1);
}
/* "If the negotiated READY timer value is set to zero, the READY timer shall be stopped immediately": */
- if (gmme->t3314_assigned_sec == 0)
+ if (gmme->t3314_assigned_sec == 0) {
gprs_gmm_gmme_ready_timer_stop(gmme);
+ /* "If after a READY timer negotiation the READY timer
+ * value is set to zero, timer T3312 is reset and started
+ * with its initial value." */
+ gprs_gmm_gmme_t3312_start(gmme);
+ }
if (TLVP_PRESENT(&tp, GSM48_IE_GMM_ALLOC_PTMSI)) {
struct osmo_mobile_identity mi;
diff --git a/src/gmm/gmm_ms_fsm.c b/src/gmm/gmm_ms_fsm.c
index fcaf0d6..889d82a 100644
--- a/src/gmm/gmm_ms_fsm.c
+++ b/src/gmm/gmm_ms_fsm.c
@@ -75,6 +75,7 @@
struct gprs_gmm_ms_fsm_ctx *ctx = (struct gprs_gmm_ms_fsm_ctx *)fi->priv;
memset(&ctx->attach, 0, sizeof(ctx->attach));
+ gprs_gmm_gmme_t3312_stop(ctx->gmme);
}
static void st_gmm_ms_deregistered(struct osmo_fsm_inst *fi, uint32_t event, void *data)
--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32910
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: If1ca164b7a6c7f7750e2e2f0812d6fde828ed4a4
Gerrit-Change-Number: 32910
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
1
0
22 May '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32909 )
Change subject: gmm: Initial implementation of READY timer
......................................................................
gmm: Initial implementation of READY timer
Change-Id: I451ce08d80fb247c28819de065136e2e4d49f3f5
---
M include/osmocom/gprs/gmm/gmm_private.h
M src/gmm/gmm.c
M src/gmm/gmm_pdu.c
M src/gmm/gmm_prim.c
M tests/gmm/gmm_prim_test.ok
5 files changed, 99 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-gprs refs/changes/09/32909/1
diff --git a/include/osmocom/gprs/gmm/gmm_private.h b/include/osmocom/gprs/gmm/gmm_private.h
index 339753b..0ae4df4 100644
--- a/include/osmocom/gprs/gmm/gmm_private.h
+++ b/include/osmocom/gprs/gmm/gmm_private.h
@@ -10,6 +10,7 @@
#include <osmocom/core/msgb.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/endian.h>
+#include <osmocom/core/tdef.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
#include <osmocom/gprs/llc/llc_prim.h>
@@ -83,6 +84,9 @@
unsigned long t3302;
unsigned long t3346;
+ /* READY timer, TS 24.008 4.7.2.1.1 */
+ struct osmo_timer_list t3314;
+ unsigned long t3314_assigned_sec; /* value assigned by the network */
};
/* gmm_prim.c: */
@@ -109,6 +113,9 @@
struct gprs_gmm_entity *gprs_gmm_find_gmme_by_tlli(uint32_t tlli);
struct gprs_gmm_entity *gprs_gmm_find_gmme_by_sess_id(uint32_t id);
uint32_t gprs_gmm_alloc_rand_tlli(void);
+void gprs_gmm_gmme_ready_timer_start(struct gprs_gmm_entity *gmme);
+void gprs_gmm_gmme_ready_timer_stop(struct gprs_gmm_entity *gmme);
+bool gprs_gmm_gmme_ready_timer_running(const struct gprs_gmm_entity *gmme);
int gprs_gmm_rx(struct gprs_gmm_entity *gmme, struct gsm48_hdr *gh, unsigned int len);
int gprs_gmm_tx_att_req(struct gprs_gmm_entity *gmme,
enum osmo_gprs_gmm_attach_type attach_type,
diff --git a/src/gmm/gmm.c b/src/gmm/gmm.c
index aef3571..5a3b0c0 100644
--- a/src/gmm/gmm.c
+++ b/src/gmm/gmm.c
@@ -78,6 +78,8 @@
{ 0 } /* empty item at the end */
};
+static void t3314_ready_timer_cb(void *data);
+
static void gprs_gmm_ctx_free(void)
{
struct gprs_gmm_entity *gmme;
@@ -173,6 +175,8 @@
gmme->t3302 = osmo_tdef_get(g_gmm_ctx->T_defs, 3302, OSMO_TDEF_S, -1);
gmme->t3346 = osmo_tdef_get(g_gmm_ctx->T_defs, 3346, OSMO_TDEF_S, -1);
+ osmo_timer_setup(&gmme->t3314, t3314_ready_timer_cb, gmme);
+
llist_add(&gmme->list, &g_gmm_ctx->gmme_list);
return gmme;
@@ -184,6 +188,8 @@
return;
LOGGMME(gmme, LOGL_DEBUG, "free()\n");
+ if (osmo_timer_pending(&gmme->t3314))
+ osmo_timer_del(&gmme->t3314);
gprs_gmm_ms_fsm_ctx_release(&gmme->ms_fsm);
llist_del(&gmme->list);
talloc_free(gmme);
@@ -280,6 +286,51 @@
return GPRS_GMM_TLLI_UNASSIGNED;
}
+/* TS 24.008 4.7.2.1.1 READY timer behaviour (A/Gb mode only) */
+/* Ready timer is started: */
+void gprs_gmm_gmme_ready_timer_start(struct gprs_gmm_entity *gmme)
+{
+ if (gmme->t3314_assigned_sec == 0)
+ return;
+ LOGGMME(gmme, LOGL_INFO, "READY timer started\n");
+ osmo_timer_schedule(&gmme->t3314, gmme->t3314_assigned_sec, 0);
+
+ /* TODO: "Timer T3312 is stopped and shall be set to its initial value
+ * for the next start when the READY timer is started." */
+}
+
+/* Ready timer is stopped: */
+void gprs_gmm_gmme_ready_timer_stop(struct gprs_gmm_entity *gmme)
+{
+ /* TODO: "In A/Gb mode, the timer T3312 is reset and started with its
+ * initial value, when the READY timer is stopped or expires."
+ */
+ if (!osmo_timer_pending(&gmme->t3314))
+ return;
+ LOGGMME(gmme, LOGL_INFO, "READY timer stopped\n");
+ osmo_timer_del(&gmme->t3314);
+}
+
+bool gprs_gmm_gmme_ready_timer_running(const struct gprs_gmm_entity *gmme)
+{
+ return osmo_timer_pending(&gmme->t3314);
+}
+
+/* READY timer expiration: */
+static void t3314_ready_timer_cb(void *data)
+{
+ /* "When the READY timer has expired the MS shall perform the routing
+ * area updating procedure when a routing area border is crossed"
+ */
+ struct gprs_gmm_entity *gmme = (struct gprs_gmm_entity *)data;
+ LOGGMME(gmme, LOGL_INFO, "READY timer expired\n");
+
+ /* TODO: "In A/Gb mode, the timer T3312 is reset and started with its
+ *initial value, when the READY timer is stopped or expires."
+ */
+
+}
+
int gprs_gmm_submit_gmmreg_attach_cnf(struct gprs_gmm_entity *gmme, bool accepted, uint8_t cause)
{
struct osmo_gprs_gmm_prim *gmm_prim_tx;
@@ -572,6 +623,18 @@
gmme->ptmsi_sig = GSM_RESERVED_TMSI;
}
+ /* 10.5.7.3 Negotiated READY timer value */
+ if (TLVP_PRESENT(&tp, GSM48_IE_GMM_TIMER_READY)) {
+ int secs = gprs_gmm_gprs_tmr_to_secs(*TLVP_VAL(&tp, GSM48_IE_GMM_TIMER_READY));
+ gmme->t3314_assigned_sec = secs >= 0 ? secs : 0;
+ } else {
+ /* Apply the requested value: */
+ gmme->t3314_assigned_sec = osmo_tdef_get(g_gmm_ctx->T_defs, 3314, OSMO_TDEF_S, -1);
+ }
+ /* "If the negotiated READY timer value is set to zero, the READY timer shall be stopped immediately": */
+ if (gmme->t3314_assigned_sec == 0)
+ gprs_gmm_gmme_ready_timer_stop(gmme);
+
if (TLVP_PRESENT(&tp, GSM48_IE_GMM_ALLOC_PTMSI)) {
struct osmo_mobile_identity mi;
if (osmo_mobile_identity_decode(&mi, TLVP_VAL(&tp, GSM48_IE_GMM_ALLOC_PTMSI),
diff --git a/src/gmm/gmm_pdu.c b/src/gmm/gmm_pdu.c
index 28fd30f..c6c8118 100644
--- a/src/gmm/gmm_pdu.c
+++ b/src/gmm/gmm_pdu.c
@@ -181,6 +181,7 @@
uint8_t *l;
int rc;
struct gsm48_ra_id *raid_enc;
+ unsigned long t3314_sec;
gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh));
gh->proto_discr = GSM48_PDISC_MM_GPRS;
@@ -236,6 +237,10 @@
msgb_tv_fixed_put(msg, GSM48_IE_GMM_PTMSI_SIG, sizeof(ptmsi_sig), ptmsi_sig);
}
+ /* 10.5.7.3 Requested READY timer value */
+ t3314_sec = osmo_tdef_get(g_gmm_ctx->T_defs, 3314, OSMO_TDEF_S, -1);
+ msgb_tv_put(msg, GSM48_IE_GMM_TIMER_READY, gprs_gmm_secs_to_gprs_tmr_floor(t3314_sec));
+
/* 9.4.1.13 P-TMSI type: The MS shall include this IE if the
* type of identity in the Mobile identity IE is set to
* "TMSI/P-TMSI/M-TMSI". */
diff --git a/src/gmm/gmm_prim.c b/src/gmm/gmm_prim.c
index 7ca6535..34c9fe9 100644
--- a/src/gmm/gmm_prim.c
+++ b/src/gmm/gmm_prim.c
@@ -603,6 +603,18 @@
return rc;
}
+static int gprs_gmm_prim_handle_gmmrr_llc_transmitted_ind(struct osmo_gprs_gmm_prim *gmm_prim)
+{
+ struct gprs_gmm_entity *gmme = gprs_gmm_find_gmme_by_tlli(gmm_prim->gmmrr.tlli);
+ if (!gmme) {
+ LOGGMM(LOGL_NOTICE, "Rx %s: Unknown TLLI 0x%08x\n",
+ osmo_gprs_gmm_prim_name(gmm_prim), gmm_prim->gmmrr.tlli);
+ return -ENOENT;
+ }
+ gprs_gmm_gmme_ready_timer_start(gmme);
+ return 0;
+}
+
static int gprs_gmm_prim_handle_gmmrr(struct osmo_gprs_gmm_prim *gmm_prim)
{
int rc = 0;
@@ -612,8 +624,7 @@
rc = 1;
break;
case OSMO_PRIM(OSMO_GPRS_GMM_GMMRR_LLC_TRANSMITTED, PRIM_OP_INDICATION):
- rc = gprs_gmm_prim_handle_unsupported(gmm_prim);
- rc = 1;
+ rc = gprs_gmm_prim_handle_gmmrr_llc_transmitted_ind(gmm_prim);
break;
default:
rc = gprs_gmm_prim_handle_unsupported(gmm_prim);
diff --git a/tests/gmm/gmm_prim_test.ok b/tests/gmm/gmm_prim_test.ok
index cfebbfa..068876b 100644
--- a/tests/gmm/gmm_prim_test.ok
+++ b/tests/gmm/gmm_prim_test.ok
@@ -1,5 +1,5 @@
==== test_gmm_prim_ms_gmmreg() [start] ====
-test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 01 04 97 07 00 00 01 0a 00 05 f4 00 00 12 34 00 f0 00 00 00 00 00 19 55 66 77 e1 ]
+test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 01 04 97 07 00 00 01 0a 00 05 f4 00 00 12 34 00 f0 00 00 00 00 00 19 55 66 77 17 16 e1 ]
test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 16 08 42 32 24 43 32 24 43 f2 ]
test_gmm_prim_up_cb(): Rx GMMREG-SIM_AUTH.indication ac_ref_nr=2 key_seq=0 rand=e2 a6 f3 f8 bb 9e a7 01 e0 ce 4f 33 64 a9 91 75
test_gmm_prim_llc_down_cb(): Rx LLGMM-ASSIGN.request old_TLLI=0xffffffff new_TLLI=0x80001234
@@ -13,7 +13,7 @@
test_gmm_prim_up_cb(): Rx GMMREG-DETACH.confirm detach_type='GPRS detach'
==== test_gmm_prim_ms_gmmreg() [end] ====
==== test_gmm_prim_ms_gmmsm() [start] ====
-test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 01 04 97 07 00 00 01 0a 00 05 f4 00 00 12 34 00 f0 00 00 00 00 00 19 55 66 77 e1 ]
+test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 01 04 97 07 00 00 01 0a 00 05 f4 00 00 12 34 00 f0 00 00 00 00 00 19 55 66 77 17 16 e1 ]
test_gmm_prim_llc_down_cb(): Rx LL-UNITDATA.request TLLI=0x80001234 SAPI=GMM l3=[08 16 08 42 32 24 43 32 24 43 f2 ]
test_gmm_prim_up_cb(): Rx GMMREG-SIM_AUTH.indication ac_ref_nr=2 key_seq=0 rand=e2 a6 f3 f8 bb 9e a7 01 e0 ce 4f 33 64 a9 91 75
test_gmm_prim_llc_down_cb(): Rx LLGMM-ASSIGN.request old_TLLI=0xffffffff new_TLLI=0x80001234
--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32909
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I451ce08d80fb247c28819de065136e2e4d49f3f5
Gerrit-Change-Number: 32909
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
1
0
[S] Change in libosmocore[master]: gsm_04_08_gprs: add IEI "GMM TMSI Based NRI Container"
by neels 22 May '23
by neels 22 May '23
22 May '23
neels has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32787 )
Change subject: gsm_04_08_gprs: add IEI "GMM TMSI Based NRI Container"
......................................................................
gsm_04_08_gprs: add IEI "GMM TMSI Based NRI Container"
OsmoHNBGW will need to obtain the NRI from GMM Attach Request and GMM
RAU Request to implement CN pooling.
Related: SYS#6412
Change-Id: Id661abfdb2c81a92c9046542bbc08d6ccd39f073
---
M include/osmocom/gsm/protocol/gsm_04_08_gprs.h
1 file changed, 14 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, approved
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/include/osmocom/gsm/protocol/gsm_04_08_gprs.h b/include/osmocom/gsm/protocol/gsm_04_08_gprs.h
index a3434c6..65dc233 100644
--- a/include/osmocom/gsm/protocol/gsm_04_08_gprs.h
+++ b/include/osmocom/gsm/protocol/gsm_04_08_gprs.h
@@ -83,6 +83,7 @@
enum gsm48_gprs_ie_mm {
GSM48_IE_GMM_CIPH_CKSN = 0x08, /* 10.5.1.2 */
GSM48_IE_GMM_PTMSI_TYPE = 0x0e, /* 10.5.5.29 */
+ GSM48_IE_GMM_TMSI_BASED_NRI_C = 0x10, /* 10.5.5.31 */
GSM48_IE_GMM_TIMER_READY = 0x17, /* 10.5.7.3 */
GSM48_IE_GMM_ALLOC_PTMSI = 0x18, /* 10.5.1.4 */
GSM48_IE_GMM_PTMSI_SIG = 0x19, /* 10.5.5.8 */
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32787
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id661abfdb2c81a92c9046542bbc08d6ccd39f073
Gerrit-Change-Number: 32787
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
1
0
[L] Change in osmo-ttcn3-hacks[master]: BSSMAP_Templates: Add VBS/VGCS related templates
by jolly 22 May '23
by jolly 22 May '23
22 May '23
Attention is currently required from: laforge.
jolly has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/32405 )
Change subject: BSSMAP_Templates: Add VBS/VGCS related templates
......................................................................
Patch Set 5:
(1 comment)
File library/BSSMAP_Templates.ttcn:
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/32405/comment/47519a28_7d96…
PS5, Line 2520: ts_BSSAP_BSSMAP
Must be tr_BSSAP_BSSMAP.
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/32405
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I949f731de794b22292b01d0ddf9a75a9e7e7e71d
Gerrit-Change-Number: 32405
Gerrit-PatchSet: 5
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Mon, 22 May 2023 15:29:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
1
0
[L] Change in osmo-hlr[master]: Add support for multiple APN profiles for subscriber data
by daniel 22 May '23
by daniel 22 May '23
22 May '23
Attention is currently required from: neels, laforge, pespin, lynxis lazus.
daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/32512 )
Change subject: Add support for multiple APN profiles for subscriber data
......................................................................
Patch Set 9: Code-Review-1
(1 comment)
File src/hlr_vty.c:
https://gerrit.osmocom.org/c/osmo-hlr/+/32512/comment/7125dfaf_68f1b1a9
PS9, Line 252: info->apn_enc = (uint8_t *) talloc_strdup(g_hlr, apn_name);
This is actually wrong since you simply copy the profile info over in the GSUP message.
osmo_gsup_configure_wildcard_apn() calls osmo_apn_from_str() which encodes the APN and prefixed the length in the beginning (in addition to apn_enc_len).
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/32512
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I540132ee5dcfd09f4816e02e702927e1074ca50f
Gerrit-Change-Number: 32512
Gerrit-PatchSet: 9
Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-CC: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Comment-Date: Mon, 22 May 2023 15:05:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
1
0
[XL] Change in osmocom-bb[master]: Migrate network identifier fields to modern osmocom structures
by pespin 22 May '23
by pespin 22 May '23
22 May '23
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32786 )
Change subject: Migrate network identifier fields to modern osmocom structures
......................................................................
Migrate network identifier fields to modern osmocom structures
This allows using well tested standarized API to print, compare, etc. usual
identifiers like PLMN, LAI, etc.
It also simplifies code by avoiding passing lots of parameters and
making it easier to identify which fields go packed together.
This is specially important since in the future more of those
identifiers will be added for GPRS.
Change-Id: I07a9289825c09ed748e53d36a746ea164c8a5d7f
---
M src/host/layer23/include/osmocom/bb/common/networks.h
M src/host/layer23/include/osmocom/bb/common/settings.h
M src/host/layer23/include/osmocom/bb/common/subscriber.h
M src/host/layer23/include/osmocom/bb/common/sysinfo.h
M src/host/layer23/include/osmocom/bb/misc/log.h
M src/host/layer23/include/osmocom/bb/mobile/gsm322.h
M src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h
M src/host/layer23/src/common/networks.c
M src/host/layer23/src/common/settings.c
M src/host/layer23/src/common/subscriber.c
M src/host/layer23/src/common/sysinfo.c
M src/host/layer23/src/common/vty.c
M src/host/layer23/src/misc/cell_log.c
M src/host/layer23/src/misc/gsmmap.c
M src/host/layer23/src/misc/log.c
M src/host/layer23/src/mobile/gsm322.c
M src/host/layer23/src/mobile/gsm48_mm.c
M src/host/layer23/src/mobile/gsm48_rr.c
M src/host/layer23/src/mobile/vty_interface.c
19 files changed, 616 insertions(+), 766 deletions(-)
Approvals:
Jenkins Builder: Verified
jolly: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
diff --git a/src/host/layer23/include/osmocom/bb/common/networks.h b/src/host/layer23/include/osmocom/bb/common/networks.h
index d34f316..408e17d 100644
--- a/src/host/layer23/include/osmocom/bb/common/networks.h
+++ b/src/host/layer23/include/osmocom/bb/common/networks.h
@@ -1,24 +1,27 @@
#ifndef _NETWORKS_H
#define _NETWORKS_H
+#include <osmocom/gsm/gsm23003.h>
-#define GSM_INPUT_INVALID 0xffff
-
+/* Instead of handling numerical MCC and MNC, they stored and handled
+ * hexadecimal. This makes it possible
+ * to correctly handle 2 and 3 digits MNC. Internally 2 digit MNCs are stored
+ * as 0xXXf, and 3 digits MNC are stored as 0xXXX, where X is the digit 0..9.
+*/
struct gsm_networks {
- uint16_t mcc;
- int16_t mnc;
+ uint16_t mcc_hex;
+ int16_t mnc_hex;
const char *name;
};
int gsm_match_mcc(uint16_t mcc, char *imsi);
-int gsm_match_mnc(uint16_t mcc, uint16_t mnc, char *imsi);
-const char *gsm_print_mcc(uint16_t mcc);
-const char *gsm_print_mnc(uint16_t mcc);
+int gsm_match_mnc(uint16_t mcc, uint16_t mnc, bool mnc_3_digits, char *imsi);
const char *gsm_get_mcc(uint16_t mcc);
-const char *gsm_get_mnc(uint16_t mcc, uint16_t mnc);
+const char *gsm_get_mnc(const struct osmo_plmn_id *plmn);
const char *gsm_imsi_mcc(char *imsi);
const char *gsm_imsi_mnc(char *imsi);
-const uint16_t gsm_input_mcc(char *string);
-const uint16_t gsm_input_mnc(char *string);
+
+uint16_t gsm_mcc_to_hex(uint16_t mcc);
+uint16_t gsm_mnc_to_hex(uint16_t mnc, bool mnc_3_digits);
#endif /* _NETWORKS_H */
diff --git a/src/host/layer23/include/osmocom/bb/common/settings.h b/src/host/layer23/include/osmocom/bb/common/settings.h
index e312a1c..f66874c 100644
--- a/src/host/layer23/include/osmocom/bb/common/settings.h
+++ b/src/host/layer23/include/osmocom/bb/common/settings.h
@@ -4,6 +4,7 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
+#include <osmocom/gsm/gsm23003.h>
struct osmocom_ms;
struct osmobb_apn;
@@ -64,7 +65,7 @@
uint8_t ki[16]; /* 128 bit max */
uint8_t barr;
uint8_t rplmn_valid;
- uint16_t rplmn_mcc, rplmn_mnc;
+ struct osmo_plmn_id rplmn;
uint16_t lac;
uint8_t imsi_attached;
uint8_t always; /* ...search hplmn... */
diff --git a/src/host/layer23/include/osmocom/bb/common/subscriber.h b/src/host/layer23/include/osmocom/bb/common/subscriber.h
index 972f613..e2a8dab 100644
--- a/src/host/layer23/include/osmocom/bb/common/subscriber.h
+++ b/src/host/layer23/include/osmocom/bb/common/subscriber.h
@@ -5,6 +5,7 @@
#include <osmocom/core/utils.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
+#include <osmocom/gsm/gsm23003.h>
/* GSM 04.08 4.1.2.2 SIM update status */
enum gsm_sub_sim_ustate {
@@ -22,12 +23,12 @@
struct gsm_sub_plmn_list {
struct llist_head entry;
- uint16_t mcc, mnc;
+ struct osmo_plmn_id plmn;
};
struct gsm_sub_plmn_na {
struct llist_head entry;
- uint16_t mcc, mnc;
+ struct osmo_plmn_id plmn;
uint8_t cause;
};
@@ -58,7 +59,7 @@
/* TMSI / LAI */
uint32_t tmsi; /* invalid tmsi: GSM_RESERVED_TMSI */
uint32_t ptmsi; /* invalid tmsi: GSM_RESERVED_TMSI */
- uint16_t mcc, mnc, lac; /* invalid lac: 0x0000 */
+ struct osmo_location_area_id lai; /* invalid lac: 0x0000 */
/* key */
@@ -80,7 +81,7 @@
/* PLMN last registered */
uint8_t plmn_valid;
- uint16_t plmn_mcc, plmn_mnc;
+ struct osmo_plmn_id plmn;
/* our access */
uint8_t acc_barr; /* if we may access, if cell barred */
@@ -111,12 +112,9 @@
int gsm_subscr_generate_kc(struct osmocom_ms *ms, uint8_t key_seq, const uint8_t *rand,
bool no_sim);
void new_sim_ustate(struct gsm_subscriber *subscr, int state);
-int gsm_subscr_del_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
- uint16_t mnc);
-int gsm_subscr_add_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
- uint16_t mnc, uint8_t cause);
-int gsm_subscr_is_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
- uint16_t mnc);
+int gsm_subscr_del_forbidden_plmn(struct gsm_subscriber *subscr, const struct osmo_plmn_id *plmn);
+int gsm_subscr_add_forbidden_plmn(struct gsm_subscriber *subscr, const struct osmo_plmn_id *plmn, uint8_t cause);
+int gsm_subscr_is_forbidden_plmn(struct gsm_subscriber *subscr, const struct osmo_plmn_id *plmn);
int gsm_subscr_dump_forbidden_plmn(struct osmocom_ms *ms,
void (*print)(void *, const char *, ...), void *priv);
void gsm_subscr_dump(struct gsm_subscriber *subscr,
diff --git a/src/host/layer23/include/osmocom/bb/common/sysinfo.h b/src/host/layer23/include/osmocom/bb/common/sysinfo.h
index 75cbcd9..0368901 100644
--- a/src/host/layer23/include/osmocom/bb/common/sysinfo.h
+++ b/src/host/layer23/include/osmocom/bb/common/sysinfo.h
@@ -2,6 +2,7 @@
#define _SYSINFO_H
#include <osmocom/gsm/gsm48_ie.h>
+#include <osmocom/gsm/gsm23003.h>
/* collection of system information of the current cell */
@@ -44,7 +45,7 @@
/* serving cell */
uint8_t bsic;
uint16_t cell_id;
- uint16_t mcc, mnc, lac; /* LAI */
+ struct osmo_location_area_id lai;
uint8_t max_retrans; /* decoded */
uint8_t tx_integer; /* decoded */
uint8_t reest_denied; /* 1 = denied */
@@ -195,9 +196,5 @@
int gsm48_decode_mobile_alloc(struct gsm_sysinfo_freq *freq,
const uint8_t *ma, uint8_t len,
uint16_t *hopping, uint8_t *hopp_len, int si4);
-int gsm48_encode_lai_hex(struct gsm48_loc_area_id *lai,
- uint16_t mcc, uint16_t mnc, uint16_t lac);
-int gsm48_decode_lai_hex(const struct gsm48_loc_area_id *lai,
- uint16_t *mcc, uint16_t *mnc, uint16_t *lac);
#endif /* _SYSINFO_H */
diff --git a/src/host/layer23/include/osmocom/bb/misc/log.h b/src/host/layer23/include/osmocom/bb/misc/log.h
index 54d795b..3183f87 100644
--- a/src/host/layer23/include/osmocom/bb/misc/log.h
+++ b/src/host/layer23/include/osmocom/bb/misc/log.h
@@ -29,6 +29,7 @@
struct node_mnc {
struct node_mnc *next;
uint16_t mnc;
+ bool mnc_3_digits;
struct node_lac *lac;
};
@@ -75,7 +76,7 @@
};
struct node_mcc *get_node_mcc(uint16_t mcc);
-struct node_mnc *get_node_mnc(struct node_mcc *mcc, uint16_t mnc);
+struct node_mnc *get_node_mnc(struct node_mcc *mcc, uint16_t mnc, bool mnc_3_digits);
struct node_lac *get_node_lac(struct node_mnc *mnc, uint16_t lac);
struct node_cell *get_node_cell(struct node_lac *lac, uint16_t cellid);
struct node_meas *add_node_meas(struct node_cell *cell);
diff --git a/src/host/layer23/include/osmocom/bb/mobile/gsm322.h b/src/host/layer23/include/osmocom/bb/mobile/gsm322.h
index 86b1ef1..4b20a1a 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/gsm322.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/gsm322.h
@@ -1,10 +1,11 @@
#ifndef _GSM322_H
#define _GSM322_H
-#include <osmocom/bb/common/sysinfo.h>
-
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/timer.h>
+#include <osmocom/gsm/gsm23003.h>
+
+#include <osmocom/bb/common/sysinfo.h>
/* 4.3.1.1 List of states for PLMN selection process (automatic mode) */
#define GSM322_A0_NULL 0
@@ -74,7 +75,7 @@
/* node for each PLMN */
struct gsm322_plmn_list {
struct llist_head entry;
- uint16_t mcc, mnc;
+ struct osmo_plmn_id plmn;
uint8_t rxlev; /* rx level in range format */
uint8_t cause; /* cause value, if PLMN is not allowed */
};
@@ -82,14 +83,14 @@
/* node for each forbidden LA */
struct gsm322_la_list {
struct llist_head entry;
- uint16_t mcc, mnc, lac;
+ struct osmo_location_area_id lai;
uint8_t cause;
};
/* node for each BA-List */
struct gsm322_ba_list {
struct llist_head entry;
- uint16_t mcc, mnc;
+ struct osmo_plmn_id plmn;
/* Band allocation for 1024+299 frequencies.
* First bit of first index is frequency 0.
*/
@@ -124,7 +125,7 @@
struct osmo_timer_list timer;
int plmn_curr; /* current index in sorted_plmn */
- uint16_t mcc, mnc; /* current network selected */
+ struct osmo_plmn_id plmn; /* current network selected */
};
/* state of CCCH activation */
@@ -171,7 +172,7 @@
/* cell selection list per frequency. */
/* scan and tune state */
struct osmo_timer_list timer; /* cell selection timer */
- uint16_t mcc, mnc; /* current network to search for */
+ struct osmo_plmn_id plmn; /* current network to search for */
uint8_t powerscan; /* currently scanning for power */
uint8_t ccch_state; /* special state of current ccch */
uint32_t scan_state; /* special state of current scan */
@@ -188,7 +189,7 @@
uint8_t selected; /* if a cell is selected */
uint16_t sel_arfcn; /* current selected serving cell! */
struct gsm48_sysinfo sel_si; /* copy of selected cell, will update */
- uint16_t sel_mcc, sel_mnc, sel_lac, sel_id;
+ struct osmo_cell_global_id sel_cgi;
/* cell re-selection */
struct llist_head nb_list; /* list of neighbour cells */
@@ -209,7 +210,7 @@
/* GSM 03.22 message */
struct gsm322_msg {
int msg_type;
- uint16_t mcc, mnc;
+ struct osmo_plmn_id plmn;
uint8_t sysinfo; /* system information type */
uint8_t same_cell; /* select same cell when RET_IDLE */
uint8_t reject; /* location update reject cause */
@@ -229,18 +230,15 @@
int gsm322_c_event(struct osmocom_ms *ms, struct msgb *msg);
int gsm322_plmn_dequeue(struct osmocom_ms *ms);
int gsm322_cs_dequeue(struct osmocom_ms *ms);
-int gsm322_add_forbidden_la(struct osmocom_ms *ms, uint16_t mcc,
- uint16_t mnc, uint16_t lac, uint8_t cause);
-int gsm322_del_forbidden_la(struct osmocom_ms *ms, uint16_t mcc,
- uint16_t mnc, uint16_t lac);
-int gsm322_is_forbidden_la(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc,
- uint16_t lac);
+int gsm322_add_forbidden_la(struct osmocom_ms *ms, const struct osmo_location_area_id *lai, uint8_t cause);
+int gsm322_del_forbidden_la(struct osmocom_ms *ms, const struct osmo_location_area_id *lai);
+int gsm322_is_forbidden_la(struct osmocom_ms *ms, const struct osmo_location_area_id *lai);
int gsm322_dump_sorted_plmn(struct osmocom_ms *ms);
int gsm322_dump_cs_list(struct gsm322_cellsel *cs, uint8_t flags,
void (*print)(void *, const char *, ...), void *priv);
int gsm322_dump_forbidden_la(struct osmocom_ms *ms,
void (*print)(void *, const char *, ...), void *priv);
-int gsm322_dump_ba_list(struct gsm322_cellsel *cs, uint16_t mcc, uint16_t mnc,
+int gsm322_dump_ba_list(struct gsm322_cellsel *cs, const struct osmo_plmn_id *plmn,
void (*print)(void *, const char *, ...), void *priv);
int gsm322_dump_nb_list(struct gsm322_cellsel *cs,
void (*print)(void *, const char *, ...), void *priv);
diff --git a/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h b/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h
index ce80317..b637a60 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h
@@ -186,7 +186,7 @@
uint8_t lupd_rej_cause; /* cause of last reject */
uint8_t lupd_periodic; /* periodic update pending */
uint8_t lupd_retry; /* pending T3211/T3213 to */
- uint16_t lupd_mcc, lupd_mnc, lupd_lac;
+ struct osmo_location_area_id lupd_lai;
/* imsi detach */
uint8_t delay_detach; /* do detach when possible */
diff --git a/src/host/layer23/src/common/networks.c b/src/host/layer23/src/common/networks.c
index 5374bc0..e2429ef 100644
--- a/src/host/layer23/src/common/networks.c
+++ b/src/host/layer23/src/common/networks.c
@@ -2,6 +2,8 @@
#include <stdint.h>
#include <stdio.h>
+#include <osmocom/gsm/gsm23003.h>
+
#include <osmocom/bb/common/networks.h>
/* list of networks */
@@ -1774,6 +1776,43 @@
{ 0, 0, NULL }
};
+/* param: numerically stored mcc as per osmo_plmn_id. */
+uint16_t gsm_mcc_to_hex(uint16_t mcc)
+{
+ uint8_t buf[3];
+ uint16_t in = mcc;
+
+ buf[2] = in % 10;
+ in = in / 10;
+ buf[1] = in % 10;
+ in = in / 10;
+ buf[0] = in % 10;
+
+ return ((buf[0] << 8) +
+ (buf[1] << 4) +
+ buf[2]);
+}
+
+/* param: numerically stored mnc as per osmo_plmn_id. */
+uint16_t gsm_mnc_to_hex(uint16_t mnc, bool mnc_3_digits)
+{
+ uint8_t buf[3];
+ uint16_t in = mnc;
+ if (mnc_3_digits) {
+ buf[2] = in % 10;
+ in = in / 10;
+ } else {
+ buf[2] = 0x0f;
+ }
+ buf[1] = in % 10;
+ in = in / 10;
+ buf[0] = in % 10;
+
+ return ((buf[0] << 8) +
+ (buf[1] << 4) +
+ buf[2]);
+}
+
/* GSM 03.22 Annex A */
int gsm_match_mcc(uint16_t mcc, char *imsi)
{
@@ -1783,30 +1822,33 @@
+ ((imsi[1] - '0') << 4)
+ imsi[2] - '0';
- return (mcc == sim_mcc);
+ return (gsm_mcc_to_hex(mcc) == sim_mcc);
}
/* GSM 03.22 Annex A */
-int gsm_match_mnc(uint16_t mcc, uint16_t mnc, char *imsi)
+int gsm_match_mnc(uint16_t mcc, uint16_t mnc, bool mnc_3_digits, char *imsi)
{
uint16_t sim_mnc;
+ uint16_t mnc_hex;
/* 1. SIM-MCC = BCCH-MCC */
if (!gsm_match_mcc(mcc, imsi))
return 0;
+ mnc_hex = gsm_mnc_to_hex(mnc, mnc_3_digits);
+
/* 2. 3rd digit of BCCH-MNC is not 0xf */
- if ((mnc & 0x00f) != 0x00f) {
+ if ((mnc_hex & 0x00f) != 0x00f) {
/* 3. 3 digit SIM-MNC = BCCH-MNC */
sim_mnc = ((imsi[3] - '0') << 8)
+ ((imsi[4] - '0') << 4)
+ imsi[5] - '0';
- return (mnc == sim_mnc);
+ return (mnc_hex == sim_mnc);
}
/* 4. BCCH-MCC in the range 310-316 */
- if (mcc >= 310 && mcc <= 316) {
+ if (gsm_mcc_to_hex(mcc) >= 310 && mnc_hex <= 316) {
/* 5. 3rd diit of SIM-MNC is 0 */
if (imsi[5] != 0)
return 0;
@@ -1817,123 +1859,47 @@
+ ((imsi[4] - '0') << 4)
+ 0x00f;
- return (mnc == sim_mnc);
-}
-
-const char *gsm_print_mcc(uint16_t mcc)
-{
- static char string[6] = "000";
-
- snprintf(string, 5, "%03x", mcc);
- return string;
-}
-
-const char *gsm_print_mnc(uint16_t mnc)
-{
- static char string[8];
-
- /* invalid format: return hex value */
- if ((mnc & 0xf000)
- || (mnc & 0x0f00) > 0x0900
- || (mnc & 0x00f0) > 0x0090
- || ((mnc & 0x000f) > 0x0009 && (mnc & 0x000f) < 0x000f)) {
- snprintf(string, 7, "0x%03x", mnc);
- return string;
- }
-
- /* two digits */
- if ((mnc & 0x000f) == 0x000f) {
- snprintf(string, 7, "%02x", mnc >> 4);
- return string;
- }
-
- /* three digits */
- snprintf(string, 7, "%03x", mnc);
- return string;
-}
-
-const uint16_t gsm_input_mcc(char *string)
-{
- uint16_t mcc;
-
- if (strlen(string) != 3)
- return GSM_INPUT_INVALID;
- if (string[0] < '0' || string [0] > '9'
- || string[1] < '0' || string [1] > '9'
- || string[2] < '0' || string [2] > '9')
- return GSM_INPUT_INVALID;
-
- mcc = ((string[0] - '0') << 8)
- | ((string[1] - '0') << 4)
- | ((string[2] - '0'));
-
- if (mcc == 0x000)
- return GSM_INPUT_INVALID;
-
- return mcc;
-}
-
-const uint16_t gsm_input_mnc(char *string)
-{
- uint16_t mnc = 0;
-
- if (strlen(string) == 2) {
- if (string[0] < '0' || string [0] > '9'
- || string[1] < '0' || string [1] > '9')
- return GSM_INPUT_INVALID;
-
- mnc = ((string[0] - '0') << 8)
- | ((string[1] - '0') << 4)
- | 0x00f;
- } else
- if (strlen(string) == 3) {
- if (string[0] < '0' || string [0] > '9'
- || string[1] < '0' || string [1] > '9'
- || string[2] < '0' || string [2] > '9')
- return GSM_INPUT_INVALID;
-
- mnc = ((string[0] - '0') << 8)
- | ((string[1] - '0') << 4)
- | ((string[2] - '0'));
- }
-
- return mnc;
+ return (mnc_hex == sim_mnc);
}
const char *gsm_get_mcc(uint16_t mcc)
{
int i;
+ uint16_t mcc_hex = gsm_mcc_to_hex(mcc);
for (i = 0; gsm_networks[i].name; i++)
- if (gsm_networks[i].mnc < 0 && gsm_networks[i].mcc == mcc)
+ if (gsm_networks[i].mnc_hex < 0 && gsm_networks[i].mcc_hex == mcc_hex)
return gsm_networks[i].name;
- return gsm_print_mcc(mcc);
+ return osmo_mcc_name(mcc);
}
-const char *gsm_get_mnc(uint16_t mcc, uint16_t mnc)
+const char *gsm_get_mnc(const struct osmo_plmn_id *plmn)
{
int i;
+ uint16_t mcc_hex = gsm_mcc_to_hex(plmn->mcc);
+ uint16_t mnc_hex = gsm_mnc_to_hex(plmn->mnc, plmn->mnc_3_digits);
for (i = 0; gsm_networks[i].name; i++)
- if (gsm_networks[i].mcc == mcc && gsm_networks[i].mnc == mnc)
+ if (gsm_networks[i].mcc_hex == mcc_hex &&
+ gsm_networks[i].mnc_hex == mnc_hex)
return gsm_networks[i].name;
- return gsm_print_mnc(mnc);
+ return osmo_mnc_name(plmn->mnc, plmn->mnc_3_digits);
}
/* get MCC from IMSI */
const char *gsm_imsi_mcc(char *imsi)
{
int i, found = 0;
- uint16_t mcc;
+ uint16_t mcc_hex;
- mcc = ((imsi[0] - '0') << 8)
+ mcc_hex = ((imsi[0] - '0') << 8)
| ((imsi[1] - '0') << 4)
| ((imsi[2] - '0'));
for (i = 0; gsm_networks[i].name; i++) {
- if (gsm_networks[i].mcc == mcc) {
+ if (gsm_networks[i].mcc_hex == mcc_hex) {
found = 1;
break;
}
@@ -1961,15 +1927,15 @@
+ imsi[5] - '0';
for (i = 0; gsm_networks[i].name; i++) {
- if (gsm_networks[i].mcc != mcc)
+ if (gsm_networks[i].mcc_hex != mcc)
continue;
- if ((gsm_networks[i].mnc & 0x00f) == 0x00f) {
- if (mnc2 == gsm_networks[i].mnc) {
+ if ((gsm_networks[i].mnc_hex & 0x00f) == 0x00f) {
+ if (mnc2 == gsm_networks[i].mnc_hex) {
found++;
position = i;
}
} else {
- if (mnc3 == gsm_networks[i].mnc) {
+ if (mnc3 == gsm_networks[i].mnc_hex) {
found++;
position = i;
}
diff --git a/src/host/layer23/src/common/settings.c b/src/host/layer23/src/common/settings.c
index 6c58e65..288b03e 100644
--- a/src/host/layer23/src/common/settings.c
+++ b/src/host/layer23/src/common/settings.c
@@ -68,7 +68,9 @@
/* test SIM */
OSMO_STRLCPY_ARRAY(set->test_sim.imsi, "001010000000000");
- set->test_sim.rplmn_mcc = set->test_sim.rplmn_mnc = 1;
+ set->test_sim.rplmn.mcc = 1;
+ set->test_sim.rplmn.mnc = 1;
+ set->test_sim.rplmn.mnc_3_digits = false;
set->test_sim.lac = 0x0000;
set->test_sim.tmsi = GSM_RESERVED_TMSI;
diff --git a/src/host/layer23/src/common/subscriber.c b/src/host/layer23/src/common/subscriber.c
index c1f9806..b0c5f19 100644
--- a/src/host/layer23/src/common/subscriber.c
+++ b/src/host/layer23/src/common/subscriber.c
@@ -106,7 +106,7 @@
/* set TMSI / LAC invalid */
subscr->tmsi = GSM_RESERVED_TMSI;
subscr->ptmsi = GSM_RESERVED_TMSI;
- subscr->lac = 0x0000;
+ subscr->lai.lac = 0x0000;
/* set key invalid */
subscr->key_seq = 7;
@@ -328,22 +328,20 @@
}
}
-/* del forbidden PLMN. if MCC==0, flush complete list */
-int gsm_subscr_del_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
- uint16_t mnc)
+/* del forbidden PLMN. if PLMN is NULL, flush complete list */
+int gsm_subscr_del_forbidden_plmn(struct gsm_subscriber *subscr, const struct osmo_plmn_id *plmn)
{
struct gsm_sub_plmn_na *na, *na2;
int deleted = 0;
llist_for_each_entry_safe(na, na2, &subscr->plmn_na, entry) {
- if (!mcc || (na->mcc == mcc && na->mnc == mnc)) {
- LOGP(DPLMN, LOGL_INFO, "Delete from list of forbidden "
- "PLMNs (mcc=%s, mnc=%s)\n",
- gsm_print_mcc(mcc), gsm_print_mnc(mnc));
+ if (!plmn || (osmo_plmn_cmp(&na->plmn, plmn) == 0)) {
+ LOGP(DPLMN, LOGL_INFO, "Delete from list of forbidden PLMNs (mcc-mnc=%s)\n",
+ osmo_plmn_name(&na->plmn));
llist_del(&na->entry);
talloc_free(na);
deleted = 1;
- if (mcc)
+ if (plmn)
break;
}
}
@@ -357,26 +355,24 @@
}
/* add forbidden PLMN */
-int gsm_subscr_add_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
- uint16_t mnc, uint8_t cause)
+int gsm_subscr_add_forbidden_plmn(struct gsm_subscriber *subscr, const struct osmo_plmn_id *plmn, uint8_t cause)
{
struct gsm_sub_plmn_na *na;
/* if already in the list, remove and add to tail */
- gsm_subscr_del_forbidden_plmn(subscr, mcc, mnc);
+ gsm_subscr_del_forbidden_plmn(subscr, plmn);
LOGP(DPLMN, LOGL_INFO, "Add to list of forbidden PLMNs "
- "(mcc=%s, mnc=%s)\n", gsm_print_mcc(mcc), gsm_print_mnc(mnc));
+ "(mcc-mnc=%s)\n", osmo_plmn_name(plmn));
na = talloc_zero(subscr->ms, struct gsm_sub_plmn_na);
if (!na)
return -ENOMEM;
- na->mcc = mcc;
- na->mnc = mnc;
+ memcpy(&na->plmn, plmn, sizeof(struct osmo_plmn_id));
na->cause = cause ? : -1; /* cause 0 is not allowed */
llist_add_tail(&na->entry, &subscr->plmn_na);
/* don't add Home PLMN to SIM */
- if (subscr->sim_valid && gsm_match_mnc(mcc, mnc, subscr->imsi))
+ if (subscr->sim_valid && gsm_match_mnc(plmn->mcc, plmn->mnc, plmn->mnc_3_digits, subscr->imsi))
return -EINVAL;
/* update plmn not allowed list on SIM */
@@ -386,13 +382,12 @@
}
/* search forbidden PLMN */
-int gsm_subscr_is_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
- uint16_t mnc)
+int gsm_subscr_is_forbidden_plmn(struct gsm_subscriber *subscr, const struct osmo_plmn_id *plmn)
{
struct gsm_sub_plmn_na *na;
llist_for_each_entry(na, &subscr->plmn_na, entry) {
- if (na->mcc == mcc && na->mnc == mnc)
+ if (osmo_plmn_cmp(&na->plmn, plmn) == 0)
return 1;
}
@@ -416,9 +411,10 @@
print(priv, "MCC |MNC |cause\n");
print(priv, "-------+-------+-------\n");
llist_for_each_entry(temp, &subscr->plmn_na, entry)
- print(priv, "%s |%s%s |#%d\n",
- gsm_print_mcc(temp->mcc), gsm_print_mnc(temp->mnc),
- ((temp->mnc & 0x00f) == 0x00f) ? " ":"", temp->cause);
+ print(priv, "%s |%-3s |#%d\n",
+ osmo_mcc_name(temp->plmn.mcc),
+ osmo_mnc_name(temp->plmn.mnc, temp->plmn.mnc_3_digits),
+ temp->cause);
return 0;
}
@@ -454,13 +450,12 @@
print(priv, " TMSI 0x%08x", subscr->tmsi);
if (subscr->ptmsi != GSM_RESERVED_TMSI)
print(priv, " P-TMSI 0x%08x", subscr->ptmsi);
- if (subscr->lac > 0x0000 && subscr->lac < 0xfffe) {
+ if (subscr->lai.lac > 0x0000 && subscr->lai.lac < 0xfffe) {
print(priv, "\n");
- print(priv, " LAI: MCC %s MNC %s LAC 0x%04x "
- "(%s, %s)\n", gsm_print_mcc(subscr->mcc),
- gsm_print_mnc(subscr->mnc), subscr->lac,
- gsm_get_mcc(subscr->mcc),
- gsm_get_mnc(subscr->mcc, subscr->mnc));
+ print(priv, " LAI: %s (%s, %s)\n",
+ osmo_lai_name(&subscr->lai),
+ gsm_get_mcc(subscr->lai.plmn.mcc),
+ gsm_get_mnc(&subscr->lai.plmn));
} else
print(priv, " LAI: invalid\n");
if (subscr->key_seq != 7) {
@@ -470,11 +465,10 @@
print(priv, "\n");
}
if (subscr->plmn_valid)
- print(priv, " Registered PLMN: MCC %s MNC %s (%s, %s)\n",
- gsm_print_mcc(subscr->plmn_mcc),
- gsm_print_mnc(subscr->plmn_mnc),
- gsm_get_mcc(subscr->plmn_mcc),
- gsm_get_mnc(subscr->plmn_mcc, subscr->plmn_mnc));
+ print(priv, " Registered PLMN: MCC-MNC %s (%s, %s)\n",
+ osmo_plmn_name(&subscr->plmn),
+ gsm_get_mcc(subscr->plmn.mcc),
+ gsm_get_mnc(&subscr->plmn));
print(priv, " Access barred cells: %s\n",
(subscr->acc_barr) ? "yes" : "no");
print(priv, " Access classes:");
@@ -488,22 +482,21 @@
print(priv, " -------+-------\n");
llist_for_each_entry(plmn_list, &subscr->plmn_list, entry)
print(priv, " %s |%s (%s, %s)\n",
- gsm_print_mcc(plmn_list->mcc),
- gsm_print_mnc(plmn_list->mnc),
- gsm_get_mcc(plmn_list->mcc),
- gsm_get_mnc(plmn_list->mcc, plmn_list->mnc));
+ osmo_mcc_name(plmn_list->plmn.mcc),
+ osmo_mnc_name(plmn_list->plmn.mnc, plmn_list->plmn.mnc_3_digits),
+ gsm_get_mcc(plmn_list->plmn.mcc),
+ gsm_get_mnc(&plmn_list->plmn));
}
if (!llist_empty(&subscr->plmn_na)) {
print(priv, " List of forbidden PLMNs:\n");
print(priv, " MCC |MNC |cause\n");
print(priv, " -------+-------+-------\n");
llist_for_each_entry(plmn_na, &subscr->plmn_na, entry)
- print(priv, " %s |%s%s |#%d "
- "(%s, %s)\n", gsm_print_mcc(plmn_na->mcc),
- gsm_print_mnc(plmn_na->mnc),
- ((plmn_na->mnc & 0x00f) == 0x00f) ? " ":"",
- plmn_na->cause, gsm_get_mcc(plmn_na->mcc),
- gsm_get_mnc(plmn_na->mcc, plmn_na->mnc));
+ print(priv, " %s |%-3s |#%d (%s, %s)\n",
+ osmo_mcc_name(plmn_na->plmn.mcc),
+ osmo_mnc_name(plmn_na->plmn.mnc, plmn_na->plmn.mnc_3_digits),
+ plmn_na->cause, gsm_get_mcc(plmn_na->plmn.mcc),
+ gsm_get_mnc(&plmn_na->plmn));
}
}
@@ -528,11 +521,9 @@
subscr->acc_barr = set->test_sim.barr; /* we may access barred cell */
subscr->acc_class = 0xffff; /* we have any access class */
subscr->plmn_valid = set->test_sim.rplmn_valid;
- subscr->plmn_mcc = set->test_sim.rplmn_mcc;
- subscr->plmn_mnc = set->test_sim.rplmn_mnc;
- subscr->mcc = set->test_sim.rplmn_mcc;
- subscr->mnc = set->test_sim.rplmn_mnc;
- subscr->lac = set->test_sim.lac;
+ memcpy(&subscr->plmn, &set->test_sim.rplmn, sizeof(struct osmo_plmn_id));
+ memcpy(&subscr->lai.plmn, &set->test_sim.rplmn, sizeof(struct osmo_plmn_id));
+ subscr->lai.lac = set->test_sim.lac;
subscr->tmsi = set->test_sim.tmsi;
subscr->ptmsi = GSM_RESERVED_TMSI;
subscr->always_search_hplmn = set->test_sim.always;
@@ -549,10 +540,10 @@
gsm_imsi_mnc(subscr->imsi));
if (subscr->plmn_valid)
- LOGP(DMM, LOGL_INFO, "-> Test card registered to %s %s 0x%04x"
- "(%s, %s)\n", gsm_print_mcc(subscr->mcc),
- gsm_print_mnc(subscr->mnc), subscr->lac, gsm_get_mcc(subscr->mcc),
- gsm_get_mnc(subscr->mcc, subscr->mnc));
+ LOGP(DMM, LOGL_INFO, "-> Test card registered to %s"
+ "(%s, %s)\n", osmo_lai_name(&subscr->lai),
+ gsm_get_mcc(subscr->lai.plmn.mcc),
+ gsm_get_mnc(&subscr->lai.plmn));
else
LOGP(DMM, LOGL_INFO, "-> Test card not registered\n");
if (subscr->imsi_attached)
@@ -654,8 +645,7 @@
subscr->tmsi = ntohl(loci->tmsi);
/* LAI */
- gsm48_decode_lai_hex(&loci->lai, &subscr->mcc, &subscr->mnc,
- &subscr->lac);
+ gsm48_decode_lai2(&loci->lai, &subscr->lai);
/* location update status */
switch (loci->lupd_status & 0x07) {
@@ -670,9 +660,8 @@
subscr->ustate = GSM_SIM_U2_NOT_UPDATED;
}
- LOGP(DMM, LOGL_INFO, "received LOCI from SIM (mcc=%s mnc=%s lac=0x%04x "
- "U%d)\n", gsm_print_mcc(subscr->mcc),
- gsm_print_mnc(subscr->mnc), subscr->lac, subscr->ustate);
+ LOGP(DMM, LOGL_INFO, "received LOCI from SIM (lai=%s U%d)\n",
+ osmo_lai_name(&subscr->lai), subscr->ustate);
return 0;
}
@@ -760,8 +749,6 @@
struct gsm_subscriber *subscr = &ms->subscr;
struct gsm_sub_plmn_list *plmn;
struct llist_head *lh, *lh2;
- uint8_t lai[5];
- uint16_t dummy_lac;
/* flush list */
llist_for_each_safe(lh, lh2, &subscr->plmn_list) {
@@ -778,16 +765,11 @@
plmn = talloc_zero(ms, struct gsm_sub_plmn_list);
if (!plmn)
return -ENOMEM;
- lai[0] = data[0];
- lai[1] = data[1];
- lai[2] = data[2];
- gsm48_decode_lai_hex((struct gsm48_loc_area_id *)lai,
- &plmn->mcc, &plmn->mnc, &dummy_lac);
+ osmo_plmn_to_bcd(&data[0], &plmn->plmn);
llist_add_tail(&plmn->entry, &subscr->plmn_list);
- LOGP(DMM, LOGL_INFO, "received PLMN selector (mcc=%s mnc=%s) "
- "from SIM\n",
- gsm_print_mcc(plmn->mcc), gsm_print_mnc(plmn->mnc));
+ LOGP(DMM, LOGL_INFO, "received PLMN selector (mcc-mnc=%s) from SIM\n",
+ osmo_plmn_name(&plmn->plmn));
data += 3;
length -= 3;
@@ -860,8 +842,6 @@
struct gsm_subscriber *subscr = &ms->subscr;
struct gsm_sub_plmn_na *na;
struct llist_head *lh, *lh2;
- uint8_t lai[5];
- uint16_t dummy_lac;
#ifdef TEST_EMPTY_FPLMN
return 0;
@@ -882,13 +862,9 @@
na = talloc_zero(ms, struct gsm_sub_plmn_na);
if (!na)
return -ENOMEM;
- lai[0] = data[0];
- lai[1] = data[1];
- lai[2] = data[2];
- gsm48_decode_lai_hex((struct gsm48_loc_area_id *)lai, &na->mcc,
- &na->mnc, &dummy_lac);
- LOGP(DMM, LOGL_INFO, "received Forbidden PLMN %s %s from SIM\n",
- gsm_print_mcc(na->mcc), gsm_print_mnc(na->mnc));
+ osmo_plmn_to_bcd(&data[0], &na->plmn);
+ LOGP(DMM, LOGL_INFO, "received Forbidden PLMN %s from SIM\n",
+ osmo_plmn_name(&na->plmn));
na->cause = -1; /* must have a value, but SIM stores no cause */
llist_add_tail(&na->entry, &subscr->plmn_na);
@@ -936,16 +912,13 @@
gsm_imsi_mcc(subscr->imsi), gsm_imsi_mnc(subscr->imsi));
/* if LAI is valid, set RPLMN */
- if (subscr->lac > 0x0000 && subscr->lac < 0xfffe) {
+ if (subscr->lai.lac > 0x0000 && subscr->lai.lac < 0xfffe) {
subscr->plmn_valid = 1;
- subscr->plmn_mcc = subscr->mcc;
- subscr->plmn_mnc = subscr->mnc;
- LOGP(DMM, LOGL_INFO, "-> SIM card registered to %s %s "
- "(%s, %s)\n", gsm_print_mcc(subscr->plmn_mcc),
- gsm_print_mnc(subscr->plmn_mnc),
- gsm_get_mcc(subscr->plmn_mcc),
- gsm_get_mnc(subscr->plmn_mcc,
- subscr->plmn_mnc));
+ memcpy(&subscr->plmn, &subscr->lai.plmn, sizeof(struct osmo_plmn_id));
+ LOGP(DMM, LOGL_INFO, "-> SIM card registered to %s (%s, %s)\n",
+ osmo_plmn_name(&subscr->plmn),
+ gsm_get_mcc(subscr->plmn.mcc),
+ gsm_get_mnc(&subscr->plmn));
} else
LOGP(DMM, LOGL_INFO, "-> SIM card not registered\n");
@@ -1138,7 +1111,6 @@
struct gsm_sub_plmn_na *na, *nas[4] = { NULL, NULL, NULL, NULL };
int count = 0, i;
uint8_t *data;
- uint8_t lai[5];
#ifdef TEST_EMPTY_FPLMN
return 0;
@@ -1170,11 +1142,8 @@
nsh->file = 0x6f7b;
for (i = 0; i < 4; i++) {
if (nas[i]) {
- gsm48_encode_lai_hex((struct gsm48_loc_area_id *)lai,
- nas[i]->mcc, nas[i]->mnc, 0);
- *data++ = lai[0];
- *data++ = lai[1];
- *data++ = lai[2];
+ osmo_plmn_to_bcd(data, &nas[i]->plmn);
+ data += 3;
} else {
*data++ = 0xff;
*data++ = 0xff;
@@ -1209,7 +1178,7 @@
loci->tmsi = htonl(subscr->tmsi);
/* LAI */
- gsm48_encode_lai_hex(&loci->lai, subscr->mcc, subscr->mnc, subscr->lac);
+ gsm48_generate_lai2(&loci->lai, &subscr->lai);
/* TMSI time */
loci->tmsi_time = 0xff;
diff --git a/src/host/layer23/src/common/sysinfo.c b/src/host/layer23/src/common/sysinfo.c
index 42bc8ab..700accd 100644
--- a/src/host/layer23/src/common/sysinfo.c
+++ b/src/host/layer23/src/common/sysinfo.c
@@ -22,6 +22,7 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/bitvec.h>
+#include <osmocom/gsm/gsm48.h>
#include <osmocom/gprs/rlcmac/csn1_defs.h>
@@ -203,12 +204,10 @@
/* serving cell */
print(priv, "Serving Cell:\n");
- print(priv, " BSIC = %d,%d MCC = %s MNC = %s LAC = 0x%04x Cell ID "
- "= 0x%04x\n", s->bsic >> 3, s->bsic & 0x7,
- gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc), s->lac,
- s->cell_id);
- print(priv, " Country = %s Network Name = %s\n", gsm_get_mcc(s->mcc),
- gsm_get_mnc(s->mcc, s->mnc));
+ print(priv, " BSIC = %d,%d LAI = %s Cell ID = 0x%04x\n",
+ s->bsic >> 3, s->bsic & 0x7, osmo_lai_name(&s->lai), s->cell_id);
+ print(priv, " Country = %s Network Name = %s\n",
+ gsm_get_mcc(s->lai.plmn.mcc), gsm_get_mnc(&s->lai.plmn));
print(priv, " MAX_RETRANS = %d TX_INTEGER = %d re-establish = %s\n",
s->max_retrans, s->tx_integer,
(s->reest_denied) ? "denied" : "allowed");
@@ -685,7 +684,7 @@
/* Cell Identity */
s->cell_id = ntohs(si->cell_identity);
/* LAI */
- gsm48_decode_lai_hex(&si->lai, &s->mcc, &s->mnc, &s->lac);
+ gsm48_decode_lai2(&si->lai, &s->lai);
/* Control Channel Description */
gsm48_decode_ccd(s, &si->control_channel_desc);
/* Cell Options (BCCH) */
@@ -699,8 +698,7 @@
gsm48_decode_si3_rest(s, si->rest_octets, payload_len);
LOGP(DRR, LOGL_INFO,
- "New SYSTEM INFORMATION 3 (mcc %s mnc %s lac 0x%04x)\n",
- gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc), s->lac);
+ "New SYSTEM INFORMATION 3 (lai=%s)\n", osmo_lai_name(&s->lai));
s->si3 = 1;
@@ -718,7 +716,7 @@
memcpy(s->si4_msg, si, OSMO_MIN(len, sizeof(s->si4_msg)));
/* LAI */
- gsm48_decode_lai_hex(&si->lai, &s->mcc, &s->mnc, &s->lac);
+ gsm48_decode_lai2(&si->lai, &s->lai);
/* Cell Selection Parameters */
gsm48_decode_cell_sel_param(s, &si->cell_sel_par);
/* RACH Control Parameter */
@@ -828,7 +826,7 @@
"read.\n");
s->cell_id = ntohs(si->cell_identity);
/* LAI */
- gsm48_decode_lai_hex(&si->lai, &s->mcc, &s->mnc, &s->lac);
+ gsm48_decode_lai2(&si->lai, &s->lai);
/* Cell Options (SACCH) */
gsm48_decode_cellopt_sacch(s, &si->cell_options);
/* NCC Permitted */
@@ -923,29 +921,3 @@
return 0;
}
-
-int gsm48_encode_lai_hex(struct gsm48_loc_area_id *lai,
- uint16_t mcc, uint16_t mnc, uint16_t lac)
-{
- lai->digits[0] = (mcc >> 8) | (mcc & 0xf0);
- lai->digits[1] = (mcc & 0x0f) | (mnc << 4);
- lai->digits[2] = (mnc >> 8) | (mnc & 0xf0);
- lai->lac = htons(lac);
-
- return 0;
-}
-
-int gsm48_decode_lai_hex(const struct gsm48_loc_area_id *lai,
- uint16_t *mcc, uint16_t *mnc, uint16_t *lac)
-{
- *mcc = ((lai->digits[0] & 0x0f) << 8)
- | (lai->digits[0] & 0xf0)
- | (lai->digits[1] & 0x0f);
- *mnc = ((lai->digits[2] & 0x0f) << 8)
- | (lai->digits[2] & 0xf0)
- | ((lai->digits[1] & 0xf0) >> 4);
- *lac = ntohs(lai->lac);
-
- return 0;
-}
-
diff --git a/src/host/layer23/src/common/vty.c b/src/host/layer23/src/common/vty.c
index 427c8aa..424efb2 100644
--- a/src/host/layer23/src/common/vty.c
+++ b/src/host/layer23/src/common/vty.c
@@ -503,18 +503,16 @@
return CMD_WARNING;
}
if (argc >= 3) {
- uint16_t mcc = gsm_input_mcc((char *)argv[1]);
- uint16_t mnc = gsm_input_mnc((char *)argv[2]);
- if (mcc == GSM_INPUT_INVALID) {
+ struct osmo_plmn_id plmn;
+ if (osmo_mcc_from_str(argv[1], &plmn.mcc) < 0) {
vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
- if (mnc == GSM_INPUT_INVALID) {
+ if (osmo_mnc_from_str(argv[2], &plmn.mnc, &plmn.mnc_3_digits) < 0) {
vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
- set->test_sim.rplmn_mcc = mcc;
- set->test_sim.rplmn_mnc = mnc;
+ memcpy(&set->test_sim.rplmn, &plmn, sizeof(plmn));
set->test_sim.rplmn_valid = 1;
} else {
set->test_sim.rplmn_valid = 0;
@@ -743,26 +741,26 @@
" (use 0000 to remove LAI)")
{
struct osmocom_ms *ms;
- uint16_t mcc = gsm_input_mcc((char *)argv[1]),
- mnc = gsm_input_mnc((char *)argv[2]),
- lac = strtoul(argv[3], NULL, 16);
+ struct osmo_plmn_id plmn;
+ uint16_t lac;
ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
- if (mcc == GSM_INPUT_INVALID) {
+ if (osmo_mcc_from_str(argv[1], &plmn.mcc) < 0) {
vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
- if (mnc == GSM_INPUT_INVALID) {
+ if (osmo_mnc_from_str(argv[2], &plmn.mnc, &plmn.mnc_3_digits) < 0) {
vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
- ms->subscr.mcc = mcc;
- ms->subscr.mnc = mnc;
- ms->subscr.lac = lac;
+ lac = strtoul(argv[3], NULL, 0);
+
+ memcpy(&ms->subscr.lai.plmn, &plmn, sizeof(plmn));
+ ms->subscr.lai.lac = lac;
ms->subscr.tmsi = GSM_RESERVED_TMSI;
gsm_subscr_write_loci(ms);
@@ -1044,7 +1042,9 @@
struct gsm_settings *set = &ms->settings;
set->test_sim.rplmn_valid = 0;
- set->test_sim.rplmn_mcc = set->test_sim.rplmn_mnc = 1;
+ set->test_sim.rplmn.mcc = 1;
+ set->test_sim.rplmn.mnc = 1;
+ set->test_sim.rplmn.mnc_3_digits = false;
set->test_sim.lac = 0x0000;
set->test_sim.tmsi = GSM_RESERVED_TMSI;
@@ -1058,20 +1058,18 @@
{
struct osmocom_ms *ms = vty->index;
struct gsm_settings *set = &ms->settings;
- uint16_t mcc = gsm_input_mcc((char *)argv[0]),
- mnc = gsm_input_mnc((char *)argv[1]);
+ struct osmo_plmn_id plmn;
- if (mcc == GSM_INPUT_INVALID) {
+ if (osmo_mcc_from_str(argv[0], &plmn.mcc) < 0) {
vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
- if (mnc == GSM_INPUT_INVALID) {
+ if (osmo_mnc_from_str(argv[1], &plmn.mnc, &plmn.mnc_3_digits) < 0) {
vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
set->test_sim.rplmn_valid = 1;
- set->test_sim.rplmn_mcc = mcc;
- set->test_sim.rplmn_mnc = mnc;
+ memcpy(&set->test_sim.rplmn, &plmn, sizeof(plmn));
if (argc >= 3)
set->test_sim.lac = strtoul(argv[2], NULL, 16);
@@ -1205,8 +1203,8 @@
(set->test_sim.barr) ? "" : "no ", VTY_NEWLINE);
if (set->test_sim.rplmn_valid) {
vty_out(vty, "%s rplmn %s %s", prefix,
- gsm_print_mcc(set->test_sim.rplmn_mcc),
- gsm_print_mnc(set->test_sim.rplmn_mnc));
+ osmo_mcc_name(set->test_sim.rplmn.mcc),
+ osmo_mnc_name(set->test_sim.rplmn.mnc, set->test_sim.rplmn.mnc_3_digits));
if (set->test_sim.lac > 0x0000 && set->test_sim.lac < 0xfffe) {
vty_out(vty, " 0x%04x", set->test_sim.lac);
if (set->test_sim.tmsi != GSM_RESERVED_TMSI) {
diff --git a/src/host/layer23/src/misc/cell_log.c b/src/host/layer23/src/misc/cell_log.c
index 7635f1f..ed4d74d 100644
--- a/src/host/layer23/src/misc/cell_log.c
+++ b/src/host/layer23/src/misc/cell_log.c
@@ -98,7 +98,7 @@
uint16_t flags;
uint8_t bsic;
int8_t rxlev_dbm;
- uint16_t mcc, mnc, lac, cellid;
+ struct osmo_cell_global_id cgi;
uint8_t ta;
double latitude, longitude;
} log_si;
@@ -187,9 +187,10 @@
if (log_si.ta != 0xff)
sprintf(ta_str, " TA=%d", log_si.ta);
- LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
- arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
- gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC-MNC=%s (%s, %s)%s\n",
+ arfcn, osmo_plmn_name(&s->lai.plmn),
+ gsm_get_mcc(s->lai.plmn.mcc),
+ gsm_get_mnc(&s->lai.plmn), ta_str);
LOGFILE("[sysinfo]\n");
LOGFILE("arfcn %d\n", s->arfcn);
diff --git a/src/host/layer23/src/misc/gsmmap.c b/src/host/layer23/src/misc/gsmmap.c
index d98f230..378b358 100644
--- a/src/host/layer23/src/misc/gsmmap.c
+++ b/src/host/layer23/src/misc/gsmmap.c
@@ -121,13 +121,13 @@
23);
printf("--------------------------------------------------------------------------\n");
gsm48_sysinfo_dump(&s, sysinfo.arfcn, print_si, stdout, NULL);
- mcc = get_node_mcc(s.mcc);
+ mcc = get_node_mcc(s.lai.plmn.mcc);
if (!mcc)
nomem();
- mnc = get_node_mnc(mcc, s.mnc);
+ mnc = get_node_mnc(mcc, s.lai.plmn.mnc, s.lai.plmn.mnc_3_digits);
if (!mnc)
nomem();
- lac = get_node_lac(mnc, s.lac);
+ lac = get_node_lac(mnc, s.lai.lac);
if (!lac)
nomem();
cell = get_node_cell(lac, s.cell_id);
@@ -296,8 +296,7 @@
}
-void kml_meas(FILE *outfp, struct node_meas *meas, int n, uint16_t mcc,
- uint16_t mnc, uint16_t lac, uint16_t cellid)
+static void kml_meas(FILE *outfp, struct node_meas *meas, int n, const struct osmo_cell_global_id *cgi)
{
struct tm *tm = localtime(&meas->gmt);
@@ -305,8 +304,11 @@
fprintf(outfp, "\t\t\t\t\t\t<name>%d: %d</name>\n", n, meas->rxlev);
fprintf(outfp, "\t\t\t\t\t\t<description>\n");
fprintf(outfp, "MCC=%s MNC=%s\nLAC=%04x CELL-ID=%04x\n(%s %s)\n",
- gsm_print_mcc(mcc), gsm_print_mnc(mnc), lac, cellid,
- gsm_get_mcc(mcc), gsm_get_mnc(mcc, mnc));
+ osmo_mcc_name(cgi->lai.plmn.mcc),
+ osmo_mnc_name(cgi->lai.plmn.mnc, cgi->lai.plmn.mnc_3_digits),
+ cgi->lai.lac, cgi->cell_identity,
+ gsm_get_mcc(cgi->lai.plmn.mcc),
+ gsm_get_mnc(&cgi->lai.plmn));
fprintf(outfp, "\n%s", asctime(tm));
fprintf(outfp, "RX-LEV %d dBm\n", meas->rxlev);
if (meas->ta_valid)
@@ -423,11 +425,11 @@
return;
fprintf(outfp, "\t\t\t\t\t<Placemark>\n");
- fprintf(outfp, "\t\t\t\t\t\t<name>MCC=%s MNC=%s\nLAC=%04x "
- "CELL-ID=%04x\n(%s %s)</name>\n", gsm_print_mcc(cell->s.mcc),
- gsm_print_mnc(cell->s.mnc), cell->s.lac, cell->s.cell_id,
- gsm_get_mcc(cell->s.mcc),
- gsm_get_mnc(cell->s.mcc, cell->s.mnc));
+ fprintf(outfp, "\t\t\t\t\t\t<name>LAI=%s "
+ "CELL-ID=%04x\n(%s %s)</name>\n",
+ osmo_lai_name(&cell->s.lai), cell->s.cell_id,
+ gsm_get_mcc(cell->s.lai.plmn.mcc),
+ gsm_get_mnc(&cell->s.lai.plmn));
fprintf(outfp, "\t\t\t\t\t\t<description>\n");
gsm48_sysinfo_dump(&cell->s, cell->sysinfo.arfcn, print_si, outfp,
NULL);
@@ -576,15 +578,20 @@
/* folder open */
fprintf(outfp, "\t<Folder>\n");
fprintf(outfp, "\t\t<name>MCC %s (%s)</name>\n",
- gsm_print_mcc(mcc->mcc), gsm_get_mcc(mcc->mcc));
+ osmo_mcc_name(mcc->mcc), gsm_get_mcc(mcc->mcc));
fprintf(outfp, "\t\t<open>0</open>\n");
mnc = mcc->mnc;
while (mnc) {
+ struct osmo_plmn_id plmn = {
+ .mcc = mcc->mcc,
+ .mnc = mnc->mnc,
+ .mnc_3_digits = mnc->mnc_3_digits,
+ };
printf(" MNC: %02x\n", mnc->mnc);
/* folder open */
fprintf(outfp, "\t\t<Folder>\n");
fprintf(outfp, "\t\t\t<name>MNC %s (%s)</name>\n",
- gsm_print_mnc(mnc->mnc), gsm_get_mnc(mcc->mcc, mnc->mnc));
+ osmo_mnc_name(mnc->mnc, mnc->mnc_3_digits), gsm_get_mnc(&plmn));
fprintf(outfp, "\t\t\t<open>0</open>\n");
lac = mnc->lac;
while (lac) {
@@ -604,9 +611,20 @@
while (meas) {
if (meas->ta_valid)
printf(" TA: %d\n", meas->ta);
- if (meas->gps_valid)
- kml_meas(outfp, meas, ++n, mcc->mcc, mnc->mnc,
- lac->lac, cell->cellid);
+ if (meas->gps_valid) {
+ struct osmo_cell_global_id cgi = {
+ .lai = {
+ .plmn = {
+ .mcc = mcc->mcc,
+ .mnc = mnc->mnc,
+ .mnc_3_digits = mnc->mnc_3_digits,
+ },
+ .lac = lac->lac,
+ },
+ .cell_identity = cell->cellid,
+ };
+ kml_meas(outfp, meas, ++n, &cgi);
+ }
meas = meas->next;
}
kml_cell(outfp, cell);
diff --git a/src/host/layer23/src/misc/log.c b/src/host/layer23/src/misc/log.c
index bd8de7f..577e126 100644
--- a/src/host/layer23/src/misc/log.c
+++ b/src/host/layer23/src/misc/log.c
@@ -55,18 +55,22 @@
return node_mcc;
}
-struct node_mnc *get_node_mnc(struct node_mcc *mcc, uint16_t mnc)
+struct node_mnc *get_node_mnc(struct node_mcc *mcc, uint16_t mnc, bool mnc_3_digits)
{
struct node_mnc *node_mnc;
struct node_mnc **node_mnc_p = &mcc->mnc;
while (*node_mnc_p) {
/* found in list */
- if ((*node_mnc_p)->mnc == mnc)
+ if ((*node_mnc_p)->mnc == mnc &&
+ (*node_mnc_p)->mnc_3_digits == mnc_3_digits)
return *node_mnc_p;
/* insert into list */
- if ((*node_mnc_p)->mnc > mnc)
+ if (((*node_mnc_p)->mnc > mnc) ||
+ ((*node_mnc_p)->mnc == mnc &&
+ (*node_mnc_p)->mnc_3_digits > mnc_3_digits)) {
break;
+ }
node_mnc_p = &((*node_mnc_p)->next);
}
@@ -75,6 +79,7 @@
if (!node_mnc)
return NULL;
node_mnc->mnc = mnc;
+ node_mnc->mnc_3_digits = mnc_3_digits;
node_mnc->next = *node_mnc_p;
*node_mnc_p = node_mnc;
return node_mnc;
diff --git a/src/host/layer23/src/mobile/gsm322.c b/src/host/layer23/src/mobile/gsm322.c
index d7b4154..f21cb59 100644
--- a/src/host/layer23/src/mobile/gsm322.c
+++ b/src/host/layer23/src/mobile/gsm322.c
@@ -46,8 +46,7 @@
const char *ba_version = "osmocom BA V1\n";
static void gsm322_cs_timeout(void *arg);
-static int gsm322_cs_select(struct osmocom_ms *ms, int index, uint16_t mcc,
- uint16_t mnc, int any);
+static int gsm322_cs_select(struct osmocom_ms *ms, int index, const struct osmo_plmn_id *plmn, int any);
static int gsm322_m_switch_on(struct osmocom_ms *ms, struct msgb *msg);
static void gsm322_any_timeout(void *arg);
static int gsm322_nb_scan(struct osmocom_ms *ms);
@@ -513,7 +512,7 @@
cs->si->si5 = 0; /* unset SI5* */
cs->si = NULL;
memset(&cs->sel_si, 0, sizeof(cs->sel_si));
- cs->sel_mcc = cs->sel_mnc = cs->sel_lac = cs->sel_id = 0;
+ memset(&cs->sel_cgi, 0, sizeof(cs->sel_cgi));
}
/* print to DCS logging */
@@ -535,17 +534,15 @@
}
/* del forbidden LA */
-int gsm322_del_forbidden_la(struct osmocom_ms *ms, uint16_t mcc,
- uint16_t mnc, uint16_t lac)
+int gsm322_del_forbidden_la(struct osmocom_ms *ms, const struct osmo_location_area_id *lai)
{
struct gsm322_plmn *plmn = &ms->plmn;
struct gsm322_la_list *la;
llist_for_each_entry(la, &plmn->forbidden_la, entry) {
- if (la->mcc == mcc && la->mnc == mnc && la->lac == lac) {
- LOGP(DPLMN, LOGL_INFO, "Delete from list of forbidden "
- "LAs (mcc=%s, mnc=%s, lac=%04x)\n",
- gsm_print_mcc(mcc), gsm_print_mnc(mnc), lac);
+ if (osmo_lai_cmp(&la->lai, lai) == 0) {
+ LOGP(DPLMN, LOGL_INFO, "Delete from list of forbidden LAs (LAI=%s)\n",
+ osmo_lai_name(lai));
llist_del(&la->entry);
talloc_free(la);
return 0;
@@ -556,21 +553,16 @@
}
/* add forbidden LA */
-int gsm322_add_forbidden_la(struct osmocom_ms *ms, uint16_t mcc,
- uint16_t mnc, uint16_t lac, uint8_t cause)
+int gsm322_add_forbidden_la(struct osmocom_ms *ms, const struct osmo_location_area_id *lai, uint8_t cause)
{
struct gsm322_plmn *plmn = &ms->plmn;
struct gsm322_la_list *la;
- LOGP(DPLMN, LOGL_INFO, "Add to list of forbidden LAs "
- "(mcc=%s, mnc=%s, lac=%04x)\n", gsm_print_mcc(mcc),
- gsm_print_mnc(mnc), lac);
+ LOGP(DPLMN, LOGL_INFO, "Add to list of forbidden LAs (LAI=%s)\n", osmo_lai_name(lai));
la = talloc_zero(ms, struct gsm322_la_list);
if (!la)
return -ENOMEM;
- la->mcc = mcc;
- la->mnc = mnc;
- la->lac = lac;
+ la->lai = *lai;
la->cause = cause;
llist_add_tail(&la->entry, &plmn->forbidden_la);
@@ -578,14 +570,13 @@
}
/* search forbidden LA */
-int gsm322_is_forbidden_la(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc,
- uint16_t lac)
+int gsm322_is_forbidden_la(struct osmocom_ms *ms, const struct osmo_location_area_id *lai)
{
struct gsm322_plmn *plmn = &ms->plmn;
struct gsm322_la_list *la;
llist_for_each_entry(la, &plmn->forbidden_la, entry) {
- if (la->mcc == mcc && la->mnc == mnc && la->lac == lac)
+ if (osmo_lai_cmp(&la->lai, lai) == 0)
return 1;
}
@@ -593,15 +584,13 @@
}
/* search for PLMN in all BA lists */
-static struct gsm322_ba_list *gsm322_find_ba_list(struct gsm322_cellsel *cs,
- uint16_t mcc, uint16_t mnc)
+static struct gsm322_ba_list *gsm322_find_ba_list(struct gsm322_cellsel *cs, const struct osmo_plmn_id *plmn)
{
struct gsm322_ba_list *ba, *ba_found = NULL;
/* search for BA list */
llist_for_each_entry(ba, &cs->ba_list, entry) {
- if (ba->mcc == mcc
- && ba->mnc == mnc) {
+ if (osmo_plmn_cmp(&ba->plmn, plmn) == 0) {
ba_found = ba;
break;
}
@@ -611,16 +600,14 @@
}
/* search available PLMN */
-int gsm322_is_plmn_avail_and_allow(struct gsm322_cellsel *cs, uint16_t mcc,
- uint16_t mnc)
+int gsm322_is_plmn_avail_and_allow(struct gsm322_cellsel *cs, const struct osmo_plmn_id *plmn)
{
int i;
for (i = 0; i <= 1023+299; i++) {
if ((cs->list[i].flags & GSM322_CS_FLAG_TEMP_AA)
&& cs->list[i].sysinfo
- && cs->list[i].sysinfo->mcc == mcc
- && cs->list[i].sysinfo->mnc == mnc)
+ && (osmo_plmn_cmp(&cs->list[i].sysinfo->lai.plmn, plmn) == 0))
return 1;
}
@@ -635,9 +622,12 @@
for (i = 0; i <= 1023+299; i++) {
if ((cs->list[i].flags & GSM322_CS_FLAG_SYSINFO)
&& cs->list[i].sysinfo
- && gsm_match_mnc(cs->list[i].sysinfo->mcc,
- cs->list[i].sysinfo->mnc, imsi))
+ && gsm_match_mnc(cs->list[i].sysinfo->lai.plmn.mcc,
+ cs->list[i].sysinfo->lai.plmn.mnc,
+ cs->list[i].sysinfo->lai.plmn.mnc_3_digits,
+ imsi))
return 1;
+ /* TODO: take into account mnc_3_digits, probably use osmo_mnc_cmp()*/
}
return 0;
@@ -899,8 +889,7 @@
/* search if network has multiple cells */
found = NULL;
llist_for_each_entry(temp, &temp_list, entry) {
- if (temp->mcc == cs->list[i].sysinfo->mcc
- && temp->mnc == cs->list[i].sysinfo->mnc) {
+ if (osmo_plmn_cmp(&temp->plmn, &cs->list[i].sysinfo->lai.plmn) == 0) {
found = temp;
break;
}
@@ -913,8 +902,7 @@
temp = talloc_zero(ms, struct gsm322_plmn_list);
if (!temp)
return -ENOMEM;
- temp->mcc = cs->list[i].sysinfo->mcc;
- temp->mnc = cs->list[i].sysinfo->mnc;
+ memcpy(&temp->plmn, &cs->list[i].sysinfo->lai.plmn, sizeof(temp->plmn));
temp->rxlev = cs->list[i].rxlev;
llist_add_tail(&temp->entry, &temp_list);
}
@@ -924,7 +912,7 @@
if (subscr->sim_valid) {
found = NULL;
llist_for_each_entry(temp, &temp_list, entry) {
- if (gsm_match_mnc(temp->mcc, temp->mnc, subscr->imsi)) {
+ if (gsm_match_mnc(temp->plmn.mcc, temp->plmn.mnc, temp->plmn.mnc_3_digits, subscr->imsi)) {
found = temp;
break;
}
@@ -940,8 +928,7 @@
llist_for_each_entry(sim_entry, &subscr->plmn_list, entry) {
found = NULL;
llist_for_each_entry(temp, &temp_list, entry) {
- if (temp->mcc == sim_entry->mcc
- && temp->mnc == sim_entry->mnc) {
+ if (osmo_plmn_cmp(&temp->plmn, &sim_entry->plmn) == 0) {
found = temp;
break;
}
@@ -995,16 +982,15 @@
i = 0;
llist_for_each_entry(temp, &plmn->sorted_plmn, entry) {
llist_for_each_entry(na_entry, &subscr->plmn_na, entry) {
- if (temp->mcc == na_entry->mcc
- && temp->mnc == na_entry->mnc) {
+ if (osmo_plmn_cmp(&temp->plmn, &na_entry->plmn) == 0) {
temp->cause = na_entry->cause;
break;
}
}
LOGP(DPLMN, LOGL_INFO, "Creating Sorted PLMN list. "
- "(%02d: mcc %s mnc %s allowed %s rx-lev %s)\n",
- i, gsm_print_mcc(temp->mcc),
- gsm_print_mnc(temp->mnc), (temp->cause) ? "no ":"yes",
+ "(%02d: mcc-mnc %s allowed %s rx-lev %s)\n",
+ i, osmo_plmn_name(&temp->plmn),
+ (temp->cause) ? "no ":"yes",
gsm_print_rxlev(temp->rxlev));
i++;
}
@@ -1027,9 +1013,9 @@
new_a_state(plmn, GSM322_A2_ON_PLMN);
/* start timer, if on VPLMN of home country OR special case */
- if (!gsm_match_mnc(plmn->mcc, plmn->mnc, subscr->imsi)
+ if (!gsm_match_mnc(plmn->plmn.mcc, plmn->plmn.mnc, plmn->plmn.mnc_3_digits, subscr->imsi)
&& (subscr->always_search_hplmn
- || gsm_match_mcc(plmn->mcc, subscr->imsi))
+ || gsm_match_mcc(plmn->plmn.mcc, subscr->imsi))
&& subscr->sim_valid && subscr->t6m_hplmn)
start_plmn_timer(plmn, subscr->t6m_hplmn * 360);
else
@@ -1070,7 +1056,7 @@
int found;
/* any allowable PLMN available? */
- found = gsm322_cs_select(ms, -1, 0, 0, 0);
+ found = gsm322_cs_select(ms, -1, NULL, 0);
/* if no PLMN in list:
* this means that we are at a point where we camp on any cell or
@@ -1079,32 +1065,28 @@
if (subscr->plmn_valid) {
LOGP(DPLMN, LOGL_INFO, "Not any PLMN allowable. "
"Do limited search with RPLMN.\n");
- plmn->mcc = subscr->plmn_mcc;
- plmn->mnc = subscr->plmn_mnc;
+ memcpy(&plmn->plmn, &subscr->plmn, sizeof(struct osmo_plmn_id));
} else
if (subscr->sim_valid) {
LOGP(DPLMN, LOGL_INFO, "Not any PLMN allowable. "
"Do limited search with HPLMN.\n");
- plmn->mcc = subscr->mcc;
- plmn->mnc = subscr->mnc;
+ memcpy(&plmn->plmn, &subscr->plmn, sizeof(struct osmo_plmn_id));
} else {
LOGP(DPLMN, LOGL_INFO, "Not any PLMN allowable. "
"Do limited search with no PLMN.\n");
- plmn->mcc = 0;
- plmn->mnc = 0;
+ memset(&plmn->plmn, 0, sizeof(struct osmo_plmn_id));
}
return gsm322_a_go_wait_for_plmns(ms, msg);
}
/* select first PLMN in list */
- plmn->mcc = cs->list[found].sysinfo->mcc;
- plmn->mnc = cs->list[found].sysinfo->mnc;
+ memcpy(&plmn->plmn, &cs->list[found].sysinfo->lai.plmn, sizeof(struct osmo_plmn_id));
LOGP(DPLMN, LOGL_INFO, "PLMN available after searching PLMN list "
- "(mcc=%s mnc=%s %s, %s)\n",
- gsm_print_mcc(plmn->mcc), gsm_print_mnc(plmn->mnc),
- gsm_get_mcc(plmn->mcc), gsm_get_mnc(plmn->mcc, plmn->mnc));
+ "(mcc=-mnc=%s %s, %s)\n",
+ osmo_plmn_name(&plmn->plmn),
+ gsm_get_mcc(plmn->plmn.mcc), gsm_get_mnc(&plmn->plmn));
/* indicate New PLMN */
nmsg = gsm322_msgb_alloc(GSM322_EVENT_NEW_PLMN);
@@ -1133,10 +1115,9 @@
i = 0;
llist_for_each_entry(plmn_entry, &plmn->sorted_plmn, entry) {
/* if last selected PLMN was HPLMN, we skip that */
- if (gsm_match_mnc(plmn_entry->mcc, plmn_entry->mnc,
- subscr->imsi)
- && plmn_entry->mcc == plmn->mcc
- && plmn_entry->mnc == plmn->mnc) {
+ if (gsm_match_mnc(plmn_entry->plmn.mcc, plmn_entry->plmn.mnc,
+ plmn_entry->plmn.mnc_3_digits, subscr->imsi)
+ && (osmo_plmn_cmp(&plmn_entry->plmn, &plmn->plmn) == 0)) {
LOGP(DPLMN, LOGL_INFO, "Skip HPLMN, because it was "
"previously selected.\n");
i++;
@@ -1147,10 +1128,9 @@
plmn_first = plmn_entry;
break;
}
- LOGP(DPLMN, LOGL_INFO, "Skip PLMN (%02d: mcc=%s, mnc=%s), "
+ LOGP(DPLMN, LOGL_INFO, "Skip PLMN (%02d: mcc-mnc=%s), "
"because it is not allowed (cause %d).\n", i,
- gsm_print_mcc(plmn_entry->mcc),
- gsm_print_mnc(plmn_entry->mnc),
+ osmo_plmn_name(&plmn_entry->plmn),
plmn_entry->cause);
i++;
}
@@ -1164,15 +1144,14 @@
return 0;
}
- LOGP(DPLMN, LOGL_INFO, "Selecting PLMN from list. (%02d: mcc=%s "
- "mnc=%s %s, %s)\n", plmn->plmn_curr,
- gsm_print_mcc(plmn_first->mcc), gsm_print_mnc(plmn_first->mnc),
- gsm_get_mcc(plmn_first->mcc),
- gsm_get_mnc(plmn_first->mcc, plmn_first->mnc));
+ LOGP(DPLMN, LOGL_INFO, "Selecting PLMN from list. (%02d: mcc-mnc=%s %s, %s)\n",
+ plmn->plmn_curr,
+ osmo_plmn_name(&plmn_first->plmn),
+ gsm_get_mcc(plmn_first->plmn.mcc),
+ gsm_get_mnc(&plmn_first->plmn));
/* set current network */
- plmn->mcc = plmn_first->mcc;
- plmn->mnc = plmn_first->mnc;
+ memcpy(&plmn->plmn, &plmn_first->plmn, sizeof(struct osmo_plmn_id));
new_a_state(plmn, GSM322_A3_TRYING_PLMN);
@@ -1208,10 +1187,9 @@
plmn_next = plmn_entry;
break;
}
- LOGP(DPLMN, LOGL_INFO, "Skip PLMN (%02d: mcc=%s, mnc=%s), "
+ LOGP(DPLMN, LOGL_INFO, "Skip PLMN (%02d: mcc-mnc=%s), "
"because it is not allowed (cause %d).\n", i,
- gsm_print_mcc(plmn_entry->mcc),
- gsm_print_mnc(plmn_entry->mnc),
+ osmo_plmn_name(&plmn_entry->plmn),
plmn_entry->cause);
i++;
}
@@ -1225,13 +1203,13 @@
}
/* set next network */
- plmn->mcc = plmn_next->mcc;
- plmn->mnc = plmn_next->mnc;
+ memcpy(&plmn->plmn, &plmn_next->plmn, sizeof(struct osmo_plmn_id));
- LOGP(DPLMN, LOGL_INFO, "Selecting PLMN from list. (%02d: mcc=%s "
- "mnc=%s %s, %s)\n", plmn->plmn_curr,
- gsm_print_mcc(plmn->mcc), gsm_print_mnc(plmn->mnc),
- gsm_get_mcc(plmn->mcc), gsm_get_mnc(plmn->mcc, plmn->mnc));
+ LOGP(DPLMN, LOGL_INFO, "Selecting PLMN from list. (%02d: mcc-mnc=%s %s, %s)\n",
+ plmn->plmn_curr,
+ osmo_plmn_name(&plmn->plmn),
+ gsm_get_mcc(plmn->plmn.mcc),
+ gsm_get_mnc(&plmn->plmn));
new_a_state(plmn, GSM322_A3_TRYING_PLMN);
@@ -1268,8 +1246,7 @@
/* search current PLMN in list */
llist_for_each_entry(plmn_entry, &plmn->sorted_plmn, entry) {
- if (plmn_entry->mcc == plmn->mcc
- && plmn_entry->mnc == plmn->mnc) {
+ if (osmo_plmn_cmp(&plmn_entry->plmn, &plmn->plmn) == 0) {
plmn_found = plmn_entry;
break;
}
@@ -1305,8 +1282,8 @@
struct gsm_subscriber *subscr = &ms->subscr;
struct gsm322_msg *gm = (struct gsm322_msg *) msg->data;
- if (subscr->plmn_valid && plmn->mcc == gm->mcc
- && plmn->mnc == gm->mnc) {
+ if (subscr->plmn_valid &&
+ (osmo_plmn_cmp(&plmn->plmn, &gm->plmn) == 0)) {
struct msgb *nmsg;
new_m_state(plmn, GSM322_A1_TRYING_RPLMN);
@@ -1337,17 +1314,14 @@
int found;
/* any allowable PLMN available */
- found = gsm322_cs_select(ms, -1, 0, 0, 0);
+ found = gsm322_cs_select(ms, -1, NULL, 0);
/* if PLMN in list */
if (found >= 0) {
- LOGP(DPLMN, LOGL_INFO, "PLMN available (mcc=%s mnc=%s "
- "%s, %s)\n", gsm_print_mcc(
- cs->list[found].sysinfo->mcc),
- gsm_print_mnc(cs->list[found].sysinfo->mnc),
- gsm_get_mcc(cs->list[found].sysinfo->mcc),
- gsm_get_mnc(cs->list[found].sysinfo->mcc,
- cs->list[found].sysinfo->mnc));
+ LOGP(DPLMN, LOGL_INFO, "PLMN available (mcc-mnc=%s %s, %s)\n",
+ osmo_plmn_name(&cs->list[found].sysinfo->lai.plmn),
+ gsm_get_mcc(cs->list[found].sysinfo->lai.plmn.mcc),
+ gsm_get_mnc(&cs->list[found].sysinfo->lai.plmn));
return gsm322_a_sel_first_plmn(ms, msg);
}
@@ -1374,17 +1348,17 @@
/* if there is a registered PLMN */
if (subscr->plmn_valid) {
/* select the registered PLMN */
- plmn->mcc = subscr->plmn_mcc;
- plmn->mnc = subscr->plmn_mnc;
+ memcpy(&plmn->plmn, &subscr->plmn, sizeof(struct osmo_plmn_id));
LOGP(DSUM, LOGL_INFO, "Start search of last registered PLMN "
- "(mcc=%s mnc=%s %s, %s)\n", gsm_print_mcc(plmn->mcc),
- gsm_print_mnc(plmn->mnc), gsm_get_mcc(plmn->mcc),
- gsm_get_mnc(plmn->mcc, plmn->mnc));
- LOGP(DPLMN, LOGL_INFO, "Use RPLMN (mcc=%s mnc=%s "
- "%s, %s)\n", gsm_print_mcc(plmn->mcc),
- gsm_print_mnc(plmn->mnc), gsm_get_mcc(plmn->mcc),
- gsm_get_mnc(plmn->mcc, plmn->mnc));
+ "(mcc-%s %s, %s)\n",
+ osmo_plmn_name(&plmn->plmn),
+ gsm_get_mcc(plmn->plmn.mcc),
+ gsm_get_mnc(&plmn->plmn));
+ LOGP(DPLMN, LOGL_INFO, "Use RPLMN (mcc-mnc=%s %s, %s)\n",
+ osmo_plmn_name(&plmn->plmn),
+ gsm_get_mcc(plmn->plmn.mcc),
+ gsm_get_mnc(&plmn->plmn));
new_a_state(plmn, GSM322_A1_TRYING_RPLMN);
@@ -1397,7 +1371,7 @@
return 0;
}
- plmn->mcc = plmn->mnc = 0;
+ memset(&plmn->plmn, 0, sizeof(plmn->plmn));
/* initiate search at cell selection */
LOGP(DSUM, LOGL_INFO, "Search for network\n");
@@ -1440,7 +1414,7 @@
gsm322_cs_sendmsg(ms, nmsg);
/* flush list of PLMNs */
- gsm_subscr_del_forbidden_plmn(&ms->subscr, 0, 0);
+ gsm_subscr_del_forbidden_plmn(&ms->subscr, NULL);
return gsm322_a_switch_on(ms, msg);
}
@@ -1518,25 +1492,22 @@
l23_vty_ms_notify(ms, NULL);
switch (msg_type) {
case GSM322_EVENT_REG_FAILED:
- l23_vty_ms_notify(ms, "Failed to register to network %s, %s "
- "(%s, %s)\n",
- gsm_print_mcc(plmn->mcc), gsm_print_mnc(plmn->mnc),
- gsm_get_mcc(plmn->mcc),
- gsm_get_mnc(plmn->mcc, plmn->mnc));
+ l23_vty_ms_notify(ms, "Failed to register to network %s (%s, %s)\n",
+ osmo_plmn_name(&plmn->plmn),
+ gsm_get_mcc(plmn->plmn.mcc),
+ gsm_get_mnc(&plmn->plmn));
break;
case GSM322_EVENT_NO_CELL_FOUND:
- l23_vty_ms_notify(ms, "No cell found for network %s, %s "
- "(%s, %s)\n",
- gsm_print_mcc(plmn->mcc), gsm_print_mnc(plmn->mnc),
- gsm_get_mcc(plmn->mcc),
- gsm_get_mnc(plmn->mcc, plmn->mnc));
+ l23_vty_ms_notify(ms, "No cell found for network %s (%s, %s)\n",
+ osmo_plmn_name(&plmn->plmn),
+ gsm_get_mcc(plmn->plmn.mcc),
+ gsm_get_mnc(&plmn->plmn));
break;
case GSM322_EVENT_ROAMING_NA:
- l23_vty_ms_notify(ms, "Roaming not allowed to network %s, %s "
- "(%s, %s)\n",
- gsm_print_mcc(plmn->mcc), gsm_print_mnc(plmn->mnc),
- gsm_get_mcc(plmn->mcc),
- gsm_get_mnc(plmn->mcc, plmn->mnc));
+ l23_vty_ms_notify(ms, "Roaming not allowed to network %s (%s, %s)\n",
+ osmo_plmn_name(&plmn->plmn),
+ gsm_get_mcc(plmn->plmn.mcc),
+ gsm_get_mnc(&plmn->plmn));
break;
}
@@ -1545,11 +1516,10 @@
else {
l23_vty_ms_notify(ms, "Search or select from network:\n");
llist_for_each_entry(temp, &plmn->sorted_plmn, entry)
- l23_vty_ms_notify(ms, " Network %s, %s (%s, %s)\n",
- gsm_print_mcc(temp->mcc),
- gsm_print_mnc(temp->mnc),
- gsm_get_mcc(temp->mcc),
- gsm_get_mnc(temp->mcc, temp->mnc));
+ l23_vty_ms_notify(ms, " Network mcc-mnc=%s (%s, %s)\n",
+ osmo_plmn_name(&temp->plmn),
+ gsm_get_mcc(temp->plmn.mcc),
+ gsm_get_mnc(&temp->plmn));
}
/* go Not on PLMN state */
@@ -1582,7 +1552,7 @@
* selected by the user. this prevents from switching back to the
* last selected PLMN and destroying the list of scanned networks.
*/
- plmn->mcc = plmn->mnc = 0;
+ memset(&plmn->plmn, 0, sizeof(plmn->plmn));
if (!subscr->sim_valid) {
return 0;
@@ -1634,17 +1604,16 @@
struct msgb *nmsg;
/* select the registered PLMN */
- plmn->mcc = subscr->plmn_mcc;
- plmn->mnc = subscr->plmn_mnc;
+ memcpy(&plmn->plmn, &subscr->plmn, sizeof(struct osmo_plmn_id));
- LOGP(DSUM, LOGL_INFO, "Start search of last registered PLMN "
- "(mcc=%s mnc=%s %s, %s)\n", gsm_print_mcc(plmn->mcc),
- gsm_print_mnc(plmn->mnc), gsm_get_mcc(plmn->mcc),
- gsm_get_mnc(plmn->mcc, plmn->mnc));
- LOGP(DPLMN, LOGL_INFO, "Use RPLMN (mcc=%s mnc=%s "
- "%s, %s)\n", gsm_print_mcc(plmn->mcc),
- gsm_print_mnc(plmn->mnc), gsm_get_mcc(plmn->mcc),
- gsm_get_mnc(plmn->mcc, plmn->mnc));
+ LOGP(DSUM, LOGL_INFO, "Start search of last registered PLMN (mcc-mnc=%s %s, %s)\n",
+ osmo_plmn_name(&plmn->plmn),
+ gsm_get_mcc(plmn->plmn.mcc),
+ gsm_get_mnc(&plmn->plmn));
+ LOGP(DPLMN, LOGL_INFO, "Use RPLMN (mcc-mnc=%s %s, %s)\n",
+ osmo_plmn_name(&plmn->plmn),
+ gsm_get_mcc(plmn->plmn.mcc),
+ gsm_get_mnc(&plmn->plmn));
new_m_state(plmn, GSM322_M1_TRYING_RPLMN);
@@ -1657,7 +1626,7 @@
return 0;
}
- plmn->mcc = plmn->mnc = 0;
+ memset(&plmn->plmn, 0, sizeof(plmn->plmn));
/* initiate search at cell selection */
LOGP(DSUM, LOGL_INFO, "Search for network\n");
@@ -1704,7 +1673,7 @@
gsm322_cs_sendmsg(ms, nmsg);
/* flush list of PLMNs */
- gsm_subscr_del_forbidden_plmn(&ms->subscr, 0, 0);
+ gsm_subscr_del_forbidden_plmn(&ms->subscr, NULL);
return gsm322_m_switch_on(ms, msg);
}
@@ -1717,8 +1686,7 @@
/* set last registered PLMN */
subscr->plmn_valid = 1;
- subscr->plmn_mcc = plmn->mcc;
- subscr->plmn_mnc = plmn->mnc;
+ memcpy(&subscr->plmn, &plmn->plmn, sizeof(struct osmo_plmn_id));
new_m_state(plmn, GSM322_M2_ON_PLMN);
@@ -1753,15 +1721,15 @@
struct msgb *nmsg;
/* use user selection */
- plmn->mcc = gm->mcc;
- plmn->mnc = gm->mnc;
+ memcpy(&plmn->plmn, &gm->plmn, sizeof(struct osmo_plmn_id));
- LOGP(DPLMN, LOGL_INFO, "User selects PLMN. (mcc=%s mnc=%s "
- "%s, %s)\n", gsm_print_mcc(plmn->mcc), gsm_print_mnc(plmn->mnc),
- gsm_get_mcc(plmn->mcc), gsm_get_mnc(plmn->mcc, plmn->mnc));
+ LOGP(DPLMN, LOGL_INFO, "User selects PLMN. (mcc-mnc=%s %s, %s)\n",
+ osmo_plmn_name(&plmn->plmn),
+ gsm_get_mcc(plmn->plmn.mcc),
+ gsm_get_mnc(&plmn->plmn));
/* if selected PLMN is in list of forbidden PLMNs */
- gsm_subscr_del_forbidden_plmn(subscr, plmn->mcc, plmn->mnc);
+ gsm_subscr_del_forbidden_plmn(subscr, &plmn->plmn);
new_m_state(plmn, GSM322_M4_TRYING_PLMN);
@@ -1817,8 +1785,7 @@
*/
/* select a suitable and allowable cell */
-static int gsm322_cs_select(struct osmocom_ms *ms, int index, uint16_t mcc,
- uint16_t mnc, int any)
+static int gsm322_cs_select(struct osmocom_ms *ms, int index, const struct osmo_plmn_id *plmn, int any)
{
struct gsm322_cellsel *cs = &ms->cellsel;
struct gsm_settings *set = &ms->settings;
@@ -1906,58 +1873,51 @@
if ((cs->list[i].flags & GSM322_CS_FLAG_FORBIDD)) {
if (!any) {
LOGP(DCS, LOGL_INFO, "Skip ARFCN %s: Cell is "
- "in list of forbidden LAs. (mcc=%s "
- "mnc=%s lai=%04x)\n",
+ "in list of forbidden LAs. (lai=%s)\n",
gsm_print_arfcn(index2arfcn(i)),
- gsm_print_mcc(s->mcc),
- gsm_print_mnc(s->mnc), s->lac);
+ osmo_lai_name(&s->lai));
continue;
}
LOGP(DCS, LOGL_INFO, "Accept ARFCN %s: Cell is in "
"list of forbidden LAs, but we search for any "
- "cell. (mcc=%s mnc=%s lai=%04x)\n",
+ "cell. (lai=%s)\n",
gsm_print_arfcn(index2arfcn(i)),
- gsm_print_mcc(s->mcc),
- gsm_print_mnc(s->mnc), s->lac);
+ osmo_lai_name(&s->lai));
cs->list[i].flags &= ~GSM322_CS_FLAG_TEMP_AA;
}
/* if cell is in list of forbidden PLMNs */
- if (gsm_subscr_is_forbidden_plmn(subscr, s->mcc, s->mnc)) {
+ if (gsm_subscr_is_forbidden_plmn(subscr, &s->lai.plmn)) {
if (!any) {
LOGP(DCS, LOGL_INFO, "Skip ARFCN %s: Cell is "
- "in list of forbidden PLMNs. (mcc=%s "
- "mnc=%s)\n",
+ "in list of forbidden PLMNs. (mcc-mnc=%s)\n",
gsm_print_arfcn(index2arfcn(i)),
- gsm_print_mcc(s->mcc),
- gsm_print_mnc(s->mnc));
+ osmo_plmn_name(&s->lai.plmn));
continue;
}
LOGP(DCS, LOGL_INFO, "Accept ARFCN %s: Cell is in list "
"of forbidden PLMNs, but we search for any "
- "cell. (mcc=%s mnc=%s)\n",
+ "cell. (mcc-mnc=%s)\n",
gsm_print_arfcn(index2arfcn(i)),
- gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc));
+ osmo_plmn_name(&s->lai.plmn));
cs->list[i].flags &= ~GSM322_CS_FLAG_TEMP_AA;
}
/* if we search a specific PLMN, but it does not match */
- if (!any && mcc && (mcc != s->mcc
- || mnc != s->mnc)) {
+ if (!any && plmn && (osmo_plmn_cmp(&s->lai.plmn, plmn) != 0)) {
LOGP(DCS, LOGL_INFO, "Skip ARFCN %s: PLMN of cell "
- "does not match target PLMN. (mcc=%s "
- "mnc=%s)\n", gsm_print_arfcn(index2arfcn(i)),
- gsm_print_mcc(s->mcc),
- gsm_print_mnc(s->mnc));
+ "does not match target PLMN. (mcc-mnc=%s)\n",
+ gsm_print_arfcn(index2arfcn(i)),
+ osmo_plmn_name(&s->lai.plmn));
continue;
}
LOGP(DCS, LOGL_INFO, "Cell ARFCN %s: Cell found, (rxlev=%s "
- "mcc=%s mnc=%s lac=%04x %s, %s)\n",
- gsm_print_arfcn(index2arfcn(i)),
+ "lai=%s %s, %s)\n",
+ gsm_print_arfcn(index2arfcn(i)),
gsm_print_rxlev(cs->list[i].rxlev),
- gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc), s->lac,
- gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc));
+ osmo_lai_name(&s->lai),
+ gsm_get_mcc(s->lai.plmn.mcc), gsm_get_mnc(&s->lai.plmn));
/* find highest power cell */
if (found < 0 || cs->list[i].rxlev > power) {
@@ -1974,8 +1934,7 @@
}
/* re-select a suitable and allowable cell */
-static int gsm322_cs_reselect(struct osmocom_ms *ms, uint16_t mcc,
- uint16_t mnc, int any)
+static int gsm322_cs_reselect(struct osmocom_ms *ms, const struct osmo_plmn_id *plmn, int any)
{
struct gsm322_cellsel *cs = &ms->cellsel;
struct gsm_subscriber *subscr = &ms->subscr;
@@ -2004,18 +1963,18 @@
/* if cell is in list of forbidden LAs */
if (!any && (cs->list[i].flags & GSM322_CS_FLAG_FORBIDD)) {
LOGP(DCS, LOGL_INFO, "Skip ARFCN %s: Cell is in list of "
- "forbidden LAs. (mcc=%s mnc=%s lai=%04x)\n",
- gsm_print_arfcn(index2arfcn(i)), gsm_print_mcc(s->mcc),
- gsm_print_mnc(s->mnc), s->lac);
+ "forbidden LAs. (lai=%s)\n",
+ gsm_print_arfcn(index2arfcn(i)),
+ osmo_lai_name(&s->lai));
return -1;
}
/* if cell is in list of forbidden PLMNs */
- if (!any && gsm_subscr_is_forbidden_plmn(subscr, s->mcc, s->mnc)) {
+ if (!any && gsm_subscr_is_forbidden_plmn(subscr, &s->lai.plmn)) {
LOGP(DCS, LOGL_INFO, "Skip ARFCN %s: Cell is in "
- "list of forbidden PLMNs. (mcc=%s mnc=%s)\n",
+ "list of forbidden PLMNs. (mcc-mnc=%s)\n",
gsm_print_arfcn(index2arfcn(i)),
- gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc));
+ osmo_plmn_name(&s->lai.plmn));
return -1;
}
@@ -2030,21 +1989,21 @@
}
/* if we search a specific PLMN, but it does not match */
- if (!any && mcc && (mcc != s->mcc
- || mnc != s->mnc)) {
+ if (!any && plmn && (osmo_plmn_cmp(plmn, &s->lai.plmn) != 0)) {
LOGP(DCS, LOGL_INFO, "Skip ARFCN %s: PLMN of cell "
- "does not match target PLMN. (mcc=%s mnc=%s)\n",
- gsm_print_arfcn(index2arfcn(i)), gsm_print_mcc(s->mcc),
- gsm_print_mnc(s->mnc));
+ "does not match target PLMN. (mcc-mnc=%s)\n",
+ gsm_print_arfcn(index2arfcn(i)),
+ osmo_plmn_name(&s->lai.plmn));
return -1;
}
LOGP(DCS, LOGL_INFO, "Cell ARFCN %s: Neighbour cell accepted, "
- "(rxlev=%s mcc=%s mnc=%s lac=%04x %s, %s)\n",
+ "(rxlev=%s lai=%s %s, %s)\n",
gsm_print_arfcn(index2arfcn(i)),
gsm_print_rxlev(cs->list[i].rxlev),
- gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc), s->lac,
- gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc));
+ osmo_lai_name(&s->lai),
+ gsm_get_mcc(s->lai.plmn.mcc),
+ gsm_get_mnc(&s->lai.plmn));
return i;
}
@@ -2053,12 +2012,13 @@
static int gsm322_search_end(struct osmocom_ms *ms)
{
struct gsm322_cellsel *cs = &ms->cellsel;
- struct gsm322_plmn *plmn = &ms->plmn;
+ struct gsm322_plmn *plmn322 = &ms->plmn;
struct msgb *nmsg;
struct gsm322_msg *ngm;
int msg_type = -1; /* no message to be sent */
- int tune_back = 0, mcc = 0, mnc = 0;
+ int tune_back = 0;
int found;
+ struct osmo_plmn_id plmn = {};
switch (cs->state) {
case GSM322_ANY_SEARCH:
@@ -2066,12 +2026,12 @@
LOGP(DCS, LOGL_INFO, "Any cell search finished.\n");
/* create AA flag */
- found = gsm322_cs_select(ms, -1, 0, 0, 0);
+ found = gsm322_cs_select(ms, -1, NULL, 0);
/* if no cell is found, or if we don't wait for any available
* and allowable PLMN to appear, we just continue to camp */
if (ms->settings.plmn_mode != PLMN_MODE_AUTO
- || plmn->state != GSM322_A4_WAIT_FOR_PLMN
+ || plmn322->state != GSM322_A4_WAIT_FOR_PLMN
|| found < 0) {
tune_back = 1;
gsm322_c_camp_any_cell(ms, NULL);
@@ -2080,10 +2040,9 @@
/* indicate available PLMN, include selected PLMN, if found */
msg_type = GSM322_EVENT_PLMN_AVAIL;
- if (gsm322_is_plmn_avail_and_allow(cs, plmn->mcc, plmn->mnc)) {
+ if (gsm322_is_plmn_avail_and_allow(cs, &plmn322->plmn)) {
/* set what PLMN becomes available */
- mcc = plmn->mcc;
- mnc = plmn->mnc;
+ memcpy(&plmn, &plmn322->plmn, sizeof(struct osmo_plmn_id));
}
new_c_state(cs, GSM322_C0_NULL);
@@ -2096,7 +2055,7 @@
LOGP(DCS, LOGL_INFO, "PLMN search finished.\n");
/* create AA flag */
- gsm322_cs_select(ms, -1, 0, 0, 0);
+ gsm322_cs_select(ms, -1, NULL, 0);
new_c_state(cs, GSM322_C0_NULL);
@@ -2148,8 +2107,7 @@
if (!nmsg)
return -ENOMEM;
ngm = (struct gsm322_msg *) nmsg->data;
- ngm->mcc = mcc;
- ngm->mnc = mnc;
+ memcpy(&ngm->plmn, &plmn, sizeof(struct osmo_plmn_id));
gsm322_plmn_sendmsg(ms, nmsg);
}
@@ -2166,10 +2124,8 @@
memcpy(cs->list[cs->arfci].sysinfo, &cs->sel_si,
sizeof(struct gsm48_sysinfo));
cs->si = cs->list[cs->arfci].sysinfo;
- cs->sel_mcc = cs->si->mcc;
- cs->sel_mnc = cs->si->mnc;
- cs->sel_lac = cs->si->lac;
- cs->sel_id = cs->si->cell_id;
+ cs->sel_cgi.lai = cs->si->lai;
+ cs->sel_cgi.cell_identity = cs->si->cell_id;
LOGP(DCS, LOGL_INFO, "Tuning back to frequency %s after full "
"search.\n", gsm_print_arfcn(cs->arfcn));
cs->sync_retries = SYNC_RETRIES;
@@ -2317,17 +2273,17 @@
cs->list[cs->arfci].flags &= ~GSM322_CS_FLAG_BARRED;
/* store selected network */
- if (s->mcc) {
- if (gsm322_is_forbidden_la(ms, s->mcc, s->mnc, s->lac))
+ if (s->lai.plmn.mcc) {
+ if (gsm322_is_forbidden_la(ms, &s->lai))
cs->list[cs->arfci].flags |= GSM322_CS_FLAG_FORBIDD;
else
cs->list[cs->arfci].flags &= ~GSM322_CS_FLAG_FORBIDD;
}
- LOGP(DCS, LOGL_DEBUG, "Scan frequency %s: Cell found. (rxlev %s "
- "mcc %s mnc %s lac %04x)\n", gsm_print_arfcn(cs->arfcn),
+ LOGP(DCS, LOGL_DEBUG, "Scan frequency %s: Cell found. (rxlev %s lai %s)\n",
+ gsm_print_arfcn(cs->arfcn),
gsm_print_rxlev(cs->list[cs->arfci].rxlev),
- gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc), s->lac);
+ osmo_lai_name(&s->lai));
/* selected PLMN (auto) becomes available during "any search" */
if (ms->settings.plmn_mode == PLMN_MODE_AUTO
@@ -2336,10 +2292,10 @@
|| cs->state == GSM322_C8_ANY_CELL_RESEL
|| cs->state == GSM322_C9_CHOOSE_ANY_CELL)
&& plmn->state == GSM322_A4_WAIT_FOR_PLMN
- && s->mcc == plmn->mcc && s->mnc == plmn->mnc) {
+ && (osmo_plmn_cmp(&s->lai.plmn, &plmn->plmn) == 0)) {
LOGP(DCS, LOGL_INFO, "Candidate network to become available "
"again\n");
- found = gsm322_cs_select(ms, cs->arfci, s->mcc, s->mnc, 0);
+ found = gsm322_cs_select(ms, cs->arfci, &s->lai.plmn, 0);
if (found >= 0) {
LOGP(DCS, LOGL_INFO, "Selected PLMN in \"A4_WAIT_F"
"OR_PLMN\" state becomes available.\n");
@@ -2350,8 +2306,7 @@
return -ENOMEM;
/* set what PLMN becomes available */
ngm = (struct gsm322_msg *) nmsg->data;
- ngm->mcc = plmn->mcc;
- ngm->mnc = plmn->mcc;
+ memcpy(&ngm->plmn, &plmn->plmn, sizeof(struct osmo_plmn_id));
gsm322_plmn_sendmsg(ms, nmsg);
new_c_state(cs, GSM322_C0_NULL);
@@ -2367,10 +2322,10 @@
|| cs->state == GSM322_C8_ANY_CELL_RESEL
|| cs->state == GSM322_C9_CHOOSE_ANY_CELL)
&& plmn->state == GSM322_M3_NOT_ON_PLMN
- && s->mcc == plmn->mcc && s->mnc == plmn->mnc) {
+ && (osmo_plmn_cmp(&s->lai.plmn, &plmn->plmn) == 0)) {
LOGP(DCS, LOGL_INFO, "Candidate network to become available "
"again\n");
- found = gsm322_cs_select(ms, cs->arfci, s->mcc, s->mnc, 0);
+ found = gsm322_cs_select(ms, cs->arfci, &s->lai.plmn, 0);
if (found >= 0) {
LOGP(DCS, LOGL_INFO, "Current selected PLMN in \"M3_N"
"OT_ON_PLMN\" state becomes available.\n");
@@ -2410,9 +2365,9 @@
if (cs->state == GSM322_C4_NORMAL_CELL_RESEL
|| cs->state == GSM322_C8_ANY_CELL_RESEL)
- found = gsm322_cs_reselect(ms, cs->mcc, cs->mnc, any);
+ found = gsm322_cs_reselect(ms, &cs->plmn, any);
else
- found = gsm322_cs_select(ms, -1, cs->mcc, cs->mnc, any);
+ found = gsm322_cs_select(ms, -1, &cs->plmn, any);
/* if not found */
if (found < 0) {
@@ -2437,18 +2392,14 @@
cs->selected = 1;
cs->sel_arfcn = cs->arfcn;
memcpy(&cs->sel_si, cs->si, sizeof(cs->sel_si));
- cs->sel_mcc = cs->si->mcc;
- cs->sel_mnc = cs->si->mnc;
- cs->sel_lac = cs->si->lac;
- cs->sel_id = cs->si->cell_id;
+ cs->sel_cgi.lai = cs->si->lai;
+ cs->sel_cgi.cell_identity = cs->si->cell_id;
if (ms->rrlayer.monitor) {
- l23_vty_ms_notify(ms, "MON: %scell selected ARFCN=%s MCC=%s MNC=%s "
- "LAC=0x%04x cellid=0x%04x (%s %s)\n",
+ l23_vty_ms_notify(ms, "MON: %scell selected ARFCN=%s CGI=%s (%s %s)\n",
(any) ? "any " : "", gsm_print_arfcn(cs->sel_arfcn),
- gsm_print_mcc(cs->sel_mcc), gsm_print_mnc(cs->sel_mnc),
- cs->sel_lac, cs->sel_id,
- gsm_get_mcc(cs->sel_mcc),
- gsm_get_mnc(cs->sel_mcc, cs->sel_mnc));
+ osmo_cgi_name(&cs->sel_cgi),
+ gsm_get_mcc(cs->sel_cgi.lai.plmn.mcc),
+ gsm_get_mnc(&cs->sel_cgi.lai.plmn));
}
/* tell CS process about available cell */
@@ -2484,13 +2435,12 @@
/* collect system information received during dedicated mode */
if (s->si5 && (!s->nb_ext_ind_si5 || s->si5bis)) {
/* find or create ba list */
- ba = gsm322_find_ba_list(cs, s->mcc, s->mnc);
+ ba = gsm322_find_ba_list(cs, &s->lai.plmn);
if (!ba) {
ba = talloc_zero(ms, struct gsm322_ba_list);
if (!ba)
return NULL;
- ba->mcc = s->mcc;
- ba->mnc = s->mnc;
+ memcpy(&ba->plmn, &s->lai.plmn, sizeof(struct osmo_plmn_id));
llist_add_tail(&ba->entry, &cs->ba_list);
}
/* update (add) ba list */
@@ -2506,10 +2456,10 @@
}
}
if (!!memcmp(freq, ba->freq, sizeof(freq))) {
- LOGP(DCS, LOGL_INFO, "New BA list (mcc=%s mnc=%s "
- "%s, %s).\n", gsm_print_mcc(ba->mcc),
- gsm_print_mnc(ba->mnc), gsm_get_mcc(ba->mcc),
- gsm_get_mnc(ba->mcc, ba->mnc));
+ LOGP(DCS, LOGL_INFO, "New BA list (mcc-mnc=%s %s, %s).\n",
+ osmo_plmn_name(&ba->plmn),
+ gsm_get_mcc(ba->plmn.mcc),
+ gsm_get_mnc(&ba->plmn));
memcpy(ba->freq, freq, sizeof(freq));
}
}
@@ -2526,13 +2476,12 @@
uint8_t freq[128+38];
/* find or create ba list */
- ba = gsm322_find_ba_list(cs, s->mcc, s->mnc);
+ ba = gsm322_find_ba_list(cs, &s->lai.plmn);
if (!ba) {
ba = talloc_zero(cs->ms, struct gsm322_ba_list);
if (!ba)
return -ENOMEM;
- ba->mcc = s->mcc;
- ba->mnc = s->mnc;
+ memcpy(&ba->plmn, &s->lai.plmn, sizeof(struct osmo_plmn_id));
llist_add_tail(&ba->entry, &cs->ba_list);
}
/* update ba list */
@@ -2549,10 +2498,10 @@
}
}
if (!!memcmp(freq, ba->freq, sizeof(freq))) {
- LOGP(DCS, LOGL_INFO, "New BA list (mcc=%s mnc=%s "
- "%s, %s).\n", gsm_print_mcc(ba->mcc),
- gsm_print_mnc(ba->mnc), gsm_get_mcc(ba->mcc),
- gsm_get_mnc(ba->mcc, ba->mnc));
+ LOGP(DCS, LOGL_INFO, "New BA list (mcc-mnc=%s %s, %s).\n",
+ osmo_plmn_name(&ba->plmn),
+ gsm_get_mcc(ba->plmn.mcc),
+ gsm_get_mnc(&ba->plmn));
memcpy(ba->freq, freq, sizeof(freq));
}
@@ -2586,8 +2535,8 @@
* Depending on the extended bit in the channel description,
* we require more or less system information about neighbor cells
*/
- if (s->mcc
- && s->mnc
+ if (s->lai.plmn.mcc
+ && s->lai.plmn.mnc
&& (gm->sysinfo == GSM48_MT_RR_SYSINFO_1
|| gm->sysinfo == GSM48_MT_RR_SYSINFO_2
|| gm->sysinfo == GSM48_MT_RR_SYSINFO_2bis
@@ -2664,8 +2613,7 @@
}
/* check if MCC, MNC, LAC, cell ID changes */
- if (cs->sel_mcc != s->mcc || cs->sel_mnc != s->mnc
- || cs->sel_lac != s->lac) {
+ if (osmo_lai_cmp(&cs->sel_cgi.lai, &s->lai) != 0) {
LOGP(DCS, LOGL_NOTICE, "Cell changes location area. "
"This is not good!\n");
if (ms->rrlayer.monitor)
@@ -2673,7 +2621,7 @@
"cell changes LAI\n");
goto trigger_resel;
}
- if (cs->sel_id != s->cell_id) {
+ if (cs->sel_cgi.cell_identity != s->cell_id) {
LOGP(DCS, LOGL_NOTICE, "Cell changes cell ID. "
"This is not good!\n");
if (ms->rrlayer.monitor)
@@ -2702,8 +2650,8 @@
* Depending on the extended bit in the channel description,
* we require more or less system information about neighbor cells
*/
- if (s->mcc
- && s->mnc
+ if (s->lai.plmn.mcc
+ && s->lai.plmn.mnc
&& (gm->sysinfo == GSM48_MT_RR_SYSINFO_1
|| gm->sysinfo == GSM48_MT_RR_SYSINFO_2
|| gm->sysinfo == GSM48_MT_RR_SYSINFO_2bis
@@ -3287,7 +3235,7 @@
new_c_state(cs, GSM322_C6_ANY_CELL_SEL);
- cs->mcc = cs->mnc = 0;
+ memset(&cs->plmn, 0, sizeof(cs->plmn));
/* unset selected cell */
gsm322_unselect_cell(cs);
@@ -3389,11 +3337,10 @@
struct gsm322_cellsel *cs = &ms->cellsel;
struct msgb *nmsg;
- LOGP(DSUM, LOGL_INFO, "Camping normally on cell (ARFCN=%s mcc=%s "
- "mnc=%s %s, %s)\n", gsm_print_arfcn(cs->sel_arfcn),
- gsm_print_mcc(cs->sel_mcc),
- gsm_print_mnc(cs->sel_mnc), gsm_get_mcc(cs->sel_mcc),
- gsm_get_mnc(cs->sel_mcc, cs->sel_mnc));
+ LOGP(DSUM, LOGL_INFO, "Camping normally on cell (ARFCN=%s mcc-mnc=%s %s, %s)\n", gsm_print_arfcn(cs->sel_arfcn),
+ osmo_plmn_name(&cs->sel_cgi.lai.plmn),
+ gsm_get_mcc(cs->sel_cgi.lai.plmn.mcc),
+ gsm_get_mnc(&cs->sel_cgi.lai.plmn));
/* if we did cell reselection, we have a valid last serving cell */
if (cs->state != GSM322_C4_NORMAL_CELL_RESEL)
@@ -3416,11 +3363,11 @@
struct gsm322_cellsel *cs = &ms->cellsel;
struct msgb *nmsg;
- LOGP(DSUM, LOGL_INFO, "Camping on any cell (ARFCN=%s mcc=%s "
- "mnc=%s %s, %s)\n", gsm_print_arfcn(cs->sel_arfcn),
- gsm_print_mcc(cs->sel_mcc),
- gsm_print_mnc(cs->sel_mnc), gsm_get_mcc(cs->sel_mcc),
- gsm_get_mnc(cs->sel_mcc, cs->sel_mnc));
+ LOGP(DSUM, LOGL_INFO, "Camping on any cell (ARFCN=%s mcc-mnc=%s %s, %s)\n",
+ gsm_print_arfcn(cs->sel_arfcn),
+ osmo_plmn_name(&cs->sel_cgi.lai.plmn),
+ gsm_get_mcc(cs->sel_cgi.lai.plmn.mcc),
+ gsm_get_mnc(&cs->sel_cgi.lai.plmn));
/* (re-)starting 'any cell selection' timer to look for coverage of
* allowed PLMNs.
@@ -3429,13 +3376,12 @@
if (ms->subscr.sim_valid
&& (cs->state != GSM322_C8_ANY_CELL_RESEL
|| !osmo_timer_pending(&cs->any_timer))) {
- struct gsm322_plmn *plmn = &ms->plmn;
+ struct gsm322_plmn *plmn322 = &ms->plmn;
stop_any_timer(cs);
if (ms->settings.plmn_mode == PLMN_MODE_MANUAL
- && (!plmn->mcc
- || gsm_subscr_is_forbidden_plmn(&ms->subscr, plmn->mcc,
- plmn->mnc))) {
+ && (!plmn322->plmn.mcc
+ || gsm_subscr_is_forbidden_plmn(&ms->subscr, &plmn322->plmn))) {
LOGP(DCS, LOGL_INFO, "Not starting 'any search' timer, "
"because no selected PLMN or forbidden\n");
} else
@@ -3526,8 +3472,7 @@
if (!ba) {
LOGP(DCS, LOGL_INFO, "No BA on sysinfo, try stored "
"BA list.\n");
- ba = gsm322_find_ba_list(cs, cs->sel_si.mcc,
- cs->sel_si.mnc);
+ ba = gsm322_find_ba_list(cs, &cs->sel_si.lai.plmn);
}
}
@@ -3628,23 +3573,22 @@
{
struct gsm322_msg *gm = (struct gsm322_msg *) msg->data;
struct gsm322_cellsel *cs = &ms->cellsel;
- struct gsm322_plmn *plmn = &ms->plmn;
+ struct gsm322_plmn *plmn322 = &ms->plmn;
struct gsm322_ba_list *ba;
- cs->mcc = plmn->mcc;
- cs->mnc = plmn->mnc;
+ memcpy(&cs->plmn, &plmn322->plmn, sizeof(struct osmo_plmn_id));
if (gm->limited) {
LOGP(DCS, LOGL_INFO, "Selected PLMN with limited service.\n");
return gsm322_c_any_cell_sel(ms, msg);
}
- LOGP(DSUM, LOGL_INFO, "Selecting PLMN (mcc=%s mnc=%s %s, %s)\n",
- gsm_print_mcc(cs->mcc), gsm_print_mnc(cs->mnc),
- gsm_get_mcc(cs->mcc), gsm_get_mnc(cs->mcc, cs->mnc));
+ LOGP(DSUM, LOGL_INFO, "Selecting PLMN (mcc-mnc=%s %s, %s)\n",
+ osmo_plmn_name(&cs->plmn),
+ gsm_get_mcc(cs->plmn.mcc), gsm_get_mnc(&cs->plmn));
/* search for BA list */
- ba = gsm322_find_ba_list(cs, plmn->mcc, plmn->mnc);
+ ba = gsm322_find_ba_list(cs, &plmn322->plmn);
if (ba) {
LOGP(DCS, LOGL_INFO, "Start stored cell selection.\n");
@@ -4161,7 +4105,7 @@
gsm_print_arfcn(cs->sel_arfcn));
arfcn_text[9] = '\0';
l23_vty_ms_notify(ms, "MON: serving %s 0x%04x %3d %3d %4d "
- "%s\n", arfcn_text, cs->sel_lac, cs->c1, cs->c2,
+ "%s\n", arfcn_text, cs->sel_cgi.lai.lac, cs->c1, cs->c2,
cs->rla_c_dbm, bargraph(cs->rla_c_dbm / 2, -55, -24));
}
@@ -4224,8 +4168,7 @@
nb->c12_valid = 1;
/* calculate CRH depending on LAI */
- if (cs->sel_mcc == s->mcc && cs->sel_mnc == s->mnc
- && cs->sel_lac == s->lac) {
+ if (osmo_lai_cmp(&cs->sel_cgi.lai, &s->lai) == 0) {
LOGP(DNB, LOGL_INFO, "-> Cell of is in the same LA, "
"so CRH = 0\n");
nb->crh = 0;
@@ -4245,7 +4188,7 @@
gsm_print_arfcn(nb->arfcn));
arfcn_text[9] = '\0';
l23_vty_ms_notify(ms, "MON: nb %2d %s 0x%04x %3d %3d %2d"
- " %4d %s\n", i + 1, arfcn_text, s->lac,
+ " %4d %s\n", i + 1, arfcn_text, s->lai.lac,
nb->c1, nb->c2, nb->crh, nb->rla_c_dbm,
bargraph(nb->rla_c_dbm / 2, -55, -24));
}
@@ -4266,18 +4209,17 @@
}
/* check if LA is forbidden */
- if (any && gsm322_is_forbidden_la(ms, s->mcc, s->mnc, s->lac)) {
+ if (any && gsm322_is_forbidden_la(ms, &s->lai)) {
LOGP(DNB, LOGL_INFO, "Skip cell: Cell has "
"forbidden LA.\n");
goto cont;
}
/* check if we have same PLMN */
- if (!any && (cs->sel_mcc != s->mcc || cs->sel_mnc != s->mnc)) {
+ if (!any && (osmo_plmn_cmp(&cs->sel_cgi.lai.plmn, &s->lai.plmn) != 0)) {
LOGP(DNB, LOGL_INFO, "Skip cell: PLMN of cell "
- "does not match target PLMN. (cell: mcc=%s "
- "mnc=%s)\n", gsm_print_mcc(s->mcc),
- gsm_print_mnc(s->mnc));
+ "does not match target PLMN. (cell: mcc-mnc=%s)\n",
+ osmo_plmn_name(&s->lai.plmn));
goto cont;
}
@@ -4861,9 +4803,9 @@
LOGP(DPLMN, LOGL_INFO, "MCC |MNC |allowed|rx-lev\n");
LOGP(DPLMN, LOGL_INFO, "-------+-------+-------+-------\n");
llist_for_each_entry(temp, &plmn->sorted_plmn, entry) {
- LOGP(DPLMN, LOGL_INFO, "%s |%s%s |%s |%s\n",
- gsm_print_mcc(temp->mcc), gsm_print_mnc(temp->mnc),
- ((temp->mnc & 0x00f) == 0x00f) ? " ":"",
+ LOGP(DPLMN, LOGL_INFO, "%s |%-3s |%s |%s\n",
+ osmo_mcc_name(temp->plmn.mcc),
+ osmo_mnc_name(temp->plmn.mnc, temp->plmn.mnc_3_digits),
(temp->cause) ? "no ":"yes",
gsm_print_rxlev(temp->rxlev));
}
@@ -4891,11 +4833,11 @@
print(priv, "%4dDCS|", i);
else
print(priv, "%4d |", i);
- if (s->mcc) {
- print(priv, "%s |%s%s |", gsm_print_mcc(s->mcc),
- gsm_print_mnc(s->mnc),
- ((s->mnc & 0x00f) == 0x00f) ? " ":"");
- print(priv, "0x%04x |0x%04x |", s->lac, s->cell_id);
+ if (s->lai.plmn.mcc) {
+ print(priv, "%s |%-3s |",
+ osmo_mcc_name(s->lai.plmn.mcc),
+ osmo_mnc_name(s->lai.plmn.mnc, s->lai.plmn.mnc_3_digits));
+ print(priv, "0x%04x |0x%04x |", s->lai.lac, s->cell_id);
} else
print(priv, "n/a |n/a |n/a |n/a |");
if ((cs->list[i].flags & GSM322_CS_FLAG_SYSINFO)) {
@@ -4934,27 +4876,27 @@
print(priv, "MCC |MNC |LAC |cause\n");
print(priv, "-------+-------+-------+-------\n");
llist_for_each_entry(temp, &plmn->forbidden_la, entry)
- print(priv, "%s |%s%s |0x%04x |#%d\n",
- gsm_print_mcc(temp->mcc), gsm_print_mnc(temp->mnc),
- ((temp->mnc & 0x00f) == 0x00f) ? " ":"",
- temp->lac, temp->cause);
+ print(priv, "%s |%-3s |0x%04x |#%d\n",
+ osmo_mcc_name(temp->lai.plmn.mcc),
+ osmo_mnc_name(temp->lai.plmn.mnc, temp->lai.plmn.mnc_3_digits),
+ temp->lai.lac, temp->cause);
return 0;
}
-int gsm322_dump_ba_list(struct gsm322_cellsel *cs, uint16_t mcc, uint16_t mnc,
+int gsm322_dump_ba_list(struct gsm322_cellsel *cs, const struct osmo_plmn_id *plmn,
void (*print)(void *, const char *, ...), void *priv)
{
struct gsm322_ba_list *ba;
int i;
llist_for_each_entry(ba, &cs->ba_list, entry) {
- if (mcc && mnc && (mcc != ba->mcc || mnc != ba->mnc))
+ if (plmn && (osmo_plmn_cmp(&ba->plmn, plmn) != 0))
continue;
- print(priv, "Band Allocation of network: MCC %s MNC %s "
- "(%s, %s)\n", gsm_print_mcc(ba->mcc),
- gsm_print_mnc(ba->mnc), gsm_get_mcc(ba->mcc),
- gsm_get_mnc(ba->mcc, ba->mnc));
+ print(priv, "Band Allocation of network: MCC-MNC %s (%s, %s)\n",
+ osmo_plmn_name(&ba->plmn),
+ gsm_get_mcc(ba->plmn.mcc),
+ gsm_get_mnc(&ba->plmn));
for (i = 0; i <= 1023+299; i++) {
if ((ba->freq[i >> 3] & (1 << (i & 7))))
print(priv, " %s",
@@ -4984,7 +4926,7 @@
print(priv, "C1=%d C2=%d ", cs->c1, cs->c1);
else
print(priv, "C1 - C2 - ");
- print(priv, "LAC=0x%04x\n\n", (cs->selected) ? cs->sel_si.lac : 0);
+ print(priv, "LAC=0x%04x\n\n", (cs->selected) ? cs->sel_si.lai.lac : 0);
print(priv, "Neighbour cells:\n\n");
llist_for_each_entry(nb, &cs->nb_list, entry) {
@@ -5027,7 +4969,7 @@
s = cs->list[arfcn2index(nb->arfcn)].sysinfo;
if (nb->state == GSM322_NB_SYSINFO && s) {
print(priv, "%s |0x%04x |0x%04x |",
- (nb->prio_low) ? "low ":"normal", s->lac,
+ (nb->prio_low) ? "low ":"normal", s->lai.lac,
s->cell_id);
} else
print(priv, "- |- |- |");
@@ -5098,6 +5040,7 @@
"stored BA list becomes obsolete.\n");
} else
while(!feof(fp)) {
+ uint16_t mcc_hex, mnc_hex;
ba = talloc_zero(ms, struct gsm322_ba_list);
if (!ba) {
fclose(fp);
@@ -5108,18 +5051,30 @@
talloc_free(ba);
break;
}
- ba->mcc = (buf[0] << 8) | buf[1];
- ba->mnc = (buf[2] << 8) | buf[3];
+ mcc_hex = (buf[0] << 8) | buf[1];
+ mnc_hex = (buf[2] << 8) | buf[3];
+ ba->plmn.mcc = (((mcc_hex & 0x0f00) >> 8) * 100) +
+ (((mcc_hex & 0x00f0) >> 4) * 10) +
+ (mcc_hex & 0x000f);
+ ba->plmn.mnc_3_digits = ((mnc_hex & 0x00f) != 0x00f);
+ if (ba->plmn.mnc_3_digits)
+ ba->plmn.mnc = (((mnc_hex & 0x0f00) >> 8) * 100) +
+ (((mnc_hex & 0x00f0) >> 4) * 10) +
+ (mnc_hex & 0x000f);
+ else
+ ba->plmn.mnc = (((mnc_hex & 0x0f00) >> 8) * 10) +
+ (((mnc_hex & 0x00f0) >> 4));
+
rc = fread(ba->freq, sizeof(ba->freq), 1, fp);
if (!rc) {
talloc_free(ba);
break;
}
llist_add_tail(&ba->entry, &cs->ba_list);
- LOGP(DCS, LOGL_INFO, "Read stored BA list (mcc=%s "
- "mnc=%s %s, %s)\n", gsm_print_mcc(ba->mcc),
- gsm_print_mnc(ba->mnc), gsm_get_mcc(ba->mcc),
- gsm_get_mnc(ba->mcc, ba->mnc));
+ LOGP(DCS, LOGL_INFO, "Read stored BA list (mcc-mnc=%s %s, %s)\n",
+ osmo_plmn_name(&ba->plmn),
+ gsm_get_mcc(ba->plmn.mcc),
+ gsm_get_mnc(&ba->plmn));
}
fclose(fp);
} else
@@ -5152,15 +5107,18 @@
llist_for_each_entry(ba, &ms->cellsel.ba_list, entry) {
size_t rc = 0;
+ uint16_t mcc_hex = gsm_mcc_to_hex(ba->plmn.mcc);
+ uint16_t mnc_hex = gsm_mnc_to_hex(ba->plmn.mnc, ba->plmn.mnc_3_digits);
uint8_t buf[] = {
- ba->mcc >> 8, ba->mcc & 0xff,
- ba->mnc >> 8, ba->mnc & 0xff,
+ mcc_hex >> 8, mcc_hex & 0xff,
+ mnc_hex >> 8, mnc_hex & 0xff,
};
LOGP(DCS, LOGL_INFO,
- "Writing stored BA list entry (mcc=%s mnc=%s %s, %s)\n",
- gsm_print_mcc(ba->mcc), gsm_print_mnc(ba->mnc),
- gsm_get_mcc(ba->mcc), gsm_get_mnc(ba->mcc, ba->mnc));
+ "Writing stored BA list entry (mcc-mnc=%s %s, %s)\n",
+ osmo_plmn_name(&ba->plmn),
+ gsm_get_mcc(ba->plmn.mcc),
+ gsm_get_mnc(&ba->plmn));
rc += fwrite(buf, sizeof(buf), 1, fp);
rc += fwrite(ba->freq, sizeof(ba->freq), 1, fp);
diff --git a/src/host/layer23/src/mobile/gsm48_mm.c b/src/host/layer23/src/mobile/gsm48_mm.c
index e72c3e0..95808ee 100644
--- a/src/host/layer23/src/mobile/gsm48_mm.c
+++ b/src/host/layer23/src/mobile/gsm48_mm.c
@@ -928,8 +928,8 @@
case GSM48_MM_SST_NORMAL_SERVICE:
l23_vty_ms_notify(ms, NULL);
l23_vty_ms_notify(ms, "On Network, normal service: %s, %s\n",
- gsm_get_mcc(plmn->mcc),
- gsm_get_mnc(plmn->mcc, plmn->mnc));
+ gsm_get_mcc(plmn->plmn.mcc),
+ gsm_get_mnc(&plmn->plmn));
break;
case GSM48_MM_SST_LIMITED_SERVICE:
l23_vty_ms_notify(ms, NULL);
@@ -953,7 +953,7 @@
case GSM48_MM_SST_ATTEMPT_UPDATE:
l23_vty_ms_notify(ms, NULL);
l23_vty_ms_notify(ms, "Trying to register with network %s, %s...\n",
- gsm_get_mcc(plmn->mcc), gsm_get_mnc(plmn->mcc, plmn->mnc));
+ gsm_get_mcc(plmn->plmn.mcc), gsm_get_mnc(&plmn->plmn));
break;
}
}
@@ -1043,7 +1043,7 @@
"SIM not updated.\n");
return GSM48_MM_SST_PLMN_SEARCH;
}
- if (subscr->lac == 0x0000 || subscr->lac >= 0xfffe) {
+ if (subscr->lai.lac == 0x0000 || subscr->lai.lac >= 0xfffe) {
LOGP(DMM, LOGL_INFO, "Selecting PLMN SEARCH state, because "
"LAI in SIM not valid.\n");
return GSM48_MM_SST_PLMN_SEARCH;
@@ -1057,15 +1057,12 @@
}
/* selected cell's LAI not equal to LAI stored on the sim */
- if (cs->sel_mcc != subscr->mcc
- || cs->sel_mnc != subscr->mnc
- || cs->sel_lac != subscr->lac) {
+ if (osmo_lai_cmp(&cs->sel_cgi.lai, &subscr->lai) != 0) {
LOGP(DMM, LOGL_INFO, "Selecting PLMN SEARCH state, because "
- "LAI of selected cell (MCC %s MNC %s LAC 0x%04x) "
- "!= LAI in SIM (MCC %s MNC %s LAC 0x%04x).\n",
- gsm_print_mcc(cs->sel_mcc), gsm_print_mnc(cs->sel_mnc),
- cs->sel_lac, gsm_print_mcc(subscr->mcc),
- gsm_print_mnc(subscr->mnc), subscr->lac);
+ "LAI of selected cell (MCC-MNC %s LAC 0x%04x) "
+ "!= LAI in SIM (MCC-MNC %s LAC 0x%04x).\n",
+ osmo_plmn_name(&cs->sel_cgi.lai.plmn), cs->sel_cgi.lai.lac,
+ osmo_plmn_name2(&subscr->lai.plmn), subscr->lai.lac);
return GSM48_MM_SST_PLMN_SEARCH;
}
@@ -1121,10 +1118,8 @@
/* if we are attached and selected cell equals the registered LAI */
if (subscr->imsi_attached
- && subscr->lac /* valid */
- && cs->sel_mcc == subscr->mcc
- && cs->sel_mnc == subscr->mnc
- && cs->sel_lac == subscr->lac) {
+ && subscr->lai.lac /* valid */
+ && (osmo_lai_cmp(&cs->sel_cgi.lai, &subscr->lai) == 0)) {
LOGP(DMM, LOGL_INFO, "We are in registered LAI as returning "
"to MM IDLE\n");
/* if SIM not updated (abnormal case as described in 4.4.4.9) */
@@ -1141,15 +1136,13 @@
if (cs->state == GSM322_C3_CAMPED_NORMALLY) {
LOGP(DMM, LOGL_INFO, "We are camping normally as returning to "
"MM IDLE\n");
- if (gsm_subscr_is_forbidden_plmn(subscr, cs->sel_mcc,
- cs->sel_mnc)) {
+ if (gsm_subscr_is_forbidden_plmn(subscr, &cs->sel_cgi.lai.plmn)) {
/* location update not allowed */
LOGP(DMM, LOGL_INFO, "Loc. upd. not allowed PLMN.\n");
new_mm_state(mm, GSM48_MM_ST_MM_IDLE,
GSM48_MM_SST_LIMITED_SERVICE);
} else
- if (gsm322_is_forbidden_la(ms, cs->sel_mcc, cs->sel_mnc,
- cs->sel_lac)) {
+ if (gsm322_is_forbidden_la(ms, &cs->sel_cgi.lai)) {
/* location update not allowed */
LOGP(DMM, LOGL_INFO, "Loc. upd. not allowed LA.\n");
new_mm_state(mm, GSM48_MM_ST_MM_IDLE,
@@ -1211,10 +1204,8 @@
/* SIM not updated in this LA */
if (subscr->ustate == GSM_SIM_U1_UPDATED
- && subscr->lac /* valid */
- && cs->sel_mcc == subscr->mcc
- && cs->sel_mnc == subscr->mnc
- && cs->sel_lac == subscr->lac
+ && subscr->lai.lac /* valid */
+ && (osmo_lai_cmp(&cs->sel_cgi.lai, &subscr->lai) == 0)
&& !mm->lupd_periodic) {
if (subscr->imsi_attached) {
struct msgb *nmsg;
@@ -1252,9 +1243,8 @@
/* PLMN mode auto and selected cell is forbidden */
if (set->plmn_mode == PLMN_MODE_AUTO
&& (!cs->selected
- || gsm_subscr_is_forbidden_plmn(subscr, cs->sel_mcc, cs->sel_mnc)
- || gsm322_is_forbidden_la(ms, cs->sel_mcc, cs->sel_mnc,
- cs->sel_lac))) {
+ || gsm_subscr_is_forbidden_plmn(subscr, &cs->sel_cgi.lai.plmn)
+ || gsm322_is_forbidden_la(ms, &cs->sel_cgi.lai))) {
struct msgb *nmsg;
LOGP(DMM, LOGL_INFO, "Selected cell is forbidden.\n");
@@ -1274,8 +1264,7 @@
* in M3 state the PLMN is not selected for registration. */
if (set->plmn_mode == PLMN_MODE_MANUAL
&& (!cs->selected
- || plmn->mcc != cs->sel_mcc
- || plmn->mnc != cs->sel_mnc
+ || (osmo_plmn_cmp(&plmn->plmn, &cs->sel_cgi.lai.plmn) != 0)
|| plmn->state == GSM322_M3_NOT_ON_PLMN)) {
struct msgb *nmsg;
@@ -1585,7 +1574,7 @@
return -EINVAL;
}
/* LAI */
- gsm48_decode_lai_hex(lai, &subscr->mcc, &subscr->mnc, &subscr->lac);
+ gsm48_decode_lai2(lai, &subscr->lai);
/* MI */
mi = gh->data + sizeof(struct gsm48_loc_area_id);
mi_type = mi[1] & GSM_MI_TYPE_MASK;
@@ -1699,7 +1688,7 @@
/* TMSI and LAI invalid */
subscr->tmsi = GSM_RESERVED_TMSI;
- subscr->lac = 0x0000;
+ subscr->lai.lac = 0x0000;
/* key is invalid */
subscr->key_seq = 7;
@@ -2018,7 +2007,7 @@
/* TMSI and LAI invalid */
subscr->tmsi = GSM_RESERVED_TMSI;
- subscr->lac = 0x0000;
+ subscr->lai.lac = 0x0000;
/* key is invalid */
subscr->key_seq = 7;
@@ -2170,20 +2159,18 @@
"forbidden PLMN.\n");
LOGP(DSUM, LOGL_INFO, "Location updating is disabled by "
"configuration\n");
- gsm_subscr_add_forbidden_plmn(subscr, cs->sel_mcc,
- cs->sel_mnc, GSM48_REJECT_PLMN_NOT_ALLOWED);
+ gsm_subscr_add_forbidden_plmn(subscr, &cs->sel_cgi.lai.plmn, GSM48_REJECT_PLMN_NOT_ALLOWED);
msg_type = GSM322_EVENT_REG_FAILED;
goto _stop;
}
/* if LAI is forbidden, don't start */
- if (gsm_subscr_is_forbidden_plmn(subscr, cs->sel_mcc, cs->sel_mnc)) {
+ if (gsm_subscr_is_forbidden_plmn(subscr, &cs->sel_cgi.lai.plmn)) {
LOGP(DMM, LOGL_INFO, "Loc. upd. not allowed PLMN.\n");
msg_type = GSM322_EVENT_REG_FAILED;
goto stop;
}
- if (gsm322_is_forbidden_la(ms, cs->sel_mcc,
- cs->sel_mnc, cs->sel_lac)) {
+ if (gsm322_is_forbidden_la(ms, &cs->sel_cgi.lai)) {
LOGP(DMM, LOGL_INFO, "Loc. upd. not allowed LA.\n");
msg_type = GSM322_EVENT_REG_FAILED;
goto stop;
@@ -2198,13 +2185,9 @@
goto stop;
}
- mm->lupd_mcc = cs->sel_mcc;
- mm->lupd_mnc = cs->sel_mnc;
- mm->lupd_lac = cs->sel_lac;
+ memcpy(&mm->lupd_lai, &cs->sel_cgi.lai, sizeof(mm->lupd_lai));
- LOGP(DSUM, LOGL_INFO, "Perform location update (MCC %s, MNC %s "
- "LAC 0x%04x)\n", gsm_print_mcc(mm->lupd_mcc),
- gsm_print_mnc(mm->lupd_mnc), mm->lupd_lac);
+ LOGP(DSUM, LOGL_INFO, "Perform location update (LAI=%s)\n", osmo_lai_name(&mm->lupd_lai));
return gsm48_mm_tx_loc_upd_req(ms);
}
@@ -2247,9 +2230,7 @@
/* if location update is not required */
if (subscr->ustate == GSM_SIM_U1_UPDATED
&& cs->selected
- && cs->sel_mcc == subscr->mcc
- && cs->sel_mnc == subscr->mnc
- && cs->sel_lac == subscr->lac
+ && (osmo_lai_cmp(&cs->sel_cgi.lai, &subscr->lai) == 0)
&& (subscr->imsi_attached
|| !s->att_allowed)) {
LOGP(DMM, LOGL_INFO, "Loc. upd. not required.\n");
@@ -2277,9 +2258,7 @@
/* 4.4.3 is attachment required? */
if (subscr->ustate == GSM_SIM_U1_UPDATED
&& cs->selected
- && cs->sel_mcc == subscr->mcc
- && cs->sel_mnc == subscr->mnc
- && cs->sel_lac == subscr->lac
+ && (osmo_lai_cmp(&cs->sel_cgi.lai, &subscr->lai) == 0)
&& !subscr->imsi_attached
&& s->att_allowed) {
/* do location update for IMSI attach */
@@ -2357,10 +2336,8 @@
*
* NOTE: The TMSI is only valid within a LAI!
*/
- gsm48_encode_lai_hex(&nlu->lai, subscr->mcc, subscr->mnc, subscr->lac);
- LOGP(DMM, LOGL_INFO, " using LAI (mcc %s mnc %s " "lac 0x%04x)\n",
- gsm_print_mcc(subscr->mcc),
- gsm_print_mnc(subscr->mnc), subscr->lac);
+ gsm48_generate_lai2(&nlu->lai, &subscr->lai);
+ LOGP(DMM, LOGL_INFO, " using LAI=%s\n", osmo_lai_name(&subscr->lai));
/* classmark 1 */
pwr_lev = gsm48_current_pwr_lev(set, cs->sel_arfcn);
gsm48_encode_classmark1(&nlu->classmark1, sup->rev_lev, sup->es_ind,
@@ -2427,7 +2404,7 @@
stop_mm_t3212(mm); /* 4.4.2 */
/* LAI */
- gsm48_decode_lai_hex(lai, &subscr->mcc, &subscr->mnc, &subscr->lac);
+ gsm48_decode_lai2(lai, &subscr->lai);
/* stop location update timer */
stop_mm_t3210(mm);
@@ -2445,19 +2422,17 @@
gsm_subscr_write_loci(ms);
/* set last registered PLMN */
- if (subscr->lac > 0x0000 && subscr->lac < 0xfffe) {
+ if (subscr->lai.lac > 0x0000 && subscr->lai.lac < 0xfffe) {
subscr->plmn_valid = 1;
- subscr->plmn_mcc = subscr->mcc;
- subscr->plmn_mnc = subscr->mnc;
+ memcpy(&subscr->plmn, &subscr->lai.plmn, sizeof(struct osmo_plmn_id));
}
LOGP(DSUM, LOGL_INFO, "Location update accepted\n");
- LOGP(DMM, LOGL_INFO, "LOCATION UPDATING ACCEPT (mcc %s mnc %s "
- "lac 0x%04x)\n", gsm_print_mcc(subscr->mcc),
- gsm_print_mnc(subscr->mnc), subscr->lac);
+ LOGP(DMM, LOGL_INFO, "LOCATION UPDATING ACCEPT (lai=%s)\n",
+ osmo_lai_name(&subscr->lai));
/* remove LA from forbidden list */
- gsm322_del_forbidden_la(ms, subscr->mcc, subscr->mnc, subscr->lac);
+ gsm322_del_forbidden_la(ms, &subscr->lai);
/* MI */
if (TLVP_PRESENT(&tp, GSM48_IE_MOBILE_ID)) {
@@ -2583,7 +2558,7 @@
case GSM48_REJECT_ROAMING_NOT_ALLOWED:
/* TMSI and LAI invalid */
subscr->tmsi = GSM_RESERVED_TMSI;
- subscr->lac = 0x0000;
+ subscr->lai.lac = 0x0000;
/* key is invalid */
subscr->key_seq = 7;
@@ -2632,15 +2607,13 @@
LOGP(DSUM, LOGL_INFO, "Location update failed (Illegal ME)\n");
break;
case GSM48_REJECT_PLMN_NOT_ALLOWED:
- gsm_subscr_add_forbidden_plmn(subscr, mm->lupd_mcc,
- mm->lupd_mnc, mm->lupd_rej_cause);
+ gsm_subscr_add_forbidden_plmn(subscr, &mm->lupd_lai.plmn, mm->lupd_rej_cause);
LOGP(DSUM, LOGL_INFO, "Location update failed (PLMN not "
"allowed)\n");
break;
case GSM48_REJECT_LOC_NOT_ALLOWED:
case GSM48_REJECT_ROAMING_NOT_ALLOWED:
- gsm322_add_forbidden_la(ms, mm->lupd_mcc, mm->lupd_mnc,
- mm->lupd_lac, mm->lupd_rej_cause);
+ gsm322_add_forbidden_la(ms, &mm->lupd_lai, mm->lupd_rej_cause);
LOGP(DSUM, LOGL_INFO, "Location update failed (LAI not "
"allowed)\n");
break;
@@ -2687,9 +2660,7 @@
stop_mm_t3210(mm);
if (subscr->ustate == GSM_SIM_U1_UPDATED
- && mm->lupd_mcc == subscr->mcc
- && mm->lupd_mnc == subscr->mnc
- && mm->lupd_lac == subscr->lac) {
+ && (osmo_lai_cmp(&mm->lupd_lai, &subscr->lai) == 0)) {
if (mm->lupd_attempt < 4) {
LOGP(DSUM, LOGL_INFO, "Try location update later\n");
LOGP(DMM, LOGL_INFO, "Loc. upd. failed, retry #%d\n",
@@ -2706,7 +2677,7 @@
/* TMSI and LAI invalid */
subscr->tmsi = GSM_RESERVED_TMSI;
- subscr->lac = 0x0000;
+ subscr->lai.lac = 0x0000;
/* key is invalid */
subscr->key_seq = 7;
@@ -2914,7 +2885,7 @@
/* TMSI and LAI invalid */
subscr->tmsi = GSM_RESERVED_TMSI;
- subscr->lac = 0x0000;
+ subscr->lai.lac = 0x0000;
/* key is invalid */
subscr->key_seq = 7;
diff --git a/src/host/layer23/src/mobile/gsm48_rr.c b/src/host/layer23/src/mobile/gsm48_rr.c
index 5690746..a0aad3c 100644
--- a/src/host/layer23/src/mobile/gsm48_rr.c
+++ b/src/host/layer23/src/mobile/gsm48_rr.c
@@ -658,10 +658,9 @@
berr = (meas->berr + meas->frames / 2) / meas->frames;
snr = (meas->snr + meas->frames / 2) / meas->frames;
OSMO_STRBUF_PRINTF(sb, "MON: f=%d lev=%s snr=%2d ber=%3d "
- "LAI=%s %s %04x ID=%04x", cs->sel_arfcn,
+ "CGI=%s", cs->sel_arfcn,
gsm_print_rxlev(rxlev), snr, berr,
- gsm_print_mcc(cs->sel_mcc),
- gsm_print_mnc(cs->sel_mnc), cs->sel_lac, cs->sel_id);
+ osmo_cgi_name(&cs->sel_cgi));
if (rr->state == GSM48_RR_ST_DEDICATED) {
OSMO_STRBUF_PRINTF(sb, " TA=%d pwr=%d",
rr->cd_now.ind_ta - set->alter_delay,
@@ -1952,9 +1951,7 @@
gsm48_decode_sysinfo4(s, si, msgb_l3len(msg));
- LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4 (mcc %s mnc %s "
- "lac 0x%04x)\n", gsm_print_mcc(s->mcc),
- gsm_print_mnc(s->mnc), s->lac);
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4 (lai=%s)\n", osmo_lai_name(&s->lai));
return gsm48_new_sysinfo(ms, si->header.system_information);
}
@@ -2077,9 +2074,8 @@
gsm48_decode_sysinfo6(s, si, msgb_l3len(msg));
- LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 6 (mcc %s mnc %s "
- "lac 0x%04x SACCH-timeout %d)\n", gsm_print_mcc(s->mcc),
- gsm_print_mnc(s->mnc), s->lac, s->sacch_radio_link_timeout);
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 6 (lai=%s SACCH-timeout %d)\n",
+ osmo_lai_name(&s->lai), s->sacch_radio_link_timeout);
meas->rl_fail = meas->s = s->sacch_radio_link_timeout;
LOGP(DRR, LOGL_INFO, "using (new) SACCH timeout %d\n", meas->rl_fail);
@@ -2148,9 +2144,7 @@
return 0;
memcpy(&tmsi, mi+2, 4);
if (ms->subscr.tmsi == ntohl(tmsi)
- && ms->subscr.mcc == cs->sel_mcc
- && ms->subscr.mnc == cs->sel_mnc
- && ms->subscr.lac == cs->sel_lac) {
+ && (osmo_lai_cmp(&ms->subscr.lai, &cs->sel_cgi.lai) == 0)) {
LOGP(DPAG, LOGL_INFO, " TMSI %08x matches\n",
ntohl(tmsi));
@@ -2269,9 +2263,7 @@
chan_2 = pa->cneed2;
/* first MI */
if (ms->subscr.tmsi == ntohl(pa->tmsi1)
- && ms->subscr.mcc == cs->sel_mcc
- && ms->subscr.mnc == cs->sel_mnc
- && ms->subscr.lac == cs->sel_lac) {
+ && (osmo_lai_cmp(&ms->subscr.lai, &cs->sel_cgi.lai) == 0)) {
LOGP(DPAG, LOGL_INFO, " TMSI %08x matches\n", ntohl(pa->tmsi1));
return gsm48_rr_chan_req(ms, gsm48_rr_chan2cause[chan_1], 1,
GSM_MI_TYPE_TMSI);
@@ -2280,9 +2272,7 @@
ntohl(pa->tmsi1));
/* second MI */
if (ms->subscr.tmsi == ntohl(pa->tmsi2)
- && ms->subscr.mcc == cs->sel_mcc
- && ms->subscr.mnc == cs->sel_mnc
- && ms->subscr.lac == cs->sel_lac) {
+ && (osmo_lai_cmp(&ms->subscr.lai, &cs->sel_cgi.lai) == 0)) {
LOGP(DPAG, LOGL_INFO, " TMSI %08x matches\n", ntohl(pa->tmsi2));
return gsm48_rr_chan_req(ms, gsm48_rr_chan2cause[chan_2], 1,
GSM_MI_TYPE_TMSI);
@@ -2339,9 +2329,7 @@
chan_4 = pa->cneed4;
/* first MI */
if (ms->subscr.tmsi == ntohl(pa->tmsi1)
- && ms->subscr.mcc == cs->sel_mcc
- && ms->subscr.mnc == cs->sel_mnc
- && ms->subscr.lac == cs->sel_lac) {
+ && (osmo_lai_cmp(&ms->subscr.lai, &cs->sel_cgi.lai) == 0)) {
LOGP(DPAG, LOGL_INFO, " TMSI %08x matches\n", ntohl(pa->tmsi1));
return gsm48_rr_chan_req(ms, gsm48_rr_chan2cause[chan_1], 1,
GSM_MI_TYPE_TMSI);
@@ -2350,9 +2338,7 @@
ntohl(pa->tmsi1));
/* second MI */
if (ms->subscr.tmsi == ntohl(pa->tmsi2)
- && ms->subscr.mcc == cs->sel_mcc
- && ms->subscr.mnc == cs->sel_mnc
- && ms->subscr.lac == cs->sel_lac) {
+ && (osmo_lai_cmp(&ms->subscr.lai, &cs->sel_cgi.lai) == 0)) {
LOGP(DPAG, LOGL_INFO, " TMSI %08x matches\n", ntohl(pa->tmsi2));
return gsm48_rr_chan_req(ms, gsm48_rr_chan2cause[chan_2], 1,
GSM_MI_TYPE_TMSI);
@@ -2361,9 +2347,7 @@
ntohl(pa->tmsi2));
/* third MI */
if (ms->subscr.tmsi == ntohl(pa->tmsi3)
- && ms->subscr.mcc == cs->sel_mcc
- && ms->subscr.mnc == cs->sel_mnc
- && ms->subscr.lac == cs->sel_lac) {
+ && (osmo_lai_cmp(&ms->subscr.lai, &cs->sel_cgi.lai) == 0)) {
LOGP(DPAG, LOGL_INFO, " TMSI %08x matches\n", ntohl(pa->tmsi3));
return gsm48_rr_chan_req(ms, gsm48_rr_chan2cause[chan_3], 1,
GSM_MI_TYPE_TMSI);
@@ -2372,9 +2356,7 @@
ntohl(pa->tmsi3));
/* fourth MI */
if (ms->subscr.tmsi == ntohl(pa->tmsi4)
- && ms->subscr.mcc == cs->sel_mcc
- && ms->subscr.mnc == cs->sel_mnc
- && ms->subscr.lac == cs->sel_lac) {
+ && (osmo_lai_cmp(&ms->subscr.lai, &cs->sel_cgi.lai) == 0)) {
LOGP(DPAG, LOGL_INFO, " TMSI %08x matches\n", ntohl(pa->tmsi4));
return gsm48_rr_chan_req(ms, gsm48_rr_chan2cause[chan_4], 1,
GSM_MI_TYPE_TMSI);
@@ -3310,9 +3292,7 @@
gsm48_rr_enc_cm2(ms, &pr->cm2, rr->cd_now.arfcn);
/* mobile identity */
if (ms->subscr.tmsi != GSM_RESERVED_TMSI
- && ms->subscr.mcc == cs->sel_mcc
- && ms->subscr.mnc == cs->sel_mnc
- && ms->subscr.lac == cs->sel_lac
+ && (osmo_lai_cmp(&ms->subscr.lai, &cs->sel_cgi.lai) == 0)
&& rr->paging_mi_type == GSM_MI_TYPE_TMSI) {
gsm48_generate_mid_from_tmsi(mi, subscr->tmsi);
LOGP(DRR, LOGL_INFO, "sending paging response with "
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index 0761419..9b9ba95 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -151,23 +151,21 @@
else
vty_out(vty, " manual network selection state : %s%s",
get_m_state_name(ms->plmn.state), VTY_NEWLINE);
- if (ms->plmn.mcc)
+ if (ms->plmn.plmn.mcc)
vty_out(vty, " MCC=%s "
- "MNC=%s (%s, %s)%s", gsm_print_mcc(ms->plmn.mcc),
- gsm_print_mnc(ms->plmn.mnc), gsm_get_mcc(ms->plmn.mcc),
- gsm_get_mnc(ms->plmn.mcc, ms->plmn.mnc), VTY_NEWLINE);
+ "MNC=%s (%s, %s)%s", osmo_mcc_name(ms->plmn.plmn.mcc),
+ osmo_mnc_name(ms->plmn.plmn.mnc, ms->plmn.plmn.mnc_3_digits),
+ gsm_get_mcc(ms->plmn.plmn.mcc),
+ gsm_get_mnc(&ms->plmn.plmn), VTY_NEWLINE);
vty_out(vty, " cell selection state: %s%s",
get_cs_state_name(ms->cellsel.state), VTY_NEWLINE);
- if (ms->cellsel.sel_mcc) {
- vty_out(vty, " ARFCN=%s MCC=%s MNC=%s "
- "LAC=0x%04x CELLID=0x%04x%s",
+ if (ms->cellsel.sel_cgi.lai.plmn.mcc) {
+ vty_out(vty, " ARFCN=%s CGI=%s%s",
gsm_print_arfcn(ms->cellsel.sel_arfcn),
- gsm_print_mcc(ms->cellsel.sel_mcc),
- gsm_print_mnc(ms->cellsel.sel_mnc),
- ms->cellsel.sel_lac, ms->cellsel.sel_id, VTY_NEWLINE);
+ osmo_cgi_name(&ms->cellsel.sel_cgi), VTY_NEWLINE);
vty_out(vty, " (%s, %s)%s",
- gsm_get_mcc(ms->cellsel.sel_mcc),
- gsm_get_mnc(ms->cellsel.sel_mcc, ms->cellsel.sel_mnc),
+ gsm_get_mcc(ms->cellsel.sel_cgi.lai.plmn.mcc),
+ gsm_get_mnc(&ms->cellsel.sel_cgi.lai.plmn),
VTY_NEWLINE);
}
vty_out(vty, " radio resource layer state: %s%s",
@@ -282,26 +280,26 @@
"Mobile Network Code")
{
struct osmocom_ms *ms;
- uint16_t mcc = 0, mnc = 0;
+ struct osmo_plmn_id plmn;
+ struct osmo_plmn_id *plmn_ptr = NULL;
ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
if (argc >= 3) {
- mcc = gsm_input_mcc((char *)argv[1]);
- mnc = gsm_input_mnc((char *)argv[2]);
- if (mcc == GSM_INPUT_INVALID) {
+ if (osmo_mcc_from_str(argv[1], &plmn.mcc) < 0) {
vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
- if (mnc == GSM_INPUT_INVALID) {
+ if (osmo_mnc_from_str(argv[2], &plmn.mnc, &plmn.mnc_3_digits) < 0) {
vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
+ plmn_ptr = &plmn;
}
- gsm322_dump_ba_list(&ms->cellsel, mcc, mnc, l23_vty_printf, vty);
+ gsm322_dump_ba_list(&ms->cellsel, plmn_ptr, l23_vty_printf, vty);
return CMD_SUCCESS;
}
@@ -372,18 +370,17 @@
"Force selecting a network that is not in the list")
{
struct osmocom_ms *ms;
- struct gsm322_plmn *plmn;
+ struct gsm322_plmn *plmn322;
struct msgb *nmsg;
struct gsm322_msg *ngm;
struct gsm322_plmn_list *temp;
- uint16_t mcc = gsm_input_mcc((char *)argv[1]),
- mnc = gsm_input_mnc((char *)argv[2]);
+ struct osmo_plmn_id plmn;
int found = 0;
ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
- plmn = &ms->plmn;
+ plmn322 = &ms->plmn;
if (ms->settings.plmn_mode != PLMN_MODE_MANUAL) {
vty_out(vty, "Not in manual network selection mode%s",
@@ -391,18 +388,18 @@
return CMD_WARNING;
}
- if (mcc == GSM_INPUT_INVALID) {
+ if (osmo_mcc_from_str(argv[1], &plmn.mcc) < 0) {
vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
- if (mnc == GSM_INPUT_INVALID) {
+ if (osmo_mnc_from_str(argv[2], &plmn.mnc, &plmn.mnc_3_digits) < 0) {
vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (argc < 4) {
- llist_for_each_entry(temp, &plmn->sorted_plmn, entry)
- if (temp->mcc == mcc && temp->mnc == mnc)
+ llist_for_each_entry(temp, &plmn322->sorted_plmn, entry)
+ if (osmo_plmn_cmp(&temp->plmn, &plmn) == 0)
found = 1;
if (!found) {
vty_out(vty, "Network not in list!%s", VTY_NEWLINE);
@@ -416,8 +413,7 @@
if (!nmsg)
return CMD_WARNING;
ngm = (struct gsm322_msg *) nmsg->data;
- ngm->mcc = mcc;
- ngm->mnc = mnc;
+ memcpy(&ngm->plmn, &plmn, sizeof(struct osmo_plmn_id));
gsm322_plmn_sendmsg(ms, nmsg);
return CMD_SUCCESS;
@@ -623,23 +619,22 @@
"Mobile Country Code\nMobile Network Code")
{
struct osmocom_ms *ms;
- uint16_t mcc = gsm_input_mcc((char *)argv[1]),
- mnc = gsm_input_mnc((char *)argv[2]);
+ struct osmo_plmn_id plmn;
ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
- if (mcc == GSM_INPUT_INVALID) {
+ if (osmo_mcc_from_str(argv[1], &plmn.mcc) < 0) {
vty_out(vty, "Given MCC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
- if (mnc == GSM_INPUT_INVALID) {
+ if (osmo_mnc_from_str(argv[2], &plmn.mnc, &plmn.mnc_3_digits) < 0) {
vty_out(vty, "Given MNC invalid%s", VTY_NEWLINE);
return CMD_WARNING;
}
- gsm_subscr_del_forbidden_plmn(&ms->subscr, mcc, mnc);
+ gsm_subscr_del_forbidden_plmn(&ms->subscr, &plmn);
return CMD_SUCCESS;
}
@@ -667,9 +662,10 @@
llist_for_each_entry(temp, &plmn->sorted_plmn, entry)
vty_out(vty, " Network %s, %s (%s, %s)%s",
- gsm_print_mcc(temp->mcc), gsm_print_mnc(temp->mnc),
- gsm_get_mcc(temp->mcc),
- gsm_get_mnc(temp->mcc, temp->mnc), VTY_NEWLINE);
+ osmo_mcc_name(temp->plmn.mcc),
+ osmo_mnc_name(temp->plmn.mnc, temp->plmn.mnc_3_digits),
+ gsm_get_mcc(temp->plmn.mcc),
+ gsm_get_mnc(&temp->plmn), VTY_NEWLINE);
return CMD_SUCCESS;
}
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32786
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I07a9289825c09ed748e53d36a746ea164c8a5d7f
Gerrit-Change-Number: 32786
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
1
0
[XL] Change in osmocom-bb[master]: Migrate network identifier fields to modern osmocom structures
by pespin 22 May '23
by pespin 22 May '23
22 May '23
Attention is currently required from: osmith, laforge.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32786 )
Change subject: Migrate network identifier fields to modern osmocom structures
......................................................................
Patch Set 4: Code-Review+2
(1 comment)
Patchset:
PS4:
RE-adding +1 from laforge after fixing printf formatting issues spotted by jolly.
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32786
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I07a9289825c09ed748e53d36a746ea164c8a5d7f
Gerrit-Change-Number: 32786
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Mon, 22 May 2023 14:51:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
1
0
[XL] Change in osmocom-bb[master]: Migrate network identifier fields to modern osmocom structures
by jolly 22 May '23
by jolly 22 May '23
22 May '23
Attention is currently required from: osmith, laforge, pespin.
jolly has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32786 )
Change subject: Migrate network identifier fields to modern osmocom structures
......................................................................
Patch Set 4: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32786
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I07a9289825c09ed748e53d36a746ea164c8a5d7f
Gerrit-Change-Number: 32786
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 22 May 2023 14:38:08 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
1
0