From d7e611472a923f0f3d6f53c8777df7f5e8114656 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Mon, 23 Oct 2023 13:53:03 +0200 Subject: [PATCH] ASCI: Add option to join voice group/broadcast calls without valid SIM This option must be enabled in the VTY and is disabled by default. Calls can be joined when service is limited or normal. With that option enabled, calls can be joined even with invalid SIM. Talking is allowed when service is normal. With that option enabled, talking is always allowed. It depends on the network, if it accepts the talker. Change-Id: I6ea851a8cb015ff685b985335968c6184beca816 Related: OS#5364 --- .../include/osmocom/bb/common/settings.h | 1 + src/host/layer23/src/mobile/gsm48_mm.c | 34 +++++++++++++++---- src/host/layer23/src/mobile/vty_interface.c | 27 +++++++++++++++ 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/host/layer23/include/osmocom/bb/common/settings.h b/src/host/layer23/include/osmocom/bb/common/settings.h index 884578b00..3b9473f96 100644 --- a/src/host/layer23/include/osmocom/bb/common/settings.h +++ b/src/host/layer23/include/osmocom/bb/common/settings.h @@ -191,6 +191,7 @@ struct gsm_settings { /* ASCI settings */ bool uplink_release_local; + bool asci_allow_any; }; struct gsm_settings_abbrev { diff --git a/src/host/layer23/src/mobile/gsm48_mm.c b/src/host/layer23/src/mobile/gsm48_mm.c index 5e0265987..378cd2d28 100644 --- a/src/host/layer23/src/mobile/gsm48_mm.c +++ b/src/host/layer23/src/mobile/gsm48_mm.c @@ -61,7 +61,9 @@ static void new_mm_state(struct gsm48_mmlayer *mm, int state, int substate); static int gsm48_mm_loc_upd_normal(struct osmocom_ms *ms, struct msgb *msg); static int gsm48_mm_loc_upd_periodic(struct osmocom_ms *ms, struct msgb *msg); static int gsm48_mm_loc_upd(struct osmocom_ms *ms, struct msgb *msg); +static int gsm48_mm_group_reject(struct osmocom_ms *ms, struct msgb *msg); static int gsm48_mm_group_rel_req(struct osmocom_ms *ms, struct msgb *msg); +static int gsm48_mm_uplink_reject(struct osmocom_ms *ms, struct msgb *msg); /* * notes @@ -3805,9 +3807,13 @@ static int gsm48_mm_uplink_free(struct osmocom_ms *ms, struct msgb *msg) static int gsm48_mm_group_req(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_mmlayer *mm = &ms->mmlayer; + struct gsm_settings *set = &ms->settings; struct gsm48_mmxx_hdr *mmh = (struct gsm48_mmxx_hdr *)msg->data; struct msgb *nmsg; + if (mm->substate == GSM48_MM_SST_NO_IMSI && !set->asci_allow_any) + return gsm48_mm_group_reject(ms, msg); + LOGP(DMM, LOGL_INFO, "Request for joining a group call, trying to establish group receive mode.\n"); /* Store infos about group/broadcast call. */ @@ -3881,6 +3887,7 @@ static int gsm48_mm_group_cnf(struct osmocom_ms *ms, struct msgb *msg) static int gsm48_mm_group_rel_ind(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_mmlayer *mm = &ms->mmlayer; + struct gsm_subscriber *subscr = &ms->subscr; struct gsm48_rr_hdr *rrh = (struct gsm48_rr_hdr *)msg->data; uint16_t msg_type; struct msgb *nmsg; @@ -3892,8 +3899,10 @@ static int gsm48_mm_group_rel_ind(struct osmocom_ms *ms, struct msgb *msg) mm->vgcs.enabled = false; /* Change mode back to normal or limited service. */ - if (mm->substate == GSM48_MM_SST_RX_VGCS_LIMITED) - new_mm_state(mm, GSM48_MM_ST_MM_IDLE, GSM48_MM_SST_LIMITED_SERVICE); + if (mm->substate == GSM48_MM_SST_RX_VGCS_LIMITED) { + new_mm_state(mm, GSM48_MM_ST_MM_IDLE, (subscr->sim_valid) ? GSM48_MM_SST_LIMITED_SERVICE + : GSM48_MM_SST_NO_IMSI); + } if (mm->substate == GSM48_MM_SST_RX_VGCS_NORMAL) new_mm_state(mm, GSM48_MM_ST_MM_IDLE, GSM48_MM_SST_NORMAL_SERVICE); @@ -3932,6 +3941,7 @@ static int gsm48_mm_group_rel_ind(struct osmocom_ms *ms, struct msgb *msg) static int gsm48_mm_group_rel_req(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_mmlayer *mm = &ms->mmlayer; + struct gsm_subscriber *subscr = &ms->subscr; struct msgb *nmsg; LOGP(DMM, LOGL_INFO, "Request to release group call in receive or transmit mode.\n"); @@ -3940,8 +3950,10 @@ static int gsm48_mm_group_rel_req(struct osmocom_ms *ms, struct msgb *msg) mm->vgcs.enabled = false; /* Change mode back to normal or limited service. */ - if (mm->substate == GSM48_MM_SST_RX_VGCS_LIMITED) - new_mm_state(mm, GSM48_MM_ST_MM_IDLE, GSM48_MM_SST_LIMITED_SERVICE); + if (mm->substate == GSM48_MM_SST_RX_VGCS_LIMITED) { + new_mm_state(mm, GSM48_MM_ST_MM_IDLE, (subscr->sim_valid) ? GSM48_MM_SST_LIMITED_SERVICE + : GSM48_MM_SST_NO_IMSI); + } if (mm->substate == GSM48_MM_SST_RX_VGCS_NORMAL) new_mm_state(mm, GSM48_MM_ST_MM_IDLE, GSM48_MM_SST_NORMAL_SERVICE); @@ -3960,8 +3972,12 @@ static int gsm48_mm_group_rel_req(struct osmocom_ms *ms, struct msgb *msg) static int gsm48_mm_uplink_req(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_mmlayer *mm = &ms->mmlayer; + struct gsm_settings *set = &ms->settings; struct msgb *nmsg; + if (mm->substate != GSM48_MM_SST_RX_VGCS_NORMAL && !set->asci_allow_any) + return gsm48_mm_uplink_reject(ms, msg); + LOGP(DMM, LOGL_INFO, "Request for uplink, trying to establish group transmit mode.\n"); /* Go into uplink pending state. */ @@ -4201,6 +4217,12 @@ static struct downstate { {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_NO_IMSI), GSM48_MMCC_EST_REQ, gsm48_mm_init_mm_no_rr}, + {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_NO_IMSI), + GSM48_MMBCC_GROUP_REQ, gsm48_mm_group_req}, + + {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_NO_IMSI), + GSM48_MMGCC_GROUP_REQ, gsm48_mm_group_req}, + /* 4.2.2.5 PLMN search, normal service */ {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_PLMN_SEARCH_NORMAL), GSM48_MMCC_EST_REQ, gsm48_mm_init_mm_no_rr}, @@ -4254,10 +4276,10 @@ static struct downstate { GSM48_MMBCC_REL_REQ, gsm48_mm_group_rel_req}, {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_RX_VGCS_LIMITED), - GSM48_MMGCC_UPLINK_REQ, gsm48_mm_uplink_reject}, + GSM48_MMGCC_UPLINK_REQ, gsm48_mm_uplink_req}, {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_RX_VGCS_LIMITED), - GSM48_MMBCC_UPLINK_REQ, gsm48_mm_uplink_reject}, + GSM48_MMBCC_UPLINK_REQ, gsm48_mm_uplink_req}, /* 4.5.1.1 MM Connection (EST) */ {SBIT(GSM48_MM_ST_RR_CONN_RELEASE_NA), ALL_STATES, diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 176607122..7611c0fad 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -1327,6 +1327,9 @@ static void config_write_ms(struct vty *vty, struct osmocom_ms *ms) if (!l23_vty_hide_default || !set->uplink_release_local) vty_out(vty, " %suplink-release-local%s", (set->uplink_release_local) ? "no " : "", VTY_NEWLINE); + if (!l23_vty_hide_default || set->asci_allow_any) + vty_out(vty, " %sasci-allow-any%s", + (set->asci_allow_any) ? "" : "no ", VTY_NEWLINE); vty_out(vty, " audio%s", VTY_NEWLINE); vty_out(vty, " io-handler %s%s", @@ -1997,6 +2000,28 @@ DEFUN(cfg_ms_uplink_release_local, cfg_ms_uplink_release_local_cmd, "uplink-rele return CMD_SUCCESS; } +DEFUN(cfg_ms_asci_allow_any, cfg_ms_asci_allow_any_cmd, "asci-allow-any", + "Allow any ASCI related call feature, even if service is limited or SIM invalid.") +{ + struct osmocom_ms *ms = vty->index; + struct gsm_settings *set = &ms->settings; + + set->asci_allow_any = true; + + return CMD_SUCCESS; +} + +DEFUN(cfg_ms_no_asci_allow_any, cfg_ms_no_asci_allow_any_cmd, "no asci-allow-any", + NO_STR "Do not allow any ASCI related call feature, if service is not normal.") +{ + struct osmocom_ms *ms = vty->index; + struct gsm_settings *set = &ms->settings; + + set->asci_allow_any = false; + + return CMD_SUCCESS; +} + static int config_write_dummy(struct vty *vty) { return CMD_SUCCESS; @@ -2586,6 +2611,8 @@ int ms_vty_init(void) install_element(MS_NODE, &cfg_ms_no_sms_store_cmd); install_element(MS_NODE, &cfg_ms_uplink_release_local_cmd); install_element(MS_NODE, &cfg_ms_no_uplink_release_local_cmd); + install_element(MS_NODE, &cfg_ms_asci_allow_any_cmd); + install_element(MS_NODE, &cfg_ms_no_asci_allow_any_cmd); install_element(MS_NODE, &cfg_ms_support_cmd); install_node(&support_node, config_write_dummy); install_element(SUPPORT_NODE, &cfg_ms_set_en_cc_dtmf_cmd);