Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 1 | module MSC_Tests { |
| 2 | |
| 3 | import from General_Types all; |
| 4 | import from Osmocom_Types all; |
| 5 | |
| 6 | import from M3UA_Types all; |
| 7 | import from M3UA_Emulation all; |
| 8 | |
| 9 | import from MTP3asp_Types all; |
| 10 | import from MTP3asp_PortType all; |
| 11 | |
| 12 | import from SCCPasp_Types all; |
| 13 | import from SCCP_Types all; |
| 14 | import from SCCP_Emulation all; |
| 15 | |
| 16 | import from SCTPasp_Types all; |
| 17 | import from SCTPasp_PortType all; |
| 18 | |
| 19 | import from BSSAP_Types all; |
| 20 | |
| 21 | type component MTC_CT { |
| 22 | /* M3UA emulation component */ |
| 23 | var M3UA_CT vc_M3UA; |
| 24 | /* SCCP emulation component */ |
| 25 | var SCCP_CT vc_SCCP; |
| 26 | /* test port to SCCP emulation */ |
| 27 | port SCCPasp_PT SCCP; |
| 28 | |
| 29 | var octetstring g_sio; |
| 30 | var MSC_SCCP_MTP3_parameters g_sccp_pars; |
| 31 | var SCCP_PAR_Address g_sccp_addr_own, g_sccp_addr_peer; |
| 32 | |
| 33 | var boolean g_initialized := false; |
| 34 | } |
| 35 | |
| 36 | modulepar { |
| 37 | charstring mp_sccp_service_type := "mtp3_itu"; |
| 38 | |
| 39 | SCTP_Association_Address mp_sctp_addr := { 22905, "127.0.0.1", 2905, "127.0.0.1" }; |
| 40 | integer mp_own_pc := 196; |
| 41 | integer mp_own_ssn := 254; |
| 42 | |
| 43 | integer mp_peer_pc := 185; /* 0.23.1 */ |
| 44 | integer mp_peer_ssn := 254; |
| 45 | } |
| 46 | |
| 47 | |
| 48 | /* construct a SCCP_PAR_Address with just PC + SSN and no GT */ |
| 49 | template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn) := { |
| 50 | addressIndicator := { |
| 51 | pointCodeIndic := '1'B, |
| 52 | ssnIndicator := '1'B, |
| 53 | globalTitleIndic := '0000'B, |
| 54 | routingIndicator := '1'B |
| 55 | }, |
| 56 | signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, '83'O), |
| 57 | //signPointCode := SCCP_SPC_int2bit(pc, mp_sccp_service_type, g_sio), |
| 58 | subsystemNumber := ssn, |
| 59 | globalTitle := omit |
| 60 | } |
| 61 | |
| 62 | function init_pars() runs on MTC_CT { |
| 63 | g_sio := '83'O; |
| 64 | g_sccp_pars := { |
| 65 | sio := { |
| 66 | ni := substr(oct2bit(g_sio),0,2), |
| 67 | prio := substr(oct2bit(g_sio),2,2), |
| 68 | si := substr(oct2bit(g_sio),4,4) |
| 69 | }, |
| 70 | opc := mp_own_pc, |
| 71 | dpc := mp_peer_pc, |
| 72 | sls := 0, |
| 73 | sccp_serviceType := mp_sccp_service_type, |
| 74 | ssn := mp_own_ssn |
| 75 | }; |
| 76 | g_sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(mp_own_pc, mp_own_ssn)); |
| 77 | g_sccp_addr_peer := valueof(ts_SccpAddr_PC_SSN(mp_peer_pc, mp_peer_ssn)); |
| 78 | } |
| 79 | |
| 80 | function init() runs on MTC_CT { |
| 81 | |
| 82 | if (g_initialized == true) { |
| 83 | return; |
| 84 | } |
| 85 | g_initialized := true; |
| 86 | |
| 87 | init_pars(); |
| 88 | |
| 89 | /* Create components */ |
| 90 | vc_M3UA := M3UA_CT.create; |
| 91 | vc_SCCP := SCCP_CT.create; |
| 92 | |
| 93 | /* connect system SCTP port to M3UA lower side */ |
| 94 | map(vc_M3UA:SCTP_PORT, system:sctp); |
| 95 | |
| 96 | /* connect MTP3 service provider to SCCP MTP3 port */ |
| 97 | connect(vc_M3UA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT); |
| 98 | |
| 99 | /* connect test suite to SCCP service provider port */ |
| 100 | connect(self:SCCP, vc_SCCP:SCCP_SP_PORT); |
| 101 | |
| 102 | vc_M3UA.start(f_M3UA_Emulation(mp_sctp_addr)); |
| 103 | vc_SCCP.start(SCCPStart(g_sccp_pars)); |
| 104 | |
| 105 | } |
| 106 | |
| 107 | function terminate() runs on MTC_CT { |
| 108 | |
| 109 | disconnect(self:SCCP, vc_SCCP:SCCP_SP_PORT); |
| 110 | disconnect(vc_M3UA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT); |
| 111 | unmap(vc_M3UA:SCTP_PORT, system:sctp); |
| 112 | |
| 113 | all component.stop; |
| 114 | |
| 115 | self.stop; |
| 116 | } |
| 117 | |
| 118 | testcase TC_nothing() runs on MTC_CT { |
| 119 | init(); |
| 120 | |
| 121 | timer T := 30.0; |
| 122 | T.start; |
| 123 | T.timeout; |
| 124 | |
| 125 | } |
| 126 | |
| 127 | template PDU_BSSAP ts_BSSAP_BSSMAP := { |
| 128 | discriminator := '0'B, |
| 129 | spare := '0000000'B, |
| 130 | dlci := omit, |
| 131 | lengthIndicator := 0, /* overwritten by codec */ |
| 132 | pdu := ? |
| 133 | } |
| 134 | |
| 135 | template PDU_BSSAP tr_BSSAP_BSSMAP := { |
| 136 | discriminator := '0'B, |
| 137 | spare := '0000000'B, |
| 138 | dlci := omit, |
| 139 | lengthIndicator := ?, |
| 140 | pdu := { |
| 141 | bssmap := ? |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | |
| 146 | type integer BssmapCause; |
| 147 | |
| 148 | template (value) BSSMAP_IE_Cause ts_BSSMAP_IE_Cause(BssmapCause val) := { |
| 149 | elementIdentifier := '04'O, |
| 150 | lengthIndicator := 0, |
| 151 | causeValue := int2bit(val, 7), |
| 152 | extensionCauseValue := '0'B, |
| 153 | spare1 := omit |
| 154 | } |
| 155 | |
| 156 | template (value) PDU_BSSAP ts_BSSMAP_Reset(BssmapCause cause) modifies ts_BSSAP_BSSMAP := { |
| 157 | pdu := { |
| 158 | bssmap := { |
| 159 | reset := { |
| 160 | messageType := '30'O, |
| 161 | cause := ts_BSSMAP_IE_Cause(cause), |
| 162 | a_InterfaceSelectorForReset := omit |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | template (value) PDU_BSSAP ts_BSSMAP_ResetAck modifies ts_BSSAP_BSSMAP := { |
| 169 | pdu := { |
| 170 | bssmap := { |
| 171 | resetAck := { |
| 172 | messageType := '31'O, |
| 173 | a_InterfaceSelectorForReset := omit |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | template PDU_BSSAP tr_BSSMAP_ResetAck modifies tr_BSSAP_BSSMAP := { |
| 180 | pdu := { |
| 181 | bssmap := { |
| 182 | resetAck := { |
| 183 | messageType := '31'O, |
| 184 | a_InterfaceSelectorForReset := * |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | template BSSMAP_IE_CellIdentifier ts_BSSMAP_IE_CellID := { |
| 191 | elementIdentifier := '05'O, |
| 192 | lengthIndicator := 0, |
| 193 | cellIdentifierDiscriminator := '0000'B, |
| 194 | spare1_4 := '0000'B, |
| 195 | cellIdentification := ? |
| 196 | } |
| 197 | |
| 198 | type uint16_t BssmapLAC; |
| 199 | type uint16_t BssmapCI; |
| 200 | |
| 201 | /* |
| 202 | template BSSMAP_IE_CellIdentifier ts_CellId_CGI(mcc, mnc, lac, ci) |
| 203 | modifies ts_BSSMAP_IE_CellID := { |
| 204 | cellIdentification := { |
| 205 | cI_LAC_CGI := { |
| 206 | mnc_mcc := FIXME, |
| 207 | lac := int2oct(lac, 2), |
| 208 | ci := int2oct(ci, 2) |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | */ |
| 213 | |
| 214 | template BSSMAP_IE_CellIdentifier ts_CellID_LAC_CI(BssmapLAC lac, BssmapCI ci) |
| 215 | modifies ts_BSSMAP_IE_CellID := { |
| 216 | cellIdentification := { |
| 217 | cI_LAC_CI := { |
| 218 | lac := int2oct(lac, 2), |
| 219 | ci := int2oct(ci, 2) |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | template BSSMAP_IE_CellIdentifier ts_CellId_CI(BssmapCI ci) |
| 225 | modifies ts_BSSMAP_IE_CellID := { |
| 226 | cellIdentification := { |
| 227 | cI_CI := int2oct(ci, 2) |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | template BSSMAP_IE_CellIdentifier ts_CellId_none |
| 232 | modifies ts_BSSMAP_IE_CellID := { |
| 233 | cellIdentification := { |
| 234 | cI_noCell := ''O |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | |
| 239 | template BSSMAP_IE_Layer3Information ts_BSSMAP_IE_L3Info(octetstring l3info) := { |
| 240 | elementIdentifier := '17'O, |
| 241 | lengthIndicator := 0, |
| 242 | layer3info := l3info |
| 243 | } |
| 244 | |
| 245 | template PDU_BSSAP ts_BSSMAP_ComplL3(BSSMAP_IE_CellIdentifier cell_id, octetstring l3_info) |
| 246 | modifies ts_BSSAP_BSSMAP := { |
| 247 | pdu := { |
| 248 | bssmap := { |
| 249 | completeLayer3Information := { |
| 250 | messageType := '57'O, |
| 251 | cellIdentifier := cell_id, |
| 252 | layer3Information := ts_BSSMAP_IE_L3Info(l3_info), |
| 253 | chosenChannel := omit, |
| 254 | lSAIdentifier := omit, |
| 255 | aPDU := omit, |
| 256 | codecList := omit, |
| 257 | redirectAttemptFlag := omit, |
| 258 | sendSequenceNumber := omit, |
| 259 | iMSI := omit |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | template PDU_BSSAP ts_BSSMAP_HandoReq(BssmapCause cause, BSSMAP_IE_CellIdentifierList cid_list) |
| 266 | modifies ts_BSSAP_BSSMAP := { |
| 267 | pdu := { |
| 268 | bssmap := { |
| 269 | handoverRequired := { |
| 270 | messageType := '11'O, |
| 271 | cause := ts_BSSMAP_IE_Cause(cause), |
| 272 | responseRequest := omit, |
| 273 | cellIdentifierList := cid_list, |
| 274 | circuitPoolList := omit, |
| 275 | currentChannelType1 := omit, |
| 276 | speechVersion := omit, |
| 277 | queueingIndicator := omit, |
| 278 | oldToNewBSSInfo := omit, |
| 279 | sourceToTargetRNCTransparentInfo := omit, |
| 280 | sourceToTargetRNCTransparentInfoCDMA := omit, |
| 281 | gERANClassmark := omit, |
| 282 | talkerPriority := omit, |
| 283 | speechCodec := omit, |
| 284 | cSG_Identifier := omit |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | // enc_PDU_BSSAP |
| 291 | |
| 292 | function f_send_BSSAP_UNITDATA(template PDU_BSSAP bssap) runs on MTC_CT { |
| 293 | SCCP.send(t_ASP_N_UNITDATA_req(g_sccp_addr_peer, g_sccp_addr_own, '00000001'B, '00000001'B, |
| 294 | enc_PDU_BSSAP(valueof(bssap)), omit)) |
| 295 | } |
| 296 | |
| 297 | testcase TC_reset() runs on MTC_CT { |
| 298 | init(); |
| 299 | |
| 300 | timer T := 2.0; |
| 301 | T.start; |
| 302 | T.timeout; |
| 303 | |
| 304 | f_send_BSSAP_UNITDATA(ts_BSSMAP_Reset(0)); |
| 305 | T.start; |
| 306 | alt { |
| 307 | //[] SCCP.receive(tr_BSSMAP_ResetAck) { } |
| 308 | [] T.timeout { setverdict(fail); } |
| 309 | } |
| 310 | |
| 311 | terminate(); |
| 312 | } |
| 313 | |
| 314 | |
| 315 | control { |
| 316 | execute( TC_reset() ); |
| 317 | execute( TC_nothing() ); |
| 318 | } |
| 319 | |
| 320 | |
| 321 | } |