mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-17 02:48:34 +03:00
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
This commit is contained in:
@@ -135,19 +135,18 @@ class EF_IST(EF_UServiceTable):
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user