[layer23] Option "no location-updating" to disabled location updating
authorAndreas.Eversberg <jolly@eversberg.eu>
Sat, 17 Jul 2010 12:43:53 +0000 (12:43 +0000)
committerAndreas.Eversberg <jolly@eversberg.eu>
Sat, 17 Jul 2010 12:43:53 +0000 (12:43 +0000)
The mobile will not transmit for location updating. All networks will be
marked as "roaming not allowed", so search process continues.

src/host/layer23/include/osmocom/settings.h
src/host/layer23/src/gsm48_mm.c
src/host/layer23/src/vty_interface.c

index e44ee3f..be13d20 100644 (file)
@@ -31,6 +31,7 @@ struct gsm_settings {
        int8_t                  alter_delay;
        uint8_t                 stick;
        uint16_t                stick_arfcn;
+       uint8_t                 no_lupd;
 };
 
 int gsm_settings_init(struct osmocom_ms *ms);
index 605fc4f..82d09a7 100644 (file)
@@ -2014,6 +2014,7 @@ static int gsm48_mm_loc_upd(struct osmocom_ms *ms, struct msgb *msg)
        struct gsm322_cellsel *cs = &ms->cellsel;
        struct gsm48_sysinfo *s = &cs->sel_si;
        struct gsm_subscriber *subscr = &ms->subscr;
+       struct gsm_settings *set = &ms->settings;
        struct msgb *nmsg;
        int msg_type;
        
@@ -2038,6 +2039,16 @@ static int gsm48_mm_loc_upd(struct osmocom_ms *ms, struct msgb *msg)
                return 0;
        }
 
+       /* deny network, if disabled */
+       if (set->no_lupd) {
+               LOGP(DMM, LOGL_INFO, "Loc. upd. disabled, adding "
+                       "forbidden PLMN.\n");
+               gsm_subscr_add_forbidden_plmn(subscr, cs->sel_mcc,
+                       cs->sel_mnc, GSM48_REJECT_PLMN_NOT_ALLOWED);
+               msg_type = GSM322_EVENT_ROAMING_NA;
+               goto stop;
+       }
+
        /* if LAI is forbidden, don't start */
        if (gsm_subscr_is_forbidden_plmn(subscr, cs->sel_mcc, cs->sel_mnc)) {
                LOGP(DMM, LOGL_INFO, "Loc. upd. not allowed PLMN.\n");
@@ -2632,7 +2643,7 @@ static int gsm48_mm_tx_cm_serv_req(struct osmocom_ms *ms, int rr_prim,
        uint8_t cause, uint8_t cm_serv)
 {
        struct gsm_subscriber *subscr = &ms->subscr;
-       struct gsm_settings *settings = &ms->settings;
+       struct gsm_settings *set = &ms->settings;
        struct msgb *nmsg;
        struct gsm48_hdr *ngh;
        struct gsm48_service_request *nsr; /* NOTE: includes MI length */
@@ -2659,9 +2670,9 @@ static int gsm48_mm_tx_cm_serv_req(struct osmocom_ms *ms, int rr_prim,
        gsm48_rr_enc_cm2(ms, (struct gsm48_classmark2 *)(cm2lv + 1));
        /* MI */
        if (!subscr->sim_valid) { /* have no SIM ? */
-               if (settings->emergency_imsi[0])
+               if (set->emergency_imsi[0])
                        gsm48_generate_mid_from_imsi(buf,
-                               settings->emergency_imsi);
+                               set->emergency_imsi);
                else
                        gsm48_encode_mi(buf, NULL, ms, GSM_MI_TYPE_IMEI);
        } else if (subscr->tmsi_valid) /* have TMSI ? */
index 192b864..297d5d1 100644 (file)
@@ -607,6 +607,10 @@ static void config_write_ms_single(struct vty *vty, struct osmocom_ms *ms)
                        VTY_NEWLINE);
        else
                vty_out(vty, " no stick%s", VTY_NEWLINE);
+       if (set->no_lupd)
+               vty_out(vty, " no location-updating%s", VTY_NEWLINE);
+       else
+               vty_out(vty, " location-updating%s", VTY_NEWLINE);
        vty_out(vty, "exit%s", VTY_NEWLINE);
        vty_out(vty, "!%s", VTY_NEWLINE);
 }
@@ -873,6 +877,26 @@ DEFUN(cfg_ms_no_stick, cfg_ms_no_stick_cmd, "no stick",
        return CMD_SUCCESS;
 }
 
+DEFUN(cfg_ms_lupd, cfg_ms_lupd_cmd, "location-updating",
+       "Allow location updating")
+{
+       struct osmocom_ms *ms = vty->index;
+
+       ms->settings.no_lupd = 0;
+
+       return CMD_SUCCESS;
+}
+
+DEFUN(cfg_ms_no_lupd, cfg_ms_no_lupd_cmd, "no location-updating",
+       NO_STR "Do not allow location updating")
+{
+       struct osmocom_ms *ms = vty->index;
+
+       ms->settings.no_lupd = 1;
+
+       return CMD_SUCCESS;
+}
+
 /* per testsim config */
 DEFUN(cfg_ms_testsim, cfg_ms_testsim_cmd, "test-sim",
        "Configure test SIM emulation")
@@ -1081,6 +1105,8 @@ int ms_vty_init(void)
        install_element(MS_NODE, &cfg_ms_no_sim_delay_cmd);
        install_element(MS_NODE, &cfg_ms_stick_cmd);
        install_element(MS_NODE, &cfg_ms_no_stick_cmd);
+       install_element(MS_NODE, &cfg_ms_lupd_cmd);
+       install_element(MS_NODE, &cfg_ms_no_lupd_cmd);
 
        install_node(&testsim_node, config_write_dummy);
        install_default(TESTSIM_NODE);