Change in pysim[master]: utils.py: Add helper method to parse ePDG Identifier from hex string

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.org
Mon Apr 20 09:03:05 UTC 2020


herlesupreeth has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/17883 )


Change subject: utils.py: Add helper method to parse ePDG Identifier from hex string
......................................................................

utils.py: Add helper method to parse ePDG Identifier from hex string

The hex string consists of contains zero or more ePDG identifier data objects.
Each ePDG Identifier TLV data object consists of tag value of '80', length of identifier, address type.

TS 31.102 version 13.4.0 Release 13. The same parsing method applies for both EF.ePDGId and EF.ePDGIdEm

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



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/83/17883/1

diff --git a/pySim/utils.py b/pySim/utils.py
index 51f2954..aeba2c1 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_epdgid(hexstr):
+	"""
+	Decode ePDG Id to get EF.ePDGId or EF.ePDGIdEm.
+	See 3GPP TS 31.102 version 13.4.0 Release 13, section 4.2.102 and 4.2.104.
+	"""
+
+	# Convert from hex str to (kind of) 'bytes'
+	epdgid_bytes = h2b(hexstr)
+
+	s = ""
+	l = 0
+
+	while l < len(epdgid_bytes):
+		# Tag value of this TLV data object: '80'
+		if ord(epdgid_bytes[l]) != 0x80:
+			break
+		l += 1
+		# Then, extract length of ePDGId from first byte after tag
+		con_len = ord(epdgid_bytes[l])
+		l += 1
+		# Address Type: 0x00 (FQDN), 0x01 (IPv4), 0x02 (IPv6), other (Reserved)
+		addr_type = ord(epdgid_bytes[l])
+		l += 1
+		# ePDG Identifier
+		# TODO: Support parsing of IPv4 and IPv6
+		if addr_type == 0x00:
+			content = epdgid_bytes[l:l+con_len]
+			s = "\t%s # %s\n" % (b2h(content), content)
+		l += con_len
+	return s

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I96fb129d178cfd7ec037989526da77899ae8d344
Gerrit-Change-Number: 17883
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/20200420/afb9c9fb/attachment.htm>


More information about the gerrit-log mailing list