OpenH323 1.18.0
|
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 * $Log: h450pdu.h,v $ 00027 * Revision 1.12 2005/11/30 13:05:01 csoutheren 00028 * Changed tags for Doxygen 00029 * 00030 * Revision 1.11 2005/03/10 07:01:29 csoutheren 00031 * Fixed problem with H.450 call identifiers not being unique across all calls on an 00032 * endpoint. Thanks to Thien Nguyen 00033 * 00034 * Revision 1.10 2002/11/21 22:37:24 robertj 00035 * Fixed problems with unrecognized invoke APDU, thanks Andrea Bondavalli 00036 * 00037 * Revision 1.9 2002/09/16 01:14:15 robertj 00038 * Added #define so can select if #pragma interface/implementation is used on 00039 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00040 * 00041 * Revision 1.8 2002/09/03 06:19:37 robertj 00042 * Normalised the multi-include header prevention ifdef/define symbol. 00043 * 00044 * Revision 1.7 2002/08/05 10:03:47 robertj 00045 * Cosmetic changes to normalise the usage of pragma interface/implementation. 00046 * 00047 * Revision 1.6 2002/07/04 00:40:31 robertj 00048 * More H.450.11 call intrusion implementation, thanks Aleksandar Todorovic 00049 * 00050 * Revision 1.5 2002/06/22 05:48:38 robertj 00051 * Added partial implementation for H.450.11 Call Intrusion 00052 * 00053 * Revision 1.4 2002/02/04 07:17:52 robertj 00054 * Added H.450.2 Consultation Transfer, thanks Norwood Systems. 00055 * 00056 * Revision 1.3 2002/01/14 00:02:40 robertj 00057 * Added H.450.6 00058 * Added extra "failure mode" parts of H.250.2. 00059 * Various other bug fixes. 00060 * Thanks Ben Madsen of Norwood Systems 00061 * 00062 * Revision 1.2 2001/08/16 07:49:16 robertj 00063 * Changed the H.450 support to be more extensible. Protocol handlers 00064 * are now in separate classes instead of all in H323Connection. 00065 * 00066 * Revision 1.1 2001/04/11 03:01:27 robertj 00067 * Added H.450.2 (call transfer), thanks a LOT to Graeme Reid & Norwood Systems 00068 * 00069 */ 00070 00071 #ifndef __OPAL_H450PDU_H 00072 #define __OPAL_H450PDU_H 00073 00074 #ifdef P_USE_PRAGMA 00075 #pragma interface 00076 #endif 00077 00078 00079 #include "x880.h" 00080 00081 00082 class H323EndPoint; 00083 class H323Connection; 00084 class H323TransportAddress; 00085 class H323SignalPDU; 00086 00087 class H4501_EndpointAddress; 00088 class H4501_InterpretationApdu; 00089 00090 00092 00095 class H450ServiceAPDU : public X880_ROS 00096 { 00097 public: 00098 X880_Invoke& BuildInvoke(int invokeId, int operation); 00099 X880_ReturnResult& BuildReturnResult(int invokeId); 00100 X880_ReturnError& BuildReturnError(int invokeId, int error); 00101 X880_Reject& BuildReject(int invokeId); 00102 00103 void BuildCallTransferInitiate(int invokeId, 00104 const PString & callIdentity, 00105 const PString & alias, 00106 const H323TransportAddress & address); 00107 00108 void BuildCallTransferIdentify(int invokeId); 00109 void BuildCallTransferAbandon(int invokeId); 00110 void BuildCallTransferSetup(int invokeId, 00111 const PString & callIdentity); 00112 00113 void BuildCallWaiting(int invokeId, int numCallsWaiting); 00114 00115 void BuildCallIntrusionForcedRelease(int invokeId, int CICL); 00116 X880_ReturnResult& BuildCallIntrusionForcedReleaseResult(int invokeId); 00117 void BuildCallIntrusionForcedReleaseError(); 00118 void BuildCallIntrusionGetCIPL(int invokeId); 00119 void BuildCallIntrusionImpending(int invokeId); 00120 void BuildCallIntrusionForceRelesed(int invokeId); 00121 00122 void AttachSupplementaryServiceAPDU(H323SignalPDU & pdu); 00123 BOOL WriteFacilityPDU( 00124 H323Connection & connection 00125 ); 00126 00127 static void ParseEndpointAddress(H4501_EndpointAddress & address, 00128 PString & party); 00129 }; 00130 00131 00132 class H450xDispatcher; 00133 00134 class H450xHandler : public PObject 00135 { 00136 PCLASSINFO(H450xHandler, PObject); 00137 public: 00138 H450xHandler( 00139 H323Connection & connection, 00140 H450xDispatcher & dispatcher 00141 ); 00142 00143 virtual void AttachToSetup( 00144 H323SignalPDU & pdu 00145 ); 00146 00147 virtual void AttachToAlerting( 00148 H323SignalPDU & pdu 00149 ); 00150 00151 virtual void AttachToConnect( 00152 H323SignalPDU & pdu 00153 ); 00154 00155 virtual void AttachToReleaseComplete( 00156 H323SignalPDU & pdu 00157 ); 00158 00159 virtual BOOL OnReceivedInvoke( 00160 int opcode, 00161 int invokeId, 00162 int linkedId, 00163 PASN_OctetString * argument 00164 ) = 0; 00165 00166 virtual BOOL OnReceivedReturnResult( 00167 X880_ReturnResult & returnResult 00168 ); 00169 00170 virtual BOOL OnReceivedReturnError( 00171 int errorCode, 00172 X880_ReturnError & returnError 00173 ); 00174 00175 virtual BOOL OnReceivedReject( 00176 int problemType, 00177 int problemNumber 00178 ); 00179 00182 void SendReturnError(int returnError); 00183 00184 void SendGeneralReject(int problem); 00185 00186 void SendInvokeReject(int problem); 00187 00188 void SendReturnResultReject(int problem); 00189 00190 void SendReturnErrorReject(int problem); 00191 00192 BOOL DecodeArguments( 00193 PASN_OctetString * argString, 00194 PASN_Object & argObject, 00195 int absentErrorCode 00196 ); 00197 00198 unsigned GetInvokeId() const { return currentInvokeId; } 00199 00200 00201 protected: 00202 H323EndPoint & endpoint; 00203 H323Connection & connection; 00204 H450xDispatcher & dispatcher; 00205 unsigned currentInvokeId; 00206 }; 00207 00208 PLIST(H450xHandlerList, H450xHandler); 00209 PDICTIONARY(H450xHandlerDict, POrdinalKey, H450xHandler); 00210 00211 00212 class H450xDispatcher : public PObject 00213 { 00214 PCLASSINFO(H450xDispatcher, PObject); 00215 public: 00216 H450xDispatcher( 00217 H323Connection & connection 00218 ); 00219 00222 void AddOpCode( 00223 unsigned opcode, 00224 H450xHandler * handler 00225 ); 00226 00227 virtual void AttachToSetup( 00228 H323SignalPDU & pdu 00229 ); 00230 00231 virtual void AttachToAlerting( 00232 H323SignalPDU & pdu 00233 ); 00234 00235 virtual void AttachToConnect( 00236 H323SignalPDU & pdu 00237 ); 00238 00239 virtual void AttachToReleaseComplete( 00240 H323SignalPDU & pdu 00241 ); 00242 00245 virtual BOOL HandlePDU( 00246 const H323SignalPDU & pdu 00247 ); 00248 00253 virtual BOOL OnReceivedInvoke(X880_Invoke& invoke, H4501_InterpretationApdu& interpretation); 00254 00260 virtual BOOL OnReceivedReturnResult(X880_ReturnResult& returnResult); 00261 00267 virtual BOOL OnReceivedReturnError(X880_ReturnError& returnError); 00268 00274 virtual BOOL OnReceivedReject(X880_Reject& reject); 00275 00278 void SendReturnError(int invokeId, int returnError); 00279 00280 void SendGeneralReject(int invokeId, int problem); 00281 00282 void SendInvokeReject(int invokeId, int problem); 00283 00284 void SendReturnResultReject(int invokeId, int problem); 00285 00286 void SendReturnErrorReject(int invokeId, int problem); 00287 00290 unsigned GetNextInvokeId() const { return ++nextInvokeId; } 00291 00292 protected: 00293 H323Connection & connection; 00294 H450xHandlerList handlers; 00295 H450xHandlerDict opcodeHandler; 00296 mutable unsigned nextInvokeId; 00297 }; 00298 00299 00300 class H4502Handler : public H450xHandler 00301 { 00302 PCLASSINFO(H4502Handler, H450xHandler); 00303 public: 00304 H4502Handler( 00305 H323Connection & connection, 00306 H450xDispatcher & dispatcher 00307 ); 00308 00309 virtual void AttachToSetup( 00310 H323SignalPDU & pdu 00311 ); 00312 00313 virtual void AttachToAlerting( 00314 H323SignalPDU & pdu 00315 ); 00316 00317 virtual void AttachToConnect( 00318 H323SignalPDU & pdu 00319 ); 00320 00321 virtual void AttachToReleaseComplete( 00322 H323SignalPDU & pdu 00323 ); 00324 00325 virtual BOOL OnReceivedInvoke( 00326 int opcode, 00327 int invokeId, 00328 int linkedId, 00329 PASN_OctetString * argument 00330 ); 00331 00334 virtual void OnReceivedCallTransferIdentify( 00335 int linkedId 00336 ); 00337 00340 virtual void OnReceivedCallTransferAbandon( 00341 int linkedId 00342 ); 00343 00346 virtual void OnReceivedCallTransferInitiate( 00347 int linkedId, 00348 PASN_OctetString * argument 00349 ); 00350 00353 virtual void OnReceivedCallTransferSetup( 00354 int linkedId, 00355 PASN_OctetString * argument 00356 ); 00357 00360 virtual void OnReceivedCallTransferUpdate( 00361 int linkedId, 00362 PASN_OctetString * argument 00363 ); 00364 00367 virtual void OnReceivedSubaddressTransfer( 00368 int linkedId, 00369 PASN_OctetString * argument 00370 ); 00371 00374 virtual void OnReceivedCallTransferComplete( 00375 int linkedId, 00376 PASN_OctetString * argument 00377 ); 00378 00381 virtual void OnReceivedCallTransferActive( 00382 int linkedId, 00383 PASN_OctetString * argument 00384 ); 00385 00386 virtual BOOL OnReceivedReturnResult( 00387 X880_ReturnResult & returnResult 00388 ); 00389 00394 void OnReceivedInitiateReturnResult(); 00395 00401 void OnReceivedSetupReturnResult(); 00402 00407 void OnReceivedIdentifyReturnResult(X880_ReturnResult &returnResult); 00408 00409 virtual BOOL OnReceivedReturnError( 00410 int errorCode, 00411 X880_ReturnError & returnError 00412 ); 00413 00418 void OnReceivedInitiateReturnError( 00419 const bool timerExpiry = false 00420 ); 00421 00428 void OnReceivedSetupReturnError( 00429 int errorCode, 00430 const bool timerExpiry = false 00431 ); 00432 00437 void OnReceivedIdentifyReturnError( 00438 const bool timerExpiry = false 00439 ); 00440 00445 void TransferCall( 00446 const PString & remoteParty, 00447 const PString & callIdentity 00448 ); 00449 00454 void ConsultationTransfer( 00455 const PString & primaryCallToken 00456 ); 00457 00460 void HandleConsultationTransfer( 00461 const PString & callIdentity, 00462 H323Connection& incoming 00463 ); 00464 00465 void AwaitSetupResponse( 00466 const PString & token, 00467 const PString & identity 00468 ); 00469 00472 enum State { 00473 e_ctIdle, 00474 e_ctAwaitIdentifyResponse, 00475 e_ctAwaitInitiateResponse, 00476 e_ctAwaitSetupResponse, 00477 e_ctAwaitSetup, 00478 e_ctAwaitConnect 00479 }; 00480 00483 State GetState() const { return ctState; } 00484 00494 virtual void onReceivedAdmissionReject(const int returnError); 00495 00498 void HandleCallTransferFailure( 00499 const int returnError 00500 ); 00501 00504 void StartctTimer(const PTimeInterval value) { ctTimer = value; } 00505 00508 void StopctTimer(); 00509 00512 BOOL IsctTimerRunning() { return ctTimer.IsRunning(); } 00513 00516 PDECLARE_NOTIFIER(PTimer, H4502Handler, OnCallTransferTimeOut); 00517 00520 const H323Connection& getAssociatedConnection() const { return connection; } 00521 00524 void SetAssociatedCallToken(const PString& token) { CallToken = token; } 00525 00528 const PString& getTransferringCallToken() const { return transferringCallToken; } 00529 00532 void SetConsultationTransferSuccess() { consultationTransfer = TRUE; } 00533 00536 BOOL isConsultationTransferSuccess() { return consultationTransfer; } 00537 00538 protected: 00539 PString transferringCallToken; // Stores the call token for the transferring connection (if there is one) 00540 PString transferringCallIdentity; // Stores the call identity for the transferring call (if there is one) 00541 State ctState; // Call Transfer state of the conneciton 00542 BOOL ctResponseSent; // Has a callTransferSetupReturnResult been sent? 00543 PTimer ctTimer; // Call Transfer Timer - Handles all four timers CT-T1, 00544 PString CallToken; // Call Token of the associated connection 00545 // (used during a consultation transfer). 00546 BOOL consultationTransfer; // Flag used to indicate whether an incoming call is involved in 00547 // a transfer through consultation. 00548 }; 00549 00550 00551 class H4504Handler : public H450xHandler 00552 { 00553 PCLASSINFO(H4504Handler, H450xHandler); 00554 public: 00555 H4504Handler( 00556 H323Connection & connection, 00557 H450xDispatcher & dispatcher 00558 ); 00559 00560 virtual BOOL OnReceivedInvoke( 00561 int opcode, 00562 int invokeId, 00563 int linkedId, 00564 PASN_OctetString * argument 00565 ); 00566 00569 virtual void OnReceivedLocalCallHold( 00570 int linkedId 00571 ); 00572 00575 virtual void OnReceivedLocalCallRetrieve( 00576 int linkedId 00577 ); 00578 00582 virtual void OnReceivedRemoteCallHold( 00583 int linkedId 00584 ); 00585 00589 virtual void OnReceivedRemoteCallRetrieve( 00590 int linkedId 00591 ); 00592 00596 void HoldCall( 00597 BOOL localHold 00598 ); 00599 00603 void RetrieveCall(); 00604 00607 enum State { 00608 e_ch_Idle, 00609 e_ch_NE_Held, 00610 e_ch_RE_Requested, 00611 e_ch_RE_Held, 00612 e_ch_RE_Retrieve_Req 00613 }; 00614 00615 State GetState() const { return holdState; } 00616 00617 00618 protected: 00619 State holdState; // Call Hold state of this connection 00620 }; 00621 00622 00623 class H4506Handler : public H450xHandler 00624 { 00625 PCLASSINFO(H4506Handler, H450xHandler); 00626 public: 00627 H4506Handler( 00628 H323Connection & connection, 00629 H450xDispatcher & dispatcher 00630 ); 00631 00632 virtual BOOL OnReceivedInvoke( 00633 int opcode, 00634 int invokeId, 00635 int linkedId, 00636 PASN_OctetString * argument 00637 ); 00638 00641 virtual void OnReceivedCallWaitingIndication( 00642 int linkedId, 00643 PASN_OctetString *argument 00644 ); 00645 00651 virtual void AttachToAlerting( 00652 H323SignalPDU & pdu, 00653 unsigned numberOfCallsWaiting = 0 00654 ); 00655 00658 enum State { 00659 e_cw_Idle, 00660 e_cw_Invoked 00661 }; 00662 00663 State GetState() const { return cwState; } 00664 00665 00666 protected: 00667 State cwState; // Call Waiting state of this connection 00668 }; 00669 00670 00671 class H45011Handler : public H450xHandler 00672 { 00673 PCLASSINFO(H45011Handler, H450xHandler); 00674 public: 00675 H45011Handler( 00676 H323Connection & connection, 00677 H450xDispatcher & dispatcher 00678 ); 00679 00680 virtual void AttachToSetup( 00681 H323SignalPDU & pdu 00682 ); 00683 00684 virtual void AttachToAlerting( 00685 H323SignalPDU & pdu 00686 ); 00687 00688 virtual void AttachToConnect( 00689 H323SignalPDU & pdu 00690 ); 00691 00692 virtual void AttachToReleaseComplete( 00693 H323SignalPDU & pdu 00694 ); 00695 00696 virtual BOOL OnReceivedInvoke( 00697 int opcode, 00698 int invokeId, 00699 int linkedId, 00700 PASN_OctetString * argument 00701 ); 00702 00705 virtual void OnReceivedCallIntrusionRequest( 00706 int linkedId, 00707 PASN_OctetString *argument 00708 ); 00709 00712 virtual void OnReceivedCallIntrusionGetCIPL( 00713 int linkedId, 00714 PASN_OctetString *argument 00715 ); 00716 00719 virtual void OnReceivedCallIntrusionIsolate( 00720 int linkedId, 00721 PASN_OctetString *argument 00722 ); 00723 00726 virtual BOOL OnReceivedCallIntrusionForcedRelease( 00727 int linkedId, 00728 PASN_OctetString *argument 00729 ); 00730 00733 virtual void OnReceivedCallIntrusionWOBRequest( 00734 int linkedId, 00735 PASN_OctetString *argument 00736 ); 00737 00740 virtual void OnReceivedCallIntrusionSilentMonitor( 00741 int linkedId, 00742 PASN_OctetString *argument 00743 ); 00744 00747 virtual void OnReceivedCallIntrusionNotification( 00748 int linkedId, 00749 PASN_OctetString *argument 00750 ); 00751 00754 virtual void OnReceivedCfbOverride( 00755 int linkedId, 00756 PASN_OctetString *argument 00757 ); 00758 00761 virtual void OnReceivedRemoteUserAlerting( 00762 int linkedId, 00763 PASN_OctetString *argument 00764 ); 00765 00768 virtual void OnReceivedCallWaiting( 00769 int linkedId, 00770 PASN_OctetString *argument 00771 ); 00772 00773 virtual BOOL OnReceivedReturnResult( 00774 X880_ReturnResult & returnResult 00775 ); 00776 00777 void OnReceivedCIRequestResult(/*X880_ReturnResult & returnResult*/); 00778 00779 virtual BOOL OnReceivedReturnError( 00780 int errorCode, 00781 X880_ReturnError & returnError 00782 ); 00783 00784 BOOL OnReceivedInvokeReturnError ( 00785 int errorCode, 00786 const bool timerExpiry = false 00787 ); 00788 00789 void OnReceivedCIGetCIPLResult( 00790 X880_ReturnResult & returnResult 00791 ); 00792 00793 BOOL OnReceivedGetCIPLReturnError( 00794 int errorCode, 00795 const bool timerExpiry = false 00796 ); 00797 00798 void IntrudeCall(int CICL ); 00799 00800 void AwaitSetupResponse( 00801 const PString & token, 00802 const PString & identity 00803 ); 00804 00805 BOOL GetRemoteCallIntrusionProtectionLevel( 00806 const PString & intrusionCallToken, 00807 unsigned intrusionCICL 00808 ); 00809 00810 void SetIntrusionImpending(); 00811 00812 void SetForcedReleaseAccepted(); 00813 00814 void SetIntrusionNotAuthorized(); 00815 00816 virtual BOOL OnReceivedReject( 00817 int problemType, 00818 int problemNumber 00819 ); 00820 00823 enum State { 00824 e_ci_Idle, 00825 e_ci_WaitAck, 00826 e_ci_GetCIPL, 00827 e_ci_OrigInvoked, 00828 e_ci_OrigIsolated, 00829 e_ci_DestNotify, 00830 e_ci_DestInvoked, 00831 e_ci_DestIsolated, 00832 e_ci_DestWOB, 00833 e_ci_IsolationRequest, 00834 e_ci_ForcedReleaseRequest, 00835 e_ci_WOBRequest 00836 }; 00837 00839 enum Generate{ 00840 e_ci_gIdle, 00841 e_ci_gConferenceRequest, 00842 e_ci_gHeldRequest, 00843 e_ci_gSilentMonitorRequest, 00844 e_ci_gIsolationRequest, 00845 e_ci_gForcedReleaseRequest, 00846 e_ci_gWOBRequest 00847 }; 00848 00850 enum SendState{ 00851 e_ci_sIdle, 00852 e_ci_sAttachToSetup, 00853 e_ci_sAttachToAlerting, 00854 e_ci_sAttachToConnect, 00855 e_ci_sAttachToReleseComplete 00856 }; 00857 00859 enum ReturnState{ 00860 e_ci_rIdle, 00861 e_ci_rCallIntrusionImpending, 00862 e_ci_rCallIntruded, 00863 e_ci_rCallIsolated, 00864 e_ci_rCallForceReleased, 00865 e_ci_rCallForceReleaseResult, 00866 e_ci_rCallIntrusionComplete, 00867 e_ci_rCallIntrusionEnd, 00868 e_ci_rNotBusy, 00869 e_ci_rTempUnavailable, 00870 e_ci_rNotAuthorized 00871 }; 00872 00875 State GetState() const { return ciState; } 00876 00879 void StartciTimer(const PTimeInterval value) { ciTimer = value; } 00880 00883 void StopciTimer(); 00884 00887 BOOL IsctTimerRunning() { return ciTimer.IsRunning(); } 00888 00891 PDECLARE_NOTIFIER(PTimer, H45011Handler, OnCallIntrudeTimeOut); 00892 00893 protected: 00894 State ciState; // Call state of this connection 00895 PTimer ciTimer; // Call Intrusion Timer - Handles all six timers CI-T1 to CI-T6, 00896 PString intrudingCallToken; 00897 PString intrudingCallIdentity; 00898 PString activeCallToken; 00899 ReturnState ciReturnState; 00900 SendState ciSendState; 00901 Generate ciGenerateState; 00902 int ciCICL; 00903 unsigned intrudingCallCICL; 00904 }; 00905 00906 00907 #endif // __OPAL_H450PDU_H 00908 00909