blob: b3e26d58cf2c4014cfc565102e1c3c5276794ecc [file] [log] [blame]
Harald Welte379d45a2017-08-03 09:55:15 +02001module GGSN_Tests {
2
Harald Welte94ade362017-08-04 00:36:55 +02003 import from General_Types all;
Harald Welte811651e2017-08-05 15:25:06 +02004 import from Osmocom_Types all;
Harald Welte94ade362017-08-04 00:36:55 +02005 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 Welte231b9412017-08-09 17:16:31 +020011 import from IP_Types all;
12 import from ICMPv6_Types all;
Harald Welte94ade362017-08-04 00:36:55 +020013
14 const integer GTP0_PORT := 3386;
15 const integer GTP1C_PORT := 2123;
16 const integer GTP1U_PORT := 2152;
Harald Welte876345e2017-08-04 16:19:59 +020017 const charstring g_bind_ip_c := "127.23.42.1";
18 const charstring g_bind_ip_u := g_bind_ip_c;
Harald Welte94ade362017-08-04 00:36:55 +020019
Harald Welte811651e2017-08-05 15:25:06 +020020 type set PdpContext {
21 hexstring imsi,
22 octetstring msisdn optional,
23 octetstring apn,
Harald Welteed7a1772017-08-09 20:26:20 +020024 ProtConfigOptions pco_req optional,
25 ProtConfigOptions pco_neg optional,
Harald Welte811651e2017-08-05 15:25:06 +020026 EndUserAddress eua,
Harald Welte231b9412017-08-09 17:16:31 +020027 OCT16 ip6_prefix optional,
Harald Welte811651e2017-08-05 15:25:06 +020028 BIT4 nsapi,
29 /* TEI (Data) local side */
30 OCT4 teid,
31 /* TEI (Control) local side */
32 OCT4 teic,
33 /* TEI (Data) remote side */
34 OCT4 teid_remote,
35 /* TEI (Control) remote side */
Harald Welte5438b9d2017-08-13 13:27:48 +020036 OCT4 teic_remote
Harald Welte811651e2017-08-05 15:25:06 +020037 }
38
Harald Welte94ade362017-08-04 00:36:55 +020039 type component GT_CT {
40 port GTPC_PT GTPC;
41 port GTPU_PT GTPU;
42
Harald Welte0be142b2017-08-13 13:28:10 +020043 var boolean g_initialized := false;
44
Harald Welte94ade362017-08-04 00:36:55 +020045 var OCT1 g_restart_ctr := '01'O;
46 /* FIXME: unify with g_bind_ip + parse from config file */
Harald Welte876345e2017-08-04 16:19:59 +020047 var OCT4 g_sgsn_ip_c := '7f172a01'O;
48 var OCT4 g_sgsn_ip_u := '7f172a01'O;
Harald Welte94ade362017-08-04 00:36:55 +020049 /* FIXME: parse remName from config file */
Harald Welte811651e2017-08-05 15:25:06 +020050 var GtpPeer g_peer_c := { connId := 0, remName := "127.0.0.6", remPort := GTP1C_PORT };
51 var GtpPeer g_peer_u := { connId := 0, remName := "127.0.0.6", remPort := GTP1U_PORT };
Harald Welte94ade362017-08-04 00:36:55 +020052 timer T_default := 3.0;
Harald Welte5438b9d2017-08-13 13:27:48 +020053
54 /* next to-be-sent GTP-C sequence number */
55 var uint16_t g_c_seq_nr;
56 /* next to-be-sent GTP-U sequence number */
57 var uint16_t g_d_seq_nr;
Harald Welte94ade362017-08-04 00:36:55 +020058 }
59
60 function f_init() runs on GT_CT {
Harald Welte0be142b2017-08-13 13:28:10 +020061 if (g_initialized == true) {
62 return;
63 }
64 g_initialized := true;
65
Harald Welte94ade362017-08-04 00:36:55 +020066 var Result res;
67 map(self:GTPC, system:GTPC);
Harald Welte876345e2017-08-04 16:19:59 +020068 res := GTP_CodecPort_CtrlFunct.f_IPL4_listen(GTPC, g_bind_ip_c, GTP1C_PORT, {udp:={}});
Harald Welte94ade362017-08-04 00:36:55 +020069 log("GTP1C ConnectionID: ", res.connId);
Harald Welte811651e2017-08-05 15:25:06 +020070 g_peer_c.connId := res.connId;
Harald Welte94ade362017-08-04 00:36:55 +020071
72 map(self:GTPU, system:GTPU);
Harald Welte811651e2017-08-05 15:25:06 +020073 res := GTP_CodecPort_CtrlFunct.f_GTPU_listen(GTPU, g_bind_ip_u, GTP1U_PORT, {udp:={}});
74 g_peer_u.connId:= res.connId;
Harald Welte5438b9d2017-08-13 13:27:48 +020075
76 g_restart_ctr := f_rnd_octstring(1);
Harald Welte11dbc7b2017-08-13 18:57:56 +020077 g_c_seq_nr := f_rnd_int(65535);
78 g_d_seq_nr := f_rnd_int(65535);
Harald Welte94ade362017-08-04 00:36:55 +020079 }
80
81 /* generalized GTP-C receive template */
Harald Weltedca80052017-08-13 20:01:38 +020082 template PDU_GTPC tr_GTP1C_PDU(template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdu := ?) := {
Harald Welte94ade362017-08-04 00:36:55 +020083 /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
84 * error if this flag is set to '1'. */
85 pn_bit := '0'B,
86 /* Sequence number flag (S) shall be set to '1'. */
87 s_bit := '1'B,
88 e_bit := ?,
89 spare := ?,
90 /* Protocol Type flag (PT) shall be set to '1'.*/
91 pt := '1'B,
92 /* Version shall be set to decimal 1 ('001'). */
93 version := '001'B,
94 messageType := msg_type,
95 lengthf := ?,
96 teid := teid,
97 opt_part := *,
Harald Weltedca80052017-08-13 20:01:38 +020098 gtpc_pdu := pdu
Harald Welte94ade362017-08-04 00:36:55 +020099 }
100
101 /* generalized GTP-C send template */
Harald Welte811651e2017-08-05 15:25:06 +0200102 template PDU_GTPC ts_GTP1C_PDU(OCT1 msg_type, OCT4 teid, GTPC_PDUs pdu, uint16_t seq_nr) := {
Harald Welte94ade362017-08-04 00:36:55 +0200103 /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
104 * error if this flag is set to '1'. */
105 pn_bit := '0'B,
106 /* Sequence number flag (S) shall be set to '1'. */
107 s_bit := '1'B,
108 e_bit := '0'B,
109 spare := '0'B,
110 /* Protocol Type flag (PT) shall be set to '1'.*/
111 pt := '1'B,
112 /* Version shall be set to decimal 1 ('001'). */
113 version := '001'B,
114 messageType := msg_type,
115 lengthf := 0, /* we assume encoder overwrites this */
116 teid := teid,
117 opt_part := {
Harald Welte811651e2017-08-05 15:25:06 +0200118 sequenceNumber := int2oct(seq_nr, 2),
Harald Welte94ade362017-08-04 00:36:55 +0200119 npduNumber := '00'O,
120 nextExtHeader := '00'O,
121 gTPC_extensionHeader_List := omit
122 },
123 gtpc_pdu := pdu
124 }
125
126 /* recovery IE */
127 template Recovery_gtpc ts_Recovery(OCT1 restart_counter) := {
Harald Weltedca80052017-08-13 20:01:38 +0200128 type_gtpc := '0E'O,
129 restartCounter := restart_counter
130 }
131
132 template Recovery_gtpc tr_Recovery(template OCT1 restart_counter) := {
133 type_gtpc := '0E'O,
Harald Welte94ade362017-08-04 00:36:55 +0200134 restartCounter := restart_counter
135 }
136
137 /* template matching reception of GTP-C echo-request */
Harald Weltedca80052017-08-13 20:01:38 +0200138 template Gtp1cUnitdata tr_GTPC_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdus := ?) := {
Harald Welte94ade362017-08-04 00:36:55 +0200139 peer := peer,
Harald Weltedca80052017-08-13 20:01:38 +0200140 gtpc := tr_GTP1C_PDU(msg_type, teid, pdus)
Harald Welte94ade362017-08-04 00:36:55 +0200141 }
142
143 /* template matching reception of GTP-C echo-request */
144 template Gtp1cUnitdata tr_GTPC_PING(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoRequest, '00000000'O);
145
Harald Weltedca80052017-08-13 20:01:38 +0200146 template GTPC_PDUs tr_EchoRespPDU(template OCT1 restart_counter) := {
147 echoResponse := {
148 recovery := tr_Recovery(restart_counter),
149 private_extension_gtpc := *
150 }
151 }
152
153 /* template matching reception of GTP-C echo-response */
154 template Gtp1cUnitdata tr_GTPC_PONG(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoResponse, '00000000'O, tr_EchoRespPDU(?));
155
Harald Welte94ade362017-08-04 00:36:55 +0200156 template GTPC_PDUs ts_EchoRespPDU(OCT1 restart_counter) := {
157 echoResponse := {
Harald Weltedca80052017-08-13 20:01:38 +0200158 recovery := ts_Recovery(restart_counter),
Harald Welte94ade362017-08-04 00:36:55 +0200159 private_extension_gtpc := omit
160 }
161 }
162
163 /* master template for senidng a GTP-C echo response */
Harald Welte811651e2017-08-05 15:25:06 +0200164 template Gtp1cUnitdata ts_GTPC_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
Harald Welte94ade362017-08-04 00:36:55 +0200165 peer := peer,
Harald Welte811651e2017-08-05 15:25:06 +0200166 gtpc := ts_GTP1C_PDU(echoResponse, '00000000'O, valueof(ts_EchoRespPDU(rest_ctr)), seq)
Harald Welte94ade362017-08-04 00:36:55 +0200167 }
168
Harald Weltedca80052017-08-13 20:01:38 +0200169 template GTPC_PDUs ts_EchoReqPDU := {
170 echoRequest := {
171 private_extension_gtpc := omit
172 }
173 }
174
175 /* master template for sending a GTP-C echo request */
176 template Gtp1cUnitdata ts_GTPC_PING(GtpPeer peer, uint16_t seq) := {
177 peer := peer,
178 gtpc := ts_GTP1C_PDU(echoRequest, '00000000'O, valueof(ts_EchoReqPDU), seq)
179 }
180
Harald Welte94ade362017-08-04 00:36:55 +0200181 template EndUserAddress t_EuaIPv4(template OCT4 ip_addr) := {
182 type_gtpc := '80'O,
183 endUserAddress := {
184 endUserAddressIPv4 := {
185 lengthf := 2,
186 pdp_typeorg := '0001'B,
187 spare := '1111'B,
188 pdp_typenum := '21'O,
189 ipv4_address := ip_addr
190 }
191 }
192 }
193 template EndUserAddress t_EuaIPv4Dyn := t_EuaIPv4(omit);
Harald Welte99ef9a42017-08-14 21:42:03 +0200194 template EndUserAddress tr_EuaIPv4(template OCT4 ip_addr) modifies t_EuaIPv4 := {
195 endUserAddress := {
196 endUserAddressIPv4 := {
197 lengthf := 2+lengthof(ip_addr)
198 }
199 }
200 }
201
Harald Welte94ade362017-08-04 00:36:55 +0200202 template EndUserAddress t_EuaIPv6(template OCT16 ip_addr) := {
203 type_gtpc := '80'O,
204 endUserAddress := {
205 endUserAddressIPv6 := {
206 lengthf := 2,
207 pdp_typeorg := '0001'B,
208 spare := '1111'B,
209 pdp_typenum := '57'O,
210 ipv6_address := ip_addr
211 }
212 }
213 }
214 template EndUserAddress t_EuaIPv6Dyn := t_EuaIPv6(omit);
Harald Welte99ef9a42017-08-14 21:42:03 +0200215 template EndUserAddress tr_EuaIPv6(template OCT16 ip_addr) modifies t_EuaIPv6 := {
216 endUserAddress := {
217 endUserAddressIPv6 := {
218 lengthf := 2+lengthof(ip_addr)
219 }
220 }
221 }
Harald Welte94ade362017-08-04 00:36:55 +0200222
223 template AccessPointName ts_APN(octetstring apn) := {
224 type_gtpc := '83'O,
225 lengthf := lengthof(apn),
226 apn_value := apn
227 }
228
229 template GSN_Address_GTPC ts_GsnAddr(octetstring ip_addr) := {
230 type_gtpc := '85'O,
231 lengthf := lengthof(ip_addr),
232 addressf := ip_addr
233 }
234
235 template MSISDN ts_Msisdn(octetstring msisdn) := {
236 type_gtpc := '86'O,
237 lengthf := lengthof(msisdn),
238 msisdn := msisdn
239 }
240
241 template QualityOfServiceProfile ts_QosDefault := {
242 type_gtpc := '87'O,
243 lengthf := 4,
244 allocRetensionPrio := '00'O,
245 qos_ProfileValue := {
246 reliabilityClass := '011'B,
247 delayClass := '001'B,
248 spare1 := '00'B,
249 precedenceClass := '010'B,
250 spare2 := '0'B,
251 peakThroughput := '1001'B,
252 meanThroughput := '11111'B,
253 spare3 := '000'B,
254 deliverErroneusSDU := omit,
255 deliveryOrder := omit,
256 trafficClass := omit,
257 maxSDUSize := omit,
258 maxBitrateUplink := omit,
259 maxBitrateDownlink := omit,
260 sduErrorRatio := omit,
261 residualBER := omit,
262 trafficHandlingPriority := omit,
263 transferDelay := omit,
264 guaranteedBitRateUplink := omit,
265 guaranteedBitRateDownlink := omit,
266 sourceStatisticsDescriptor := omit,
267 signallingIndication := omit,
268 spare4 := omit,
269 maxBitrateDownlinkExt := omit,
270 guaranteedBitRateDownlinkExt := omit,
271 maxBitrateUplinkExt := omit,
272 guaranteedBitRateUplinkExt := omit
273 }
274 }
275
276 template IMSI_gtpc ts_Imsi(hexstring digits) := {
277 type_gtpc := '02'O,
278 digits := digits,
279 padding := 'F'H
280 }
281
282 template GTPC_PDUs ts_CreatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
283 BIT4 nsapi, EndUserAddress eua, octetstring apn,
284 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
Harald Welteed7a1772017-08-09 20:26:20 +0200285 octetstring msisdn, template ProtConfigOptions pco := omit) := {
Harald Welte94ade362017-08-04 00:36:55 +0200286 createPDPContextRequest := {
287 imsi := ts_Imsi(imsi),
288 rai := omit,
289 recovery := ts_Recovery(restart_ctr),
290 selectionMode := {
291 type_gtpc := '0F'O,
292 selectModeValue := '00'B,
293 spare := '111111'B
294 },
295 teidDataI := {
296 type_gtpc := '00'O,
297 teidDataI := teid_data
298 },
299 teidControlPlane := {
300 type_gtpc := '00'O,
301 teidControlPlane := teid_ctrl
302 },
303 nsapi := {
304 type_gtpc := '00'O,
305 nsapi := nsapi,
306 unused := '0000'B
307 },
308 linked_nsapi := omit,
309 charging_char := omit,
310 trace_ref := omit,
311 trace_type := omit,
312 endUserAddress := eua,
313 accessPointName := ts_APN(apn),
Harald Welteed7a1772017-08-09 20:26:20 +0200314 protConfigOptions := pco,
Harald Welte94ade362017-08-04 00:36:55 +0200315 sgsn_addr_signalling := ts_GsnAddr(sgsn_ip_sign),
316 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
317 msisdn := ts_Msisdn(msisdn),
318 qualityOfServiceProfile := ts_QosDefault,
319 tft := omit,
320 triggerId := omit,
321 omcId := omit,
322 commonFlags := omit,
323 aPN_Restriction := omit,
324 ratType := omit,
325 userLocationInformation := omit,
326 mS_TimeZone := omit,
327 imeisv := omit,
328 camelChargingInformationContainer := omit,
329 additionalTraceInfo := omit,
330 correlationID := omit,
331 evolvedAllocationRetentionPriorityI := omit,
332 extendedCommonFlags := omit,
333 userCSGInformation := omit,
334 aPN_AMBR := omit,
335 signallingPriorityIndication := omit,
336 cN_OperatorSelectionEntity := omit,
337 private_extension_gtpc := omit
338 }
339 }
340
Harald Welte811651e2017-08-05 15:25:06 +0200341 template Gtp1cUnitdata ts_GTPC_CreatePDP(GtpPeer peer, uint16_t seq, hexstring imsi,
342 OCT1 restart_ctr, OCT4 teid_data,
Harald Welte94ade362017-08-04 00:36:55 +0200343 OCT4 teid_ctrl, BIT4 nsapi, EndUserAddress eua,
344 octetstring apn, octetstring sgsn_ip_sign,
Harald Welteed7a1772017-08-09 20:26:20 +0200345 octetstring sgsn_ip_data, octetstring msisdn,
346 template ProtConfigOptions pco := omit) := {
Harald Welte94ade362017-08-04 00:36:55 +0200347 peer := peer,
348 gtpc := ts_GTP1C_PDU(createPDPContextRequest, '00000000'O,
349 valueof(ts_CreatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
350 nsapi, eua, apn, sgsn_ip_sign,
Harald Welteed7a1772017-08-09 20:26:20 +0200351 sgsn_ip_data, msisdn, pco)), seq)
352 }
353
Harald Welte99ef9a42017-08-14 21:42:03 +0200354 /* PCO send base template */
Harald Welteed7a1772017-08-09 20:26:20 +0200355 template ProtConfigOptions ts_PCO := {
356 type_gtpc := '84'O,
357 lengthf := 0,
358 configProtocol := '000'B,
359 spare := '0000'B,
360 extension0 := '1'B,
361 protocols := {}
362 }
Harald Welte99ef9a42017-08-14 21:42:03 +0200363 /* PCO receive base template */
364 template ProtConfigOptions tr_PCO := {
365 type_gtpc := '84'O,
366 lengthf := ?,
367 configProtocol := '000'B,
368 spare := ?,
369 extension0 := '1'B,
370 protocols := {}
371 }
Harald Welteed7a1772017-08-09 20:26:20 +0200372
373 template ProtConfigOptions ts_PCO_IPv6_DNS modifies ts_PCO := {
374 protocols := {
375 { protocolID := '0003'O, lengthProtoID := 0, protoIDContents := ''O }
376 }
377 }
Harald Welte99ef9a42017-08-14 21:42:03 +0200378 template ProtConfigOptions tr_PCO_IPv6_DNS_resp(template OCT16 contents) modifies tr_PCO := {
379 protocols := {
380 { protocolID := '0003'O, lengthProtoID := 16, protoIDContents := contents }
381 }
382 }
Harald Welteed7a1772017-08-09 20:26:20 +0200383
384 template ProtConfigOptions ts_PCO_IPv4_DNS_IPCP modifies ts_PCO := {
385 protocols := {
386 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := '01000010810600000000830600000000'O }
387 }
388 }
389
390 template ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := {
391 protocols := {
392 { protocolID := '000d'O, lengthProtoID := 0, protoIDContents := ''O }
393 }
Harald Welte94ade362017-08-04 00:36:55 +0200394 }
Harald Welte99ef9a42017-08-14 21:42:03 +0200395 template ProtConfigOptions tr_PCO_IPv4_DNS_CONT_resp(template OCT4 contents) modifies tr_PCO := {
396 protocols := {
397 { protocolID := '000d'O, lengthProtoID := 4, protoIDContents := contents }
398 }
399 }
400
Harald Welte94ade362017-08-04 00:36:55 +0200401
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200402 function f_teardown_ind_IE(in template BIT1 ind) return template TearDownInd {
Harald Welte811651e2017-08-05 15:25:06 +0200403/*
404 if (not isvalue(ind)) {
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200405 return omit;
406 }
Harald Welte811651e2017-08-05 15:25:06 +0200407*/
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200408 var TearDownInd ret := {
409 type_gtpc := '13'O,
410 tdInd := valueof(ind),
411 spare:= '0000000'B
412 }
413 return ret;
414 }
415
416 template GTPC_PDUs ts_DeletePdpPDU(BIT4 nsapi, template BIT1 teardown_ind) := {
417 deletePDPContextRequest := {
418 cause := omit,
419 tearDownIndicator := f_teardown_ind_IE(teardown_ind),
420 nsapi := {
421 type_gtpc := '14'O,
422 nsapi := nsapi,
423 unused := '0000'B
424 },
425 protConfigOptions := omit,
426 userLocationInformation := omit,
427 mS_TimeZone := omit,
428 extendedCommonFlags := omit,
429 uLI_Timestamp := omit,
430 private_extension_gtpc := omit
431 }
432 }
433
Harald Welte811651e2017-08-05 15:25:06 +0200434 template Gtp1cUnitdata ts_GTPC_DeletePDP(GtpPeer peer, uint16_t seq, OCT4 teid,
435 BIT4 nsapi, template BIT1 teardown_ind) := {
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200436 peer := peer,
437 gtpc := ts_GTP1C_PDU(deletePDPContextRequest, teid,
Harald Welte811651e2017-08-05 15:25:06 +0200438 valueof(ts_DeletePdpPDU(nsapi, teardown_ind)), seq)
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200439 }
440
441
Harald Welte3af89482017-08-04 16:20:23 +0200442 /* GTP-U */
443
Harald Welte231b9412017-08-09 17:16:31 +0200444 template PDU_GTPU tr_GTP1U_PDU(template OCT1 msg_type, template OCT4 teid, template GTPU_IEs ies := ?) := {
Harald Welte3af89482017-08-04 16:20:23 +0200445 pn_bit := ?,
446 s_bit := ?,
447 e_bit := ?,
448 spare := ?,
449 /* Protocol Type flag (PT) shall be set to '1' in GTP */
450 pt := '1'B,
451 /* Version shall be set to decimal 1 ('001'). */
452 version := '001'B,
453 messageType := msg_type,
454 lengthf := ?,
455 teid := teid,
456 opt_part := *,
Harald Welte231b9412017-08-09 17:16:31 +0200457 gtpu_IEs := ies
Harald Welte3af89482017-08-04 16:20:23 +0200458 }
459
460 /* generalized GTP-U send template */
Harald Welte811651e2017-08-05 15:25:06 +0200461 template PDU_GTPU ts_GTP1U_PDU(OCT1 msg_type, uint16_t seq, OCT4 teid, GTPU_IEs ies) := {
Harald Welte3af89482017-08-04 16:20:23 +0200462 /* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN
463 * flag is set to 1. */
464 pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */
465 /* If the Sequence Number flag (S) is set to '1' the sequence number field is present and
466 * meaningful otherwise it is set to '0'. For GTP-U messages Echo Request, Echo Response,
467 * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'. */
Harald Welte811651e2017-08-05 15:25:06 +0200468 s_bit := '1'B, /* we assume the encoder overwrites this if an optional part is given */
Harald Welte3af89482017-08-04 16:20:23 +0200469 /* Extension header presence */
470 e_bit := '0'B,
471 spare := '0'B,
472 /* Protocol Type flag (PT) shall be set to '1' in GTP */
473 pt := '1'B,
474 /* Version shall be set to decimal 1 ('001'). */
475 version := '001'B,
476 messageType := msg_type,
477 lengthf := 0, /* we assume encoder overwrites this */
478 teid := teid,
Harald Welte811651e2017-08-05 15:25:06 +0200479 opt_part := {
480 sequenceNumber := int2oct(seq, 2),
481 npduNumber := '00'O,
482 nextExtHeader := '00'O,
483 gTPU_extensionHeader_List := omit
484 },
Harald Welte3af89482017-08-04 16:20:23 +0200485 gtpu_IEs := ies
486 }
487
488 template Gtp1uUnitdata tr_GTPU_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid) := {
489 peer := peer,
490 gtpu := tr_GTP1U_PDU(msg_type, teid)
491 }
492
493
Harald Welte231b9412017-08-09 17:16:31 +0200494 /* template matching reception of GTP-U echo-request */
Harald Welte3af89482017-08-04 16:20:23 +0200495 template Gtp1uUnitdata tr_GTPU_PING(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoRequest, '00000000'O);
496
Harald Welte231b9412017-08-09 17:16:31 +0200497 /* template matching reception of GTP-U GPDU */
498 template GTPU_IEs t_GPDU(template octetstring data) := {
499 g_PDU_IEs := {
500 data := data
501 }
502 }
503 template Gtp1uUnitdata tr_GTPU_GPDU(template GtpPeer peer, template OCT4 teid, template octetstring data := ?) := {
504 peer := peer,
505 gtpu := tr_GTP1U_PDU('FF'O, teid, t_GPDU(data))
506 }
507
Harald Welte3af89482017-08-04 16:20:23 +0200508 template GTPU_IEs ts_UEchoRespPDU(OCT1 restart_counter) := {
509 echoResponse_IEs := {
510 recovery_gtpu := {
511 type_gtpu := '00'O, /* we assume encoder fixes? */
512 restartCounter := restart_counter
513 },
514 private_extension_gtpu := omit
515 }
516 }
517
518 /* master template for sending a GTP-U echo response */
Harald Welte811651e2017-08-05 15:25:06 +0200519 template Gtp1uUnitdata ts_GTPU_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
Harald Welte3af89482017-08-04 16:20:23 +0200520 peer := peer,
Harald Welte811651e2017-08-05 15:25:06 +0200521 gtpu := ts_GTP1U_PDU(echoResponse, seq, '00000000'O, valueof(ts_UEchoRespPDU(rest_ctr)))
Harald Welte3af89482017-08-04 16:20:23 +0200522 }
523
Harald Welte811651e2017-08-05 15:25:06 +0200524 /* master template for sending a GTP-U user plane data */
525 template Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, uint16_t seq, OCT4 teid, octetstring data) := {
526 peer := peer,
527 gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }})
528 }
Harald Welte3af89482017-08-04 16:20:23 +0200529
Harald Welte94ade362017-08-04 00:36:55 +0200530 /* Altstep implementing responses to any incoming echo requests */
531 altstep pingpong() runs on GT_CT {
532 var Gtp1cUnitdata ud;
Harald Welte3af89482017-08-04 16:20:23 +0200533 var Gtp1uUnitdata udu;
Harald Welte94ade362017-08-04 00:36:55 +0200534 [] GTPC.receive(tr_GTPC_PING(?)) -> value ud {
Harald Welte811651e2017-08-05 15:25:06 +0200535 var uint16_t seq := oct2int(ud.gtpc.opt_part.sequenceNumber);
536 GTPC.send(ts_GTPC_PONG(ud.peer, seq, '00'O));
Harald Welte94ade362017-08-04 00:36:55 +0200537 repeat;
538 };
Harald Welte3af89482017-08-04 16:20:23 +0200539 [] GTPU.receive(tr_GTPU_PING(?)) -> value udu {
Harald Welte811651e2017-08-05 15:25:06 +0200540 var uint16_t seq := oct2int(udu.gtpu.opt_part.sequenceNumber);
541 GTPU.send(ts_GTPU_PONG(udu.peer, seq, '00'O));
Harald Welte3af89482017-08-04 16:20:23 +0200542 };
Harald Welte94ade362017-08-04 00:36:55 +0200543 [] T_default.timeout { setverdict(fail); };
544 }
545
Harald Welte811651e2017-08-05 15:25:06 +0200546 /* 'internet' in DNS encoding */
Harald Welteed097432017-08-13 13:28:49 +0200547 const octetstring c_ApnInternet := '08696E7465726E6574'O;
548 const octetstring c_ApnInet6 := '05696E657436'O;
549 const octetstring c_ApnInet46 := '06696E65743436'O;
Harald Welte94ade362017-08-04 00:36:55 +0200550
Harald Welte811651e2017-08-05 15:25:06 +0200551 /* return random integer between 0 and max */
552 function f_rnd_int(integer max) return integer {
553 return float2int(rnd()*int2float(max));
554 }
555
556 /* return random NSAPI */
557 function f_rnd_nsapi() return BIT4 {
558 return int2bit(f_rnd_int(16), 4);
559 }
560
561 /* return random TEI[DC] */
562 function f_rnd_tei() return OCT4 {
563 return int2oct(f_rnd_int(4294967296), 4);
564 }
565
Harald Welteed097432017-08-13 13:28:49 +0200566 /* return hexstring composed of random digits */
567 function f_rnd_hexstring(in integer len, in integer max := 15) return hexstring {
568 var integer i;
569 var hexstring ret := ''H;
570 for (i := 0; i < len; i := i + 1) {
571 ret := ret & int2hex(f_rnd_int(max), 1);
572 }
573 return ret;
574 }
575
576 /* return octetstring composed of random bytes */
577 function f_rnd_octstring(in integer len) return octetstring {
578 var integer i;
579 var octetstring ret := ''O;
580 for (i := 0; i < len; i := i + 1) {
581 ret := ret & int2oct(f_rnd_int(255), 1);
582 }
583 return ret;
584 }
585
586 function f_rnd_imsi(in hexstring prefix) return hexstring {
587 return prefix & f_rnd_hexstring(15 - lengthof(prefix), 9);
588 }
589
590 function f_rnd_msisdn(in octetstring prefix, integer len := 6) return octetstring {
591 return prefix & f_rnd_octstring(len - lengthof(prefix));
592 }
593
594
Harald Welte811651e2017-08-05 15:25:06 +0200595 /* define an (internal) representation of a PDP context */
596 template PdpContext t_DefinePDP(hexstring imsi, octetstring msisdn, octetstring apn,
597 EndUserAddress eua) := {
598 imsi := imsi,
599 msisdn := msisdn,
600 nsapi := f_rnd_nsapi(),
601 apn := apn,
Harald Welteed7a1772017-08-09 20:26:20 +0200602 pco_req := omit,
Harald Welte811651e2017-08-05 15:25:06 +0200603 eua := eua,
604 teid := f_rnd_tei(),
Harald Welte5438b9d2017-08-13 13:27:48 +0200605 teic := f_rnd_tei()
Harald Welte811651e2017-08-05 15:25:06 +0200606 }
607
608 /* send GTP-C for a given context and increment sequence number */
Harald Welte41575e92017-08-13 13:49:57 +0200609 function f_send_gtpc(in template Gtp1cUnitdata data) runs on GT_CT {
Harald Welte811651e2017-08-05 15:25:06 +0200610 GTPC.send(data);
Harald Welte5438b9d2017-08-13 13:27:48 +0200611 g_c_seq_nr := g_c_seq_nr + 1;
Harald Welte811651e2017-08-05 15:25:06 +0200612 }
613
614 /* send GTP-U for a given context and increment sequence number */
Harald Welte231b9412017-08-09 17:16:31 +0200615 function f_send_gtpu(inout PdpContext ctx, in octetstring data) runs on GT_CT {
Harald Welte5438b9d2017-08-13 13:27:48 +0200616 GTPU.send(ts_GTP1U_GPDU(g_peer_u, g_d_seq_nr, ctx.teid_remote, data));
617 g_d_seq_nr := g_d_seq_nr + 1;
Harald Welte811651e2017-08-05 15:25:06 +0200618 }
619
620 /* send a PDP context activation */
621 function f_pdp_ctx_act(inout PdpContext ctx) runs on GT_CT {
Harald Welte94ade362017-08-04 00:36:55 +0200622 var Gtp1cUnitdata ud;
Harald Welte94ade362017-08-04 00:36:55 +0200623 var default d;
624
625 log("sending CreatePDP");
Harald Welte41575e92017-08-13 13:49:57 +0200626 f_send_gtpc(ts_GTPC_CreatePDP(g_peer_c, g_c_seq_nr, ctx.imsi, g_restart_ctr,
Harald Welte811651e2017-08-05 15:25:06 +0200627 ctx.teid, ctx.teic, ctx.nsapi, ctx.eua, ctx.apn,
Harald Welteed7a1772017-08-09 20:26:20 +0200628 g_sgsn_ip_c, g_sgsn_ip_u, ctx.msisdn, ctx.pco_req));
Harald Welte94ade362017-08-04 00:36:55 +0200629 T_default.start;
Harald Welte94ade362017-08-04 00:36:55 +0200630 d := activate(pingpong());
631 alt {
Harald Welte811651e2017-08-05 15:25:06 +0200632 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, createPDPContextResponse, ctx.teic)) -> value ud {
633 var CreatePDPContextResponse cpr := ud.gtpc.gtpc_pdu.createPDPContextResponse;
634 if (cpr.cause.causevalue == '80'O) {
Harald Welte99ef9a42017-08-14 21:42:03 +0200635 /* Check if EUA type corresponds to requested type */
636 if (match(ctx.eua, t_EuaIPv4(?)) and
637 not match(cpr.endUserAddress, tr_EuaIPv4(?))){
638 setverdict(fail);
639 }
640 if (match(ctx.eua, t_EuaIPv6(?)) and
641 not match(cpr.endUserAddress, tr_EuaIPv6(?))) {
642 setverdict(fail);
643 }
644 /* Check if PCO response corresponds to request */
645 if (ispresent(ctx.pco_req)) {
646 if (match(ctx.pco_req, ts_PCO_IPv4_DNS_CONT) and
647 not match(cpr.protConfigOptions, tr_PCO_IPv4_DNS_CONT_resp(?))) {
648 log("IPv4 DNS Container requested, but missing");
649 setverdict(fail);
650 }
651 if (match(ctx.pco_req, ts_PCO_IPv6_DNS) and
652 not match(cpr.protConfigOptions, tr_PCO_IPv6_DNS_resp(?))) {
653 log("IPv6 DNS Container requested, but missing");
654 setverdict(fail);
655 }
656 }
Harald Welte811651e2017-08-05 15:25:06 +0200657 ctx.teid_remote := cpr.teidDataI.teidDataI;
658 ctx.teic_remote := cpr.teidControlPlane.teidControlPlane;
Harald Welte231b9412017-08-09 17:16:31 +0200659 ctx.eua := cpr.endUserAddress;
Harald Welteed7a1772017-08-09 20:26:20 +0200660 ctx.pco_neg := cpr.protConfigOptions;
Harald Welte94ade362017-08-04 00:36:55 +0200661 setverdict(pass);
662 } else {
663 setverdict(fail);
664 }
665 }
666 }
667 deactivate(d);
Harald Welte811651e2017-08-05 15:25:06 +0200668 T_default.stop;
Harald Welte94ade362017-08-04 00:36:55 +0200669 }
670
Harald Welte811651e2017-08-05 15:25:06 +0200671 function f_pdp_ctx_del(PdpContext ctx, template BIT1 teardown_ind) runs on GT_CT {
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200672 var Gtp1cUnitdata ud;
673 var default d;
674
Harald Welte41575e92017-08-13 13:49:57 +0200675 f_send_gtpc(ts_GTPC_DeletePDP(g_peer_c, g_c_seq_nr, ctx.teic_remote, ctx.nsapi, teardown_ind));
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200676 T_default.start;
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200677 d := activate(pingpong());
678 alt {
Harald Welte811651e2017-08-05 15:25:06 +0200679 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextResponse, ctx.teic)) -> value ud {
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200680 if (ud.gtpc.gtpc_pdu.deletePDPContextResponse.cause.causevalue == '80'O) {
681 setverdict(pass);
682 } else {
683 setverdict(fail);
684 }
685 }
686 }
687 deactivate(d);
Harald Welte811651e2017-08-05 15:25:06 +0200688 T_default.stop;
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200689 }
Harald Welte811651e2017-08-05 15:25:06 +0200690 /* IPv6 router solicitation fe80::2 -> ff02::2 from 02:88:b5:1f:25:59 */
691 const octetstring c_router_solicit := '6000000000103afffe800000000000000000000000000002ff02000000000000000000000000000285009f2b0000000001010288b51f2559'O;
692 /* IPv6 neighbor solicitation fe80::2 -> ff02::1:ff00:2 from 02:88:b5:1f:25:59 */
693 const octetstring c_neigh_solicit:= '6000000000203afffe800000000000000000000000000002ff0200000000000000000001ff00000287009f9600000000fe80000000000000000000000000000201010288b51f2559'O;
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200694
Harald Welte231b9412017-08-09 17:16:31 +0200695 /* template to generate a 'Prefix Information' ICMPv6 option */
696 template OptionField ts_ICMP6_OptPrefix(OCT16 prefix, INT1 prefix_len) := {
697 prefixInformation := {
698 typeField := 3,
699 lengthIndicator := 8,
700 prefixLength := prefix_len,
701 reserved1 := '000000'B,
702 a_Bit := '0'B,
703 l_Bit := '0'B,
704 validLifetime := oct2int('FFFFFFFF'O),
705 preferredLifetime := oct2int('FFFFFFFF'O),
706 reserved2 := '00000000'O,
707 prefix := prefix
708 }
709 }
710
711 /* template for an ICMPv6 router solicitation */
712 template PDU_ICMPv6 ts_ICMPv6_RS := {
713 routerSolicitation := {
714 typeField := 133,
715 code := 0,
716 checksum := '0000'O,
717 reserved := '00000000'O,
718 /* TODO: do we need 'Source link-layer address' ? */
719 options := omit
720 }
721 }
722
723 /* template for an ICMPv6 router advertisement */
724 template PDU_ICMPv6 ts_ICMPv6_RA(OCT16 prefix, INT1 prefix_len) := {
725 routerAdvertisement := {
726 typeField := 134,
727 code := 0,
728 checksum := '0000'O,
729 curHopLimit := ?,
730 reserved := '000000'B,
731 o_Bit := '0'B,
732 m_Bit := '0'B,
733 routerLifetime := oct2int('FFFF'O),
734 reachableTime := oct2int('FFFFFFFF'O),
735 retransTimer := oct2int('FFFFFFFF'O),
736 options := {
737 ts_ICMP6_OptPrefix(prefix, prefix_len)
738 }
739 }
740 }
741
742 template PDU_ICMPv6 ts_ICMPv6_NS(OCT16 target_addr) := {
743 neighborSolicitation := {
744 typeField := 135,
745 code := 0,
746 checksum := '0000'O,
747 reserved := '00000000'O,
748 targetAddress := target_addr,
749 /* TODO: do we need 'Source link-layer address' ? */
750 options := omit
751 }
752 }
753
754 /* derive ICMPv6 link-local address from lower 64bit of link_id */
755 /* template for receiving/matching an ICMPv6 'Prefix Information' option */
756 template OptionField tr_ICMP6_OptPrefix(template OCT16 prefix, template INT1 prefix_len) := {
757 prefixInformation := {
758 typeField := 3,
759 lengthIndicator := 4,
760 prefixLength := prefix_len,
761 reserved1 := ?,
762 a_Bit := ?,
763 l_Bit := ?,
764 validLifetime := ?,
765 preferredLifetime := ?,
766 reserved2 := ?,
767 prefix := prefix
768 }
769 }
770
771 /* template for receiving/matching an ICMPv6 router advertisement */
772 template PDU_ICMPv6 tr_ICMPv6_RA(template OCT16 prefix, template INT1 prefix_len) := {
773 routerAdvertisement := {
774 typeField := 134,
775 code := 0,
776 checksum := ?,
777 curHopLimit := ?,
778 reserved := ?,
779 o_Bit := '0'B,
780 m_Bit := '0'B,
781 routerLifetime := ?,
782 reachableTime := ?,
783 retransTimer := ?,
784 options := {
785 tr_ICMP6_OptPrefix(prefix, prefix_len)
786 }
787 }
788 }
789
790 /* template to construct IPv6_packet from input arguments, ready for use in f_IPv6_enc() */
791 template IPv6_packet ts_IP6(OCT16 srcaddr, OCT16 dstaddr, LIN1 nexthead, octetstring payload, LIN1 hlim := 255) := {
792 header := {
793 ver := 6,
794 trclass := 0,
795 flabel := 0,
796 plen := 0,
797 nexthead := nexthead,
798 hlim := hlim,
799 srcaddr := srcaddr,
800 dstaddr := dstaddr
801 },
802 ext_headers := omit,
803 payload := payload
804 }
805
806 function f_ipv6_link_local(in OCT16 link_id) return OCT16 {
807 return 'FE80000000000000'O & substr(link_id, 8, 8);
808 }
809
810 /* Compute solicited-node multicast address as per RFC4291 2.7.1 */
811 function f_ipv6_sol_node_mcast(in OCT16 addr) return OCT16 {
812 return 'FF0200000000000000000001FF'O & substr(addr, 13, 3);
813 }
814
815 /* generate and encode ICMPv6 router solicitation */
816 function f_gen_icmpv6_router_solicitation(in OCT16 link_id) return octetstring {
817 const OCT16 c_ip6_all_router_mcast := 'FF020000000000000000000000000002'O;
818 var OCT16 saddr := f_ipv6_link_local(link_id);
819
820 var octetstring tmp;
821 tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_RS), saddr, c_ip6_all_router_mcast);
822 var IPv6_packet ip6 := valueof(ts_IP6(saddr, c_ip6_all_router_mcast, 58, tmp));
823
824 return f_IPv6_enc(ip6);
825 }
826
827 /* create ICMPv6 router solicitation deriving link-id from PDP Context EUA */
828 function f_icmpv6_rs_for_pdp(in PdpContext ctx) return octetstring {
829 var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address;
830 return f_gen_icmpv6_router_solicitation(interface_id);
831 }
832
833 /* generate and encode ICMPv6 neighbor solicitation */
834 function f_gen_icmpv6_neigh_solicit(in OCT16 saddr, in OCT16 daddr, in OCT16 tgt_addr) return octetstring {
835 var octetstring tmp;
836 tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_NS(tgt_addr)), saddr, daddr);
837 var IPv6_packet ip6 := valueof(ts_IP6(saddr, daddr, 58, tmp));
838 return f_IPv6_enc(ip6);
839 }
840
841 /* generate and encode ICMPv6 neighbor solicitation for PDP Context */
842 function f_gen_icmpv6_neigh_solicit_for_pdp(in PdpContext ctx) return octetstring {
843 var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address;
844 var OCT16 link_local := f_ipv6_link_local(interface_id);
845 var OCT16 daddr := f_ipv6_sol_node_mcast(link_local);
846
847 return f_gen_icmpv6_neigh_solicit(link_local, daddr, link_local);
848 }
849
850 /* wait for GGSN to send us an ICMPv6 router advertisement */
851 function f_wait_rtr_adv(PdpContext ctx) runs on GT_CT {
852 var Gtp1uUnitdata ud;
853 T_default.start;
854 alt {
855 //'6???????????3aff'O
856 [] GTPU.receive(tr_GTPU_GPDU(g_peer_u, ?)) -> value ud {
857 var octetstring gpdu := ud.gtpu.gtpu_IEs.g_PDU_IEs.data;
858 var IPv6_packet ip6 := f_IPv6_dec(gpdu);
859 if (ip6.header.ver != 6 or ip6.header.nexthead != 58 or ip6.header.hlim != 255) {
860 repeat;
861 }
862 var PDU_ICMPv6 icmp6 := f_dec_PDU_ICMPv6(ip6.payload);
863 if (not match(icmp6, tr_ICMPv6_RA(?, 64))) {
864 repeat;
865 }
866 ctx.ip6_prefix := icmp6.routerAdvertisement.options[0].prefixInformation.prefix;
867 log("RA with /64 prefix ", ctx.ip6_prefix);
868 }
869 [] GTPU.receive(tr_GTPU_GPDU(?, ?)) { repeat; }
870 [] GTPU.receive { setverdict(fail); }
871 [] T_default.timeout { setverdict(fail); }
872 }
873 T_default.stop;
874 }
875
Harald Welte0ef285b2017-08-13 20:06:01 +0200876 /* Test IPv6 context activation for dynamic IPv6 EUA without request of IPv6 DNS */
Harald Welteed7a1772017-08-09 20:26:20 +0200877 testcase TC_pdp6_act_deact() runs on GT_CT {
Harald Welte94ade362017-08-04 00:36:55 +0200878 f_init();
Harald Welte231b9412017-08-09 17:16:31 +0200879
Harald Welteed097432017-08-13 13:28:49 +0200880 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
Harald Welte811651e2017-08-05 15:25:06 +0200881 f_pdp_ctx_act(ctx);
Harald Welteed7a1772017-08-09 20:26:20 +0200882 f_pdp_ctx_del(ctx, '1'B);
883 }
884
Harald Welte0ef285b2017-08-13 20:06:01 +0200885 /* Test IPv6 context activation for dynamic IPv6 EUA wirh request of IPv6 DNS in PCO */
Harald Welteed7a1772017-08-09 20:26:20 +0200886 testcase TC_pdp6_act_deact_pcodns() runs on GT_CT {
887 f_init();
888
Harald Welteed097432017-08-13 13:28:49 +0200889 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
Harald Welteed7a1772017-08-09 20:26:20 +0200890 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
891 f_pdp_ctx_act(ctx);
892 f_pdp_ctx_del(ctx, '1'B);
893 }
894
Harald Welte0ef285b2017-08-13 20:06:01 +0200895 /* Test PDP context activation for dynamic IPv6 EUA with IPv6 DNS in PCO and router solicitation/advertisement */
Harald Welteed7a1772017-08-09 20:26:20 +0200896 testcase TC_pdp6_act_deact_icmp6() runs on GT_CT {
897 f_init();
898
Harald Welteed097432017-08-13 13:28:49 +0200899 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
Harald Welteed7a1772017-08-09 20:26:20 +0200900 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
901 f_pdp_ctx_act(ctx);
Harald Welte231b9412017-08-09 17:16:31 +0200902
903 //f_send_gtpu(ctx, c_router_solicit);
904 //f_send_gtpu(ctx, c_neigh_solicit);
905
906 f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx));
907 f_wait_rtr_adv(ctx);
908 f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx));
909
Harald Welte811651e2017-08-05 15:25:06 +0200910 f_pdp_ctx_del(ctx, '1'B);
Harald Welte94ade362017-08-04 00:36:55 +0200911 }
912
Harald Welte0ef285b2017-08-13 20:06:01 +0200913 /* Test PDP context activation for dynamic IPv4 EUA without DNS request */
Harald Welteed7a1772017-08-09 20:26:20 +0200914 testcase TC_pdp4_act_deact() runs on GT_CT {
915 f_init();
Harald Welteed097432017-08-13 13:28:49 +0200916 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
Harald Welteed7a1772017-08-09 20:26:20 +0200917 f_pdp_ctx_act(ctx);
918 f_pdp_ctx_del(ctx, '1'B);
919 }
920
Harald Welte0ef285b2017-08-13 20:06:01 +0200921 /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in IPCP */
Harald Welteed7a1772017-08-09 20:26:20 +0200922 testcase TC_pdp4_act_deact_ipcp() runs on GT_CT {
923 f_init();
Harald Welteed097432017-08-13 13:28:49 +0200924 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
Harald Weltedca80052017-08-13 20:01:38 +0200925 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_IPCP);
Harald Welteed7a1772017-08-09 20:26:20 +0200926 f_pdp_ctx_act(ctx);
927 f_pdp_ctx_del(ctx, '1'B);
928 }
929
Harald Welte0ef285b2017-08-13 20:06:01 +0200930 /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in PCO */
Harald Welteed7a1772017-08-09 20:26:20 +0200931 testcase TC_pdp4_act_deact_pcodns() runs on GT_CT {
932 f_init();
Harald Welteed097432017-08-13 13:28:49 +0200933 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
Harald Weltedca80052017-08-13 20:01:38 +0200934 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
Harald Welteed7a1772017-08-09 20:26:20 +0200935 f_pdp_ctx_act(ctx);
936 f_pdp_ctx_del(ctx, '1'B);
937 }
938
Harald Weltedca80052017-08-13 20:01:38 +0200939 testcase TC_echo_req_resp() runs on GT_CT {
940 f_init();
941 f_send_gtpc(ts_GTPC_PING(g_peer_c, g_c_seq_nr));
942 T_default.start;
943 alt {
944 [] GTPC.receive(tr_GTPC_PONG(g_peer_c)) { setverdict(pass); };
945 [] GTPC.receive { repeat; };
946 [] T_default.timeout { setverdict(fail); }
947 }
948 T_default.stop;
949 }
950
Harald Welte94ade362017-08-04 00:36:55 +0200951 control {
Harald Welteed7a1772017-08-09 20:26:20 +0200952 execute(TC_pdp4_act_deact());
953 execute(TC_pdp4_act_deact_ipcp());
954 execute(TC_pdp4_act_deact_pcodns());
955
956 execute(TC_pdp6_act_deact());
957 execute(TC_pdp6_act_deact_pcodns());
958 execute(TC_pdp6_act_deact_icmp6());
Harald Weltedca80052017-08-13 20:01:38 +0200959
960 execute(TC_echo_req_resp());
Harald Welte94ade362017-08-04 00:36:55 +0200961 }
Harald Welte379d45a2017-08-03 09:55:15 +0200962}