Change in pysim[master]: utils.py: Support IPv4 encoding for Address TLV object present in EF....

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
Tue Jan 5 14:22:42 UTC 2021


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

Change subject: utils.py: Support IPv4 encoding for Address TLV object present in EF.ePDGId and EF.ePDGIdEm
......................................................................

utils.py: Support IPv4 encoding for Address TLV object present in EF.ePDGId and EF.ePDGIdEm

Change-Id: Id46a44257d09c98ad5e0b7558e25e2bc52b23978
---
M pySim/utils.py
1 file changed, 11 insertions(+), 2 deletions(-)

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



diff --git a/pySim/utils.py b/pySim/utils.py
index c5a38d8..782cb8b 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -550,10 +550,19 @@
 
 	s = ""
 
-	# TODO: Encoding of IPv4 and IPv6 address
-	if addr_type == '00':
+	# TODO: Encoding of IPv6 address
+	if addr_type == '00': #FQDN
 		hex_str = s2h(addr)
 		s += '80' + ('%02x' % ((len(hex_str)//2)+1)) + '00' + hex_str
+	elif addr_type == '01': #IPv4
+		ipv4_list = addr.split('.')
+		ipv4_str = ""
+		for i in ipv4_list:
+			ipv4_str += ('%02x' % (int(i)))
+
+		# Unused bytes shall be set to 'ff'. i.e 4th Octet after Address Type is not used
+		# IPv4 Address is in octet 5 to octet 8 of the TLV data object
+		s += '80' + ('%02x' % ((len(ipv4_str)//2)+2)) + '01' + 'ff' + ipv4_str
 
 	return s
 

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Id46a44257d09c98ad5e0b7558e25e2bc52b23978
Gerrit-Change-Number: 21868
Gerrit-PatchSet: 5
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/20210105/1ee852a6/attachment.htm>


More information about the gerrit-log mailing list