osmo-ttcn3-hacks/library/GTP_Templates.ttcn

736 lines
23 KiB
Plaintext

/* GTP Templates in TTCN-3
* (C) 2018 Harald Welte <laforge@gnumonks.org>
* contributions by sysmocom - s.f.m.c. GmbH
* All rights reserved.
*
* Released under the terms of GNU General Public License, Version 2 or
* (at your option) any later version.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
module GTP_Templates {
import from General_Types all;
import from Osmocom_Types all;
import from GTPC_Types all;
import from GTPU_Types all;
import from GTP_CodecPort all;
import from IPCP_Types all;
/* Table 38 of 3GPP TS 29.060 */
type enumerated GTP_Cause {
GTP_CAUSE_REQUEST_IMEI (1),
GTP_CAUSE_REQUEST_IMSI_AND_IMEI (2),
GTP_CAUSE_NO_IDENTITY_NEDED (3),
GTP_CAUSE_MS_REFUSES (4),
GTP_CAUSE_MS_IS_NOT_GPRS_RESPONDING (5),
/* reserved */
GTP_CAUSE_REQUEST_ACCEPTED (128)
/* FIXME */
};
/* generalized GTP-C receive template */
template PDU_GTPC tr_GTP1C_PDU(template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdu := ?) := {
/* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
* error if this flag is set to '1'. */
pn_bit := '0'B,
/* Sequence number flag (S) shall be set to '1'. */
s_bit := '1'B,
e_bit := ?,
spare := ?,
/* Protocol Type flag (PT) shall be set to '1'.*/
pt := '1'B,
/* Version shall be set to decimal 1 ('001'). */
version := '001'B,
messageType := msg_type,
lengthf := ?,
teid := teid,
opt_part := *,
gtpc_pdu := pdu
}
/* generalized GTP-C send template */
template PDU_GTPC ts_GTP1C_PDU(OCT1 msg_type, OCT4 teid, GTPC_PDUs pdu, uint16_t seq_nr) := {
/* N-PDU Number flag (PN) shall be set to '0'. A GTP-C receiver shall not return an
* error if this flag is set to '1'. */
pn_bit := '0'B,
/* Sequence number flag (S) shall be set to '1'. */
s_bit := '1'B,
e_bit := '0'B,
spare := '0'B,
/* Protocol Type flag (PT) shall be set to '1'.*/
pt := '1'B,
/* Version shall be set to decimal 1 ('001'). */
version := '001'B,
messageType := msg_type,
lengthf := 0, /* we assume encoder overwrites this */
teid := teid,
opt_part := {
sequenceNumber := int2oct(seq_nr, 2),
npduNumber := '00'O,
nextExtHeader := '00'O,
gTPC_extensionHeader_List := omit
},
gtpc_pdu := pdu
}
/* recovery IE */
template Recovery_gtpc ts_Recovery(OCT1 restart_counter) := {
type_gtpc := '0E'O,
restartCounter := restart_counter
}
template Recovery_gtpc tr_Recovery(template OCT1 restart_counter) := {
type_gtpc := '0E'O,
restartCounter := restart_counter
}
/* template matching reception of GTP-C echo-request */
template Gtp1cUnitdata tr_GTPC_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid, template GTPC_PDUs pdus := ?) := {
peer := peer,
gtpc := tr_GTP1C_PDU(msg_type, teid, pdus)
}
/* template matching reception of GTP-C echo-request */
template Gtp1cUnitdata tr_GTPC_PING(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoRequest, '00000000'O);
template GTPC_PDUs tr_EchoRespPDU(template OCT1 restart_counter) := {
echoResponse := {
recovery := tr_Recovery(restart_counter),
private_extension_gtpc := *
}
}
/* template matching reception of GTP-C echo-response */
template Gtp1cUnitdata tr_GTPC_PONG(template GtpPeer peer) := tr_GTPC_MsgType(peer, echoResponse, '00000000'O, tr_EchoRespPDU(?));
template GTPC_PDUs ts_EchoRespPDU(OCT1 restart_counter) := {
echoResponse := {
recovery := ts_Recovery(restart_counter),
private_extension_gtpc := omit
}
}
/* master template for senidng a GTP-C echo response */
template Gtp1cUnitdata ts_GTPC_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
peer := peer,
gtpc := ts_GTP1C_PDU(echoResponse, '00000000'O, valueof(ts_EchoRespPDU(rest_ctr)), seq)
}
template GTPC_PDUs ts_EchoReqPDU := {
echoRequest := {
private_extension_gtpc := omit
}
}
/* master template for sending a GTP-C echo request */
template Gtp1cUnitdata ts_GTPC_PING(GtpPeer peer, uint16_t seq) := {
peer := peer,
gtpc := ts_GTP1C_PDU(echoRequest, '00000000'O, valueof(ts_EchoReqPDU), seq)
}
template EndUserAddress t_EuaIPv4(template OCT4 ip_addr) := {
type_gtpc := '80'O,
endUserAddress := {
endUserAddressIPv4 := {
lengthf := 2,
pdp_typeorg := '0001'B,
spare := '1111'B,
pdp_typenum := '21'O,
ipv4_address := ip_addr
}
}
}
template EndUserAddress t_EuaIPv4Dyn := t_EuaIPv4(omit);
template EndUserAddress tr_EuaIPv4(template OCT4 ip_addr) modifies t_EuaIPv4 := {
endUserAddress := {
endUserAddressIPv4 := {
lengthf := 2+lengthof(ip_addr)
}
}
}
template EndUserAddress t_EuaIPv6(template OCT16 ip_addr) := {
type_gtpc := '80'O,
endUserAddress := {
endUserAddressIPv6 := {
lengthf := 2,
pdp_typeorg := '0001'B,
spare := '1111'B,
pdp_typenum := '57'O,
ipv6_address := ip_addr
}
}
}
template EndUserAddress t_EuaIPv6Dyn := t_EuaIPv6(omit);
template EndUserAddress tr_EuaIPv6(template OCT16 ip_addr) modifies t_EuaIPv6 := {
endUserAddress := {
endUserAddressIPv6 := {
lengthf := 2+lengthof(ip_addr)
}
}
}
/* 3GPP TS 29.060 Figure 37A: End User Address Information Element for IPv4v6 (both static) */
template EndUserAddress t_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) := {
type_gtpc := '80'O,
endUserAddress := {
endUserAddressIPv4andIPv6 := {
lengthf := 2,
pdp_typeorg := '0001'B,
spare := '1111'B,
pdp_typenum := '8D'O,
ipv4_address := ip_addr4,
ipv6_address := ip_addr6
}
}
}
template EndUserAddress t_EuaIPv4Dynv6Dyn := t_EuaIPv4v6(omit, omit);
template EndUserAddress tr_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) modifies t_EuaIPv4v6 := {
endUserAddress := {
endUserAddressIPv4andIPv6 := {
lengthf := 2+lengthof(ip_addr4)+lengthof(ip_addr6)
}
}
}
template AccessPointName ts_APN(octetstring apn) := {
type_gtpc := '83'O,
lengthf := lengthof(apn),
apn_value := apn
}
template GSN_Address_GTPC ts_GsnAddr(octetstring ip_addr) := {
type_gtpc := '85'O,
lengthf := lengthof(ip_addr),
addressf := ip_addr
}
template MSISDN ts_Msisdn(octetstring msisdn) := {
type_gtpc := '86'O,
lengthf := lengthof(msisdn),
msisdn := msisdn
}
template QualityOfServiceProfile ts_QosDefault := {
type_gtpc := '87'O,
lengthf := 4,
allocRetensionPrio := '00'O,
qos_ProfileValue := {
reliabilityClass := '011'B,
delayClass := '001'B,
spare1 := '00'B,
precedenceClass := '010'B,
spare2 := '0'B,
peakThroughput := '1001'B,
meanThroughput := '11111'B,
spare3 := '000'B,
deliverErroneusSDU := omit,
deliveryOrder := omit,
trafficClass := omit,
maxSDUSize := omit,
maxBitrateUplink := omit,
maxBitrateDownlink := omit,
sduErrorRatio := omit,
residualBER := omit,
trafficHandlingPriority := omit,
transferDelay := omit,
guaranteedBitRateUplink := omit,
guaranteedBitRateDownlink := omit,
sourceStatisticsDescriptor := omit,
signallingIndication := omit,
spare4 := omit,
maxBitrateDownlinkExt := omit,
guaranteedBitRateDownlinkExt := omit,
maxBitrateUplinkExt := omit,
guaranteedBitRateUplinkExt := omit
}
}
template IMSI_gtpc ts_Imsi(hexstring digits) := {
type_gtpc := '02'O,
digits := digits,
padding := 'F'H
}
template GTPC_PDUs ts_CreatePdpPDU(hexstring imsi, OCT1 restart_ctr, OCT4 teid_data, OCT4 teid_ctrl,
BIT4 nsapi, EndUserAddress eua, octetstring apn,
octetstring sgsn_ip_sign, octetstring sgsn_ip_data,
octetstring msisdn, template ProtConfigOptions pco := omit) := {
createPDPContextRequest := {
imsi := ts_Imsi(imsi),
rai := omit,
recovery := ts_Recovery(restart_ctr),
selectionMode := {
type_gtpc := '0F'O,
selectModeValue := '00'B,
spare := '111111'B
},
teidDataI := {
type_gtpc := '00'O,
teidDataI := teid_data
},
teidControlPlane := {
type_gtpc := '00'O,
teidControlPlane := teid_ctrl
},
nsapi := {
type_gtpc := '00'O,
nsapi := nsapi,
unused := '0000'B
},
linked_nsapi := omit,
charging_char := omit,
trace_ref := omit,
trace_type := omit,
endUserAddress := eua,
accessPointName := ts_APN(apn),
protConfigOptions := pco,
sgsn_addr_signalling := ts_GsnAddr(sgsn_ip_sign),
sgsn_addr_traffic := ts_GsnAddr(sgsn_ip_data),
msisdn := ts_Msisdn(msisdn),
qualityOfServiceProfile := ts_QosDefault,
tft := omit,
triggerId := omit,
omcId := omit,
commonFlags := omit,
aPN_Restriction := omit,
ratType := omit,
userLocationInformation := omit,
mS_TimeZone := omit,
imeisv := omit,
camelChargingInformationContainer := omit,
additionalTraceInfo := omit,
correlationID := omit,
evolvedAllocationRetentionPriorityI := omit,
extendedCommonFlags := omit,
userCSGInformation := omit,
aPN_AMBR := omit,
signallingPriorityIndication := omit,
cN_OperatorSelectionEntity := omit,
private_extension_gtpc := omit
}
}
template Gtp1cUnitdata ts_GTPC_CreatePDP(GtpPeer peer, uint16_t seq, hexstring imsi,
OCT1 restart_ctr, OCT4 teid_data,
OCT4 teid_ctrl, BIT4 nsapi, EndUserAddress eua,
octetstring apn, octetstring sgsn_ip_sign,
octetstring sgsn_ip_data, octetstring msisdn,
template ProtConfigOptions pco := omit) := {
peer := peer,
gtpc := ts_GTP1C_PDU(createPDPContextRequest, '00000000'O,
valueof(ts_CreatePdpPDU(imsi, restart_ctr, teid_data, teid_ctrl,
nsapi, eua, apn, sgsn_ip_sign,
sgsn_ip_data, msisdn, pco)), seq)
}
template NSAPI_GTPC ts_NSAPI(BIT4 nsapi) := {
type_gtpc := '14'O,
nsapi := nsapi,
unused := '0000'B
}
template ReorderingRequired ts_ReorderReq(boolean req := false) := {
type_gtpc := '08'O,
reordreq := bool2bit(req),
spare := '0000000'B
}
template GTPC_PDUs ts_CreatePdpRespPDU(OCT1 cause, OCT4 teid_data, OCT4 teid_ctrl, BIT4 nsapi,
octetstring ggsn_ip_sign, octetstring ggsn_ip_data,
OCT4 chg_id, template EndUserAddress eua := omit,
template Recovery_gtpc recovery := omit,
template ProtConfigOptions pco := omit) := {
createPDPContextResponse := {
cause := { '00'O, cause },
reorderingRequired := ts_ReorderReq(false),
recovery := recovery,
teidDataI := {
type_gtpc := '00'O,
teidDataI := teid_data
},
teidControlPlane := {
type_gtpc := '00'O,
teidControlPlane := teid_ctrl
},
nsapi := ts_NSAPI(nsapi),
chargingID := {
type_gtpc := '7F'O,
chargingID := chg_id
},
endUserAddress := eua,
protConfigOptions := pco,
ggsn_addr_controlPlane := ts_GsnAddr(ggsn_ip_sign),
ggsn_addr_traffic := ts_GsnAddr(ggsn_ip_data),
alt_ggsn_addr_controlPane := omit,
alt_ggsn_addr_traffic := omit,
qualityOfServiceProfile := ts_QosDefault,
commonFlags := omit,
aPN_Restriction := omit,
mS_InfoChangeReportingAction := omit,
bearerControlMode := omit,
evolvedAllocationRetentionPriorityI := omit,
extendedCommonFlag := omit,
csg_information_reporting_action := omit,
aPN_AMBR := omit,
gGSN_BackOffTime := omit,
private_extension_gtpc := omit
}
}
template Gtp1cUnitdata ts_GTPC_CreatePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
OCT1 cause,
OCT4 teid_ctrl, OCT4 teid_data,
BIT4 nsapi, octetstring ggsn_ip_sign,
octetstring ggsn_ip_data, OCT4 chg_id,
template EndUserAddress eua := omit,
template Recovery_gtpc recovery := omit,
template ProtConfigOptions pco := omit) := {
peer := peer,
gtpc := ts_GTP1C_PDU(createPDPContextResponse, teid,
valueof(ts_CreatePdpRespPDU(cause, teid_data, teid_ctrl, nsapi,
ggsn_ip_sign, ggsn_ip_data, chg_id,
eua, recovery, pco)), seq)
}
/* PCO send base template */
template ProtConfigOptions ts_PCO := {
type_gtpc := '84'O,
lengthf := 0,
configProtocol := '000'B,
spare := '0000'B,
extension0 := '1'B,
protocols := {}
}
/* PCO receive base template */
template ProtConfigOptions tr_PCO := {
type_gtpc := '84'O,
lengthf := ?,
configProtocol := '000'B,
spare := ?,
extension0 := '1'B,
protocols := {}
}
template ProtConfigOptions ts_PCO_IPv6_DNS modifies ts_PCO := {
protocols := {
{ protocolID := '0003'O, lengthProtoID := 0, protoIDContents := ''O }
}
}
template ProtConfigOptions tr_PCO_IPv6_DNS_resp(template OCT16 contents) modifies tr_PCO := {
protocols := {
*, { protocolID := '0003'O, lengthProtoID := 16, protoIDContents := contents }, *
}
}
template ProtConfigOptions ts_PCO_IPv4_DNS_IPCP modifies ts_PCO := {
protocols := {
/* dummy PAP entry to check if our parser in the GGSN can properly iterate over
* the list of protocols, see Change-Id Icc2e6716c33d78d3c3e000f529806228d8aa155e */
{ protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
{ protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS)) }
}
}
template ProtConfigOptions ts_PCO_IPv4_PRI_DNS_IPCP modifies ts_PCO := {
protocols := {
/* dummy PAP entry to check if our parser can cope with a single primary DNS entry
* see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
{ protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
{ protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) }
}
}
template ProtConfigOptions ts_PCO_IPv4_SEC_DNS_IPCP modifies ts_PCO := {
protocols := {
/* dummy PAP entry to check if our parser can cope with a single secondary DNS entry
* see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
{ protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
{ protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
}
}
template ProtConfigOptions ts_PCO_IPv4_SEPARATE_DNS_IPCP modifies ts_PCO := {
protocols := {
/* dummy PAP entry to check if our parser can cope with a primary and secondary DNS
* in separate IPCP containers OS#3381 */
{ protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O },
{ protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) },
{ protocolID := '8021'O, lengthProtoID := 16, protoIDContents :=
enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) }
}
}
template ProtocolElement tr_PCO_Proto(OCT2 prot_id) := {
protocolID := prot_id,
lengthProtoID := ?,
protoIDContents := ?
}
template ProtConfigOptions tr_PCO_Contains(OCT2 prot_id) modifies tr_PCO := {
protocols := { *, tr_PCO_Proto(prot_id), * }
}
template ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := {
protocols := {
{ protocolID := '000d'O, lengthProtoID := 0, protoIDContents := ''O }
}
}
template ProtConfigOptions tr_PCO_IPv4_DNS_CONT_resp(template OCT4 contents) modifies tr_PCO := {
protocols := {
*, { protocolID := '000d'O, lengthProtoID := 4, protoIDContents := contents }, *
}
}
/* extract a given protocol payload from PCO */
function f_PCO_extract_proto(ProtConfigOptions pco, OCT2 protocol, integer nth_match := 1) return octetstring {
var integer i;
var integer num_matches := 0;
for (i := 0; i < lengthof(pco.protocols); i := i + 1) {
if (pco.protocols[i].protocolID == protocol) {
num_matches := num_matches + 1;
if (num_matches == nth_match) {
return pco.protocols[i].protoIDContents;
}
}
}
setverdict(fail, "Could not extract protocol payload from protocol ", protocol);
mtc.stop;
return ''O;
}
template IpcpPacket tr_IPCP(template LcpCode code, template uint8_t identifier,
template IpcpOptionList opts) := {
code := code,
identifier := identifier,
len := ?,
options := opts
}
template IpcpOption tr_IPCP_PrimaryDns(template OCT4 addr) := {
code := IPCP_OPT_PrimaryDNS,
len := 6,
data := addr
}
template IpcpOption tr_IPCP_SecondaryDns(template OCT4 addr) := {
code := IPCP_OPT_SecondaryDNS,
len := 6,
data := addr
}
template IpcpPacket tr_IPCP_Ack_DNS(template uint8_t identifier := ?, template OCT4 dns1 := ?,
template OCT4 dns2 := ?) :=
tr_IPCP(LCP_Configure_Ack, identifier,
{ *, tr_IPCP_PrimaryDns(dns1), *, tr_IPCP_SecondaryDns(dns2), * });
template IpcpPacket ts_IPCP(LcpCode code, uint8_t identifier, template IpcpOptionList opts) := {
code := code,
identifier := identifier,
len := 0, /* overwritten */
options := opts
}
template IpcpPacket ts_IPCP_ReqDNS(uint8_t identifier := 0) :=
ts_IPCP(LCP_Configure_Request, identifier,
{ tr_IPCP_PrimaryDns('00000000'O), tr_IPCP_SecondaryDns('00000000'O) });
template IpcpPacket ts_IPCP_ReqDNS_Primary(uint8_t identifier := 0) :=
ts_IPCP(LCP_Configure_Request, identifier,
{ tr_IPCP_PrimaryDns('00000000'O) });
template IpcpPacket ts_IPCP_ReqDNS_Secondary(uint8_t identifier := 0) :=
ts_IPCP(LCP_Configure_Request, identifier,
{ tr_IPCP_SecondaryDns('00000000'O) });
function f_teardown_ind_IE(in template (omit) BIT1 ind) return template (omit) TearDownInd {
if (istemplatekind(ind, "omit")) {
return omit;
}
var TearDownInd ret := {
type_gtpc := '13'O,
tdInd := valueof(ind),
spare:= '0000000'B
}
return ret;
}
template GTPC_PDUs ts_DeletePdpPDU(BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
deletePDPContextRequest := {
cause := omit,
tearDownIndicator := f_teardown_ind_IE(teardown_ind),
nsapi := {
type_gtpc := '14'O,
nsapi := nsapi,
unused := '0000'B
},
protConfigOptions := omit,
userLocationInformation := omit,
mS_TimeZone := omit,
extendedCommonFlags := omit,
uLI_Timestamp := omit,
private_extension_gtpc := omit
}
}
template Gtp1cUnitdata ts_GTPC_DeletePDP(GtpPeer peer, uint16_t seq, OCT4 teid,
BIT4 nsapi, template (omit) BIT1 teardown_ind) := {
peer := peer,
gtpc := ts_GTP1C_PDU(deletePDPContextRequest, teid,
valueof(ts_DeletePdpPDU(nsapi, teardown_ind)), seq)
}
template GTPC_PDUs ts_DeletePdpRespPDU(OCT1 cause,
template ProtConfigOptions pco := omit) := {
deletePDPContextResponse := {
cause := { '00'O, cause },
protConfigOptions := pco,
userLocationInformation := omit,
mS_TimeZone := omit,
uLI_Timestamp := omit,
private_extension_gtpc := omit
}
}
template Gtp1cUnitdata ts_GTPC_DeletePdpResp(GtpPeer peer, uint16_t seq, OCT4 teid,
OCT1 cause,
template ProtConfigOptions pco := omit) := {
peer := peer,
gtpc := ts_GTP1C_PDU(deletePDPContextResponse, teid,
valueof(ts_DeletePdpRespPDU(cause, pco)), seq)
}
/* GTP-U */
template PDU_GTPU tr_GTP1U_PDU(template OCT1 msg_type, template OCT4 teid, template GTPU_IEs ies := ?) := {
pn_bit := ?,
s_bit := ?,
e_bit := ?,
spare := ?,
/* Protocol Type flag (PT) shall be set to '1' in GTP */
pt := '1'B,
/* Version shall be set to decimal 1 ('001'). */
version := '001'B,
messageType := msg_type,
lengthf := ?,
teid := teid,
opt_part := *,
gtpu_IEs := ies
}
function f_GTPU_s_bit(template (omit) uint16_t seq) return BIT1 {
if (istemplatekind(seq, "omit")) {
return '0'B;
}
return '1'B;
}
function f_GTPU_opt_part(template (omit) uint16_t seq) return template (omit) GTPU_Header_optional_part {
if (istemplatekind(seq, "omit")) {
return omit;
}
var GTPU_Header_optional_part ret := {
sequenceNumber := int2oct(valueof(seq), 2),
npduNumber := '00'O,
nextExtHeader := '00'O,
gTPU_extensionHeader_List := omit
};
return ret;
}
/* generalized GTP-U send template */
template PDU_GTPU ts_GTP1U_PDU(OCT1 msg_type, template (omit) uint16_t seq, OCT4 teid, GTPU_IEs ies) := {
/* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN
* flag is set to 1. */
pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */
/* If the Sequence Number flag (S) is set to '1' the sequence number field is present and
* meaningful otherwise it is set to '0'. For GTP-U messages Echo Request, Echo Response,
* Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'.
*
* Note that the caller must ensure that these conditions hold.
* The caller can either pass a sequence number (we set s_bit to '1'B) when appropriate,
* or may omit the sequence number (we set s_bit to '0'B). */
s_bit := f_GTPU_s_bit(seq),
/* Extension header presence */
e_bit := '0'B,
spare := '0'B,
/* Protocol Type flag (PT) shall be set to '1' in GTP */
pt := '1'B,
/* Version shall be set to decimal 1 ('001'). */
version := '001'B,
messageType := msg_type,
lengthf := 0, /* we assume encoder overwrites this */
teid := teid,
opt_part := f_GTPU_opt_part(seq),
gtpu_IEs := ies
}
template Gtp1uUnitdata tr_GTPU_MsgType(template GtpPeer peer, template OCT1 msg_type, template OCT4 teid) := {
peer := peer,
gtpu := tr_GTP1U_PDU(msg_type, teid)
}
/* template matching reception of GTP-U echo-request */
template Gtp1uUnitdata tr_GTPU_PING(template GtpPeer peer) := tr_GTPU_MsgType(peer, echoRequest, '00000000'O);
/* template matching reception of GTP-U GPDU */
template GTPU_IEs t_GPDU(template octetstring data) := {
g_PDU_IEs := {
data := data
}
}
template Gtp1uUnitdata tr_GTPU_GPDU(template GtpPeer peer, template OCT4 teid, template octetstring data := ?) := {
peer := peer,
gtpu := tr_GTP1U_PDU('FF'O, teid, t_GPDU(data))
}
template GTPU_IEs ts_UEchoRespPDU(OCT1 restart_counter) := {
echoResponse_IEs := {
recovery_gtpu := {
type_gtpu := '00'O, /* we assume encoder fixes? */
restartCounter := restart_counter
},
private_extension_gtpu := omit
}
}
/* master template for sending a GTP-U echo response */
template Gtp1uUnitdata ts_GTPU_PONG(GtpPeer peer, uint16_t seq, OCT1 rest_ctr) := {
peer := peer,
gtpu := ts_GTP1U_PDU(echoResponse, seq, '00000000'O, valueof(ts_UEchoRespPDU(rest_ctr)))
}
template GSNAddress_gtpu ts_UGsnAddr(octetstring ip_addr) := {
type_gtpu := '85'O,
lengthf := lengthof(ip_addr),
gSNAddressValue := ip_addr
}
template TeidDataI_gtpu ts_UteidDataI(OCT4 teid) := {
type_gtpu := '10'O,
teidDataI := teid
}
template GTPU_IEs ts_UErrorIndication(OCT4 teid, octetstring gsn_addr) := {
errorIndication_IEs := {
teidDataI_gtpu := ts_UteidDataI(teid),
gSNAddress_gtpu := ts_UGsnAddr(gsn_addr),
private_extension_gtpu := omit
}
}
/* master template for sending a GTP-U Error indication */
template Gtp1uUnitdata ts_GTPU_ErrorIndication(GtpPeer peer, uint16_t seq, OCT4 teid, octetstring gsn_addr) := {
peer := peer,
gtpu := ts_GTP1U_PDU('1A'O, seq, '00000000'O, valueof(ts_UErrorIndication(teid, gsn_addr)))
}
/* master template for sending a GTP-U user plane data */
template Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, template (omit) uint16_t seq, OCT4 teid, octetstring data) := {
peer := peer,
gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }})
}
}