pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/32435 )

 (

4 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: layer23: Use GSM_RESERVED_TMSI from libosmocore everywhere
......................................................................

layer23: Use GSM_RESERVED_TMSI from libosmocore everywhere

Change-Id: Ib9483b8ae4067994aef523291733ae706ffabe7a
---
M src/host/layer23/include/osmocom/bb/common/subscriber.h
M src/host/layer23/src/common/settings.c
M src/host/layer23/src/common/subscriber.c
M src/host/layer23/src/common/vty.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
7 files changed, 33 insertions(+), 22 deletions(-)

Approvals:
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/src/host/layer23/include/osmocom/bb/common/subscriber.h 
b/src/host/layer23/include/osmocom/bb/common/subscriber.h
index 8b15295..3aacbda 100644
--- a/src/host/layer23/include/osmocom/bb/common/subscriber.h
+++ b/src/host/layer23/include/osmocom/bb/common/subscriber.h
@@ -45,7 +45,7 @@
        char                    iccid[21]; /* 20 + termination */

        /* TMSI / LAI */
-       uint32_t                tmsi; /* invalid tmsi: 0xffffffff */
+       uint32_t                tmsi; /* invalid tmsi: GSM_RESERVED_TMSI */
        uint16_t                mcc, mnc, lac; /* invalid lac: 0x0000 */


diff --git a/src/host/layer23/src/common/settings.c 
b/src/host/layer23/src/common/settings.c
index d391f7d..565da96 100644
--- a/src/host/layer23/src/common/settings.c
+++ b/src/host/layer23/src/common/settings.c
@@ -19,6 +19,7 @@
 #include <errno.h>
 #include <string.h>
 #include <osmocom/core/talloc.h>
+#include <osmocom/gsm/gsm48.h>

 #include <osmocom/bb/common/settings.h>
 #include <osmocom/bb/common/utils.h>
@@ -69,7 +70,7 @@
        strcpy(set->test_imsi, "001010000000000");
        set->test_rplmn_mcc = set->test_rplmn_mnc = 1;
        set->test_lac = 0x0000;
-       set->test_tmsi = 0xffffffff;
+       set->test_tmsi = GSM_RESERVED_TMSI;

        /* set all supported features */
        set->sms_ptp = sup->sms_ptp;
diff --git a/src/host/layer23/src/common/subscriber.c 
b/src/host/layer23/src/common/subscriber.c
index 41d59f9..90d6a78 100644
--- a/src/host/layer23/src/common/subscriber.c
+++ b/src/host/layer23/src/common/subscriber.c
@@ -22,6 +22,7 @@
 #include <osmocom/core/talloc.h>
 #include <osmocom/crypt/auth.h>
 #include <osmocom/gsm/gsm23003.h>
+#include <osmocom/gsm/gsm48.h>

 #include <osmocom/bb/common/logging.h>
 #include <osmocom/bb/common/osmocom_data.h>
@@ -77,7 +78,7 @@
        subscr->ms = ms;

        /* set TMSI / LAC invalid */
-       subscr->tmsi = 0xffffffff;
+       subscr->tmsi = GSM_RESERVED_TMSI;
        subscr->lac = 0x0000;

        /* set key invalid */
@@ -1152,7 +1153,7 @@
                        subscr->sms_sca);
        print(priv, " Status: %s  IMSI %s", subscr_ustate_names[subscr->ustate],
                (subscr->imsi_attached) ? "attached" : "detached");
-       if (subscr->tmsi != 0xffffffff)
+       if (subscr->tmsi != GSM_RESERVED_TMSI)
                print(priv, "  TMSI 0x%08x", subscr->tmsi);
        if (subscr->lac > 0x0000 && subscr->lac < 0xfffe) {
                print(priv, "\n");
diff --git a/src/host/layer23/src/common/vty.c 
b/src/host/layer23/src/common/vty.c
index bbe8e2a..27d0330 100644
--- a/src/host/layer23/src/common/vty.c
+++ b/src/host/layer23/src/common/vty.c
@@ -635,7 +635,7 @@
        if (argc >= 4)
                set->test_tmsi = strtoul(argv[3], NULL, 16);
        else
-               set->test_tmsi = 0xffffffff;
+               set->test_tmsi = GSM_RESERVED_TMSI;

        if (attached)
                set->test_imsi_attached = 1;
@@ -763,7 +763,7 @@
                        gsm_print_mnc(set->test_rplmn_mnc));
                if (set->test_lac > 0x0000 && set->test_lac < 0xfffe) {
                        vty_out(vty, " 0x%04x", set->test_lac);
-                       if (set->test_tmsi != 0xffffffff) {
+                       if (set->test_tmsi != GSM_RESERVED_TMSI) {
                                vty_out(vty, " 0x%08x", set->test_tmsi);
                                if (set->test_imsi_attached)
                                        vty_out(vty, " attached");
diff --git a/src/host/layer23/src/mobile/gsm48_mm.c 
b/src/host/layer23/src/mobile/gsm48_mm.c
index 6c5a860..e72c3e0 100644
--- a/src/host/layer23/src/mobile/gsm48_mm.c
+++ b/src/host/layer23/src/mobile/gsm48_mm.c
@@ -1601,12 +1601,12 @@
                gsm48_mm_tx_tmsi_reall_cpl(ms);
                break;
        case GSM_MI_TYPE_IMSI:
-               subscr->tmsi = 0xffffffff;
+               subscr->tmsi = GSM_RESERVED_TMSI;
                LOGP(DMM, LOGL_INFO, "TMSI removed.\n");
                gsm48_mm_tx_tmsi_reall_cpl(ms);
                break;
        default:
-               subscr->tmsi = 0xffffffff;
+               subscr->tmsi = GSM_RESERVED_TMSI;
                LOGP(DMM, LOGL_NOTICE, "TMSI reallocation with unknown MI "
                        "type %d.\n", mi_type);
                gsm48_mm_tx_mm_status(ms, GSM48_REJECT_INCORRECT_MESSAGE);
@@ -1698,7 +1698,7 @@
        subscr->sim_valid = 0;

        /* TMSI and LAI invalid */
-       subscr->tmsi = 0xffffffff;
+       subscr->tmsi = GSM_RESERVED_TMSI;
        subscr->lac = 0x0000;

        /* key is invalid */
@@ -1755,7 +1755,7 @@
                return gsm48_mm_tx_mm_status(ms,
                        GSM48_REJECT_MSG_NOT_COMPATIBLE);
        }
-       if (mi_type == GSM_MI_TYPE_TMSI && subscr->tmsi == 0xffffffff) {
+       if (mi_type == GSM_MI_TYPE_TMSI && subscr->tmsi == GSM_RESERVED_TMSI) {
                LOGP(DMM, LOGL_INFO, "IDENTITY REQUEST of TMSI, but we have no "
                        "TMSI\n");
                return gsm48_mm_tx_mm_status(ms,
@@ -1824,7 +1824,7 @@
                pwr_lev);
         msgb_v_put(nmsg, *((uint8_t *)&cm));
        /* MI */
-       if (subscr->tmsi != 0xffffffff) { /* have TMSI ? */
+       if (subscr->tmsi != GSM_RESERVED_TMSI) { /* have TMSI ? */
                gsm48_encode_mi(buf, nmsg, ms, GSM_MI_TYPE_TMSI);
                LOGP(DMM, LOGL_INFO, " using TMSI 0x%08x\n", subscr->tmsi);
        } else {
@@ -2017,7 +2017,7 @@
                subscr->sim_valid = 0;

                /* TMSI and LAI invalid */
-               subscr->tmsi = 0xffffffff;
+               subscr->tmsi = GSM_RESERVED_TMSI;
                subscr->lac = 0x0000;

                /* key is invalid */
@@ -2366,7 +2366,7 @@
        gsm48_encode_classmark1(&nlu->classmark1, sup->rev_lev, sup->es_ind,
                set->a5_1, pwr_lev);
        /* MI */
-       if (subscr->tmsi != 0xffffffff) { /* have TMSI ? */
+       if (subscr->tmsi != GSM_RESERVED_TMSI) { /* have TMSI ? */
                gsm48_encode_mi(buf, NULL, ms, GSM_MI_TYPE_TMSI);
                LOGP(DMM, LOGL_INFO, " using TMSI 0x%08x\n", subscr->tmsi);
        } else {
@@ -2487,7 +2487,7 @@
                        break;
                case GSM_MI_TYPE_IMSI:
                        LOGP(DMM, LOGL_INFO, "TMSI removed\n");
-                       subscr->tmsi = 0xffffffff;
+                       subscr->tmsi = GSM_RESERVED_TMSI;

                        /* store LOCI on sim */
                        gsm_subscr_write_loci(ms);
@@ -2582,7 +2582,7 @@
        case GSM48_REJECT_LOC_NOT_ALLOWED:
        case GSM48_REJECT_ROAMING_NOT_ALLOWED:
                /* TMSI and LAI invalid */
-               subscr->tmsi = 0xffffffff;
+               subscr->tmsi = GSM_RESERVED_TMSI;
                subscr->lac = 0x0000;

                /* key is invalid */
@@ -2705,7 +2705,7 @@
        }

        /* TMSI and LAI invalid */
-       subscr->tmsi = 0xffffffff;
+       subscr->tmsi = GSM_RESERVED_TMSI;
        subscr->lac = 0x0000;

        /* key is invalid */
@@ -2831,7 +2831,7 @@
                        set->imei);
                gsm48_encode_mi(buf, NULL, ms, GSM_MI_TYPE_IMEI);
        } else
-       if (subscr->tmsi != 0xffffffff) { /* have TMSI ? */
+       if (subscr->tmsi != GSM_RESERVED_TMSI) { /* have TMSI ? */
                gsm48_encode_mi(buf, NULL, ms, GSM_MI_TYPE_TMSI);
                LOGP(DMM, LOGL_INFO, "-> Using TMSI\n");
        } else {
@@ -2913,7 +2913,7 @@
                abort_any = 1;

                /* TMSI and LAI invalid */
-               subscr->tmsi = 0xffffffff;
+               subscr->tmsi = GSM_RESERVED_TMSI;
                subscr->lac = 0x0000;

                /* key is invalid */
diff --git a/src/host/layer23/src/mobile/gsm48_rr.c 
b/src/host/layer23/src/mobile/gsm48_rr.c
index 231bea0..5690746 100644
--- a/src/host/layer23/src/mobile/gsm48_rr.c
+++ b/src/host/layer23/src/mobile/gsm48_rr.c
@@ -3309,7 +3309,7 @@
                pr->cm2_len = sizeof(pr->cm2);
                gsm48_rr_enc_cm2(ms, &pr->cm2, rr->cd_now.arfcn);
                /* mobile identity */
-               if (ms->subscr.tmsi != 0xffffffff
+               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
diff --git a/src/host/layer23/src/mobile/vty_interface.c 
b/src/host/layer23/src/mobile/vty_interface.c
index e7f0454..3938c3b 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -438,7 +438,7 @@

        /* Initial testcard settings */
        uint16_t mcc = 0x001, mnc = 0x01f, lac = 0x0000;
-       uint32_t tmsi = 0xffffffff;
+       uint32_t tmsi = GSM_RESERVED_TMSI;

        ms = l23_vty_get_ms(argv[0], vty);
        if (!ms)
@@ -458,7 +458,7 @@
                if (set->test_lac > 0x0000 && set->test_lac < 0xfffe)
                        lac = set->test_lac;

-               if (set->test_tmsi != 0xffffffff)
+               if (set->test_tmsi != GSM_RESERVED_TMSI)
                        tmsi = set->test_tmsi;
        }

@@ -719,7 +719,7 @@
        ms->subscr.mcc = mcc;
        ms->subscr.mnc = mnc;
        ms->subscr.lac = lac;
-       ms->subscr.tmsi = 0xffffffff;
+       ms->subscr.tmsi = GSM_RESERVED_TMSI;

        gsm_subscr_write_loci(ms);


--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32435
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Ib9483b8ae4067994aef523291733ae706ffabe7a
Gerrit-Change-Number: 32435
Gerrit-PatchSet: 6
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to