00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 #ifndef __OPAL_H450PDU_H
00076 #define __OPAL_H450PDU_H
00077
00078 #ifdef P_USE_PRAGMA
00079 #pragma interface
00080 #endif
00081
00082
00083 #include "x880.h"
00084
00085
00086 class H323EndPoint;
00087 class H323Connection;
00088 class H323TransportAddress;
00089 class H323SignalPDU;
00090
00091 class H4501_EndpointAddress;
00092 class H4501_InterpretationApdu;
00093
00094
00096
00099 class H450ServiceAPDU : public X880_ROS
00100 {
00101 public:
00102 X880_Invoke& BuildInvoke(int invokeId, int operation);
00103 X880_ReturnResult& BuildReturnResult(int invokeId);
00104 X880_ReturnError& BuildReturnError(int invokeId, int error);
00105 X880_Reject& BuildReject(int invokeId);
00106
00107 void BuildCallTransferInitiate(int invokeId,
00108 const PString & callIdentity,
00109 const PString & alias,
00110 const H323TransportAddress & address);
00111
00112 void BuildCallTransferIdentify(int invokeId);
00113 void BuildCallTransferAbandon(int invokeId);
00114 void BuildCallTransferSetup(int invokeId,
00115 const PString & callIdentity);
00116
00117 void BuildCallWaiting(int invokeId, int numCallsWaiting);
00118
00119 void BuildCallIntrusionForcedRelease(int invokeId, int CICL);
00120 X880_ReturnResult& BuildCallIntrusionForcedReleaseResult(int invokeId);
00121 void BuildCallIntrusionForcedReleaseError();
00122 void BuildCallIntrusionGetCIPL(int invokeId);
00123 void BuildCallIntrusionImpending(int invokeId);
00124 void BuildCallIntrusionForceRelesed(int invokeId);
00125
00126 void AttachSupplementaryServiceAPDU(H323SignalPDU & pdu);
00127 BOOL WriteFacilityPDU(
00128 H323Connection & connection
00129 );
00130
00131 static void ParseEndpointAddress(H4501_EndpointAddress & address,
00132 PString & party);
00133 };
00134
00135
00136 class H450xDispatcher;
00137
00138 class H450xHandler : public PObject
00139 {
00140 PCLASSINFO(H450xHandler, PObject);
00141 public:
00142 H450xHandler(
00143 H323Connection & connection,
00144 H450xDispatcher & dispatcher
00145 );
00146
00147 virtual void AttachToSetup(
00148 H323SignalPDU & pdu
00149 );
00150
00151 virtual void AttachToAlerting(
00152 H323SignalPDU & pdu
00153 );
00154
00155 virtual void AttachToConnect(
00156 H323SignalPDU & pdu
00157 );
00158
00159 virtual void AttachToReleaseComplete(
00160 H323SignalPDU & pdu
00161 );
00162
00163 virtual BOOL OnReceivedInvoke(
00164 int opcode,
00165 int invokeId,
00166 int linkedId,
00167 PASN_OctetString * argument
00168 ) = 0;
00169
00170 virtual BOOL OnReceivedReturnResult(
00171 X880_ReturnResult & returnResult
00172 );
00173
00174 virtual BOOL OnReceivedReturnError(
00175 int errorCode,
00176 X880_ReturnError & returnError
00177 );
00178
00179 virtual BOOL OnReceivedReject(
00180 int problemType,
00181 int problemNumber
00182 );
00183
00186 void SendReturnError(int returnError);
00187
00188 void SendGeneralReject(int problem);
00189
00190 void SendInvokeReject(int problem);
00191
00192 void SendReturnResultReject(int problem);
00193
00194 void SendReturnErrorReject(int problem);
00195
00196 BOOL DecodeArguments(
00197 PASN_OctetString * argString,
00198 PASN_Object & argObject,
00199 int absentErrorCode
00200 );
00201
00202 unsigned GetInvokeId() const { return currentInvokeId; }
00203
00204
00205 protected:
00206 H323EndPoint & endpoint;
00207 H323Connection & connection;
00208 H450xDispatcher & dispatcher;
00209 unsigned currentInvokeId;
00210 };
00211
00212 PLIST(H450xHandlerList, H450xHandler);
00213 PDICTIONARY(H450xHandlerDict, POrdinalKey, H450xHandler);
00214
00215
00216 class H450xDispatcher : public PObject
00217 {
00218 PCLASSINFO(H450xDispatcher, PObject);
00219 public:
00220 H450xDispatcher(
00221 H323Connection & connection
00222 );
00223
00226 void AddOpCode(
00227 unsigned opcode,
00228 H450xHandler * handler
00229 );
00230
00231 virtual void AttachToSetup(
00232 H323SignalPDU & pdu
00233 );
00234
00235 virtual void AttachToAlerting(
00236 H323SignalPDU & pdu
00237 );
00238
00239 virtual void AttachToConnect(
00240 H323SignalPDU & pdu
00241 );
00242
00243 virtual void AttachToReleaseComplete(
00244 H323SignalPDU & pdu
00245 );
00246
00249 virtual BOOL HandlePDU(
00250 const H323SignalPDU & pdu
00251 );
00252
00257 virtual BOOL OnReceivedInvoke(X880_Invoke& invoke, H4501_InterpretationApdu& interpretation);
00258
00264 virtual BOOL OnReceivedReturnResult(X880_ReturnResult& returnResult);
00265
00271 virtual BOOL OnReceivedReturnError(X880_ReturnError& returnError);
00272
00278 virtual BOOL OnReceivedReject(X880_Reject& reject);
00279
00282 void SendReturnError(int invokeId, int returnError);
00283
00284 void SendGeneralReject(int invokeId, int problem);
00285
00286 void SendInvokeReject(int invokeId, int problem);
00287
00288 void SendReturnResultReject(int invokeId, int problem);
00289
00290 void SendReturnErrorReject(int invokeId, int problem);
00291
00294 unsigned GetNextInvokeId() const { return ++nextInvokeId; }
00295
00296 protected:
00297 H323Connection & connection;
00298 H450xHandlerList handlers;
00299 H450xHandlerDict opcodeHandler;
00300 mutable unsigned nextInvokeId;
00301 };
00302
00303
00304 class H4502Handler : public H450xHandler
00305 {
00306 PCLASSINFO(H4502Handler, H450xHandler);
00307 public:
00308 H4502Handler(
00309 H323Connection & connection,
00310 H450xDispatcher & dispatcher
00311 );
00312
00313 virtual void AttachToSetup(
00314 H323SignalPDU & pdu
00315 );
00316
00317 virtual void AttachToAlerting(
00318 H323SignalPDU & pdu
00319 );
00320
00321 virtual void AttachToConnect(
00322 H323SignalPDU & pdu
00323 );
00324
00325 virtual void AttachToReleaseComplete(
00326 H323SignalPDU & pdu
00327 );
00328
00329 virtual BOOL OnReceivedInvoke(
00330 int opcode,
00331 int invokeId,
00332 int linkedId,
00333 PASN_OctetString * argument
00334 );
00335
00338 virtual void OnReceivedCallTransferIdentify(
00339 int linkedId
00340 );
00341
00344 virtual void OnReceivedCallTransferAbandon(
00345 int linkedId
00346 );
00347
00350 virtual void OnReceivedCallTransferInitiate(
00351 int linkedId,
00352 PASN_OctetString * argument
00353 );
00354
00357 virtual void OnReceivedCallTransferSetup(
00358 int linkedId,
00359 PASN_OctetString * argument
00360 );
00361
00364 virtual void OnReceivedCallTransferUpdate(
00365 int linkedId,
00366 PASN_OctetString * argument
00367 );
00368
00371 virtual void OnReceivedSubaddressTransfer(
00372 int linkedId,
00373 PASN_OctetString * argument
00374 );
00375
00378 virtual void OnReceivedCallTransferComplete(
00379 int linkedId,
00380 PASN_OctetString * argument
00381 );
00382
00385 virtual void OnReceivedCallTransferActive(
00386 int linkedId,
00387 PASN_OctetString * argument
00388 );
00389
00390 virtual BOOL OnReceivedReturnResult(
00391 X880_ReturnResult & returnResult
00392 );
00393
00398 void OnReceivedInitiateReturnResult();
00399
00405 void OnReceivedSetupReturnResult();
00406
00411 void OnReceivedIdentifyReturnResult(X880_ReturnResult &returnResult);
00412
00413 virtual BOOL OnReceivedReturnError(
00414 int errorCode,
00415 X880_ReturnError & returnError
00416 );
00417
00422 void OnReceivedInitiateReturnError(
00423 const bool timerExpiry = false
00424 );
00425
00432 void OnReceivedSetupReturnError(
00433 int errorCode,
00434 const bool timerExpiry = false
00435 );
00436
00441 void OnReceivedIdentifyReturnError(
00442 const bool timerExpiry = false
00443 );
00444
00449 void TransferCall(
00450 const PString & remoteParty,
00451 const PString & callIdentity
00452 );
00453
00458 void ConsultationTransfer(
00459 const PString & primaryCallToken
00460 );
00461
00464 void HandleConsultationTransfer(
00465 const PString & callIdentity,
00466 H323Connection& incoming
00467 );
00468
00469 void AwaitSetupResponse(
00470 const PString & token,
00471 const PString & identity
00472 );
00473
00476 enum State {
00477 e_ctIdle,
00478 e_ctAwaitIdentifyResponse,
00479 e_ctAwaitInitiateResponse,
00480 e_ctAwaitSetupResponse,
00481 e_ctAwaitSetup,
00482 e_ctAwaitConnect
00483 };
00484
00487 State GetState() const { return ctState; }
00488
00498 virtual void onReceivedAdmissionReject(const int returnError);
00499
00502 void HandleCallTransferFailure(
00503 const int returnError
00504 );
00505
00508 void StartctTimer(const PTimeInterval value) { ctTimer = value; }
00509
00512 void StopctTimer();
00513
00516 BOOL IsctTimerRunning() { return ctTimer.IsRunning(); }
00517
00520 PDECLARE_NOTIFIER(PTimer, H4502Handler, OnCallTransferTimeOut);
00521
00524 const H323Connection& getAssociatedConnection() const { return connection; }
00525
00528 void SetAssociatedCallToken(const PString& token) { CallToken = token; }
00529
00532 const PString& getTransferringCallToken() const { return transferringCallToken; }
00533
00536 void SetConsultationTransferSuccess() { consultationTransfer = TRUE; }
00537
00540 BOOL isConsultationTransferSuccess() { return consultationTransfer; }
00541
00542 protected:
00543 PString transferringCallToken;
00544 PString transferringCallIdentity;
00545 State ctState;
00546 BOOL ctResponseSent;
00547 PTimer ctTimer;
00548 PString CallToken;
00549
00550 BOOL consultationTransfer;
00551
00552 };
00553
00554
00555 class H4503Handler : public H450xHandler
00556 {
00557 PCLASSINFO(H4503Handler, H450xHandler);
00558 public:
00559 H4503Handler(
00560 H323Connection & connection,
00561 H450xDispatcher & dispatcher
00562 );
00563
00564 virtual BOOL OnReceivedInvoke(
00565 int opcode,
00566 int invokeId,
00567 int linkedId,
00568 PASN_OctetString * argument
00569 );
00570
00573 void OnReceivedDivertingLegInfo2(
00574 int linkedId,
00575 PASN_OctetString * argument
00576 );
00577
00578 BOOL GetRedirectingNumber(
00579 PString &originalCalledNr,
00580 PString &lastDivertingNr ,
00581 int &divCounter,
00582 int &origdivReason,
00583 int &divReason
00584 );
00585
00586 protected:
00587 PString m_originalCalledNr;
00588 PString m_lastDivertingNr;
00589 int m_diversionCounter;
00590 int m_origdiversionReason;
00591 int m_diversionReason;
00592 };
00593
00594
00595 class H4504Handler : public H450xHandler
00596 {
00597 PCLASSINFO(H4504Handler, H450xHandler);
00598 public:
00599 H4504Handler(
00600 H323Connection & connection,
00601 H450xDispatcher & dispatcher
00602 );
00603
00604 virtual BOOL OnReceivedInvoke(
00605 int opcode,
00606 int invokeId,
00607 int linkedId,
00608 PASN_OctetString * argument
00609 );
00610
00613 virtual void OnReceivedLocalCallHold(
00614 int linkedId
00615 );
00616
00619 virtual void OnReceivedLocalCallRetrieve(
00620 int linkedId
00621 );
00622
00626 virtual void OnReceivedRemoteCallHold(
00627 int linkedId
00628 );
00629
00633 virtual void OnReceivedRemoteCallRetrieve(
00634 int linkedId
00635 );
00636
00640 void HoldCall(
00641 BOOL localHold
00642 );
00643
00647 void RetrieveCall();
00648
00651 enum State {
00652 e_ch_Idle,
00653 e_ch_NE_Held,
00654 e_ch_RE_Requested,
00655 e_ch_RE_Held,
00656 e_ch_RE_Retrieve_Req
00657 };
00658
00659 State GetState() const { return holdState; }
00660
00661
00662 protected:
00663 State holdState;
00664 };
00665
00666
00667 class H4506Handler : public H450xHandler
00668 {
00669 PCLASSINFO(H4506Handler, H450xHandler);
00670 public:
00671 H4506Handler(
00672 H323Connection & connection,
00673 H450xDispatcher & dispatcher
00674 );
00675
00676 virtual BOOL OnReceivedInvoke(
00677 int opcode,
00678 int invokeId,
00679 int linkedId,
00680 PASN_OctetString * argument
00681 );
00682
00685 virtual void OnReceivedCallWaitingIndication(
00686 int linkedId,
00687 PASN_OctetString *argument
00688 );
00689
00695 virtual void AttachToAlerting(
00696 H323SignalPDU & pdu,
00697 unsigned numberOfCallsWaiting = 0
00698 );
00699
00702 enum State {
00703 e_cw_Idle,
00704 e_cw_Invoked
00705 };
00706
00707 State GetState() const { return cwState; }
00708
00709
00710 protected:
00711 State cwState;
00712 };
00713
00714
00715 class H45011Handler : public H450xHandler
00716 {
00717 PCLASSINFO(H45011Handler, H450xHandler);
00718 public:
00719 H45011Handler(
00720 H323Connection & connection,
00721 H450xDispatcher & dispatcher
00722 );
00723
00724 virtual void AttachToSetup(
00725 H323SignalPDU & pdu
00726 );
00727
00728 virtual void AttachToAlerting(
00729 H323SignalPDU & pdu
00730 );
00731
00732 virtual void AttachToConnect(
00733 H323SignalPDU & pdu
00734 );
00735
00736 virtual void AttachToReleaseComplete(
00737 H323SignalPDU & pdu
00738 );
00739
00740 virtual BOOL OnReceivedInvoke(
00741 int opcode,
00742 int invokeId,
00743 int linkedId,
00744 PASN_OctetString * argument
00745 );
00746
00749 virtual void OnReceivedCallIntrusionRequest(
00750 int linkedId,
00751 PASN_OctetString *argument
00752 );
00753
00756 virtual void OnReceivedCallIntrusionGetCIPL(
00757 int linkedId,
00758 PASN_OctetString *argument
00759 );
00760
00763 virtual void OnReceivedCallIntrusionIsolate(
00764 int linkedId,
00765 PASN_OctetString *argument
00766 );
00767
00770 virtual BOOL OnReceivedCallIntrusionForcedRelease(
00771 int linkedId,
00772 PASN_OctetString *argument
00773 );
00774
00777 virtual void OnReceivedCallIntrusionWOBRequest(
00778 int linkedId,
00779 PASN_OctetString *argument
00780 );
00781
00784 virtual void OnReceivedCallIntrusionSilentMonitor(
00785 int linkedId,
00786 PASN_OctetString *argument
00787 );
00788
00791 virtual void OnReceivedCallIntrusionNotification(
00792 int linkedId,
00793 PASN_OctetString *argument
00794 );
00795
00798 virtual void OnReceivedCfbOverride(
00799 int linkedId,
00800 PASN_OctetString *argument
00801 );
00802
00805 virtual void OnReceivedRemoteUserAlerting(
00806 int linkedId,
00807 PASN_OctetString *argument
00808 );
00809
00812 virtual void OnReceivedCallWaiting(
00813 int linkedId,
00814 PASN_OctetString *argument
00815 );
00816
00817 virtual BOOL OnReceivedReturnResult(
00818 X880_ReturnResult & returnResult
00819 );
00820
00821 void OnReceivedCIRequestResult();
00822
00823 virtual BOOL OnReceivedReturnError(
00824 int errorCode,
00825 X880_ReturnError & returnError
00826 );
00827
00828 BOOL OnReceivedInvokeReturnError (
00829 int errorCode,
00830 const bool timerExpiry = false
00831 );
00832
00833 void OnReceivedCIGetCIPLResult(
00834 X880_ReturnResult & returnResult
00835 );
00836
00837 BOOL OnReceivedGetCIPLReturnError(
00838 int errorCode,
00839 const bool timerExpiry = false
00840 );
00841
00842 void IntrudeCall(int CICL );
00843
00844 void AwaitSetupResponse(
00845 const PString & token,
00846 const PString & identity
00847 );
00848
00849 BOOL GetRemoteCallIntrusionProtectionLevel(
00850 const PString & intrusionCallToken,
00851 unsigned intrusionCICL
00852 );
00853
00854 void SetIntrusionImpending();
00855
00856 void SetForcedReleaseAccepted();
00857
00858 void SetIntrusionNotAuthorized();
00859
00860 virtual BOOL OnReceivedReject(
00861 int problemType,
00862 int problemNumber
00863 );
00864
00867 enum State {
00868 e_ci_Idle,
00869 e_ci_WaitAck,
00870 e_ci_GetCIPL,
00871 e_ci_OrigInvoked,
00872 e_ci_OrigIsolated,
00873 e_ci_DestNotify,
00874 e_ci_DestInvoked,
00875 e_ci_DestIsolated,
00876 e_ci_DestWOB,
00877 e_ci_IsolationRequest,
00878 e_ci_ForcedReleaseRequest,
00879 e_ci_WOBRequest
00880 };
00881
00883 enum Generate{
00884 e_ci_gIdle,
00885 e_ci_gConferenceRequest,
00886 e_ci_gHeldRequest,
00887 e_ci_gSilentMonitorRequest,
00888 e_ci_gIsolationRequest,
00889 e_ci_gForcedReleaseRequest,
00890 e_ci_gWOBRequest
00891 };
00892
00894 enum SendState{
00895 e_ci_sIdle,
00896 e_ci_sAttachToSetup,
00897 e_ci_sAttachToAlerting,
00898 e_ci_sAttachToConnect,
00899 e_ci_sAttachToReleseComplete
00900 };
00901
00903 enum ReturnState{
00904 e_ci_rIdle,
00905 e_ci_rCallIntrusionImpending,
00906 e_ci_rCallIntruded,
00907 e_ci_rCallIsolated,
00908 e_ci_rCallForceReleased,
00909 e_ci_rCallForceReleaseResult,
00910 e_ci_rCallIntrusionComplete,
00911 e_ci_rCallIntrusionEnd,
00912 e_ci_rNotBusy,
00913 e_ci_rTempUnavailable,
00914 e_ci_rNotAuthorized
00915 };
00916
00919 State GetState() const { return ciState; }
00920
00923 void StartciTimer(const PTimeInterval value) { ciTimer = value; }
00924
00927 void StopciTimer();
00928
00931 BOOL IsctTimerRunning() { return ciTimer.IsRunning(); }
00932
00935 PDECLARE_NOTIFIER(PTimer, H45011Handler, OnCallIntrudeTimeOut);
00936
00937 protected:
00938 State ciState;
00939 PTimer ciTimer;
00940 PString intrudingCallToken;
00941 PString intrudingCallIdentity;
00942 PString activeCallToken;
00943 ReturnState ciReturnState;
00944 SendState ciSendState;
00945 Generate ciGenerateState;
00946 int ciCICL;
00947 unsigned intrudingCallCICL;
00948 };
00949
00950
00951 #endif // __OPAL_H450PDU_H
00952
00953