summaryrefslogtreecommitdiffstats
path: root/src/host/layer23
diff options
context:
space:
mode:
authorAndreas.Eversberg2010-07-19 11:37:57 +0200
committerAndreas.Eversberg2010-07-19 11:37:57 +0200
commit7ea81070fae0a75ed7aba006948437da42201e28 (patch)
treef3479a6a7b35927758e0ce23f0b82d965234bcea /src/host/layer23
parent[calypso] Rework of keypad interrupt handler. (diff)
downloadosmocom-7ea81070fae0a75ed7aba006948437da42201e28.tar.gz
osmocom-7ea81070fae0a75ed7aba006948437da42201e28.tar.xz
osmocom-7ea81070fae0a75ed7aba006948437da42201e28.zip
[layer23] Fixed "return to IDLE" after cell re-selection.
Also remove forbidden PLMN from list when choosing cell manually.
Diffstat (limited to 'src/host/layer23')
-rwxr-xr-xsrc/host/layer23/include/osmocom/gsm322.h2
-rw-r--r--src/host/layer23/src/gsm322.c21
-rw-r--r--src/host/layer23/src/subscriber.c8
-rw-r--r--src/host/layer23/src/vty_interface.c2
4 files changed, 21 insertions, 12 deletions
diff --git a/src/host/layer23/include/osmocom/gsm322.h b/src/host/layer23/include/osmocom/gsm322.h
index 4b7df7a..78e380f 100755
--- a/src/host/layer23/include/osmocom/gsm322.h
+++ b/src/host/layer23/include/osmocom/gsm322.h
@@ -47,7 +47,7 @@
#define GSM322_EVENT_PLMN_SEARCH_END 12
#define GSM322_EVENT_USER_RESEL 13
#define GSM322_EVENT_PLMN_AVAIL 14
-#define GSM322_EVENT_CHOSE_PLMN 15
+#define GSM322_EVENT_CHOOSE_PLMN 15
#define GSM322_EVENT_SEL_MANUAL 16
#define GSM322_EVENT_SEL_AUTO 17
#define GSM322_EVENT_CELL_FOUND 18
diff --git a/src/host/layer23/src/gsm322.c b/src/host/layer23/src/gsm322.c
index 2fccc52..405483c 100644
--- a/src/host/layer23/src/gsm322.c
+++ b/src/host/layer23/src/gsm322.c
@@ -160,7 +160,7 @@ static const struct value_string gsm322_event_names[] = {
{ GSM322_EVENT_PLMN_SEARCH_END, "EVENT_PLMN_SEARCH_END" },
{ GSM322_EVENT_USER_RESEL, "EVENT_USER_RESEL" },
{ GSM322_EVENT_PLMN_AVAIL, "EVENT_PLMN_AVAIL" },
- { GSM322_EVENT_CHOSE_PLMN, "EVENT_CHOSE_PLMN" },
+ { GSM322_EVENT_CHOOSE_PLMN, "EVENT_CHOOSE_PLMN" },
{ GSM322_EVENT_SEL_MANUAL, "EVENT_SEL_MANUAL" },
{ GSM322_EVENT_SEL_AUTO, "EVENT_SEL_AUTO" },
{ GSM322_EVENT_CELL_FOUND, "EVENT_CELL_FOUND" },
@@ -1068,7 +1068,7 @@ static int gsm322_a_switch_on(struct osmocom_ms *ms, struct msgb *msg)
if (!subscr->sim_valid) {
LOGP(DSUM, LOGL_INFO, "SIM is removed\n");
- LOGP(DPLMN, LOGL_INFO, "Switch on without SIM.\n");
+ LOGP(DPLMN, LOGL_INFO, "SIM is removed\n");
new_a_state(plmn, GSM322_A6_NO_SIM);
return 0;
@@ -1383,9 +1383,6 @@ static int gsm322_m_go_on_plmn(struct osmocom_ms *ms, struct msgb *msg)
struct gsm322_plmn *plmn = &ms->plmn;
struct gsm_subscriber *subscr = &ms->subscr;
- /* if selected PLMN is in list of forbidden PLMNs */
- gsm_subscr_del_forbidden_plmn(subscr, plmn->mcc, plmn->mnc);
-
/* set last registered PLMN */
subscr->plmn_valid = 1;
subscr->plmn_mcc = plmn->mcc;
@@ -1439,6 +1436,7 @@ static int gsm322_m_plmn_avail(struct osmocom_ms *ms, struct msgb *msg)
static int gsm322_m_choose_plmn(struct osmocom_ms *ms, struct msgb *msg)
{
struct gsm322_plmn *plmn = &ms->plmn;
+ struct gsm_subscriber *subscr = &ms->subscr;
struct gsm322_msg *gm = (struct gsm322_msg *) msg->data;
struct msgb *nmsg;
@@ -1453,6 +1451,9 @@ static int gsm322_m_choose_plmn(struct osmocom_ms *ms, struct msgb *msg)
"%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));
+ /* if selected PLMN is in list of forbidden PLMNs */
+ gsm_subscr_del_forbidden_plmn(subscr, plmn->mcc, plmn->mnc);
+
new_m_state(plmn, GSM322_M4_TRYING_PLMN);
/* indicate New PLMN */
@@ -2849,6 +2850,8 @@ static int gsm322_c_choose_cell(struct osmocom_ms *ms, struct msgb *msg)
/* After location updating, we choose the last cell */
if (gm->same_cell) {
+ struct msgb *nmsg;
+
if (!cs->selected) {
printf("No cell selected when ret.idle, please fix!\n");
exit(0L);
@@ -2864,6 +2867,12 @@ static int gsm322_c_choose_cell(struct osmocom_ms *ms, struct msgb *msg)
new_c_state(cs, GSM322_C3_CAMPED_NORMALLY);
+ /* tell that we have selected the cell, so RR returns IDLE */
+ nmsg = gsm48_mmevent_msgb_alloc(GSM48_MM_EVENT_CELL_SELECTED);
+ if (!nmsg)
+ return -ENOMEM;
+ gsm48_mmevent_msg(ms, nmsg);
+
return 0;
}
@@ -3127,7 +3136,7 @@ static struct plmnmstatelist {
GSM322_EVENT_PLMN_AVAIL, gsm322_m_plmn_avail},
{SBIT(GSM322_M3_NOT_ON_PLMN),
- GSM322_EVENT_CHOSE_PLMN, gsm322_m_choose_plmn},
+ GSM322_EVENT_CHOOSE_PLMN, gsm322_m_choose_plmn},
{SBIT(GSM322_M4_TRYING_PLMN),
GSM322_EVENT_REG_SUCCESS, gsm322_m_go_on_plmn},
diff --git a/src/host/layer23/src/subscriber.c b/src/host/layer23/src/subscriber.c
index 80ea5a4..34b7582 100644
--- a/src/host/layer23/src/subscriber.c
+++ b/src/host/layer23/src/subscriber.c
@@ -181,10 +181,6 @@ int gsm_subscr_add_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
{
struct gsm_sub_plmn_na *na;
- /* don't add Home PLMN */
- if (subscr->sim_valid && gsm_match_mnc(mcc, mnc, subscr->imsi))
- return -EINVAL;
-
LOGP(DPLMN, LOGL_INFO, "Add to list of forbidden PLMNs "
"(mcc=%s, mnc=%s)\n", gsm_print_mcc(mcc), gsm_print_mnc(mnc));
na = talloc_zero(l23_ctx, struct gsm_sub_plmn_na);
@@ -195,6 +191,10 @@ int gsm_subscr_add_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc,
na->cause = cause;
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))
+ return -EINVAL;
+
#ifdef TODO
update plmn not allowed list on sim
#endif
diff --git a/src/host/layer23/src/vty_interface.c b/src/host/layer23/src/vty_interface.c
index 297d5d1..c085c89 100644
--- a/src/host/layer23/src/vty_interface.c
+++ b/src/host/layer23/src/vty_interface.c
@@ -426,7 +426,7 @@ DEFUN(network_select, network_select_cmd, "network select MS_NAME MCC MNC",
return CMD_WARNING;
}
- nmsg = gsm322_msgb_alloc(GSM322_EVENT_CHOSE_PLMN);
+ nmsg = gsm322_msgb_alloc(GSM322_EVENT_CHOOSE_PLMN);
if (!nmsg)
return CMD_WARNING;
ngm = (struct gsm322_msg *) nmsg->data;