Gathering SIM operator MCC/MNC without reading EFad

Aleksander Morgado aleksander at lanedo.com
Mon Oct 21 08:25:43 PDT 2013


Hey hey,

The generic implementation of load_operator_identifier() in MMSim (the
one reading the MCC/MNC of the operator which issued the SIM card)
currently relies on reading the 'MNC length' field from the EFad file in
the SIM card. Once it knows the MNC length, it will just get the [3+MNC
length] bytes long prefix of the IMSI string.

Now, the 'MNC length' field in the EFad file is *optional*; so even in
successful reads of EFad, the field may just be unavailable. I was
looking for a way to handle this case, when I found that the IMSI is
defined as follows (3GPP TS23.003):

  IMSI is composed of three parts:
  i) Mobile Country Code (MCC) consisting of three digits. The MCC
identifies uniquely the country of domicile of the mobile subscriber;
  ii) Mobile Network Code (MNC) consisting of two or three digits for
GSM applications. The MNC identifies the home GSM PLMN of the mobile
subscriber. The length of the MNC (two or three digits) depends on the
value of the MCC. A mixture of two and three digit MNC codes within a
single MCC area is not recommended and is outside the scope of this
specification.
  iii) Mobile Subscriber Identification Number (MSIN) identifying the
mobile subscriber within a GSM PLMN

In particular, it explicitly states that there shouldn't be any MCC
which allows both 2 and 3 digit MNCs. With that in mind, I compiled a
list of MCC values with 3 digit MNCs (using the m-b-p-i). This ends up
giving us a method like this:

guint
mm_3gpp_get_mnc_length_for_mcc (guint mcc)
{
    /*
     * Info obtained from the mobile-broadband-provider-info database
     *   https://git.gnome.org/browse/mobile-broadband-provider-info
     */

    switch (mcc) {
    case 302: /* Canada */
    case 310: /* United states */
    case 311: /* United states */
    case 338: /* Jamaica */
    case 342: /* Barbados */
    case 358: /* St Lucia */
    case 360: /* St Vincent */
    case 364: /* Bahamas */
    case 405: /* India */
    case 732: /* Colombia */
        return 3;
    default:
        /* For the remaining ones, default to 2 */
        return 2;
    }
}

>From the list above; the only MCC for which I have doubts is '405'.
India has several MCCs assigned: '404' has all 2-digit MNCs; while '405'
seems to have both 2-digit and 3-digit MNCs (in the m-b-p-i database I
mean). My assumption right now is that the 2-digit MNCs with a '405' MCC
really should all have an extra leading zero to make them 3-digit. It
would be great if someone could confirm this, though.


Anyway, I got a 'aleksander/mnc-length' branch in upstream git with this
implementation, which among other things also makes the QMI based modems
to show the MCC/MNC of the operator which issued the card.

Anyone got comments on this? I know that maintaining the list of MCCs
with 3-digit-MNCs hardcoded in code is not the best idea; so suggestions
more than welcome.

-- 
Aleksander


More information about the ModemManager-devel mailing list