Harald Welte | 379d45a | 2017-08-03 09:55:15 +0200 | [diff] [blame] | 1 | module GGSN_Tests { |
| 2 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 3 | import from General_Types all; |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 4 | import from Osmocom_Types all; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 5 | import from IPL4asp_PortType all; |
| 6 | import from IPL4asp_Types all; |
| 7 | import from GTP_CodecPort all; |
| 8 | import from GTP_CodecPort_CtrlFunct all; |
| 9 | import from GTPC_Types all; |
| 10 | import from GTPU_Types all; |
Harald Welte | 71a3602 | 2017-12-04 18:55:58 +0100 | [diff] [blame] | 11 | import from IPCP_Types all; |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 12 | import from IP_Types all; |
| 13 | import from ICMPv6_Types all; |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 14 | import from Native_Functions all; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 15 | |
| 16 | const integer GTP0_PORT := 3386; |
| 17 | const integer GTP1C_PORT := 2123; |
| 18 | const integer GTP1U_PORT := 2152; |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 19 | |
| 20 | modulepar { |
| 21 | charstring m_bind_ip_gtpc := "127.23.42.1"; |
| 22 | charstring m_bind_ip_gtpu := "127.23.42.1"; |
| 23 | |
| 24 | charstring m_ggsn_ip_gtpc := "127.0.0.6"; |
| 25 | charstring m_ggsn_ip_gtpu := "127.0.0.6"; |
| 26 | } |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 27 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 28 | type set PdpContext { |
| 29 | hexstring imsi, |
| 30 | octetstring msisdn optional, |
| 31 | octetstring apn, |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 32 | ProtConfigOptions pco_req optional, |
| 33 | ProtConfigOptions pco_neg optional, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 34 | EndUserAddress eua, |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 35 | OCT16 ip6_prefix optional, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 36 | BIT4 nsapi, |
| 37 | /* TEI (Data) local side */ |
| 38 | OCT4 teid, |
| 39 | /* TEI (Control) local side */ |
| 40 | OCT4 teic, |
| 41 | /* TEI (Data) remote side */ |
| 42 | OCT4 teid_remote, |
| 43 | /* TEI (Control) remote side */ |
Harald Welte | 5438b9d | 2017-08-13 13:27:48 +0200 | [diff] [blame] | 44 | OCT4 teic_remote |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 45 | } |
| 46 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 47 | type component GT_CT { |
| 48 | port GTPC_PT GTPC; |
| 49 | port GTPU_PT GTPU; |
| 50 | |
Harald Welte | 0be142b | 2017-08-13 13:28:10 +0200 | [diff] [blame] | 51 | var boolean g_initialized := false; |
| 52 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 53 | var OCT1 g_restart_ctr := '01'O; |
| 54 | /* FIXME: unify with g_bind_ip + parse from config file */ |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 55 | var OCT4 g_sgsn_ip_c; |
| 56 | var OCT4 g_sgsn_ip_u; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 57 | /* FIXME: parse remName from config file */ |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 58 | var GtpPeer g_peer_c := { connId := 0, remName := m_ggsn_ip_gtpc, remPort := GTP1C_PORT }; |
| 59 | var GtpPeer g_peer_u := { connId := 0, remName := m_ggsn_ip_gtpu, remPort := GTP1U_PORT }; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 60 | timer T_default := 3.0; |
Harald Welte | 5438b9d | 2017-08-13 13:27:48 +0200 | [diff] [blame] | 61 | |
| 62 | /* next to-be-sent GTP-C sequence number */ |
| 63 | var uint16_t g_c_seq_nr; |
| 64 | /* next to-be-sent GTP-U sequence number */ |
| 65 | var uint16_t g_d_seq_nr; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | function f_init() runs on GT_CT { |
Harald Welte | 0be142b | 2017-08-13 13:28:10 +0200 | [diff] [blame] | 69 | if (g_initialized == true) { |
| 70 | return; |
| 71 | } |
| 72 | g_initialized := true; |
| 73 | |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 74 | g_sgsn_ip_c := f_inet_addr(m_bind_ip_gtpc); |
| 75 | g_sgsn_ip_u := f_inet_addr(m_bind_ip_gtpu); |
| 76 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 77 | var Result res; |
| 78 | map(self:GTPC, system:GTPC); |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 79 | res := GTP_CodecPort_CtrlFunct.f_IPL4_listen(GTPC, m_bind_ip_gtpc, GTP1C_PORT, {udp:={}}); |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 80 | log("GTP1C ConnectionID: ", res.connId); |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 81 | g_peer_c.connId := res.connId; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 82 | |
| 83 | map(self:GTPU, system:GTPU); |
Harald Welte | ddeecbb | 2017-08-18 22:53:30 +0200 | [diff] [blame] | 84 | res := GTP_CodecPort_CtrlFunct.f_GTPU_listen(GTPU, m_bind_ip_gtpu, GTP1U_PORT, {udp:={}}); |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 85 | g_peer_u.connId:= res.connId; |
Harald Welte | 5438b9d | 2017-08-13 13:27:48 +0200 | [diff] [blame] | 86 | |
| 87 | g_restart_ctr := f_rnd_octstring(1); |
Harald Welte | 11dbc7b | 2017-08-13 18:57:56 +0200 | [diff] [blame] | 88 | g_c_seq_nr := f_rnd_int(65535); |
| 89 | g_d_seq_nr := f_rnd_int(65535); |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | /* generalized GTP-C receive template */ |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 93 | template PDU_GTPC tr_GTP1C_PDU(template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdu := ?) := { |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 94 | /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an |
| 95 | * error if this flag is set to '1'. */ |
| 96 | pn_bit := '0'B, |
| 97 | /* Sequence number flag (S) shall be set to '1'. */ |
| 98 | s_bit := '1'B, |
| 99 | e_bit := ?, |
| 100 | spare := ?, |
| 101 | /* Protocol Type flag (PT) shall be set to '1'.*/ |
| 102 | pt := '1'B, |
| 103 | /* Version shall be set to decimal 1 ('001'). */ |
| 104 | version := '001'B, |
| 105 | messageType := msg_type, |
| 106 | lengthf := ?, |
| 107 | teid := teid, |
| 108 | opt_part := *, |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 109 | gtpc_pdu := pdu |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | /* generalized GTP-C send template */ |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 113 | template PDU_GTPC ts_GTP1C_PDU(OCT1 msg_type, OCT4 teid, GTPC_PDUs pdu, uint16_t seq_nr) := { |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 114 | /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an |
| 115 | * error if this flag is set to '1'. */ |
| 116 | pn_bit := '0'B, |
| 117 | /* Sequence number flag (S) shall be set to '1'. */ |
| 118 | s_bit := '1'B, |
| 119 | e_bit := '0'B, |
| 120 | spare := '0'B, |
| 121 | /* Protocol Type flag (PT) shall be set to '1'.*/ |
| 122 | pt := '1'B, |
| 123 | /* Version shall be set to decimal 1 ('001'). */ |
| 124 | version := '001'B, |
| 125 | messageType := msg_type, |
| 126 | lengthf := 0, /* we assume encoder overwrites this */ |
| 127 | teid := teid, |
| 128 | opt_part := { |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 129 | sequenceNumber := int2oct(seq_nr, 2), |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 130 | npduNumber := '00'O, |
| 131 | nextExtHeader := '00'O, |
| 132 | gTPC_extensionHeader_List := omit |
| 133 | }, |
| 134 | gtpc_pdu := pdu |
| 135 | } |
| 136 | |
| 137 | /* recovery IE */ |
| 138 | template Recovery_gtpc ts_Recovery(OCT1 restart_counter) := { |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 139 | type_gtpc := '0E'O, |
| 140 | restartCounter := restart_counter |
| 141 | } |
| 142 | |
| 143 | template Recovery_gtpc tr_Recovery(template OCT1 restart_counter) := { |
| 144 | type_gtpc := '0E'O, |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 145 | restartCounter := restart_counter |
| 146 | } |
| 147 | |
| 148 | /* template matching reception of GTP-C echo-request */ |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 149 | template Gtp1cUnitdata tr_GTPC_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdus := ?) := { |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 150 | peer := peer, |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 151 | gtpc := tr_GTP1C_PDU(msg_type, teid, pdus) |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | /* template matching reception of GTP-C echo-request */ |
| 155 | template Gtp1cUnitdata tr_GTPC_PING(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoRequest, '00000000'O); |
| 156 | |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 157 | template GTPC_PDUs tr_EchoRespPDU(template OCT1 restart_counter) := { |
| 158 | echoResponse := { |
| 159 | recovery := tr_Recovery(restart_counter), |
| 160 | private_extension_gtpc := * |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | /* template matching reception of GTP-C echo-response */ |
| 165 | template Gtp1cUnitdata tr_GTPC_PONG(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoResponse, '00000000'O, tr_EchoRespPDU(?)); |
| 166 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 167 | template GTPC_PDUs ts_EchoRespPDU(OCT1 restart_counter) := { |
| 168 | echoResponse := { |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 169 | recovery := ts_Recovery(restart_counter), |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 170 | private_extension_gtpc := omit |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | /* master template for senidng a GTP-C echo response */ |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 175 | template Gtp1cUnitdata ts_GTPC_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := { |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 176 | peer := peer, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 177 | gtpc := ts_GTP1C_PDU(echoResponse, '00000000'O, valueof(ts_EchoRespPDU(rest_ctr)), seq) |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 178 | } |
| 179 | |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 180 | template GTPC_PDUs ts_EchoReqPDU := { |
| 181 | echoRequest := { |
| 182 | private_extension_gtpc := omit |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /* master template for sending a GTP-C echo request */ |
| 187 | template Gtp1cUnitdata ts_GTPC_PING(GtpPeer peer, uint16_t seq) := { |
| 188 | peer := peer, |
| 189 | gtpc := ts_GTP1C_PDU(echoRequest, '00000000'O, valueof(ts_EchoReqPDU), seq) |
| 190 | } |
| 191 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 192 | template EndUserAddress t_EuaIPv4(template OCT4 ip_addr) := { |
| 193 | type_gtpc := '80'O, |
| 194 | endUserAddress := { |
| 195 | endUserAddressIPv4 := { |
| 196 | lengthf := 2, |
| 197 | pdp_typeorg := '0001'B, |
| 198 | spare := '1111'B, |
| 199 | pdp_typenum := '21'O, |
| 200 | ipv4_address := ip_addr |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | template EndUserAddress t_EuaIPv4Dyn := t_EuaIPv4(omit); |
Harald Welte | 99ef9a4 | 2017-08-14 21:42:03 +0200 | [diff] [blame] | 205 | template EndUserAddress tr_EuaIPv4(template OCT4 ip_addr) modifies t_EuaIPv4 := { |
| 206 | endUserAddress := { |
| 207 | endUserAddressIPv4 := { |
Harald Welte | bb5a19e | 2017-09-21 22:50:41 +0800 | [diff] [blame] | 208 | lengthf := 2+lengthof(ip_addr) |
Harald Welte | 99ef9a4 | 2017-08-14 21:42:03 +0200 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 213 | template EndUserAddress t_EuaIPv6(template OCT16 ip_addr) := { |
| 214 | type_gtpc := '80'O, |
| 215 | endUserAddress := { |
| 216 | endUserAddressIPv6 := { |
| 217 | lengthf := 2, |
| 218 | pdp_typeorg := '0001'B, |
| 219 | spare := '1111'B, |
| 220 | pdp_typenum := '57'O, |
| 221 | ipv6_address := ip_addr |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | template EndUserAddress t_EuaIPv6Dyn := t_EuaIPv6(omit); |
Harald Welte | 99ef9a4 | 2017-08-14 21:42:03 +0200 | [diff] [blame] | 226 | template EndUserAddress tr_EuaIPv6(template OCT16 ip_addr) modifies t_EuaIPv6 := { |
| 227 | endUserAddress := { |
| 228 | endUserAddressIPv6 := { |
| 229 | lengthf := 2+lengthof(ip_addr) |
| 230 | } |
| 231 | } |
| 232 | } |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 233 | |
| 234 | template AccessPointName ts_APN(octetstring apn) := { |
| 235 | type_gtpc := '83'O, |
| 236 | lengthf := lengthof(apn), |
| 237 | apn_value := apn |
| 238 | } |
| 239 | |
| 240 | template GSN_Address_GTPC ts_GsnAddr(octetstring ip_addr) := { |
| 241 | type_gtpc := '85'O, |
| 242 | lengthf := lengthof(ip_addr), |
| 243 | addressf := ip_addr |
| 244 | } |
| 245 | |
| 246 | template MSISDN ts_Msisdn(octetstring msisdn) := { |
| 247 | type_gtpc := '86'O, |
| 248 | lengthf := lengthof(msisdn), |
| 249 | msisdn := msisdn |
| 250 | } |
| 251 | |
| 252 | template QualityOfServiceProfile ts_QosDefault := { |
| 253 | type_gtpc := '87'O, |
| 254 | lengthf := 4, |
| 255 | allocRetensionPrio := '00'O, |
| 256 | qos_ProfileValue := { |
| 257 | reliabilityClass := '011'B, |
| 258 | delayClass := '001'B, |
| 259 | spare1 := '00'B, |
| 260 | precedenceClass := '010'B, |
| 261 | spare2 := '0'B, |
| 262 | peakThroughput := '1001'B, |
| 263 | meanThroughput := '11111'B, |
| 264 | spare3 := '000'B, |
| 265 | deliverErroneusSDU := omit, |
| 266 | deliveryOrder := omit, |
| 267 | trafficClass := omit, |
| 268 | maxSDUSize := omit, |
| 269 | maxBitrateUplink := omit, |
| 270 | maxBitrateDownlink := omit, |
| 271 | sduErrorRatio := omit, |
| 272 | residualBER := omit, |
| 273 | trafficHandlingPriority := omit, |
| 274 | transferDelay := omit, |
| 275 | guaranteedBitRateUplink := omit, |
| 276 | guaranteedBitRateDownlink := omit, |
| 277 | sourceStatisticsDescriptor := omit, |
| 278 | signallingIndication := omit, |
| 279 | spare4 := omit, |
| 280 | maxBitrateDownlinkExt := omit, |
| 281 | guaranteedBitRateDownlinkExt := omit, |
| 282 | maxBitrateUplinkExt := omit, |
| 283 | guaranteedBitRateUplinkExt := omit |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | template IMSI_gtpc ts_Imsi(hexstring digits) := { |
| 288 | type_gtpc := '02'O, |
| 289 | digits := digits, |
| 290 | padding := 'F'H |
| 291 | } |
| 292 | |
| 293 | template GTPC_PDUs ts_CreatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl, |
| 294 | BIT4 nsapi, EndUserAddress eua, octetstring apn, |
| 295 | octetstring sgsn_ip_sign, octetstring sgsn_ip_data, |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 296 | octetstring msisdn, template ProtConfigOptions pco := omit) := { |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 297 | createPDPContextRequest := { |
| 298 | imsi := ts_Imsi(imsi), |
| 299 | rai := omit, |
| 300 | recovery := ts_Recovery(restart_ctr), |
| 301 | selectionMode := { |
| 302 | type_gtpc := '0F'O, |
| 303 | selectModeValue := '00'B, |
| 304 | spare := '111111'B |
| 305 | }, |
| 306 | teidDataI := { |
| 307 | type_gtpc := '00'O, |
| 308 | teidDataI := teid_data |
| 309 | }, |
| 310 | teidControlPlane := { |
| 311 | type_gtpc := '00'O, |
| 312 | teidControlPlane := teid_ctrl |
| 313 | }, |
| 314 | nsapi := { |
| 315 | type_gtpc := '00'O, |
| 316 | nsapi := nsapi, |
| 317 | unused := '0000'B |
| 318 | }, |
| 319 | linked_nsapi := omit, |
| 320 | charging_char := omit, |
| 321 | trace_ref := omit, |
| 322 | trace_type := omit, |
| 323 | endUserAddress := eua, |
| 324 | accessPointName := ts_APN(apn), |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 325 | protConfigOptions := pco, |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 326 | sgsn_addr_signalling := ts_GsnAddr(sgsn_ip_sign), |
| 327 | sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data), |
| 328 | msisdn := ts_Msisdn(msisdn), |
| 329 | qualityOfServiceProfile := ts_QosDefault, |
| 330 | tft := omit, |
| 331 | triggerId := omit, |
| 332 | omcId := omit, |
| 333 | commonFlags := omit, |
| 334 | aPN_Restriction := omit, |
| 335 | ratType := omit, |
| 336 | userLocationInformation := omit, |
| 337 | mS_TimeZone := omit, |
| 338 | imeisv := omit, |
| 339 | camelChargingInformationContainer := omit, |
| 340 | additionalTraceInfo := omit, |
| 341 | correlationID := omit, |
| 342 | evolvedAllocationRetentionPriorityI := omit, |
| 343 | extendedCommonFlags := omit, |
| 344 | userCSGInformation := omit, |
| 345 | aPN_AMBR := omit, |
| 346 | signallingPriorityIndication := omit, |
| 347 | cN_OperatorSelectionEntity := omit, |
| 348 | private_extension_gtpc := omit |
| 349 | } |
| 350 | } |
| 351 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 352 | template Gtp1cUnitdata ts_GTPC_CreatePDP(GtpPeer peer, uint16_t seq, hexstring imsi, |
| 353 | OCT1 restart_ctr, OCT4 teid_data, |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 354 | OCT4 teid_ctrl, BIT4 nsapi, EndUserAddress eua, |
| 355 | octetstring apn, octetstring sgsn_ip_sign, |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 356 | octetstring sgsn_ip_data, octetstring msisdn, |
| 357 | template ProtConfigOptions pco := omit) := { |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 358 | peer := peer, |
| 359 | gtpc := ts_GTP1C_PDU(createPDPContextRequest, '00000000'O, |
| 360 | valueof(ts_CreatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl, |
| 361 | nsapi, eua, apn, sgsn_ip_sign, |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 362 | sgsn_ip_data, msisdn, pco)), seq) |
| 363 | } |
| 364 | |
Harald Welte | 99ef9a4 | 2017-08-14 21:42:03 +0200 | [diff] [blame] | 365 | /* PCO send base template */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 366 | template ProtConfigOptions ts_PCO := { |
| 367 | type_gtpc := '84'O, |
| 368 | lengthf := 0, |
| 369 | configProtocol := '000'B, |
| 370 | spare := '0000'B, |
| 371 | extension0 := '1'B, |
| 372 | protocols := {} |
| 373 | } |
Harald Welte | 99ef9a4 | 2017-08-14 21:42:03 +0200 | [diff] [blame] | 374 | /* PCO receive base template */ |
| 375 | template ProtConfigOptions tr_PCO := { |
| 376 | type_gtpc := '84'O, |
| 377 | lengthf := ?, |
| 378 | configProtocol := '000'B, |
| 379 | spare := ?, |
| 380 | extension0 := '1'B, |
| 381 | protocols := {} |
| 382 | } |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 383 | |
| 384 | template ProtConfigOptions ts_PCO_IPv6_DNS modifies ts_PCO := { |
| 385 | protocols := { |
| 386 | { protocolID := '0003'O, lengthProtoID := 0, protoIDContents := ''O } |
| 387 | } |
| 388 | } |
Harald Welte | 99ef9a4 | 2017-08-14 21:42:03 +0200 | [diff] [blame] | 389 | template ProtConfigOptions tr_PCO_IPv6_DNS_resp(template OCT16 contents) modifies tr_PCO := { |
| 390 | protocols := { |
Harald Welte | 3ab91d6 | 2017-08-25 14:46:39 +0200 | [diff] [blame] | 391 | *, { protocolID := '0003'O, lengthProtoID := 16, protoIDContents := contents }, * |
Harald Welte | 99ef9a4 | 2017-08-14 21:42:03 +0200 | [diff] [blame] | 392 | } |
| 393 | } |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 394 | |
| 395 | template ProtConfigOptions ts_PCO_IPv4_DNS_IPCP modifies ts_PCO := { |
| 396 | protocols := { |
Harald Welte | ab4ca94 | 2017-09-07 18:41:52 +0200 | [diff] [blame] | 397 | /* dummy PAP entry to check if our parser in the GGSN can properly iterate over |
| 398 | * the list of protocols, see Change-Id Icc2e6716c33d78d3c3e000f529806228d8aa155e */ |
| 399 | { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O }, |
Harald Welte | eb9184d | 2017-12-04 19:01:47 +0100 | [diff] [blame] | 400 | { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := |
| 401 | enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) } |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 402 | } |
| 403 | } |
| 404 | |
Harald Welte | 71a3602 | 2017-12-04 18:55:58 +0100 | [diff] [blame] | 405 | template ProtocolElement tr_PCO_Proto(OCT2 prot_id) := { |
| 406 | protocolID := prot_id, |
| 407 | lengthProtoID := ?, |
| 408 | protoIDContents := ? |
| 409 | } |
| 410 | template ProtConfigOptions tr_PCO_Contains(OCT2 prot_id) modifies tr_PCO := { |
| 411 | protocols := { *, tr_PCO_Proto(prot_id), * } |
| 412 | } |
| 413 | |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 414 | template ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := { |
| 415 | protocols := { |
| 416 | { protocolID := '000d'O, lengthProtoID := 0, protoIDContents := ''O } |
| 417 | } |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 418 | } |
Harald Welte | 99ef9a4 | 2017-08-14 21:42:03 +0200 | [diff] [blame] | 419 | template ProtConfigOptions tr_PCO_IPv4_DNS_CONT_resp(template OCT4 contents) modifies tr_PCO := { |
| 420 | protocols := { |
Harald Welte | 3ab91d6 | 2017-08-25 14:46:39 +0200 | [diff] [blame] | 421 | *, { protocolID := '000d'O, lengthProtoID := 4, protoIDContents := contents }, * |
Harald Welte | 99ef9a4 | 2017-08-14 21:42:03 +0200 | [diff] [blame] | 422 | } |
| 423 | } |
| 424 | |
Harald Welte | 71a3602 | 2017-12-04 18:55:58 +0100 | [diff] [blame] | 425 | /* extract a given protocol payload from PCO */ |
| 426 | function f_PCO_extract_proto(ProtConfigOptions pco, OCT2 protocol) return octetstring { |
| 427 | var integer i; |
| 428 | for (i := 0; i < lengthof(pco.protocols); i := i + 1) { |
| 429 | if (pco.protocols[i].protocolID == protocol) { |
| 430 | return pco.protocols[i].protoIDContents; |
| 431 | } |
| 432 | } |
| 433 | setverdict(fail); |
| 434 | return ''O; |
| 435 | } |
| 436 | |
| 437 | template IpcpPacket tr_IPCP(template LcpCode code, template uint8_t identifier, |
| 438 | template IpcpOptionList opts) := { |
| 439 | code := code, |
| 440 | identifier := identifier, |
| 441 | len := ?, |
| 442 | options := opts |
| 443 | } |
| 444 | template IpcpOption tr_IPCP_PrimaryDns(template OCT4 addr) := { |
| 445 | code := IPCP_OPT_PrimaryDNS, |
| 446 | len := 6, |
| 447 | data := addr |
| 448 | } |
| 449 | template IpcpOption tr_IPCP_SecondaryDns(template OCT4 addr) := { |
| 450 | code := IPCP_OPT_SecondaryDNS, |
| 451 | len := 6, |
| 452 | data := addr |
| 453 | } |
Harald Welte | 71a3602 | 2017-12-04 18:55:58 +0100 | [diff] [blame] | 454 | template IpcpPacket tr_IPCP_Ack_DNS(template uint8_t identifier := ?, template OCT4 dns1 := ?, |
| 455 | template OCT4 dns2 := ?) := |
| 456 | tr_IPCP(LCP_Configure_Ack, identifier, |
| 457 | { *, tr_IPCP_PrimaryDns(dns1), *, tr_IPCP_SecondaryDns(dns2), * }); |
| 458 | |
Harald Welte | eb9184d | 2017-12-04 19:01:47 +0100 | [diff] [blame] | 459 | template IpcpPacket ts_IPCP(LcpCode code, uint8_t identifier, template IpcpOptionList opts) := { |
| 460 | code := code, |
| 461 | identifier := identifier, |
| 462 | len := 0, /* overwritten */ |
| 463 | options := opts |
| 464 | } |
| 465 | template IpcpPacket ts_IPCP_ReqDNS(uint8_t identifier := 0) := |
| 466 | ts_IPCP(LCP_Configure_Request, identifier, |
| 467 | { tr_IPCP_PrimaryDns('00000000'O), tr_IPCP_SecondaryDns('00000000'O) }); |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 468 | |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 469 | function f_teardown_ind_IE(in template BIT1 ind) return template TearDownInd { |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 470 | /* |
| 471 | if (not isvalue(ind)) { |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 472 | return omit; |
| 473 | } |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 474 | */ |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 475 | var TearDownInd ret := { |
| 476 | type_gtpc := '13'O, |
| 477 | tdInd := valueof(ind), |
| 478 | spare:= '0000000'B |
| 479 | } |
| 480 | return ret; |
| 481 | } |
| 482 | |
| 483 | template GTPC_PDUs ts_DeletePdpPDU(BIT4 nsapi, template BIT1 teardown_ind) := { |
| 484 | deletePDPContextRequest := { |
| 485 | cause := omit, |
| 486 | tearDownIndicator := f_teardown_ind_IE(teardown_ind), |
| 487 | nsapi := { |
| 488 | type_gtpc := '14'O, |
| 489 | nsapi := nsapi, |
| 490 | unused := '0000'B |
| 491 | }, |
| 492 | protConfigOptions := omit, |
| 493 | userLocationInformation := omit, |
| 494 | mS_TimeZone := omit, |
| 495 | extendedCommonFlags := omit, |
| 496 | uLI_Timestamp := omit, |
| 497 | private_extension_gtpc := omit |
| 498 | } |
| 499 | } |
| 500 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 501 | template Gtp1cUnitdata ts_GTPC_DeletePDP(GtpPeer peer, uint16_t seq, OCT4 teid, |
| 502 | BIT4 nsapi, template BIT1 teardown_ind) := { |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 503 | peer := peer, |
| 504 | gtpc := ts_GTP1C_PDU(deletePDPContextRequest, teid, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 505 | valueof(ts_DeletePdpPDU(nsapi, teardown_ind)), seq) |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 506 | } |
| 507 | |
| 508 | |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 509 | /* GTP-U */ |
| 510 | |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 511 | template PDU_GTPU tr_GTP1U_PDU(template OCT1 msg_type, template OCT4 teid, template GTPU_IEs ies := ?) := { |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 512 | pn_bit := ?, |
| 513 | s_bit := ?, |
| 514 | e_bit := ?, |
| 515 | spare := ?, |
| 516 | /* Protocol Type flag (PT) shall be set to '1' in GTP */ |
| 517 | pt := '1'B, |
| 518 | /* Version shall be set to decimal 1 ('001'). */ |
| 519 | version := '001'B, |
| 520 | messageType := msg_type, |
| 521 | lengthf := ?, |
| 522 | teid := teid, |
| 523 | opt_part := *, |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 524 | gtpu_IEs := ies |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | /* generalized GTP-U send template */ |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 528 | template PDU_GTPU ts_GTP1U_PDU(OCT1 msg_type, uint16_t seq, OCT4 teid, GTPU_IEs ies) := { |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 529 | /* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN |
| 530 | * flag is set to 1. */ |
| 531 | pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */ |
| 532 | /* If the Sequence Number flag (S) is set to '1' the sequence number field is present and |
| 533 | * meaningful otherwise it is set to '0'. For GTP-U messages Echo Request, Echo Response, |
| 534 | * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'. */ |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 535 | s_bit := '1'B, /* we assume the encoder overwrites this if an optional part is given */ |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 536 | /* Extension header presence */ |
| 537 | e_bit := '0'B, |
| 538 | spare := '0'B, |
| 539 | /* Protocol Type flag (PT) shall be set to '1' in GTP */ |
| 540 | pt := '1'B, |
| 541 | /* Version shall be set to decimal 1 ('001'). */ |
| 542 | version := '001'B, |
| 543 | messageType := msg_type, |
| 544 | lengthf := 0, /* we assume encoder overwrites this */ |
| 545 | teid := teid, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 546 | opt_part := { |
| 547 | sequenceNumber := int2oct(seq, 2), |
| 548 | npduNumber := '00'O, |
| 549 | nextExtHeader := '00'O, |
| 550 | gTPU_extensionHeader_List := omit |
| 551 | }, |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 552 | gtpu_IEs := ies |
| 553 | } |
| 554 | |
| 555 | template Gtp1uUnitdata tr_GTPU_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid) := { |
| 556 | peer := peer, |
| 557 | gtpu := tr_GTP1U_PDU(msg_type, teid) |
| 558 | } |
| 559 | |
| 560 | |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 561 | /* template matching reception of GTP-U echo-request */ |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 562 | template Gtp1uUnitdata tr_GTPU_PING(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoRequest, '00000000'O); |
| 563 | |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 564 | /* template matching reception of GTP-U GPDU */ |
| 565 | template GTPU_IEs t_GPDU(template octetstring data) := { |
| 566 | g_PDU_IEs := { |
| 567 | data := data |
| 568 | } |
| 569 | } |
| 570 | template Gtp1uUnitdata tr_GTPU_GPDU(template GtpPeer peer, template OCT4 teid, template octetstring data := ?) := { |
| 571 | peer := peer, |
| 572 | gtpu := tr_GTP1U_PDU('FF'O, teid, t_GPDU(data)) |
| 573 | } |
| 574 | |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 575 | template GTPU_IEs ts_UEchoRespPDU(OCT1 restart_counter) := { |
| 576 | echoResponse_IEs := { |
| 577 | recovery_gtpu := { |
| 578 | type_gtpu := '00'O, /* we assume encoder fixes? */ |
| 579 | restartCounter := restart_counter |
| 580 | }, |
| 581 | private_extension_gtpu := omit |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | /* master template for sending a GTP-U echo response */ |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 586 | template Gtp1uUnitdata ts_GTPU_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := { |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 587 | peer := peer, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 588 | gtpu := ts_GTP1U_PDU(echoResponse, seq, '00000000'O, valueof(ts_UEchoRespPDU(rest_ctr))) |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 589 | } |
| 590 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 591 | /* master template for sending a GTP-U user plane data */ |
| 592 | template Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, uint16_t seq, OCT4 teid, octetstring data) := { |
| 593 | peer := peer, |
| 594 | gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }}) |
| 595 | } |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 596 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 597 | /* Altstep implementing responses to any incoming echo requests */ |
| 598 | altstep pingpong() runs on GT_CT { |
| 599 | var Gtp1cUnitdata ud; |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 600 | var Gtp1uUnitdata udu; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 601 | [] GTPC.receive(tr_GTPC_PING(?)) -> value ud { |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 602 | var uint16_t seq := oct2int(ud.gtpc.opt_part.sequenceNumber); |
| 603 | GTPC.send(ts_GTPC_PONG(ud.peer, seq, '00'O)); |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 604 | repeat; |
| 605 | }; |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 606 | [] GTPU.receive(tr_GTPU_PING(?)) -> value udu { |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 607 | var uint16_t seq := oct2int(udu.gtpu.opt_part.sequenceNumber); |
| 608 | GTPU.send(ts_GTPU_PONG(udu.peer, seq, '00'O)); |
Harald Welte | 3af8948 | 2017-08-04 16:20:23 +0200 | [diff] [blame] | 609 | }; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 610 | [] T_default.timeout { setverdict(fail); }; |
| 611 | } |
| 612 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 613 | /* 'internet' in DNS encoding */ |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 614 | const octetstring c_ApnInternet := '08696E7465726E6574'O; |
| 615 | const octetstring c_ApnInet6 := '05696E657436'O; |
| 616 | const octetstring c_ApnInet46 := '06696E65743436'O; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 617 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 618 | /* return random integer between 0 and max */ |
| 619 | function f_rnd_int(integer max) return integer { |
| 620 | return float2int(rnd()*int2float(max)); |
| 621 | } |
| 622 | |
| 623 | /* return random NSAPI */ |
| 624 | function f_rnd_nsapi() return BIT4 { |
| 625 | return int2bit(f_rnd_int(16), 4); |
| 626 | } |
| 627 | |
| 628 | /* return random TEI[DC] */ |
| 629 | function f_rnd_tei() return OCT4 { |
| 630 | return int2oct(f_rnd_int(4294967296), 4); |
| 631 | } |
| 632 | |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 633 | /* return hexstring composed of random digits */ |
| 634 | function f_rnd_hexstring(in integer len, in integer max := 15) return hexstring { |
| 635 | var integer i; |
| 636 | var hexstring ret := ''H; |
| 637 | for (i := 0; i < len; i := i + 1) { |
| 638 | ret := ret & int2hex(f_rnd_int(max), 1); |
| 639 | } |
| 640 | return ret; |
| 641 | } |
| 642 | |
| 643 | /* return octetstring composed of random bytes */ |
| 644 | function f_rnd_octstring(in integer len) return octetstring { |
| 645 | var integer i; |
| 646 | var octetstring ret := ''O; |
| 647 | for (i := 0; i < len; i := i + 1) { |
| 648 | ret := ret & int2oct(f_rnd_int(255), 1); |
| 649 | } |
| 650 | return ret; |
| 651 | } |
| 652 | |
| 653 | function f_rnd_imsi(in hexstring prefix) return hexstring { |
| 654 | return prefix & f_rnd_hexstring(15 - lengthof(prefix), 9); |
| 655 | } |
| 656 | |
| 657 | function f_rnd_msisdn(in octetstring prefix, integer len := 6) return octetstring { |
| 658 | return prefix & f_rnd_octstring(len - lengthof(prefix)); |
| 659 | } |
| 660 | |
| 661 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 662 | /* define an (internal) representation of a PDP context */ |
| 663 | template PdpContext t_DefinePDP(hexstring imsi, octetstring msisdn, octetstring apn, |
| 664 | EndUserAddress eua) := { |
| 665 | imsi := imsi, |
| 666 | msisdn := msisdn, |
| 667 | nsapi := f_rnd_nsapi(), |
| 668 | apn := apn, |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 669 | pco_req := omit, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 670 | eua := eua, |
| 671 | teid := f_rnd_tei(), |
Harald Welte | 5438b9d | 2017-08-13 13:27:48 +0200 | [diff] [blame] | 672 | teic := f_rnd_tei() |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | /* send GTP-C for a given context and increment sequence number */ |
Harald Welte | 41575e9 | 2017-08-13 13:49:57 +0200 | [diff] [blame] | 676 | function f_send_gtpc(in template Gtp1cUnitdata data) runs on GT_CT { |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 677 | GTPC.send(data); |
Harald Welte | 5438b9d | 2017-08-13 13:27:48 +0200 | [diff] [blame] | 678 | g_c_seq_nr := g_c_seq_nr + 1; |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | /* send GTP-U for a given context and increment sequence number */ |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 682 | function f_send_gtpu(inout PdpContext ctx, in octetstring data) runs on GT_CT { |
Harald Welte | 5438b9d | 2017-08-13 13:27:48 +0200 | [diff] [blame] | 683 | GTPU.send(ts_GTP1U_GPDU(g_peer_u, g_d_seq_nr, ctx.teid_remote, data)); |
| 684 | g_d_seq_nr := g_d_seq_nr + 1; |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 685 | } |
| 686 | |
| 687 | /* send a PDP context activation */ |
| 688 | function f_pdp_ctx_act(inout PdpContext ctx) runs on GT_CT { |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 689 | var Gtp1cUnitdata ud; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 690 | var default d; |
| 691 | |
| 692 | log("sending CreatePDP"); |
Harald Welte | 41575e9 | 2017-08-13 13:49:57 +0200 | [diff] [blame] | 693 | f_send_gtpc(ts_GTPC_CreatePDP(g_peer_c, g_c_seq_nr, ctx.imsi, g_restart_ctr, |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 694 | ctx.teid, ctx.teic, ctx.nsapi, ctx.eua, ctx.apn, |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 695 | g_sgsn_ip_c, g_sgsn_ip_u, ctx.msisdn, ctx.pco_req)); |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 696 | T_default.start; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 697 | d := activate(pingpong()); |
| 698 | alt { |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 699 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, createPDPContextResponse, ctx.teic)) -> value ud { |
| 700 | var CreatePDPContextResponse cpr := ud.gtpc.gtpc_pdu.createPDPContextResponse; |
| 701 | if (cpr.cause.causevalue == '80'O) { |
Harald Welte | 99ef9a4 | 2017-08-14 21:42:03 +0200 | [diff] [blame] | 702 | /* Check if EUA type corresponds to requested type */ |
| 703 | if (match(ctx.eua, t_EuaIPv4(?)) and |
| 704 | not match(cpr.endUserAddress, tr_EuaIPv4(?))){ |
| 705 | setverdict(fail); |
| 706 | } |
| 707 | if (match(ctx.eua, t_EuaIPv6(?)) and |
| 708 | not match(cpr.endUserAddress, tr_EuaIPv6(?))) { |
| 709 | setverdict(fail); |
| 710 | } |
| 711 | /* Check if PCO response corresponds to request */ |
| 712 | if (ispresent(ctx.pco_req)) { |
| 713 | if (match(ctx.pco_req, ts_PCO_IPv4_DNS_CONT) and |
| 714 | not match(cpr.protConfigOptions, tr_PCO_IPv4_DNS_CONT_resp(?))) { |
| 715 | log("IPv4 DNS Container requested, but missing"); |
| 716 | setverdict(fail); |
| 717 | } |
| 718 | if (match(ctx.pco_req, ts_PCO_IPv6_DNS) and |
| 719 | not match(cpr.protConfigOptions, tr_PCO_IPv6_DNS_resp(?))) { |
| 720 | log("IPv6 DNS Container requested, but missing"); |
| 721 | setverdict(fail); |
| 722 | } |
| 723 | } |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 724 | ctx.teid_remote := cpr.teidDataI.teidDataI; |
| 725 | ctx.teic_remote := cpr.teidControlPlane.teidControlPlane; |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 726 | ctx.eua := cpr.endUserAddress; |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 727 | ctx.pco_neg := cpr.protConfigOptions; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 728 | setverdict(pass); |
| 729 | } else { |
| 730 | setverdict(fail); |
| 731 | } |
| 732 | } |
| 733 | } |
| 734 | deactivate(d); |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 735 | T_default.stop; |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 736 | } |
| 737 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 738 | function f_pdp_ctx_del(PdpContext ctx, template BIT1 teardown_ind) runs on GT_CT { |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 739 | var Gtp1cUnitdata ud; |
| 740 | var default d; |
| 741 | |
Harald Welte | 41575e9 | 2017-08-13 13:49:57 +0200 | [diff] [blame] | 742 | f_send_gtpc(ts_GTPC_DeletePDP(g_peer_c, g_c_seq_nr, ctx.teic_remote, ctx.nsapi, teardown_ind)); |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 743 | T_default.start; |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 744 | d := activate(pingpong()); |
| 745 | alt { |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 746 | [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextResponse, ctx.teic)) -> value ud { |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 747 | if (ud.gtpc.gtpc_pdu.deletePDPContextResponse.cause.causevalue == '80'O) { |
| 748 | setverdict(pass); |
| 749 | } else { |
| 750 | setverdict(fail); |
| 751 | } |
| 752 | } |
| 753 | } |
| 754 | deactivate(d); |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 755 | T_default.stop; |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 756 | } |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 757 | /* IPv6 router solicitation fe80::2 -> ff02::2 from 02:88:b5:1f:25:59 */ |
| 758 | const octetstring c_router_solicit := '6000000000103afffe800000000000000000000000000002ff02000000000000000000000000000285009f2b0000000001010288b51f2559'O; |
| 759 | /* IPv6 neighbor solicitation fe80::2 -> ff02::1:ff00:2 from 02:88:b5:1f:25:59 */ |
| 760 | const octetstring c_neigh_solicit:= '6000000000203afffe800000000000000000000000000002ff0200000000000000000001ff00000287009f9600000000fe80000000000000000000000000000201010288b51f2559'O; |
Harald Welte | f1e0d5a | 2017-08-05 08:51:22 +0200 | [diff] [blame] | 761 | |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 762 | /* template to generate a 'Prefix Information' ICMPv6 option */ |
| 763 | template OptionField ts_ICMP6_OptPrefix(OCT16 prefix, INT1 prefix_len) := { |
| 764 | prefixInformation := { |
| 765 | typeField := 3, |
| 766 | lengthIndicator := 8, |
| 767 | prefixLength := prefix_len, |
| 768 | reserved1 := '000000'B, |
| 769 | a_Bit := '0'B, |
| 770 | l_Bit := '0'B, |
| 771 | validLifetime := oct2int('FFFFFFFF'O), |
| 772 | preferredLifetime := oct2int('FFFFFFFF'O), |
| 773 | reserved2 := '00000000'O, |
| 774 | prefix := prefix |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | /* template for an ICMPv6 router solicitation */ |
| 779 | template PDU_ICMPv6 ts_ICMPv6_RS := { |
| 780 | routerSolicitation := { |
| 781 | typeField := 133, |
| 782 | code := 0, |
| 783 | checksum := '0000'O, |
| 784 | reserved := '00000000'O, |
| 785 | /* TODO: do we need 'Source link-layer address' ? */ |
| 786 | options := omit |
| 787 | } |
| 788 | } |
| 789 | |
| 790 | /* template for an ICMPv6 router advertisement */ |
| 791 | template PDU_ICMPv6 ts_ICMPv6_RA(OCT16 prefix, INT1 prefix_len) := { |
| 792 | routerAdvertisement := { |
| 793 | typeField := 134, |
| 794 | code := 0, |
| 795 | checksum := '0000'O, |
| 796 | curHopLimit := ?, |
| 797 | reserved := '000000'B, |
| 798 | o_Bit := '0'B, |
| 799 | m_Bit := '0'B, |
| 800 | routerLifetime := oct2int('FFFF'O), |
| 801 | reachableTime := oct2int('FFFFFFFF'O), |
| 802 | retransTimer := oct2int('FFFFFFFF'O), |
| 803 | options := { |
| 804 | ts_ICMP6_OptPrefix(prefix, prefix_len) |
| 805 | } |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | template PDU_ICMPv6 ts_ICMPv6_NS(OCT16 target_addr) := { |
| 810 | neighborSolicitation := { |
| 811 | typeField := 135, |
| 812 | code := 0, |
| 813 | checksum := '0000'O, |
| 814 | reserved := '00000000'O, |
| 815 | targetAddress := target_addr, |
| 816 | /* TODO: do we need 'Source link-layer address' ? */ |
| 817 | options := omit |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | /* derive ICMPv6 link-local address from lower 64bit of link_id */ |
| 822 | /* template for receiving/matching an ICMPv6 'Prefix Information' option */ |
| 823 | template OptionField tr_ICMP6_OptPrefix(template OCT16 prefix, template INT1 prefix_len) := { |
| 824 | prefixInformation := { |
| 825 | typeField := 3, |
| 826 | lengthIndicator := 4, |
| 827 | prefixLength := prefix_len, |
| 828 | reserved1 := ?, |
| 829 | a_Bit := ?, |
| 830 | l_Bit := ?, |
| 831 | validLifetime := ?, |
| 832 | preferredLifetime := ?, |
| 833 | reserved2 := ?, |
| 834 | prefix := prefix |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | /* template for receiving/matching an ICMPv6 router advertisement */ |
| 839 | template PDU_ICMPv6 tr_ICMPv6_RA(template OCT16 prefix, template INT1 prefix_len) := { |
| 840 | routerAdvertisement := { |
| 841 | typeField := 134, |
| 842 | code := 0, |
| 843 | checksum := ?, |
| 844 | curHopLimit := ?, |
| 845 | reserved := ?, |
| 846 | o_Bit := '0'B, |
| 847 | m_Bit := '0'B, |
| 848 | routerLifetime := ?, |
| 849 | reachableTime := ?, |
| 850 | retransTimer := ?, |
| 851 | options := { |
| 852 | tr_ICMP6_OptPrefix(prefix, prefix_len) |
| 853 | } |
| 854 | } |
| 855 | } |
| 856 | |
| 857 | /* template to construct IPv6_packet from input arguments, ready for use in f_IPv6_enc() */ |
| 858 | template IPv6_packet ts_IP6(OCT16 srcaddr, OCT16 dstaddr, LIN1 nexthead, octetstring payload, LIN1 hlim := 255) := { |
| 859 | header := { |
| 860 | ver := 6, |
| 861 | trclass := 0, |
| 862 | flabel := 0, |
| 863 | plen := 0, |
| 864 | nexthead := nexthead, |
| 865 | hlim := hlim, |
| 866 | srcaddr := srcaddr, |
| 867 | dstaddr := dstaddr |
| 868 | }, |
| 869 | ext_headers := omit, |
| 870 | payload := payload |
| 871 | } |
| 872 | |
| 873 | function f_ipv6_link_local(in OCT16 link_id) return OCT16 { |
| 874 | return 'FE80000000000000'O & substr(link_id, 8, 8); |
| 875 | } |
| 876 | |
| 877 | /* Compute solicited-node multicast address as per RFC4291 2.7.1 */ |
| 878 | function f_ipv6_sol_node_mcast(in OCT16 addr) return OCT16 { |
| 879 | return 'FF0200000000000000000001FF'O & substr(addr, 13, 3); |
| 880 | } |
| 881 | |
| 882 | /* generate and encode ICMPv6 router solicitation */ |
| 883 | function f_gen_icmpv6_router_solicitation(in OCT16 link_id) return octetstring { |
| 884 | const OCT16 c_ip6_all_router_mcast := 'FF020000000000000000000000000002'O; |
| 885 | var OCT16 saddr := f_ipv6_link_local(link_id); |
| 886 | |
| 887 | var octetstring tmp; |
| 888 | tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_RS), saddr, c_ip6_all_router_mcast); |
| 889 | var IPv6_packet ip6 := valueof(ts_IP6(saddr, c_ip6_all_router_mcast, 58, tmp)); |
| 890 | |
| 891 | return f_IPv6_enc(ip6); |
| 892 | } |
| 893 | |
| 894 | /* create ICMPv6 router solicitation deriving link-id from PDP Context EUA */ |
| 895 | function f_icmpv6_rs_for_pdp(in PdpContext ctx) return octetstring { |
| 896 | var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address; |
| 897 | return f_gen_icmpv6_router_solicitation(interface_id); |
| 898 | } |
| 899 | |
| 900 | /* generate and encode ICMPv6 neighbor solicitation */ |
| 901 | function f_gen_icmpv6_neigh_solicit(in OCT16 saddr, in OCT16 daddr, in OCT16 tgt_addr) return octetstring { |
| 902 | var octetstring tmp; |
| 903 | tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_NS(tgt_addr)), saddr, daddr); |
| 904 | var IPv6_packet ip6 := valueof(ts_IP6(saddr, daddr, 58, tmp)); |
| 905 | return f_IPv6_enc(ip6); |
| 906 | } |
| 907 | |
| 908 | /* generate and encode ICMPv6 neighbor solicitation for PDP Context */ |
| 909 | function f_gen_icmpv6_neigh_solicit_for_pdp(in PdpContext ctx) return octetstring { |
| 910 | var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address; |
| 911 | var OCT16 link_local := f_ipv6_link_local(interface_id); |
| 912 | var OCT16 daddr := f_ipv6_sol_node_mcast(link_local); |
| 913 | |
| 914 | return f_gen_icmpv6_neigh_solicit(link_local, daddr, link_local); |
| 915 | } |
| 916 | |
| 917 | /* wait for GGSN to send us an ICMPv6 router advertisement */ |
| 918 | function f_wait_rtr_adv(PdpContext ctx) runs on GT_CT { |
| 919 | var Gtp1uUnitdata ud; |
| 920 | T_default.start; |
| 921 | alt { |
| 922 | //'6???????????3aff'O |
| 923 | [] GTPU.receive(tr_GTPU_GPDU(g_peer_u, ?)) -> value ud { |
| 924 | var octetstring gpdu := ud.gtpu.gtpu_IEs.g_PDU_IEs.data; |
| 925 | var IPv6_packet ip6 := f_IPv6_dec(gpdu); |
| 926 | if (ip6.header.ver != 6 or ip6.header.nexthead != 58 or ip6.header.hlim != 255) { |
| 927 | repeat; |
| 928 | } |
| 929 | var PDU_ICMPv6 icmp6 := f_dec_PDU_ICMPv6(ip6.payload); |
| 930 | if (not match(icmp6, tr_ICMPv6_RA(?, 64))) { |
| 931 | repeat; |
| 932 | } |
| 933 | ctx.ip6_prefix := icmp6.routerAdvertisement.options[0].prefixInformation.prefix; |
| 934 | log("RA with /64 prefix ", ctx.ip6_prefix); |
| 935 | } |
| 936 | [] GTPU.receive(tr_GTPU_GPDU(?, ?)) { repeat; } |
| 937 | [] GTPU.receive { setverdict(fail); } |
| 938 | [] T_default.timeout { setverdict(fail); } |
| 939 | } |
| 940 | T_default.stop; |
| 941 | } |
| 942 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 943 | /* Test IPv6 context activation for dynamic IPv6 EUA without request of IPv6 DNS */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 944 | testcase TC_pdp6_act_deact() runs on GT_CT { |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 945 | f_init(); |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 946 | |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 947 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 948 | f_pdp_ctx_act(ctx); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 949 | f_pdp_ctx_del(ctx, '1'B); |
| 950 | } |
| 951 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 952 | /* Test IPv6 context activation for dynamic IPv6 EUA wirh request of IPv6 DNS in PCO */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 953 | testcase TC_pdp6_act_deact_pcodns() runs on GT_CT { |
| 954 | f_init(); |
| 955 | |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 956 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 957 | ctx.pco_req := valueof(ts_PCO_IPv6_DNS); |
| 958 | f_pdp_ctx_act(ctx); |
| 959 | f_pdp_ctx_del(ctx, '1'B); |
| 960 | } |
| 961 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 962 | /* Test PDP context activation for dynamic IPv6 EUA with IPv6 DNS in PCO and router solicitation/advertisement */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 963 | testcase TC_pdp6_act_deact_icmp6() runs on GT_CT { |
| 964 | f_init(); |
| 965 | |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 966 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 967 | ctx.pco_req := valueof(ts_PCO_IPv6_DNS); |
| 968 | f_pdp_ctx_act(ctx); |
Harald Welte | 231b941 | 2017-08-09 17:16:31 +0200 | [diff] [blame] | 969 | |
| 970 | //f_send_gtpu(ctx, c_router_solicit); |
| 971 | //f_send_gtpu(ctx, c_neigh_solicit); |
| 972 | |
| 973 | f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx)); |
| 974 | f_wait_rtr_adv(ctx); |
| 975 | f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx)); |
| 976 | |
Harald Welte | 811651e | 2017-08-05 15:25:06 +0200 | [diff] [blame] | 977 | f_pdp_ctx_del(ctx, '1'B); |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 978 | } |
| 979 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 980 | /* Test PDP context activation for dynamic IPv4 EUA without DNS request */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 981 | testcase TC_pdp4_act_deact() runs on GT_CT { |
| 982 | f_init(); |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 983 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 984 | f_pdp_ctx_act(ctx); |
| 985 | f_pdp_ctx_del(ctx, '1'B); |
| 986 | } |
| 987 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 988 | /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in IPCP */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 989 | testcase TC_pdp4_act_deact_ipcp() runs on GT_CT { |
| 990 | f_init(); |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 991 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 992 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_IPCP); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 993 | f_pdp_ctx_act(ctx); |
Harald Welte | 71a3602 | 2017-12-04 18:55:58 +0100 | [diff] [blame] | 994 | /* verify IPCP is at all contained */ |
| 995 | if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) { |
| 996 | setverdict(fail, "IPCP not found in PCO"); |
| 997 | } |
| 998 | /* verify IPCP contains both primary and secondary DNS */ |
| 999 | var IpcpPacket ipcp := dec_IpcpPacket(f_PCO_extract_proto(ctx.pco_neg, '8021'O)); |
Harald Welte | e7096c1 | 2017-12-04 19:40:44 +0100 | [diff] [blame] | 1000 | if (not match(ipcp, tr_IPCP_Ack_DNS(0, 'C0A86401'O, '08080808'O))) { |
Harald Welte | 71a3602 | 2017-12-04 18:55:58 +0100 | [diff] [blame] | 1001 | setverdict(fail, "Primary/Secondary DNS not found in IPCP"); |
| 1002 | } |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1003 | f_pdp_ctx_del(ctx, '1'B); |
| 1004 | } |
| 1005 | |
Harald Welte | 0ef285b | 2017-08-13 20:06:01 +0200 | [diff] [blame] | 1006 | /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in PCO */ |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1007 | testcase TC_pdp4_act_deact_pcodns() runs on GT_CT { |
| 1008 | f_init(); |
Harald Welte | ed09743 | 2017-08-13 13:28:49 +0200 | [diff] [blame] | 1009 | var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 1010 | ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1011 | f_pdp_ctx_act(ctx); |
| 1012 | f_pdp_ctx_del(ctx, '1'B); |
| 1013 | } |
| 1014 | |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 1015 | testcase TC_echo_req_resp() runs on GT_CT { |
| 1016 | f_init(); |
| 1017 | f_send_gtpc(ts_GTPC_PING(g_peer_c, g_c_seq_nr)); |
| 1018 | T_default.start; |
| 1019 | alt { |
| 1020 | [] GTPC.receive(tr_GTPC_PONG(g_peer_c)) { setverdict(pass); }; |
| 1021 | [] GTPC.receive { repeat; }; |
| 1022 | [] T_default.timeout { setverdict(fail); } |
| 1023 | } |
| 1024 | T_default.stop; |
| 1025 | } |
| 1026 | |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 1027 | control { |
Harald Welte | ed7a177 | 2017-08-09 20:26:20 +0200 | [diff] [blame] | 1028 | execute(TC_pdp4_act_deact()); |
| 1029 | execute(TC_pdp4_act_deact_ipcp()); |
| 1030 | execute(TC_pdp4_act_deact_pcodns()); |
| 1031 | |
| 1032 | execute(TC_pdp6_act_deact()); |
| 1033 | execute(TC_pdp6_act_deact_pcodns()); |
| 1034 | execute(TC_pdp6_act_deact_icmp6()); |
Harald Welte | dca8005 | 2017-08-13 20:01:38 +0200 | [diff] [blame] | 1035 | |
| 1036 | execute(TC_echo_req_resp()); |
Harald Welte | 94ade36 | 2017-08-04 00:36:55 +0200 | [diff] [blame] | 1037 | } |
Harald Welte | 379d45a | 2017-08-03 09:55:15 +0200 | [diff] [blame] | 1038 | } |