This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
herlesupreeth gerrit-no-reply at lists.osmocom.orgherlesupreeth has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/16991 ) Change subject: Added feature to parse Service table based on SIM type. If USIM is present EF.UST service mapping is used else EF.SST service mapping is used ...................................................................... Added feature to parse Service table based on SIM type. If USIM is present EF.UST service mapping is used else EF.SST service mapping is used Change-Id: I6680e8c7f86326f72b98a33338e0dd5b58e55013 --- M pySim-read.py A pySim/ts_31_102.py M pySim/ts_51_011.py M pySim/utils.py M pysim-testdata/Fairwaves-SIM.ok M pysim-testdata/Wavemobile-SIM.ok M pysim-testdata/fakemagicsim.ok M pysim-testdata/sysmoISIM-SJA2.ok M pysim-testdata/sysmoUSIM-SJS1.ok M pysim-testdata/sysmosim-gr1.ok 10 files changed, 259 insertions(+), 31 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/91/16991/1 diff --git a/pySim-read.py b/pySim-read.py index 4e17b42..1210852 100755 --- a/pySim-read.py +++ b/pySim-read.py @@ -28,7 +28,8 @@ import random import re import sys -from pySim.ts_51_011 import EF, DF +from pySim.ts_51_011 import EF, DF, EF_SST_map +from pySim.ts_31_102 import EF_UST_map try: import json @@ -37,7 +38,7 @@ import simplejson as json from pySim.commands import SimCardCommands -from pySim.utils import h2b, swap_nibbles, rpad, dec_imsi, dec_iccid, format_xplmn_w_act, dec_spn +from pySim.utils import h2b, swap_nibbles, rpad, dec_imsi, dec_iccid, format_xplmn_w_act, dec_spn, parse_st def parse_options(): @@ -114,31 +115,37 @@ else: print("IMSI: Can't read, response code = %s" % (sw,)) - # EF.SST + # Determine whether the has just SIM or SIM+USIM or SIM+USIM+ISIM + # First (known) halves of the AID + aid_usim = "a0000000871002" + aid_isim = "a0000000871004" + + sim_type = [] + # Find out how many records the EF.DIR has + aid_record_count = scc.record_count(['3f00', '2F00']) + for i in range(0, aid_record_count): + record = scc.read_record(['3f00', '2F00'], i + 1) + if aid_isim in record[0]: + sim_type.append("ISIM") + elif aid_usim in record[0]: + sim_type.append("USIM") + else: + sim_type.append("SIM") + + # EF.SST/EF.UST - Base on SIM type + # Both EF.SST and EF.UST have same identifier - 6F38 (res, sw) = scc.read_binary(EF['SST']) if sw == '9000': - swapped = swap_nibbles(res) - print("USIM Service Table: %s" % swapped) - if len(res) >= 24: - byte12 = int(swapped[(12*2) - 2:(12*2)], 16) - service96 = (byte12&0x80 == 0x80) - print("Service 96 - Non-Access Stratum configuration by USIM: %s" % service96) - service95 = (byte12&0x40 == 0x40) - print("Service 95 - Support of UICC access to IMS: %s" % service95) - service93 = (byte12&0x10 == 0x10) - print("Service 93 - Communication Control for IMS by USIM: %s" % service93) - if len(res) >= 6: - byte3 = int(swapped[(3*2) - 2:(3*2)], 16) - service21 = (byte3&0x10 == 0x10) - print("Service 21 - MSISDN: %s" % service21) - if len(res) >= 10: - byte5 = int(swapped[(5*2) - 2:(5*2)], 16) - service34 = (byte5&0x02 == 0x02) - service35 = (byte5&0x04 == 0x04) - print("Service 34 - Enabled Services Table: %s" % service34) - print("Service 35 - APN Control List (ACL): %s" % service35) + # Get list of available services + avail_srvcs = parse_st(res) + srvc_map = EF_SST_map + if "USIM" in sim_type: + srvc_map = EF_UST_map + # Print those we're interested in + for s in (96, 95, 93, 21, 34, 35): + print('Service %d - %s: %s' % (s, srvc_map[s], s in avail_srvcs)) else: - print("USIM Service Table: Can't read, response code = %s" % (sw,)) + print("Service Table: Can't read, response code = %s" % (sw,)) # EF.SMSP (res, sw) = scc.read_record(['3f00', '7f10', '6f42'], 1) diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py new file mode 100644 index 0000000..c29aa04 --- /dev/null +++ b/pySim/ts_31_102.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Various constants from ETSI TS 131 102 +""" + +# +# Copyright (C) 2020 Supreeth Herle <herlesupreeth at gmail.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# Mapping between USIM Service Number and its description +EF_UST_map = { + 1: 'Local Phone Book', + 2: 'Fixed Dialling Numbers (FDN)', + 3: 'Extension 2', + 4: 'Service Dialling Numbers (SDN)', + 5: 'Extension3', + 6: 'Barred Dialling Numbers (BDN)', + 7: 'Extension4', + 8: 'Outgoing Call Information (OCI and OCT)', + 9: 'Incoming Call Information (ICI and ICT)', + 10: 'Short Message Storage (SMS)', + 11: 'Short Message Status Reports (SMSR)', + 12: 'Short Message Service Parameters (SMSP)', + 13: 'Advice of Charge (AoC)', + 14: 'Capability Configuration Parameters 2 (CCP2)', + 15: 'Cell Broadcast Message Identifier', + 16: 'Cell Broadcast Message Identifier Ranges', + 17: 'Group Identifier Level 1', + 18: 'Group Identifier Level 2', + 19: 'Service Provider Name', + 20: 'User controlled PLMN selector with Access Technology', + 21: 'MSISDN', + 22: 'Image (IMG)', + 23: 'Support of Localised Service Areas (SoLSA)', + 24: 'Enhanced Multi-Level Precedence and Pre-emption Service', + 25: 'Automatic Answer for eMLPP', + 26: 'RFU', + 27: 'GSM Access', + 28: 'Data download via SMS-PP', + 29: 'Data download via SMS-CB', + 30: 'Call Control by USIM', + 31: 'MO-SMS Control by USIM', + 32: 'RUN AT COMMAND command', + 33: 'shall be set to 1', + 34: 'Enabled Services Table', + 35: 'APN Control List (ACL)', + 36: 'Depersonalisation Control Keys', + 37: 'Co-operative Network List', + 38: 'GSM security context', + 39: 'CPBCCH Information', + 40: 'Investigation Scan', + 41: 'MexE', + 42: 'Operator controlled PLMN selector with Access Technology', + 43: 'HPLMN selector with Access Technology', + 44: 'Extension 5', + 45: 'PLMN Network Name', + 46: 'Operator PLMN List', + 47: 'Mailbox Dialling Numbers', + 48: 'Message Waiting Indication Status', + 49: 'Call Forwarding Indication Status', + 50: 'Reserved and shall be ignored', + 51: 'Service Provider Display Information', + 52: 'Multimedia Messaging Service (MMS)', + 53: 'Extension 8', + 54: 'Call control on GPRS by USIM', + 55: 'MMS User Connectivity Parameters', + 56: 'Network\'s indication of alerting in the MS (NIA)', + 57: 'VGCS Group Identifier List (EFVGCS and EFVGCSS)', + 58: 'VBS Group Identifier List (EFVBS and EFVBSS)', + 59: 'Pseudonym', + 60: 'User Controlled PLMN selector for I-WLAN access', + 61: 'Operator Controlled PLMN selector for I-WLAN access', + 62: 'User controlled WSID list', + 63: 'Operator controlled WSID list', + 64: 'VGCS security', + 65: 'VBS security', + 66: 'WLAN Reauthentication Identity', + 67: 'Multimedia Messages Storage', + 68: 'Generic Bootstrapping Architecture (GBA)', + 69: 'MBMS security', + 70: 'Data download via USSD and USSD application mode', + 71: 'Equivalent HPLMN', + 72: 'Additional TERMINAL PROFILE after UICC activation', + 73: 'Equivalent HPLMN Presentation Indication', + 74: 'Last RPLMN Selection Indication', + 75: 'OMA BCAST Smart Card Profile', + 76: 'GBA-based Local Key Establishment Mechanism', + 77: 'Terminal Applications', + 78: 'Service Provider Name Icon', + 79: 'PLMN Network Name Icon', + 80: 'Connectivity Parameters for USIM IP connections', + 81: 'Home I-WLAN Specific Identifier List', + 82: 'I-WLAN Equivalent HPLMN Presentation Indication', + 83: 'I-WLAN HPLMN Priority Indication', + 84: 'I-WLAN Last Registered PLMN', + 85: 'EPS Mobility Management Information', + 86: 'Allowed CSG Lists and corresponding indications', + 87: 'Call control on EPS PDN connection by USIM', + 88: 'HPLMN Direct Access', + 89: 'eCall Data', + 90: 'Operator CSG Lists and corresponding indications', + 91: 'Support for SM-over-IP', + 92: 'Support of CSG Display Control', + 93: 'Communication Control for IMS by USIM', + 94: 'Extended Terminal Applications', + 95: 'Support of UICC access to IMS', + 96: 'Non-Access Stratum configuration by USIM', + 97: 'PWS configuration by USIM', + 98: 'RFU', + 99: 'URI support by UICC', + 100: 'Extended EARFCN support', + 101: 'ProSe', + 102: 'USAT Application Pairing', + 103: 'Media Type support', + 104: 'IMS call disconnection cause', + 105: 'URI support for MO SHORT MESSAGE CONTROL', + 106: 'ePDG configuration Information support', + 107: 'ePDG configuration Information configured', + 108: 'ACDC support', + 109: 'MCPTT', + 110: 'ePDG configuration Information for Emergency Service support', + 111: 'ePDG configuration Information for Emergency Service configured', +} \ No newline at end of file diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py index 754d57f..1cec91f 100644 --- a/pySim/ts_51_011.py +++ b/pySim/ts_51_011.py @@ -249,3 +249,66 @@ 'MMSUP': DF['GSM']+[EF_num['MMSUP']], 'MMSUCP': DF['GSM']+[EF_num['MMSUCP']], } + +# Mapping between SIM Service Number and its description +EF_SST_map = { + 1: 'CHV1 disable function', + 2: 'Abbreviated Dialling Numbers (ADN)', + 3: 'Fixed Dialling Numbers (FDN)', + 4: 'Short Message Storage (SMS)', + 5: 'Advice of Charge (AoC)', + 6: 'Capability Configuration Parameters (CCP)', + 7: 'PLMN selector', + 8: 'RFU', + 9: 'MSISDN', + 10: 'Extension1', + 11: 'Extension2', + 12: 'SMS Parameters', + 13: 'Last Number Dialled (LND)', + 14: 'Cell Broadcast Message Identifier', + 15: 'Group Identifier Level 1', + 16: 'Group Identifier Level 2', + 17: 'Service Provider Name', + 18: 'Service Dialling Numbers (SDN)', + 19: 'Extension3', + 20: 'RFU', + 21: 'VGCS Group Identifier List (EFVGCS and EFVGCSS)', + 22: 'VBS Group Identifier List (EFVBS and EFVBSS)', + 23: 'enhanced Multi-Level Precedence and Pre-emption Service', + 24: 'Automatic Answer for eMLPP', + 25: 'Data download via SMS-CB', + 26: 'Data download via SMS-PP', + 27: 'Menu selection', + 28: 'Call control', + 29: 'Proactive SIM', + 30: 'Cell Broadcast Message Identifier Ranges', + 31: 'Barred Dialling Numbers (BDN)', + 32: 'Extension4', + 33: 'De-personalization Control Keys', + 34: 'Co-operative Network List', + 35: 'Short Message Status Reports', + 36: 'Network\'s indication of alerting in the MS', + 37: 'Mobile Originated Short Message control by SIM', + 38: 'GPRS', + 39: 'Image (IMG)', + 40: 'SoLSA (Support of Local Service Area)', + 41: 'USSD string data object supported in Call Control', + 42: 'RUN AT COMMAND command', + 43: 'User controlled PLMN Selector with Access Technology', + 44: 'Operator controlled PLMN Selector with Access Technology', + 45: 'HPLMN Selector with Access Technology', + 46: 'CPBCCH Information', + 47: 'Investigation Scan', + 48: 'Extended Capability Configuration Parameters', + 49: 'MExE', + 50: 'Reserved and shall be ignored', + 51: 'PLMN Network Name', + 52: 'Operator PLMN List', + 53: 'Mailbox Dialling Numbers', + 54: 'Message Waiting Indication Status', + 55: 'Call Forwarding Indication Status', + 56: 'Service Provider Display Information', + 57: 'Multimedia Messaging Service (MMS)', + 58: 'Extension 8', + 59: 'MMS User Connectivity Parameters', +} \ No newline at end of file diff --git a/pySim/utils.py b/pySim/utils.py index fbe3e47..2d71ade 100644 --- a/pySim/utils.py +++ b/pySim/utils.py @@ -252,4 +252,24 @@ mcc += digit2 * 10 if digit3 != 0XF: mcc += digit3 - return mcc \ No newline at end of file + return mcc + +def parse_st(st): + """ + Parses the EF S/UST and returns available/supported services + """ + swapped = swap_nibbles(st) + print("Service Table: %s" % swapped) + swapped_bytes = [swapped[i:i+2] for i in range(0, len(swapped), 2) ] + avail_srvc = [] + # Get each byte and check for available services + for i in range(0, len(swapped_bytes)): + byte = int(swapped_bytes[i], 16) + for j in range(1, 9): + if byte&0x01 == 0x01: + # Byte X contains info about Services num (8X-7) to num (8X) + # bit = 1: service available + # bit = 0: service not available + avail_srvc.append((8*i) + j) + byte = byte >> 1 + return avail_srvc diff --git a/pysim-testdata/Fairwaves-SIM.ok b/pysim-testdata/Fairwaves-SIM.ok index 149b9b4..d1b62f2 100644 --- a/pysim-testdata/Fairwaves-SIM.ok +++ b/pysim-testdata/Fairwaves-SIM.ok @@ -2,7 +2,7 @@ Reading ... ICCID: 8988219000000117833 IMSI: 001010000000111 -USIM Service Table: ffc33cff30f0fff000f0ff300f0c +Service Table: ffc33cff30f0fff000f0ff300f0c Service 96 - Non-Access Stratum configuration by USIM: False Service 95 - Support of UICC access to IMS: False Service 93 - Communication Control for IMS by USIM: True diff --git a/pysim-testdata/Wavemobile-SIM.ok b/pysim-testdata/Wavemobile-SIM.ok index 8214a4c..0347401 100644 --- a/pysim-testdata/Wavemobile-SIM.ok +++ b/pysim-testdata/Wavemobile-SIM.ok @@ -2,7 +2,7 @@ Reading ... ICCID: 89445310150011013678 IMSI: 001010000000102 -USIM Service Table: ff33fff0c300fff000c00f0c0f300000 +Service Table: ff33fff0c300fff000c00f0c0f300000 Service 96 - Non-Access Stratum configuration by USIM: False Service 95 - Support of UICC access to IMS: False Service 93 - Communication Control for IMS by USIM: False diff --git a/pysim-testdata/fakemagicsim.ok b/pysim-testdata/fakemagicsim.ok index be24539..be5f8f4 100644 --- a/pysim-testdata/fakemagicsim.ok +++ b/pysim-testdata/fakemagicsim.ok @@ -2,7 +2,7 @@ Reading ... ICCID: 1122334455667788990 IMSI: 001010000000102 -USIM Service Table: fff3fff030000f3000c0 +Service Table: fff3fff030000f3000c0 Service 21 - MSISDN: True Service 34 - Enabled Services Table: False Service 35 - APN Control List (ACL): False diff --git a/pysim-testdata/sysmoISIM-SJA2.ok b/pysim-testdata/sysmoISIM-SJA2.ok index 7161b55..d40944c 100644 --- a/pysim-testdata/sysmoISIM-SJA2.ok +++ b/pysim-testdata/sysmoISIM-SJA2.ok @@ -2,7 +2,7 @@ Reading ... ICCID: 8988211900000000004 IMSI: 001010000000102 -USIM Service Table: ff33fffff300f3f003c00f3c0f0000 +Service Table: ff33fffff300f3f003c00f3c0f0000 Service 96 - Non-Access Stratum configuration by USIM: False Service 95 - Support of UICC access to IMS: False Service 93 - Communication Control for IMS by USIM: True diff --git a/pysim-testdata/sysmoUSIM-SJS1.ok b/pysim-testdata/sysmoUSIM-SJS1.ok index 25f14d8..43fa43b 100644 --- a/pysim-testdata/sysmoUSIM-SJS1.ok +++ b/pysim-testdata/sysmoUSIM-SJS1.ok @@ -2,7 +2,7 @@ Reading ... ICCID: 1122334455667788990 IMSI: 001010000000102 -USIM Service Table: fff3fffff300f3f10fc0000c0f0000 +Service Table: fff3fffff300f3f10fc0000c0f0000 Service 96 - Non-Access Stratum configuration by USIM: False Service 95 - Support of UICC access to IMS: False Service 93 - Communication Control for IMS by USIM: False diff --git a/pysim-testdata/sysmosim-gr1.ok b/pysim-testdata/sysmosim-gr1.ok index b26433b..f466f9f 100644 --- a/pysim-testdata/sysmosim-gr1.ok +++ b/pysim-testdata/sysmosim-gr1.ok @@ -2,7 +2,7 @@ Reading ... ICCID: 1122334455667788990 IMSI: 001010000000102 -USIM Service Table: fff3fff0f00000300000 +Service Table: fff3fff0f00000300000 Service 21 - MSISDN: True Service 34 - Enabled Services Table: False Service 35 - APN Control List (ACL): False -- To view, visit https://gerrit.osmocom.org/c/pysim/+/16991 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I6680e8c7f86326f72b98a33338e0dd5b58e55013 Gerrit-Change-Number: 16991 Gerrit-PatchSet: 1 Gerrit-Owner: herlesupreeth <herlesupreeth at gmail.com> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200124/b72793e6/attachment.htm>