blob: a222b2ef601a50e39e2d6fcced184e85463cc903 [file] [log] [blame]
Harald Weltec69cf4e2018-02-17 20:57:02 +01001module GTP_Templates {
2
3 import from General_Types all;
4 import from Osmocom_Types all;
5 import from GTPC_Types all;
6 import from GTPU_Types all;
7 import from GTP_CodecPort all;
8 import from IPCP_Types all;
9
Harald Welte3b4c3562018-03-01 10:01:58 +010010 /* Table 38 of 3GPP TS 29.060 */
11 type enumerated GTP_Cause {
12 GTP_CAUSE_REQUEST_IMEI (1),
13 GTP_CAUSE_REQUEST_IMSI_AND_IMEI (2),
14 GTP_CAUSE_NO_IDENTITY_NEDED (3),
15 GTP_CAUSE_MS_REFUSES (4),
16 GTP_CAUSE_MS_IS_NOT_GPRS_RESPONDING (5),
17 /* reserved */
18 GTP_CAUSE_REQUEST_ACCEPTED (128)
19 /* FIXME */
20 };
21
Harald Weltec69cf4e2018-02-17 20:57:02 +010022 /* generalized GTP-C receive template */
23 template PDU_GTPC tr_GTP1C_PDU(template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdu := ?) := {
24 /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
25 * error if this flag is set to '1'. */
26 pn_bit := '0'B,
27 /* Sequence number flag (S) shall be set to '1'. */
28 s_bit := '1'B,
29 e_bit := ?,
30 spare := ?,
31 /* Protocol Type flag (PT) shall be set to '1'.*/
32 pt := '1'B,
33 /* Version shall be set to decimal 1 ('001'). */
34 version := '001'B,
35 messageType := msg_type,
36 lengthf := ?,
37 teid := teid,
38 opt_part := *,
39 gtpc_pdu := pdu
40 }
41
42 /* generalized GTP-C send template */
43 template PDU_GTPC ts_GTP1C_PDU(OCT1 msg_type, OCT4 teid, GTPC_PDUs pdu, uint16_t seq_nr) := {
44 /* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
45 * error if this flag is set to '1'. */
46 pn_bit := '0'B,
47 /* Sequence number flag (S) shall be set to '1'. */
48 s_bit := '1'B,
49 e_bit := '0'B,
50 spare := '0'B,
51 /* Protocol Type flag (PT) shall be set to '1'.*/
52 pt := '1'B,
53 /* Version shall be set to decimal 1 ('001'). */
54 version := '001'B,
55 messageType := msg_type,
56 lengthf := 0, /* we assume encoder overwrites this */
57 teid := teid,
58 opt_part := {
59 sequenceNumber := int2oct(seq_nr, 2),
60 npduNumber := '00'O,
61 nextExtHeader := '00'O,
62 gTPC_extensionHeader_List := omit
63 },
64 gtpc_pdu := pdu
65 }
66
67 /* recovery IE */
68 template Recovery_gtpc ts_Recovery(OCT1 restart_counter) := {
69 type_gtpc := '0E'O,
70 restartCounter := restart_counter
71 }
72
73 template Recovery_gtpc tr_Recovery(template OCT1 restart_counter) := {
74 type_gtpc := '0E'O,
75 restartCounter := restart_counter
76 }
77
78 /* template matching reception of GTP-C echo-request */
79 template Gtp1cUnitdata tr_GTPC_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdus := ?) := {
80 peer := peer,
81 gtpc := tr_GTP1C_PDU(msg_type, teid, pdus)
82 }
83
84 /* template matching reception of GTP-C echo-request */
85 template Gtp1cUnitdata tr_GTPC_PING(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoRequest, '00000000'O);
86
87 template GTPC_PDUs tr_EchoRespPDU(template OCT1 restart_counter) := {
88 echoResponse := {
89 recovery := tr_Recovery(restart_counter),
90 private_extension_gtpc := *
91 }
92 }
93
94 /* template matching reception of GTP-C echo-response */
95 template Gtp1cUnitdata tr_GTPC_PONG(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoResponse, '00000000'O, tr_EchoRespPDU(?));
96
97 template GTPC_PDUs ts_EchoRespPDU(OCT1 restart_counter) := {
98 echoResponse := {
99 recovery := ts_Recovery(restart_counter),
100 private_extension_gtpc := omit
101 }
102 }
103
104 /* master template for senidng a GTP-C echo response */
105 template Gtp1cUnitdata ts_GTPC_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
106 peer := peer,
107 gtpc := ts_GTP1C_PDU(echoResponse, '00000000'O, valueof(ts_EchoRespPDU(rest_ctr)), seq)
108 }
109
110 template GTPC_PDUs ts_EchoReqPDU := {
111 echoRequest := {
112 private_extension_gtpc := omit
113 }
114 }
115
116 /* master template for sending a GTP-C echo request */
117 template Gtp1cUnitdata ts_GTPC_PING(GtpPeer peer, uint16_t seq) := {
118 peer := peer,
119 gtpc := ts_GTP1C_PDU(echoRequest, '00000000'O, valueof(ts_EchoReqPDU), seq)
120 }
121
122 template EndUserAddress t_EuaIPv4(template OCT4 ip_addr) := {
123 type_gtpc := '80'O,
124 endUserAddress := {
125 endUserAddressIPv4 := {
126 lengthf := 2,
127 pdp_typeorg := '0001'B,
128 spare := '1111'B,
129 pdp_typenum := '21'O,
130 ipv4_address := ip_addr
131 }
132 }
133 }
134 template EndUserAddress t_EuaIPv4Dyn := t_EuaIPv4(omit);
135 template EndUserAddress tr_EuaIPv4(template OCT4 ip_addr) modifies t_EuaIPv4 := {
136 endUserAddress := {
137 endUserAddressIPv4 := {
138 lengthf := 2+lengthof(ip_addr)
139 }
140 }
141 }
142
143 template EndUserAddress t_EuaIPv6(template OCT16 ip_addr) := {
144 type_gtpc := '80'O,
145 endUserAddress := {
146 endUserAddressIPv6 := {
147 lengthf := 2,
148 pdp_typeorg := '0001'B,
149 spare := '1111'B,
150 pdp_typenum := '57'O,
151 ipv6_address := ip_addr
152 }
153 }
154 }
155 template EndUserAddress t_EuaIPv6Dyn := t_EuaIPv6(omit);
156 template EndUserAddress tr_EuaIPv6(template OCT16 ip_addr) modifies t_EuaIPv6 := {
157 endUserAddress := {
158 endUserAddressIPv6 := {
159 lengthf := 2+lengthof(ip_addr)
160 }
161 }
162 }
163
164 template AccessPointName ts_APN(octetstring apn) := {
165 type_gtpc := '83'O,
166 lengthf := lengthof(apn),
167 apn_value := apn
168 }
169
170 template GSN_Address_GTPC ts_GsnAddr(octetstring ip_addr) := {
171 type_gtpc := '85'O,
172 lengthf := lengthof(ip_addr),
173 addressf := ip_addr
174 }
175
176 template MSISDN ts_Msisdn(octetstring msisdn) := {
177 type_gtpc := '86'O,
178 lengthf := lengthof(msisdn),
179 msisdn := msisdn
180 }
181
182 template QualityOfServiceProfile ts_QosDefault := {
183 type_gtpc := '87'O,
184 lengthf := 4,
185 allocRetensionPrio := '00'O,
186 qos_ProfileValue := {
187 reliabilityClass := '011'B,
188 delayClass := '001'B,
189 spare1 := '00'B,
190 precedenceClass := '010'B,
191 spare2 := '0'B,
192 peakThroughput := '1001'B,
193 meanThroughput := '11111'B,
194 spare3 := '000'B,
195 deliverErroneusSDU := omit,
196 deliveryOrder := omit,
197 trafficClass := omit,
198 maxSDUSize := omit,
199 maxBitrateUplink := omit,
200 maxBitrateDownlink := omit,
201 sduErrorRatio := omit,
202 residualBER := omit,
203 trafficHandlingPriority := omit,
204 transferDelay := omit,
205 guaranteedBitRateUplink := omit,
206 guaranteedBitRateDownlink := omit,
207 sourceStatisticsDescriptor := omit,
208 signallingIndication := omit,
209 spare4 := omit,
210 maxBitrateDownlinkExt := omit,
211 guaranteedBitRateDownlinkExt := omit,
212 maxBitrateUplinkExt := omit,
213 guaranteedBitRateUplinkExt := omit
214 }
215 }
216
217 template IMSI_gtpc ts_Imsi(hexstring digits) := {
218 type_gtpc := '02'O,
219 digits := digits,
220 padding := 'F'H
221 }
222
223 template GTPC_PDUs ts_CreatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
224 BIT4 nsapi, EndUserAddress eua, octetstring apn,
225 octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
226 octetstring msisdn, template ProtConfigOptions pco := omit) := {
227 createPDPContextRequest := {
228 imsi := ts_Imsi(imsi),
229 rai := omit,
230 recovery := ts_Recovery(restart_ctr),
231 selectionMode := {
232 type_gtpc := '0F'O,
233 selectModeValue := '00'B,
234 spare := '111111'B
235 },
236 teidDataI := {
237 type_gtpc := '00'O,
238 teidDataI := teid_data
239 },
240 teidControlPlane := {
241 type_gtpc := '00'O,
242 teidControlPlane := teid_ctrl
243 },
244 nsapi := {
245 type_gtpc := '00'O,
246 nsapi := nsapi,
247 unused := '0000'B
248 },
249 linked_nsapi := omit,
250 charging_char := omit,
251 trace_ref := omit,
252 trace_type := omit,
253 endUserAddress := eua,
254 accessPointName := ts_APN(apn),
255 protConfigOptions := pco,
256 sgsn_addr_signalling := ts_GsnAddr(sgsn_ip_sign),
257 sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
258 msisdn := ts_Msisdn(msisdn),
259 qualityOfServiceProfile := ts_QosDefault,
260 tft := omit,
261 triggerId := omit,
262 omcId := omit,
263 commonFlags := omit,
264 aPN_Restriction := omit,
265 ratType := omit,
266 userLocationInformation := omit,
267 mS_TimeZone := omit,
268 imeisv := omit,
269 camelChargingInformationContainer := omit,
270 additionalTraceInfo := omit,
271 correlationID := omit,
272 evolvedAllocationRetentionPriorityI := omit,
273 extendedCommonFlags := omit,
274 userCSGInformation := omit,
275 aPN_AMBR := omit,
276 signallingPriorityIndication := omit,
277 cN_OperatorSelectionEntity := omit,
278 private_extension_gtpc := omit
279 }
280 }
281
282 template Gtp1cUnitdata ts_GTPC_CreatePDP(GtpPeer peer, uint16_t seq, hexstring imsi,
283 OCT1 restart_ctr, OCT4 teid_data,
284 OCT4 teid_ctrl, BIT4 nsapi, EndUserAddress eua,
285 octetstring apn, octetstring sgsn_ip_sign,
286 octetstring sgsn_ip_data, octetstring msisdn,
287 template ProtConfigOptions pco := omit) := {
288 peer := peer,
289 gtpc := ts_GTP1C_PDU(createPDPContextRequest, '00000000'O,
290 valueof(ts_CreatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
291 nsapi, eua, apn, sgsn_ip_sign,
292 sgsn_ip_data, msisdn, pco)), seq)
293 }
294
Harald Welteeded9ad2018-02-17 20:57:34 +0100295
296 template NSAPI_GTPC ts_NSAPI(BIT4 nsapi) := {
297 type_gtpc := '14'O,
298 nsapi := nsapi,
299 unused := '0000'B
300 }
301
302 template ReorderingRequired ts_ReorderReq(boolean req := false) := {
303 type_gtpc := '08'O,
304 reordreq := bool2bit(req),
305 spare := '0000000'B
306 }
307
308 template GTPC_PDUs ts_CreatePdpRespPDU(OCT1 cause, OCT4 teid_data, OCT4 teid_ctrl, BIT4 nsapi,
309 octetstring ggsn_ip_sign, octetstring ggsn_ip_data,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100310 OCT4 chg_id, template EndUserAddress eua := omit,
Harald Welteeded9ad2018-02-17 20:57:34 +0100311 template ProtConfigOptions pco := omit) := {
312 createPDPContextResponse := {
313 cause := { '00'O, cause },
314 reorderingRequired := ts_ReorderReq(false),
315 recovery := omit,
316 teidDataI := {
317 type_gtpc := '00'O,
318 teidDataI := teid_data
319 },
320 teidControlPlane := {
321 type_gtpc := '00'O,
322 teidControlPlane := teid_ctrl
323 },
324 nsapi := ts_NSAPI(nsapi),
Harald Welte7aff2ca2018-02-18 15:34:50 +0100325 chargingID := {
326 type_gtpc := '7F'O,
327 chargingID := chg_id
328 },
Harald Welteeded9ad2018-02-17 20:57:34 +0100329 endUserAddress := eua,
330 protConfigOptions := pco,
331 ggsn_addr_controlPlane := ts_GsnAddr(ggsn_ip_sign),
332 ggsn_addr_traffic := ts_GsnAddr(ggsn_ip_data),
333 alt_ggsn_addr_controlPane := omit,
334 alt_ggsn_addr_traffic := omit,
335 qualityOfServiceProfile := ts_QosDefault,
336 commonFlags := omit,
337 aPN_Restriction := omit,
338 mS_InfoChangeReportingAction := omit,
339 bearerControlMode := omit,
340 evolvedAllocationRetentionPriorityI := omit,
341 extendedCommonFlag := omit,
342 csg_information_reporting_action := omit,
343 aPN_AMBR := omit,
344 gGSN_BackOffTime := omit,
345 private_extension_gtpc := omit
346 }
347 }
348
349 template Gtp1cUnitdata ts_GTPC_CreatePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
350 OCT1 cause,
351 OCT4 teid_ctrl, OCT4 teid_data,
352 BIT4 nsapi, octetstring ggsn_ip_sign,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100353 octetstring ggsn_ip_data, OCT4 chg_id,
Harald Welteeded9ad2018-02-17 20:57:34 +0100354 template EndUserAddress eua := omit,
355 template ProtConfigOptions pco := omit) := {
356 peer := peer,
357 gtpc := ts_GTP1C_PDU(createPDPContextResponse, teid,
358 valueof(ts_CreatePdpRespPDU(cause, teid_data, teid_ctrl, nsapi,
Harald Welte7aff2ca2018-02-18 15:34:50 +0100359 ggsn_ip_sign, ggsn_ip_data, chg_id,
Harald Welteeded9ad2018-02-17 20:57:34 +0100360 eua, pco)), seq)
361 }
362
Harald Weltec69cf4e2018-02-17 20:57:02 +0100363 /* PCO send base template */
364 template ProtConfigOptions ts_PCO := {
365 type_gtpc := '84'O,
366 lengthf := 0,
367 configProtocol := '000'B,
368 spare := '0000'B,
369 extension0 := '1'B,
370 protocols := {}
371 }
372 /* PCO receive base template */
373 template ProtConfigOptions tr_PCO := {
374 type_gtpc := '84'O,
375 lengthf := ?,
376 configProtocol := '000'B,
377 spare := ?,
378 extension0 := '1'B,
379 protocols := {}
380 }
381
382 template ProtConfigOptions ts_PCO_IPv6_DNS modifies ts_PCO := {
383 protocols := {
384 { protocolID := '0003'O, lengthProtoID := 0, protoIDContents := ''O }
385 }
386 }
387 template ProtConfigOptions tr_PCO_IPv6_DNS_resp(template OCT16 contents) modifies tr_PCO := {
388 protocols := {
389 *, { protocolID := '0003'O, lengthProtoID := 16, protoIDContents := contents }, *
390 }
391 }
392
393 template ProtConfigOptions ts_PCO_IPv4_DNS_IPCP modifies ts_PCO := {
394 protocols := {
395 /* dummy PAP entry to check if our parser in the GGSN can properly iterate over
396 * the list of protocols, see Change-Id Icc2e6716c33d78d3c3e000f529806228d8aa155e */
397 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
398 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
399 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
400 }
401 }
402
Philipp Maier33e52612018-05-30 17:22:02 +0200403 template ProtConfigOptions ts_PCO_IPv4_PRI_DNS_IPCP modifies ts_PCO := {
404 protocols := {
405 /* dummy PAP entry to check if our parser can cope with a single primary DNS entry
406 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
407 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
408 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
409 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) }
410 }
411 }
412 template ProtConfigOptions ts_PCO_IPv4_SEC_DNS_IPCP modifies ts_PCO := {
413 protocols := {
414 /* dummy PAP entry to check if our parser can cope with a single secondary DNS entry
415 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
416 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
417 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
418 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
419 }
420 }
421 template ProtConfigOptions ts_PCO_IPv4_SEPARATE_DNS_IPCP modifies ts_PCO := {
422 protocols := {
423 /* dummy PAP entry to check if our parser can cope with a primary and secondary DNS
424 * in separate IPCP containers OS#3381 */
425 { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
426 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
427 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) },
428 { protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
429 enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
430 }
431 }
432
Harald Weltec69cf4e2018-02-17 20:57:02 +0100433 template ProtocolElement tr_PCO_Proto(OCT2 prot_id) := {
434 protocolID := prot_id,
435 lengthProtoID := ?,
436 protoIDContents := ?
437 }
438 template ProtConfigOptions tr_PCO_Contains(OCT2 prot_id) modifies tr_PCO := {
439 protocols := { *, tr_PCO_Proto(prot_id), * }
440 }
441
442 template ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := {
443 protocols := {
444 { protocolID := '000d'O, lengthProtoID := 0, protoIDContents := ''O }
445 }
446 }
447 template ProtConfigOptions tr_PCO_IPv4_DNS_CONT_resp(template OCT4 contents) modifies tr_PCO := {
448 protocols := {
449 *, { protocolID := '000d'O, lengthProtoID := 4, protoIDContents := contents }, *
450 }
451 }
452
453 /* extract a given protocol payload from PCO */
454 function f_PCO_extract_proto(ProtConfigOptions pco, OCT2 protocol, integer nth_match := 1) return octetstring {
455 var integer i;
456 var integer num_matches := 0;
457 for (i := 0; i < lengthof(pco.protocols); i := i + 1) {
458 if (pco.protocols[i].protocolID == protocol) {
459 num_matches := num_matches + 1;
460 if (num_matches == nth_match) {
461 return pco.protocols[i].protoIDContents;
462 }
463 }
464 }
465 setverdict(fail);
466 return ''O;
467 }
468
469 template IpcpPacket tr_IPCP(template LcpCode code, template uint8_t identifier,
470 template IpcpOptionList opts) := {
471 code := code,
472 identifier := identifier,
473 len := ?,
474 options := opts
475 }
476 template IpcpOption tr_IPCP_PrimaryDns(template OCT4 addr) := {
477 code := IPCP_OPT_PrimaryDNS,
478 len := 6,
479 data := addr
480 }
481 template IpcpOption tr_IPCP_SecondaryDns(template OCT4 addr) := {
482 code := IPCP_OPT_SecondaryDNS,
483 len := 6,
484 data := addr
485 }
486 template IpcpPacket tr_IPCP_Ack_DNS(template uint8_t identifier := ?, template OCT4 dns1 := ?,
487 template OCT4 dns2 := ?) :=
488 tr_IPCP(LCP_Configure_Ack, identifier,
489 { *, tr_IPCP_PrimaryDns(dns1), *, tr_IPCP_SecondaryDns(dns2), * });
490
491 template IpcpPacket ts_IPCP(LcpCode code, uint8_t identifier, template IpcpOptionList opts) := {
492 code := code,
493 identifier := identifier,
494 len := 0, /* overwritten */
495 options := opts
496 }
497 template IpcpPacket ts_IPCP_ReqDNS(uint8_t identifier := 0) :=
498 ts_IPCP(LCP_Configure_Request, identifier,
499 { tr_IPCP_PrimaryDns('00000000'O), tr_IPCP_SecondaryDns('00000000'O) });
500
Philipp Maier33e52612018-05-30 17:22:02 +0200501 template IpcpPacket ts_IPCP_ReqDNS_Primary(uint8_t identifier := 0) :=
502 ts_IPCP(LCP_Configure_Request, identifier,
503 { tr_IPCP_PrimaryDns('00000000'O) });
504 template IpcpPacket ts_IPCP_ReqDNS_Secondary(uint8_t identifier := 0) :=
505 ts_IPCP(LCP_Configure_Request, identifier,
506 { tr_IPCP_SecondaryDns('00000000'O) });
507
Harald Welte57b9b7f2018-02-18 22:28:13 +0100508 function f_teardown_ind_IE(in template (omit) BIT1 ind) return template (omit) TearDownInd {
509 if (istemplatekind(ind, "omit")) {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100510 return omit;
511 }
Harald Weltec69cf4e2018-02-17 20:57:02 +0100512 var TearDownInd ret := {
513 type_gtpc := '13'O,
514 tdInd := valueof(ind),
515 spare:= '0000000'B
516 }
517 return ret;
518 }
519
Harald Welte57b9b7f2018-02-18 22:28:13 +0100520 template GTPC_PDUs ts_DeletePdpPDU(BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100521 deletePDPContextRequest := {
522 cause := omit,
523 tearDownIndicator := f_teardown_ind_IE(teardown_ind),
524 nsapi := {
525 type_gtpc := '14'O,
526 nsapi := nsapi,
527 unused := '0000'B
528 },
529 protConfigOptions := omit,
530 userLocationInformation := omit,
531 mS_TimeZone := omit,
532 extendedCommonFlags := omit,
533 uLI_Timestamp := omit,
534 private_extension_gtpc := omit
535 }
536 }
537
538 template Gtp1cUnitdata ts_GTPC_DeletePDP(GtpPeer peer, uint16_t seq, OCT4 teid,
Harald Welte57b9b7f2018-02-18 22:28:13 +0100539 BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100540 peer := peer,
541 gtpc := ts_GTP1C_PDU(deletePDPContextRequest, teid,
542 valueof(ts_DeletePdpPDU(nsapi, teardown_ind)), seq)
543 }
544
Harald Welte6f203162018-02-18 22:04:55 +0100545 template GTPC_PDUs ts_DeletePdpRespPDU(OCT1 cause,
546 template ProtConfigOptions pco := omit) := {
547 deletePDPContextResponse := {
548 cause := { '00'O, cause },
549 protConfigOptions := pco,
550 userLocationInformation := omit,
551 mS_TimeZone := omit,
552 uLI_Timestamp := omit,
553 private_extension_gtpc := omit
554 }
555 }
556
557 template Gtp1cUnitdata ts_GTPC_DeletePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
558 OCT1 cause,
559 template ProtConfigOptions pco := omit) := {
560 peer := peer,
561 gtpc := ts_GTP1C_PDU(deletePDPContextResponse, teid,
562 valueof(ts_DeletePdpRespPDU(cause, pco)), seq)
563 }
564
565
Harald Weltec69cf4e2018-02-17 20:57:02 +0100566
567 /* GTP-U */
568
569 template PDU_GTPU tr_GTP1U_PDU(template OCT1 msg_type, template OCT4 teid, template GTPU_IEs ies := ?) := {
570 pn_bit := ?,
571 s_bit := ?,
572 e_bit := ?,
573 spare := ?,
574 /* Protocol Type flag (PT) shall be set to '1' in GTP */
575 pt := '1'B,
576 /* Version shall be set to decimal 1 ('001'). */
577 version := '001'B,
578 messageType := msg_type,
579 lengthf := ?,
580 teid := teid,
581 opt_part := *,
582 gtpu_IEs := ies
583 }
584
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200585 function f_GTPU_s_bit(template (omit) uint16_t seq) return BIT1 {
586 if (istemplatekind(seq, "omit")) {
587 return '0'B;
588 }
589 return '1'B;
590 }
591
592 function f_GTPU_opt_part(template (omit) uint16_t seq) return template (omit) GTPU_Header_optional_part {
593 if (istemplatekind(seq, "omit")) {
594 return omit;
595 }
596 var GTPU_Header_optional_part ret := {
597 sequenceNumber := int2oct(valueof(seq), 2),
598 npduNumber := '00'O,
599 nextExtHeader := '00'O,
600 gTPU_extensionHeader_List := omit
601 };
602 return ret;
603 }
604
Harald Weltec69cf4e2018-02-17 20:57:02 +0100605 /* generalized GTP-U send template */
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200606 template PDU_GTPU ts_GTP1U_PDU(OCT1 msg_type, template (omit) uint16_t seq, OCT4 teid, GTPU_IEs ies) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100607 /* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN
608 * flag is set to 1. */
609 pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */
610 /* If the Sequence Number flag (S) is set to '1' the sequence number field is present and
611 * meaningful otherwise it is set to '0'. For GTP-U messages Echo Request, Echo Response,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200612 * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'.
613 *
614 * Note that the caller must ensure that these conditions hold.
615 * The caller can either pass a sequence number (we set s_bit to '1'B) when appropriate,
616 * or may omit the sequence number (we set s_bit to '0'B). */
617 s_bit := f_GTPU_s_bit(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +0100618 /* Extension header presence */
619 e_bit := '0'B,
620 spare := '0'B,
621 /* Protocol Type flag (PT) shall be set to '1' in GTP */
622 pt := '1'B,
623 /* Version shall be set to decimal 1 ('001'). */
624 version := '001'B,
625 messageType := msg_type,
626 lengthf := 0, /* we assume encoder overwrites this */
627 teid := teid,
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200628 opt_part := f_GTPU_opt_part(seq),
Harald Weltec69cf4e2018-02-17 20:57:02 +0100629 gtpu_IEs := ies
630 }
631
632 template Gtp1uUnitdata tr_GTPU_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid) := {
633 peer := peer,
634 gtpu := tr_GTP1U_PDU(msg_type, teid)
635 }
636
637
638 /* template matching reception of GTP-U echo-request */
639 template Gtp1uUnitdata tr_GTPU_PING(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoRequest, '00000000'O);
640
641 /* template matching reception of GTP-U GPDU */
642 template GTPU_IEs t_GPDU(template octetstring data) := {
643 g_PDU_IEs := {
644 data := data
645 }
646 }
647 template Gtp1uUnitdata tr_GTPU_GPDU(template GtpPeer peer, template OCT4 teid, template octetstring data := ?) := {
648 peer := peer,
649 gtpu := tr_GTP1U_PDU('FF'O, teid, t_GPDU(data))
650 }
651
652 template GTPU_IEs ts_UEchoRespPDU(OCT1 restart_counter) := {
653 echoResponse_IEs := {
654 recovery_gtpu := {
655 type_gtpu := '00'O, /* we assume encoder fixes? */
656 restartCounter := restart_counter
657 },
658 private_extension_gtpu := omit
659 }
660 }
661
662 /* master template for sending a GTP-U echo response */
663 template Gtp1uUnitdata ts_GTPU_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
664 peer := peer,
665 gtpu := ts_GTP1U_PDU(echoResponse, seq, '00000000'O, valueof(ts_UEchoRespPDU(rest_ctr)))
666 }
667
668 /* master template for sending a GTP-U user plane data */
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200669 template Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, template (omit) uint16_t seq, OCT4 teid, octetstring data) := {
Harald Weltec69cf4e2018-02-17 20:57:02 +0100670 peer := peer,
671 gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }})
672 }
673}