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:
Harald Welte
2023-12-08 15:06:29 +01:00
committed by laforge
parent b3c46135bb
commit 301d6ed14a
2 changed files with 17 additions and 18 deletions

View File

@@ -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):