OPAL  Version 3.14.3
h450pdu.h
Go to the documentation of this file.
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  * $Revision: 29536 $
27  * $Author: rjongbloed $
28  * $Date: 2013-04-19 18:55:15 +1000 (Fri, 19 Apr 2013) $
29  */
30 
31 #ifndef OPAL_H323_H450PDU_H
32 #define OPAL_H323_H450PDU_H
33 
34 #ifdef P_USE_PRAGMA
35 #pragma interface
36 #endif
37 
38 #include <opal_config.h>
39 
40 #if OPAL_H450
41 
42 #include <asn/x880.h>
43 #include <asn/h4501.h>
44 #include <asn/h4502.h>
45 
46 #include <asn/h4507.h>
47 
48 class H323EndPoint;
49 class H323Connection;
51 class H323SignalPDU;
52 
53 class H4501_EndpointAddress;
54 class H4501_InterpretationApdu;
55 
56 
58 
61 class H450ServiceAPDU : public X880_ROS
62 {
63  public:
64  X880_Invoke& BuildInvoke(int invokeId, int operation);
65  X880_ReturnResult& BuildReturnResult(int invokeId);
66  X880_ReturnError& BuildReturnError(int invokeId, int error);
67  X880_Reject& BuildReject(int invokeId);
68 
69  void BuildCallTransferInitiate(int invokeId,
70  const PString & callIdentity,
71  const PString & alias,
72  const H323TransportAddress & address);
73 
74  void BuildCallTransferIdentify(int invokeId);
75  void BuildCallTransferAbandon(int invokeId);
76  void BuildCallTransferSetup(int invokeId,
77  const PString & callIdentity);
78 
79  void BuildCallWaiting(int invokeId, int numCallsWaiting);
80  void BuildMessageWaiting(int invokeId,
81  H4507_H323_MWI_Operations &mwiOp,
82  PASN_Sequence &argument);
83  void BuildInterrogateResult(int invokeId,
84  H4507_MWIInterrogateRes &interrogateResult);
85 
86  void BuildCallIntrusionForcedRelease(int invokeId, int CICL);
87  X880_ReturnResult& BuildCallIntrusionForcedReleaseResult(int invokeId);
89  void BuildCallIntrusionGetCIPL(int invokeId);
90  void BuildCallIntrusionImpending(int invokeId);
91  void BuildCallIntrusionForceRelesed(int invokeId);
92 
94  PBoolean WriteFacilityPDU(
95  H323Connection & connection
96  );
97 
98  static void ParseEndpointAddress(H4501_EndpointAddress & address,
99  PString & party);
100 };
101 
102 
103 class H450xDispatcher;
104 
105 class H450xHandler : public PObject
106 {
107  PCLASSINFO(H450xHandler, PObject);
108  public:
109  H450xHandler(
112  );
113 
114  virtual void AttachToSetup(
115  H323SignalPDU & pdu
116  );
117 
118  virtual void AttachToAlerting(
119  H323SignalPDU & pdu
120  );
121 
122  virtual void AttachToConnect(
123  H323SignalPDU & pdu
124  );
125 
126  virtual void AttachToReleaseComplete(
127  H323SignalPDU & pdu
128  );
129 
130  virtual PBoolean OnReceivedInvoke(
131  int opcode,
132  int invokeId,
133  int linkedId,
134  PASN_OctetString * argument
135  ) = 0;
136 
137  virtual PBoolean OnReceivedReturnResult(
138  X880_ReturnResult & returnResult
139  );
140 
141  virtual PBoolean OnReceivedReturnError(
142  int errorCode,
143  X880_ReturnError & returnError
144  );
145 
146  virtual PBoolean OnReceivedReject(
147  int problemType,
148  int problemNumber
149  );
150 
153  void SendReturnError(int returnError);
154 
155  void SendGeneralReject(int problem);
156 
157  void SendInvokeReject(int problem);
158 
159  void SendReturnResultReject(int problem);
160 
161  void SendReturnErrorReject(int problem);
162 
163  PBoolean DecodeArguments(
164  PASN_OctetString * argString,
165  PASN_Object & argObject,
166  int absentErrorCode
167  );
168 
169  unsigned GetInvokeId() const { return currentInvokeId; }
170 
171 
172  protected:
176  unsigned currentInvokeId;
177 };
178 
179 PARRAY(H450xHandlerArray, H450xHandler);
180 PDICTIONARY(H450xHandlerDict, POrdinalKey, H450xHandler);
181 
182 
183 class H450xDispatcher : public PObject
184 {
185  PCLASSINFO(H450xDispatcher, PObject);
186  public:
189  );
190 
193  void AddOpCode(
194  unsigned opcode,
195  H450xHandler * handler
196  );
197 
198  virtual void AttachToSetup(
199  H323SignalPDU & pdu
200  );
201 
202  virtual void AttachToAlerting(
203  H323SignalPDU & pdu
204  );
205 
206  virtual void AttachToConnect(
207  H323SignalPDU & pdu
208  );
209 
210  virtual void AttachToReleaseComplete(
211  H323SignalPDU & pdu
212  );
213 
216  virtual PBoolean HandlePDU(
217  const H323SignalPDU & pdu
218  );
219 
224  virtual PBoolean OnReceivedInvoke(X880_Invoke& invoke, H4501_InterpretationApdu& interpretation);
225 
231  virtual PBoolean OnReceivedReturnResult(X880_ReturnResult& returnResult);
232 
238  virtual PBoolean OnReceivedReturnError(X880_ReturnError& returnError);
239 
245  virtual PBoolean OnReceivedReject(X880_Reject& reject);
246 
249  void SendReturnError(int invokeId, int returnError);
250 
251  void SendGeneralReject(int invokeId, int problem);
252 
253  void SendInvokeReject(int invokeId, int problem);
254 
255  void SendReturnResultReject(int invokeId, int problem);
256 
257  void SendReturnErrorReject(int invokeId, int problem);
258 
261  unsigned GetNextInvokeId() const { return ++nextInvokeId; }
262 
263  protected:
265  H450xHandlerArray handlers;
266  H450xHandlerDict opcodeHandler;
267  mutable unsigned nextInvokeId; // Next available invoke ID for H450 operations
268 };
269 
270 
272 {
273  PCLASSINFO(H4502Handler, H450xHandler);
274  public:
275  H4502Handler(
278  );
279 
280  virtual void AttachToSetup(
281  H323SignalPDU & pdu
282  );
283 
284  virtual void AttachToAlerting(
285  H323SignalPDU & pdu
286  );
287 
288  virtual void AttachToConnect(
289  H323SignalPDU & pdu
290  );
291 
292  virtual void AttachToReleaseComplete(
293  H323SignalPDU & pdu
294  );
295 
296  virtual PBoolean OnReceivedInvoke(
297  int opcode,
298  int invokeId,
299  int linkedId,
300  PASN_OctetString * argument
301  );
302 
305  virtual void OnReceivedCallTransferIdentify(
306  int linkedId
307  );
308 
311  virtual void OnReceivedCallTransferAbandon(
312  int linkedId
313  );
314 
317  virtual void OnReceivedCallTransferInitiate(
318  int linkedId,
319  PASN_OctetString * argument
320  );
321 
324  virtual void OnReceivedCallTransferSetup(
325  int linkedId,
326  PASN_OctetString * argument
327  );
328 
331  virtual void OnReceivedCallTransferUpdate(
332  int linkedId,
333  PASN_OctetString * argument
334  );
335 
338  virtual void OnReceivedSubaddressTransfer(
339  int linkedId,
340  PASN_OctetString * argument
341  );
342 
345  virtual void OnReceivedCallTransferComplete(
346  int linkedId,
347  PASN_OctetString * argument
348  );
349 
352  virtual void OnReceivedCallTransferActive(
353  int linkedId,
354  PASN_OctetString * argument
355  );
356 
357  virtual PBoolean OnReceivedReturnResult(
358  X880_ReturnResult & returnResult
359  );
360 
366 
373 
378  void OnReceivedIdentifyReturnResult(X880_ReturnResult &returnResult);
379 
380  virtual PBoolean OnReceivedReturnError(
381  int errorCode,
382  X880_ReturnError & returnError
383  );
384 
390  const bool timerExpiry = false
391  );
392 
400  int errorCode,
401  const bool timerExpiry = false
402  );
403 
409  const bool timerExpiry = false
410  );
411 
416  bool TransferCall(
417  const PString & remoteParty,
418  const PString & callIdentity
419  );
420 
426  const PString & primaryCallToken
427  );
428 
432  const PString & callIdentity,
433  H323Connection& incoming
434  );
435 
436  void AwaitSetupResponse(
437  const PString & token,
438  const PString & identity
439  );
440 
443  enum State {
450  };
451 
454  State GetState() const { return ctState; }
455 
465  virtual void onReceivedAdmissionReject(const int returnError);
466 
470  const int returnError
471  );
472 
475  void StartctTimer(const PTimeInterval value) { ctTimer = value; }
476 
479  void StopctTimer();
480 
483  PBoolean IsctTimerRunning() { return ctTimer.IsRunning(); }
484 
487  PDECLARE_NOTIFIER(PTimer, H4502Handler, OnCallTransferTimeOut);
488 
492 
495  void SetAssociatedCallToken(const PString& token) { CallToken = token; }
496 
499  const PString& getTransferringCallToken() const { return transferringCallToken; }
500 
504 
508 
509  protected:
510  PString transferringCallToken; // Stores the call token for the transferring connection (if there is one)
511  PString transferringCallIdentity; // Stores the call identity for the transferring call (if there is one)
512  State ctState; // Call Transfer state of the conneciton
513  PBoolean ctResponseSent; // Has a callTransferSetupReturnResult been sent?
514  PTimer ctTimer; // Call Transfer Timer - Handles all four timers CT-T1,
515  PString CallToken; // Call Token of the associated connection
516  // (used during a consultation transfer).
517  PBoolean consultationTransfer; // Flag used to indicate whether an incoming call is involved in
518  // a transfer through consultation.
519 };
520 
521 
523 {
524  PCLASSINFO(H4504Handler, H450xHandler);
525  public:
526  H4504Handler(
529  );
530 
531  virtual PBoolean OnReceivedInvoke(
532  int opcode,
533  int invokeId,
534  int linkedId,
535  PASN_OctetString * argument
536  );
537 
540  virtual void OnReceivedLocalCallHold(
541  int linkedId
542  );
543 
546  virtual void OnReceivedLocalCallRetrieve(
547  int linkedId
548  );
549 
553  virtual void OnReceivedRemoteCallHold(
554  int linkedId
555  );
556 
560  virtual void OnReceivedRemoteCallRetrieve(
561  int linkedId
562  );
563 
567  bool HoldCall(
568  PBoolean localHold
569  );
570 
574  bool RetrieveCall();
575 
578  enum State {
584  };
585 
586  State GetState() const { return holdState; }
587 
588 
589  protected:
590  State holdState; // Call Hold state of this connection
591 };
592 
593 
595 {
596  PCLASSINFO(H4506Handler, H450xHandler);
597  public:
598  H4506Handler(
601  );
602 
603  virtual PBoolean OnReceivedInvoke(
604  int opcode,
605  int invokeId,
606  int linkedId,
607  PASN_OctetString * argument
608  );
609 
612  virtual void OnReceivedCallWaitingIndication(
613  int linkedId,
614  PASN_OctetString *argument
615  );
616 
622  virtual void AttachToAlerting(
623  H323SignalPDU & pdu,
624  unsigned numberOfCallsWaiting = 0
625  );
626 
629  enum State {
632  };
633 
634  State GetState() const { return cwState; }
635 
636 
637  protected:
638  State cwState; // Call Waiting state of this connection
639 };
640 
645 {
646  PCLASSINFO(H4507Handler, H450xHandler);
647  public:
648  H4507Handler(
651  );
652 
653  virtual PBoolean OnReceivedInvoke(
654  int opcode,
655  int invokeId,
656  int linkedId,
657  PASN_OctetString * argument
658  );
659 
660 
664  virtual void AttachToSetup(H323SignalPDU & setupPDU,
665  H4507_H323_MWI_Operations &mwiOp,
666  PASN_Sequence &argument);
667 
670  virtual void AttachInterrogateResultToPdu(H323SignalPDU & pdu,
671  H4507_MWIInterrogateRes &interrogateResult);
672  virtual void AttachErrorToPdu(H323SignalPDU & pdu,
673  H4507_MessageWaitingIndicationErrors error);
676  enum State {
679  };
680 
681  State GetState() const { return mwiState; }
682 
683 
684  protected:
685  State mwiState; // Message waiting state of this connection
686 };
687 
688 
690 {
691  PCLASSINFO(H45011Handler, H450xHandler);
692  public:
696  );
697 
698  virtual void AttachToSetup(
699  H323SignalPDU & pdu
700  );
701 
702  virtual void AttachToAlerting(
703  H323SignalPDU & pdu
704  );
705 
706  virtual void AttachToConnect(
707  H323SignalPDU & pdu
708  );
709 
710  virtual void AttachToReleaseComplete(
711  H323SignalPDU & pdu
712  );
713 
714  virtual PBoolean OnReceivedInvoke(
715  int opcode,
716  int invokeId,
717  int linkedId,
718  PASN_OctetString * argument
719  );
720 
723  virtual void OnReceivedCallIntrusionRequest(
724  int linkedId,
725  PASN_OctetString *argument
726  );
727 
730  virtual void OnReceivedCallIntrusionGetCIPL(
731  int linkedId,
732  PASN_OctetString *argument
733  );
734 
737  virtual void OnReceivedCallIntrusionIsolate(
738  int linkedId,
739  PASN_OctetString *argument
740  );
741 
744  virtual PBoolean OnReceivedCallIntrusionForcedRelease(
745  int linkedId,
746  PASN_OctetString *argument
747  );
748 
752  int linkedId,
753  PASN_OctetString *argument
754  );
755 
759  int linkedId,
760  PASN_OctetString *argument
761  );
762 
766  int linkedId,
767  PASN_OctetString *argument
768  );
769 
772  virtual void OnReceivedCfbOverride(
773  int linkedId,
774  PASN_OctetString *argument
775  );
776 
779  virtual void OnReceivedRemoteUserAlerting(
780  int linkedId,
781  PASN_OctetString *argument
782  );
783 
786  virtual void OnReceivedCallWaiting(
787  int linkedId,
788  PASN_OctetString *argument
789  );
790 
791  virtual PBoolean OnReceivedReturnResult(
792  X880_ReturnResult & returnResult
793  );
794 
795  void OnReceivedCIRequestResult(/*X880_ReturnResult & returnResult*/);
796 
797  virtual PBoolean OnReceivedReturnError(
798  int errorCode,
799  X880_ReturnError & returnError
800  );
801 
802  PBoolean OnReceivedInvokeReturnError (
803  int errorCode,
804  const bool timerExpiry = false
805  );
806 
808  X880_ReturnResult & returnResult
809  );
810 
812  int errorCode,
813  const bool timerExpiry = false
814  );
815 
816  void IntrudeCall(int CICL );
817 
818  void AwaitSetupResponse(
819  const PString & token,
820  const PString & identity
821  );
822 
824  const PString & intrusionCallToken,
825  unsigned intrusionCICL
826  );
827 
828  void SetIntrusionImpending();
829 
831 
833 
834  virtual PBoolean OnReceivedReject(
835  int problemType,
836  int problemNumber
837  );
838 
841  enum State {
854  };
855 
857  enum Generate{
865  };
866 
868  enum SendState{
874  };
875 
889  };
890 
893  State GetState() const { return ciState; }
894 
897  void StartciTimer(const PTimeInterval value) { ciTimer = value; }
898 
901  void StopciTimer();
902 
905  PBoolean IsctTimerRunning() { return ciTimer.IsRunning(); }
906 
909  PDECLARE_NOTIFIER(PTimer, H45011Handler, OnCallIntrudeTimeOut);
910 
911  protected:
912  State ciState; // Call state of this connection
913  PTimer ciTimer; // Call Intrusion Timer - Handles all six timers CI-T1 to CI-T6,
920  int ciCICL;
922 };
923 
924 
925 #endif // OPAL_H450
926 
927 #endif // OPAL_H323_H450PDU_H
928 
929