Change in pysim[master]: utils.py: Add helper method to parse and print Service Table

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/.

laforge gerrit-no-reply at lists.osmocom.org
Wed Apr 29 09:10:55 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/17896 )

Change subject: utils.py: Add helper method to parse and print Service Table
......................................................................

utils.py: Add helper method to parse and print Service Table

This method helps in printing Service Tables in EF.SST, EF.UST, EF.IST.
Takes hex string of Service table, parses it and prints available service along with its description.

Change-Id: Ie1e82e07ead2e28314a5794661e6b2ced0acd72a
---
M pySim/utils.py
1 file changed, 31 insertions(+), 0 deletions(-)

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



diff --git a/pySim/utils.py b/pySim/utils.py
index 51f2954..be670e9 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -347,3 +347,34 @@
 				avail_srvc.append((8*i) + j)
 			byte = byte >> 1
 	return avail_srvc
+
+def dec_st(st, table="sim"):
+	"""
+	Parses the EF S/U/IST and prints the list of available services in EF S/U/IST
+	"""
+
+	if table == "usim":
+		from pySim.ts_31_102 import EF_UST_map
+		lookup_map = EF_UST_map
+	else:
+		from pySim.ts_51_011 import EF_SST_map
+		lookup_map = EF_SST_map
+
+	st_bytes = [st[i:i+2] for i in range(0, len(st), 2) ]
+
+	avail_st = ""
+	# Get each byte and check for available services
+	for i in range(0, len(st_bytes)):
+		# Byte i contains info about Services num (8i+1) to num (8i+8)
+		byte = int(st_bytes[i], 16)
+		# Services in each byte are in order MSB to LSB
+		# MSB - Service (8i+8)
+		# LSB - Service (8i+1)
+		for j in range(1, 9):
+			if byte&0x01 == 0x01 and ((8*i) + j in lookup_map):
+				# Byte X contains info about Services num (8X-7) to num (8X)
+				# bit = 1: service available
+				# bit = 0: service not available
+				avail_st += '\tService %d - %s\n' % ((8*i) + j, lookup_map[(8*i) + j])
+			byte = byte >> 1
+	return avail_st

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie1e82e07ead2e28314a5794661e6b2ced0acd72a
Gerrit-Change-Number: 17896
Gerrit-PatchSet: 2
Gerrit-Owner: herlesupreeth <herlesupreeth at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200429/b0e06600/attachment.htm>


More information about the gerrit-log mailing list