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