This file is indexed.

/usr/include/opal/h323/h450pdu.h is in libopal-dev 3.10.10~dfsg2-2+b2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
/*
 * h450pdu.h
 *
 * H.450 Helper functions
 *
 * Open H323 Library
 *
 * Copyright (c) 2001 Norwood Systems Pty. Ltd.
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is Open H323 Library.
 *
 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
 *
 * Contributor(s): ______________________________________.
 *
 * $Revision: 24178 $
 * $Author: rjongbloed $
 * $Date: 2010-04-05 19:10:56 -0500 (Mon, 05 Apr 2010) $
 */

#ifndef OPAL_H323_H450PDU_H
#define OPAL_H323_H450PDU_H

#ifdef P_USE_PRAGMA
#pragma interface
#endif

#include <opal/buildopts.h>

#if OPAL_H450

#include <asn/x880.h>
#include <asn/h4501.h>
#include <asn/h4502.h>

#include <asn/h4507.h>

class H323EndPoint;
class H323Connection;
class H323TransportAddress;
class H323SignalPDU;

class H4501_EndpointAddress;
class H4501_InterpretationApdu;


///////////////////////////////////////////////////////////////////////////////

/**PDU definition for H.450 services.
  */
class H450ServiceAPDU : public X880_ROS
{
  public:
    X880_Invoke& BuildInvoke(int invokeId, int operation);
    X880_ReturnResult& BuildReturnResult(int invokeId);
    X880_ReturnError& BuildReturnError(int invokeId, int error);
    X880_Reject& BuildReject(int invokeId);

    void BuildCallTransferInitiate(int invokeId,
                                   const PString & callIdentity,
                                   const PString & alias,
                                   const H323TransportAddress & address);

    void BuildCallTransferIdentify(int invokeId);
    void BuildCallTransferAbandon(int invokeId);
    void BuildCallTransferSetup(int invokeId,
                                const PString & callIdentity);

    void BuildCallWaiting(int invokeId, int numCallsWaiting);
    void BuildMessageWaiting(int invokeId, 
                             H4507_H323_MWI_Operations  &mwiOp, 
                             PASN_Sequence &argument);
    void BuildInterrogateResult(int invokeId, 
                                H4507_MWIInterrogateRes &interrogateResult);
    
    void BuildCallIntrusionForcedRelease(int invokeId, int CICL);
    X880_ReturnResult& BuildCallIntrusionForcedReleaseResult(int invokeId);
    void BuildCallIntrusionForcedReleaseError();
    void BuildCallIntrusionGetCIPL(int invokeId);
    void BuildCallIntrusionImpending(int invokeId);
    void BuildCallIntrusionForceRelesed(int invokeId);

    void AttachSupplementaryServiceAPDU(H323SignalPDU & pdu);
    PBoolean WriteFacilityPDU(
      H323Connection & connection
    );

    static void ParseEndpointAddress(H4501_EndpointAddress & address,
                                     PString & party);
};


class H450xDispatcher;

class H450xHandler : public PObject
{
    PCLASSINFO(H450xHandler, PObject);
  public:
    H450xHandler(
      H323Connection & connection,
      H450xDispatcher & dispatcher
    );

    virtual void AttachToSetup(
      H323SignalPDU & pdu
    );

    virtual void AttachToAlerting(
      H323SignalPDU & pdu
    );

    virtual void AttachToConnect(
      H323SignalPDU & pdu
    );

    virtual void AttachToReleaseComplete(
      H323SignalPDU & pdu
    );

    virtual PBoolean OnReceivedInvoke(
      int opcode,
      int invokeId,                           ///<  InvokeId of operation (used in response)
      int linkedId,                           ///<  InvokeId of associated operation (if any)
      PASN_OctetString * argument             ///<  Parameters for the initiate operation
    ) = 0;

    virtual PBoolean OnReceivedReturnResult(
      X880_ReturnResult & returnResult
    );

    virtual PBoolean OnReceivedReturnError(
      int errorCode,
      X880_ReturnError & returnError
    );

    virtual PBoolean OnReceivedReject(
      int problemType,
      int problemNumber
    );

    /**Send a return error in response to an invoke operation.
     */
    void SendReturnError(int returnError);

    void SendGeneralReject(int problem);

    void SendInvokeReject(int problem);

    void SendReturnResultReject(int problem);

    void SendReturnErrorReject(int problem);

    PBoolean DecodeArguments(
      PASN_OctetString * argString,
      PASN_Object & argObject,
      int absentErrorCode
    );

    unsigned GetInvokeId() const { return currentInvokeId; }


  protected:
    H323EndPoint   & endpoint;
    H323Connection & connection;
    H450xDispatcher & dispatcher;
    unsigned          currentInvokeId;
};

PARRAY(H450xHandlerArray, H450xHandler);
PDICTIONARY(H450xHandlerDict, POrdinalKey, H450xHandler);


class H450xDispatcher : public PObject
{
    PCLASSINFO(H450xDispatcher, PObject);
  public:
    H450xDispatcher(
      H323Connection & connection
    );

    /**Add a handler for the op code.
      */
    void AddOpCode(
      unsigned opcode,
      H450xHandler * handler
    );

    virtual void AttachToSetup(
      H323SignalPDU & pdu
    );

    virtual void AttachToAlerting(
      H323SignalPDU & pdu
    );

    virtual void AttachToConnect(
      H323SignalPDU & pdu
    );

    virtual void AttachToReleaseComplete(
      H323SignalPDU & pdu
    );

    /** Handle the H.450.x Supplementary Service PDU if present in the H225_H323_UU_PDU
     */
    virtual PBoolean HandlePDU(
      const H323SignalPDU & pdu
    );

    /**Handle an incoming X880 Invoke PDU.
       The default behaviour is to attempt to decode the invoke operation
       and call the corresponding OnReceived<Operation> method on the EndPoint.
     */
    virtual PBoolean OnReceivedInvoke(X880_Invoke& invoke, H4501_InterpretationApdu& interpretation);

    /**Handle an incoming X880 Return Result PDU.
       The default behaviour is to attempt to match the return result
       to a previous invoke operation and call the corresponding
       OnReceived<Operation>Success method on the EndPoint.
     */
    virtual PBoolean OnReceivedReturnResult(X880_ReturnResult& returnResult);

    /**Handle an incoming X880 Return Error PDU.
       The default behaviour is to attempt to match the return error
       to a previous invoke operation and call the corresponding
       OnReceived<Operation>Error method on the EndPoint.
     */
    virtual PBoolean OnReceivedReturnError(X880_ReturnError& returnError);

    /**Handle an incoming X880 Reject PDU.
       The default behaviour is to attempt to match the reject
       to a previous invoke, return result or return error operation
       and call OnReceived<Operation>Reject method on the EndPoint.
     */
    virtual PBoolean OnReceivedReject(X880_Reject& reject);

    /**Send a return error in response to an invoke operation.
     */
    void SendReturnError(int invokeId, int returnError);

    void SendGeneralReject(int invokeId, int problem);

    void SendInvokeReject(int invokeId, int problem);

    void SendReturnResultReject(int invokeId, int problem);

    void SendReturnErrorReject(int invokeId, int problem);

    /**Get the next available invoke Id for H450 operations
     */
    unsigned GetNextInvokeId() const { return ++nextInvokeId; }

  protected:
    H323Connection & connection;
    H450xHandlerArray handlers;
    H450xHandlerDict  opcodeHandler;
    mutable unsigned  nextInvokeId;             // Next available invoke ID for H450 operations
};


class H4502Handler : public H450xHandler
{
    PCLASSINFO(H4502Handler, H450xHandler);
  public:
    H4502Handler(
      H323Connection & connection,
      H450xDispatcher & dispatcher
    );

    virtual void AttachToSetup(
      H323SignalPDU & pdu
    );

    virtual void AttachToAlerting(
      H323SignalPDU & pdu
    );

    virtual void AttachToConnect(
      H323SignalPDU & pdu
    );

    virtual void AttachToReleaseComplete(
      H323SignalPDU & pdu
    );

    virtual PBoolean OnReceivedInvoke(
      int opcode,
      int invokeId,                           ///<  InvokeId of operation (used in response)
      int linkedId,                           ///<  InvokeId of associated operation (if any)
      PASN_OctetString * argument             ///<  Parameters for the initiate operation
    );

    /**Handle an incoming Call Transfer Identify operation.
     */
    virtual void OnReceivedCallTransferIdentify(
      int linkedId                            ///<  InvokeId of associated operation (if any)
    );

    /**Handle an incoming Call Transfer Abandon operation.
     */
    virtual void OnReceivedCallTransferAbandon(
      int linkedId                            ///<  InvokeId of associated operation (if any)
    );

    /**Handle an incoming Call Transfer Initiate operation.
     */
    virtual void OnReceivedCallTransferInitiate(
      int linkedId,                           ///<  InvokeId of associated operation (if any)
      PASN_OctetString * argument             ///<  Parameters for the initiate operation
    );

    /**Handle an incoming Call Transfer Setup operation.
     */
    virtual void OnReceivedCallTransferSetup(
      int linkedId,                           ///<  InvokeId of associated operation (if any)
      PASN_OctetString * argument             ///<  Parameters for the setup operation
    );

    /**Handle an incoming Call Transfer Update operation.
     */
    virtual void OnReceivedCallTransferUpdate(
      int linkedId,                           ///<  InvokeId of associated operation (if any)
      PASN_OctetString * argument             ///<  Parameters for the update operation
    );

    /**Handle an incoming Subaddress Transfer operation.
     */
    virtual void OnReceivedSubaddressTransfer(
      int linkedId,                           ///<  InvokeId of associated operation (if any)
      PASN_OctetString * argument             ///<  Parameters for the subaddress transfer operation
    );

    /**Handle an incoming Call Transfer Complete operation.
     */
    virtual void OnReceivedCallTransferComplete(
      int linkedId,                           ///<  InvokeId of associated operation (if any)
      PASN_OctetString * argument             ///<  Parameters for the complete operation
    );

    /**Handle an incoming Call Transfer Active operation.
     */
    virtual void OnReceivedCallTransferActive(
      int linkedId,                           ///<  InvokeId of associated operation (if any)
      PASN_OctetString * argument             ///<  Parameters for the active operation
    );

    virtual PBoolean OnReceivedReturnResult(
      X880_ReturnResult & returnResult
    );

    /**Handle the reception of a callTransferInitiate returnResult when we are in call transfer state 
       e_ctAwaitInitiateResponse.  Note this is an internal function and it is not expected an 
       application would use it. 
     */
    void OnReceivedInitiateReturnResult();
    
    /**Handle the reception of a callTransferSetup returnResult when we are in call transfer state 
       e_ctAwaitSetupResponse.  This funtion exists to handle the case when the transferred-to
       endpoint does not support H.450.2.  Note this is an internal function and it is not expected an 
       application would use it.
     */
    void OnReceivedSetupReturnResult();

    /**Handle the reception of a callTransferIdentify returnResult when we are in call transfer state 
       e_ctAwaitIdentifyResponse.  Note this is an internal function and it is not expected an 
       application would use it.
     */
    void OnReceivedIdentifyReturnResult(X880_ReturnResult &returnResult);

    virtual PBoolean OnReceivedReturnError(
      int errorCode,
      X880_ReturnError & returnError
    );

    /**Handle the reception of a callTransferInitiate returnError or expiry of Call Transfer Timer CT-T3 
       when we are in call transfer state e_ctAwaitInitiateResponse.  Note this is an internal function 
       and it is not expected an application would use it. 
     */
    void OnReceivedInitiateReturnError(
      const bool timerExpiry = false ///<  Flag to indicate expiry
    );

    /**Handle the reception of a callTransferSetup returnError or expiry of Call Transfer Timer CT-T4 
       when we are in call transfer state e_ctAwaitSetupResponse.  This funtion also additionally handles 
       the case when the transferred-to endpoint does not support H.450.2 and has rejected the incoming 
       call request.  Note this is an internal function and it is not expected an application would use 
       it.
     */
    void OnReceivedSetupReturnError(
      int errorCode,
      const bool timerExpiry = false ///<  Flag to indicate expiry
    );

    /**Handle the reception of a callTransferIdentify returnError or expiry of Call Transfer Timer CT-T1
       when we are in call transfer state e_ctAwaitIdentifyResponse.  Note this is an internal function and it is not expected an 
       application would use it.
     */
    void OnReceivedIdentifyReturnError(
      const bool timerExpiry = false ///<  Flag to indicate expiry
    );

    /**Initiate the transfer of an existing call (connection) to a new remote party
       using H.450.2.  This sends a Call Transfer Initiate Invoke message from the
       A-Party (transferring endpoint) to the B-Party (transferred endpoint).
     */
    bool TransferCall(
      const PString & remoteParty,   ///<  Remote party to transfer the existing call to
      const PString & callIdentity   ///<  Call Identity of secondary call if present  
    );

    /**Transfer the call through consultation so the remote party in the primary call is connected to
       the called party in the second call using H.450.2.  This sends a Call Transfer Identify Invoke 
       message from the A-Party (transferring endpoint) to the C-Party (transferred-to endpoint).
     */
    void ConsultationTransfer(
      const PString & primaryCallToken   ///<  Primary call
    );

    /**Handle the reception of a callTransferSetupInvoke APDU whilst a secondary call exists.
     */
    void HandleConsultationTransfer(
      const PString & callIdentity,  ///<  Call Identity of secondary call
      H323Connection& incoming       ///<  New incoming connection
    );

    void AwaitSetupResponse(
      const PString & token,
      const PString & identity
    );

    /**Sub-state for call transfer.
      */
    enum State {
      e_ctIdle,
      e_ctAwaitIdentifyResponse,
      e_ctAwaitInitiateResponse,
      e_ctAwaitSetupResponse,
      e_ctAwaitSetup,
      e_ctAwaitConnect
    };

    /**Get the current call transfer state.
     */
    State GetState() const { return ctState; }

    /**Handle the reception of an Admission Reject during a pending call
       transfer operation at the transferred endpoint. If the call transfer
       state of the current connection is e_ctAwaitSetupResponse, the stack
       attempts to find the existing connection between the transferred and
       transferring endpoints and inform this connection that a
       callTransferInitiateReturnError PDU needs to be sent.  No action is
       taken if the current connection is not in call transfer state
       e_ctAwaitSetupResponse.
     */
    virtual void onReceivedAdmissionReject(const int returnError);

    /**Handle the failure of a call transfer operation.
      */
    void HandleCallTransferFailure(
      const int returnError    ///<  failure reason
    );

    /** Start the Call Transfer Timer using the specified time interval.
     */
    void StartctTimer(const PTimeInterval value) { ctTimer = value; }

    /** Stop the Call Transfer Timer
     */
    void StopctTimer();

    /**Is the Call Transfer Timer running?
     */
    PBoolean IsctTimerRunning() { return ctTimer.IsRunning(); }

    /**Callback mechanism for Call Transfer Timers CT-T1, CT-T2, CT-T3 & CT-T4
     */
    PDECLARE_NOTIFIER(PTimer, H4502Handler, OnCallTransferTimeOut);

    /**Get the connection assoicated with this H4502Handler.
     */
    const H323Connection& getAssociatedConnection() const { return connection; }

    /**Set the associated callToken.
     */
    void SetAssociatedCallToken(const PString& token) { CallToken = token; }

    /**Get the transferringCallToken member
     */
    const PString& getTransferringCallToken() const { return transferringCallToken; }

    /**Set the 'consultationTransfer' member to true (indicating a successful transfer)
     */
    void SetConsultationTransferSuccess() { consultationTransfer = true; }

    /**Was the transfer through consultation successful.
     */
    PBoolean isConsultationTransferSuccess() { return consultationTransfer; }

  protected:
    PString transferringCallToken;    // Stores the call token for the transferring connection (if there is one)
    PString transferringCallIdentity; // Stores the call identity for the transferring call (if there is one)
    State   ctState;                  // Call Transfer state of the conneciton
    PBoolean    ctResponseSent;           // Has a callTransferSetupReturnResult been sent?
    PTimer  ctTimer;                  // Call Transfer Timer - Handles all four timers CT-T1,
    PString CallToken;                // Call Token of the associated connection 
                                      // (used during a consultation transfer).
    PBoolean consultationTransfer;        // Flag used to indicate whether an incoming call is involved in
                                      // a transfer through consultation.
};


class H4504Handler : public H450xHandler
{
    PCLASSINFO(H4504Handler, H450xHandler);
  public:
    H4504Handler(
      H323Connection & connection,
      H450xDispatcher & dispatcher
    );

    virtual PBoolean OnReceivedInvoke(
      int opcode,
      int invokeId,                           ///<  InvokeId of operation (used in response)
      int linkedId,                           ///<  InvokeId of associated operation (if any)
      PASN_OctetString * argument             ///<  Parameters for the initiate operation
    );

    /**Handle an incoming Near-End Call Hold operation
    */
    virtual void OnReceivedLocalCallHold(
      int linkedId                            ///<  InvokeId of associated operation (if any)
    );

    /**Handle an incoming Near-End Call Retrieve operation
    */
    virtual void OnReceivedLocalCallRetrieve(
      int linkedId                            ///<  InvokeId of associated operation (if any)
    );

    /**Handle an incoming Remote Call Hold operation
    * TBD: Remote hold operations not yet implemented -- dcassel 4/01
    */
    virtual void OnReceivedRemoteCallHold(
      int linkedId                            ///<  InvokeId of associated operation (if any)
    );

    /**Handle an incoming Remote Call Retrieve operation
    * TBD: Remote hold operations not yet implemented -- dcassel 4/01
    */
    virtual void OnReceivedRemoteCallRetrieve(
      int linkedId                            ///<  InvokeId of associated operation (if any)
    );

    /**Place the call on hold, suspending all media channels (H.450.4)
    * NOTE: Only Local Hold is implemented so far. 
    */
    bool HoldCall(
      PBoolean localHold   ///<  true for Local Hold, false for Remote Hold
    );

    /**Retrieve the call from hold, activating all media channels (H.450.4)
    * NOTE: Only Local Hold is implemented so far. 
    */
    bool RetrieveCall();

    /**Sub-state for call hold.
      */
    enum State {
      e_ch_Idle,
      e_ch_NE_Held,
      e_ch_RE_Requested,
      e_ch_RE_Held,
      e_ch_RE_Retrieve_Req
    };

    State GetState() const { return holdState; }


  protected:
    State holdState;  // Call Hold state of this connection
};


class H4506Handler : public H450xHandler
{
    PCLASSINFO(H4506Handler, H450xHandler);
  public:
    H4506Handler(
      H323Connection & connection,
      H450xDispatcher & dispatcher
    );

    virtual PBoolean OnReceivedInvoke(
      int opcode,
      int invokeId,                           ///<  InvokeId of operation (used in response)
      int linkedId,                           ///<  InvokeId of associated operation (if any)
      PASN_OctetString * argument             ///<  Parameters for the initiate operation
    );

    /**Handle an incoming Call Waiting Indication PDU
    */
    virtual void OnReceivedCallWaitingIndication(
      int linkedId,
      PASN_OctetString *argument
    );

    /**Attach a call waiting APDU to the passed in Alerting PDU.  The second paramter is used to
       indicate to the calling user how many additional users are "camped on" the called user.  A
       value of zero indicates to the calling user that he/she is the only user attempting to reach
       the busy called user.
    */
    virtual void AttachToAlerting(
      H323SignalPDU & pdu,
      unsigned numberOfCallsWaiting = 0
    );

    /**Sub-state for call waiting.
      */
    enum State {
      e_cw_Idle,
      e_cw_Invoked
    };

    State GetState() const { return cwState; }


  protected:
    State cwState;  // Call Waiting state of this connection
};

/**
 * @class H4507Handler Message Waiting
 */
class H4507Handler : public H450xHandler
{
    PCLASSINFO(H4507Handler, H450xHandler);
  public:
    H4507Handler(
      H323Connection & connection,
      H450xDispatcher & dispatcher
    );

    virtual PBoolean OnReceivedInvoke(
      int opcode,
      int invokeId,                           /// InvokeId of operation (used in response)
      int linkedId,                           /// InvokeId of associated operation (if any)
      PASN_OctetString * argument             /// Parameters for the initiate operation
    );
    
    
    /**Attach a message waiting APDU to the passed in Setup PDU. 
      */

    virtual void AttachToSetup(H323SignalPDU & setupPDU,
                               H4507_H323_MWI_Operations  &mwiOp, 
                               PASN_Sequence &argument);
    
    /**Attach a message waiting Interrogate return result APDU to the passed PDU. 
     */    
    virtual void AttachInterrogateResultToPdu(H323SignalPDU & pdu,
                                              H4507_MWIInterrogateRes &interrogateResult);
    virtual void AttachErrorToPdu(H323SignalPDU & pdu,
                                        H4507_MessageWaitingIndicationErrors error);
    /**Sub-state for message waiting.
      */
    enum State {
      e_mwi_Idle,
      e_mwi_Invoked
    };

    State GetState() const { return mwiState; }


  protected:
    State mwiState;  // Message waiting state of this connection
};


class H45011Handler : public H450xHandler
{
  PCLASSINFO(H45011Handler, H450xHandler);
  public:
    H45011Handler(
      H323Connection & connection,
      H450xDispatcher & dispatcher
    );

    virtual void AttachToSetup(
      H323SignalPDU & pdu
    );

    virtual void AttachToAlerting(
      H323SignalPDU & pdu
    );

    virtual void AttachToConnect(
      H323SignalPDU & pdu
    );

    virtual void AttachToReleaseComplete(
      H323SignalPDU & pdu
    );

    virtual PBoolean OnReceivedInvoke(
      int opcode,
      int invokeId,                           ///<  InvokeId of operation (used in response)
      int linkedId,                           ///<  InvokeId of associated operation (if any)
      PASN_OctetString * argument             ///<  Parameters for the initiate operation
    );

    /**Handle an incoming Call Intrusion operation
    */
    virtual void OnReceivedCallIntrusionRequest(
      int linkedId,
      PASN_OctetString *argument
    );

    /**Handle an incoming Call Intrusion GetCIPL operation
    */
    virtual void OnReceivedCallIntrusionGetCIPL(
      int linkedId,
      PASN_OctetString *argument
    );

    /**Handle an incoming Call Intrusion Isolate operation
    */
    virtual void OnReceivedCallIntrusionIsolate(
      int linkedId,
      PASN_OctetString *argument
    );

    /**Handle an incoming Call Intrusion Forced Release operation
    */
    virtual PBoolean OnReceivedCallIntrusionForcedRelease(
      int linkedId,
      PASN_OctetString *argument
    );

    /**Handle an incoming Call Intrusion WOB operation
    */
    virtual void OnReceivedCallIntrusionWOBRequest(
      int linkedId,
      PASN_OctetString *argument
    );

    /**Handle an incoming Call Intrusion Silent Monitor operation
    */
    virtual void OnReceivedCallIntrusionSilentMonitor(
      int linkedId,
      PASN_OctetString *argument
    );

    /**Handle an incoming Call Intrusion Notification operation
    */
    virtual void OnReceivedCallIntrusionNotification(
      int linkedId,
      PASN_OctetString *argument
    );

    /**Handle an incoming Call Intrusion cfb Override operation
    */
    virtual void OnReceivedCfbOverride(
      int linkedId,
      PASN_OctetString *argument
    );

    /**Handle an incoming Call Intrusion Remote User Alerting operation
    */
    virtual void OnReceivedRemoteUserAlerting(
      int linkedId,
      PASN_OctetString *argument
    );

    /**Handle an incoming Call Intrusion Call Waiting operation
    */
    virtual void OnReceivedCallWaiting(
      int linkedId,
      PASN_OctetString *argument
    );

    virtual PBoolean OnReceivedReturnResult(
      X880_ReturnResult & returnResult
    );

    void OnReceivedCIRequestResult(/*X880_ReturnResult & returnResult*/);

    virtual PBoolean OnReceivedReturnError(
      int errorCode,
      X880_ReturnError & returnError
    );

    PBoolean OnReceivedInvokeReturnError (
      int errorCode,
      const bool timerExpiry = false ///<  Flag to indicate expiry
    );

    void OnReceivedCIGetCIPLResult(
      X880_ReturnResult & returnResult
    );

    PBoolean OnReceivedGetCIPLReturnError(
      int errorCode,
      const bool timerExpiry = false ///<  Flag to indicate expiry
    );

    void IntrudeCall(int CICL );

    void AwaitSetupResponse(
      const PString & token,
      const PString & identity
    );

    PBoolean GetRemoteCallIntrusionProtectionLevel(
      const PString & intrusionCallToken,
      unsigned intrusionCICL
    );

    void SetIntrusionImpending();

    void SetForcedReleaseAccepted();

    void SetIntrusionNotAuthorized();

    virtual PBoolean OnReceivedReject(
      int problemType,
      int problemNumber
    );

    /**Sub-state for call intrusion.
      */
    enum State {
      e_ci_Idle,
      e_ci_WaitAck,
      e_ci_GetCIPL,
      e_ci_OrigInvoked,
      e_ci_OrigIsolated,
      e_ci_DestNotify,
      e_ci_DestInvoked,
      e_ci_DestIsolated,
      e_ci_DestWOB,
      e_ci_IsolationRequest,
      e_ci_ForcedReleaseRequest,
      e_ci_WOBRequest
    };

    /**What to generate */
    enum Generate{
      e_ci_gIdle,
      e_ci_gConferenceRequest,
      e_ci_gHeldRequest,
      e_ci_gSilentMonitorRequest,
      e_ci_gIsolationRequest,
      e_ci_gForcedReleaseRequest,
      e_ci_gWOBRequest
    };

    /** When to send SS message */
    enum SendState{
      e_ci_sIdle,
      e_ci_sAttachToSetup,
      e_ci_sAttachToAlerting,
      e_ci_sAttachToConnect,
      e_ci_sAttachToReleseComplete
    };

    /** What to return */
    enum ReturnState{
      e_ci_rIdle,
      e_ci_rCallIntrusionImpending,
      e_ci_rCallIntruded,
      e_ci_rCallIsolated,
      e_ci_rCallForceReleased,
      e_ci_rCallForceReleaseResult,
      e_ci_rCallIntrusionComplete,
      e_ci_rCallIntrusionEnd,
      e_ci_rNotBusy,
      e_ci_rTempUnavailable,
      e_ci_rNotAuthorized
    };
    
    /**Get the current call intrusion state.
     */
    State GetState() const { return ciState; }

    /** Start the Call Intrusion Timer using the specified time interval.
     */
    void StartciTimer(const PTimeInterval value) { ciTimer = value; }

    /** Stop the Call Intrusion Timer
     */
    void StopciTimer();

    /**Is the Call Intrusion Timer running?
     */
    PBoolean IsctTimerRunning() { return ciTimer.IsRunning(); }

    /**Callback mechanism for Call Intrusion Timers CI-T1, CI-T2, CI-T3 & CI-T4 & CI-T5 & CI-T6
     */
    PDECLARE_NOTIFIER(PTimer, H45011Handler, OnCallIntrudeTimeOut);

  protected:
    State       ciState;               // Call state of this connection
    PTimer      ciTimer;               // Call Intrusion Timer - Handles all six timers CI-T1 to CI-T6,
    PString     intrudingCallToken;
    PString     intrudingCallIdentity;
    PString     activeCallToken;
    ReturnState ciReturnState;
    SendState   ciSendState;
    Generate    ciGenerateState;
    int         ciCICL;
    unsigned    intrudingCallCICL;
};


#endif // OPAL_H450

#endif // OPAL_H323_H450PDU_H


/////////////////////////////////////////////////////////////////////////////