Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | # without this, pylint will fail when inner classes are used |
| 4 | # within the 'nested' kwarg of our TlvMeta metaclass on python 3.7 :( |
| 5 | # pylint: disable=undefined-variable |
| 6 | |
| 7 | """ |
| 8 | The File (and its derived classes) uses the classes of pySim.filesystem in |
| 9 | order to describe the files specified in UIC Reference P38 T 9001 5.0 "FFFIS for GSM-R SIM Cards" |
| 10 | """ |
| 11 | |
| 12 | # |
| 13 | # Copyright (C) 2021 Harald Welte <laforge@osmocom.org> |
| 14 | # |
| 15 | # This program is free software: you can redistribute it and/or modify |
| 16 | # it under the terms of the GNU General Public License as published by |
| 17 | # the Free Software Foundation, either version 2 of the License, or |
| 18 | # (at your option) any later version. |
| 19 | # |
| 20 | # This program is distributed in the hope that it will be useful, |
| 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | # GNU General Public License for more details. |
| 24 | # |
| 25 | # You should have received a copy of the GNU General Public License |
| 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 27 | # |
| 28 | |
| 29 | |
| 30 | from pySim.utils import * |
| 31 | #from pySim.tlv import * |
| 32 | from struct import pack, unpack |
| 33 | from construct import * |
| 34 | from construct import Optional as COptional |
| 35 | from pySim.construct import * |
| 36 | import enum |
| 37 | |
| 38 | from pySim.filesystem import * |
| 39 | import pySim.ts_102_221 |
| 40 | import pySim.ts_51_011 |
| 41 | |
| 42 | ###################################################################### |
| 43 | # DF.EIRENE (FFFIS for GSM-R SIM Cards) |
| 44 | ###################################################################### |
| 45 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 46 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 47 | class FuncNTypeAdapter(Adapter): |
| 48 | def _decode(self, obj, context, path): |
| 49 | bcd = swap_nibbles(b2h(obj)) |
Harald Welte | 8dbf714 | 2023-01-24 14:35:19 +0100 | [diff] [blame] | 50 | last_digit = int(bcd[-1], 16) |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 51 | return {'functional_number': bcd[:-1], |
Harald Welte | 8dbf714 | 2023-01-24 14:35:19 +0100 | [diff] [blame] | 52 | 'presentation_of_only_this_fn': bool(last_digit & 4), |
| 53 | 'permanent_fn': bool(last_digit & 8)} |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 54 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 55 | def _encode(self, obj, context, path): |
| 56 | return 'FIXME' |
| 57 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 58 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 59 | class EF_FN(LinFixedEF): |
| 60 | """Section 7.2""" |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 61 | _test_decode = [ |
| 62 | ( "40315801000010ff01", |
| 63 | { "functional_number_and_type": { "functional_number": "04138510000001f", |
| 64 | "presentation_of_only_this_fn": True, "permanent_fn": True }, "list_number": 1 } ), |
| 65 | ] |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 66 | def __init__(self): |
Harald Welte | e6d7b14 | 2023-01-24 14:27:25 +0100 | [diff] [blame] | 67 | super().__init__(fid='6ff1', sfid=None, name='EF.FN', |
Harald Welte | 99e4cc0 | 2022-07-21 15:25:47 +0200 | [diff] [blame] | 68 | desc='Functional numbers', rec_len=(9, 9)) |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 69 | self._construct = Struct('functional_number_and_type'/FuncNTypeAdapter(Bytes(8)), |
| 70 | 'list_number'/Int8ub) |
| 71 | |
| 72 | |
| 73 | class PlConfAdapter(Adapter): |
| 74 | """Section 7.4.3""" |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 75 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 76 | def _decode(self, obj, context, path): |
| 77 | num = int(obj) & 0x7 |
| 78 | if num == 0: |
| 79 | return 'None' |
| 80 | elif num == 1: |
| 81 | return 4 |
| 82 | elif num == 2: |
| 83 | return 3 |
| 84 | elif num == 3: |
| 85 | return 2 |
| 86 | elif num == 4: |
| 87 | return 1 |
| 88 | elif num == 5: |
| 89 | return 0 |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 90 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 91 | def _encode(self, obj, context, path): |
| 92 | if obj == 'None': |
| 93 | return 0 |
| 94 | obj = int(obj) |
| 95 | if obj == 4: |
| 96 | return 1 |
| 97 | elif obj == 3: |
| 98 | return 2 |
| 99 | elif obj == 2: |
| 100 | return 3 |
| 101 | elif obj == 1: |
| 102 | return 4 |
| 103 | elif obj == 0: |
| 104 | return 5 |
| 105 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 106 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 107 | class PlCallAdapter(Adapter): |
| 108 | """Section 7.4.12""" |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 109 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 110 | def _decode(self, obj, context, path): |
| 111 | num = int(obj) & 0x7 |
| 112 | if num == 0: |
| 113 | return 'None' |
| 114 | elif num == 1: |
| 115 | return 4 |
| 116 | elif num == 2: |
| 117 | return 3 |
| 118 | elif num == 3: |
| 119 | return 2 |
| 120 | elif num == 4: |
| 121 | return 1 |
| 122 | elif num == 5: |
| 123 | return 0 |
| 124 | elif num == 6: |
| 125 | return 'B' |
| 126 | elif num == 7: |
| 127 | return 'A' |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 128 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 129 | def _encode(self, obj, context, path): |
| 130 | if obj == 'None': |
| 131 | return 0 |
| 132 | if obj == 4: |
| 133 | return 1 |
| 134 | elif obj == 3: |
| 135 | return 2 |
| 136 | elif obj == 2: |
| 137 | return 3 |
| 138 | elif obj == 1: |
| 139 | return 4 |
| 140 | elif obj == 0: |
| 141 | return 5 |
| 142 | elif obj == 'B': |
| 143 | return 6 |
| 144 | elif obj == 'A': |
| 145 | return 7 |
| 146 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 147 | |
| 148 | NextTableType = Enum(Byte, decision=0xf0, predefined=0xf1, |
| 149 | num_dial_digits=0xf2, ic=0xf3, empty=0xff) |
| 150 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 151 | |
| 152 | class EF_CallconfC(TransparentEF): |
| 153 | """Section 7.3""" |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 154 | _test_de_encode = [ |
| 155 | ( "026121ffffffffffff1e000a040a010253600795792426f0", |
| 156 | { "pl_conf": 3, "conf_nr": "1612ffffffffffff", "max_rand": 30, "n_ack_max": 10, |
| 157 | "pl_ack": 1, "n_nested_max": 10, "train_emergency_gid": 1, "shunting_emergency_gid": 2, |
| 158 | "imei": "350670599742620f" } ), |
| 159 | ] |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 160 | def __init__(self): |
Harald Welte | 13edf30 | 2022-07-21 15:19:23 +0200 | [diff] [blame] | 161 | super().__init__(fid='6ff2', sfid=None, name='EF.CallconfC', size=(24, 24), |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 162 | desc='Call Configuration of emergency calls Configuration') |
| 163 | self._construct = Struct('pl_conf'/PlConfAdapter(Int8ub), |
| 164 | 'conf_nr'/BcdAdapter(Bytes(8)), |
| 165 | 'max_rand'/Int8ub, |
| 166 | 'n_ack_max'/Int16ub, |
| 167 | 'pl_ack'/PlCallAdapter(Int8ub), |
| 168 | 'n_nested_max'/Int8ub, |
| 169 | 'train_emergency_gid'/Int8ub, |
| 170 | 'shunting_emergency_gid'/Int8ub, |
| 171 | 'imei'/BcdAdapter(Bytes(8))) |
| 172 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 173 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 174 | class EF_CallconfI(LinFixedEF): |
| 175 | """Section 7.5""" |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 176 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 177 | def __init__(self): |
Harald Welte | 99e4cc0 | 2022-07-21 15:25:47 +0200 | [diff] [blame] | 178 | super().__init__(fid='6ff3', sfid=None, name='EF.CallconfI', rec_len=(21, 21), |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 179 | desc='Call Configuration of emergency calls Information') |
| 180 | self._construct = Struct('t_dur'/Int24ub, |
| 181 | 't_relcalc'/Int32ub, |
| 182 | 'pl_call'/PlCallAdapter(Int8ub), |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 183 | 'cause' / |
| 184 | FlagsEnum(Int8ub, powered_off=1, |
| 185 | radio_link_error=2, user_command=5), |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 186 | 'gcr'/BcdAdapter(Bytes(4)), |
| 187 | 'fnr'/BcdAdapter(Bytes(8))) |
| 188 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 189 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 190 | class EF_Shunting(TransparentEF): |
| 191 | """Section 7.6""" |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 192 | _test_de_encode = [ |
| 193 | ( "03f8ffffff000000", { "common_gid": 3, "shunting_gid": "f8ffffff000000" } ), |
| 194 | ] |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 195 | def __init__(self): |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 196 | super().__init__(fid='6ff4', sfid=None, |
Harald Welte | 13edf30 | 2022-07-21 15:19:23 +0200 | [diff] [blame] | 197 | name='EF.Shunting', desc='Shunting', size=(8, 8)) |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 198 | self._construct = Struct('common_gid'/Int8ub, |
Harald Welte | 3c98d5e | 2022-07-20 07:40:05 +0200 | [diff] [blame] | 199 | 'shunting_gid'/HexAdapter(Bytes(7))) |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 200 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 201 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 202 | class EF_GsmrPLMN(LinFixedEF): |
| 203 | """Section 7.7""" |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 204 | _test_de_encode = [ |
| 205 | ( "22f860f86f8d6f8e01", { "plmn": "228f06", "class_of_network": { |
| 206 | "supported": { "vbs": True, "vgcs": True, "emlpp": True, |
| 207 | "fn": True, "eirene": True }, "preference": 0 }, |
| 208 | "ic_incoming_ref_tbl": "6f8d", "outgoing_ref_tbl": "6f8e", |
| 209 | "ic_table_ref": "01" } ), |
| 210 | ( "22f810416f8d6f8e02", { "plmn": "228f01", "class_of_network": { |
| 211 | "supported": { "vbs": False, "vgcs": False, "emlpp": False, |
| 212 | "fn": True, "eirene": False }, "preference": 1 }, |
| 213 | "ic_incoming_ref_tbl": "6f8d", "outgoing_ref_tbl": "6f8e", |
| 214 | "ic_table_ref": "02" } ), |
| 215 | ] |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 216 | def __init__(self): |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 217 | super().__init__(fid='6ff5', sfid=None, name='EF.GsmrPLMN', |
Harald Welte | 99e4cc0 | 2022-07-21 15:25:47 +0200 | [diff] [blame] | 218 | desc='GSM-R network selection', rec_len=(9, 9)) |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 219 | self._construct = Struct('plmn'/BcdAdapter(Bytes(3)), |
| 220 | 'class_of_network'/BitStruct('supported'/FlagsEnum(BitsInteger(5), vbs=1, vgcs=2, emlpp=4, fn=8, eirene=16), |
| 221 | 'preference'/BitsInteger(3)), |
| 222 | 'ic_incoming_ref_tbl'/HexAdapter(Bytes(2)), |
| 223 | 'outgoing_ref_tbl'/HexAdapter(Bytes(2)), |
| 224 | 'ic_table_ref'/HexAdapter(Bytes(1))) |
| 225 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 226 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 227 | class EF_IC(LinFixedEF): |
| 228 | """Section 7.8""" |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 229 | _test_de_encode = [ |
| 230 | ( "f06f8e40f10001", { "next_table_type": "decision", "id_of_next_table": "6f8e", |
| 231 | "ic_decision_value": "041f", "network_string_table_index": 1 } ), |
| 232 | ( "ffffffffffffff", { "next_table_type": "empty", "id_of_next_table": "ffff", |
| 233 | "ic_decision_value": "ffff", "network_string_table_index": 65535 } ), |
| 234 | ] |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 235 | def __init__(self): |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 236 | super().__init__(fid='6f8d', sfid=None, name='EF.IC', |
Harald Welte | 99e4cc0 | 2022-07-21 15:25:47 +0200 | [diff] [blame] | 237 | desc='International Code', rec_len=(7, 7)) |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 238 | self._construct = Struct('next_table_type'/NextTableType, |
| 239 | 'id_of_next_table'/HexAdapter(Bytes(2)), |
| 240 | 'ic_decision_value'/BcdAdapter(Bytes(2)), |
Harald Welte | 9181a69 | 2023-01-31 16:32:28 +0100 | [diff] [blame] | 241 | 'network_string_table_index'/Int16ub) |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 242 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 243 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 244 | class EF_NW(LinFixedEF): |
| 245 | """Section 7.9""" |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 246 | _test_de_encode = [ |
| 247 | ( "47534d2d52204348", "GSM-R CH" ), |
| 248 | ( "537769737347534d", "SwissGSM" ), |
| 249 | ( "47534d2d52204442", "GSM-R DB" ), |
| 250 | ( "47534d2d52524649", "GSM-RRFI" ), |
| 251 | ] |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 252 | def __init__(self): |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 253 | super().__init__(fid='6f80', sfid=None, name='EF.NW', |
Harald Welte | 99e4cc0 | 2022-07-21 15:25:47 +0200 | [diff] [blame] | 254 | desc='Network Name', rec_len=(8, 8)) |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 255 | self._construct = GsmString(8) |
| 256 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 257 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 258 | class EF_Switching(LinFixedEF): |
| 259 | """Section 8.4""" |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 260 | _test_de_encode = [ |
| 261 | ( "f26f87f0ff00", { "next_table_type": "num_dial_digits", "id_of_next_table": "6f87", |
| 262 | "decision_value": "0fff", "string_table_index": 0 } ), |
| 263 | ( "f06f8ff1ff01", { "next_table_type": "decision", "id_of_next_table": "6f8f", |
| 264 | "decision_value": "1fff", "string_table_index": 1 } ), |
| 265 | ( "f16f89f5ff05", { "next_table_type": "predefined", "id_of_next_table": "6f89", |
| 266 | "decision_value": "5fff", "string_table_index": 5 } ), |
| 267 | ] |
| 268 | def __init__(self, fid='1234', name='Switching', desc=None): |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 269 | super().__init__(fid=fid, sfid=None, |
Harald Welte | 99e4cc0 | 2022-07-21 15:25:47 +0200 | [diff] [blame] | 270 | name=name, desc=desc, rec_len=(6, 6)) |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 271 | self._construct = Struct('next_table_type'/NextTableType, |
| 272 | 'id_of_next_table'/HexAdapter(Bytes(2)), |
| 273 | 'decision_value'/BcdAdapter(Bytes(2)), |
| 274 | 'string_table_index'/Int8ub) |
| 275 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 276 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 277 | class EF_Predefined(LinFixedEF): |
| 278 | """Section 8.5""" |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 279 | _test_de_encode = [ |
| 280 | ( "f26f85", 1, { "next_table_type": "num_dial_digits", "id_of_next_table": "6f85" } ), |
| 281 | ( "f0ffc8", 2, { "predefined_value1": "0fff", "string_table_index1": 200 } ), |
| 282 | ] |
Harald Welte | 6bf2d5f | 2023-01-24 15:54:26 +0100 | [diff] [blame] | 283 | # header and other records have different structure. WTF !?! |
| 284 | construct_first = Struct('next_table_type'/NextTableType, |
| 285 | 'id_of_next_table'/HexAdapter(Bytes(2))) |
Harald Welte | 73a7fea | 2023-01-24 16:52:29 +0100 | [diff] [blame] | 286 | construct_others = Struct('predefined_value1'/BcdAdapter(Bytes(2)), |
Harald Welte | 6bf2d5f | 2023-01-24 15:54:26 +0100 | [diff] [blame] | 287 | 'string_table_index1'/Int8ub) |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 288 | |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 289 | def __init__(self, fid='1234', name='Predefined', desc=None): |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 290 | super().__init__(fid=fid, sfid=None, |
Harald Welte | 99e4cc0 | 2022-07-21 15:25:47 +0200 | [diff] [blame] | 291 | name=name, desc=desc, rec_len=(3, 3)) |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 292 | |
Harald Welte | 6bf2d5f | 2023-01-24 15:54:26 +0100 | [diff] [blame] | 293 | def _decode_record_bin(self, raw_bin_data : bytes, record_nr : int) -> dict: |
| 294 | if record_nr == 1: |
| 295 | return parse_construct(self.construct_first, raw_bin_data) |
| 296 | else: |
| 297 | return parse_construct(self.construct_others, raw_bin_data) |
| 298 | |
| 299 | def _encode_record_bin(self, abstract_data : dict, record_nr : int) -> bytearray: |
| 300 | r = None |
| 301 | if record_nr == 1: |
| 302 | r = self.construct_first.build(abstract_data) |
| 303 | else: |
| 304 | r = self.construct_others.build(abstract_data) |
| 305 | return filter_dict(r) |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 306 | |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 307 | class EF_DialledVals(TransparentEF): |
| 308 | """Section 8.6""" |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 309 | _test_de_encode = [ |
| 310 | ( "ffffff22", { "next_table_type": "empty", "id_of_next_table": "ffff", "dialed_digits": "22" } ), |
| 311 | ( "f16f8885", { "next_table_type": "predefined", "id_of_next_table": "6f88", "dialed_digits": "58" }), |
| 312 | ] |
| 313 | def __init__(self, fid='1234', name='DialledVals', desc=None): |
Harald Welte | 13edf30 | 2022-07-21 15:19:23 +0200 | [diff] [blame] | 314 | super().__init__(fid=fid, sfid=None, name=name, desc=desc, size=(4, 4)) |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 315 | self._construct = Struct('next_table_type'/NextTableType, |
| 316 | 'id_of_next_table'/HexAdapter(Bytes(2)), |
| 317 | 'dialed_digits'/BcdAdapter(Bytes(1))) |
| 318 | |
| 319 | |
| 320 | class DF_EIRENE(CardDF): |
| 321 | def __init__(self, fid='7fe0', name='DF.EIRENE', desc='GSM-R EIRENE'): |
| 322 | super().__init__(fid=fid, name=name, desc=desc) |
| 323 | files = [ |
| 324 | # Section 7.1.6 / Table 10 EIRENE GSM EFs |
| 325 | EF_FN(), |
| 326 | EF_CallconfC(), |
| 327 | EF_CallconfI(), |
| 328 | EF_Shunting(), |
| 329 | EF_GsmrPLMN(), |
| 330 | EF_IC(), |
| 331 | EF_NW(), |
| 332 | |
| 333 | # support of the numbering plan |
| 334 | EF_Switching(fid='6f8e', name='EF.CT', desc='Call Type'), |
| 335 | EF_Switching(fid='6f8f', name='EF.SC', desc='Short Code'), |
| 336 | EF_Predefined(fid='6f88', name='EF.FC', desc='Function Code'), |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 337 | EF_Predefined(fid='6f89', name='EF.Service', |
| 338 | desc='VGCS/VBS Service Code'), |
| 339 | EF_Predefined(fid='6f8a', name='EF.Call', |
| 340 | desc='First digit of the group ID'), |
| 341 | EF_Predefined(fid='6f8b', name='EF.FctTeam', |
| 342 | desc='Call Type 6 Team Type + Team member function'), |
| 343 | EF_Predefined(fid='6f92', name='EF.Controller', |
| 344 | desc='Call Type 7 Controller function code'), |
| 345 | EF_Predefined(fid='6f8c', name='EF.Gateway', |
| 346 | desc='Access to external networks'), |
| 347 | EF_DialledVals(fid='6f81', name='EF.5to8digits', |
| 348 | desc='Call Type 2 User Identity Number length'), |
| 349 | EF_DialledVals(fid='6f82', name='EF.2digits', |
| 350 | desc='2 digits input'), |
| 351 | EF_DialledVals(fid='6f83', name='EF.8digits', |
| 352 | desc='8 digits input'), |
| 353 | EF_DialledVals(fid='6f84', name='EF.9digits', |
| 354 | desc='9 digits input'), |
| 355 | EF_DialledVals(fid='6f85', name='EF.SSSSS', |
| 356 | desc='Group call area input'), |
| 357 | EF_DialledVals(fid='6f86', name='EF.LLLLL', |
| 358 | desc='Location number Call Type 6'), |
| 359 | EF_DialledVals(fid='6f91', name='EF.Location', |
| 360 | desc='Location number Call Type 7'), |
| 361 | EF_DialledVals(fid='6f87', name='EF.FreeNumber', |
| 362 | desc='Free Number Call Type 0 and 8'), |
| 363 | ] |
Harald Welte | 2a33ad2 | 2021-10-20 10:14:18 +0200 | [diff] [blame] | 364 | self.add_files(files) |