TCAPPackage
{iso(1) memberbody(2) usa(840) t1-114(10013) modules(0) tcapPackage(0) version4(4)} DEFINITIONS ::=

BEGIN

IMPORTS
   OPERATION, ERROR
      FROM TCAP-Remote-Operations-Information-Objects
      {iso(1) memberbody(2) usa(840) t1-114(10013) modules(0) informationObjects(1) version4(4)};

PackageType ::= CHOICE {
   unidirectional           [PRIVATE 1]  IMPLICIT UniTransactionPDU,
   queryWithPerm            [PRIVATE 2]  IMPLICIT TransactionPDU,
   queryWithoutPerm         [PRIVATE 3]  IMPLICIT TransactionPDU,
   response                 [PRIVATE 4]  IMPLICIT TransactionPDU,
   conversationWithPerm     [PRIVATE 5]  IMPLICIT TransactionPDU,
   conversationWithoutPerm  [PRIVATE 6]  IMPLICIT TransactionPDU,
   abort                    [PRIVATE 22] IMPLICIT Abort
}

UniTransactionPDU ::= SEQUENCE {
   identifier               TransactionID,
   dialoguePortion          DialoguePortion OPTIONAL,
   componentPortion         ComponentSequence
}

TransactionPDU ::= SEQUENCE {
   identifier               TransactionID,
   dialoguePortion          DialoguePortion OPTIONAL,
   componentPortion         ComponentSequence OPTIONAL
}
-- TransactionPDU should include either a Dialogue Portion, 
-- a Component Sequence or both

TransactionID ::= [PRIVATE 7] IMPLICIT OCTET STRING
-- 0 octets for the Unidirectional, 4 octets for Query, Response & Abort
-- 8 octets for Conversation in the order Originating then Responding TID

Abort ::= SEQUENCE {
   identifier               TransactionID,
   dialoguePortion          DialoguePortion OPTIONAL,
   causeInformation         CHOICE {
                               abortCause       P-Abort-cause,
                               userInformation  UserAbortInformation
                            } OPTIONAL
}
-- When the Abort package is generated by the Transaction sublayer,
-- the P-Abort-cause must be present

P-Abort-cause ::= [PRIVATE 23] IMPLICIT INTEGER {
   unrecognizedPackageType(1),
   incorrectTransactionPortion(2),
   badlyStructuredTransactionPortion(3),
   unassignedRespondingTransactionID(4),
   permissionToReleaseProblem(5), -- for further study
   resourceUnavailable(6),
   unrecognizedDialoguePortionID(7),
   badlyStructuredDialoguePortion(8),
   missingDialoguePortion(9),
   inconsistentDialoguePortion(10)
}

DialoguePortion ::= [PRIVATE 25] IMPLICIT SEQUENCE {
   version                  ProtocolVersion OPTIONAL,
   applicationContext       CHOICE {
                               integerApplicationId  IntegerApplicationContext,
                               objectApplicationId   ObjectIDApplicationContext
                            } OPTIONAL,
   userInformation          UserInformation OPTIONAL,
   securityContext          CHOICE {
                               integerSecurityId  [0] IMPLICIT INTEGER,
                               objectSecurityId   [1] IMPLICIT OBJECT IDENTIFIER
                            } OPTIONAL,
   confidentiality          [2] IMPLICIT Confidentiality OPTIONAL
}

ProtocolVersion ::= [PRIVATE 26] IMPLICIT OCTET STRING(SIZE (1))
-- 0000 0000 not used
-- 0000 0001 T1.114-1996
-- 0000 0010 T1.114-2000
-- other reserved
-- These values can be combined using the bit-wise logical or operation
-- to indicate support for more than one version, e.g. the value 0000 0011
-- means that both 1996 and 2000 versions are supported

IntegerApplicationContext ::= [PRIVATE 27] IMPLICIT INTEGER

ObjectIDApplicationContext ::= [PRIVATE 28] IMPLICIT OBJECT IDENTIFIER

UserInformation ::= [PRIVATE 29] IMPLICIT SEQUENCE OF EXTERNAL

Confidentiality ::= SEQUENCE {
   confidentialityId        CHOICE {
                               integerConfidentialityId  [0] IMPLICIT INTEGER,
	                            objectConfidentialityId   [1] IMPLICIT OBJECT IDENTIFIER
                            } OPTIONAL,
   ...
   -- The extension marker indicates the possible presence of items
   -- in the confidentiality set that are used by the confidentiality
   -- algorithm.
}

UserAbortInformation ::= [PRIVATE 24]  EXTERNAL

ComponentSequence ::= [PRIVATE 8] IMPLICIT SEQUENCE OF ComponentPDU{InvokeId, {Invocable}, {Returnable}}
-- Component Portion specification starts below
ComponentPDU{InvokeId:InvokeIdSet, OPERATION:Invocable, OPERATION:Returnable}
   ::= CHOICE {
   invokeLast               [PRIVATE 9] IMPLICIT Invoke{{InvokeIdSet}, {Invocable}}
                                (CONSTRAINED BY { -- invocable.&invokeLast must be TRUE --}
                                   ! RejectProblem:generalincorrectComponentPortion),
   returnResultLast         [PRIVATE 10] IMPLICIT ReturnResult{{Returnable}},
   returnError              [PRIVATE 11] IMPLICIT ReturnError{{Errors  {{Returnable}}}},
   reject                   [PRIVATE 12] IMPLICIT Reject,
   invokeNotLast            [PRIVATE 13] IMPLICIT Invoke{{InvokeIdSet}, {Invocable}}
                                (CONSTRAINED BY { -- invocable.&invokeLast must be FALSE --}
                                   ! RejectProblem:generalincorrectComponentPortion),
   returnResultNotLast      [PRIVATE 14] IMPLICIT ReturnResult{{Returnable}}
} (CONSTRAINED BY {-- must conform to the above definition --} ! RejectProblem:generalunrecognisedComponentType)

Invoke{InvokeId:InvokeIdSet, OPERATION:Operations} ::= SEQUENCE {
   componentIDs             [PRIVATE 15] IMPLICIT OCTET STRING(SIZE (0..2))
                                -- The invoke ID precedes the correlation id. There may be no
                                -- identifier,only an invoke ID, or both invoke and correlation ID.
                                (CONSTRAINED BY {-- must be unambiguous --} 
                                   ! RejectProblem:invokeduplicateInvocation)
                                (CONSTRAINED BY {-- correlation ID must identify an outstanding operation --} 
                                   ! RejectProblem:invokeunrecognisedCorrelationId) OPTIONAL,
   -- operationCode
   opcode                    OPERATION.&operationCode ({Operations} ! RejectProblem:invokeunrecognisedOperation),
                              --    OPERATION.&ParameterType
   parameter                 OPERATION.&ResultType ({Operations}{@opcode}
                                   ! RejectProblem:invoke-mistypedArgument) OPTIONAL
} (CONSTRAINED BY {-- must conform to the above definition --} ! RejectProblem:generalincorrectComponentPortion)
  (CONSTRAINED BY {-- must have consistent encoding --} ! RejectProblem:generalbadlyStructuredCompPortion)
  (CONSTRAINED BY {-- must conform to T1.114.3 encoding rules --} ! RejectProblem:generalincorrectComponentCoding)

ReturnResult{OPERATION:Operations} ::= SEQUENCE {
   componentID               [PRIVATE 15] IMPLICIT OCTET STRING(SIZE (1))
                                (CONSTRAINED BY {-- must be that of an outstanding operation --}
                                   ! RejectProblem:returnResultunrecognisedCorrelationId)
                                (CONSTRAINED BY {-- which returns a result --}
                                   ! RejectProblem:returnResultunexpectedReturnResult),
   parameter                 OPERATION.&ResultType
                                 --     ({Operations}{@opcode} !RejectProblem:returnResultincorrectParameter)
                                 OPTIONAL
}  (CONSTRAINED BY {-- must conform to the above definition --} ! RejectProblem:generalincorrectComponentPortion)
   (CONSTRAINED BY {-- must have consistent encoding --} ! RejectProblem:generalbadlyStructuredCompPortion)
   (CONSTRAINED BY {-- must conform to T1.114.3 encoding rules --} ! RejectProblem:generalincorrectComponentCoding)

ReturnError{ERROR:Errors} ::= SEQUENCE {
   componentID               [PRIVATE 15] IMPLICIT OCTET STRING(SIZE (1))
                                (CONSTRAINED BY {-- must be that of an outstanding operation --}
                                   ! RejectProblem:returnErrorunrecognisedCorrelationId)
                                (CONSTRAINED BY {-- which returns an error --}
                                   ! RejectProblem:returnErrorunexpectedReturnError),
   errorCode                 ERROR.&errorCode({Errors} ! RejectProblem:returnErrorunrecognisedError)
                                (CONSTRAINED BY {-- must be in the &Errors field of the associated operation --}
                                   ! RejectProblem:returnErrorunexpectedError),
   parameter                 ERROR.&ParameterType ({Errors}{@errorCode} !RejectProblem:returnErrorincorrectParameter) OPTIONAL
}  (CONSTRAINED BY {-- must conform to the above definition --} ! RejectProblem:generalincorrectComponentPortion)
   (CONSTRAINED BY {-- must have consistent encoding --} ! RejectProblem:generalbadlyStructuredCompPortion)
   (CONSTRAINED BY {-- must conform to T1.114.3 encoding rules --} ! RejectProblem:generalincorrectComponentCoding)

Reject ::= SEQUENCE {
   componentID               [PRIVATE 15] IMPLICIT OCTET STRING(SIZE (0..1)),
   rejectProblem             [PRIVATE 21] IMPLICIT Problem,
   parameter                 CHOICE {
                                paramSequence  [PRIVATE 16] IMPLICIT SEQUENCE {},
                                paramSet       [PRIVATE 18] IMPLICIT SET {}
                                -- The choice between paramSequence and paramSet is implementation
                                -- dependent, however paramSequence is preferred.
                             }
}  (CONSTRAINED BY {-- must conform to the above definition --} ! RejectProblem:generalincorrectComponentPortion)
   (CONSTRAINED BY {-- must have consistent encoding --} ! RejectProblem:generalbadlyStructuredCompPortion)
   (CONSTRAINED BY {-- must conform to T1.114.3 encoding rules --} !  RejectProblem:generalincorrectComponentCoding)

-- PROBLEMS, the specification of Problems follows
Problem ::= INTEGER {
   generalunrecognisedComponentType(257),
   generalincorrectComponentPortion(258),
   generalbadlyStructuredCompPortion(259),
   generalincorrectComponentCoding(260),
   invokeduplicateInvocation(513),
   invokeunrecognisedOperation(514),
   invokeincorrectParameter(515),
   invokeunrecognisedCorrelationID(516),
   returnResultunrecognisedCorrelationID(769),
   returnResultunexpectedReturnResult(770),
   returnResultincorrectParameter(771),
   returnErrorunrecognisedCorrelationID(1025),
   returnErrorunexpectedReturnError(1026),
   returnErrorunrecognisedError(1027),
   returnErrorunexpectedError(1028),
   returnErrorincorrectParameter(1029),
   -- Applications using T1.114-1988 report Transaction portion
   -- problems using a Reject component with a problem code in
   -- the range 1281e6
   -- It is preferred that other applications report
   -- these problems using the Abort package type
   transactionunrecognizedPackageType(1281),
   transactionincorrectTransPortion(1282),
   transactionbadlyStructuredTransPortion(1283),
   transactionunassignedRespondingTransID(1284),
   transactionpermissionToReleaseProblem(1285),
   transactionresourceUnavailable(1286)
}
								    
TCInvokeIdSet ::= InvokeId(WITH COMPONENTS { present  (-128..127) })

END
