1 /* 2 * h450pdu.h 3 * 4 * H.450 Helper functions 5 * 6 * Open H323 Library 7 * 8 * Copyright (c) 2001 Norwood Systems Pty. Ltd. 9 * 10 * The contents of this file are subject to the Mozilla Public License 11 * Version 1.0 (the "License"); you may not use this file except in 12 * compliance with the License. You may obtain a copy of the License at 13 * http://www.mozilla.org/MPL/ 14 * 15 * Software distributed under the License is distributed on an "AS IS" 16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 17 * the License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * The Original Code is Open H323 Library. 21 * 22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 23 * 24 * Contributor(s): ______________________________________. 25 * 26 * $ Id $ 27 * 28 */ 29 30 #ifndef __OPAL_H450PDU_H 31 #define __OPAL_H450PDU_H 32 33 #ifdef P_USE_PRAGMA 34 #pragma interface 35 #endif 36 37 38 #include "x880.h" 39 #include "ptlib_extras.h" 40 41 42 class H323EndPoint; 43 class H323Connection; 44 class H323TransportAddress; 45 class H323SignalPDU; 46 47 class H4501_EndpointAddress; 48 class H4501_InterpretationApdu; 49 50 51 /////////////////////////////////////////////////////////////////////////////// 52 53 /**PDU definition for H.450 services. 54 */ 55 class H450ServiceAPDU : public X880_ROS 56 { 57 public: 58 X880_Invoke& BuildInvoke(int invokeId, int operation); 59 X880_ReturnResult& BuildReturnResult(int invokeId); 60 X880_ReturnError& BuildReturnError(int invokeId, int error); 61 X880_Reject& BuildReject(int invokeId); 62 63 void BuildCallTransferInitiate(int invokeId, 64 const PString & callIdentity, 65 const PString & alias, 66 const H323TransportAddress & address); 67 68 void BuildCallTransferIdentify(int invokeId); 69 void BuildCallTransferAbandon(int invokeId); 70 void BuildCallTransferSetup(int invokeId, 71 const PString & callIdentity); 72 73 void BuildCallWaiting(int invokeId, int numCallsWaiting); 74 75 X880_Invoke & BuildMessageWaitIndicationActivate(int invokeId); 76 X880_Invoke & BuildMessageWaitIndicationDeactivate(int invokeId); 77 X880_Invoke & BuildMessageWaitIndicationInterrogate(int invokeId); 78 79 X880_ReturnResult & BuildMessageWaitIndicationResult(int invokeId, int opcode); 80 81 void BuildCallIntrusionForcedRelease(int invokeId, int CICL); 82 X880_ReturnResult& BuildCallIntrusionForcedReleaseResult(int invokeId); 83 void BuildCallIntrusionForcedReleaseError(); 84 void BuildCallIntrusionGetCIPL(int invokeId); 85 void BuildCallIntrusionImpending(int invokeId); 86 void BuildCallIntrusionForceRelesed(int invokeId); 87 88 void AttachSupplementaryServiceAPDU(H323SignalPDU & pdu); 89 PBoolean WriteFacilityPDU( 90 H323Connection & connection 91 ); 92 93 static void ParseEndpointAddress(H4501_EndpointAddress & address, 94 PString & party); 95 }; 96 97 98 class H450xDispatcher; 99 100 class H450xHandler : public PObject 101 { 102 PCLASSINFO(H450xHandler, PObject); 103 public: 104 H450xHandler( 105 H323Connection & connection, 106 H450xDispatcher & dispatcher 107 ); 108 109 virtual void AttachToSetup( 110 H323SignalPDU & pdu 111 ); 112 113 virtual void AttachToAlerting( 114 H323SignalPDU & pdu 115 ); 116 117 virtual void AttachToConnect( 118 H323SignalPDU & pdu 119 ); 120 121 virtual void AttachToReleaseComplete( 122 H323SignalPDU & pdu 123 ); 124 125 virtual PBoolean OnReceivedInvoke( 126 int opcode, 127 int invokeId, ///< InvokeId of operation (used in response) 128 int linkedId, ///< InvokeId of associated operation (if any) 129 PASN_OctetString * argument ///< Parameters for the initiate operation 130 ) = 0; 131 132 virtual PBoolean OnReceivedReturnResult( 133 X880_ReturnResult & returnResult 134 ); 135 136 virtual PBoolean OnReceivedReturnError( 137 int errorCode, 138 X880_ReturnError & returnError 139 ); 140 141 virtual PBoolean OnReceivedReject( 142 int problemType, 143 int problemNumber 144 ); 145 146 /**Send a return error in response to an invoke operation. 147 */ 148 void SendReturnError(int returnError); 149 150 void SendGeneralReject(int problem); 151 152 void SendInvokeReject(int problem); 153 154 void SendReturnResultReject(int problem); 155 156 void SendReturnErrorReject(int problem); 157 158 PBoolean DecodeArguments( 159 PASN_OctetString * argString, 160 PASN_Object & argObject, 161 int absentErrorCode 162 ); 163 GetInvokeId()164 unsigned GetInvokeId() const { return currentInvokeId; } 165 166 167 protected: 168 H323EndPoint & endpoint; 169 H323Connection & connection; 170 H450xDispatcher & dispatcher; 171 unsigned currentInvokeId; 172 }; 173 174 H323LIST(H450xHandlerList, H450xHandler); 175 H323DICTIONARY(H450xHandlerDict, POrdinalKey, H450xHandler); 176 177 178 class H450xDispatcher : public PObject 179 { 180 PCLASSINFO(H450xDispatcher, PObject); 181 public: 182 H450xDispatcher( 183 H323Connection & connection 184 ); 185 186 /**Add a handler for the op code. 187 */ 188 void AddOpCode( 189 unsigned opcode, 190 H450xHandler * handler 191 ); 192 193 virtual void AttachToSetup( 194 H323SignalPDU & pdu 195 ); 196 197 virtual void AttachToAlerting( 198 H323SignalPDU & pdu 199 ); 200 201 virtual void AttachToConnect( 202 H323SignalPDU & pdu 203 ); 204 205 virtual void AttachToReleaseComplete( 206 H323SignalPDU & pdu 207 ); 208 209 /** Handle the H.450.x Supplementary Service PDU if present in the H225_H323_UU_PDU 210 */ 211 virtual PBoolean HandlePDU( 212 const H323SignalPDU & pdu 213 ); 214 215 /**Handle an incoming X880 Invoke PDU. 216 The default behaviour is to attempt to decode the invoke operation 217 and call the corresponding OnReceived<Operation> method on the EndPoint. 218 */ 219 virtual PBoolean OnReceivedInvoke(X880_Invoke& invoke, H4501_InterpretationApdu& interpretation); 220 221 /**Handle an incoming X880 Return Result PDU. 222 The default behaviour is to attempt to match the return result 223 to a previous invoke operation and call the corresponding 224 OnReceived<Operation>Success method on the EndPoint. 225 */ 226 virtual PBoolean OnReceivedReturnResult(X880_ReturnResult& returnResult); 227 228 /**Handle an incoming X880 Return Error PDU. 229 The default behaviour is to attempt to match the return error 230 to a previous invoke operation and call the corresponding 231 OnReceived<Operation>Error method on the EndPoint. 232 */ 233 virtual PBoolean OnReceivedReturnError(X880_ReturnError& returnError); 234 235 /**Handle an incoming X880 Reject PDU. 236 The default behaviour is to attempt to match the reject 237 to a previous invoke, return result or return error operation 238 and call OnReceived<Operation>Reject method on the EndPoint. 239 */ 240 virtual PBoolean OnReceivedReject(X880_Reject& reject); 241 242 /**Send a return error in response to an invoke operation. 243 */ 244 void SendReturnError(int invokeId, int returnError); 245 246 void SendGeneralReject(int invokeId, int problem); 247 248 void SendInvokeReject(int invokeId, int problem); 249 250 void SendReturnResultReject(int invokeId, int problem); 251 252 void SendReturnErrorReject(int invokeId, int problem); 253 254 /**Get the next available invoke Id for H450 operations 255 */ GetNextInvokeId()256 unsigned GetNextInvokeId() const { return ++nextInvokeId; } 257 258 protected: 259 H323Connection & connection; 260 H450xHandlerList handlers; 261 H450xHandlerDict opcodeHandler; 262 mutable unsigned nextInvokeId; ///< Next available invoke ID for H450 operations 263 }; 264 265 266 class H4502Handler : public H450xHandler 267 { 268 PCLASSINFO(H4502Handler, H450xHandler); 269 public: 270 H4502Handler( 271 H323Connection & connection, 272 H450xDispatcher & dispatcher 273 ); 274 275 virtual void AttachToSetup( 276 H323SignalPDU & pdu 277 ); 278 279 virtual void AttachToAlerting( 280 H323SignalPDU & pdu 281 ); 282 283 virtual void AttachToConnect( 284 H323SignalPDU & pdu 285 ); 286 287 virtual void AttachToReleaseComplete( 288 H323SignalPDU & pdu 289 ); 290 291 virtual PBoolean OnReceivedInvoke( 292 int opcode, 293 int invokeId, ///< InvokeId of operation (used in response) 294 int linkedId, ///< InvokeId of associated operation (if any) 295 PASN_OctetString * argument ///< Parameters for the initiate operation 296 ); 297 298 /**Handle an incoming Call Transfer Identify operation. 299 */ 300 virtual void OnReceivedCallTransferIdentify( 301 int linkedId ///< InvokeId of associated operation (if any) 302 ); 303 304 /**Handle an incoming Call Transfer Abandon operation. 305 */ 306 virtual void OnReceivedCallTransferAbandon( 307 int linkedId ///< InvokeId of associated operation (if any) 308 ); 309 310 /**Handle an incoming Call Transfer Initiate operation. 311 */ 312 virtual void OnReceivedCallTransferInitiate( 313 int linkedId, ///< InvokeId of associated operation (if any) 314 PASN_OctetString * argument ///< Parameters for the initiate operation 315 ); 316 317 /**Handle an incoming Call Transfer Setup operation. 318 */ 319 virtual void OnReceivedCallTransferSetup( 320 int linkedId, ///< InvokeId of associated operation (if any) 321 PASN_OctetString * argument ///< Parameters for the setup operation 322 ); 323 324 /**Handle an incoming Call Transfer Update operation. 325 */ 326 virtual void OnReceivedCallTransferUpdate( 327 int linkedId, ///< InvokeId of associated operation (if any) 328 PASN_OctetString * argument ///< Parameters for the update operation 329 ); 330 331 /**Handle an incoming Subaddress Transfer operation. 332 */ 333 virtual void OnReceivedSubaddressTransfer( 334 int linkedId, ///< InvokeId of associated operation (if any) 335 PASN_OctetString * argument ///< Parameters for the subaddress transfer operation 336 ); 337 338 /**Handle an incoming Call Transfer Complete operation. 339 */ 340 virtual void OnReceivedCallTransferComplete( 341 int linkedId, ///< InvokeId of associated operation (if any) 342 PASN_OctetString * argument ///< Parameters for the complete operation 343 ); 344 345 /**Handle an incoming Call Transfer Active operation. 346 */ 347 virtual void OnReceivedCallTransferActive( 348 int linkedId, ///< InvokeId of associated operation (if any) 349 PASN_OctetString * argument ///< Parameters for the active operation 350 ); 351 352 virtual PBoolean OnReceivedReturnResult( 353 X880_ReturnResult & returnResult 354 ); 355 356 /**Handle the reception of a callTransferInitiate returnResult when we are in call transfer state 357 e_ctAwaitInitiateResponse. Note this is an internal function and it is not expected an 358 application would use it. 359 */ 360 void OnReceivedInitiateReturnResult(); 361 362 /**Handle the reception of a callTransferSetup returnResult when we are in call transfer state 363 e_ctAwaitSetupResponse. This funtion exists to handle the case when the transferred-to 364 endpoint does not support H.450.2. Note this is an internal function and it is not expected an 365 application would use it. 366 */ 367 void OnReceivedSetupReturnResult(); 368 369 /**Handle the reception of a callTransferIdentify returnResult when we are in call transfer state 370 e_ctAwaitIdentifyResponse. Note this is an internal function and it is not expected an 371 application would use it. 372 */ 373 void OnReceivedIdentifyReturnResult(X880_ReturnResult &returnResult); 374 375 virtual PBoolean OnReceivedReturnError( 376 int errorCode, 377 X880_ReturnError & returnError 378 ); 379 380 /**Handle the reception of a callTransferInitiate returnError or expiry of Call Transfer Timer CT-T3 381 when we are in call transfer state e_ctAwaitInitiateResponse. Note this is an internal function 382 and it is not expected an application would use it. 383 */ 384 void OnReceivedInitiateReturnError( 385 const bool timerExpiry = false ///< Flag to indicate expiry 386 ); 387 388 /**Handle the reception of a callTransferSetup returnError or expiry of Call Transfer Timer CT-T4 389 when we are in call transfer state e_ctAwaitSetupResponse. This funtion also additionally handles 390 the case when the transferred-to endpoint does not support H.450.2 and has rejected the incoming 391 call request. Note this is an internal function and it is not expected an application would use 392 it. 393 */ 394 void OnReceivedSetupReturnError( 395 int errorCode, 396 const bool timerExpiry = false ///< Flag to indicate expiry 397 ); 398 399 /**Handle the reception of a callTransferIdentify returnError or expiry of Call Transfer Timer CT-T1 400 when we are in call transfer state e_ctAwaitIdentifyResponse. Note this is an internal function and it is not expected an 401 application would use it. 402 */ 403 void OnReceivedIdentifyReturnError( 404 const bool timerExpiry = false ///< Flag to indicate expiry 405 ); 406 407 /**Initiate the transfer of an existing call (connection) to a new remote party 408 using H.450.2. This sends a Call Transfer Initiate Invoke message from the 409 A-Party (transferring endpoint) to the B-Party (transferred endpoint). 410 */ 411 void TransferCall( 412 const PString & remoteParty, ///< Remote party to transfer the existing call to 413 const PString & callIdentity ///< Call Identity of secondary call if present 414 ); 415 416 /**Transfer the call through consultation so the remote party in the primary call is connected to 417 the called party in the second call using H.450.2. This sends a Call Transfer Identify Invoke 418 message from the A-Party (transferring endpoint) to the C-Party (transferred-to endpoint). 419 */ 420 void ConsultationTransfer( 421 const PString & primaryCallToken ///< Primary call 422 ); 423 424 /**Handle the reception of a callTransferSetupInvoke APDU whilst a secondary call exists. 425 */ 426 void HandleConsultationTransfer( 427 const PString & callIdentity, ///< Call Identity of secondary call 428 H323Connection& incoming ///< New incoming connection 429 ); 430 431 void AwaitSetupResponse( 432 const PString & token, 433 const PString & identity 434 ); 435 436 /**Sub-state for call transfer. 437 */ 438 enum State { 439 e_ctIdle, 440 e_ctAwaitIdentifyResponse, 441 e_ctAwaitInitiateResponse, 442 e_ctAwaitSetupResponse, 443 e_ctAwaitSetup, 444 e_ctAwaitConnect 445 }; 446 447 /**Get the current call transfer state. 448 */ GetState()449 State GetState() const { return ctState; } 450 451 /**Handle the reception of an Admission Reject during a pending call 452 transfer operation at the transferred endpoint. If the call transfer 453 state of the current connection is e_ctAwaitSetupResponse, the stack 454 attempts to find the existing connection between the transferred and 455 transferring endpoints and inform this connection that a 456 callTransferInitiateReturnError PDU needs to be sent. No action is 457 taken if the current connection is not in call transfer state 458 e_ctAwaitSetupResponse. 459 */ 460 virtual void onReceivedAdmissionReject(const int returnError); 461 462 /**Handle the failure of a call transfer operation. 463 */ 464 void HandleCallTransferFailure( 465 const int returnError ///< failure reason 466 ); 467 468 /** Start the Call Transfer Timer using the specified time interval. 469 */ StartctTimer(const PTimeInterval value)470 void StartctTimer(const PTimeInterval value) { ctTimer = value; } 471 472 /** Stop the Call Transfer Timer 473 */ 474 void StopctTimer(); 475 476 /**Is the Call Transfer Timer running? 477 */ IsctTimerRunning()478 PBoolean IsctTimerRunning() { return ctTimer.IsRunning(); } 479 480 /**Callback mechanism for Call Transfer Timers CT-T1, CT-T2, CT-T3 & CT-T4 481 */ 482 PDECLARE_NOTIFIER(PTimer, H4502Handler, OnCallTransferTimeOut); 483 484 /**Get the connection assoicated with this H4502Handler. 485 */ getAssociatedConnection()486 const H323Connection& getAssociatedConnection() const { return connection; } 487 488 /**Set the associated callToken. 489 */ SetAssociatedCallToken(const PString & token)490 void SetAssociatedCallToken(const PString& token) { CallToken = token; } 491 492 /**Get the transferringCallToken member 493 */ getTransferringCallToken()494 const PString& getTransferringCallToken() const { return transferringCallToken; } 495 496 /**Set the 'consultationTransfer' member to TRUE (indicating a successful transfer) 497 */ SetConsultationTransferSuccess()498 void SetConsultationTransferSuccess() { consultationTransfer = TRUE; } 499 500 /**Was the transfer through consultation successful. 501 */ isConsultationTransferSuccess()502 PBoolean isConsultationTransferSuccess() { return consultationTransfer; } 503 504 protected: 505 PString transferringCallToken; // Stores the call token for the transferring connection (if there is one) 506 PString transferringCallIdentity; // Stores the call identity for the transferring call (if there is one) 507 State ctState; // Call Transfer state of the conneciton 508 PBoolean ctResponseSent; // Has a callTransferSetupReturnResult been sent? 509 PTimer ctTimer; // Call Transfer Timer - Handles all four timers CT-T1, 510 PString CallToken; // Call Token of the associated connection 511 // (used during a consultation transfer). 512 PBoolean consultationTransfer; // Flag used to indicate whether an incoming call is involved in 513 // a transfer through consultation. 514 }; 515 516 517 class H4503Handler : public H450xHandler 518 { 519 PCLASSINFO(H4503Handler, H450xHandler); 520 public: 521 H4503Handler( 522 H323Connection & connection, 523 H450xDispatcher & dispatcher 524 ); 525 526 virtual PBoolean OnReceivedInvoke( 527 int opcode, 528 int invokeId, /// InvokeId of operation (used in response) 529 int linkedId, /// InvokeId of associated operation (if any) 530 PASN_OctetString * argument /// Parameters for the initiate operation 531 ); 532 533 /**Handle an incoming Near-End Call Hold operation 534 */ 535 void OnReceivedDivertingLegInfo2( 536 int linkedId, /// InvokeId of associated operation (if any) 537 PASN_OctetString * argument 538 ); 539 540 PBoolean GetRedirectingNumber( 541 PString &originalCalledNr, /// InvokeId of associated operation (if any) 542 PString &lastDivertingNr , 543 int &divCounter, 544 int &origdivReason, 545 int &divReason 546 ); 547 548 protected: 549 PString m_originalCalledNr; // Originally called number (=> the 1st redirecting number) 550 PString m_lastDivertingNr; // last diverting number (in the case of nultiple-call forward) 551 int m_diversionCounter; 552 int m_origdiversionReason; // original diversion reason 553 int m_diversionReason; // diversion reason 554 }; 555 556 557 class H4504Handler : public H450xHandler 558 { 559 PCLASSINFO(H4504Handler, H450xHandler); 560 public: 561 H4504Handler( 562 H323Connection & connection, 563 H450xDispatcher & dispatcher 564 ); 565 566 virtual PBoolean OnReceivedInvoke( 567 int opcode, 568 int invokeId, ///< InvokeId of operation (used in response) 569 int linkedId, ///< InvokeId of associated operation (if any) 570 PASN_OctetString * argument ///< Parameters for the initiate operation 571 ); 572 573 /**Handle an incoming Near-End Call Hold operation 574 */ 575 virtual void OnReceivedLocalCallHold( 576 int linkedId ///< InvokeId of associated operation (if any) 577 ); 578 579 /**Handle an incoming Near-End Call Retrieve operation 580 */ 581 virtual void OnReceivedLocalCallRetrieve( 582 int linkedId ///< InvokeId of associated operation (if any) 583 ); 584 585 /**Handle an incoming Remote Call Hold operation 586 * TBD: Remote hold operations not yet implemented -- dcassel 4/01 587 */ 588 virtual void OnReceivedRemoteCallHold( 589 int linkedId ///< InvokeId of associated operation (if any) 590 ); 591 592 /**Handle an incoming Remote Call Retrieve operation 593 * TBD: Remote hold operations not yet implemented -- dcassel 4/01 594 */ 595 virtual void OnReceivedRemoteCallRetrieve( 596 int linkedId ///< InvokeId of associated operation (if any) 597 ); 598 599 /**Place the call on hold, suspending all media channels (H.450.4) 600 * NOTE: Only Local Hold is implemented so far. 601 */ 602 void HoldCall( 603 PBoolean localHold ///< true for Local Hold, false for Remote Hold 604 ); 605 606 /**Retrieve the call from hold, activating all media channels (H.450.4) 607 * NOTE: Only Local Hold is implemented so far. 608 */ 609 void RetrieveCall(); 610 611 /**Sub-state for call hold. 612 */ 613 enum State { 614 e_ch_Idle, 615 e_ch_NE_Held, 616 e_ch_RE_Requested, 617 e_ch_RE_Held, 618 e_ch_RE_Retrieve_Req 619 }; 620 GetState()621 State GetState() const { return holdState; } 622 623 624 protected: 625 State holdState; // Call Hold state of this connection 626 }; 627 628 629 class H4506Handler : public H450xHandler 630 { 631 PCLASSINFO(H4506Handler, H450xHandler); 632 public: 633 H4506Handler( 634 H323Connection & connection, 635 H450xDispatcher & dispatcher 636 ); 637 638 virtual PBoolean OnReceivedInvoke( 639 int opcode, 640 int invokeId, ///< InvokeId of operation (used in response) 641 int linkedId, ///< InvokeId of associated operation (if any) 642 PASN_OctetString * argument ///< Parameters for the initiate operation 643 ); 644 645 /**Handle an incoming Call Waiting Indication PDU 646 */ 647 virtual void OnReceivedCallWaitingIndication( 648 int linkedId, 649 PASN_OctetString *argument 650 ); 651 652 /**Attach a call waiting APDU to the passed in Alerting PDU. The second paramter is used to 653 indicate to the calling user how many additional users are "camped on" the called user. A 654 value of zero indicates to the calling user that he/she is the only user attempting to reach 655 the busy called user. 656 */ 657 virtual void AttachToAlerting( 658 H323SignalPDU & pdu, 659 unsigned numberOfCallsWaiting = 0 660 ); 661 662 /**Sub-state for call waiting. 663 */ 664 enum State { 665 e_cw_Idle, 666 e_cw_Invoked 667 }; 668 GetState()669 State GetState() const { return cwState; } 670 671 672 protected: 673 State cwState; // Call Waiting state of this connection 674 }; 675 676 677 class H4507Handler : public H450xHandler 678 { 679 PCLASSINFO(H4507Handler, H450xHandler); 680 public: 681 H4507Handler( 682 H323Connection & connection, 683 H450xDispatcher & dispatcher 684 ); 685 686 virtual void AttachToSetup( 687 H323SignalPDU & pdu 688 ); 689 690 virtual void AttachToConnect( 691 H323SignalPDU & pdu 692 ); 693 694 virtual PBoolean OnReceivedInvoke( 695 int opcode, 696 int invokeId, ///< InvokeId of operation (used in response) 697 int linkedId, ///< InvokeId of associated operation (if any) 698 PASN_OctetString * argument ///< Parameters for the initiate operation 699 ); 700 701 PBoolean OnReceiveMWIActivate( 702 PASN_OctetString * argument ///< Parameters for the initiate operation 703 ); 704 705 PBoolean OnReceiveMWIDeactivate( 706 PASN_OctetString * argument ///< Parameters for the initiate operation 707 ); 708 709 PBoolean OnReceiveMWIInterrogate( 710 PASN_OctetString * argument ///< Parameters for the initiate operation 711 ); 712 713 PBoolean OnReceiveMWIInterrogateResult( 714 PASN_OctetString * argument ///< Parameters for the initiate operation 715 ); 716 717 virtual PBoolean OnReceivedReturnResult( 718 X880_ReturnResult & returnResult 719 ); 720 721 virtual PBoolean OnReceivedReturnError( 722 int errorCode, 723 X880_ReturnError & returnError 724 ); 725 726 enum State { 727 e_mwi_Idle, 728 e_mwi_Wait 729 }; 730 GetState()731 State GetState() const { return mwiState; } 732 733 enum Type { 734 e_mwi_typeNone, 735 e_mwi_activate, 736 e_mwi_deactivate, 737 e_mwi_interrogate, 738 }; 739 GetType()740 Type GetType() const { return mwiType; } 741 StartmwiTimer(const PTimeInterval value)742 void StartmwiTimer(const PTimeInterval value) { mwiTimer = value; } 743 744 void StopmwiTimer(); 745 IsmwiTimerRunning()746 PBoolean IsmwiTimerRunning() { return mwiTimer.IsRunning(); } 747 748 749 PDECLARE_NOTIFIER(PTimer, H4507Handler, OnMWITimeOut); 750 751 protected: 752 State mwiState; // Call state of this connection 753 Type mwiType; // Type of MWI action 754 PTimer mwiTimer; // Timer - T1 and T2 755 756 }; 757 758 759 class H45011Handler : public H450xHandler 760 { 761 PCLASSINFO(H45011Handler, H450xHandler); 762 public: 763 H45011Handler( 764 H323Connection & connection, 765 H450xDispatcher & dispatcher 766 ); 767 768 virtual void AttachToSetup( 769 H323SignalPDU & pdu 770 ); 771 772 virtual void AttachToAlerting( 773 H323SignalPDU & pdu 774 ); 775 776 virtual void AttachToConnect( 777 H323SignalPDU & pdu 778 ); 779 780 virtual void AttachToReleaseComplete( 781 H323SignalPDU & pdu 782 ); 783 784 virtual PBoolean OnReceivedInvoke( 785 int opcode, 786 int invokeId, ///< InvokeId of operation (used in response) 787 int linkedId, ///< InvokeId of associated operation (if any) 788 PASN_OctetString * argument ///< Parameters for the initiate operation 789 ); 790 791 /**Handle an incoming Call Intrusion operation 792 */ 793 virtual void OnReceivedCallIntrusionRequest( 794 int linkedId, 795 PASN_OctetString *argument 796 ); 797 798 /**Handle an incoming Call Intrusion GetCIPL operation 799 */ 800 virtual void OnReceivedCallIntrusionGetCIPL( 801 int linkedId, 802 PASN_OctetString *argument 803 ); 804 805 /**Handle an incoming Call Intrusion Isolate operation 806 */ 807 virtual void OnReceivedCallIntrusionIsolate( 808 int linkedId, 809 PASN_OctetString *argument 810 ); 811 812 /**Handle an incoming Call Intrusion Forced Release operation 813 */ 814 virtual PBoolean OnReceivedCallIntrusionForcedRelease( 815 int linkedId, 816 PASN_OctetString *argument 817 ); 818 819 /**Handle an incoming Call Intrusion WOB operation 820 */ 821 virtual void OnReceivedCallIntrusionWOBRequest( 822 int linkedId, 823 PASN_OctetString *argument 824 ); 825 826 /**Handle an incoming Call Intrusion Silent Monitor operation 827 */ 828 virtual void OnReceivedCallIntrusionSilentMonitor( 829 int linkedId, 830 PASN_OctetString *argument 831 ); 832 833 /**Handle an incoming Call Intrusion Notification operation 834 */ 835 virtual void OnReceivedCallIntrusionNotification( 836 int linkedId, 837 PASN_OctetString *argument 838 ); 839 840 /**Handle an incoming Call Intrusion cfb Override operation 841 */ 842 virtual void OnReceivedCfbOverride( 843 int linkedId, 844 PASN_OctetString *argument 845 ); 846 847 /**Handle an incoming Call Intrusion Remote User Alerting operation 848 */ 849 virtual void OnReceivedRemoteUserAlerting( 850 int linkedId, 851 PASN_OctetString *argument 852 ); 853 854 /**Handle an incoming Call Intrusion Call Waiting operation 855 */ 856 virtual void OnReceivedCallWaiting( 857 int linkedId, 858 PASN_OctetString *argument 859 ); 860 861 virtual PBoolean OnReceivedReturnResult( 862 X880_ReturnResult & returnResult 863 ); 864 865 void OnReceivedCIRequestResult(/*X880_ReturnResult & returnResult*/); 866 867 virtual PBoolean OnReceivedReturnError( 868 int errorCode, 869 X880_ReturnError & returnError 870 ); 871 872 PBoolean OnReceivedInvokeReturnError ( 873 int errorCode, 874 const bool timerExpiry = false ///< Flag to indicate expiry 875 ); 876 877 void OnReceivedCIGetCIPLResult( 878 X880_ReturnResult & returnResult 879 ); 880 881 PBoolean OnReceivedGetCIPLReturnError( 882 int errorCode, 883 const bool timerExpiry = false ///< Flag to indicate expiry 884 ); 885 886 void IntrudeCall(int CICL ); 887 888 void AwaitSetupResponse( 889 const PString & token, 890 const PString & identity 891 ); 892 893 PBoolean GetRemoteCallIntrusionProtectionLevel( 894 const PString & intrusionCallToken, 895 unsigned intrusionCICL 896 ); 897 898 void SetIntrusionImpending(); 899 900 void SetForcedReleaseAccepted(); 901 902 void SetIntrusionNotAuthorized(); 903 904 virtual PBoolean OnReceivedReject( 905 int problemType, 906 int problemNumber 907 ); 908 909 /**Sub-state for call intrusion. 910 */ 911 enum State { 912 e_ci_Idle, 913 e_ci_WaitAck, 914 e_ci_GetCIPL, 915 e_ci_OrigInvoked, 916 e_ci_OrigIsolated, 917 e_ci_DestNotify, 918 e_ci_DestInvoked, 919 e_ci_DestIsolated, 920 e_ci_DestWOB, 921 e_ci_IsolationRequest, 922 e_ci_ForcedReleaseRequest, 923 e_ci_WOBRequest 924 }; 925 926 /**What to generate */ 927 enum Generate{ 928 e_ci_gIdle, 929 e_ci_gConferenceRequest, 930 e_ci_gHeldRequest, 931 e_ci_gSilentMonitorRequest, 932 e_ci_gIsolationRequest, 933 e_ci_gForcedReleaseRequest, 934 e_ci_gWOBRequest 935 }; 936 937 /** When to send SS message */ 938 enum SendState{ 939 e_ci_sIdle, 940 e_ci_sAttachToSetup, 941 e_ci_sAttachToAlerting, 942 e_ci_sAttachToConnect, 943 e_ci_sAttachToReleseComplete 944 }; 945 946 /** What to return */ 947 enum ReturnState{ 948 e_ci_rIdle, 949 e_ci_rCallIntrusionImpending, 950 e_ci_rCallIntruded, 951 e_ci_rCallIsolated, 952 e_ci_rCallForceReleased, 953 e_ci_rCallForceReleaseResult, 954 e_ci_rCallIntrusionComplete, 955 e_ci_rCallIntrusionEnd, 956 e_ci_rNotBusy, 957 e_ci_rTempUnavailable, 958 e_ci_rNotAuthorized 959 }; 960 961 /**Get the current call intrusion state. 962 */ GetState()963 State GetState() const { return ciState; } 964 965 /** Start the Call Intrusion Timer using the specified time interval. 966 */ StartciTimer(const PTimeInterval value)967 void StartciTimer(const PTimeInterval value) { ciTimer = value; } 968 969 /** Stop the Call Intrusion Timer 970 */ 971 void StopciTimer(); 972 973 /**Is the Call Intrusion Timer running? 974 */ IsctTimerRunning()975 PBoolean IsctTimerRunning() { return ciTimer.IsRunning(); } 976 977 /**Callback mechanism for Call Intrusion Timers CI-T1, CI-T2, CI-T3 & CI-T4 & CI-T5 & CI-T6 978 */ 979 PDECLARE_NOTIFIER(PTimer, H45011Handler, OnCallIntrudeTimeOut); 980 981 protected: 982 State ciState; // Call state of this connection 983 PTimer ciTimer; // Call Intrusion Timer - Handles all six timers CI-T1 to CI-T6, 984 PString intrudingCallToken; 985 PString intrudingCallIdentity; 986 PString activeCallToken; 987 ReturnState ciReturnState; 988 SendState ciSendState; 989 Generate ciGenerateState; 990 int ciCICL; 991 unsigned intrudingCallCICL; 992 }; 993 994 995 #endif // __OPAL_H450PDU_H 996 997 998 ///////////////////////////////////////////////////////////////////////////// 999