31.102: Fix EF.Routing_Indicator for odd number of digits

The routing indicator is BCD-encoded but has an arbitrary length of
1, 2, 3 or 4 digits.

In order to support the odd lengths of 1 or 3, we must not pad on the
byte level, but on the nibble level. This requires a slight extension of
the Rpad() Adapter.

Change-Id: I6c26dccdd570de7b7a4cd48338068e230340ec7c
Fixes: OS#6054
This commit is contained in:
Harald Welte
2023-06-09 09:17:05 +02:00
parent 1dce498a67
commit f9a5ba5e0f
2 changed files with 11 additions and 7 deletions

View File

@@ -1089,7 +1089,8 @@ class EF_Routing_Indicator(TransparentEF):
# 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
# shall be coded as "1111" to fill the 4 digits coding of Routing Indicator
self._construct = Struct('routing_indicator'/BcdAdapter(Rpad(Bytes(2))), 'rfu'/HexAdapter(Bytes(2)))
self._construct = Struct('routing_indicator'/Rpad(BcdAdapter(Bytes(2)), 'f', 2),
'rfu'/HexAdapter(Bytes(2)))
# TS 31.102 Section 4.4.11.13
class EF_TN3GPPSNN(TransparentEF):