Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 1 | module Test { |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 2 | import from GSM_Types all; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 3 | import from GSM_SystemInformation all; |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 4 | import from GSMTAP_Types all; |
| 5 | import from GSMTAP_PortType all; |
| 6 | import from IPL4_GSMTAP_CtrlFunct all; |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 7 | import from TELNETasp_PortType all; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 8 | |
| 9 | const octetstring si1 := '5506198fb38000000000000000000000000000e504002b'O; |
| 10 | const octetstring si2 := '59061a00000000000000000000000000000000ffe50400'O; |
| 11 | const octetstring si3 := '49061b000062f22404d2490301275d40e50400392b2b2b'O; |
| 12 | const octetstring si4 := '31061c62f22404d25d40e504002b2b2b2b2b2b2b2b2b2b'O; |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 13 | const octetstring c_si2bis := '550602bfe809b3ff00000000000000000000007900002b'O; |
| 14 | const octetstring c_si2ter := '010603bf66b0aa0a00000002000000000000002b2b2b2b'O; |
| 15 | const octetstring c_si2quater := '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 16 | |
| 17 | type component dummy_CT { |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 18 | port GSMTAP_PT GSMTAP; |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 19 | port TELNETasp_PT BSCVTY; |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 20 | var boolean initialized := false; |
| 21 | var SystemInformationConfig si_cfg := { |
| 22 | bcch_extended := false, |
| 23 | si1_present := true, |
| 24 | si2bis_present := false, |
| 25 | si2ter_present := false, |
| 26 | si2quater_present := false, |
| 27 | si7_present := false, |
| 28 | si8_present := false, |
| 29 | si9_present := false, |
| 30 | si13_present := false, |
| 31 | si13alt_present := false, |
| 32 | si15_present := false, |
| 33 | si16_present := false, |
| 34 | si17_present := false, |
| 35 | si2n_present := false, |
| 36 | si21_present := false, |
| 37 | si22_present := false |
| 38 | }; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | testcase TC_si1() runs on dummy_CT { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 42 | log("SI: ", dec_SystemInformation(si1)); |
| 43 | log("SI: ", dec_SystemInformation(si2)); |
| 44 | log("SI: ", dec_SystemInformation(si3)); |
| 45 | log("SI: ", dec_SystemInformation(si4)); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 46 | setverdict(pass); |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 47 | } |
| 48 | |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 49 | template GsmtapHeader t_GsmtapHeader := { |
| 50 | version := GSMTAP_VERSION, |
| 51 | hdr_len := 4, |
| 52 | msg_type := ?, |
| 53 | timeslot := ?, |
| 54 | arfcn := ?, |
| 55 | signal_dbm := ?, |
| 56 | snr_db := ?, |
| 57 | frame_number := ?, |
| 58 | sub_type := ?, |
| 59 | antenna_nr := ?, |
| 60 | sub_slot := ?, |
| 61 | res := ? |
| 62 | } |
| 63 | |
| 64 | template GsmtapHeader t_GsmtapHeaderUm(template GsmtapChannel ch) modifies t_GsmtapHeader := { |
| 65 | msg_type := GSMTAP_TYPE_UM, |
| 66 | sub_type := ch |
| 67 | } |
| 68 | |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 69 | template GsmtapMessage t_bcch := { |
| 70 | header := t_GsmtapHeaderUm(GSMTAP_CHANNEL_BCCH), |
| 71 | payload := ? |
| 72 | } |
| 73 | |
| 74 | template GSMTAP_RecvFrom t_recvfrom(template GsmtapChannel ch) := { |
| 75 | connId := ?, |
| 76 | remName := ?, |
| 77 | remPort := ?, |
| 78 | locName := ?, |
| 79 | locPort := GSMTAP_PORT, |
| 80 | proto := {udp:={}}, |
| 81 | userData := ?, |
| 82 | msg := { header := t_GsmtapHeaderUm(ch), payload := ?} |
| 83 | } |
| 84 | |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 85 | /* tuple of gsmtap header + decoded SI */ |
| 86 | type record SystemInformationGsmtap { |
| 87 | GsmtapHeader gsmtap, |
| 88 | SystemInformation si |
| 89 | } |
| 90 | |
| 91 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
| 92 | type record of SystemInformationGsmtap SystemInformationVector; |
| 93 | |
| 94 | /* an array of SI-vectors indexed by TC value */ |
| 95 | type SystemInformationVector SystemInformationVectorPerTc[8]; |
| 96 | |
| 97 | type record of integer IntegerRecord; |
| 98 | |
| 99 | function f_array_contains(IntegerRecord arr, integer key) return boolean { |
| 100 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 101 | if (arr[i] == key) { |
| 102 | return true; |
| 103 | } |
| 104 | } |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | |
| 109 | /* compute TC as per 45.002 6.3.1.3 */ |
| 110 | function f_gsm_compute_tc(integer fn) return integer { |
| 111 | return (fn / 51) mod 8; |
| 112 | } |
| 113 | |
| 114 | /* determine if a given SI vector contains given SI type at least once */ |
| 115 | function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 116 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 117 | var integer fn_mod51 := arr[i].gsmtap.frame_number mod 51; |
| 118 | if (not bcch_ext and fn_mod51 == 2 or |
| 119 | bcch_ext and fn_mod51 == 6) { |
| 120 | if (arr[i].si.header.message_type == key) { |
| 121 | return true; |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | return false; |
| 126 | } |
| 127 | |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 128 | /* ensure a given TC slot of the SI vector contains given SI type at least once at TC */ |
| 129 | function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 130 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
| 131 | log("Fail: No ", key, " in TC=", tc, "!"); |
| 132 | setverdict(fail); |
| 133 | } |
| 134 | } |
| 135 | |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 136 | /* check if a given SI vector contains given SI type at least once on any TC */ |
| 137 | function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean { |
| 138 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 139 | if (f_si_vecslot_contains(arr[tc], key) or |
| 140 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 141 | return true; |
| 142 | } |
| 143 | } |
| 144 | return false; |
| 145 | } |
| 146 | |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 147 | /* determine if a given SI vector contains given SI type at least N of M times */ |
| 148 | function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean { |
| 149 | var integer count := 0; |
| 150 | if (sizeof(arr) < m) { |
| 151 | log("Error: Insufficient SI in array"); |
| 152 | setverdict(fail); |
| 153 | return false; |
| 154 | } |
| 155 | for (var integer i:= 0; i < m; i := i + 1) { |
| 156 | var integer fn_mod51 := arr[i].gsmtap.frame_number mod 51; |
| 157 | if (not bcch_ext and fn_mod51 == 2 or |
| 158 | bcch_ext and fn_mod51 == 6) { |
| 159 | if (arr[i].si.header.message_type == key) { |
| 160 | count := count + 1; |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | if (count >= n) { |
| 165 | return true; |
| 166 | } else { |
| 167 | return false; |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | /* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */ |
| 172 | function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) { |
| 173 | if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) { |
| 174 | log("Fail: Not ", n, "/", m, " of ", key, " in TC=", tc, "!"); |
| 175 | setverdict(fail); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | /* determine if a given SI vector contains given SI type at least once */ |
| 180 | function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 181 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 182 | var integer fn_mod51 := arr[i].gsmtap.frame_number mod 51; |
| 183 | if (not bcch_ext and fn_mod51 == 2 or |
| 184 | bcch_ext and fn_mod51 == 6) { |
| 185 | if (arr[i].si.header.message_type != key) { |
| 186 | return false; |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | return true; |
| 191 | } |
| 192 | |
| 193 | /* ensure a given TC slot of the SI vector contains only given SI type */ |
| 194 | function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 195 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
| 196 | log("Fail: Not all ", key, " in TC=", tc, "!"); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 197 | setverdict(fail); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | /* SI configuration of cell, against which we validate actual SI messages */ |
| 202 | type set SystemInformationConfig { |
| 203 | boolean bcch_extended, |
| 204 | boolean si1_present, |
| 205 | boolean si2bis_present, |
| 206 | boolean si2ter_present, |
| 207 | boolean si2quater_present, |
| 208 | boolean si7_present, |
| 209 | boolean si8_present, |
| 210 | boolean si9_present, |
| 211 | boolean si13_present, |
| 212 | boolean si13alt_present, |
| 213 | boolean si15_present, |
| 214 | boolean si16_present, |
| 215 | boolean si17_present, |
| 216 | boolean si2n_present, |
| 217 | boolean si21_present, |
| 218 | boolean si22_present |
| 219 | } |
| 220 | |
| 221 | /* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */ |
| 222 | function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) { |
| 223 | var integer i; |
| 224 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 225 | if (sizeof(si_per_tc[i]) == 0) { |
| 226 | setverdict(fail, "No SI messages for TC=0!"); |
| 227 | } |
| 228 | } |
| 229 | if (cfg.si1_present) { |
| 230 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 231 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 232 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 233 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 234 | /* make sure *ALL* contain SI1 */ |
| 235 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 236 | } |
| 237 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 238 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 239 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 240 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 241 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 242 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 243 | |
| 244 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 245 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 246 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 247 | * consecutive occurrences of TC = 4. */ |
| 248 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 249 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 250 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 251 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 252 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 253 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 254 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | if (cfg.si7_present or cfg.si8_present) { |
| 258 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 259 | * if System Information type 4 does not contain all information needed for cell |
| 260 | * selection and reselection. */ |
| 261 | if (not cfg.bcch_extended) { |
| 262 | setverdict(fail, "Error: SI7/SI8 require BCCH Extd."); |
| 263 | } |
| 264 | if (cfg.si7_present) { |
| 265 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 266 | } |
| 267 | if (cfg.si8_present) { |
| 268 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | if (cfg.si2quater_present) { |
| 273 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 274 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 275 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 276 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 277 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 278 | if (not (cfg.bcch_extended)) { |
| 279 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 280 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 281 | } else { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 282 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 283 | } |
| 284 | } else { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 285 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 286 | } |
| 287 | } |
| 288 | if (cfg.si9_present) { |
| 289 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 290 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 291 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 292 | } |
| 293 | if (cfg.si13_present) { |
| 294 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 295 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 296 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 297 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 298 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 299 | * within any of 4 consecutive occurrences of TC=4. */ |
| 300 | if (not cfg.bcch_extended) { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 301 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 302 | } else { |
| 303 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 304 | } |
| 305 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
| 306 | setverdict(fail, "Cannot have SI13alt and SI13"); |
| 307 | } |
| 308 | } |
| 309 | if (cfg.si16_present or cfg.si17_present) { |
| 310 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 311 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 312 | if (cfg.si22_present) { |
| 313 | setverdict(fail, "Error: Cannot have SI16/SI17 and SI22!"); |
| 314 | } |
| 315 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
| 316 | setverdict(fail, "Cannot have SI16/SI17 and SI22!"); |
| 317 | } |
| 318 | if (not cfg.bcch_extended) { |
| 319 | setverdict(fail, "Error: SI16/SI17 requires BCCH Extd!"); |
| 320 | } |
| 321 | if (cfg.si16_present) { |
| 322 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 323 | } |
| 324 | if (cfg.si17_present) { |
| 325 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 330 | * broadcast information. The frequency with which they are sent is determined by the |
| 331 | * system operator. System Information type 9 identifies the scheduling of System |
| 332 | * Information type 18 and 20 messages. */ |
| 333 | |
| 334 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 335 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 336 | * Information Type 9. */ |
| 337 | |
| 338 | if (cfg.si15_present) { |
| 339 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 340 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 341 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 342 | * 4 consecutive occurrences of TC = 1. */ |
| 343 | if (not cfg.bcch_extended) { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 344 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 345 | } else { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 346 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 347 | } |
| 348 | } |
| 349 | if (cfg.si13alt_present) { |
| 350 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 351 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 352 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 353 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 354 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 355 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 356 | * of TC = 4. */ |
| 357 | if (cfg.si13_present) { |
| 358 | setverdict(fail, "Error: Cannot have SI13alt and SI13"); |
| 359 | } |
| 360 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
| 361 | setverdict(fail, "Cannot have SI13alt and SI13"); |
| 362 | } |
| 363 | if (not cfg.bcch_extended) { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 364 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 365 | } else { |
| 366 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 367 | } |
| 368 | } |
| 369 | if (cfg.si2n_present) { |
| 370 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 371 | * as determined by the system operator. In the case that the message is sent on the |
| 372 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 373 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 374 | * consecutive occurrences of TC = 4. */ |
| 375 | if (not cfg.bcch_extended) { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 376 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 377 | } else { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 378 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 379 | } |
| 380 | } |
| 381 | if (cfg.si21_present) { |
| 382 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 383 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 384 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 385 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 386 | * cell then this message shall only be sent on BCCH Ext. */ |
| 387 | if (not cfg.bcch_extended) { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 388 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 389 | } else { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 390 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 391 | if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) { |
| 392 | setverdict(fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!"); |
| 393 | } |
| 394 | } |
| 395 | } |
| 396 | if (cfg.si22_present) { |
| 397 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 398 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 399 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 400 | * =2 and TC=6. */ |
| 401 | if (cfg.si16_present or cfg.si17_present) { |
| 402 | setverdict(fail, "Error: Cannot have SI16/SI17 and SI22!"); |
| 403 | } |
| 404 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 405 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
| 406 | setverdict(fail, "Cannot have SI16/SI17 and SI22!"); |
| 407 | } |
| 408 | if (not cfg.bcch_extended) { |
| 409 | setverdict(fail, "Error: SI22 requires BCCH Extd!"); |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 410 | } else { |
| 411 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 412 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 413 | } |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 418 | function f_gsmtap_sample_si(GSMTAP_PT pt, float duration := 8.0) return SystemInformationVectorPerTc { |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 419 | timer T := duration; |
| 420 | var SystemInformationVectorPerTc si_per_tc; |
| 421 | var GSMTAP_RecvFrom rf; |
| 422 | |
| 423 | /* initialize all per-TC vectors empty */ |
| 424 | for (var integer i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 425 | si_per_tc[i] := {}; |
| 426 | } |
| 427 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 428 | /* flush all previous/buffered elements */ |
| 429 | pt.clear |
| 430 | |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 431 | T.start; |
| 432 | alt { |
| 433 | [] pt.receive(t_recvfrom(GSMTAP_CHANNEL_BCCH)) -> value rf { |
| 434 | var SystemInformation si := dec_SystemInformation(rf.msg.payload); |
| 435 | var SystemInformationGsmtap sig := { rf.msg.header, si }; |
| 436 | var integer tc := f_gsm_compute_tc(rf.msg.header.frame_number); |
| 437 | log("SI received at TC=", tc, ": ", si); |
| 438 | /* append to the per-TC bucket */ |
| 439 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 440 | repeat; |
| 441 | } |
| 442 | [] pt.receive { repeat; }; |
| 443 | [] T.timeout { }; |
| 444 | } |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 445 | for (var integer i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 446 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 447 | } |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 448 | return si_per_tc; |
| 449 | } |
| 450 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 451 | function f_init() runs on dummy_CT { |
| 452 | if (initialized) { |
| 453 | return; |
| 454 | } |
| 455 | /* GSMTAP initialization */ |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 456 | map(self:GSMTAP, system:GSMTAP); |
| 457 | IPL4_GSMTAP_CtrlFunct.f_IPL4_listen(GSMTAP, "0.0.0.0", GSMTAP_PORT, {udp := {}}); |
| 458 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 459 | /* VTY initialization */ |
| 460 | map(self:BSCVTY, system:BSCVTY); |
| 461 | f_vty_set_prompts(BSCVTY) |
Harald Welte | fd512cb | 2017-07-16 01:34:15 +0200 | [diff] [blame] | 462 | f_vty_transceive(BSCVTY, "enable"); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 463 | |
| 464 | initialized := true; |
| 465 | } |
| 466 | |
| 467 | testcase TC_si_default() runs on dummy_CT { |
| 468 | var SystemInformationVectorPerTc si_per_tc; |
| 469 | |
| 470 | f_init(); |
| 471 | |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 472 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 473 | f_validate_si_scheduling(si_cfg, si_per_tc); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 474 | |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 475 | setverdict(pass); |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 476 | } |
| 477 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 478 | testcase TC_si_sched_2bis() runs on dummy_CT { |
| 479 | var SystemInformationVectorPerTc si_per_tc; |
| 480 | f_init(); |
| 481 | |
| 482 | /* Enable SI2bis + validate scheduling */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 483 | si_cfg.si2bis_present := true; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 484 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 485 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
| 486 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 487 | |
| 488 | /* cleanup */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 489 | si_cfg.si2bis_present := false; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 490 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 491 | |
| 492 | setverdict(pass); |
| 493 | } |
| 494 | |
| 495 | testcase TC_si_sched_2ter() runs on dummy_CT { |
| 496 | var SystemInformationVectorPerTc si_per_tc; |
| 497 | f_init(); |
| 498 | |
| 499 | /* Enable SI2ter + validate scheduling */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 500 | si_cfg.si2ter_present := true; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 501 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 502 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
| 503 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 504 | |
| 505 | /* cleanup */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 506 | si_cfg.si2ter_present := false; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 507 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 508 | |
| 509 | setverdict(pass); |
| 510 | } |
| 511 | |
| 512 | testcase TC_si_sched_2ter_2bis() runs on dummy_CT { |
| 513 | var SystemInformationVectorPerTc si_per_tc; |
| 514 | f_init(); |
| 515 | |
| 516 | /* Enable SI2bis + SI2ter + validate scheduling */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 517 | si_cfg.si2bis_present := true; |
| 518 | si_cfg.si2ter_present := true; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 519 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 520 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
| 521 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 522 | |
| 523 | /* cleanup */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 524 | si_cfg.si2bis_present := false; |
| 525 | si_cfg.si2ter_present := false; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 526 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 527 | |
| 528 | setverdict(pass); |
| 529 | } |
| 530 | |
| 531 | testcase TC_si_sched_2quater() runs on dummy_CT { |
| 532 | var SystemInformationVectorPerTc si_per_tc; |
| 533 | f_init(); |
| 534 | |
| 535 | /* Enable SI2quater + validate scheduling */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 536 | si_cfg.si2quater_present := true; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 537 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 538 | |
| 539 | /* cleanup */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 540 | si_cfg.si2quater_present := false; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 541 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 542 | |
| 543 | setverdict(pass); |
| 544 | } |
| 545 | |
| 546 | testcase TC_si_sched_13() runs on dummy_CT { |
| 547 | var SystemInformationVectorPerTc si_per_tc; |
| 548 | f_init(); |
| 549 | |
| 550 | /* Enable SI2ter + validate scheduling */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 551 | si_cfg.si13_present := true; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 552 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 553 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
| 554 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 555 | |
| 556 | /* cleanup */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 557 | si_cfg.si13_present := false; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 558 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 559 | |
| 560 | setverdict(pass); |
| 561 | } |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 562 | |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 563 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on dummy_CT { |
| 564 | var SystemInformationVectorPerTc si_per_tc; |
| 565 | f_init(); |
| 566 | |
| 567 | si_cfg.si2bis_present := true; |
| 568 | si_cfg.si2ter_present := true; |
| 569 | si_cfg.si2quater_present := true; |
| 570 | si_cfg.si13_present := true; |
| 571 | f_si_cfg_to_vty(); |
| 572 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
| 573 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 574 | |
| 575 | /* cleanup */ |
| 576 | si_cfg.si2bis_present := false; |
| 577 | si_cfg.si2ter_present := false; |
| 578 | si_cfg.si2quater_present := false; |
| 579 | si_cfg.si13_present := false; |
| 580 | f_si_cfg_to_vty(); |
| 581 | |
| 582 | setverdict(pass); |
| 583 | } |
| 584 | |
| 585 | function f_si_cfg_to_vty() runs on dummy_CT { |
| 586 | if (si_cfg.si2bis_present) { |
| 587 | f_vty_si_static(BSCVTY, 0, "2bis", c_si2bis); |
| 588 | } else { |
| 589 | f_vty_si_computed(BSCVTY, 0, "2bis"); |
| 590 | } |
| 591 | if (si_cfg.si2ter_present) { |
| 592 | f_vty_si_static(BSCVTY, 0, "2ter", c_si2ter); |
| 593 | } else { |
| 594 | f_vty_si_computed(BSCVTY, 0, "2ter"); |
| 595 | } |
| 596 | if (si_cfg.si13_present) { |
| 597 | f_vty_gprs_mode(BSCVTY, 0, "gprs"); |
| 598 | } else { |
| 599 | f_vty_gprs_mode(BSCVTY, 0, "none"); |
| 600 | } |
| 601 | if (si_cfg.si2quater_present) { |
| 602 | f_vty_si2q_add_uarfcn(BSCVTY, 0, 23, 42); |
| 603 | } else { |
| 604 | f_vty_si2q_del_uarfcn(BSCVTY, 0, 23, 42); |
| 605 | } |
| 606 | /* for debugging */ |
| 607 | f_vty_transceive(BSCVTY, "write terminal"); |
| 608 | /* actually commit the changes from BSC -> BTS */ |
| 609 | f_vty_si_resend(BSCVTY, 0); |
| 610 | } |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 611 | |
| 612 | /* permitted prompts on VTY */ |
| 613 | const charstring NORMAL_PROMPT := "OpenBSC> "; |
| 614 | const charstring ENABLE_PROMPT := "OpenBSC# "; |
| 615 | const charstring CONFIG_PROMPT := "OpenBSC(*)\#"; |
Harald Welte | d1f74c6 | 2017-07-16 03:04:37 +0200 | [diff] [blame^] | 616 | template charstring t_vty_unknown := pattern "*% Unknown command."; |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 617 | |
| 618 | const ASP_TelnetDynamicConfig vty_prompt[3] := { |
| 619 | { |
| 620 | prompt := { |
| 621 | id := 1, |
| 622 | prompt := NORMAL_PROMPT, |
| 623 | has_wildcards := false |
| 624 | } |
| 625 | }, { |
| 626 | prompt := { |
| 627 | id := 2, |
| 628 | prompt := ENABLE_PROMPT, |
| 629 | has_wildcards := false |
| 630 | } |
| 631 | }, { |
| 632 | prompt := { |
| 633 | id := 3, |
| 634 | prompt := CONFIG_PROMPT, |
| 635 | has_wildcards := true |
| 636 | } |
| 637 | } |
| 638 | }; |
| 639 | |
| 640 | /* configure prompts in TELNETasp module */ |
| 641 | function f_vty_set_prompts(TELNETasp_PT pt) { |
| 642 | /* set some configuration that isn't possible to express |
| 643 | * in the config file due to syntactic restrictions (Who invents config |
| 644 | * files that don't permit regular expressions? */ |
| 645 | for (var integer i := 0; i < sizeof(vty_prompt); i:= i + 1) { |
| 646 | pt.send(vty_prompt[i]) |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | /* wait for any of the permitted prompts; buffer + return all intermediate output */ |
| 651 | function f_vty_wait_for_prompt(TELNETasp_PT pt) return charstring { |
| 652 | template charstring config_pattern := pattern CONFIG_PROMPT; |
| 653 | var charstring rx, buf := ""; |
| 654 | timer T := 2.0; |
| 655 | |
| 656 | T.start; |
| 657 | alt { |
| 658 | [] pt.receive(NORMAL_PROMPT) { }; |
| 659 | [] pt.receive(ENABLE_PROMPT) { }; |
| 660 | [] pt.receive(config_pattern) { }; |
Harald Welte | fd512cb | 2017-07-16 01:34:15 +0200 | [diff] [blame] | 661 | [] pt.receive(t_vty_unknown) { setverdict(fail, "VTY: Unknown Command") }; |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 662 | [] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat }; |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 663 | [] T.timeout { setverdict(fail, "VTY Timeout for prompt"); return ""}; |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 664 | } |
| 665 | T.stop; |
| 666 | return buf; |
| 667 | } |
| 668 | |
| 669 | /* send a VTY command and obtain response until prompt is received */ |
| 670 | function f_vty_transceive(TELNETasp_PT pt, charstring tx) return charstring { |
| 671 | pt.send(tx); |
| 672 | return f_vty_wait_for_prompt(pt); |
| 673 | } |
| 674 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 675 | type integer BtsNr (0..255); |
| 676 | type integer BtsTrxNr (0..255); |
| 677 | type integer BtsTimeslotNr (0..7); |
| 678 | |
| 679 | type charstring BtsGprsMode ("none", "gprs", "egrps"); |
| 680 | |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 681 | /* enter the'confiugration' mode of the VTY */ |
| 682 | function f_vty_enter_config(TELNETasp_PT pt) { |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 683 | f_vty_transceive(pt, "configure terminal") |
| 684 | } |
| 685 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 686 | function f_vty_enter_cfg_network(TELNETasp_PT pt) { |
| 687 | f_vty_enter_config(pt); |
| 688 | f_vty_transceive(pt, "network") |
| 689 | } |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 690 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 691 | function f_vty_enter_cfg_bts(TELNETasp_PT pt, BtsNr bts := 0) { |
| 692 | f_vty_enter_cfg_network(pt); |
| 693 | f_vty_transceive(pt, "bts " & int2str(bts)); |
| 694 | } |
| 695 | |
| 696 | function f_vty_enter_cfg_trx(TELNETasp_PT pt, BtsNr bts := 0, BtsTrxNr trx := 0) { |
| 697 | f_vty_enter_cfg_bts(pt, bts); |
| 698 | f_vty_transceive(pt, "trx " & int2str(trx)); |
| 699 | } |
| 700 | |
| 701 | function f_vty_enter_cfg_ts(TELNETasp_PT pt, BtsNr bts := 0, BtsTrxNr trx := 0, BtsTimeslotNr ts) { |
| 702 | f_vty_enter_cfg_trx(pt, bts, trx); |
| 703 | f_vty_transceive(pt, "timeslot " & int2str(ts)); |
| 704 | } |
| 705 | |
| 706 | function f_vty_si_static(TELNETasp_PT pt, BtsNr bts, charstring si, octetstring bytes) { |
| 707 | f_vty_enter_cfg_bts(pt, bts); |
| 708 | f_vty_transceive(pt, "system-information " & si & " mode static"); |
| 709 | f_vty_transceive(pt, "system-information " & si & " static " & hex2str(oct2hex(bytes))); |
| 710 | f_vty_transceive(pt, "end"); |
| 711 | } |
| 712 | |
| 713 | function f_vty_si_computed(TELNETasp_PT pt, BtsNr bts, charstring si) { |
| 714 | f_vty_enter_cfg_bts(pt, bts); |
| 715 | f_vty_transceive(pt, "system-information " & si & " mode computed"); |
| 716 | f_vty_transceive(pt, "end"); |
| 717 | } |
| 718 | |
| 719 | function f_vty_si_resend(TELNETasp_PT pt, BtsNr bts := 0) { |
| 720 | f_vty_transceive(pt, "bts " & int2str(bts) & " resend-system-information"); |
Harald Welte | c17c88e | 2017-07-16 00:39:59 +0200 | [diff] [blame] | 721 | /* wait for 1s until changes propagate */ |
| 722 | timer T := 1.0; |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 723 | T.start; |
| 724 | T.timeout; |
| 725 | } |
| 726 | |
| 727 | function f_vty_gprs_mode(TELNETasp_PT pt, integer bts, BtsGprsMode mode) { |
| 728 | f_vty_enter_cfg_bts(pt, bts); |
| 729 | f_vty_transceive(pt, "gprs mode " & mode); |
| 730 | f_vty_transceive(pt, "end"); |
| 731 | } |
| 732 | |
| 733 | function f_vty_si2q_add_uarfcn(TELNETasp_PT pt, BtsNr bts, UmtsArfcn uarfcn, UmtsScramblingCode sc, integer diversity := 0) { |
| 734 | f_vty_enter_cfg_bts(pt, bts); |
| 735 | f_vty_transceive(pt, "si2quater neighbor-list add uarfcn " & int2str(uarfcn) & " " & int2str(sc) & " " & int2str(diversity)); |
| 736 | f_vty_transceive(pt, "end"); |
| 737 | } |
| 738 | |
| 739 | function f_vty_si2q_del_uarfcn(TELNETasp_PT pt, BtsNr bts, UmtsArfcn uarfcn, UmtsScramblingCode sc) { |
| 740 | f_vty_enter_cfg_bts(pt, bts); |
| 741 | f_vty_transceive(pt, "si2quater neighbor-list del uarfcn " & int2str(uarfcn) & " " & int2str(sc)); |
| 742 | f_vty_transceive(pt, "end"); |
| 743 | } |
| 744 | |
| 745 | testcase TC_telnet() runs on dummy_CT { |
| 746 | f_init(); |
Harald Welte | fd512cb | 2017-07-16 01:34:15 +0200 | [diff] [blame] | 747 | f_vty_enter_config(BSCVTY); |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 748 | f_vty_transceive(BSCVTY, "show network") |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 749 | f_vty_transceive(BSCVTY, "network") |
| 750 | f_vty_transceive(BSCVTY, "bts 0") |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 751 | f_vty_transceive(BSCVTY, "end") |
| 752 | setverdict(pass); |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 753 | } |
| 754 | |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 755 | control { |
| 756 | execute(TC_si1()); |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 757 | execute(TC_telnet()); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 758 | execute(TC_si_default()); |
| 759 | execute(TC_si_sched_2bis()); |
| 760 | execute(TC_si_sched_2ter()); |
| 761 | execute(TC_si_sched_2ter_2bis()); |
| 762 | execute(TC_si_sched_2quater()); |
| 763 | execute(TC_si_sched_13()); |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 764 | execute(TC_si_sched_13_2bis_2ter_2quater()); |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 765 | } |
| 766 | } |