# h450pdu.h

Go to the documentation of this file.

    00001 /*
    00002  * h450pdu.h
    00003  *
    00004  * H.450 Helper functions
    00005  *
    00006  * Open H323 Library
    00007  *
    00008  * Copyright (c) 2001 Norwood Systems Pty. Ltd.
    00009  *
    00010  * The contents of this file are subject to the Mozilla Public License
    00011  * Version 1.0 (the "License"); you may not use this file except in
    00012  * compliance with the License. You may obtain a copy of the License at
    00013  * http://www.mozilla.org/MPL/
    00014  *
    00015  * Software distributed under the License is distributed on an "AS IS"
    00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
    00017  * the License for the specific language governing rights and limitations
    00018  * under the License.
    00019  *
    00020  * The Original Code is Open H323 Library.
    00021  *
    00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
    00023  *
    00024  * Contributor(s): ______________________________________.
    00025  *
    00026  * $Revision: 24178 $
    00027  * $Author: rjongbloed $
    00028  * $Date: 2010-04-05 19:10:56 -0500 (Mon, 05 Apr 2010) $
    00029  */
    00030
    00031 #ifndef OPAL_H323_H450PDU_H
    00032 #define OPAL_H323_H450PDU_H
    00033
    00034 #ifdef P_USE_PRAGMA
    00035 #pragma interface
    00036 #endif
    00037
    00038 #include <opal/buildopts.h>
    00039
    00040 #if OPAL_H450
    00041
    00042 #include <asn/x880.h>
    00043 #include <asn/h4501.h>
    00044 #include <asn/h4502.h>
    00045
    00046 #include <asn/h4507.h>
    00047
    00048 class H323EndPoint;
    00049 class H323Connection;
    00050 class H323TransportAddress;
    00051 class H323SignalPDU;
    00052
    00053 class H4501_EndpointAddress;
    00054 class H4501_InterpretationApdu;
    00055
    00056
    00058
    00061 class H450ServiceAPDU : public X880_ROS
    00062 {
    00063   public:
    00064     X880_Invoke& BuildInvoke(int invokeId, int operation);
    00065     X880_ReturnResult& BuildReturnResult(int invokeId);
    00066     X880_ReturnError& BuildReturnError(int invokeId, int error);
    00067     X880_Reject& BuildReject(int invokeId);
    00068
    00069     void BuildCallTransferInitiate(int invokeId,
    00070                                    const PString & callIdentity,
    00071                                    const PString & alias,
    00072                                    const H323TransportAddress & address);
    00073
    00074     void BuildCallTransferIdentify(int invokeId);
    00075     void BuildCallTransferAbandon(int invokeId);
    00076     void BuildCallTransferSetup(int invokeId,
    00077                                 const PString & callIdentity);
    00078
    00079     void BuildCallWaiting(int invokeId, int numCallsWaiting);
    00080     void BuildMessageWaiting(int invokeId,
    00081                              H4507_H323_MWI_Operations  &mwiOp,
    00082                              PASN_Sequence &argument);
    00083     void BuildInterrogateResult(int invokeId,
    00084                                 H4507_MWIInterrogateRes &interrogateResult);
    00085
    00086     void BuildCallIntrusionForcedRelease(int invokeId, int CICL);
    00087     X880_ReturnResult& BuildCallIntrusionForcedReleaseResult(int invokeId);
    00088     void BuildCallIntrusionForcedReleaseError();
    00089     void BuildCallIntrusionGetCIPL(int invokeId);
    00090     void BuildCallIntrusionImpending(int invokeId);
    00091     void BuildCallIntrusionForceRelesed(int invokeId);
    00092
    00093     void AttachSupplementaryServiceAPDU(H323SignalPDU & pdu);
    00094     PBoolean WriteFacilityPDU(
    00095       H323Connection & connection
    00096     );
    00097
    00098     static void ParseEndpointAddress(H4501_EndpointAddress & address,
    00099                                      PString & party);
    00100 };
    00101
    00102
    00103 class H450xDispatcher;
    00104
    00105 class H450xHandler : public PObject
    00106 {
    00107     PCLASSINFO(H450xHandler, PObject);
    00108   public:
    00109     H450xHandler(
    00110       H323Connection & connection,
    00111       H450xDispatcher & dispatcher
    00112     );
    00113
    00114     virtual void AttachToSetup(
    00115       H323SignalPDU & pdu
    00116     );
    00117
    00118     virtual void AttachToAlerting(
    00119       H323SignalPDU & pdu
    00120     );
    00121
    00122     virtual void AttachToConnect(
    00123       H323SignalPDU & pdu
    00124     );
    00125
    00126     virtual void AttachToReleaseComplete(
    00127       H323SignalPDU & pdu
    00128     );
    00129
    00130     virtual PBoolean OnReceivedInvoke(
    00131       int opcode,
    00132       int invokeId,
    00133       int linkedId,
    00134       PASN_OctetString * argument
    00135     ) = 0;
    00136
    00137     virtual PBoolean OnReceivedReturnResult(
    00138       X880_ReturnResult & returnResult
    00139     );
    00140
    00141     virtual PBoolean OnReceivedReturnError(
    00142       int errorCode,
    00143       X880_ReturnError & returnError
    00144     );
    00145
    00146     virtual PBoolean OnReceivedReject(
    00147       int problemType,
    00148       int problemNumber
    00149     );
    00150
    00153     void SendReturnError(int returnError);
    00154
    00155     void SendGeneralReject(int problem);
    00156
    00157     void SendInvokeReject(int problem);
    00158
    00159     void SendReturnResultReject(int problem);
    00160
    00161     void SendReturnErrorReject(int problem);
    00162
    00163     PBoolean DecodeArguments(
    00164       PASN_OctetString * argString,
    00165       PASN_Object & argObject,
    00166       int absentErrorCode
    00167     );
    00168
    00169     unsigned GetInvokeId() const { return currentInvokeId; }
    00170
    00171
    00172   protected:
    00173     H323EndPoint   & endpoint;
    00174     H323Connection & connection;
    00175     H450xDispatcher & dispatcher;
    00176     unsigned          currentInvokeId;
    00177 };
    00178
    00179 PARRAY(H450xHandlerArray, H450xHandler);
    00180 PDICTIONARY(H450xHandlerDict, POrdinalKey, H450xHandler);
    00181
    00182
    00183 class H450xDispatcher : public PObject
    00184 {
    00185     PCLASSINFO(H450xDispatcher, PObject);
    00186   public:
    00187     H450xDispatcher(
    00188       H323Connection & connection
    00189     );
    00190
    00193     void AddOpCode(
    00194       unsigned opcode,
    00195       H450xHandler * handler
    00196     );
    00197
    00198     virtual void AttachToSetup(
    00199       H323SignalPDU & pdu
    00200     );
    00201
    00202     virtual void AttachToAlerting(
    00203       H323SignalPDU & pdu
    00204     );
    00205
    00206     virtual void AttachToConnect(
    00207       H323SignalPDU & pdu
    00208     );
    00209
    00210     virtual void AttachToReleaseComplete(
    00211       H323SignalPDU & pdu
    00212     );
    00213
    00216     virtual PBoolean HandlePDU(
    00217       const H323SignalPDU & pdu
    00218     );
    00219
    00224     virtual PBoolean OnReceivedInvoke(X880_Invoke& invoke, H4501_InterpretationApdu& interpretation);
    00225
    00231     virtual PBoolean OnReceivedReturnResult(X880_ReturnResult& returnResult);
    00232
    00238     virtual PBoolean OnReceivedReturnError(X880_ReturnError& returnError);
    00239
    00245     virtual PBoolean OnReceivedReject(X880_Reject& reject);
    00246
    00249     void SendReturnError(int invokeId, int returnError);
    00250
    00251     void SendGeneralReject(int invokeId, int problem);
    00252
    00253     void SendInvokeReject(int invokeId, int problem);
    00254
    00255     void SendReturnResultReject(int invokeId, int problem);
    00256
    00257     void SendReturnErrorReject(int invokeId, int problem);
    00258
    00261     unsigned GetNextInvokeId() const { return ++nextInvokeId; }
    00262
    00263   protected:
    00264     H323Connection & connection;
    00265     H450xHandlerArray handlers;
    00266     H450xHandlerDict  opcodeHandler;
    00267     mutable unsigned  nextInvokeId;             // Next available invoke ID for H450 operations
    00268 };
    00269
    00270
    00271 class H4502Handler : public H450xHandler
    00272 {
    00273     PCLASSINFO(H4502Handler, H450xHandler);
    00274   public:
    00275     H4502Handler(
    00276       H323Connection & connection,
    00277       H450xDispatcher & dispatcher
    00278     );
    00279
    00280     virtual void AttachToSetup(
    00281       H323SignalPDU & pdu
    00282     );
    00283
    00284     virtual void AttachToAlerting(
    00285       H323SignalPDU & pdu
    00286     );
    00287
    00288     virtual void AttachToConnect(
    00289       H323SignalPDU & pdu
    00290     );
    00291
    00292     virtual void AttachToReleaseComplete(
    00293       H323SignalPDU & pdu
    00294     );
    00295
    00296     virtual PBoolean OnReceivedInvoke(
    00297       int opcode,
    00298       int invokeId,
    00299       int linkedId,
    00300       PASN_OctetString * argument
    00301     );
    00302
    00305     virtual void OnReceivedCallTransferIdentify(
    00306       int linkedId
    00307     );
    00308
    00311     virtual void OnReceivedCallTransferAbandon(
    00312       int linkedId
    00313     );
    00314
    00317     virtual void OnReceivedCallTransferInitiate(
    00318       int linkedId,
    00319       PASN_OctetString * argument
    00320     );
    00321
    00324     virtual void OnReceivedCallTransferSetup(
    00325       int linkedId,
    00326       PASN_OctetString * argument
    00327     );
    00328
    00331     virtual void OnReceivedCallTransferUpdate(
    00332       int linkedId,
    00333       PASN_OctetString * argument
    00334     );
    00335
    00338     virtual void OnReceivedSubaddressTransfer(
    00339       int linkedId,
    00340       PASN_OctetString * argument
    00341     );
    00342
    00345     virtual void OnReceivedCallTransferComplete(
    00346       int linkedId,
    00347       PASN_OctetString * argument
    00348     );
    00349
    00352     virtual void OnReceivedCallTransferActive(
    00353       int linkedId,
    00354       PASN_OctetString * argument
    00355     );
    00356
    00357     virtual PBoolean OnReceivedReturnResult(
    00358       X880_ReturnResult & returnResult
    00359     );
    00360
    00365     void OnReceivedInitiateReturnResult();
    00366
    00372     void OnReceivedSetupReturnResult();
    00373
    00378     void OnReceivedIdentifyReturnResult(X880_ReturnResult &returnResult);
    00379
    00380     virtual PBoolean OnReceivedReturnError(
    00381       int errorCode,
    00382       X880_ReturnError & returnError
    00383     );
    00384
    00389     void OnReceivedInitiateReturnError(
    00390       const bool timerExpiry = false
    00391     );
    00392
    00399     void OnReceivedSetupReturnError(
    00400       int errorCode,
    00401       const bool timerExpiry = false
    00402     );
    00403
    00408     void OnReceivedIdentifyReturnError(
    00409       const bool timerExpiry = false
    00410     );
    00411
    00416     bool TransferCall(
    00417       const PString & remoteParty,
    00418       const PString & callIdentity
    00419     );
    00420
    00425     void ConsultationTransfer(
    00426       const PString & primaryCallToken
    00427     );
    00428
    00431     void HandleConsultationTransfer(
    00432       const PString & callIdentity,
    00433       H323Connection& incoming
    00434     );
    00435
    00436     void AwaitSetupResponse(
    00437       const PString & token,
    00438       const PString & identity
    00439     );
    00440
    00443     enum State {
    00444       e_ctIdle,
    00445       e_ctAwaitIdentifyResponse,
    00446       e_ctAwaitInitiateResponse,
    00447       e_ctAwaitSetupResponse,
    00448       e_ctAwaitSetup,
    00449       e_ctAwaitConnect
    00450     };
    00451
    00454     State GetState() const { return ctState; }
    00455
    00465     virtual void onReceivedAdmissionReject(const int returnError);
    00466
    00469     void HandleCallTransferFailure(
    00470       const int returnError
    00471     );
    00472
    00475     void StartctTimer(const PTimeInterval value) { ctTimer = value; }
    00476
    00479     void StopctTimer();
    00480
    00483     PBoolean IsctTimerRunning() { return ctTimer.IsRunning(); }
    00484
    00487     PDECLARE_NOTIFIER(PTimer, H4502Handler, OnCallTransferTimeOut);
    00488
    00491     const H323Connection& getAssociatedConnection() const { return connection; }
    00492
    00495     void SetAssociatedCallToken(const PString& token) { CallToken = token; }
    00496
    00499     const PString& getTransferringCallToken() const { return transferringCallToken; }
    00500
    00503     void SetConsultationTransferSuccess() { consultationTransfer = true; }
    00504
    00507     PBoolean isConsultationTransferSuccess() { return consultationTransfer; }
    00508
    00509   protected:
    00510     PString transferringCallToken;    // Stores the call token for the transferring connection (if there is one)
    00511     PString transferringCallIdentity; // Stores the call identity for the transferring call (if there is one)
    00512     State   ctState;                  // Call Transfer state of the conneciton
    00513     PBoolean    ctResponseSent;           // Has a callTransferSetupReturnResult been sent?
    00514     PTimer  ctTimer;                  // Call Transfer Timer - Handles all four timers CT-T1,
    00515     PString CallToken;                // Call Token of the associated connection
    00516                                       // (used during a consultation transfer).
    00517     PBoolean consultationTransfer;        // Flag used to indicate whether an incoming call is involved in
    00518                                       // a transfer through consultation.
    00519 };
    00520
    00521
    00522 class H4504Handler : public H450xHandler
    00523 {
    00524     PCLASSINFO(H4504Handler, H450xHandler);
    00525   public:
    00526     H4504Handler(
    00527       H323Connection & connection,
    00528       H450xDispatcher & dispatcher
    00529     );
    00530
    00531     virtual PBoolean OnReceivedInvoke(
    00532       int opcode,
    00533       int invokeId,
    00534       int linkedId,
    00535       PASN_OctetString * argument
    00536     );
    00537
    00540     virtual void OnReceivedLocalCallHold(
    00541       int linkedId
    00542     );
    00543
    00546     virtual void OnReceivedLocalCallRetrieve(
    00547       int linkedId
    00548     );
    00549
    00553     virtual void OnReceivedRemoteCallHold(
    00554       int linkedId
    00555     );
    00556
    00560     virtual void OnReceivedRemoteCallRetrieve(
    00561       int linkedId
    00562     );
    00563
    00567     bool HoldCall(
    00568       PBoolean localHold
    00569     );
    00570
    00574     bool RetrieveCall();
    00575
    00578     enum State {
    00579       e_ch_Idle,
    00580       e_ch_NE_Held,
    00581       e_ch_RE_Requested,
    00582       e_ch_RE_Held,
    00583       e_ch_RE_Retrieve_Req
    00584     };
    00585
    00586     State GetState() const { return holdState; }
    00587
    00588
    00589   protected:
    00590     State holdState;  // Call Hold state of this connection
    00591 };
    00592
    00593
    00594 class H4506Handler : public H450xHandler
    00595 {
    00596     PCLASSINFO(H4506Handler, H450xHandler);
    00597   public:
    00598     H4506Handler(
    00599       H323Connection & connection,
    00600       H450xDispatcher & dispatcher
    00601     );
    00602
    00603     virtual PBoolean OnReceivedInvoke(
    00604       int opcode,
    00605       int invokeId,
    00606       int linkedId,
    00607       PASN_OctetString * argument
    00608     );
    00609
    00612     virtual void OnReceivedCallWaitingIndication(
    00613       int linkedId,
    00614       PASN_OctetString *argument
    00615     );
    00616
    00622     virtual void AttachToAlerting(
    00623       H323SignalPDU & pdu,
    00624       unsigned numberOfCallsWaiting = 0
    00625     );
    00626
    00629     enum State {
    00630       e_cw_Idle,
    00631       e_cw_Invoked
    00632     };
    00633
    00634     State GetState() const { return cwState; }
    00635
    00636
    00637   protected:
    00638     State cwState;  // Call Waiting state of this connection
    00639 };
    00640
    00644 class H4507Handler : public H450xHandler
    00645 {
    00646     PCLASSINFO(H4507Handler, H450xHandler);
    00647   public:
    00648     H4507Handler(
    00649       H323Connection & connection,
    00650       H450xDispatcher & dispatcher
    00651     );
    00652
    00653     virtual PBoolean OnReceivedInvoke(
    00654       int opcode,
    00655       int invokeId,
    00656       int linkedId,
    00657       PASN_OctetString * argument
    00658     );
    00659
    00660
    00664     virtual void AttachToSetup(H323SignalPDU & setupPDU,
    00665                                H4507_H323_MWI_Operations  &mwiOp,
    00666                                PASN_Sequence &argument);
    00667
    00670     virtual void AttachInterrogateResultToPdu(H323SignalPDU & pdu,
    00671                                               H4507_MWIInterrogateRes &interrogateResult);
    00672     virtual void AttachErrorToPdu(H323SignalPDU & pdu,
    00673                                         H4507_MessageWaitingIndicationErrors error);
    00676     enum State {
    00677       e_mwi_Idle,
    00678       e_mwi_Invoked
    00679     };
    00680
    00681     State GetState() const { return mwiState; }
    00682
    00683
    00684   protected:
    00685     State mwiState;  // Message waiting state of this connection
    00686 };
    00687
    00688
    00689 class H45011Handler : public H450xHandler
    00690 {
    00691   PCLASSINFO(H45011Handler, H450xHandler);
    00692   public:
    00693     H45011Handler(
    00694       H323Connection & connection,
    00695       H450xDispatcher & dispatcher
    00696     );
    00697
    00698     virtual void AttachToSetup(
    00699       H323SignalPDU & pdu
    00700     );
    00701
    00702     virtual void AttachToAlerting(
    00703       H323SignalPDU & pdu
    00704     );
    00705
    00706     virtual void AttachToConnect(
    00707       H323SignalPDU & pdu
    00708     );
    00709
    00710     virtual void AttachToReleaseComplete(
    00711       H323SignalPDU & pdu
    00712     );
    00713
    00714     virtual PBoolean OnReceivedInvoke(
    00715       int opcode,
    00716       int invokeId,
    00717       int linkedId,
    00718       PASN_OctetString * argument
    00719     );
    00720
    00723     virtual void OnReceivedCallIntrusionRequest(
    00724       int linkedId,
    00725       PASN_OctetString *argument
    00726     );
    00727
    00730     virtual void OnReceivedCallIntrusionGetCIPL(
    00731       int linkedId,
    00732       PASN_OctetString *argument
    00733     );
    00734
    00737     virtual void OnReceivedCallIntrusionIsolate(
    00738       int linkedId,
    00739       PASN_OctetString *argument
    00740     );
    00741
    00744     virtual PBoolean OnReceivedCallIntrusionForcedRelease(
    00745       int linkedId,
    00746       PASN_OctetString *argument
    00747     );
    00748
    00751     virtual void OnReceivedCallIntrusionWOBRequest(
    00752       int linkedId,
    00753       PASN_OctetString *argument
    00754     );
    00755
    00758     virtual void OnReceivedCallIntrusionSilentMonitor(
    00759       int linkedId,
    00760       PASN_OctetString *argument
    00761     );
    00762
    00765     virtual void OnReceivedCallIntrusionNotification(
    00766       int linkedId,
    00767       PASN_OctetString *argument
    00768     );
    00769
    00772     virtual void OnReceivedCfbOverride(
    00773       int linkedId,
    00774       PASN_OctetString *argument
    00775     );
    00776
    00779     virtual void OnReceivedRemoteUserAlerting(
    00780       int linkedId,
    00781       PASN_OctetString *argument
    00782     );
    00783
    00786     virtual void OnReceivedCallWaiting(
    00787       int linkedId,
    00788       PASN_OctetString *argument
    00789     );
    00790
    00791     virtual PBoolean OnReceivedReturnResult(
    00792       X880_ReturnResult & returnResult
    00793     );
    00794
    00795     void OnReceivedCIRequestResult(/*X880_ReturnResult & returnResult*/);
    00796
    00797     virtual PBoolean OnReceivedReturnError(
    00798       int errorCode,
    00799       X880_ReturnError & returnError
    00800     );
    00801
    00802     PBoolean OnReceivedInvokeReturnError (
    00803       int errorCode,
    00804       const bool timerExpiry = false
    00805     );
    00806
    00807     void OnReceivedCIGetCIPLResult(
    00808       X880_ReturnResult & returnResult
    00809     );
    00810
    00811     PBoolean OnReceivedGetCIPLReturnError(
    00812       int errorCode,
    00813       const bool timerExpiry = false
    00814     );
    00815
    00816     void IntrudeCall(int CICL );
    00817
    00818     void AwaitSetupResponse(
    00819       const PString & token,
    00820       const PString & identity
    00821     );
    00822
    00823     PBoolean GetRemoteCallIntrusionProtectionLevel(
    00824       const PString & intrusionCallToken,
    00825       unsigned intrusionCICL
    00826     );
    00827
    00828     void SetIntrusionImpending();
    00829
    00830     void SetForcedReleaseAccepted();
    00831
    00832     void SetIntrusionNotAuthorized();
    00833
    00834     virtual PBoolean OnReceivedReject(
    00835       int problemType,
    00836       int problemNumber
    00837     );
    00838
    00841     enum State {
    00842       e_ci_Idle,
    00843       e_ci_WaitAck,
    00844       e_ci_GetCIPL,
    00845       e_ci_OrigInvoked,
    00846       e_ci_OrigIsolated,
    00847       e_ci_DestNotify,
    00848       e_ci_DestInvoked,
    00849       e_ci_DestIsolated,
    00850       e_ci_DestWOB,
    00851       e_ci_IsolationRequest,
    00852       e_ci_ForcedReleaseRequest,
    00853       e_ci_WOBRequest
    00854     };
    00855
    00857     enum Generate{
    00858       e_ci_gIdle,
    00859       e_ci_gConferenceRequest,
    00860       e_ci_gHeldRequest,
    00861       e_ci_gSilentMonitorRequest,
    00862       e_ci_gIsolationRequest,
    00863       e_ci_gForcedReleaseRequest,
    00864       e_ci_gWOBRequest
    00865     };
    00866
    00868     enum SendState{
    00869       e_ci_sIdle,
    00870       e_ci_sAttachToSetup,
    00871       e_ci_sAttachToAlerting,
    00872       e_ci_sAttachToConnect,
    00873       e_ci_sAttachToReleseComplete
    00874     };
    00875
    00877     enum ReturnState{
    00878       e_ci_rIdle,
    00879       e_ci_rCallIntrusionImpending,
    00880       e_ci_rCallIntruded,
    00881       e_ci_rCallIsolated,
    00882       e_ci_rCallForceReleased,
    00883       e_ci_rCallForceReleaseResult,
    00884       e_ci_rCallIntrusionComplete,
    00885       e_ci_rCallIntrusionEnd,
    00886       e_ci_rNotBusy,
    00887       e_ci_rTempUnavailable,
    00888       e_ci_rNotAuthorized
    00889     };
    00890
    00893     State GetState() const { return ciState; }
    00894
    00897     void StartciTimer(const PTimeInterval value) { ciTimer = value; }
    00898
    00901     void StopciTimer();
    00902
    00905     PBoolean IsctTimerRunning() { return ciTimer.IsRunning(); }
    00906
    00909     PDECLARE_NOTIFIER(PTimer, H45011Handler, OnCallIntrudeTimeOut);
    00910
    00911   protected:
    00912     State       ciState;               // Call state of this connection
    00913     PTimer      ciTimer;               // Call Intrusion Timer - Handles all six timers CI-T1 to CI-T6,
    00914     PString     intrudingCallToken;
    00915     PString     intrudingCallIdentity;
    00916     PString     activeCallToken;
    00917     ReturnState ciReturnState;
    00918     SendState   ciSendState;
    00919     Generate    ciGenerateState;
    00920     int         ciCICL;
    00921     unsigned    intrudingCallCICL;
    00922 };
    00923
    00924
    00925 #endif // OPAL_H450
    00926
    00927 #endif // OPAL_H323_H450PDU_H
    00928
    00929