Fix more odd-length digit sequences via PaddedBcdAdapter
There are more files where trailing digits are indicated using 'f' and should be stripped during decode, including EF.MSISDN and EF.VGCS This is not just a presentation issue, but actually rendered wrong data before, see the modified test output where our "read_record_uicc.ok" file contained "bcd_len: 7" but then only 6 BCD digits due to this bug. Change-Id: I4571482da924a3d645caa297108279d182448d21
This commit is contained in:
@@ -596,7 +596,7 @@ class EF_ICI(CyclicEF):
|
|||||||
self._construct = Struct('alpha_id'/Bytes(this._.total_len-28),
|
self._construct = Struct('alpha_id'/Bytes(this._.total_len-28),
|
||||||
'len_of_bcd_contents'/Int8ub,
|
'len_of_bcd_contents'/Int8ub,
|
||||||
'ton_npi'/Int8ub,
|
'ton_npi'/Int8ub,
|
||||||
'call_number'/BcdAdapter(Bytes(10)),
|
'call_number'/PaddedBcdAdapter(Rpad(Bytes(10))),
|
||||||
'cap_cfg2_record_id'/Int8ub,
|
'cap_cfg2_record_id'/Int8ub,
|
||||||
'ext5_record_id'/Int8ub,
|
'ext5_record_id'/Int8ub,
|
||||||
'date_and_time'/BcdAdapter(Bytes(7)),
|
'date_and_time'/BcdAdapter(Bytes(7)),
|
||||||
@@ -612,7 +612,7 @@ class EF_OCI(CyclicEF):
|
|||||||
self._construct = Struct('alpha_id'/Bytes(this._.total_len-27),
|
self._construct = Struct('alpha_id'/Bytes(this._.total_len-27),
|
||||||
'len_of_bcd_contents'/Int8ub,
|
'len_of_bcd_contents'/Int8ub,
|
||||||
'ton_npi'/Int8ub,
|
'ton_npi'/Int8ub,
|
||||||
'call_number'/BcdAdapter(Bytes(10)),
|
'call_number'/PaddedBcdAdapter(Rpad(Bytes(10))),
|
||||||
'cap_cfg2_record_id'/Int8ub,
|
'cap_cfg2_record_id'/Int8ub,
|
||||||
'ext5_record_id'/Int8ub,
|
'ext5_record_id'/Int8ub,
|
||||||
'date_and_time'/BcdAdapter(Bytes(7)),
|
'date_and_time'/BcdAdapter(Bytes(7)),
|
||||||
@@ -1118,7 +1118,7 @@ class EF_Routing_Indicator(TransparentEF):
|
|||||||
# responsibility of home network operator but BCD coding shall be used. If a network
|
# responsibility of home network operator but BCD coding shall be used. If a network
|
||||||
# operator decides to assign less than 4 digits to Routing Indicator, the remaining digits
|
# operator decides to assign less than 4 digits to Routing Indicator, the remaining digits
|
||||||
# shall be coded as "1111" to fill the 4 digits coding of Routing Indicator
|
# shall be coded as "1111" to fill the 4 digits coding of Routing Indicator
|
||||||
self._construct = Struct('routing_indicator'/Rpad(BcdAdapter(Bytes(2)), 'f', 2),
|
self._construct = Struct('routing_indicator'/PaddedBcdAdapter(Rpad(Bytes(2))),
|
||||||
'rfu'/Bytes(2))
|
'rfu'/Bytes(2))
|
||||||
|
|
||||||
# TS 31.102 Section 4.4.11.13 (Rel 16)
|
# TS 31.102 Section 4.4.11.13 (Rel 16)
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ class EF_ADN(LinFixedEF):
|
|||||||
self._construct = Struct('alpha_id'/COptional(GsmOrUcs2Adapter(Rpad(Bytes(this._.total_len-14)))),
|
self._construct = Struct('alpha_id'/COptional(GsmOrUcs2Adapter(Rpad(Bytes(this._.total_len-14)))),
|
||||||
'len_of_bcd'/Int8ub,
|
'len_of_bcd'/Int8ub,
|
||||||
'ton_npi'/TonNpi,
|
'ton_npi'/TonNpi,
|
||||||
'dialing_nr'/ExtendedBcdAdapter(BcdAdapter(Rpad(Bytes(10)))),
|
'dialing_nr'/ExtendedBcdAdapter(PaddedBcdAdapter(Rpad(Bytes(10)))),
|
||||||
'cap_conf_id'/Int8ub,
|
'cap_conf_id'/Int8ub,
|
||||||
ext_name/Int8ub)
|
ext_name/Int8ub)
|
||||||
|
|
||||||
@@ -193,11 +193,11 @@ class EF_MSISDN(LinFixedEF):
|
|||||||
( 'ffffffffffffffffffffffffffffffffffffffff04b12143f5ffffffffffffffffff',
|
( 'ffffffffffffffffffffffffffffffffffffffff04b12143f5ffffffffffffffffff',
|
||||||
{"alpha_id": "", "len_of_bcd": 4, "ton_npi": {"ext": True, "type_of_number": "network_specific",
|
{"alpha_id": "", "len_of_bcd": 4, "ton_npi": {"ext": True, "type_of_number": "network_specific",
|
||||||
"numbering_plan_id": "isdn_e164"},
|
"numbering_plan_id": "isdn_e164"},
|
||||||
"dialing_nr": "12345f"}),
|
"dialing_nr": "12345"}),
|
||||||
( '456967656e65205275666e756d6d6572ffffffff0891947172199181f3ffffffffff',
|
( '456967656e65205275666e756d6d6572ffffffff0891947172199181f3ffffffffff',
|
||||||
{"alpha_id": "Eigene Rufnummer", "len_of_bcd": 8, "ton_npi": {"ext": True, "type_of_number": "international",
|
{"alpha_id": "Eigene Rufnummer", "len_of_bcd": 8, "ton_npi": {"ext": True, "type_of_number": "international",
|
||||||
"numbering_plan_id": "isdn_e164"},
|
"numbering_plan_id": "isdn_e164"},
|
||||||
"dialing_nr": "4917279119183f"}),
|
"dialing_nr": "4917279119183"}),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Ensure deprecated representations still work
|
# Ensure deprecated representations still work
|
||||||
@@ -215,7 +215,7 @@ class EF_MSISDN(LinFixedEF):
|
|||||||
self._construct = Struct('alpha_id'/COptional(GsmOrUcs2Adapter(Rpad(Bytes(this._.total_len-14)))),
|
self._construct = Struct('alpha_id'/COptional(GsmOrUcs2Adapter(Rpad(Bytes(this._.total_len-14)))),
|
||||||
'len_of_bcd'/Int8ub,
|
'len_of_bcd'/Int8ub,
|
||||||
'ton_npi'/TonNpi,
|
'ton_npi'/TonNpi,
|
||||||
'dialing_nr'/ExtendedBcdAdapter(BcdAdapter(Rpad(Bytes(10)))),
|
'dialing_nr'/ExtendedBcdAdapter(PaddedBcdAdapter(Rpad(Bytes(10)))),
|
||||||
Padding(2, pattern=b'\xff'))
|
Padding(2, pattern=b'\xff'))
|
||||||
|
|
||||||
# Maintain compatibility with deprecated representations
|
# Maintain compatibility with deprecated representations
|
||||||
@@ -661,12 +661,12 @@ class EF_AD(TransparentEF):
|
|||||||
# TS 51.011 Section 10.3.20 / 10.3.22
|
# TS 51.011 Section 10.3.20 / 10.3.22
|
||||||
class EF_VGCS(TransRecEF):
|
class EF_VGCS(TransRecEF):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( "92f9ffff", "299fffff" ),
|
( "92f9ffff", "299" ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='6fb1', sfid=None, name='EF.VGCS', size=(4, 200), rec_len=4,
|
def __init__(self, fid='6fb1', sfid=None, name='EF.VGCS', size=(4, 200), rec_len=4,
|
||||||
desc='Voice Group Call Service', **kwargs):
|
desc='Voice Group Call Service', **kwargs):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, rec_len=rec_len, **kwargs)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, rec_len=rec_len, **kwargs)
|
||||||
self._construct = BcdAdapter(Bytes(4))
|
self._construct = PaddedBcdAdapter(Rpad(Bytes(4)))
|
||||||
|
|
||||||
# TS 51.011 Section 10.3.21 / 10.3.23
|
# TS 51.011 Section 10.3.21 / 10.3.23
|
||||||
class EF_VGCSS(TransparentEF):
|
class EF_VGCSS(TransparentEF):
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
"type_of_number": "reserved_for_extension",
|
"type_of_number": "reserved_for_extension",
|
||||||
"numbering_plan_id": "reserved_for_extension"
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
},
|
},
|
||||||
"dialing_nr": "123456",
|
"dialing_nr": "1234567",
|
||||||
"cap_conf_id": 42,
|
"cap_conf_id": 42,
|
||||||
"ext4_record_id": 23
|
"ext4_record_id": 23
|
||||||
},
|
},
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
"type_of_number": "reserved_for_extension",
|
"type_of_number": "reserved_for_extension",
|
||||||
"numbering_plan_id": "reserved_for_extension"
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
},
|
},
|
||||||
"dialing_nr": "123456",
|
"dialing_nr": "1234567",
|
||||||
"cap_conf_id": 42,
|
"cap_conf_id": 42,
|
||||||
"ext4_record_id": 23
|
"ext4_record_id": 23
|
||||||
},
|
},
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
"type_of_number": "reserved_for_extension",
|
"type_of_number": "reserved_for_extension",
|
||||||
"numbering_plan_id": "reserved_for_extension"
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
},
|
},
|
||||||
"dialing_nr": "123456",
|
"dialing_nr": "1234567",
|
||||||
"cap_conf_id": 42,
|
"cap_conf_id": 42,
|
||||||
"ext4_record_id": 23
|
"ext4_record_id": 23
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
"type_of_number": "reserved_for_extension",
|
"type_of_number": "reserved_for_extension",
|
||||||
"numbering_plan_id": "reserved_for_extension"
|
"numbering_plan_id": "reserved_for_extension"
|
||||||
},
|
},
|
||||||
"dialing_nr": "123456",
|
"dialing_nr": "1234567",
|
||||||
"cap_conf_id": 42,
|
"cap_conf_id": 42,
|
||||||
"ext4_record_id": 23
|
"ext4_record_id": 23
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user