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: 20344 $
00027  * $Author: rjongbloed $
00028  * $Date: 2008-05-30 03:10:56 +0000 (Fri, 30 May 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     bool 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     bool HoldCall(
00565       PBoolean localHold   
00566     );
00567 
00571     bool 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     
00661     virtual void AttachToSetup(H323SignalPDU & setupPDU,
00662                                H4507_H323_MWI_Operations  &mwiOp, 
00663                                PASN_Sequence &argument);
00664     
00667     virtual void AttachInterrogateResultToPdu(H323SignalPDU & pdu,
00668                                               H4507_MWIInterrogateRes &interrogateResult);
00669     virtual void AttachErrorToPdu(H323SignalPDU & pdu,
00670                                         H4507_MessageWaitingIndicationErrors error);
00673     enum State {
00674       e_mwi_Idle,
00675       e_mwi_Invoked
00676     };
00677 
00678     State GetState() const { return mwiState; }
00679 
00680 
00681   protected:
00682     State mwiState;  // Message waiting state of this connection
00683 };
00684 
00685 
00686 class H45011Handler : public H450xHandler
00687 {
00688   PCLASSINFO(H45011Handler, H450xHandler);
00689   public:
00690     H45011Handler(
00691       H323Connection & connection,
00692       H450xDispatcher & dispatcher
00693     );
00694 
00695     virtual void AttachToSetup(
00696       H323SignalPDU & pdu
00697     );
00698 
00699     virtual void AttachToAlerting(
00700       H323SignalPDU & pdu
00701     );
00702 
00703     virtual void AttachToConnect(
00704       H323SignalPDU & pdu
00705     );
00706 
00707     virtual void AttachToReleaseComplete(
00708       H323SignalPDU & pdu
00709     );
00710 
00711     virtual PBoolean OnReceivedInvoke(
00712       int opcode,
00713       int invokeId,                           
00714       int linkedId,                           
00715       PASN_OctetString * argument             
00716     );
00717 
00720     virtual void OnReceivedCallIntrusionRequest(
00721       int linkedId,
00722       PASN_OctetString *argument
00723     );
00724 
00727     virtual void OnReceivedCallIntrusionGetCIPL(
00728       int linkedId,
00729       PASN_OctetString *argument
00730     );
00731 
00734     virtual void OnReceivedCallIntrusionIsolate(
00735       int linkedId,
00736       PASN_OctetString *argument
00737     );
00738 
00741     virtual PBoolean OnReceivedCallIntrusionForcedRelease(
00742       int linkedId,
00743       PASN_OctetString *argument
00744     );
00745 
00748     virtual void OnReceivedCallIntrusionWOBRequest(
00749       int linkedId,
00750       PASN_OctetString *argument
00751     );
00752 
00755     virtual void OnReceivedCallIntrusionSilentMonitor(
00756       int linkedId,
00757       PASN_OctetString *argument
00758     );
00759 
00762     virtual void OnReceivedCallIntrusionNotification(
00763       int linkedId,
00764       PASN_OctetString *argument
00765     );
00766 
00769     virtual void OnReceivedCfbOverride(
00770       int linkedId,
00771       PASN_OctetString *argument
00772     );
00773 
00776     virtual void OnReceivedRemoteUserAlerting(
00777       int linkedId,
00778       PASN_OctetString *argument
00779     );
00780 
00783     virtual void OnReceivedCallWaiting(
00784       int linkedId,
00785       PASN_OctetString *argument
00786     );
00787 
00788     virtual PBoolean OnReceivedReturnResult(
00789       X880_ReturnResult & returnResult
00790     );
00791 
00792     void OnReceivedCIRequestResult(/*X880_ReturnResult & returnResult*/);
00793 
00794     virtual PBoolean OnReceivedReturnError(
00795       int errorCode,
00796       X880_ReturnError & returnError
00797     );
00798 
00799     PBoolean OnReceivedInvokeReturnError (
00800       int errorCode,
00801       const bool timerExpiry = false 
00802     );
00803 
00804     void OnReceivedCIGetCIPLResult(
00805       X880_ReturnResult & returnResult
00806     );
00807 
00808     PBoolean OnReceivedGetCIPLReturnError(
00809       int errorCode,
00810       const bool timerExpiry = false 
00811     );
00812 
00813     void IntrudeCall(int CICL );
00814 
00815     void AwaitSetupResponse(
00816       const PString & token,
00817       const PString & identity
00818     );
00819 
00820     PBoolean GetRemoteCallIntrusionProtectionLevel(
00821       const PString & intrusionCallToken,
00822       unsigned intrusionCICL
00823     );
00824 
00825     void SetIntrusionImpending();
00826 
00827     void SetForcedReleaseAccepted();
00828 
00829     void SetIntrusionNotAuthorized();
00830 
00831     virtual PBoolean OnReceivedReject(
00832       int problemType,
00833       int problemNumber
00834     );
00835 
00838     enum State {
00839       e_ci_Idle,
00840       e_ci_WaitAck,
00841       e_ci_GetCIPL,
00842       e_ci_OrigInvoked,
00843       e_ci_OrigIsolated,
00844       e_ci_DestNotify,
00845       e_ci_DestInvoked,
00846       e_ci_DestIsolated,
00847       e_ci_DestWOB,
00848       e_ci_IsolationRequest,
00849       e_ci_ForcedReleaseRequest,
00850       e_ci_WOBRequest
00851     };
00852 
00854     enum Generate{
00855       e_ci_gIdle,
00856       e_ci_gConferenceRequest,
00857       e_ci_gHeldRequest,
00858       e_ci_gSilentMonitorRequest,
00859       e_ci_gIsolationRequest,
00860       e_ci_gForcedReleaseRequest,
00861       e_ci_gWOBRequest
00862     };
00863 
00865     enum SendState{
00866       e_ci_sIdle,
00867       e_ci_sAttachToSetup,
00868       e_ci_sAttachToAlerting,
00869       e_ci_sAttachToConnect,
00870       e_ci_sAttachToReleseComplete
00871     };
00872 
00874     enum ReturnState{
00875       e_ci_rIdle,
00876       e_ci_rCallIntrusionImpending,
00877       e_ci_rCallIntruded,
00878       e_ci_rCallIsolated,
00879       e_ci_rCallForceReleased,
00880       e_ci_rCallForceReleaseResult,
00881       e_ci_rCallIntrusionComplete,
00882       e_ci_rCallIntrusionEnd,
00883       e_ci_rNotBusy,
00884       e_ci_rTempUnavailable,
00885       e_ci_rNotAuthorized
00886     };
00887     
00890     State GetState() const { return ciState; }
00891 
00894     void StartciTimer(const PTimeInterval value) { ciTimer = value; }
00895 
00898     void StopciTimer();
00899 
00902     PBoolean IsctTimerRunning() { return ciTimer.IsRunning(); }
00903 
00906     PDECLARE_NOTIFIER(PTimer, H45011Handler, OnCallIntrudeTimeOut);
00907 
00908   protected:
00909     State       ciState;               // Call state of this connection
00910     PTimer      ciTimer;               // Call Intrusion Timer - Handles all six timers CI-T1 to CI-T6,
00911     PString     intrudingCallToken;
00912     PString     intrudingCallIdentity;
00913     PString     activeCallToken;
00914     ReturnState ciReturnState;
00915     SendState   ciSendState;
00916     Generate    ciGenerateState;
00917     int         ciCICL;
00918     unsigned    intrudingCallCICL;
00919 };
00920 
00921 
00922 #endif // __OPAL_H450PDU_H
00923 
00924 

Generated on Mon Sep 15 11:49:08 2008 for OPAL by  doxygen 1.5.1