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
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #ifndef __OPAL_H450PDU_H
00100 #define __OPAL_H450PDU_H
00101
00102 #ifdef P_USE_PRAGMA
00103 #pragma interface
00104 #endif
00105
00106
00107 #include <asn/x880.h>
00108 #include <asn/h4501.h>
00109 #include <asn/h4502.h>
00110
00111
00112 class H323EndPoint;
00113 class H323Connection;
00114 class H323TransportAddress;
00115 class H323SignalPDU;
00116
00117 class H4501_EndpointAddress;
00118 class H4501_InterpretationApdu;
00119
00120
00122
00125 class H450ServiceAPDU : public X880_ROS
00126 {
00127 public:
00128 X880_Invoke& BuildInvoke(int invokeId, int operation);
00129 X880_ReturnResult& BuildReturnResult(int invokeId);
00130 X880_ReturnError& BuildReturnError(int invokeId, int error);
00131 X880_Reject& BuildReject(int invokeId);
00132
00133 void BuildCallTransferInitiate(int invokeId,
00134 const PString & callIdentity,
00135 const PString & alias,
00136 const H323TransportAddress & address);
00137
00138 void BuildCallTransferIdentify(int invokeId);
00139 void BuildCallTransferAbandon(int invokeId);
00140 void BuildCallTransferSetup(int invokeId,
00141 const PString & callIdentity);
00142
00143 void BuildCallWaiting(int invokeId, int numCallsWaiting);
00144
00145 void BuildCallIntrusionForcedRelease(int invokeId, int CICL);
00146 X880_ReturnResult& BuildCallIntrusionForcedReleaseResult(int invokeId);
00147 void BuildCallIntrusionForcedReleaseError();
00148 void BuildCallIntrusionGetCIPL(int invokeId);
00149 void BuildCallIntrusionImpending(int invokeId);
00150 void BuildCallIntrusionForceRelesed(int invokeId);
00151
00152 void AttachSupplementaryServiceAPDU(H323SignalPDU & pdu);
00153 BOOL WriteFacilityPDU(
00154 H323Connection & connection
00155 );
00156
00157 static void ParseEndpointAddress(H4501_EndpointAddress & address,
00158 PString & party);
00159 };
00160
00161
00162 class H450xDispatcher;
00163
00164 class H450xHandler : public PObject
00165 {
00166 PCLASSINFO(H450xHandler, PObject);
00167 public:
00168 H450xHandler(
00169 H323Connection & connection,
00170 H450xDispatcher & dispatcher
00171 );
00172
00173 virtual void AttachToSetup(
00174 H323SignalPDU & pdu
00175 );
00176
00177 virtual void AttachToAlerting(
00178 H323SignalPDU & pdu
00179 );
00180
00181 virtual void AttachToConnect(
00182 H323SignalPDU & pdu
00183 );
00184
00185 virtual void AttachToReleaseComplete(
00186 H323SignalPDU & pdu
00187 );
00188
00189 virtual BOOL OnReceivedInvoke(
00190 int opcode,
00191 int invokeId,
00192 int linkedId,
00193 PASN_OctetString * argument
00194 ) = 0;
00195
00196 virtual BOOL OnReceivedReturnResult(
00197 X880_ReturnResult & returnResult
00198 );
00199
00200 virtual BOOL OnReceivedReturnError(
00201 int errorCode,
00202 X880_ReturnError & returnError
00203 );
00204
00205 virtual BOOL OnReceivedReject(
00206 int problemType,
00207 int problemNumber
00208 );
00209
00212 void SendReturnError(int returnError);
00213
00214 void SendGeneralReject(int problem);
00215
00216 void SendInvokeReject(int problem);
00217
00218 void SendReturnResultReject(int problem);
00219
00220 void SendReturnErrorReject(int problem);
00221
00222 BOOL DecodeArguments(
00223 PASN_OctetString * argString,
00224 PASN_Object & argObject,
00225 int absentErrorCode
00226 );
00227
00228 unsigned GetInvokeId() const { return currentInvokeId; }
00229
00230
00231 protected:
00232 H323EndPoint & endpoint;
00233 H323Connection & connection;
00234 H450xDispatcher & dispatcher;
00235 unsigned currentInvokeId;
00236 };
00237
00238 PLIST(H450xHandlerList, H450xHandler);
00239 PDICTIONARY(H450xHandlerDict, POrdinalKey, H450xHandler);
00240
00241
00242 class H450xDispatcher : public PObject
00243 {
00244 PCLASSINFO(H450xDispatcher, PObject);
00245 public:
00246 H450xDispatcher(
00247 H323Connection & connection
00248 );
00249
00252 void AddOpCode(
00253 unsigned opcode,
00254 H450xHandler * handler
00255 );
00256
00257 virtual void AttachToSetup(
00258 H323SignalPDU & pdu
00259 );
00260
00261 virtual void AttachToAlerting(
00262 H323SignalPDU & pdu
00263 );
00264
00265 virtual void AttachToConnect(
00266 H323SignalPDU & pdu
00267 );
00268
00269 virtual void AttachToReleaseComplete(
00270 H323SignalPDU & pdu
00271 );
00272
00275 virtual BOOL HandlePDU(
00276 const H323SignalPDU & pdu
00277 );
00278
00283 virtual BOOL OnReceivedInvoke(X880_Invoke& invoke, H4501_InterpretationApdu& interpretation);
00284
00290 virtual BOOL OnReceivedReturnResult(X880_ReturnResult& returnResult);
00291
00297 virtual BOOL OnReceivedReturnError(X880_ReturnError& returnError);
00298
00304 virtual BOOL OnReceivedReject(X880_Reject& reject);
00305
00308 void SendReturnError(int invokeId, int returnError);
00309
00310 void SendGeneralReject(int invokeId, int problem);
00311
00312 void SendInvokeReject(int invokeId, int problem);
00313
00314 void SendReturnResultReject(int invokeId, int problem);
00315
00316 void SendReturnErrorReject(int invokeId, int problem);
00317
00320 unsigned GetNextInvokeId() const { return ++nextInvokeId; }
00321
00322 protected:
00323 H323Connection & connection;
00324 H450xHandlerList handlers;
00325 H450xHandlerDict opcodeHandler;
00326 mutable unsigned nextInvokeId;
00327 };
00328
00329
00330 class H4502Handler : public H450xHandler
00331 {
00332 PCLASSINFO(H4502Handler, H450xHandler);
00333 public:
00334 H4502Handler(
00335 H323Connection & connection,
00336 H450xDispatcher & dispatcher
00337 );
00338
00339 virtual void AttachToSetup(
00340 H323SignalPDU & pdu
00341 );
00342
00343 virtual void AttachToAlerting(
00344 H323SignalPDU & pdu
00345 );
00346
00347 virtual void AttachToConnect(
00348 H323SignalPDU & pdu
00349 );
00350
00351 virtual void AttachToReleaseComplete(
00352 H323SignalPDU & pdu
00353 );
00354
00355 virtual BOOL OnReceivedInvoke(
00356 int opcode,
00357 int invokeId,
00358 int linkedId,
00359 PASN_OctetString * argument
00360 );
00361
00364 virtual void OnReceivedCallTransferIdentify(
00365 int linkedId
00366 );
00367
00370 virtual void OnReceivedCallTransferAbandon(
00371 int linkedId
00372 );
00373
00376 virtual void OnReceivedCallTransferInitiate(
00377 int linkedId,
00378 PASN_OctetString * argument
00379 );
00380
00383 virtual void OnReceivedCallTransferSetup(
00384 int linkedId,
00385 PASN_OctetString * argument
00386 );
00387
00390 virtual void OnReceivedCallTransferUpdate(
00391 int linkedId,
00392 PASN_OctetString * argument
00393 );
00394
00397 virtual void OnReceivedSubaddressTransfer(
00398 int linkedId,
00399 PASN_OctetString * argument
00400 );
00401
00404 virtual void OnReceivedCallTransferComplete(
00405 int linkedId,
00406 PASN_OctetString * argument
00407 );
00408
00411 virtual void OnReceivedCallTransferActive(
00412 int linkedId,
00413 PASN_OctetString * argument
00414 );
00415
00416 virtual BOOL OnReceivedReturnResult(
00417 X880_ReturnResult & returnResult
00418 );
00419
00424 void OnReceivedInitiateReturnResult();
00425
00431 void OnReceivedSetupReturnResult();
00432
00437 void OnReceivedIdentifyReturnResult(X880_ReturnResult &returnResult);
00438
00439 virtual BOOL OnReceivedReturnError(
00440 int errorCode,
00441 X880_ReturnError & returnError
00442 );
00443
00448 void OnReceivedInitiateReturnError(
00449 const bool timerExpiry = false
00450 );
00451
00458 void OnReceivedSetupReturnError(
00459 int errorCode,
00460 const bool timerExpiry = false
00461 );
00462
00467 void OnReceivedIdentifyReturnError(
00468 const bool timerExpiry = false
00469 );
00470
00475 void TransferCall(
00476 const PString & remoteParty,
00477 const PString & callIdentity
00478 );
00479
00484 void ConsultationTransfer(
00485 const PString & primaryCallToken
00486 );
00487
00490 void HandleConsultationTransfer(
00491 const PString & callIdentity,
00492 H323Connection& incoming
00493 );
00494
00495 void AwaitSetupResponse(
00496 const PString & token,
00497 const PString & identity
00498 );
00499
00502 enum State {
00503 e_ctIdle,
00504 e_ctAwaitIdentifyResponse,
00505 e_ctAwaitInitiateResponse,
00506 e_ctAwaitSetupResponse,
00507 e_ctAwaitSetup,
00508 e_ctAwaitConnect
00509 };
00510
00513 State GetState() const { return ctState; }
00514
00524 virtual void onReceivedAdmissionReject(const int returnError);
00525
00528 void HandleCallTransferFailure(
00529 const int returnError
00530 );
00531
00534 void StartctTimer(const PTimeInterval value) { ctTimer = value; }
00535
00538 void StopctTimer();
00539
00542 BOOL IsctTimerRunning() { return ctTimer.IsRunning(); }
00543
00546 PDECLARE_NOTIFIER(PTimer, H4502Handler, OnCallTransferTimeOut);
00547
00550 const H323Connection& getAssociatedConnection() const { return connection; }
00551
00554 void SetAssociatedCallToken(const PString& token) { CallToken = token; }
00555
00558 const PString& getTransferringCallToken() const { return transferringCallToken; }
00559
00562 void SetConsultationTransferSuccess() { consultationTransfer = TRUE; }
00563
00566 BOOL isConsultationTransferSuccess() { return consultationTransfer; }
00567
00568 protected:
00569 PString transferringCallToken;
00570 PString transferringCallIdentity;
00571 State ctState;
00572 BOOL ctResponseSent;
00573 PTimer ctTimer;
00574 PString CallToken;
00575
00576 BOOL consultationTransfer;
00577
00578 };
00579
00580
00581 class H4504Handler : public H450xHandler
00582 {
00583 PCLASSINFO(H4504Handler, H450xHandler);
00584 public:
00585 H4504Handler(
00586 H323Connection & connection,
00587 H450xDispatcher & dispatcher
00588 );
00589
00590 virtual BOOL OnReceivedInvoke(
00591 int opcode,
00592 int invokeId,
00593 int linkedId,
00594 PASN_OctetString * argument
00595 );
00596
00599 virtual void OnReceivedLocalCallHold(
00600 int linkedId
00601 );
00602
00605 virtual void OnReceivedLocalCallRetrieve(
00606 int linkedId
00607 );
00608
00612 virtual void OnReceivedRemoteCallHold(
00613 int linkedId
00614 );
00615
00619 virtual void OnReceivedRemoteCallRetrieve(
00620 int linkedId
00621 );
00622
00626 void HoldCall(
00627 BOOL localHold
00628 );
00629
00633 void RetrieveCall();
00634
00637 enum State {
00638 e_ch_Idle,
00639 e_ch_NE_Held,
00640 e_ch_RE_Requested,
00641 e_ch_RE_Held,
00642 e_ch_RE_Retrieve_Req
00643 };
00644
00645 State GetState() const { return holdState; }
00646
00647
00648 protected:
00649 State holdState;
00650 };
00651
00652
00653 class H4506Handler : public H450xHandler
00654 {
00655 PCLASSINFO(H4506Handler, H450xHandler);
00656 public:
00657 H4506Handler(
00658 H323Connection & connection,
00659 H450xDispatcher & dispatcher
00660 );
00661
00662 virtual BOOL OnReceivedInvoke(
00663 int opcode,
00664 int invokeId,
00665 int linkedId,
00666 PASN_OctetString * argument
00667 );
00668
00671 virtual void OnReceivedCallWaitingIndication(
00672 int linkedId,
00673 PASN_OctetString *argument
00674 );
00675
00681 virtual void AttachToAlerting(
00682 H323SignalPDU & pdu,
00683 unsigned numberOfCallsWaiting = 0
00684 );
00685
00688 enum State {
00689 e_cw_Idle,
00690 e_cw_Invoked
00691 };
00692
00693 State GetState() const { return cwState; }
00694
00695
00696 protected:
00697 State cwState;
00698 };
00699
00700
00701 class H45011Handler : public H450xHandler
00702 {
00703 PCLASSINFO(H45011Handler, H450xHandler);
00704 public:
00705 H45011Handler(
00706 H323Connection & connection,
00707 H450xDispatcher & dispatcher
00708 );
00709
00710 virtual void AttachToSetup(
00711 H323SignalPDU & pdu
00712 );
00713
00714 virtual void AttachToAlerting(
00715 H323SignalPDU & pdu
00716 );
00717
00718 virtual void AttachToConnect(
00719 H323SignalPDU & pdu
00720 );
00721
00722 virtual void AttachToReleaseComplete(
00723 H323SignalPDU & pdu
00724 );
00725
00726 virtual BOOL OnReceivedInvoke(
00727 int opcode,
00728 int invokeId,
00729 int linkedId,
00730 PASN_OctetString * argument
00731 );
00732
00735 virtual void OnReceivedCallIntrusionRequest(
00736 int linkedId,
00737 PASN_OctetString *argument
00738 );
00739
00742 virtual void OnReceivedCallIntrusionGetCIPL(
00743 int linkedId,
00744 PASN_OctetString *argument
00745 );
00746
00749 virtual void OnReceivedCallIntrusionIsolate(
00750 int linkedId,
00751 PASN_OctetString *argument
00752 );
00753
00756 virtual BOOL OnReceivedCallIntrusionForcedRelease(
00757 int linkedId,
00758 PASN_OctetString *argument
00759 );
00760
00763 virtual void OnReceivedCallIntrusionWOBRequest(
00764 int linkedId,
00765 PASN_OctetString *argument
00766 );
00767
00770 virtual void OnReceivedCallIntrusionSilentMonitor(
00771 int linkedId,
00772 PASN_OctetString *argument
00773 );
00774
00777 virtual void OnReceivedCallIntrusionNotification(
00778 int linkedId,
00779 PASN_OctetString *argument
00780 );
00781
00784 virtual void OnReceivedCfbOverride(
00785 int linkedId,
00786 PASN_OctetString *argument
00787 );
00788
00791 virtual void OnReceivedRemoteUserAlerting(
00792 int linkedId,
00793 PASN_OctetString *argument
00794 );
00795
00798 virtual void OnReceivedCallWaiting(
00799 int linkedId,
00800 PASN_OctetString *argument
00801 );
00802
00803 virtual BOOL OnReceivedReturnResult(
00804 X880_ReturnResult & returnResult
00805 );
00806
00807 void OnReceivedCIRequestResult();
00808
00809 virtual BOOL OnReceivedReturnError(
00810 int errorCode,
00811 X880_ReturnError & returnError
00812 );
00813
00814 BOOL OnReceivedInvokeReturnError (
00815 int errorCode,
00816 const bool timerExpiry = false
00817 );
00818
00819 void OnReceivedCIGetCIPLResult(
00820 X880_ReturnResult & returnResult
00821 );
00822
00823 BOOL OnReceivedGetCIPLReturnError(
00824 int errorCode,
00825 const bool timerExpiry = false
00826 );
00827
00828 void IntrudeCall(int CICL );
00829
00830 void AwaitSetupResponse(
00831 const PString & token,
00832 const PString & identity
00833 );
00834
00835 BOOL GetRemoteCallIntrusionProtectionLevel(
00836 const PString & intrusionCallToken,
00837 unsigned intrusionCICL
00838 );
00839
00840 void SetIntrusionImpending();
00841
00842 void SetForcedReleaseAccepted();
00843
00844 void SetIntrusionNotAuthorized();
00845
00846 virtual BOOL OnReceivedReject(
00847 int problemType,
00848 int problemNumber
00849 );
00850
00853 enum State {
00854 e_ci_Idle,
00855 e_ci_WaitAck,
00856 e_ci_GetCIPL,
00857 e_ci_OrigInvoked,
00858 e_ci_OrigIsolated,
00859 e_ci_DestNotify,
00860 e_ci_DestInvoked,
00861 e_ci_DestIsolated,
00862 e_ci_DestWOB,
00863 e_ci_IsolationRequest,
00864 e_ci_ForcedReleaseRequest,
00865 e_ci_WOBRequest
00866 };
00867
00869 enum Generate{
00870 e_ci_gIdle,
00871 e_ci_gConferenceRequest,
00872 e_ci_gHeldRequest,
00873 e_ci_gSilentMonitorRequest,
00874 e_ci_gIsolationRequest,
00875 e_ci_gForcedReleaseRequest,
00876 e_ci_gWOBRequest
00877 };
00878
00880 enum SendState{
00881 e_ci_sIdle,
00882 e_ci_sAttachToSetup,
00883 e_ci_sAttachToAlerting,
00884 e_ci_sAttachToConnect,
00885 e_ci_sAttachToReleseComplete
00886 };
00887
00889 enum ReturnState{
00890 e_ci_rIdle,
00891 e_ci_rCallIntrusionImpending,
00892 e_ci_rCallIntruded,
00893 e_ci_rCallIsolated,
00894 e_ci_rCallForceReleased,
00895 e_ci_rCallForceReleaseResult,
00896 e_ci_rCallIntrusionComplete,
00897 e_ci_rCallIntrusionEnd,
00898 e_ci_rNotBusy,
00899 e_ci_rTempUnavailable,
00900 e_ci_rNotAuthorized
00901 };
00902
00905 State GetState() const { return ciState; }
00906
00909 void StartciTimer(const PTimeInterval value) { ciTimer = value; }
00910
00913 void StopciTimer();
00914
00917 BOOL IsctTimerRunning() { return ciTimer.IsRunning(); }
00918
00921 PDECLARE_NOTIFIER(PTimer, H45011Handler, OnCallIntrudeTimeOut);
00922
00923 protected:
00924 State ciState;
00925 PTimer ciTimer;
00926 PString intrudingCallToken;
00927 PString intrudingCallIdentity;
00928 PString activeCallToken;
00929 ReturnState ciReturnState;
00930 SendState ciSendState;
00931 Generate ciGenerateState;
00932 int ciCICL;
00933 unsigned intrudingCallCICL;
00934 };
00935
00936
00937 #endif // __OPAL_H450PDU_H
00938
00939