TCAPMessages {itu-t recommendation q 773 modules(2) messages(1) version3(3)}
DEFINITIONS IMPLICIT TAGS ::=
BEGIN

-- EXPORTS everything
-- Transaction Portion fields.
IMPORTS
  ROS{}, InvokeId
    FROM Remote-Operations-Generic-ROS-PDUs {joint-iso-itu-t
      remote-operations(4) generic-ROS-PDUs(6) version1(0)}
  OPERATION
    FROM Remote-Operations-Information-Objects {joint-iso-itu-t
      remote-operations(4) informationObjects(5) version1(0)};

TCMessage{OPERATION:Invokable, OPERATION:Returnable} ::= CHOICE {
  unidirectional  [APPLICATION 1]  Unidirectional{{Invokable}, {Returnable}},
  begin           [APPLICATION 2]  Begin{{Invokable}, {Returnable}},
  end             [APPLICATION 4]  End{{Invokable}, {Returnable}},
  continue        [APPLICATION 5]  Continue{{Invokable}, {Returnable}},
  abort           [APPLICATION 7]  Abort
}

Unidirectional{OPERATION:Invokable, OPERATION:Returnable} ::= SEQUENCE {
  dialoguePortion  DialoguePortion OPTIONAL,
  components       ComponentPortion{{Invokable}, {Returnable}}
}

Begin{OPERATION:Invokable, OPERATION:Returnable} ::= SEQUENCE {
  otid             OrigTransactionID,
  dialoguePortion  DialoguePortion OPTIONAL,
  components       ComponentPortion{{Invokable}, {Returnable}} OPTIONAL
}

End{OPERATION:Invokable, OPERATION:Returnable} ::= SEQUENCE {
  dtid             DestTransactionID,
  dialoguePortion  DialoguePortion OPTIONAL,
  components       ComponentPortion{{Invokable}, {Returnable}} OPTIONAL
}

Continue{OPERATION:Invokable, OPERATION:Returnable} ::= SEQUENCE {
  otid             OrigTransactionID,
  dtid             DestTransactionID,
  dialoguePortion  DialoguePortion OPTIONAL,
  components       ComponentPortion{{Invokable}, {Returnable}} OPTIONAL
}

Abort ::= SEQUENCE {
  dtid    DestTransactionID,
  reason  CHOICE {p-abortCause  P-AbortCause,
                  u-abortCause  DialoguePortion} OPTIONAL
}
-- NOTE - When the Abort Message is generated by the Transaction sublayer, a p-Abort Cause may be 
-- present. The u-abortCause may be generated by the component sublayer in which case it is an ABRT 
-- APDU, or by the TC-User in which case it could be either an ABRT APDU or data in some user-defined
-- abstract syntax.

DialoguePortion ::= [APPLICATION 11] EXPLICIT EXTERNAL
-- The dialogue portion carries the dialogue control PDUs as value of the external data type. The direct 
-- reference should be set to {itu-t recommendation q 773 as(1) dialogue-as(1) version1(1)} if structured 
-- dialogue is used and to {itu-t recommendation q 773 as(1) unidialogue-as(2) version1(1)} if unstructured 
-- dialogue is used.

OrigTransactionID ::= [APPLICATION 8]  OCTET STRING(SIZE (1..4))

DestTransactionID ::= [APPLICATION 9]  OCTET STRING(SIZE (1..4))

P-AbortCause ::= [APPLICATION 10]  INTEGER {
  unrecognizedMessageType(0), unrecognizedTransactionID(1),
  badlyFormattedTransactionPortion(2), incorrectTransactionPortion(3),
  resourceLimitation(4)}(0..127)

-- COMPONENT PORTION. The last field in the transaction portion of the TCAP message is the 
-- component portion. The component portion may be absent.
ComponentPortion{OPERATION:Invokable, OPERATION:Returnable} ::=
  [APPLICATION 12] SEQUENCE SIZE (1..MAX) OF Component{{Invokable}, {Returnable}}

-- Component Portion fields
-- Recommendation X.880 defines four Application Protocol Data Units (APDUs) for invoking
-- operations, returning results or error, and for the rejection of invalid PDUs.
-- TCAP adds returnResultNotLast to allow for the segmentation of a result.
Component{OPERATION:Invokable, OPERATION:Returnable} ::= CHOICE {
  basicROS             ROS{{TCInvokeIdSet}, {Invokable}, {Returnable}},
  returnResultNotLast  [7]  returnResult < ROS{{TCInvokeIdSet}, {Invokable}, {Returnable}}
}

TCInvokeIdSet ::= InvokeId(WITH COMPONENTS { present  (-128..127) })


END -- TCAPMessages
