laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35278?usp=email )
Change subject: isim: Replace legacy imperative address TLV encoder/decoder with construct ...................................................................... isim: Replace legacy imperative address TLV encoder/decoder with construct We've recently introduced IPv{4,6}Adapter construct classes and can switch to this instead of using the old imperative encoder/decoder functions {enc,dec}_addr_tlv(). Aside from code cleanup, this also means we now support the IPv6 address type in EF.PCSCF. Change-Id: I4d01ccfe473a8a80fbee33fdcbd8a19b39da85ac --- M pySim/ts_31_103.py 1 file changed, 25 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/78/35278/1 diff --git a/pySim/ts_31_103.py b/pySim/ts_31_103.py index 5268c70..a4a7656 100644 --- a/pySim/ts_31_103.py +++ b/pySim/ts_31_103.py @@ -135,19 +135,18 @@ class EF_PCSCF(LinFixedEF): _test_de_encode = [ ( '802c0070637363662e696d732e6d6e633030302e6d63633733382e7075622e336770706e6574776f726b2e6f7267', - { "addr": "pcscf.ims.mnc000.mcc738.pub.3gppnetwork.org", "addr_type": "00" } ), + {'pcscf_address': { "address": "pcscf.ims.mnc000.mcc738.pub.3gppnetwork.org", "type_of_address": "FQDN" } } ), ] + class PcscfAddress(BER_TLV_IE, tag=0x80): + _construct = Struct('type_of_address'/Enum(Byte, FQDN=0, IPv4=1, IPv6=2), + 'address'/Switch(this.type_of_address, + {'FQDN': Utf8Adapter(GreedyBytes), + 'IPv4': Ipv4Adapter(GreedyBytes), + 'IPv6': Ipv6Adapter(GreedyBytes)})) + def __init__(self, fid='6f09', sfid=None, name='EF.P-CSCF', desc='P-CSCF Address', **kwargs): super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) - - def _decode_record_hex(self, raw_hex, **kwargs): - addr, addr_type = dec_addr_tlv(raw_hex) - return {"addr": addr, "addr_type": addr_type} - - def _encode_record_hex(self, json_in, **kwargs): - addr = json_in['addr'] - addr_type = json_in['addr_type'] - return enc_addr_tlv(addr, addr_type) + self._tlv = EF_PCSCF.PcscfAddress # TS 31.103 Section 4.2.9 class EF_GBABP(TransparentEF): -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35278?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I4d01ccfe473a8a80fbee33fdcbd8a19b39da85ac Gerrit-Change-Number: 35278 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <lafo...@osmocom.org> Gerrit-MessageType: newchange