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

Generated on Fri Mar 7 07:36:33 2008 for OPAL by  doxygen 1.5.1