# 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: 21004 $
    00027  * $Author: rjongbloed $
    00028  * $Date: 2008-09-16 07:08:56 +0000 (Tue, 16 Sep 2008) $
    00029  */
    00030
    00031 #ifndef __OPAL_H450PDU_H
    00032 #define __OPAL_H450PDU_H
    00033
    00034 #ifdef P_USE_PRAGMA
    00035 #pragma interface
    00036 #endif
    00037
    00038 #include <opal/buildopts.h>
    00039
    00040 #include <asn/x880.h>
    00041 #include <asn/h4501.h>
    00042 #include <asn/h4502.h>
    00043
    00044 #include <asn/h4507.h>
    00045
    00046 class H323EndPoint;
    00047 class H323Connection;
    00048 class H323TransportAddress;
    00049 class H323SignalPDU;
    00050
    00051 class H4501_EndpointAddress;
    00052 class H4501_InterpretationApdu;
    00053
    00054
    00056
    00059 class H450ServiceAPDU : public X880_ROS
    00060 {
    00061   public:
    00062     X880_Invoke& BuildInvoke(int invokeId, int operation);
    00063     X880_ReturnResult& BuildReturnResult(int invokeId);
    00064     X880_ReturnError& BuildReturnError(int invokeId, int error);
    00065     X880_Reject& BuildReject(int invokeId);
    00066
    00067     void BuildCallTransferInitiate(int invokeId,
    00068                                    const PString & callIdentity,
    00069                                    const PString & alias,
    00070                                    const H323TransportAddress & address);
    00071
    00072     void BuildCallTransferIdentify(int invokeId);
    00073     void BuildCallTransferAbandon(int invokeId);
    00074     void BuildCallTransferSetup(int invokeId,
    00075                                 const PString & callIdentity);
    00076
    00077     void BuildCallWaiting(int invokeId, int numCallsWaiting);
    00078     void BuildMessageWaiting(int invokeId,
    00079                              H4507_H323_MWI_Operations  &mwiOp,
    00080                              PASN_Sequence &argument);
    00081     void BuildInterrogateResult(int invokeId,
    00082                                 H4507_MWIInterrogateRes &interrogateResult);
    00083
    00084     void BuildCallIntrusionForcedRelease(int invokeId, int CICL);
    00085     X880_ReturnResult& BuildCallIntrusionForcedReleaseResult(int invokeId);
    00086     void BuildCallIntrusionForcedReleaseError();
    00087     void BuildCallIntrusionGetCIPL(int invokeId);
    00088     void BuildCallIntrusionImpending(int invokeId);
    00089     void BuildCallIntrusionForceRelesed(int invokeId);
    00090
    00091     void AttachSupplementaryServiceAPDU(H323SignalPDU & pdu);
    00092     PBoolean WriteFacilityPDU(
    00093       H323Connection & connection
    00094     );
    00095
    00096     static void ParseEndpointAddress(H4501_EndpointAddress & address,
    00097                                      PString & party);
    00098 };
    00099
    00100
    00101 class H450xDispatcher;
    00102
    00103 class H450xHandler : public PObject
    00104 {
    00105     PCLASSINFO(H450xHandler, PObject);
    00106   public:
    00107     H450xHandler(
    00108       H323Connection & connection,
    00109       H450xDispatcher & dispatcher
    00110     );
    00111
    00112     virtual void AttachToSetup(
    00113       H323SignalPDU & pdu
    00114     );
    00115
    00116     virtual void AttachToAlerting(
    00117       H323SignalPDU & pdu
    00118     );
    00119
    00120     virtual void AttachToConnect(
    00121       H323SignalPDU & pdu
    00122     );
    00123
    00124     virtual void AttachToReleaseComplete(
    00125       H323SignalPDU & pdu
    00126     );
    00127
    00128     virtual PBoolean OnReceivedInvoke(
    00129       int opcode,
    00130       int invokeId,
    00131       int linkedId,
    00132       PASN_OctetString * argument
    00133     ) = 0;
    00134
    00135     virtual PBoolean OnReceivedReturnResult(
    00136       X880_ReturnResult & returnResult
    00137     );
    00138
    00139     virtual PBoolean OnReceivedReturnError(
    00140       int errorCode,
    00141       X880_ReturnError & returnError
    00142     );
    00143
    00144     virtual PBoolean OnReceivedReject(
    00145       int problemType,
    00146       int problemNumber
    00147     );
    00148
    00151     void SendReturnError(int returnError);
    00152
    00153     void SendGeneralReject(int problem);
    00154
    00155     void SendInvokeReject(int problem);
    00156
    00157     void SendReturnResultReject(int problem);
    00158
    00159     void SendReturnErrorReject(int problem);
    00160
    00161     PBoolean DecodeArguments(
    00162       PASN_OctetString * argString,
    00163       PASN_Object & argObject,
    00164       int absentErrorCode
    00165     );
    00166
    00167     unsigned GetInvokeId() const { return currentInvokeId; }
    00168
    00169
    00170   protected:
    00171     H323EndPoint   & endpoint;
    00172     H323Connection & connection;
    00173     H450xDispatcher & dispatcher;
    00174     unsigned          currentInvokeId;
    00175 };
    00176
    00177 PARRAY(H450xHandlerArray, H450xHandler);
    00178 PDICTIONARY(H450xHandlerDict, POrdinalKey, H450xHandler);
    00179
    00180
    00181 class H450xDispatcher : public PObject
    00182 {
    00183     PCLASSINFO(H450xDispatcher, PObject);
    00184   public:
    00185     H450xDispatcher(
    00186       H323Connection & connection
    00187     );
    00188
    00191     void AddOpCode(
    00192       unsigned opcode,
    00193       H450xHandler * handler
    00194     );
    00195
    00196     virtual void AttachToSetup(
    00197       H323SignalPDU & pdu
    00198     );
    00199
    00200     virtual void AttachToAlerting(
    00201       H323SignalPDU & pdu
    00202     );
    00203
    00204     virtual void AttachToConnect(
    00205       H323SignalPDU & pdu
    00206     );
    00207
    00208     virtual void AttachToReleaseComplete(
    00209       H323SignalPDU & pdu
    00210     );
    00211
    00214     virtual PBoolean HandlePDU(
    00215       const H323SignalPDU & pdu
    00216     );
    00217
    00222     virtual PBoolean OnReceivedInvoke(X880_Invoke& invoke, H4501_InterpretationApdu& interpretation);
    00223
    00229     virtual PBoolean OnReceivedReturnResult(X880_ReturnResult& returnResult);
    00230
    00236     virtual PBoolean OnReceivedReturnError(X880_ReturnError& returnError);
    00237
    00243     virtual PBoolean OnReceivedReject(X880_Reject& reject);
    00244
    00247     void SendReturnError(int invokeId, int returnError);
    00248
    00249     void SendGeneralReject(int invokeId, int problem);
    00250
    00251     void SendInvokeReject(int invokeId, int problem);
    00252
    00253     void SendReturnResultReject(int invokeId, int problem);
    00254
    00255     void SendReturnErrorReject(int invokeId, int problem);
    00256
    00259     unsigned GetNextInvokeId() const { return ++nextInvokeId; }
    00260
    00261   protected:
    00262     H323Connection & connection;
    00263     H450xHandlerArray handlers;
    00264     H450xHandlerDict  opcodeHandler;
    00265     mutable unsigned  nextInvokeId;             // Next available invoke ID for H450 operations
    00266 };
    00267
    00268
    00269 class H4502Handler : public H450xHandler
    00270 {
    00271     PCLASSINFO(H4502Handler, H450xHandler);
    00272   public:
    00273     H4502Handler(
    00274       H323Connection & connection,
    00275       H450xDispatcher & dispatcher
    00276     );
    00277
    00278     virtual void AttachToSetup(
    00279       H323SignalPDU & pdu
    00280     );
    00281
    00282     virtual void AttachToAlerting(
    00283       H323SignalPDU & pdu
    00284     );
    00285
    00286     virtual void AttachToConnect(
    00287       H323SignalPDU & pdu
    00288     );
    00289
    00290     virtual void AttachToReleaseComplete(
    00291       H323SignalPDU & pdu
    00292     );
    00293
    00294     virtual PBoolean OnReceivedInvoke(
    00295       int opcode,
    00296       int invokeId,
    00297       int linkedId,
    00298       PASN_OctetString * argument
    00299     );
    00300
    00303     virtual void OnReceivedCallTransferIdentify(
    00304       int linkedId
    00305     );
    00306
    00309     virtual void OnReceivedCallTransferAbandon(
    00310       int linkedId
    00311     );
    00312
    00315     virtual void OnReceivedCallTransferInitiate(
    00316       int linkedId,
    00317       PASN_OctetString * argument
    00318     );
    00319
    00322     virtual void OnReceivedCallTransferSetup(
    00323       int linkedId,
    00324       PASN_OctetString * argument
    00325     );
    00326
    00329     virtual void OnReceivedCallTransferUpdate(
    00330       int linkedId,
    00331       PASN_OctetString * argument
    00332     );
    00333
    00336     virtual void OnReceivedSubaddressTransfer(
    00337       int linkedId,
    00338       PASN_OctetString * argument
    00339     );
    00340
    00343     virtual void OnReceivedCallTransferComplete(
    00344       int linkedId,
    00345       PASN_OctetString * argument
    00346     );
    00347
    00350     virtual void OnReceivedCallTransferActive(
    00351       int linkedId,
    00352       PASN_OctetString * argument
    00353     );
    00354
    00355     virtual PBoolean OnReceivedReturnResult(
    00356       X880_ReturnResult & returnResult
    00357     );
    00358
    00363     void OnReceivedInitiateReturnResult();
    00364
    00370     void OnReceivedSetupReturnResult();
    00371
    00376     void OnReceivedIdentifyReturnResult(X880_ReturnResult &returnResult);
    00377
    00378     virtual PBoolean OnReceivedReturnError(
    00379       int errorCode,
    00380       X880_ReturnError & returnError
    00381     );
    00382
    00387     void OnReceivedInitiateReturnError(
    00388       const bool timerExpiry = false
    00389     );
    00390
    00397     void OnReceivedSetupReturnError(
    00398       int errorCode,
    00399       const bool timerExpiry = false
    00400     );
    00401
    00406     void OnReceivedIdentifyReturnError(
    00407       const bool timerExpiry = false
    00408     );
    00409
    00414     bool TransferCall(
    00415       const PString & remoteParty,
    00416       const PString & callIdentity
    00417     );
    00418
    00423     void ConsultationTransfer(
    00424       const PString & primaryCallToken
    00425     );
    00426
    00429     void HandleConsultationTransfer(
    00430       const PString & callIdentity,
    00431       H323Connection& incoming
    00432     );
    00433
    00434     void AwaitSetupResponse(
    00435       const PString & token,
    00436       const PString & identity
    00437     );
    00438
    00441     enum State {
    00442       e_ctIdle,
    00443       e_ctAwaitIdentifyResponse,
    00444       e_ctAwaitInitiateResponse,
    00445       e_ctAwaitSetupResponse,
    00446       e_ctAwaitSetup,
    00447       e_ctAwaitConnect
    00448     };
    00449
    00452     State GetState() const { return ctState; }
    00453
    00463     virtual void onReceivedAdmissionReject(const int returnError);
    00464
    00467     void HandleCallTransferFailure(
    00468       const int returnError
    00469     );
    00470
    00473     void StartctTimer(const PTimeInterval value) { ctTimer = value; }
    00474
    00477     void StopctTimer();
    00478
    00481     PBoolean IsctTimerRunning() { return ctTimer.IsRunning(); }
    00482
    00485     PDECLARE_NOTIFIER(PTimer, H4502Handler, OnCallTransferTimeOut);
    00486
    00489     const H323Connection& getAssociatedConnection() const { return connection; }
    00490
    00493     void SetAssociatedCallToken(const PString& token) { CallToken = token; }
    00494
    00497     const PString& getTransferringCallToken() const { return transferringCallToken; }
    00498
    00501     void SetConsultationTransferSuccess() { consultationTransfer = PTrue; }
    00502
    00505     PBoolean isConsultationTransferSuccess() { return consultationTransfer; }
    00506
    00507   protected:
    00508     PString transferringCallToken;    // Stores the call token for the transferring connection (if there is one)
    00509     PString transferringCallIdentity; // Stores the call identity for the transferring call (if there is one)
    00510     State   ctState;                  // Call Transfer state of the conneciton
    00511     PBoolean    ctResponseSent;           // Has a callTransferSetupReturnResult been sent?
    00512     PTimer  ctTimer;                  // Call Transfer Timer - Handles all four timers CT-T1,
    00513     PString CallToken;                // Call Token of the associated connection
    00514                                       // (used during a consultation transfer).
    00515     PBoolean consultationTransfer;        // Flag used to indicate whether an incoming call is involved in
    00516                                       // a transfer through consultation.
    00517 };
    00518
    00519
    00520 class H4504Handler : public H450xHandler
    00521 {
    00522     PCLASSINFO(H4504Handler, H450xHandler);
    00523   public:
    00524     H4504Handler(
    00525       H323Connection & connection,
    00526       H450xDispatcher & dispatcher
    00527     );
    00528
    00529     virtual PBoolean OnReceivedInvoke(
    00530       int opcode,
    00531       int invokeId,
    00532       int linkedId,
    00533       PASN_OctetString * argument
    00534     );
    00535
    00538     virtual void OnReceivedLocalCallHold(
    00539       int linkedId
    00540     );
    00541
    00544     virtual void OnReceivedLocalCallRetrieve(
    00545       int linkedId
    00546     );
    00547
    00551     virtual void OnReceivedRemoteCallHold(
    00552       int linkedId
    00553     );
    00554
    00558     virtual void OnReceivedRemoteCallRetrieve(
    00559       int linkedId
    00560     );
    00561
    00565     bool HoldCall(
    00566       PBoolean localHold
    00567     );
    00568
    00572     bool RetrieveCall();
    00573
    00576     enum State {
    00577       e_ch_Idle,
    00578       e_ch_NE_Held,
    00579       e_ch_RE_Requested,
    00580       e_ch_RE_Held,
    00581       e_ch_RE_Retrieve_Req
    00582     };
    00583
    00584     State GetState() const { return holdState; }
    00585
    00586
    00587   protected:
    00588     State holdState;  // Call Hold state of this connection
    00589 };
    00590
    00591
    00592 class H4506Handler : public H450xHandler
    00593 {
    00594     PCLASSINFO(H4506Handler, H450xHandler);
    00595   public:
    00596     H4506Handler(
    00597       H323Connection & connection,
    00598       H450xDispatcher & dispatcher
    00599     );
    00600
    00601     virtual PBoolean OnReceivedInvoke(
    00602       int opcode,
    00603       int invokeId,
    00604       int linkedId,
    00605       PASN_OctetString * argument
    00606     );
    00607
    00610     virtual void OnReceivedCallWaitingIndication(
    00611       int linkedId,
    00612       PASN_OctetString *argument
    00613     );
    00614
    00620     virtual void AttachToAlerting(
    00621       H323SignalPDU & pdu,
    00622       unsigned numberOfCallsWaiting = 0
    00623     );
    00624
    00627     enum State {
    00628       e_cw_Idle,
    00629       e_cw_Invoked
    00630     };
    00631
    00632     State GetState() const { return cwState; }
    00633
    00634
    00635   protected:
    00636     State cwState;  // Call Waiting state of this connection
    00637 };
    00638
    00642 class H4507Handler : public H450xHandler
    00643 {
    00644     PCLASSINFO(H4507Handler, H450xHandler);
    00645   public:
    00646     H4507Handler(
    00647       H323Connection & connection,
    00648       H450xDispatcher & dispatcher
    00649     );
    00650
    00651     virtual PBoolean OnReceivedInvoke(
    00652       int opcode,
    00653       int invokeId,
    00654       int linkedId,
    00655       PASN_OctetString * argument
    00656     );
    00657
    00658
    00662     virtual void AttachToSetup(H323SignalPDU & setupPDU,
    00663                                H4507_H323_MWI_Operations  &mwiOp,
    00664                                PASN_Sequence &argument);
    00665
    00668     virtual void AttachInterrogateResultToPdu(H323SignalPDU & pdu,
    00669                                               H4507_MWIInterrogateRes &interrogateResult);
    00670     virtual void AttachErrorToPdu(H323SignalPDU & pdu,
    00671                                         H4507_MessageWaitingIndicationErrors error);
    00674     enum State {
    00675       e_mwi_Idle,
    00676       e_mwi_Invoked
    00677     };
    00678
    00679     State GetState() const { return mwiState; }
    00680
    00681
    00682   protected:
    00683     State mwiState;  // Message waiting state of this connection
    00684 };
    00685
    00686
    00687 class H45011Handler : public H450xHandler
    00688 {
    00689   PCLASSINFO(H45011Handler, H450xHandler);
    00690   public:
    00691     H45011Handler(
    00692       H323Connection & connection,
    00693       H450xDispatcher & dispatcher
    00694     );
    00695
    00696     virtual void AttachToSetup(
    00697       H323SignalPDU & pdu
    00698     );
    00699
    00700     virtual void AttachToAlerting(
    00701       H323SignalPDU & pdu
    00702     );
    00703
    00704     virtual void AttachToConnect(
    00705       H323SignalPDU & pdu
    00706     );
    00707
    00708     virtual void AttachToReleaseComplete(
    00709       H323SignalPDU & pdu
    00710     );
    00711
    00712     virtual PBoolean OnReceivedInvoke(
    00713       int opcode,
    00714       int invokeId,
    00715       int linkedId,
    00716       PASN_OctetString * argument
    00717     );
    00718
    00721     virtual void OnReceivedCallIntrusionRequest(
    00722       int linkedId,
    00723       PASN_OctetString *argument
    00724     );
    00725
    00728     virtual void OnReceivedCallIntrusionGetCIPL(
    00729       int linkedId,
    00730       PASN_OctetString *argument
    00731     );
    00732
    00735     virtual void OnReceivedCallIntrusionIsolate(
    00736       int linkedId,
    00737       PASN_OctetString *argument
    00738     );
    00739
    00742     virtual PBoolean OnReceivedCallIntrusionForcedRelease(
    00743       int linkedId,
    00744       PASN_OctetString *argument
    00745     );
    00746
    00749     virtual void OnReceivedCallIntrusionWOBRequest(
    00750       int linkedId,
    00751       PASN_OctetString *argument
    00752     );
    00753
    00756     virtual void OnReceivedCallIntrusionSilentMonitor(
    00757       int linkedId,
    00758       PASN_OctetString *argument
    00759     );
    00760
    00763     virtual void OnReceivedCallIntrusionNotification(
    00764       int linkedId,
    00765       PASN_OctetString *argument
    00766     );
    00767
    00770     virtual void OnReceivedCfbOverride(
    00771       int linkedId,
    00772       PASN_OctetString *argument
    00773     );
    00774
    00777     virtual void OnReceivedRemoteUserAlerting(
    00778       int linkedId,
    00779       PASN_OctetString *argument
    00780     );
    00781
    00784     virtual void OnReceivedCallWaiting(
    00785       int linkedId,
    00786       PASN_OctetString *argument
    00787     );
    00788
    00789     virtual PBoolean OnReceivedReturnResult(
    00790       X880_ReturnResult & returnResult
    00791     );
    00792
    00793     void OnReceivedCIRequestResult(/*X880_ReturnResult & returnResult*/);
    00794
    00795     virtual PBoolean OnReceivedReturnError(
    00796       int errorCode,
    00797       X880_ReturnError & returnError
    00798     );
    00799
    00800     PBoolean OnReceivedInvokeReturnError (
    00801       int errorCode,
    00802       const bool timerExpiry = false
    00803     );
    00804
    00805     void OnReceivedCIGetCIPLResult(
    00806       X880_ReturnResult & returnResult
    00807     );
    00808
    00809     PBoolean OnReceivedGetCIPLReturnError(
    00810       int errorCode,
    00811       const bool timerExpiry = false
    00812     );
    00813
    00814     void IntrudeCall(int CICL );
    00815
    00816     void AwaitSetupResponse(
    00817       const PString & token,
    00818       const PString & identity
    00819     );
    00820
    00821     PBoolean GetRemoteCallIntrusionProtectionLevel(
    00822       const PString & intrusionCallToken,
    00823       unsigned intrusionCICL
    00824     );
    00825
    00826     void SetIntrusionImpending();
    00827
    00828     void SetForcedReleaseAccepted();
    00829
    00830     void SetIntrusionNotAuthorized();
    00831
    00832     virtual PBoolean OnReceivedReject(
    00833       int problemType,
    00834       int problemNumber
    00835     );
    00836
    00839     enum State {
    00840       e_ci_Idle,
    00841       e_ci_WaitAck,
    00842       e_ci_GetCIPL,
    00843       e_ci_OrigInvoked,
    00844       e_ci_OrigIsolated,
    00845       e_ci_DestNotify,
    00846       e_ci_DestInvoked,
    00847       e_ci_DestIsolated,
    00848       e_ci_DestWOB,
    00849       e_ci_IsolationRequest,
    00850       e_ci_ForcedReleaseRequest,
    00851       e_ci_WOBRequest
    00852     };
    00853
    00855     enum Generate{
    00856       e_ci_gIdle,
    00857       e_ci_gConferenceRequest,
    00858       e_ci_gHeldRequest,
    00859       e_ci_gSilentMonitorRequest,
    00860       e_ci_gIsolationRequest,
    00861       e_ci_gForcedReleaseRequest,
    00862       e_ci_gWOBRequest
    00863     };
    00864
    00866     enum SendState{
    00867       e_ci_sIdle,
    00868       e_ci_sAttachToSetup,
    00869       e_ci_sAttachToAlerting,
    00870       e_ci_sAttachToConnect,
    00871       e_ci_sAttachToReleseComplete
    00872     };
    00873
    00875     enum ReturnState{
    00876       e_ci_rIdle,
    00877       e_ci_rCallIntrusionImpending,
    00878       e_ci_rCallIntruded,
    00879       e_ci_rCallIsolated,
    00880       e_ci_rCallForceReleased,
    00881       e_ci_rCallForceReleaseResult,
    00882       e_ci_rCallIntrusionComplete,
    00883       e_ci_rCallIntrusionEnd,
    00884       e_ci_rNotBusy,
    00885       e_ci_rTempUnavailable,
    00886       e_ci_rNotAuthorized
    00887     };
    00888
    00891     State GetState() const { return ciState; }
    00892
    00895     void StartciTimer(const PTimeInterval value) { ciTimer = value; }
    00896
    00899     void StopciTimer();
    00900
    00903     PBoolean IsctTimerRunning() { return ciTimer.IsRunning(); }
    00904
    00907     PDECLARE_NOTIFIER(PTimer, H45011Handler, OnCallIntrudeTimeOut);
    00908
    00909   protected:
    00910     State       ciState;               // Call state of this connection
    00911     PTimer      ciTimer;               // Call Intrusion Timer - Handles all six timers CI-T1 to CI-T6,
    00912     PString     intrudingCallToken;
    00913     PString     intrudingCallIdentity;
    00914     PString     activeCallToken;
    00915     ReturnState ciReturnState;
    00916     SendState   ciSendState;
    00917     Generate    ciGenerateState;
    00918     int         ciCICL;
    00919     unsigned    intrudingCallCICL;
    00920 };
    00921
    00922
    00923 #endif // __OPAL_H450PDU_H
    00924
    00925