///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2023 Ericsson Telecom AB
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v2.0
// which accompanies this distribution, and is available at
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
///////////////////////////////////////////////////////////////////////////////
//  File:         SCCP_Types.ttcn
//  Description:  SS7 SCCP definitions according to specification
//                 ITU-T SS7 SCCP, ANSI ..., ttc ..., mpt
//  Reference:    ITU-T: Recommendation Q.711-Q.714 (07/96)
//                ANSI:  T1.112-2001
//                ttc:   JT-Q711 -JT-Q714 (ver 2, 04/97)
//  Rev:          R7A
//  Prodnr:       CNL 113 341
//  Updated:      2008-05-08
//  Contact:      http://ttcn.ericsson.se

module SCCP_Types.objid { itu_t(0) identified_organization (4) etsi(0)
  reserved(127) etsi_identified_organization(0) ericsson(5)
  testing (0) generic(0) sccp(1) v3(3) typeDefinitions(2) patchNo(3)}

{//start of the module

modulepar
{//startparameters

//------------------Protocol Timer Values----------------------------------

//Waiting for connection confirm message  -1 to 2 minutes

  float      tspc_timer_T_conn_est:=120.0;

  //Delay to send a message on a conn IT on a
  //connection section when there are no
  //messages to send
  //5 to 10 minutes

  float       tspc_timer_T_ias:=600.0;
  //Waiting to receive a message on a connection
  //section
  //11 to 21 minutes
  float       tspc_timer_T_iar:=1260.0;
  //Waiting for release complete message -10 to 20 seconds

  float       tspc_timer_T_rel:=20.0;
  //Waiting for release complete message; or to
  //repeat sending released message after the
  //initial T(rel) expiry
  //10 to 20 seconds
  float       tspc_timer_T_repeat_rel:=20.0;

  //Waiting for release complete message; or to
  //release connection resources, freeze the LRN
  //and alert a maintenance function after the
  //initial T(rel) expiry
  //extending to 1 minute
  float       tspc_timer_T_int:=60.0;

  //Waiting to resume normal procedure for
  //temporary connection sections during the
  //restart procedure
  //23 to 25 minutes
 	float       tspc_timer_T_guard:=1500.0;

  //Waiting to release temporary connection
  //section or alert maintenance function after
  //reset request message is sent
  //10 to 20 seconds
	float       tspc_timer_T_reset:=20.0;
  //Waiting to receive all the segments of the
  //remaining segments single segmented
  //message after receiving the first segment
  //10 to 20 seconds

  //  float       tspc_timer_T_reasssembly;

	float       tspc_timer_T_internal_reset:=0.0;
  //zero-only for sending internal signals!!


	float       tspc_timer_guard :=120.0
  //the same as tspc_timer_T_conn_est:1 or 2 minutes

}//end parameters



import from General_Types    all;
import from MTP3asp_Types    all;
//import from MTP3asp_PortType all;

import from SCCPasp_Types  all;

external function enc_PDU_SCCP( in PDU_SCCP pdu) return octetstring
  with { extension "prototype(convert)"
         extension "encode(RAW)"
       };
external function dec_PDU_SCCP( in octetstring o) return PDU_SCCP
  with { extension "prototype(convert)"
         extension "decode(RAW)"
       };

// Address encoder/decoder for itu:
external function enc_PDU_SCCP_Address_itu( in SCCP_param_CPartyAddress_itu pdu) return octetstring
  with { extension "prototype(convert)"
         extension "encode(RAW)"
       };
external function dec_PDU_SCCP_Address_itu( in octetstring o) return SCCP_param_CPartyAddress_itu
  with { extension "prototype(convert)"
         extension "decode(RAW)"
       };

// Address encoder/decoder for ansi:
external function enc_PDU_SCCP_Address_ansi( in SCCP_param_CPartyAddress_ansi pdu) return octetstring
  with { extension "prototype(convert)"
         extension "encode(RAW)"
       };
external function dec_PDU_SCCP_Address_ansi( in octetstring o) return SCCP_param_CPartyAddress_ansi
  with { extension "prototype(convert)"
         extension "decode(RAW)"
       };

// Address encoder/decoder for ttc:
external function enc_PDU_SCCP_Address_ttc( in SCCP_param_CPartyAddress_ttc pdu) return octetstring
  with { extension "prototype(convert)"
         extension "encode(RAW)"
       };
external function dec_PDU_SCCP_Address_ttc( in octetstring o) return SCCP_param_CPartyAddress_ttc
  with { extension "prototype(convert)"
         extension "decode(RAW)"
       };

// Address encoder/decoder for mpt:
external function enc_PDU_SCCP_Address_mpt( in SCCP_param_CPartyAddress_mpt pdu) return octetstring
  with { extension "prototype(convert)"
         extension "encode(RAW)"
       };
external function dec_PDU_SCCP_Address_mpt( in octetstring o) return SCCP_param_CPartyAddress_mpt
  with { extension "prototype(convert)"
         extension "decode(RAW)"
       };

external function enc_PDU_SCMG_message( in PDU_SCMG_message pdu) return octetstring
  with { extension "prototype(convert)"
         extension "encode(RAW)"
       };
external function dec_PDU_SCMG_message( in octetstring o) return PDU_SCMG_message
  with { extension "prototype(convert)"
         extension "decode(RAW)"
       };

group Types
{
	group FieldDefinitions
	{
	//---------------------------------------------------------------------------
	// Field Parameter Name (ITU:$3/Q713 $3, ANSI:Table 2/T1.112.3-2001
	//---------------------------------------------------------------------------
		type integer SCCP_field_ParameterName with { variant "FIELDLENGTH(8)"};
    const SCCP_field_ParameterName con_SCCP_eop :=0,      con_SCCP_dLocRef:=1,
                                   con_SCCP_sLocRef:=2,   con_SCCP_cdPA:=3,
                                   con_SCCP_cgPA:=4,      con_SCCP_protclass:=5,
                                   con_SCCP_segmReas:=6,  con_SCCP_recSeqNum:=7,
                                   con_SCCP_seqSegm:=8,   con_SCCP_credit:=9,
                                   con_SCCP_relCause:=10, con_SCCP_retCause:=11,
                                   con_SCCP_resCause:=12, con_SCCP_errorCause:=13,
                                   con_SCCP_refCause:=14, con_SCCP_data:=15,
                                   con_SCCP_segm:=16,     con_SCCP_hopCount:=17,
                                   con_SCCP_imp:=18,      con_SCCP_longData:=19,
                                   con_SCCP_mti:=248,     con_SCCP_ins:=249,
                                   con_SCCP_isni:=250;


     //EOP End of optional parameters,      DLocRef Destination local reference,
     //SLocRef Source local reference,      CdPA Called party address,
     //CgPA Calling party address,          ProtClass Protocol class,
     //SegmReas Segmenting/reassembling,    RecSeqNum Receive sequence number,
     //SeqSegm Sequencing/segmenting,       Credit Credit,
     //RelCause Release cause,              RetCau Return cause,
     //ResCau Reset cause,                  ErrCau Error cause,
     //RefCau Refusal cause,                Data Data,
     //SEGM Segmentation,                   HopCount Hop counter,
     //IMP Importance,                      LongData Long data,
     // --- only in ANSI:---
     //MTI Message Type Interworking
     //INS
     //ISNI
     //ISNI

	//---------------------------------------------------------------------------
	// Field Address Indicator (ITU: Q713 $3.4.1, ANSI: T1.112.3 $3.4.1)
	//---------------------------------------------------------------------------
	type record  SCCP_field_AddressIndicator_itu
  {
    BIT1          pointCodeIndic,
    BIT1          ssnIndicator,
    BIT4          globalTitleIndic,
    BIT1          routingIndicator,
    BIT1          reserved
  }
  with { variant "" }

  // field order is interesting at coding/decoding
  type record  SCCP_field_AddressIndicator_ansi
  {
    BIT1          ssnIndicator,
    BIT1          pointCodeIndic,
    BIT4          globalTitleIndic,
    BIT1          routingIndicator,
    BIT1          reserved
  }
  with { variant "" }

	//---------------------------------------------------------------------------
	// Subfield Signalling Point Code (Q713 $3.4.2.1)
	//---------------------------------------------------------------------------
	// use functions SCCP_getSPC and SCCP_setSPC to handle it!!!

  type BIT16 SCCP_field_SignallingPointCode_itu; // TO BE DEFINED: msb or lsb ???
  type BIT24 SCCP_field_SignallingPointCode_ansi; // TO BE DEFINED: msb or lsb ???
  type BIT16 SCCP_field_SignallingPointCode_ttc; // TO BE DEFINED: msb or lsb ???
  type BIT24 SCCP_field_SignallingPointCode_mpt; // TO BE DEFINED: msb or lsb ???
  //---------------------------------------------------------------------------
	// Subfield Subsystem Number (Q713 $3.4.2.2)
	//---------------------------------------------------------------------------
	//values declared in SCCPConstants in SCCP.ttcn

	type integer    SCCP_field_SubsystemNumber
    with { variant "FIELDLENGTH(8)" };


	//---------------------------------------------------------------------------
	// Subfield Global Title (ITU: Q713 $3.4.2.3, ANSI T1.112.3 $3.4.2.3
	//---------------------------------------------------------------------------

	//---------------------------------------------------------------------------
	// Subfield Global Title, Nature of address only
  //ITU: GTI=0001, Q713 $3.4.2.3.1
  //ANSI: -

	type record  SCCP_field_GlobalTitle_NoA
  {
    BIT7          natureOfAddress,
    BIT1          oddeven,
    hexstring     globalTitleAddress
    //it should be hexstring, number digits are in BCD;
    //hexstring is already supported yet by ETH compiler
  }
  with { variant "" }


	//---------------------------------------------------------------------------
	// Global Title, Translation type only (
  // ITU:   GTI=0010, Q713 $3.4.2.3.2
  // ANSI:  GTI=0010, Figure6A/T1.112.3

  type record  SCCP_field_GlobalTitle_TT
  {
    OCT1          translationType,
    hexstring     globalTitleAddress
  }
   with { variant "" }


	//---------------------------------------------------------------------------
	// Global Title, Translation type & numbering plan & encoding scheme
	// ITU: GTI=0011, Q713 $3.4.2.3.3)
  // ANSI GTI=0001, Figure6/T1.112.3

  type record  SCCP_field_GlobalTitle_TT_NP_ES
  {
    OCT1          translationType,
    BIT4          encodingScheme,
    BIT4          numberingPlan,
    hexstring     globalTitleAddress
  }
  with { variant "" }


  //-----------------------------------------------------------------------------
  // Global Title, Translation type & numbering plan & encoding scheme & nature of
  // address
  // GTI=0100, Q713 $3.4.2.3.4)
  // ANSI: -

  // Suggested to change name to SCCP_field_GlobalTitle_TT_NP_ES_NoA

  type record  SCCP_field_SignallingPointCode_TT_NP_ES_NoA
  {
    OCT1          translationType,
    BIT4          encodingScheme,
    BIT4          numberingPlan,
    BIT7          natureOfAddress,
    BIT1          reserved,
    hexstring     globalTitleAddress
  }
  with { variant "" }


  type union  SCCP_field_GlobalTitle_itu
  {
    SCCP_field_GlobalTitle_NoA                    gti0001,
    SCCP_field_GlobalTitle_TT                     gti0010,
    SCCP_field_GlobalTitle_TT_NP_ES               gti0011,
    SCCP_field_SignallingPointCode_TT_NP_ES_NoA   gti0100
  }
  with { variant "" }
   // no TAG is added as alternatives depend on the gti field of the address indicator

  type union  SCCP_field_GlobalTitle_ansi
  {
    SCCP_field_GlobalTitle_TT_NP_ES               gti0001,
    SCCP_field_GlobalTitle_TT                     gti0010
  }
  with { variant "" }

//---------------------------------------------------------------------------
// Field Protocol Class (Q713 $3.6)
//---------------------------------------------------------------------------
//type enumerated SCCP_field_ProtocolClass
//  { class0 (0), class1(1), class2(2), class3(3) }
//   with { variant "FIELDLENGTH(4)" }
//ethgry(2002-08-01): replaced by BIT4

//---------------------------------------------------------------------------
// Field Importance (Q713 $3.19)
//---------------------------------------------------------------------------
  type integer SCCP_field_Importance
  with { variant "FIELDLENGTH(3)" }


}//endgroup FieldDefinitions


group ParameterDefinitions
{
  //---------------------------------------------------------------------------
  // Parameter Message Type (Q713 $2.1)
  //---------------------------------------------------------------------------
  type integer SCCP_param_MessageType with { variant "FIELDLENGTH(8)" }
  const SCCP_param_MessageType cr:=1,      cc:=2,      cref:=3,
                               rlsd:=4,    rlc:=5,    dt1:=6,    dt2:=7,
                               ak:=8,      udt:=9,    udts:=10,  ed:=11,
                               ea:=12,     rsr:=13,   rsc:=14,   err:=15,
                               it:=16,     xudt:=17,  xudts:=18, ludt:=19,
                               ludts:=20;


   //CR Connection request,    CC Connection confirm,    CREF Connection refused,
   //RLSD Released,            RLC Release complete,     DT1 Data form 1,
   //DT2 Data form 2,          AK Data acknowledgement,  UDT Unitdata,
   //UDTS Unitdata service,    ED Expedited data,        EA Expedited data acknowledgement,
   //RSR Reset request,        RSC Reset confirm,        ERR Protocol data unit error,
   //IT Inactivity test,       XUDT Extended unitdata,   XUDTS Extended unitdata service,
   //LUDT Long unitdata,       LUDTS Long unitdata service


  //---------------------------------------------------------------------------
  // End of Optional Parameters (Q713 $3.1)
  //---------------------------------------------------------------------------
  type record SCCP_param_EndOfOptionalParams
  {
    SCCP_field_ParameterName             paramName (con_SCCP_eop)
  }
  with { variant "" }


  //---------------------------------------------------------------------------
  // Parameter Destination Local Reference (Q713 $3.2)
  //---------------------------------------------------------------------------
  type octetstring SCCP_param_DestLocalReference
  with { variant "FIELDLENGTH(3)"}


  //---------------------------------------------------------------------------
  // Parameter Source Local Reference (Q713 $3.3)
  //---------------------------------------------------------------------------

  type octetstring SCCP_param_SourceLocalReference
  with { variant "FIELDLENGTH(3)" }


  //---------------------------------------------------------------------------
  // Parameter Called/Calling Party Address (Q713 $3.4/$3.5)
  //---------------------------------------------------------------------------
  /* Removed 2004.02.16 by ethbaat:

  type union SCCP_superfield_SignallingPointCode_itu
  {
    SCCP_field_SignallingPointCode_itu   present,
    Dummy                                absent
  } with { variant "" }


  type union SCCP_superfield_SignallingPointCode_ansi
  {
    SCCP_field_SignallingPointCode_ansi   present,
    Dummy                                 absent
  } with { variant "" }

  type union SCCP_superfield_SignallingPointCode_ttc
  {
    SCCP_field_SignallingPointCode_ttc   present,
    Dummy                                absent
  } with { variant "" }

  type union SCCP_superfield_SubsystemNumber
  {
    SCCP_field_SubsystemNumber        present,
    Dummy                            absent
  } with { variant "" }

 */

  // Standard Independent Encoded Calling/Called Party Address:
  // used in SCCP.ttcn/Convert

  // this address is used everywhere in SCCP inside:
  type octetstring SCCP_CPartyAddressEnc_addr with { variant ""};

  type record SCCP_param_CPartyAddressEnc
  {
    LIN1                           paramLength,
    SCCP_CPartyAddressEnc_addr     addr
  } with { variant (paramLength) "LENGTHTO( addr )"}

  // Structured, decoded versions:

  type record SCCP_param_CPartyAddress_itu {

    SCCP_field_AddressIndicator_itu         addressIndicator,
    SCCP_field_SignallingPointCode_itu      signPointCode   optional,
    SCCP_field_SubsystemNumber              subsystemNumber optional,
    SCCP_field_GlobalTitle_itu              globalTitle     optional
  }
  with { variant  (signPointCode)   "PRESENCE( addressIndicator.pointCodeIndic = '1'B)";
         variant (subsystemNumber)  "PRESENCE( addressIndicator.ssnIndicator   = '1'B)";
         variant (globalTitle)      "PRESENCE( {addressIndicator.globalTitleIndic = '0001'B,
                                                addressIndicator.globalTitleIndic = '0010'B,
                                                addressIndicator.globalTitleIndic = '0011'B,
                                                addressIndicator.globalTitleIndic = '0100'B}),
                                    CROSSTAG(
                                    gti0001, addressIndicator.globalTitleIndic = '0001'B;
                                    gti0010, addressIndicator.globalTitleIndic = '0010'B;
                                    gti0011, addressIndicator.globalTitleIndic = '0011'B;
                                    gti0100, addressIndicator.globalTitleIndic = '0100'B)"
        }

  type record SCCP_param_CPartyAddress_ansi
  {
    SCCP_field_AddressIndicator_ansi     addressIndicator,
    SCCP_field_SubsystemNumber           subsystemNumber  optional,
    SCCP_field_SignallingPointCode_ansi  signPointCode    optional,
    SCCP_field_GlobalTitle_ansi          globalTitle      optional
  }
  with {
            variant (subsystemNumber) "PRESENCE( addressIndicator.ssnIndicator = '1'B )";
            variant (signPointCode)   "PRESENCE( addressIndicator.pointCodeIndic = '1'B )";
            variant (globalTitle)     "PRESENCE( {addressIndicator.globalTitleIndic = '0001'B,
                                                  addressIndicator.globalTitleIndic = '0010'B}),
                                      CROSSTAG(
                                      gti0001, addressIndicator.globalTitleIndic = '0001'B;
                                      gti0010, addressIndicator.globalTitleIndic = '0010'B)"
       }

  type record SCCP_param_CPartyAddress_ttc {

    SCCP_field_AddressIndicator_itu         addressIndicator,
    SCCP_field_SignallingPointCode_ttc      signPointCode     optional,
    SCCP_field_SubsystemNumber              subsystemNumber   optional,
    SCCP_field_GlobalTitle_itu              globalTitle       optional
  }
  with {  variant (signPointCode)    "PRESENCE( addressIndicator.pointCodeIndic = '1'B)";
          variant (subsystemNumber)  "PRESENCE( addressIndicator.ssnIndicator   = '1'B)";
          variant (globalTitle)      "PRESENCE( {addressIndicator.globalTitleIndic = '0001'B,
                                                 addressIndicator.globalTitleIndic  = '0010'B,
                                                 addressIndicator.globalTitleIndic  = '0011'B,
                                                 addressIndicator.globalTitleIndic  = '0100'B}),
                                     CROSSTAG(
                                     gti0001, addressIndicator.globalTitleIndic = '0001'B;
                                     gti0010, addressIndicator.globalTitleIndic = '0010'B;
                                     gti0011, addressIndicator.globalTitleIndic = '0011'B;
                                     gti0100, addressIndicator.globalTitleIndic = '0100'B)"
        }

  type record SCCP_param_CPartyAddress_mpt {

    SCCP_field_AddressIndicator_itu         addressIndicator,
    SCCP_field_SignallingPointCode_mpt      signPointCode     optional,
    SCCP_field_SubsystemNumber              subsystemNumber   optional,
    SCCP_field_GlobalTitle_itu              globalTitle       optional
  }
  with {  variant (signPointCode)    "PRESENCE( addressIndicator.pointCodeIndic = '1'B)";
          variant (subsystemNumber)  "PRESENCE( addressIndicator.ssnIndicator   = '1'B)";
          variant (globalTitle)      "PRESENCE( {addressIndicator.globalTitleIndic = '0001'B,
                                                 addressIndicator.globalTitleIndic  = '0010'B,
                                                 addressIndicator.globalTitleIndic  = '0011'B,
                                                 addressIndicator.globalTitleIndic  = '0100'B}),
                                     CROSSTAG(
                                     gti0001, addressIndicator.globalTitleIndic = '0001'B;
                                     gti0010, addressIndicator.globalTitleIndic = '0010'B;
                                     gti0011, addressIndicator.globalTitleIndic = '0011'B;
                                     gti0100, addressIndicator.globalTitleIndic = '0100'B)"
        }

//  type record SCCP_param_CPartyAddress_opt_itu
  type record SCCP_param_CPartyAddressEnc_opt
  {
    SCCP_field_ParameterName        paramName(con_SCCP_cdPA, con_SCCP_cgPA),
    LIN1                            paramLength,
    SCCP_CPartyAddressEnc_addr      addr
  } with { variant (paramLength) "LENGTHTO( addr )"}

  //---------------------------------------------------------------------------
  // Parameter Protocol Class (Q713 $3.6)
  //---------------------------------------------------------------------------
  type record SCCP_param_ProtocolClass
  {
    BIT4                             class,
    BIT4                             messageHandling
  }
  with { variant "" }


  //---------------------------------------------------------------------------
  // Parameter Segmenting/reassembling (Q713 $3.7)
  //---------------------------------------------------------------------------
  type record SCCP_param_SegmentingReassembl
  {
    BIT1                             more,
    BIT7                             reserved
  }
  with { variant "" }


  //---------------------------------------------------------------------------
  // Parameter Receive Sequence Number (Q713 $3.8)
  //---------------------------------------------------------------------------
  type record SCCP_param_RecSeqNumber
  {
    BIT1                             reserved,
    BIT7                             pr
  }
  with { variant "" }


  //---------------------------------------------------------------------------
  // Parameter Sequencing/Segmenting (Q713 $3.9)
  //---------------------------------------------------------------------------
  type record SCCP_param_SequencingSegmenting
  {
    BIT1                             reserved,
    BIT7                             p_s,
    BIT1                             more,
    BIT7                             pr
  }
  with { variant "" }


  //---------------------------------------------------------------------------
  // Parameter Credit(Q713 $3.10)
  //---------------------------------------------------------------------------
  type octetstring SCCP_param_Credit
  with { variant "FIELDLENGTH(1)" }//ethlel0813


  type record SCCP_param_Credit_opt
  {
    SCCP_field_ParameterName         paramName(con_SCCP_credit),
    LIN1                             paramLength, // always 1!
    OCT1                             credit
  }
  with { variant "" }


//---------------------------------------------------------------------------
// Parameter Release Cause(Q713 $3.11)
//---------------------------------------------------------------------------
//type enumerated  SCCP_param_ReleaseCause
//  { endUserOrig(0),     endUserCong(1),      endUserFailure(2),  sCCPUserOrig(3),
//    remProcError(4),    inconsConnData(5),   accessFailure(6),   accessCongestion(7),
//    subsystFailure(8),  subsystCongest(9),   mTPFailure(10),     networkCongest(11),
//    expResetTimer(12),  expRecInacTimer(13), reserved(14),       unqualified(15),
//    sCCPFailure(16)
//  }
//   with { variant "FIELDLENGTH(8)" }

//values declared in SCCPConstants in SCCP.ttcn

  type integer SCCP_param_ReleaseCause
  with { variant "FIELDLENGTH(8), COMP(nosign)" };


//---------------------------------------------------------------------------
// Parameter Return Cause(Q713 $3.12)
//---------------------------------------------------------------------------
//type enumerated  SCCP_param_ReturnCause
//  { noTransl4AddrNature(0),    noTransl4SpecifAddr(1),    subsystemCongestion(2),
//    subsystemFailure(3),       unequippedUser(4),         mTPFailure(5),
//    networkCongestion(6),      unqualified(7),            errorMessageTransport(8),
//    errorLocalProcessing(9),   destNoReassembly(10),      sCCPFailure(11),
//    hopCounterViolation(12),   segmeNotSupported(13),     segmentationFailure(14)
//  }
//   with { variant "FIELDLENGTH(8)" }

  //values declared in SCCPConstants in SCCP.ttcn
  type integer SCCP_param_ReturnCause
  with { variant "FIELDLENGTH(8), COMP(nosign)" };


//---------------------------------------------------------------------------
// Parameter Reset Cause(Q713 $3.13)
//---------------------------------------------------------------------------
//type enumerated  SCCP_param_ResetCause
//  { endUserOriginated(0),               sCCPUserOriginated(1),
//   messOutOfOrder_incPs(2),            messOutOfOrder_incPr(3),
//    remProcErr_messOutOfWindow(4),      emProcErr_IncPsAfterReinit(5),
//    remProcErr_general(6),              remEndUserOperational(7),
//    networkOperational(8),              accessOperational(9),
//    networkCongestion(10),              reserved(11),
//    unqualified(12)
//  }
//   with { variant "FIELDLENGTH(8)" }


  //values declared in SCCPConstants in SCCP.ttcn

  type integer SCCP_param_ResetCause
  with { variant "FIELDLENGTH(8), COMP(nosign)" };


  //---------------------------------------------------------------------------
  // Parameter Error Cause(Q713 $3.14)
  //---------------------------------------------------------------------------
  //type enumerated  SCCP_param_ErrorCause
  //  { unassignedDestinationLRN(0),              inconsistentSourceLRN(1),
  //    pointCodeMismatch(2),                     serviceClassMismatch(3),
  //    unqualified(4)
  //  }
  //   with { variant "FIELDLENGTH(8)" }

  //values declared in SCCPConstants in SCCP.ttcn

  type integer SCCP_param_ErrorCause
  with { variant "FIELDLENGTH(8), COMP(nosign)" };


  //---------------------------------------------------------------------------
  // Parameter Refusal Cause(Q713 $3.15)
  //---------------------------------------------------------------------------
   //type enumerated  SCCP_param_RefusalCause
   //  { endUserOrigin(0),             endUserConges(1),          endUserFailure(2),
   //    sCCPUserOrigin(3),            destAddrUnkn(4),           destInaccess(5),
   //    qOSNotAvail_nonTransient(6),  qOSNotAvail_transient(7),  accessFailure(8),
   //    accessCongestion(9),          subsystemFailure(10),      subsystemCongest(11),
   //    expConnEstTimer(12),          incomUserData(13),         reserved(14),
   //    unqualified(15),              hopCounterViol(16),        sCCPFailure(17),
   //    noTransl4address(18),         unequippedUser(19)
   //  }
   //   with { variant "FIELDLENGTH(8)" }


  //values declared in SCCPConstants in SCCP.ttcn

  type integer SCCP_param_RefusalCause
   with { variant "FIELDLENGTH(8), COMP(nosign)" };


  //---------------------------------------------------------------------------
  // Parameter User data (Q713 $3.16)
  //---------------------------------------------------------------------------
  type record SCCP_param_Data
  {
   LIN1                             paramLength,
   OCTN                             data
  }
   with { variant (paramLength) "LENGTHTO(data)" }


  type record SCCP_param_Data_opt
  {
    SCCP_field_ParameterName         paramName(con_SCCP_data),
    LIN1                             paramLength,
    OCTN                             data
  }
  with { variant (paramLength) "LENGTHTO(data)" }


  //---------------------------------------------------------------------------
  // Parameter Segmentation (Q713 $3.17)
  //---------------------------------------------------------------------------

  type record SCCP_param_Segmentation_opt
  {
    SCCP_field_ParameterName         paramName(con_SCCP_segm),
    LIN1                             paramLength,       //always 4!
    BIT4                             remainingSegment,
    BIT2                             reserved,
    BIT1                             class,
    BIT1                             firstSegm,
    OCT3                             segmLocalRef
  }
  with { variant "" }


  //---------------------------------------------------------------------------
  // Parameter Hop counter (Q713 $3.18)
  //---------------------------------------------------------------------------
  type integer SCCP_param_HopCounter
  with { variant "FIELDLENGTH(8), COMP(nosign)" };


  type record SCCP_param_HopCounter_opt
  {
    SCCP_field_ParameterName         paramName(con_SCCP_hopCount),
    LIN1                             paramLength,           //always 1!
    SCCP_param_HopCounter            counter
  }
  with { variant (paramLength) "LENGTHTO(counter)" }


  //---------------------------------------------------------------------------
  // Parameter Importance (Q713 $3.19)
  //---------------------------------------------------------------------------

  type record SCCP_param_Importance_opt
  {
    SCCP_field_ParameterName         paramName(con_SCCP_imp),
    LIN1                             paramLength,           //always 1!
    SCCP_field_Importance            importance,
    BIT5                             reserved
  }
  with { variant ""}
  //with { variant (paramLength) "LENGTHTO(importance)" } //????


  //---------------------------------------------------------------------------
  // Parameter Long data (Q713 $3.20)
  //---------------------------------------------------------------------------
  type record SCCP_param_LongData
  {
    LIN2                             paramLength,
    OCTN                             data
  }
  with { variant (paramLength) "LENGTHTO(data)" }


  //********************************************************************************
  // SCCP management parameters (Q713 $5)
  //********************************************************************************

  //---------------------------------------------------------------------------
  // SCMG format identifier (Q713 $5.1)
  //---------------------------------------------------------------------------
  type enumerated SCMG_param_FormatId
  {
    sSAallowed(1),               // SSA subsystem-allowed
    sSPprohib(2),                // SSP subsystem-prohibited
    sSTstaTest(3),               // SST subsystem-status-test
    sORoutReq(4),                // SOR subsystem-out-of-service-request
    sORoutGrant (5),             // SOG subsystem-out-of-service-grant
    sSCcongest(6)                // SSC SCCP/subsystem-congested
  }
  with { variant "FIELDLENGTH(8)" }


  //---------------------------------------------------------------------------
  // Affected SSN (Q713 $5.2.1)
  //---------------------------------------------------------------------------
  type SCCP_field_SubsystemNumber SCMG_param_AffectedSSN
  with { variant "" }

  //---------------------------------------------------------------------------
  // Affected Pointcode (Q713 $5.2.2)
  //---------------------------------------------------------------------------
  type SCCP_field_SignallingPointCode_itu SCMG_param_AffectedPointCode
  with { variant "" }

  //---------------------------------------------------------------------------
  // Subsystem Multiplicity Indicator (Q713 $5.2.3)
  //---------------------------------------------------------------------------
  type record SCMG_param_MultiplIndicator
  {
    BIT2          smi,
    BIT6          reserved
  }
  with { variant "" }

  //---------------------------------------------------------------------------
  // SCCP congestion level (Q713 $5.2.4)
  //---------------------------------------------------------------------------
  type record SCMG_param_CongestionLevel
  {
    BIT4          congLevel,
    BIT4          reserved
  }
  with { variant "" }

}//endgroup ParameterDefinitions


group PDUDefinitions
{
  //********************************************************************************
  // Message Connection Request (CR) (Q713 $4.2)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Optional part
  type set  SCCP_ConnReq_optionalPart
  {
    SCCP_param_Credit_opt                  credit           optional,
    SCCP_param_CPartyAddressEnc_opt        callingPAddress  optional,
    SCCP_param_Data_opt                    data             optional,
    SCCP_param_HopCounter_opt              hopCounter       optional,
    SCCP_param_Importance_opt              importance       optional
  }
  with { variant "TAG ( credit,           paramName= con_SCCP_credit;
                        callingPAddress,  paramName= con_SCCP_cgPA;
                        data,             paramName= con_SCCP_data;
                        hopCounter,       paramName= con_SCCP_hopCount;
                        importance ,      paramName= con_SCCP_imp)"
       }


  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_ConnectionRequest
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_SourceLocalReference      sourceLocRef,
    SCCP_param_ProtocolClass             protClass,
    LIN1                                 pointer1,    //will be 2
    LIN1                                 pointer2,
    SCCP_param_CPartyAddressEnc          calledPAddress,
    SCCP_ConnReq_optionalPart            optionalPart optional,
    SCCP_param_EndOfOptionalParams       eop   optional
  }
  with { variant (pointer1) "POINTERTO(calledPAddress)";
         variant (pointer2) "POINTERTO(optionalPart)";
         variant "TAG (eop,paramName=con_SCCP_eop )"
            //Note, that optional part itself is mandatory but it may be empty!
       }


  //********************************************************************************
  // Message Connection Confirm (CC) (Q713 $4.3)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Optional part
  type set  SCCP_ConnConfirm_optionalPart
  {
   SCCP_param_Credit_opt                  credit           optional,
   SCCP_param_CPartyAddressEnc_opt        calledPAddress   optional,
   SCCP_param_Data_opt                    data             optional,
   SCCP_param_Importance_opt              importance       optional
  }
  with { variant "TAG ( credit,           paramName= con_SCCP_credit;
                        calledPAddress,   paramName= con_SCCP_cdPA;
                        data,             paramName= con_SCCP_data;
                        importance,       paramName= con_SCCP_imp)"
        }

  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_ConnectionConfirm
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    SCCP_param_SourceLocalReference      sourceLocRef,
    SCCP_param_ProtocolClass             protClass,
    LIN1                                 pointer1,
    SCCP_ConnConfirm_optionalPart        optionalPart optional,
    SCCP_param_EndOfOptionalParams       eop   optional
  }
  with { variant (pointer1) "POINTERTO(optionalPart)";
           variant "TAG (eop,paramName=con_SCCP_eop )"}


  //********************************************************************************
  // Message Connection Refused (CREF) (Q713 $4.4)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Optional part
  type set  SCCP_ConnRefused_optionalPart
  {
    SCCP_param_CPartyAddressEnc_opt        calledPAddress   optional,
    SCCP_param_Data_opt                    data             optional,
    SCCP_param_Importance_opt              importance       optional
  }
  with { variant "TAG (calledPAddress,    paramName= con_SCCP_cdPA;
                        data,             paramName= con_SCCP_data;
                        importance,       paramName= con_SCCP_imp)"
       }

  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_ConnectionRefused
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    SCCP_param_RefusalCause              refusalCause,
    LIN1                                 pointer1,
    SCCP_ConnRefused_optionalPart        optionalPart optional,
    SCCP_param_EndOfOptionalParams       eop   optional
  }
  with { variant (pointer1) "POINTERTO(optionalPart)";
         variant "TAG (eop,paramName=con_SCCP_eop )"}


  //********************************************************************************
  // Message Released (RLSD) (Q713 $4.5)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Optional part
  type set  SCCP_Released_optionalPart
  {
    SCCP_param_Data_opt                    data             optional,
    SCCP_param_Importance_opt              importance       optional
  }
  with { variant "TAG (data,       paramName= con_SCCP_data;
                       importance, paramName= con_SCCP_imp)"
       }

  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_Released
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    SCCP_param_SourceLocalReference      sourceLocRef,
    SCCP_param_ReleaseCause              releaseCause,
    LIN1                                 pointer1,
    SCCP_Released_optionalPart           optionalPart optional,
    SCCP_param_EndOfOptionalParams       eop   optional
  }
  with { variant (pointer1) "POINTERTO(optionalPart)";
         variant "TAG (eop,paramName=con_SCCP_eop )" }


  //********************************************************************************
  // Message Release Complete (RLC) (Q713 $4.6)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_ReleaseComplete
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    SCCP_param_SourceLocalReference      sourceLocRef
  }
  with { variant "" }


  //********************************************************************************
  // Message Data form 1 (DT1) (Q713 $4.7)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_DataForm1
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    SCCP_param_SegmentingReassembl       segmentingReassembl,
    LIN1                                 pointer1,            //always 1!
    SCCP_param_Data                      data
  }
  with { variant (pointer1) "POINTERTO(data)"; }


  //********************************************************************************
  // Message Data form 2 (DT2) (Q713 $4.8)
  //********************************************************************************

  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_DataForm2
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    SCCP_param_SequencingSegmenting      sequencingSegmenting,
    LIN1                                 pointer1,              //always 1!
    SCCP_param_Data                      data
  }
  with { variant (pointer1) "POINTERTO(data)"; }


  //********************************************************************************
  // Message Data Acknowledgement (AK) (Q713 $4.9)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_DataAcknowledgement
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    SCCP_param_RecSeqNumber              recSeqNumber,
    SCCP_param_Credit                    credit
  }
  with { variant "" }


  //********************************************************************************
  // Message Unitdata (UDT) (Q713 $4.10)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_Unitdata
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_ProtocolClass             protClass,
    LIN1                                 pointer1,       //will be 3
    LIN1                                 pointer2,
    LIN1                                 pointer3,
    SCCP_param_CPartyAddressEnc          calledPAddress,
    SCCP_param_CPartyAddressEnc          callingPAddress,
    SCCP_param_Data                      data
  }
  with {  variant (pointer1) "POINTERTO(calledPAddress)";
          variant (pointer2) "POINTERTO(callingPAddress)";
          variant (pointer3) "POINTERTO(data)"
       }


  //********************************************************************************
  // Message Unitdata service (UDTS) (Q713 $4.11)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_UnitdataService
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_ReturnCause               returnCause,
    LIN1                                 pointer1,       //will be 3
    LIN1                                 pointer2,
    LIN1                                 pointer3,
    SCCP_param_CPartyAddressEnc          calledPAddress,
    SCCP_param_CPartyAddressEnc          callingPAddress,
    SCCP_param_Data                      data
  }
  with {  variant (pointer1) "POINTERTO(calledPAddress)";
          variant (pointer2) "POINTERTO(callingPAddress)";
          variant (pointer3) "POINTERTO(data)"
       }


  //********************************************************************************
  // Message Expedited Data (ED) (Q713 $4.12)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_ExpeditedData
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    LIN1                                 pointer1,              //always 1!
    SCCP_param_Data                      data
  }
  with { variant (pointer1) "POINTERTO(data)" }


  //********************************************************************************
  // Message Expedited Data Acknowledgement (EA) (Q713 $4.13)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_ExpeditedDataAck
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef
  }
  with { variant "" }


  //********************************************************************************
  // Message Reset Request (RSR) (Q713 $4.14)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_ResetRequest
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    SCCP_param_SourceLocalReference      sourceLocRef,
    SCCP_param_ResetCause                resetCause
  }
  with { variant "" }


  //********************************************************************************
  // Message Reset Confirmation (RSC) (Q713 $4.15)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_ResetConfirm
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    SCCP_param_SourceLocalReference      sourceLocRef
  }
  with { variant "" }


  //********************************************************************************
  // Message Protocol data unit error (ERR) (Q713 $4.16)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_ProtDataUnitError
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    SCCP_param_ErrorCause                errorCause
  }
  with { variant "" }


  //********************************************************************************
  // Message Inactivity test (IT) (Q713 $4.17)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_InactivityTest
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_DestLocalReference        destLocRef,
    SCCP_param_SourceLocalReference      sourceLocRef,
    SCCP_param_ProtocolClass             protClass,
    SCCP_param_SequencingSegmenting      sequencingSegmenting,
    SCCP_param_Credit                    credit
  }
  with { variant "" }


  //********************************************************************************
  // Message Extended Unitdata (XUDT) (Q713 $4.18)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Optional part
  type record  SCCP_ExtUnitdata_optionalPart
  {
    SCCP_param_Segmentation_opt            segmentation     optional,
    SCCP_param_Importance_opt              importance       optional
  }
  with { variant "TAG (segmentation,      paramName= con_SCCP_segm;
                        importance,       paramName= con_SCCP_imp)"
       }

  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_ExtUnitdata
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_ProtocolClass             protClass,
    SCCP_param_HopCounter                hopCounter,
    LIN1                                 pointer1,      //will be 4
    LIN1                                 pointer2,
    LIN1                                 pointer3,
    LIN1                                 pointer4,
    SCCP_param_CPartyAddressEnc          calledPAddress,
    SCCP_param_CPartyAddressEnc          callingPAddress,
    SCCP_param_Data                      data,
    SCCP_ExtUnitdata_optionalPart        optionalPart optional,
    SCCP_param_EndOfOptionalParams       eop   optional
  }
  with { variant (pointer1) "POINTERTO(calledPAddress)";
         variant (pointer2) "POINTERTO(callingPAddress)";
         variant (pointer3) "POINTERTO(data)";
         variant (pointer4) "POINTERTO(optionalPart)";
         variant "TAG (eop, paramName=con_SCCP_eop )"
       }


  //********************************************************************************
  // Message Extended Unitdata Service(XUDTS) (Q713 $4.19)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Optional part
  // The same as SCCP_ExtUnitdata_optionalPart

  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_ExtUnitdataService
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_ReturnCause               returnCause,
    SCCP_param_HopCounter                hopCounter,
    LIN1                                 pointer1,      //will be 4
    LIN1                                 pointer2,
    LIN1                                 pointer3,
    LIN1                                 pointer4,
    SCCP_param_CPartyAddressEnc          calledPAddress,
    SCCP_param_CPartyAddressEnc          callingPAddress,
    SCCP_param_Data                      data,
    SCCP_ExtUnitdata_optionalPart        optionalPart optional,
    SCCP_param_EndOfOptionalParams       eop   optional
  }
  with {  variant (pointer1) "POINTERTO(calledPAddress)";
          variant (pointer2) "POINTERTO(callingPAddress)";
          variant (pointer3) "POINTERTO(data)";
          variant (pointer4) "POINTERTO(optionalPart)";
          variant "TAG (eop,paramName=con_SCCP_eop )"
        }


  //********************************************************************************
  // Message Long Unitdata (LUDT) (Q713 $4.20)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Optional part
  // The same as SCCP_ExtUnitdata_optionalPart

  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_LongUnitdata
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_ProtocolClass             protClass,
    SCCP_param_HopCounter                hopCounter,
    LIN2                                 pointer1,
    LIN2                                 pointer2,
    LIN2                                 pointer3,
    LIN2                                 pointer4,
    SCCP_param_CPartyAddressEnc          calledPAddress,
    SCCP_param_CPartyAddressEnc          callingPAddress,
    SCCP_param_LongData                  longData,
    SCCP_ExtUnitdata_optionalPart        optionalPart optional,
    SCCP_param_EndOfOptionalParams       eop   optional
   }
   with { variant (pointer1) "POINTERTO(calledPAddress)";
          variant (pointer1) "PTROFFSET(8)";
          variant (pointer2) "POINTERTO(callingPAddress)";
          variant (pointer2) "PTROFFSET(8)";
          variant (pointer3) "POINTERTO(longData)";
          variant (pointer3) "PTROFFSET(8)";
          variant (pointer4) "POINTERTO(optionalPart)";
          variant (pointer4) "PTROFFSET(8)";
          variant "TAG (eop,paramName=con_SCCP_eop) "
        }


  //********************************************************************************
  // Message Long Unitdata Service (LUDTS) (Q713 $4.21)
  //********************************************************************************
  //---------------------------------------------------------------------------
  // Optional part
  // The same as SCCP_ExtUnitdata_optionalPart

  //---------------------------------------------------------------------------
  // Message definition
  //---------------------------------------------------------------------------
  type record  PDU_SCCP_LongUnitdataService
  {
    SCCP_param_MessageType               messageType,
    SCCP_param_ReturnCause               returnCause,
    SCCP_param_HopCounter                hopCounter,
    LIN2                                 pointer1,      //will be 5
    LIN2                                 pointer2,
    LIN2                                 pointer3,
    LIN2                                 pointer4,
    SCCP_param_CPartyAddressEnc          calledPAddress,
    SCCP_param_CPartyAddressEnc          callingPAddress,
    SCCP_param_LongData                  longData,
    SCCP_ExtUnitdata_optionalPart        optionalPart optional,
    SCCP_param_EndOfOptionalParams       eop   optional
  }
  with {  variant (pointer1) "POINTERTO(calledPAddress)";
          variant (pointer1) "PTROFFSET(8)";
          variant (pointer2) "POINTERTO(callingPAddress)";
          variant (pointer2) "PTROFFSET(8)";
          variant (pointer3) "POINTERTO(longData)";
          variant (pointer3) "PTROFFSET(8)";
          variant (pointer4) "POINTERTO(optionalPart)";
          variant (pointer4) "PTROFFSET(8)";
          variant "TAG (eop,paramName=con_SCCP_eop) "
       }


  //********************************************************************************
  // SCCP management messages (Q713 $5.3)
  //********************************************************************************
  type record  PDU_SCMG_message
  {
   SCMG_param_FormatId                  messageType,
   SCMG_param_AffectedSSN               affectedSSN,
   SCMG_param_AffectedPointCode         affectedPC,
   SCMG_param_MultiplIndicator          smi,
   SCMG_param_CongestionLevel           congLevel optional
      //shall be present in all messages except SSG
  }
   with { variant "" }

  //********************************************************************************
  // SCCP Top Level PDU (Q713 $4.2)
  //********************************************************************************

  type union  PDU_SCCP
  {
    PDU_SCCP_ConnectionRequest          connrequest,
    PDU_SCCP_ConnectionRefused          connrefused,
    PDU_SCCP_Released                   released,
    PDU_SCCP_ReleaseComplete            relcomp,
    PDU_SCCP_DataForm1                  dataform1,
    PDU_SCCP_DataForm2                  dataform2,
    PDU_SCCP_DataAcknowledgement        dataack,
    PDU_SCCP_UnitdataService            udataserv,
    PDU_SCCP_ExpeditedData              expdata,
    PDU_SCCP_ExpeditedDataAck           expdataack ,
    PDU_SCCP_ResetRequest               resetreq,
    PDU_SCCP_ResetConfirm               resconf,
    PDU_SCCP_ProtDataUnitError          pduerror,
    PDU_SCCP_InactivityTest             inacttest,
    PDU_SCCP_ExtUnitdata                extudata,
    PDU_SCCP_ExtUnitdataService         extudataserv ,
    PDU_SCCP_LongUnitdata               longudata,
    PDU_SCCP_LongUnitdataService        longudataserv,
    PDU_SCCP_Unitdata                   unitdata,
    PDU_SCCP_ConnectionConfirm          connconfirm
    // PDU_SCMG_message                    scmg
  }
  with { variant "TAG (connrequest,       messageType = cr;
                       connconfirm,       messageType = cc;
                       connrefused,       messageType = cref;
                       released,          messageType = rlsd;
                       relcomp,           messageType = rlc;
                       dataform1,         messageType = dt1;
                       dataform2,         messageType = dt2;
                       dataack,           messageType = ak;
                       unitdata,          messageType = udt;
                       udataserv,         messageType = udts;
                       expdata,           messageType = ed;
                       expdataack,        messageType = ea;
                       resetreq,          messageType = rsr;
                       resconf,           messageType = rsc;
                       pduerror,          messageType = err;
                       inacttest,         messageType = it;
                       extudata,          messageType = xudt;
                       extudataserv,      messageType = xudts;
                       longudata,         messageType = ludt;
                       longudataserv,     messageType = ludts)"
       }

}//endgroup PDUDefinitions

}//endgroup Types



group OtherTypedefinitions
{//startgroup  OtherTypedefinitions

  // enum replaced with this solution:
  type integer states;
  const states
    idle:=0,
    connection_pending_OG:=1,
    connection_pending_IC:=2,
    active:=3,                 // ==data transfer, see 6.1.1.2.1/Q.711.
    disconnect_pending:=4,     // ==
    //reset_OG,- as N_RESET_req and N_RESET_resp will not be received, this state should never occur
    reset_bothway:=5,
    reset_IC:=5,
    //frozen_reference,
    wait_conn_confirm:=6;

  type record sccp_buffer
  {
    octetstring buffer,
    integer     actlen,
    integer     maxlen
  }

  // === Connection Oriented Data: ===

  // record holding all data of a connection
  type record       ConnectionData
  {
    OCT3        localReference, //segmLocReference????,
    OCT3        remoteReference, //segmRemoteRef????,
    states      state,
    integer     connectionId,
    //integer     max_len, //maximal length of input buffer
    sccp_buffer reassembler_buffer // data collected here before sending up to the User
  }

  // === Connectionless Data: =======================
  // == sending:==
  // Segmentation Local Reference
  type integer segmLocRef_states;
  const segmLocRef_states segmLocRef_idle :=0, segmLocRef_busy:=1;

  type record segmLocRef
  {
    OCT3              val,
    segmLocRef_states state
  }

  // == receiving: ==
  type record ClessRcvBuff
  {
    //OCT3        segmLocalRef,  // not used ??
    OCT3                   segmRemoteRef,
    segmLocRef_states      state,
    sccp_buffer            reassembler_buffer
  }

  type charstring SCCP_ServiceType;

  const charstring mtp3_itu  := "mtp3_itu";  // SCCP_itu
  const charstring mtp3_ansi := "mtp3_ansi"; //SCCP_ansi
  const charstring mtp3_ttc  := "mtp3_ttc";   //SCCP_ttc
  const charstring mtp3b_itu := "mtp3b_itu";
  const charstring mtp3b_ansi:= "mtp3b_ansi";
  const charstring mtp3b_ttc := "mtp3b_ttc";
  const charstring m3ua      := "m3ua";
  const charstring mtp3_mpt  := "mtp3_mpt";

  type record MSC_SCCP_MTP3_parameters
  {
    MTP3_Field_sio   sio,
    integer          opc,
    integer          dpc,
    integer          sls,
    SCCP_ServiceType sccp_serviceType,
    integer          ssn optional    //This should be set if you want only one
  }                                  //active subsystem on the link.

}//endgroup OtherTypedefinitions

group MessageTypes
{
    // *************************************************************************
    // *  ASP_sccp type definitions                                                 *
    // *************************************************************************


  //       type record ASP_MTP3_TRANSFERind_sccp
  //        {
  //         octetstring       sio length(1),  // see values in Q.704 $14.2.1
  //         integer           opc,
  //         integer           dpc,
  //         integer           sls,
  //         PDU_SCCP          data
  //        }


  type record ASP_MTP3_TRANSFERreq_sccp
  {
    octetstring       sio length(1),  // see values in Q.704 $14.2.1
    integer           opc,
    integer           dpc,
    integer           sls,
    PDU_SCCP          data
  }

}//end group Messagetypes

group ASPTemplates
{

// *************************************************************************
// *  ASP template definitions   sending
// *************************************************************************

//  template ASP_MTP3_TRANSFERind_sccp t_ASP_MTP3_TRANSFERind_sccp
//  (
//
//   octetstring  pl_sio,
//   integer      pl_opc,
//   integer      pl_dpc,
//   integer      pl_sls,
//   template PDU_SCCP  pl_data) :=
//      {
//       sio  :=                              pl_sio,
//        opc  :=                              pl_opc,
//        dpc  :=                              pl_dpc,
//        sls  :=                              pl_sls,
//        data :=                              pl_data
//       }


  template ASP_MTP3_TRANSFERreq_sccp t_ASP_MTP3_TRANSFERreq_sccp
  (

    octetstring           pl_sio,
    integer               pl_opc,
    integer               pl_dpc,
    integer               pl_sls,
    template PDU_SCCP     pl_data
    ) :=
      {
        sio  :=  pl_sio,
        opc  :=  pl_opc,
        dpc  :=  pl_dpc,
        sls  :=  pl_sls,
        data :=  pl_data
      }


// *************************************************************************
// *  ASP template definitions   receiving                                            *
// *************************************************************************


//template ASP_MTP3_TRANSFERind_sccp tr_ASP_MTP3_TRANSFERind_sccp
// (
//
//   PDU_SCCP  pl_data) :=
//       {
//        sio  :=                              ?,
//        opc  :=                              ?,
//        dpc  :=                              ?,
//        sls  :=                              ?,
//        data :=                              pl_data
//       }


  template ASP_MTP3_TRANSFERreq_sccp tr_ASP_MTP3_TRANSFERreq_sccp
  //  (

  //  PDU_SCCP    pl_data)
  :=
      {
        sio  :=                              ?,
        opc  :=                              ?,
        dpc  :=                              ?,
        sls  :=                              ?,
        data :=                              ?  //pl_data
       }






}//endgroup ASPTemplates


} with { encode "RAW" } // end module
