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
00076
00077
00078
00079
00080
00081 #ifndef __OPAL_H450PDU_H
00082 #define __OPAL_H450PDU_H
00083
00084 #ifdef P_USE_PRAGMA
00085 #pragma interface
00086 #endif
00087
00088
00089 #include "x880.h"
00090
00091
00092 class H323EndPoint;
00093 class H323Connection;
00094 class H323TransportAddress;
00095 class H323SignalPDU;
00096
00097 class H4501_EndpointAddress;
00098 class H4501_InterpretationApdu;
00099
00100
00102
00105 class H450ServiceAPDU : public X880_ROS
00106 {
00107 public:
00108 X880_Invoke& BuildInvoke(int invokeId, int operation);
00109 X880_ReturnResult& BuildReturnResult(int invokeId);
00110 X880_ReturnError& BuildReturnError(int invokeId, int error);
00111 X880_Reject& BuildReject(int invokeId);
00112
00113 void BuildCallTransferInitiate(int invokeId,
00114 const PString & callIdentity,
00115 const PString & alias,
00116 const H323TransportAddress & address);
00117
00118 void BuildCallTransferIdentify(int invokeId);
00119 void BuildCallTransferAbandon(int invokeId);
00120 void BuildCallTransferSetup(int invokeId,
00121 const PString & callIdentity);
00122
00123 void BuildCallWaiting(int invokeId, int numCallsWaiting);
00124
00125 void BuildCallIntrusionForcedRelease(int invokeId, int CICL);
00126 X880_ReturnResult& BuildCallIntrusionForcedReleaseResult(int invokeId);
00127 void BuildCallIntrusionForcedReleaseError();
00128 void BuildCallIntrusionGetCIPL(int invokeId);
00129 void BuildCallIntrusionImpending(int invokeId);
00130 void BuildCallIntrusionForceRelesed(int invokeId);
00131
00132 void AttachSupplementaryServiceAPDU(H323SignalPDU & pdu);
00133 BOOL WriteFacilityPDU(
00134 H323Connection & connection
00135 );
00136
00137 static void ParseEndpointAddress(H4501_EndpointAddress & address,
00138 PString & party);
00139 };
00140
00141
00142 class H450xDispatcher;
00143
00144 class H450xHandler : public PObject
00145 {
00146 PCLASSINFO(H450xHandler, PObject);
00147 public:
00148 H450xHandler(
00149 H323Connection & connection,
00150 H450xDispatcher & dispatcher
00151 );
00152
00153 virtual void AttachToSetup(
00154 H323SignalPDU & pdu
00155 );
00156
00157 virtual void AttachToAlerting(
00158 H323SignalPDU & pdu
00159 );
00160
00161 virtual void AttachToConnect(
00162 H323SignalPDU & pdu
00163 );
00164
00165 virtual void AttachToReleaseComplete(
00166 H323SignalPDU & pdu
00167 );
00168
00169 virtual BOOL OnReceivedInvoke(
00170 int opcode,
00171 int invokeId,
00172 int linkedId,
00173 PASN_OctetString * argument
00174 ) = 0;
00175
00176 virtual BOOL OnReceivedReturnResult(
00177 X880_ReturnResult & returnResult
00178 );
00179
00180 virtual BOOL OnReceivedReturnError(
00181 int errorCode,
00182 X880_ReturnError & returnError
00183 );
00184
00185 virtual BOOL OnReceivedReject(
00186 int problemType,
00187 int problemNumber
00188 );
00189
00192 void SendReturnError(int returnError);
00193
00194 void SendGeneralReject(int problem);
00195
00196 void SendInvokeReject(int problem);
00197
00198 void SendReturnResultReject(int problem);
00199
00200 void SendReturnErrorReject(int problem);
00201
00202 BOOL DecodeArguments(
00203 PASN_OctetString * argString,
00204 PASN_Object & argObject,
00205 int absentErrorCode
00206 );
00207
00208 unsigned GetInvokeId() const { return currentInvokeId; }
00209
00210
00211 protected:
00212 H323EndPoint & endpoint;
00213 H323Connection & connection;
00214 H450xDispatcher & dispatcher;
00215 unsigned currentInvokeId;
00216 };
00217
00218 PLIST(H450xHandlerList, H450xHandler);
00219 PDICTIONARY(H450xHandlerDict, POrdinalKey, H450xHandler);
00220
00221
00222 class H450xDispatcher : public PObject
00223 {
00224 PCLASSINFO(H450xDispatcher, PObject);
00225 public:
00226 H450xDispatcher(
00227 H323Connection & connection
00228 );
00229
00232 void AddOpCode(
00233 unsigned opcode,
00234 H450xHandler * handler
00235 );
00236
00237 virtual void AttachToSetup(
00238 H323SignalPDU & pdu
00239 );
00240
00241 virtual void AttachToAlerting(
00242 H323SignalPDU & pdu
00243 );
00244
00245 virtual void AttachToConnect(
00246 H323SignalPDU & pdu
00247 );
00248
00249 virtual void AttachToReleaseComplete(
00250 H323SignalPDU & pdu
00251 );
00252
00255 virtual BOOL HandlePDU(
00256 const H323SignalPDU & pdu
00257 );
00258
00263 virtual BOOL OnReceivedInvoke(X880_Invoke& invoke, H4501_InterpretationApdu& interpretation);
00264
00270 virtual BOOL OnReceivedReturnResult(X880_ReturnResult& returnResult);
00271
00277 virtual BOOL OnReceivedReturnError(X880_ReturnError& returnError);
00278
00284 virtual BOOL OnReceivedReject(X880_Reject& reject);
00285
00288 void SendReturnError(int invokeId, int returnError);
00289
00290 void SendGeneralReject(int invokeId, int problem);
00291
00292 void SendInvokeReject(int invokeId, int problem);
00293
00294 void SendReturnResultReject(int invokeId, int problem);
00295
00296 void SendReturnErrorReject(int invokeId, int problem);
00297
00300 unsigned GetNextInvokeId() const { return ++nextInvokeId; }
00301
00302 protected:
00303 H323Connection & connection;
00304 H450xHandlerList handlers;
00305 H450xHandlerDict opcodeHandler;
00306 mutable unsigned nextInvokeId;
00307 };
00308
00309
00310 class H4502Handler : public H450xHandler
00311 {
00312 PCLASSINFO(H4502Handler, H450xHandler);
00313 public:
00314 H4502Handler(
00315 H323Connection & connection,
00316 H450xDispatcher & dispatcher
00317 );
00318
00319 virtual void AttachToSetup(
00320 H323SignalPDU & pdu
00321 );
00322
00323 virtual void AttachToAlerting(
00324 H323SignalPDU & pdu
00325 );
00326
00327 virtual void AttachToConnect(
00328 H323SignalPDU & pdu
00329 );
00330
00331 virtual void AttachToReleaseComplete(
00332 H323SignalPDU & pdu
00333 );
00334
00335 virtual BOOL OnReceivedInvoke(
00336 int opcode,
00337 int invokeId,
00338 int linkedId,
00339 PASN_OctetString * argument
00340 );
00341
00344 virtual void OnReceivedCallTransferIdentify(
00345 int linkedId
00346 );
00347
00350 virtual void OnReceivedCallTransferAbandon(
00351 int linkedId
00352 );
00353
00356 virtual void OnReceivedCallTransferInitiate(
00357 int linkedId,
00358 PASN_OctetString * argument
00359 );
00360
00363 virtual void OnReceivedCallTransferSetup(
00364 int linkedId,
00365 PASN_OctetString * argument
00366 );
00367
00370 virtual void OnReceivedCallTransferUpdate(
00371 int linkedId,
00372 PASN_OctetString * argument
00373 );
00374
00377 virtual void OnReceivedSubaddressTransfer(
00378 int linkedId,
00379 PASN_OctetString * argument
00380 );
00381
00384 virtual void OnReceivedCallTransferComplete(
00385 int linkedId,
00386 PASN_OctetString * argument
00387 );
00388
00391 virtual void OnReceivedCallTransferActive(
00392 int linkedId,
00393 PASN_OctetString * argument
00394 );
00395
00396 virtual BOOL OnReceivedReturnResult(
00397 X880_ReturnResult & returnResult
00398 );
00399
00404 void OnReceivedInitiateReturnResult();
00405
00411 void OnReceivedSetupReturnResult();
00412
00417 void OnReceivedIdentifyReturnResult(X880_ReturnResult &returnResult);
00418
00419 virtual BOOL OnReceivedReturnError(
00420 int errorCode,
00421 X880_ReturnError & returnError
00422 );
00423
00428 void OnReceivedInitiateReturnError(
00429 const bool timerExpiry = false
00430 );
00431
00438 void OnReceivedSetupReturnError(
00439 int errorCode,
00440 const bool timerExpiry = false
00441 );
00442
00447 void OnReceivedIdentifyReturnError(
00448 const bool timerExpiry = false
00449 );
00450
00455 void TransferCall(
00456 const PString & remoteParty,
00457 const PString & callIdentity
00458 );
00459
00464 void ConsultationTransfer(
00465 const PString & primaryCallToken
00466 );
00467
00470 void HandleConsultationTransfer(
00471 const PString & callIdentity,
00472 H323Connection& incoming
00473 );
00474
00475 void AwaitSetupResponse(
00476 const PString & token,
00477 const PString & identity
00478 );
00479
00482 enum State {
00483 e_ctIdle,
00484 e_ctAwaitIdentifyResponse,
00485 e_ctAwaitInitiateResponse,
00486 e_ctAwaitSetupResponse,
00487 e_ctAwaitSetup,
00488 e_ctAwaitConnect
00489 };
00490
00493 State GetState() const { return ctState; }
00494
00504 virtual void onReceivedAdmissionReject(const int returnError);
00505
00508 void HandleCallTransferFailure(
00509 const int returnError
00510 );
00511
00514 void StartctTimer(const PTimeInterval value) { ctTimer = value; }
00515
00518 void StopctTimer();
00519
00522 BOOL IsctTimerRunning() { return ctTimer.IsRunning(); }
00523
00526 PDECLARE_NOTIFIER(PTimer, H4502Handler, OnCallTransferTimeOut);
00527
00530 const H323Connection& getAssociatedConnection() const { return connection; }
00531
00534 void SetAssociatedCallToken(const PString& token) { CallToken = token; }
00535
00538 const PString& getTransferringCallToken() const { return transferringCallToken; }
00539
00542 void SetConsultationTransferSuccess() { consultationTransfer = TRUE; }
00543
00546 BOOL isConsultationTransferSuccess() { return consultationTransfer; }
00547
00548 protected:
00549 PString transferringCallToken;
00550 PString transferringCallIdentity;
00551 State ctState;
00552 BOOL ctResponseSent;
00553 PTimer ctTimer;
00554 PString CallToken;
00555
00556 BOOL consultationTransfer;
00557
00558 };
00559
00560
00561 class H4503Handler : public H450xHandler
00562 {
00563 PCLASSINFO(H4503Handler, H450xHandler);
00564 public:
00565 H4503Handler(
00566 H323Connection & connection,
00567 H450xDispatcher & dispatcher
00568 );
00569
00570 virtual BOOL OnReceivedInvoke(
00571 int opcode,
00572 int invokeId,
00573 int linkedId,
00574 PASN_OctetString * argument
00575 );
00576
00579 void OnReceivedDivertingLegInfo2(
00580 int linkedId,
00581 PASN_OctetString * argument
00582 );
00583
00584 BOOL GetRedirectingNumber(
00585 PString &originalCalledNr,
00586 PString &lastDivertingNr ,
00587 int &divCounter,
00588 int &origdivReason,
00589 int &divReason
00590 );
00591
00592 protected:
00593 PString m_originalCalledNr;
00594 PString m_lastDivertingNr;
00595 int m_diversionCounter;
00596 int m_origdiversionReason;
00597 int m_diversionReason;
00598 };
00599
00600
00601 class H4504Handler : public H450xHandler
00602 {
00603 PCLASSINFO(H4504Handler, H450xHandler);
00604 public:
00605 H4504Handler(
00606 H323Connection & connection,
00607 H450xDispatcher & dispatcher
00608 );
00609
00610 virtual BOOL OnReceivedInvoke(
00611 int opcode,
00612 int invokeId,
00613 int linkedId,
00614 PASN_OctetString * argument
00615 );
00616
00619 virtual void OnReceivedLocalCallHold(
00620 int linkedId
00621 );
00622
00625 virtual void OnReceivedLocalCallRetrieve(
00626 int linkedId
00627 );
00628
00632 virtual void OnReceivedRemoteCallHold(
00633 int linkedId
00634 );
00635
00639 virtual void OnReceivedRemoteCallRetrieve(
00640 int linkedId
00641 );
00642
00646 void HoldCall(
00647 BOOL localHold
00648 );
00649
00653 void RetrieveCall();
00654
00657 enum State {
00658 e_ch_Idle,
00659 e_ch_NE_Held,
00660 e_ch_RE_Requested,
00661 e_ch_RE_Held,
00662 e_ch_RE_Retrieve_Req
00663 };
00664
00665 State GetState() const { return holdState; }
00666
00667
00668 protected:
00669 State holdState;
00670 };
00671
00672
00673 class H4506Handler : public H450xHandler
00674 {
00675 PCLASSINFO(H4506Handler, H450xHandler);
00676 public:
00677 H4506Handler(
00678 H323Connection & connection,
00679 H450xDispatcher & dispatcher
00680 );
00681
00682 virtual BOOL OnReceivedInvoke(
00683 int opcode,
00684 int invokeId,
00685 int linkedId,
00686 PASN_OctetString * argument
00687 );
00688
00691 virtual void OnReceivedCallWaitingIndication(
00692 int linkedId,
00693 PASN_OctetString *argument
00694 );
00695
00701 virtual void AttachToAlerting(
00702 H323SignalPDU & pdu,
00703 unsigned numberOfCallsWaiting = 0
00704 );
00705
00708 enum State {
00709 e_cw_Idle,
00710 e_cw_Invoked
00711 };
00712
00713 State GetState() const { return cwState; }
00714
00715
00716 protected:
00717 State cwState;
00718 };
00719
00720
00721 class H45011Handler : public H450xHandler
00722 {
00723 PCLASSINFO(H45011Handler, H450xHandler);
00724 public:
00725 H45011Handler(
00726 H323Connection & connection,
00727 H450xDispatcher & dispatcher
00728 );
00729
00730 virtual void AttachToSetup(
00731 H323SignalPDU & pdu
00732 );
00733
00734 virtual void AttachToAlerting(
00735 H323SignalPDU & pdu
00736 );
00737
00738 virtual void AttachToConnect(
00739 H323SignalPDU & pdu
00740 );
00741
00742 virtual void AttachToReleaseComplete(
00743 H323SignalPDU & pdu
00744 );
00745
00746 virtual BOOL OnReceivedInvoke(
00747 int opcode,
00748 int invokeId,
00749 int linkedId,
00750 PASN_OctetString * argument
00751 );
00752
00755 virtual void OnReceivedCallIntrusionRequest(
00756 int linkedId,
00757 PASN_OctetString *argument
00758 );
00759
00762 virtual void OnReceivedCallIntrusionGetCIPL(
00763 int linkedId,
00764 PASN_OctetString *argument
00765 );
00766
00769 virtual void OnReceivedCallIntrusionIsolate(
00770 int linkedId,
00771 PASN_OctetString *argument
00772 );
00773
00776 virtual BOOL OnReceivedCallIntrusionForcedRelease(
00777 int linkedId,
00778 PASN_OctetString *argument
00779 );
00780
00783 virtual void OnReceivedCallIntrusionWOBRequest(
00784 int linkedId,
00785 PASN_OctetString *argument
00786 );
00787
00790 virtual void OnReceivedCallIntrusionSilentMonitor(
00791 int linkedId,
00792 PASN_OctetString *argument
00793 );
00794
00797 virtual void OnReceivedCallIntrusionNotification(
00798 int linkedId,
00799 PASN_OctetString *argument
00800 );
00801
00804 virtual void OnReceivedCfbOverride(
00805 int linkedId,
00806 PASN_OctetString *argument
00807 );
00808
00811 virtual void OnReceivedRemoteUserAlerting(
00812 int linkedId,
00813 PASN_OctetString *argument
00814 );
00815
00818 virtual void OnReceivedCallWaiting(
00819 int linkedId,
00820 PASN_OctetString *argument
00821 );
00822
00823 virtual BOOL OnReceivedReturnResult(
00824 X880_ReturnResult & returnResult
00825 );
00826
00827 void OnReceivedCIRequestResult();
00828
00829 virtual BOOL OnReceivedReturnError(
00830 int errorCode,
00831 X880_ReturnError & returnError
00832 );
00833
00834 BOOL OnReceivedInvokeReturnError (
00835 int errorCode,
00836 const bool timerExpiry = false
00837 );
00838
00839 void OnReceivedCIGetCIPLResult(
00840 X880_ReturnResult & returnResult
00841 );
00842
00843 BOOL OnReceivedGetCIPLReturnError(
00844 int errorCode,
00845 const bool timerExpiry = false
00846 );
00847
00848 void IntrudeCall(int CICL );
00849
00850 void AwaitSetupResponse(
00851 const PString & token,
00852 const PString & identity
00853 );
00854
00855 BOOL GetRemoteCallIntrusionProtectionLevel(
00856 const PString & intrusionCallToken,
00857 unsigned intrusionCICL
00858 );
00859
00860 void SetIntrusionImpending();
00861
00862 void SetForcedReleaseAccepted();
00863
00864 void SetIntrusionNotAuthorized();
00865
00866 virtual BOOL OnReceivedReject(
00867 int problemType,
00868 int problemNumber
00869 );
00870
00873 enum State {
00874 e_ci_Idle,
00875 e_ci_WaitAck,
00876 e_ci_GetCIPL,
00877 e_ci_OrigInvoked,
00878 e_ci_OrigIsolated,
00879 e_ci_DestNotify,
00880 e_ci_DestInvoked,
00881 e_ci_DestIsolated,
00882 e_ci_DestWOB,
00883 e_ci_IsolationRequest,
00884 e_ci_ForcedReleaseRequest,
00885 e_ci_WOBRequest
00886 };
00887
00889 enum Generate{
00890 e_ci_gIdle,
00891 e_ci_gConferenceRequest,
00892 e_ci_gHeldRequest,
00893 e_ci_gSilentMonitorRequest,
00894 e_ci_gIsolationRequest,
00895 e_ci_gForcedReleaseRequest,
00896 e_ci_gWOBRequest
00897 };
00898
00900 enum SendState{
00901 e_ci_sIdle,
00902 e_ci_sAttachToSetup,
00903 e_ci_sAttachToAlerting,
00904 e_ci_sAttachToConnect,
00905 e_ci_sAttachToReleseComplete
00906 };
00907
00909 enum ReturnState{
00910 e_ci_rIdle,
00911 e_ci_rCallIntrusionImpending,
00912 e_ci_rCallIntruded,
00913 e_ci_rCallIsolated,
00914 e_ci_rCallForceReleased,
00915 e_ci_rCallForceReleaseResult,
00916 e_ci_rCallIntrusionComplete,
00917 e_ci_rCallIntrusionEnd,
00918 e_ci_rNotBusy,
00919 e_ci_rTempUnavailable,
00920 e_ci_rNotAuthorized
00921 };
00922
00925 State GetState() const { return ciState; }
00926
00929 void StartciTimer(const PTimeInterval value) { ciTimer = value; }
00930
00933 void StopciTimer();
00934
00937 BOOL IsctTimerRunning() { return ciTimer.IsRunning(); }
00938
00941 PDECLARE_NOTIFIER(PTimer, H45011Handler, OnCallIntrudeTimeOut);
00942
00943 protected:
00944 State ciState;
00945 PTimer ciTimer;
00946 PString intrudingCallToken;
00947 PString intrudingCallIdentity;
00948 PString activeCallToken;
00949 ReturnState ciReturnState;
00950 SendState ciSendState;
00951 Generate ciGenerateState;
00952 int ciCICL;
00953 unsigned intrudingCallCICL;
00954 };
00955
00956
00957 #endif // __OPAL_H450PDU_H
00958
00959