blob: dd9acbcdca3c4aec7535ceba7f47a1f03e725719 [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 Welteddeecbb2017-08-18 22:53:30 +020013 import from Native_Functions all;
Harald Welte94ade362017-08-04 00:36:55 +020014
15 const integer GTP0_PORT := 3386;
16 const integer GTP1C_PORT := 2123;
17 const integer GTP1U_PORT := 2152;
Harald Welteddeecbb2017-08-18 22:53:30 +020018
19 modulepar {
20 charstring m_bind_ip_gtpc := "127.23.42.1";
21 charstring m_bind_ip_gtpu := "127.23.42.1";
22
23 charstring m_ggsn_ip_gtpc := "127.0.0.6";
24 charstring m_ggsn_ip_gtpu := "127.0.0.6";
25 }
Harald Welte94ade362017-08-04 00:36:55 +020026
Harald Welte811651e2017-08-05 15:25:06 +020027 type set PdpContext {
28 hexstring imsi,
29 octetstring msisdn optional,
30 octetstring apn,
Harald Welteed7a1772017-08-09 20:26:20 +020031 ProtConfigOptions pco_req optional,
32 ProtConfigOptions pco_neg optional,
Harald Welte811651e2017-08-05 15:25:06 +020033 EndUserAddress eua,
Harald Welte231b9412017-08-09 17:16:31 +020034 OCT16 ip6_prefix optional,
Harald Welte811651e2017-08-05 15:25:06 +020035 BIT4 nsapi,
36 /* TEI (Data) local side */
37 OCT4 teid,
38 /* TEI (Control) local side */
39 OCT4 teic,
40 /* TEI (Data) remote side */
41 OCT4 teid_remote,
42 /* TEI (Control) remote side */
Harald Welte5438b9d2017-08-13 13:27:48 +020043 OCT4 teic_remote
Harald Welte811651e2017-08-05 15:25:06 +020044 }
45
Harald Welte94ade362017-08-04 00:36:55 +020046 type component GT_CT {
47 port GTPC_PT GTPC;
48 port GTPU_PT GTPU;
49
Harald Welte0be142b2017-08-13 13:28:10 +020050 var boolean g_initialized := false;
51
Harald Welte94ade362017-08-04 00:36:55 +020052 var OCT1 g_restart_ctr := '01'O;
53 /* FIXME: unify with g_bind_ip + parse from config file */
Harald Welteddeecbb2017-08-18 22:53:30 +020054 var OCT4 g_sgsn_ip_c;
55 var OCT4 g_sgsn_ip_u;
Harald Welte94ade362017-08-04 00:36:55 +020056 /* FIXME: parse remName from config file */
Harald Welteddeecbb2017-08-18 22:53:30 +020057 var GtpPeer g_peer_c := { connId := 0, remName := m_ggsn_ip_gtpc, remPort := GTP1C_PORT };
58 var GtpPeer g_peer_u := { connId := 0, remName := m_ggsn_ip_gtpu, remPort := GTP1U_PORT };
Harald Welte94ade362017-08-04 00:36:55 +020059 timer T_default := 3.0;
Harald Welte5438b9d2017-08-13 13:27:48 +020060
61 /* next to-be-sent GTP-C sequence number */
62 var uint16_t g_c_seq_nr;
63 /* next to-be-sent GTP-U sequence number */
64 var uint16_t g_d_seq_nr;
Harald Welte94ade362017-08-04 00:36:55 +020065 }
66
67 function f_init() runs on GT_CT {
Harald Welte0be142b2017-08-13 13:28:10 +020068 if (g_initialized == true) {
69 return;
70 }
71 g_initialized := true;
72
Harald Welteddeecbb2017-08-18 22:53:30 +020073 g_sgsn_ip_c := f_inet_addr(m_bind_ip_gtpc);
74 g_sgsn_ip_u := f_inet_addr(m_bind_ip_gtpu);
75
Harald Welte94ade362017-08-04 00:36:55 +020076 var Result res;
77 map(self:GTPC, system:GTPC);
Harald Welteddeecbb2017-08-18 22:53:30 +020078 res := GTP_CodecPort_CtrlFunct.f_IPL4_listen(GTPC, m_bind_ip_gtpc, GTP1C_PORT, {udp:={}});
Harald Welte94ade362017-08-04 00:36:55 +020079 log("GTP1C ConnectionID: ", res.connId);
Harald Welte811651e2017-08-05 15:25:06 +020080 g_peer_c.connId := res.connId;
Harald Welte94ade362017-08-04 00:36:55 +020081
82 map(self:GTPU, system:GTPU);
Harald Welteddeecbb2017-08-18 22:53:30 +020083 res := GTP_CodecPort_CtrlFunct.f_GTPU_listen(GTPU, m_bind_ip_gtpu, GTP1U_PORT, {udp:={}});
Harald Welte811651e2017-08-05 15:25:06 +020084 g_peer_u.connId:= res.connId;
Harald Welte5438b9d2017-08-13 13:27:48 +020085
86 g_restart_ctr := f_rnd_octstring(1);
Harald Welte11dbc7b2017-08-13 18:57:56 +020087 g_c_seq_nr := f_rnd_int(65535);
88 g_d_seq_nr := f_rnd_int(65535);
Harald Welte94ade362017-08-04 00:36:55 +020089 }
90
91 /* generalized GTP-C receive template */
Harald Weltedca80052017-08-13 20:01:38 +020092 template PDU_GTPC tr_GTP1C_PDU(template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdu := ?) := {
Harald Welte94ade362017-08-04 00:36:55 +020093 /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
94 * error if this flag is set to '1'. */
95 pn_bit := '0'B,
96 /* Sequence number flag (S) shall be set to '1'. */
97 s_bit := '1'B,
98 e_bit := ?,
99 spare := ?,
100 /* Protocol Type flag (PT) shall be set to '1'.*/
101 pt := '1'B,
102 /* Version shall be set to decimal 1 ('001'). */
103 version := '001'B,
104 messageType := msg_type,
105 lengthf := ?,
106 teid := teid,
107 opt_part := *,
Harald Weltedca80052017-08-13 20:01:38 +0200108 gtpc_pdu := pdu
Harald Welte94ade362017-08-04 00:36:55 +0200109 }
110
111 /* generalized GTP-C send template */
Harald Welte811651e2017-08-05 15:25:06 +0200112 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 +0200113 /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
114 * error if this flag is set to '1'. */
115 pn_bit := '0'B,
116 /* Sequence number flag (S) shall be set to '1'. */
117 s_bit := '1'B,
118 e_bit := '0'B,
119 spare := '0'B,
120 /* Protocol Type flag (PT) shall be set to '1'.*/
121 pt := '1'B,
122 /* Version shall be set to decimal 1 ('001'). */
123 version := '001'B,
124 messageType := msg_type,
125 lengthf := 0, /* we assume encoder overwrites this */
126 teid := teid,
127 opt_part := {
Harald Welte811651e2017-08-05 15:25:06 +0200128 sequenceNumber := int2oct(seq_nr, 2),
Harald Welte94ade362017-08-04 00:36:55 +0200129 npduNumber := '00'O,
130 nextExtHeader := '00'O,
131 gTPC_extensionHeader_List := omit
132 },
133 gtpc_pdu := pdu
134 }
135
136 /* recovery IE */
137 template Recovery_gtpc ts_Recovery(OCT1 restart_counter) := {
Harald Weltedca80052017-08-13 20:01:38 +0200138 type_gtpc := '0E'O,
139 restartCounter := restart_counter
140 }
141
142 template Recovery_gtpc tr_Recovery(template OCT1 restart_counter) := {
143 type_gtpc := '0E'O,
Harald Welte94ade362017-08-04 00:36:55 +0200144 restartCounter := restart_counter
145 }
146
147 /* template matching reception of GTP-C echo-request */
Harald Weltedca80052017-08-13 20:01:38 +0200148 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 +0200149 peer := peer,
Harald Weltedca80052017-08-13 20:01:38 +0200150 gtpc := tr_GTP1C_PDU(msg_type, teid, pdus)
Harald Welte94ade362017-08-04 00:36:55 +0200151 }
152
153 /* template matching reception of GTP-C echo-request */
154 template Gtp1cUnitdata tr_GTPC_PING(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoRequest, '00000000'O);
155
Harald Weltedca80052017-08-13 20:01:38 +0200156 template GTPC_PDUs tr_EchoRespPDU(template OCT1 restart_counter) := {
157 echoResponse := {
158 recovery := tr_Recovery(restart_counter),
159 private_extension_gtpc := *
160 }
161 }
162
163 /* template matching reception of GTP-C echo-response */
164 template Gtp1cUnitdata tr_GTPC_PONG(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoResponse, '00000000'O, tr_EchoRespPDU(?));
165
Harald Welte94ade362017-08-04 00:36:55 +0200166 template GTPC_PDUs ts_EchoRespPDU(OCT1 restart_counter) := {
167 echoResponse := {
Harald Weltedca80052017-08-13 20:01:38 +0200168 recovery := ts_Recovery(restart_counter),
Harald Welte94ade362017-08-04 00:36:55 +0200169 private_extension_gtpc := omit
170 }
171 }
172
173 /* master template for senidng a GTP-C echo response */
Harald Welte811651e2017-08-05 15:25:06 +0200174 template Gtp1cUnitdata ts_GTPC_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
Harald Welte94ade362017-08-04 00:36:55 +0200175 peer := peer,
Harald Welte811651e2017-08-05 15:25:06 +0200176 gtpc := ts_GTP1C_PDU(echoResponse, '00000000'O, valueof(ts_EchoRespPDU(rest_ctr)), seq)
Harald Welte94ade362017-08-04 00:36:55 +0200177 }
178
Harald Weltedca80052017-08-13 20:01:38 +0200179 template GTPC_PDUs ts_EchoReqPDU := {
180 echoRequest := {
181 private_extension_gtpc := omit
182 }
183 }
184
185 /* master template for sending a GTP-C echo request */
186 template Gtp1cUnitdata ts_GTPC_PING(GtpPeer peer, uint16_t seq) := {
187 peer := peer,
188 gtpc := ts_GTP1C_PDU(echoRequest, '00000000'O, valueof(ts_EchoReqPDU), seq)
189 }
190
Harald Welte94ade362017-08-04 00:36:55 +0200191 template EndUserAddress t_EuaIPv4(template OCT4 ip_addr) := {
192 type_gtpc := '80'O,
193 endUserAddress := {
194 endUserAddressIPv4 := {
195 lengthf := 2,
196 pdp_typeorg := '0001'B,
197 spare := '1111'B,
198 pdp_typenum := '21'O,
199 ipv4_address := ip_addr
200 }
201 }
202 }
203 template EndUserAddress t_EuaIPv4Dyn := t_EuaIPv4(omit);
Harald Welte99ef9a42017-08-14 21:42:03 +0200204 template EndUserAddress tr_EuaIPv4(template OCT4 ip_addr) modifies t_EuaIPv4 := {
205 endUserAddress := {
206 endUserAddressIPv4 := {
Harald Weltebb5a19e2017-09-21 22:50:41 +0800207 lengthf := 2+lengthof(ip_addr)
Harald Welte99ef9a42017-08-14 21:42:03 +0200208 }
209 }
210 }
211
Harald Welte94ade362017-08-04 00:36:55 +0200212 template EndUserAddress t_EuaIPv6(template OCT16 ip_addr) := {
213 type_gtpc := '80'O,
214 endUserAddress := {
215 endUserAddressIPv6 := {
216 lengthf := 2,
217 pdp_typeorg := '0001'B,
218 spare := '1111'B,
219 pdp_typenum := '57'O,
220 ipv6_address := ip_addr
221 }
222 }
223 }
224 template EndUserAddress t_EuaIPv6Dyn := t_EuaIPv6(omit);
Harald Welte99ef9a42017-08-14 21:42:03 +0200225 template EndUserAddress tr_EuaIPv6(template OCT16 ip_addr) modifies t_EuaIPv6 := {
226 endUserAddress := {
227 endUserAddressIPv6 := {
228 lengthf := 2+lengthof(ip_addr)
229 }
230 }
231 }
Harald Welte94ade362017-08-04 00:36:55 +0200232
233 template AccessPointName ts_APN(octetstring apn) := {
234 type_gtpc := '83'O,
235 lengthf := lengthof(apn),
236 apn_value := apn
237 }
238
239 template GSN_Address_GTPC ts_GsnAddr(octetstring ip_addr) := {
240 type_gtpc := '85'O,
241 lengthf := lengthof(ip_addr),
242 addressf := ip_addr
243 }
244
245 template MSISDN ts_Msisdn(octetstring msisdn) := {
246 type_gtpc := '86'O,
247 lengthf := lengthof(msisdn),
248 msisdn := msisdn
249 }
250
251 template QualityOfServiceProfile ts_QosDefault := {
252 type_gtpc := '87'O,
253 lengthf := 4,
254 allocRetensionPrio := '00'O,
255 qos_ProfileValue := {
256 reliabilityClass := '011'B,
257 delayClass := '001'B,
258 spare1 := '00'B,
259 precedenceClass := '010'B,
260 spare2 := '0'B,
261 peakThroughput := '1001'B,
262 meanThroughput := '11111'B,
263 spare3 := '000'B,
264 deliverErroneusSDU := omit,
265 deliveryOrder := omit,
266 trafficClass := omit,
267 maxSDUSize := omit,
268 maxBitrateUplink := omit,
269 maxBitrateDownlink := omit,
270 sduErrorRatio := omit,
271 residualBER := omit,
272 trafficHandlingPriority := omit,
273 transferDelay := omit,
274 guaranteedBitRateUplink := omit,
275 guaranteedBitRateDownlink := omit,
276 sourceStatisticsDescriptor := omit,
277 signallingIndication := omit,
278 spare4 := omit,
279 maxBitrateDownlinkExt := omit,
280 guaranteedBitRateDownlinkExt := omit,
281 maxBitrateUplinkExt := omit,
282 guaranteedBitRateUplinkExt := omit
283 }
284 }
285
286 template IMSI_gtpc ts_Imsi(hexstring digits) := {
287 type_gtpc := '02'O,
288 digits := digits,
289 padding := 'F'H
290 }
291
292 template GTPC_PDUs ts_CreatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
293 BIT4 nsapi, EndUserAddress eua, octetstring apn,
294 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
Harald Welteed7a1772017-08-09 20:26:20 +0200295 octetstring msisdn, template ProtConfigOptions pco := omit) := {
Harald Welte94ade362017-08-04 00:36:55 +0200296 createPDPContextRequest := {
297 imsi := ts_Imsi(imsi),
298 rai := omit,
299 recovery := ts_Recovery(restart_ctr),
300 selectionMode := {
301 type_gtpc := '0F'O,
302 selectModeValue := '00'B,
303 spare := '111111'B
304 },
305 teidDataI := {
306 type_gtpc := '00'O,
307 teidDataI := teid_data
308 },
309 teidControlPlane := {
310 type_gtpc := '00'O,
311 teidControlPlane := teid_ctrl
312 },
313 nsapi := {
314 type_gtpc := '00'O,
315 nsapi := nsapi,
316 unused := '0000'B
317 },
318 linked_nsapi := omit,
319 charging_char := omit,
320 trace_ref := omit,
321 trace_type := omit,
322 endUserAddress := eua,
323 accessPointName := ts_APN(apn),
Harald Welteed7a1772017-08-09 20:26:20 +0200324 protConfigOptions := pco,
Harald Welte94ade362017-08-04 00:36:55 +0200325 sgsn_addr_signalling := ts_GsnAddr(sgsn_ip_sign),
326 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
327 msisdn := ts_Msisdn(msisdn),
328 qualityOfServiceProfile := ts_QosDefault,
329 tft := omit,
330 triggerId := omit,
331 omcId := omit,
332 commonFlags := omit,
333 aPN_Restriction := omit,
334 ratType := omit,
335 userLocationInformation := omit,
336 mS_TimeZone := omit,
337 imeisv := omit,
338 camelChargingInformationContainer := omit,
339 additionalTraceInfo := omit,
340 correlationID := omit,
341 evolvedAllocationRetentionPriorityI := omit,
342 extendedCommonFlags := omit,
343 userCSGInformation := omit,
344 aPN_AMBR := omit,
345 signallingPriorityIndication := omit,
346 cN_OperatorSelectionEntity := omit,
347 private_extension_gtpc := omit
348 }
349 }
350
Harald Welte811651e2017-08-05 15:25:06 +0200351 template Gtp1cUnitdata ts_GTPC_CreatePDP(GtpPeer peer, uint16_t seq, hexstring imsi,
352 OCT1 restart_ctr, OCT4 teid_data,
Harald Welte94ade362017-08-04 00:36:55 +0200353 OCT4 teid_ctrl, BIT4 nsapi, EndUserAddress eua,
354 octetstring apn, octetstring sgsn_ip_sign,
Harald Welteed7a1772017-08-09 20:26:20 +0200355 octetstring sgsn_ip_data, octetstring msisdn,
356 template ProtConfigOptions pco := omit) := {
Harald Welte94ade362017-08-04 00:36:55 +0200357 peer := peer,
358 gtpc := ts_GTP1C_PDU(createPDPContextRequest, '00000000'O,
359 valueof(ts_CreatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
360 nsapi, eua, apn, sgsn_ip_sign,
Harald Welteed7a1772017-08-09 20:26:20 +0200361 sgsn_ip_data, msisdn, pco)), seq)
362 }
363
Harald Welte99ef9a42017-08-14 21:42:03 +0200364 /* PCO send base template */
Harald Welteed7a1772017-08-09 20:26:20 +0200365 template ProtConfigOptions ts_PCO := {
366 type_gtpc := '84'O,
367 lengthf := 0,
368 configProtocol := '000'B,
369 spare := '0000'B,
370 extension0 := '1'B,
371 protocols := {}
372 }
Harald Welte99ef9a42017-08-14 21:42:03 +0200373 /* PCO receive base template */
374 template ProtConfigOptions tr_PCO := {
375 type_gtpc := '84'O,
376 lengthf := ?,
377 configProtocol := '000'B,
378 spare := ?,
379 extension0 := '1'B,
380 protocols := {}
381 }
Harald Welteed7a1772017-08-09 20:26:20 +0200382
383 template ProtConfigOptions ts_PCO_IPv6_DNS modifies ts_PCO := {
384 protocols := {
385 { protocolID := '0003'O, lengthProtoID := 0, protoIDContents := ''O }
386 }
387 }
Harald Welte99ef9a42017-08-14 21:42:03 +0200388 template ProtConfigOptions tr_PCO_IPv6_DNS_resp(template OCT16 contents) modifies tr_PCO := {
389 protocols := {
Harald Welte3ab91d62017-08-25 14:46:39 +0200390 *, { protocolID := '0003'O, lengthProtoID := 16, protoIDContents := contents }, *
Harald Welte99ef9a42017-08-14 21:42:03 +0200391 }
392 }
Harald Welteed7a1772017-08-09 20:26:20 +0200393
394 template ProtConfigOptions ts_PCO_IPv4_DNS_IPCP modifies ts_PCO := {
395 protocols := {
Harald Welteab4ca942017-09-07 18:41:52 +0200396 /* dummy PAP entry to check if our parser in the GGSN can properly iterate over
397 * the list of protocols, see Change-Id Icc2e6716c33d78d3c3e000f529806228d8aa155e */
398 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
Harald Welteed7a1772017-08-09 20:26:20 +0200399 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := '01000010810600000000830600000000'O }
400 }
401 }
402
403 template ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := {
404 protocols := {
405 { protocolID := '000d'O, lengthProtoID := 0, protoIDContents := ''O }
406 }
Harald Welte94ade362017-08-04 00:36:55 +0200407 }
Harald Welte99ef9a42017-08-14 21:42:03 +0200408 template ProtConfigOptions tr_PCO_IPv4_DNS_CONT_resp(template OCT4 contents) modifies tr_PCO := {
409 protocols := {
Harald Welte3ab91d62017-08-25 14:46:39 +0200410 *, { protocolID := '000d'O, lengthProtoID := 4, protoIDContents := contents }, *
Harald Welte99ef9a42017-08-14 21:42:03 +0200411 }
412 }
413
Harald Welte94ade362017-08-04 00:36:55 +0200414
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200415 function f_teardown_ind_IE(in template BIT1 ind) return template TearDownInd {
Harald Welte811651e2017-08-05 15:25:06 +0200416/*
417 if (not isvalue(ind)) {
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200418 return omit;
419 }
Harald Welte811651e2017-08-05 15:25:06 +0200420*/
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200421 var TearDownInd ret := {
422 type_gtpc := '13'O,
423 tdInd := valueof(ind),
424 spare:= '0000000'B
425 }
426 return ret;
427 }
428
429 template GTPC_PDUs ts_DeletePdpPDU(BIT4 nsapi, template BIT1 teardown_ind) := {
430 deletePDPContextRequest := {
431 cause := omit,
432 tearDownIndicator := f_teardown_ind_IE(teardown_ind),
433 nsapi := {
434 type_gtpc := '14'O,
435 nsapi := nsapi,
436 unused := '0000'B
437 },
438 protConfigOptions := omit,
439 userLocationInformation := omit,
440 mS_TimeZone := omit,
441 extendedCommonFlags := omit,
442 uLI_Timestamp := omit,
443 private_extension_gtpc := omit
444 }
445 }
446
Harald Welte811651e2017-08-05 15:25:06 +0200447 template Gtp1cUnitdata ts_GTPC_DeletePDP(GtpPeer peer, uint16_t seq, OCT4 teid,
448 BIT4 nsapi, template BIT1 teardown_ind) := {
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200449 peer := peer,
450 gtpc := ts_GTP1C_PDU(deletePDPContextRequest, teid,
Harald Welte811651e2017-08-05 15:25:06 +0200451 valueof(ts_DeletePdpPDU(nsapi, teardown_ind)), seq)
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200452 }
453
454
Harald Welte3af89482017-08-04 16:20:23 +0200455 /* GTP-U */
456
Harald Welte231b9412017-08-09 17:16:31 +0200457 template PDU_GTPU tr_GTP1U_PDU(template OCT1 msg_type, template OCT4 teid, template GTPU_IEs ies := ?) := {
Harald Welte3af89482017-08-04 16:20:23 +0200458 pn_bit := ?,
459 s_bit := ?,
460 e_bit := ?,
461 spare := ?,
462 /* Protocol Type flag (PT) shall be set to '1' in GTP */
463 pt := '1'B,
464 /* Version shall be set to decimal 1 ('001'). */
465 version := '001'B,
466 messageType := msg_type,
467 lengthf := ?,
468 teid := teid,
469 opt_part := *,
Harald Welte231b9412017-08-09 17:16:31 +0200470 gtpu_IEs := ies
Harald Welte3af89482017-08-04 16:20:23 +0200471 }
472
473 /* generalized GTP-U send template */
Harald Welte811651e2017-08-05 15:25:06 +0200474 template PDU_GTPU ts_GTP1U_PDU(OCT1 msg_type, uint16_t seq, OCT4 teid, GTPU_IEs ies) := {
Harald Welte3af89482017-08-04 16:20:23 +0200475 /* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN
476 * flag is set to 1. */
477 pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */
478 /* If the Sequence Number flag (S) is set to '1' the sequence number field is present and
479 * meaningful otherwise it is set to '0'. For GTP-U messages Echo Request, Echo Response,
480 * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'. */
Harald Welte811651e2017-08-05 15:25:06 +0200481 s_bit := '1'B, /* we assume the encoder overwrites this if an optional part is given */
Harald Welte3af89482017-08-04 16:20:23 +0200482 /* Extension header presence */
483 e_bit := '0'B,
484 spare := '0'B,
485 /* Protocol Type flag (PT) shall be set to '1' in GTP */
486 pt := '1'B,
487 /* Version shall be set to decimal 1 ('001'). */
488 version := '001'B,
489 messageType := msg_type,
490 lengthf := 0, /* we assume encoder overwrites this */
491 teid := teid,
Harald Welte811651e2017-08-05 15:25:06 +0200492 opt_part := {
493 sequenceNumber := int2oct(seq, 2),
494 npduNumber := '00'O,
495 nextExtHeader := '00'O,
496 gTPU_extensionHeader_List := omit
497 },
Harald Welte3af89482017-08-04 16:20:23 +0200498 gtpu_IEs := ies
499 }
500
501 template Gtp1uUnitdata tr_GTPU_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid) := {
502 peer := peer,
503 gtpu := tr_GTP1U_PDU(msg_type, teid)
504 }
505
506
Harald Welte231b9412017-08-09 17:16:31 +0200507 /* template matching reception of GTP-U echo-request */
Harald Welte3af89482017-08-04 16:20:23 +0200508 template Gtp1uUnitdata tr_GTPU_PING(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoRequest, '00000000'O);
509
Harald Welte231b9412017-08-09 17:16:31 +0200510 /* template matching reception of GTP-U GPDU */
511 template GTPU_IEs t_GPDU(template octetstring data) := {
512 g_PDU_IEs := {
513 data := data
514 }
515 }
516 template Gtp1uUnitdata tr_GTPU_GPDU(template GtpPeer peer, template OCT4 teid, template octetstring data := ?) := {
517 peer := peer,
518 gtpu := tr_GTP1U_PDU('FF'O, teid, t_GPDU(data))
519 }
520
Harald Welte3af89482017-08-04 16:20:23 +0200521 template GTPU_IEs ts_UEchoRespPDU(OCT1 restart_counter) := {
522 echoResponse_IEs := {
523 recovery_gtpu := {
524 type_gtpu := '00'O, /* we assume encoder fixes? */
525 restartCounter := restart_counter
526 },
527 private_extension_gtpu := omit
528 }
529 }
530
531 /* master template for sending a GTP-U echo response */
Harald Welte811651e2017-08-05 15:25:06 +0200532 template Gtp1uUnitdata ts_GTPU_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
Harald Welte3af89482017-08-04 16:20:23 +0200533 peer := peer,
Harald Welte811651e2017-08-05 15:25:06 +0200534 gtpu := ts_GTP1U_PDU(echoResponse, seq, '00000000'O, valueof(ts_UEchoRespPDU(rest_ctr)))
Harald Welte3af89482017-08-04 16:20:23 +0200535 }
536
Harald Welte811651e2017-08-05 15:25:06 +0200537 /* master template for sending a GTP-U user plane data */
538 template Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, uint16_t seq, OCT4 teid, octetstring data) := {
539 peer := peer,
540 gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }})
541 }
Harald Welte3af89482017-08-04 16:20:23 +0200542
Harald Welte94ade362017-08-04 00:36:55 +0200543 /* Altstep implementing responses to any incoming echo requests */
544 altstep pingpong() runs on GT_CT {
545 var Gtp1cUnitdata ud;
Harald Welte3af89482017-08-04 16:20:23 +0200546 var Gtp1uUnitdata udu;
Harald Welte94ade362017-08-04 00:36:55 +0200547 [] GTPC.receive(tr_GTPC_PING(?)) -> value ud {
Harald Welte811651e2017-08-05 15:25:06 +0200548 var uint16_t seq := oct2int(ud.gtpc.opt_part.sequenceNumber);
549 GTPC.send(ts_GTPC_PONG(ud.peer, seq, '00'O));
Harald Welte94ade362017-08-04 00:36:55 +0200550 repeat;
551 };
Harald Welte3af89482017-08-04 16:20:23 +0200552 [] GTPU.receive(tr_GTPU_PING(?)) -> value udu {
Harald Welte811651e2017-08-05 15:25:06 +0200553 var uint16_t seq := oct2int(udu.gtpu.opt_part.sequenceNumber);
554 GTPU.send(ts_GTPU_PONG(udu.peer, seq, '00'O));
Harald Welte3af89482017-08-04 16:20:23 +0200555 };
Harald Welte94ade362017-08-04 00:36:55 +0200556 [] T_default.timeout { setverdict(fail); };
557 }
558
Harald Welte811651e2017-08-05 15:25:06 +0200559 /* 'internet' in DNS encoding */
Harald Welteed097432017-08-13 13:28:49 +0200560 const octetstring c_ApnInternet := '08696E7465726E6574'O;
561 const octetstring c_ApnInet6 := '05696E657436'O;
562 const octetstring c_ApnInet46 := '06696E65743436'O;
Harald Welte94ade362017-08-04 00:36:55 +0200563
Harald Welte811651e2017-08-05 15:25:06 +0200564 /* return random integer between 0 and max */
565 function f_rnd_int(integer max) return integer {
566 return float2int(rnd()*int2float(max));
567 }
568
569 /* return random NSAPI */
570 function f_rnd_nsapi() return BIT4 {
571 return int2bit(f_rnd_int(16), 4);
572 }
573
574 /* return random TEI[DC] */
575 function f_rnd_tei() return OCT4 {
576 return int2oct(f_rnd_int(4294967296), 4);
577 }
578
Harald Welteed097432017-08-13 13:28:49 +0200579 /* return hexstring composed of random digits */
580 function f_rnd_hexstring(in integer len, in integer max := 15) return hexstring {
581 var integer i;
582 var hexstring ret := ''H;
583 for (i := 0; i < len; i := i + 1) {
584 ret := ret & int2hex(f_rnd_int(max), 1);
585 }
586 return ret;
587 }
588
589 /* return octetstring composed of random bytes */
590 function f_rnd_octstring(in integer len) return octetstring {
591 var integer i;
592 var octetstring ret := ''O;
593 for (i := 0; i < len; i := i + 1) {
594 ret := ret & int2oct(f_rnd_int(255), 1);
595 }
596 return ret;
597 }
598
599 function f_rnd_imsi(in hexstring prefix) return hexstring {
600 return prefix & f_rnd_hexstring(15 - lengthof(prefix), 9);
601 }
602
603 function f_rnd_msisdn(in octetstring prefix, integer len := 6) return octetstring {
604 return prefix & f_rnd_octstring(len - lengthof(prefix));
605 }
606
607
Harald Welte811651e2017-08-05 15:25:06 +0200608 /* define an (internal) representation of a PDP context */
609 template PdpContext t_DefinePDP(hexstring imsi, octetstring msisdn, octetstring apn,
610 EndUserAddress eua) := {
611 imsi := imsi,
612 msisdn := msisdn,
613 nsapi := f_rnd_nsapi(),
614 apn := apn,
Harald Welteed7a1772017-08-09 20:26:20 +0200615 pco_req := omit,
Harald Welte811651e2017-08-05 15:25:06 +0200616 eua := eua,
617 teid := f_rnd_tei(),
Harald Welte5438b9d2017-08-13 13:27:48 +0200618 teic := f_rnd_tei()
Harald Welte811651e2017-08-05 15:25:06 +0200619 }
620
621 /* send GTP-C for a given context and increment sequence number */
Harald Welte41575e92017-08-13 13:49:57 +0200622 function f_send_gtpc(in template Gtp1cUnitdata data) runs on GT_CT {
Harald Welte811651e2017-08-05 15:25:06 +0200623 GTPC.send(data);
Harald Welte5438b9d2017-08-13 13:27:48 +0200624 g_c_seq_nr := g_c_seq_nr + 1;
Harald Welte811651e2017-08-05 15:25:06 +0200625 }
626
627 /* send GTP-U for a given context and increment sequence number */
Harald Welte231b9412017-08-09 17:16:31 +0200628 function f_send_gtpu(inout PdpContext ctx, in octetstring data) runs on GT_CT {
Harald Welte5438b9d2017-08-13 13:27:48 +0200629 GTPU.send(ts_GTP1U_GPDU(g_peer_u, g_d_seq_nr, ctx.teid_remote, data));
630 g_d_seq_nr := g_d_seq_nr + 1;
Harald Welte811651e2017-08-05 15:25:06 +0200631 }
632
633 /* send a PDP context activation */
634 function f_pdp_ctx_act(inout PdpContext ctx) runs on GT_CT {
Harald Welte94ade362017-08-04 00:36:55 +0200635 var Gtp1cUnitdata ud;
Harald Welte94ade362017-08-04 00:36:55 +0200636 var default d;
637
638 log("sending CreatePDP");
Harald Welte41575e92017-08-13 13:49:57 +0200639 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 +0200640 ctx.teid, ctx.teic, ctx.nsapi, ctx.eua, ctx.apn,
Harald Welteed7a1772017-08-09 20:26:20 +0200641 g_sgsn_ip_c, g_sgsn_ip_u, ctx.msisdn, ctx.pco_req));
Harald Welte94ade362017-08-04 00:36:55 +0200642 T_default.start;
Harald Welte94ade362017-08-04 00:36:55 +0200643 d := activate(pingpong());
644 alt {
Harald Welte811651e2017-08-05 15:25:06 +0200645 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, createPDPContextResponse, ctx.teic)) -> value ud {
646 var CreatePDPContextResponse cpr := ud.gtpc.gtpc_pdu.createPDPContextResponse;
647 if (cpr.cause.causevalue == '80'O) {
Harald Welte99ef9a42017-08-14 21:42:03 +0200648 /* Check if EUA type corresponds to requested type */
649 if (match(ctx.eua, t_EuaIPv4(?)) and
650 not match(cpr.endUserAddress, tr_EuaIPv4(?))){
651 setverdict(fail);
652 }
653 if (match(ctx.eua, t_EuaIPv6(?)) and
654 not match(cpr.endUserAddress, tr_EuaIPv6(?))) {
655 setverdict(fail);
656 }
657 /* Check if PCO response corresponds to request */
658 if (ispresent(ctx.pco_req)) {
659 if (match(ctx.pco_req, ts_PCO_IPv4_DNS_CONT) and
660 not match(cpr.protConfigOptions, tr_PCO_IPv4_DNS_CONT_resp(?))) {
661 log("IPv4 DNS Container requested, but missing");
662 setverdict(fail);
663 }
664 if (match(ctx.pco_req, ts_PCO_IPv6_DNS) and
665 not match(cpr.protConfigOptions, tr_PCO_IPv6_DNS_resp(?))) {
666 log("IPv6 DNS Container requested, but missing");
667 setverdict(fail);
668 }
669 }
Harald Welte811651e2017-08-05 15:25:06 +0200670 ctx.teid_remote := cpr.teidDataI.teidDataI;
671 ctx.teic_remote := cpr.teidControlPlane.teidControlPlane;
Harald Welte231b9412017-08-09 17:16:31 +0200672 ctx.eua := cpr.endUserAddress;
Harald Welteed7a1772017-08-09 20:26:20 +0200673 ctx.pco_neg := cpr.protConfigOptions;
Harald Welte94ade362017-08-04 00:36:55 +0200674 setverdict(pass);
675 } else {
676 setverdict(fail);
677 }
678 }
679 }
680 deactivate(d);
Harald Welte811651e2017-08-05 15:25:06 +0200681 T_default.stop;
Harald Welte94ade362017-08-04 00:36:55 +0200682 }
683
Harald Welte811651e2017-08-05 15:25:06 +0200684 function f_pdp_ctx_del(PdpContext ctx, template BIT1 teardown_ind) runs on GT_CT {
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200685 var Gtp1cUnitdata ud;
686 var default d;
687
Harald Welte41575e92017-08-13 13:49:57 +0200688 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 +0200689 T_default.start;
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200690 d := activate(pingpong());
691 alt {
Harald Welte811651e2017-08-05 15:25:06 +0200692 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextResponse, ctx.teic)) -> value ud {
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200693 if (ud.gtpc.gtpc_pdu.deletePDPContextResponse.cause.causevalue == '80'O) {
694 setverdict(pass);
695 } else {
696 setverdict(fail);
697 }
698 }
699 }
700 deactivate(d);
Harald Welte811651e2017-08-05 15:25:06 +0200701 T_default.stop;
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200702 }
Harald Welte811651e2017-08-05 15:25:06 +0200703 /* IPv6 router solicitation fe80::2 -> ff02::2 from 02:88:b5:1f:25:59 */
704 const octetstring c_router_solicit := '6000000000103afffe800000000000000000000000000002ff02000000000000000000000000000285009f2b0000000001010288b51f2559'O;
705 /* IPv6 neighbor solicitation fe80::2 -> ff02::1:ff00:2 from 02:88:b5:1f:25:59 */
706 const octetstring c_neigh_solicit:= '6000000000203afffe800000000000000000000000000002ff0200000000000000000001ff00000287009f9600000000fe80000000000000000000000000000201010288b51f2559'O;
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200707
Harald Welte231b9412017-08-09 17:16:31 +0200708 /* template to generate a 'Prefix Information' ICMPv6 option */
709 template OptionField ts_ICMP6_OptPrefix(OCT16 prefix, INT1 prefix_len) := {
710 prefixInformation := {
711 typeField := 3,
712 lengthIndicator := 8,
713 prefixLength := prefix_len,
714 reserved1 := '000000'B,
715 a_Bit := '0'B,
716 l_Bit := '0'B,
717 validLifetime := oct2int('FFFFFFFF'O),
718 preferredLifetime := oct2int('FFFFFFFF'O),
719 reserved2 := '00000000'O,
720 prefix := prefix
721 }
722 }
723
724 /* template for an ICMPv6 router solicitation */
725 template PDU_ICMPv6 ts_ICMPv6_RS := {
726 routerSolicitation := {
727 typeField := 133,
728 code := 0,
729 checksum := '0000'O,
730 reserved := '00000000'O,
731 /* TODO: do we need 'Source link-layer address' ? */
732 options := omit
733 }
734 }
735
736 /* template for an ICMPv6 router advertisement */
737 template PDU_ICMPv6 ts_ICMPv6_RA(OCT16 prefix, INT1 prefix_len) := {
738 routerAdvertisement := {
739 typeField := 134,
740 code := 0,
741 checksum := '0000'O,
742 curHopLimit := ?,
743 reserved := '000000'B,
744 o_Bit := '0'B,
745 m_Bit := '0'B,
746 routerLifetime := oct2int('FFFF'O),
747 reachableTime := oct2int('FFFFFFFF'O),
748 retransTimer := oct2int('FFFFFFFF'O),
749 options := {
750 ts_ICMP6_OptPrefix(prefix, prefix_len)
751 }
752 }
753 }
754
755 template PDU_ICMPv6 ts_ICMPv6_NS(OCT16 target_addr) := {
756 neighborSolicitation := {
757 typeField := 135,
758 code := 0,
759 checksum := '0000'O,
760 reserved := '00000000'O,
761 targetAddress := target_addr,
762 /* TODO: do we need 'Source link-layer address' ? */
763 options := omit
764 }
765 }
766
767 /* derive ICMPv6 link-local address from lower 64bit of link_id */
768 /* template for receiving/matching an ICMPv6 'Prefix Information' option */
769 template OptionField tr_ICMP6_OptPrefix(template OCT16 prefix, template INT1 prefix_len) := {
770 prefixInformation := {
771 typeField := 3,
772 lengthIndicator := 4,
773 prefixLength := prefix_len,
774 reserved1 := ?,
775 a_Bit := ?,
776 l_Bit := ?,
777 validLifetime := ?,
778 preferredLifetime := ?,
779 reserved2 := ?,
780 prefix := prefix
781 }
782 }
783
784 /* template for receiving/matching an ICMPv6 router advertisement */
785 template PDU_ICMPv6 tr_ICMPv6_RA(template OCT16 prefix, template INT1 prefix_len) := {
786 routerAdvertisement := {
787 typeField := 134,
788 code := 0,
789 checksum := ?,
790 curHopLimit := ?,
791 reserved := ?,
792 o_Bit := '0'B,
793 m_Bit := '0'B,
794 routerLifetime := ?,
795 reachableTime := ?,
796 retransTimer := ?,
797 options := {
798 tr_ICMP6_OptPrefix(prefix, prefix_len)
799 }
800 }
801 }
802
803 /* template to construct IPv6_packet from input arguments, ready for use in f_IPv6_enc() */
804 template IPv6_packet ts_IP6(OCT16 srcaddr, OCT16 dstaddr, LIN1 nexthead, octetstring payload, LIN1 hlim := 255) := {
805 header := {
806 ver := 6,
807 trclass := 0,
808 flabel := 0,
809 plen := 0,
810 nexthead := nexthead,
811 hlim := hlim,
812 srcaddr := srcaddr,
813 dstaddr := dstaddr
814 },
815 ext_headers := omit,
816 payload := payload
817 }
818
819 function f_ipv6_link_local(in OCT16 link_id) return OCT16 {
820 return 'FE80000000000000'O & substr(link_id, 8, 8);
821 }
822
823 /* Compute solicited-node multicast address as per RFC4291 2.7.1 */
824 function f_ipv6_sol_node_mcast(in OCT16 addr) return OCT16 {
825 return 'FF0200000000000000000001FF'O & substr(addr, 13, 3);
826 }
827
828 /* generate and encode ICMPv6 router solicitation */
829 function f_gen_icmpv6_router_solicitation(in OCT16 link_id) return octetstring {
830 const OCT16 c_ip6_all_router_mcast := 'FF020000000000000000000000000002'O;
831 var OCT16 saddr := f_ipv6_link_local(link_id);
832
833 var octetstring tmp;
834 tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_RS), saddr, c_ip6_all_router_mcast);
835 var IPv6_packet ip6 := valueof(ts_IP6(saddr, c_ip6_all_router_mcast, 58, tmp));
836
837 return f_IPv6_enc(ip6);
838 }
839
840 /* create ICMPv6 router solicitation deriving link-id from PDP Context EUA */
841 function f_icmpv6_rs_for_pdp(in PdpContext ctx) return octetstring {
842 var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address;
843 return f_gen_icmpv6_router_solicitation(interface_id);
844 }
845
846 /* generate and encode ICMPv6 neighbor solicitation */
847 function f_gen_icmpv6_neigh_solicit(in OCT16 saddr, in OCT16 daddr, in OCT16 tgt_addr) return octetstring {
848 var octetstring tmp;
849 tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_NS(tgt_addr)), saddr, daddr);
850 var IPv6_packet ip6 := valueof(ts_IP6(saddr, daddr, 58, tmp));
851 return f_IPv6_enc(ip6);
852 }
853
854 /* generate and encode ICMPv6 neighbor solicitation for PDP Context */
855 function f_gen_icmpv6_neigh_solicit_for_pdp(in PdpContext ctx) return octetstring {
856 var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address;
857 var OCT16 link_local := f_ipv6_link_local(interface_id);
858 var OCT16 daddr := f_ipv6_sol_node_mcast(link_local);
859
860 return f_gen_icmpv6_neigh_solicit(link_local, daddr, link_local);
861 }
862
863 /* wait for GGSN to send us an ICMPv6 router advertisement */
864 function f_wait_rtr_adv(PdpContext ctx) runs on GT_CT {
865 var Gtp1uUnitdata ud;
866 T_default.start;
867 alt {
868 //'6???????????3aff'O
869 [] GTPU.receive(tr_GTPU_GPDU(g_peer_u, ?)) -> value ud {
870 var octetstring gpdu := ud.gtpu.gtpu_IEs.g_PDU_IEs.data;
871 var IPv6_packet ip6 := f_IPv6_dec(gpdu);
872 if (ip6.header.ver != 6 or ip6.header.nexthead != 58 or ip6.header.hlim != 255) {
873 repeat;
874 }
875 var PDU_ICMPv6 icmp6 := f_dec_PDU_ICMPv6(ip6.payload);
876 if (not match(icmp6, tr_ICMPv6_RA(?, 64))) {
877 repeat;
878 }
879 ctx.ip6_prefix := icmp6.routerAdvertisement.options[0].prefixInformation.prefix;
880 log("RA with /64 prefix ", ctx.ip6_prefix);
881 }
882 [] GTPU.receive(tr_GTPU_GPDU(?, ?)) { repeat; }
883 [] GTPU.receive { setverdict(fail); }
884 [] T_default.timeout { setverdict(fail); }
885 }
886 T_default.stop;
887 }
888
Harald Welte0ef285b2017-08-13 20:06:01 +0200889 /* Test IPv6 context activation for dynamic IPv6 EUA without request of IPv6 DNS */
Harald Welteed7a1772017-08-09 20:26:20 +0200890 testcase TC_pdp6_act_deact() runs on GT_CT {
Harald Welte94ade362017-08-04 00:36:55 +0200891 f_init();
Harald Welte231b9412017-08-09 17:16:31 +0200892
Harald Welteed097432017-08-13 13:28:49 +0200893 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 +0200894 f_pdp_ctx_act(ctx);
Harald Welteed7a1772017-08-09 20:26:20 +0200895 f_pdp_ctx_del(ctx, '1'B);
896 }
897
Harald Welte0ef285b2017-08-13 20:06:01 +0200898 /* Test IPv6 context activation for dynamic IPv6 EUA wirh request of IPv6 DNS in PCO */
Harald Welteed7a1772017-08-09 20:26:20 +0200899 testcase TC_pdp6_act_deact_pcodns() runs on GT_CT {
900 f_init();
901
Harald Welteed097432017-08-13 13:28:49 +0200902 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 +0200903 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
904 f_pdp_ctx_act(ctx);
905 f_pdp_ctx_del(ctx, '1'B);
906 }
907
Harald Welte0ef285b2017-08-13 20:06:01 +0200908 /* Test PDP context activation for dynamic IPv6 EUA with IPv6 DNS in PCO and router solicitation/advertisement */
Harald Welteed7a1772017-08-09 20:26:20 +0200909 testcase TC_pdp6_act_deact_icmp6() runs on GT_CT {
910 f_init();
911
Harald Welteed097432017-08-13 13:28:49 +0200912 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 +0200913 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
914 f_pdp_ctx_act(ctx);
Harald Welte231b9412017-08-09 17:16:31 +0200915
916 //f_send_gtpu(ctx, c_router_solicit);
917 //f_send_gtpu(ctx, c_neigh_solicit);
918
919 f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx));
920 f_wait_rtr_adv(ctx);
921 f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx));
922
Harald Welte811651e2017-08-05 15:25:06 +0200923 f_pdp_ctx_del(ctx, '1'B);
Harald Welte94ade362017-08-04 00:36:55 +0200924 }
925
Harald Welte0ef285b2017-08-13 20:06:01 +0200926 /* Test PDP context activation for dynamic IPv4 EUA without DNS request */
Harald Welteed7a1772017-08-09 20:26:20 +0200927 testcase TC_pdp4_act_deact() runs on GT_CT {
928 f_init();
Harald Welteed097432017-08-13 13:28:49 +0200929 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 +0200930 f_pdp_ctx_act(ctx);
931 f_pdp_ctx_del(ctx, '1'B);
932 }
933
Harald Welte0ef285b2017-08-13 20:06:01 +0200934 /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in IPCP */
Harald Welteed7a1772017-08-09 20:26:20 +0200935 testcase TC_pdp4_act_deact_ipcp() runs on GT_CT {
936 f_init();
Harald Welteed097432017-08-13 13:28:49 +0200937 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 +0200938 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_IPCP);
Harald Welteed7a1772017-08-09 20:26:20 +0200939 f_pdp_ctx_act(ctx);
940 f_pdp_ctx_del(ctx, '1'B);
941 }
942
Harald Welte0ef285b2017-08-13 20:06:01 +0200943 /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in PCO */
Harald Welteed7a1772017-08-09 20:26:20 +0200944 testcase TC_pdp4_act_deact_pcodns() runs on GT_CT {
945 f_init();
Harald Welteed097432017-08-13 13:28:49 +0200946 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 +0200947 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
Harald Welteed7a1772017-08-09 20:26:20 +0200948 f_pdp_ctx_act(ctx);
949 f_pdp_ctx_del(ctx, '1'B);
950 }
951
Harald Weltedca80052017-08-13 20:01:38 +0200952 testcase TC_echo_req_resp() runs on GT_CT {
953 f_init();
954 f_send_gtpc(ts_GTPC_PING(g_peer_c, g_c_seq_nr));
955 T_default.start;
956 alt {
957 [] GTPC.receive(tr_GTPC_PONG(g_peer_c)) { setverdict(pass); };
958 [] GTPC.receive { repeat; };
959 [] T_default.timeout { setverdict(fail); }
960 }
961 T_default.stop;
962 }
963
Harald Welte94ade362017-08-04 00:36:55 +0200964 control {
Harald Welteed7a1772017-08-09 20:26:20 +0200965 execute(TC_pdp4_act_deact());
966 execute(TC_pdp4_act_deact_ipcp());
967 execute(TC_pdp4_act_deact_pcodns());
968
969 execute(TC_pdp6_act_deact());
970 execute(TC_pdp6_act_deact_pcodns());
971 execute(TC_pdp6_act_deact_icmp6());
Harald Weltedca80052017-08-13 20:01:38 +0200972
973 execute(TC_echo_req_resp());
Harald Welte94ade362017-08-04 00:36:55 +0200974 }
Harald Welte379d45a2017-08-03 09:55:15 +0200975}