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