OPAL  Version 3.14.3
h4601.h
Go to the documentation of this file.
1 /*
2  * h4601.h
3  *
4  * Virteos H.460 Implementation for the h323plus Library.
5  *
6  * Virteos is a Trade Mark of ISVO (Asia) Pte Ltd.
7  *
8  * Copyright (c) 2004 ISVO (Asia) Pte Ltd. All Rights Reserved.
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  * Alternatively, the contents of this file may be used under the terms
16  * of the General Public License (the "GNU License"), in which case the
17  * provisions of GNU License are applicable instead of those
18  * above. If you wish to allow use of your version of this file only
19  * under the terms of the GNU License and not to allow others to use
20  * your version of this file under the MPL, indicate your decision by
21  * deleting the provisions above and replace them with the notice and
22  * other provisions required by the GNU License. If you do not delete
23  * the provisions above, a recipient may use your version of this file
24  * under either the MPL or the GNU License."
25  *
26  * Software distributed under the License is distributed on an "AS IS"
27  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
28  * the License for the specific language governing rights and limitations
29  * under the License.
30  *
31  * The Original Code is derived from and used in conjunction with the
32  * OpenH323 Project (www.openh323.org/)
33  *
34  * The Initial Developer of the Original Code is ISVO (Asia) Pte Ltd.
35  *
36  * Contributor(s): Many thanks to Simon Horne.
37  * Robert Jongbloed (robertj@voxlucida.com.au).
38  *
39  * $Revision: 31420 $
40  * $Author: rjongbloed $
41  * $Date: 2014-02-10 11:36:04 +1100 (Mon, 10 Feb 2014) $
42 */
43 
44 #ifndef OPAL_H460_H4601_H
45 #define OPAL_H460_H4601_H
46 
47 #ifdef P_USE_PRAGMA
48 #pragma interface
49 #endif
50 
51 #include <opal_config.h>
52 
53 #if OPAL_H460
54 
55 #include <asn/h225.h>
56 #include <h323/transaddr.h>
57 #include <opal/guid.h>
58 #include <h460/h460.h>
59 #include <ptlib/pluginmgr.h>
60 #include <ptclib/url.h>
61 
62 
63 class H323EndPoint;
64 class H323Connection;
65 class H460_Feature;
66 
67 
69 
79 class H460_FeatureID : public H225_GenericIdentifier
80 {
81  /* Due to some naughty reinterpret_cast<> of H225_GenericIdentifier to
82  H460_FeatureID in various palces, do not add members or do any virtual
83  function overrides in this class! */
84  public:
90 
93  H460_FeatureID(unsigned id);
94 
97  H460_FeatureID(const PASN_ObjectId & id);
98 
101  H460_FeatureID(const PString & id);
102 
105  H460_FeatureID(const H225_GenericIdentifier & id);
107 
113  PString GetOID() const;
114 
117  operator unsigned () const { return (const PASN_Integer &)*this; }
118 
121  operator PString () const { return ((const H225_GloballyUniqueID &)*this).AsString(); }
123 };
124 
125 
127 
132 class H460_FeatureContent : public H225_Content
133 {
134  /* Due to some naughty reinterpret_cast<> of H225_GenericIdentifier to
135  H460_FeatureID in various palces, do not add members or do any virtual
136  function overrides in this class! */
137  public:
143 
147  H460_FeatureContent(const PASN_OctetString & param);
148 
151  H460_FeatureContent(const PString & param);
152 
155  H460_FeatureContent(const PASN_BMPString & param);
156 
159  H460_FeatureContent(bool param);
160 
163  H460_FeatureContent(unsigned param, unsigned len);
164 
168 
171  H460_FeatureContent(const H225_AliasAddress & add);
172 
175  H460_FeatureContent(const PURL & add);
176 
180 
183  H460_FeatureContent(const H225_ArrayOf_EnumeratedParameter & table);
184 
188 
191  H460_FeatureContent(const H460_Feature & nested);
193 };
194 
195 
197 
202 class H460_FeatureParameter : public H225_EnumeratedParameter
203 {
204  /* Due to some naughty reinterpret_cast<> of H225_GenericIdentifier to
205  H460_FeatureID in various palces, do not add members or do any virtual
206  function overrides in this class! */
207  public:
213 
217 
220  H460_FeatureParameter(const H460_FeatureID & id, const H460_FeatureContent & content);
221 
224  H460_FeatureParameter(const H225_EnumeratedParameter & param);
226 
231  const H460_FeatureID & GetID() const { return reinterpret_cast<const H460_FeatureID &>(m_id); }
232 
235  void SetContent(const H460_FeatureContent & content);
237 
240  operator const PASN_OctetString &() const;
241  operator PString() const;
242  operator const PASN_BMPString &() const;
243  operator bool() const;
244  operator unsigned() const;
245  operator const H460_FeatureID &() const;
246  operator const H225_AliasAddress &() const;
247  operator H323TransportAddress() const;
248  operator const H225_ArrayOf_EnumeratedParameter &() const;
249  operator PURL() const;
250  operator OpalGloballyUniqueID() const;
251 
252  H460_FeatureParameter & operator=(const PASN_OctetString & value);
253  H460_FeatureParameter & operator=(const PString & value);
254  H460_FeatureParameter & operator=(const PASN_BMPString & value);
255  H460_FeatureParameter & operator=(bool value);
256  H460_FeatureParameter & operator=(unsigned value);
258  H460_FeatureParameter & operator=(const H225_AliasAddress & value);
260  H460_FeatureParameter & operator=(const H225_ArrayOf_EnumeratedParameter & value);
263 };
264 
265 
267 
271 class H460_FeatureDescriptor : public H225_FeatureDescriptor
272 {
273  /* Due to some naughty reinterpret_cast<> of H225_GenericIdentifier to
274  H460_FeatureID in various palces, do not add members or do any virtual
275  function overrides in this class! */
276  public:
282 
286 
289  H460_FeatureDescriptor(const H225_FeatureDescriptor & descriptor);
291 
294  const H460_FeatureID & GetID() const
295  { return reinterpret_cast<const H460_FeatureID &>(m_id); }
296 
300  const H460_FeatureID & id,
301  const H460_FeatureContent & content = H460_FeatureContent(),
302  bool unique = true
303  );
304 
308  H460_FeatureParameter * param,
309  bool unique = true
310  );
311 
314  void RemoveParameterAt(PINDEX index);
315 
318  void RemoveParameter(const H460_FeatureID & id);
319 
322  void ReplaceParameter(const H460_FeatureID & id, const H460_FeatureContent & content);
323 
326  H460_FeatureParameter & GetParameterAt(PINDEX index) const
327  { return reinterpret_cast<H460_FeatureParameter &>(m_parameters[index]); }
328 
331  PINDEX GetParameterIndex(const H460_FeatureID & id) const;
332 
336 
339  bool GetBooleanParameter(const H460_FeatureID & id) const;
340 
343  bool HasParameter(const H460_FeatureID & id) const;
344 
352  bool IsParameterIsUnique(const H460_FeatureID & id) const;
353 
356  PINDEX GetParameterCount() const
357  { return m_parameters.GetSize(); }
358 
362  PINDEX index
363  ) { return GetParameterAt(index); }
365 };
366 
367 
369 
373 class H460_Feature : public PObject
374 {
375  PCLASSINFO_WITH_CLONE(H460_Feature, PObject);
376  public:
383 
386 
387  P_DECLARE_TRACED_ENUM(Category,
388  Needed,
389  Desired,
390  Supported
391  );
392  Category GetCategory() const { return m_category; }
393  void SetCategory(Category cat) { m_category = cat; }
395 
400  const H460_FeatureID & GetID() const
401  { return m_descriptor.GetID(); }
402 
405  void SetFeatureID(const H460_FeatureID & id) { m_descriptor.m_id = id; }
406 
409  virtual bool Initialise(H323EndPoint & ep, H323Connection * con);
410 
413  virtual bool IsNegotiated() const { return m_supportedByRemote; }
415 
421  const H460_FeatureID & id,
422  const H460_FeatureContent & content = H460_FeatureContent(),
423  bool unique = true
424  ) { return m_descriptor.AddParameter(id, content, unique); }
425 
429  H460_FeatureParameter * param,
430  bool unique = true
431  ) { return m_descriptor.AddParameter(param, unique); }
432 
435  virtual void RemoveParameterAt(
436  PINDEX index
437  ) { m_descriptor.RemoveParameterAt(index); }
438 
441  virtual void RemoveParameter(
442  const H460_FeatureID & id
443  ) { m_descriptor.RemoveParameter(id); }
444 
447  virtual void ReplaceParameter(
448  const H460_FeatureID id,
449  const H460_FeatureContent & content
450  ) { m_descriptor.ReplaceParameter(id, content); }
451 
455  PINDEX index
456  ) { return m_descriptor.GetParameterAt(index); }
457 
461  const H460_FeatureID & id
462  ) { return m_descriptor.GetParameter(id); }
463 
466  virtual bool HasParameter(
467  const H460_FeatureID & id
468  ) { return m_descriptor.HasParameter(id); }
469 
470  // Operators
472  PINDEX index
473  ) { return GetParameter(index); }
474 
478  const H460_FeatureID & id
479  ) { return GetParameter(id); }
480 
483  PINDEX GetParameterCount() const
484  { return m_descriptor.GetParameterCount(); }
486 
491  static PStringList GetFeatureNames(PPluginManager * pluginMgr = NULL);
492 
495  static H460_Feature * CreateFeature(
496  const PString & featurename,
497  PPluginManager * pluginMgr = NULL
498  );
500 
503  /* These are the main calls which can be overridden to
504  allow the various derived features access to the GEF
505  interface.
506  */
507  virtual bool OnSendPDU(H460_MessageType pduType, H460_FeatureDescriptor & pdu);
508  virtual void OnReceivePDU(H460_MessageType pduType, const H460_FeatureDescriptor & pdu);
509 
510  // PDU calls (Used in the H225_RAS Class)
511  virtual bool OnSendGatekeeperRequest(H460_FeatureDescriptor & /*pdu*/) { return false; }
512  virtual bool OnSendGatekeeperConfirm(H460_FeatureDescriptor & /*pdu*/) { return false; }
513  virtual bool OnSendGatekeeperReject(H460_FeatureDescriptor & /*pdu*/) { return false; }
514 
515  virtual void OnReceiveGatekeeperRequest(const H460_FeatureDescriptor & /*pdu*/) { }
516  virtual void OnReceiveGatekeeperConfirm(const H460_FeatureDescriptor & /*pdu*/) { }
517  virtual void OnReceiveGatekeeperReject(const H460_FeatureDescriptor & /*pdu*/) { }
518 
519  virtual bool OnSendRegistrationRequest(H460_FeatureDescriptor & /*pdu*/, bool /*lightweight*/) { return false; }
520  virtual bool OnSendRegistrationConfirm(H460_FeatureDescriptor & /*pdu*/) { return false; }
521  virtual bool OnSendRegistrationReject(H460_FeatureDescriptor & /*pdu*/) { return false; }
522 
523  virtual void OnReceiveRegistrationRequest(const H460_FeatureDescriptor & /*pdu*/) { }
524  virtual void OnReceiveRegistrationConfirm(const H460_FeatureDescriptor & /*pdu*/) { }
525  virtual void OnReceiveRegistrationReject(const H460_FeatureDescriptor & /*pdu*/) { }
526 
527  virtual bool OnSendAdmissionRequest(H460_FeatureDescriptor & /*pdu*/) { return false; }
528  virtual bool OnSendAdmissionConfirm(H460_FeatureDescriptor & /*pdu*/) { return false; }
529  virtual bool OnSendAdmissionReject(H460_FeatureDescriptor & /*pdu*/) { return false; }
530 
531  virtual void OnReceiveAdmissionRequest(const H460_FeatureDescriptor & /*pdu*/) { }
532  virtual void OnReceiveAdmissionConfirm(const H460_FeatureDescriptor & /*pdu*/) { }
533  virtual void OnReceiveAdmissionReject(const H460_FeatureDescriptor & /*pdu*/) { }
534 
535  virtual bool OnSendLocationRequest(H460_FeatureDescriptor & /*pdu*/) { return false; }
536  virtual bool OnSendLocationConfirm(H460_FeatureDescriptor & /*pdu*/) { return false; }
537  virtual bool OnSendLocationReject(H460_FeatureDescriptor & /*pdu*/) { return false; }
538 
539  virtual void OnReceiveLocationRequest(const H460_FeatureDescriptor & /*pdu*/) { }
540  virtual void OnReceiveLocationConfirm(const H460_FeatureDescriptor & /*pdu*/) { }
541  virtual void OnReceiveLocationReject(const H460_FeatureDescriptor & /*pdu*/) { }
542 
543  virtual bool OnSendServiceControlIndication(H460_FeatureDescriptor & /*pdu*/) { return false; }
544  virtual bool OnSendServiceControlResponse(H460_FeatureDescriptor & /*pdu*/) { return false; }
545 
547  virtual void OnReceiveServiceControlResponse(const H460_FeatureDescriptor & /*pdu*/) { }
548 
549  virtual bool OnSendNonStandardMessage(H460_FeatureDescriptor & /*pdu*/) { return false; }
550  virtual void OnReceiveNonStandardMessage(const H460_FeatureDescriptor & /*pdu*/) { }
551 
552  virtual bool OnSendUnregistrationRequest(H460_FeatureDescriptor & /*pdu*/) { return false; }
553  virtual void OnReceiveUnregistrationRequest(const H460_FeatureDescriptor & /*pdu*/) { }
554 
555  virtual bool OnSendEndpoint(H460_FeatureDescriptor & /*pdu*/) { return false; }
556  virtual void OnReceiveEndpoint(const H460_FeatureDescriptor & /*pdu*/) { }
557 
558  virtual bool OnSendInfoRequestMessage(H460_FeatureDescriptor & /*pdu*/) { return false; }
559  virtual void OnReceiveInfoRequestMessage(const H460_FeatureDescriptor & /*pdu*/) { }
560 
561  virtual bool OnSendInfoRequestResponseMessage(H460_FeatureDescriptor & /*pdu*/) { return false; }
563 
564  virtual bool OnSendDisengagementRequestMessage(H460_FeatureDescriptor & /*pdu*/) { return false; }
566 
567  virtual bool OnSendDisengagementConfirmMessage(H460_FeatureDescriptor & /*pdu*/) { return false; }
570 
573  // UUIE Calls (Used in the H323SignalPDU Class)
574  virtual bool OnSendSetup_UUIE(H460_FeatureDescriptor & /*pdu*/) { return false; }
575  virtual void OnReceiveSetup_UUIE(const H460_FeatureDescriptor & /*pdu*/) { }
576 
577  virtual bool OnSendAlerting_UUIE(H460_FeatureDescriptor & /*pdu*/) { return false; }
578  virtual void OnReceiveAlerting_UUIE(const H460_FeatureDescriptor & /*pdu*/) { }
579 
580  virtual bool OnSendCallProceeding_UUIE(H460_FeatureDescriptor & /*pdu*/) { return false; }
581  virtual void OnReceiveCallProceeding_UUIE(const H460_FeatureDescriptor & /*pdu*/) { }
582 
583  virtual bool OnSendCallConnect_UUIE(H460_FeatureDescriptor & /*pdu*/) { return false; }
584  virtual void OnReceiveCallConnect_UUIE(const H460_FeatureDescriptor & /*pdu*/) { }
585 
586  virtual bool OnSendFacility_UUIE(H460_FeatureDescriptor & /*pdu*/) { return false; }
587  virtual void OnReceiveFacility_UUIE(const H460_FeatureDescriptor & /*pdu*/) { }
588 
589  virtual bool OnSendReleaseComplete_UUIE(H460_FeatureDescriptor & /*pdu*/) { return false; }
590  virtual void OnReceiveReleaseComplete_UUIE(const H460_FeatureDescriptor & /*pdu*/) { }
591 
592  virtual bool OnSendUnAllocatedPDU(H460_FeatureDescriptor & /*pdu*/) { return false; }
593  virtual void OnReceivedUnAllocatedPDU(const H460_FeatureDescriptor & /*pdu*/) { }
594 
595  virtual bool OnSendingOLCGenericInformation(unsigned /*sessionID*/, H245_ArrayOf_GenericParameter & /*param*/, bool /*ack*/) { return false; }
596  virtual void OnReceiveOLCGenericInformation(unsigned /*sessionID */, const H245_ArrayOf_GenericParameter & /*param*/, bool /*isAck*/) { }
598 
599  H323EndPoint * GetEndPoint() const { return m_endpoint; }
601 
602  static H460_Feature * FromContext(PObject * context, const H460_FeatureID & id);
603  template <class FEAT> static bool FromContext(PObject * context, FEAT * & feature)
604  {
605  feature = dynamic_cast<FEAT *>(FromContext(context, FEAT::ID()));
606  return feature != NULL;
607  }
608 
609  protected:
610  H460_Feature * GetFeatureOnGk(const H460_FeatureID & id) const;
611 
612  template <class FEAT> bool GetFeatureOnGk(FEAT * & feature, const H460_FeatureID & id = FEAT::ID())
613  {
614  feature = dynamic_cast<FEAT *>(GetFeatureOnGk(id));
615  return feature != NULL;
616  }
617 
618  bool IsFeatureNegotiatedOnGk(const H460_FeatureID & id) const;
619 
620 #if OPAL_H460_NAT
621  PNatMethod * GetNatMethod(const char * methodName) const;
622 
623  template <class METH> bool GetNatMethod(const char * methodName, METH * & natMethod) const
624  {
625  natMethod = dynamic_cast<METH *>(GetNatMethod(methodName));
626  return natMethod != NULL;
627  }
628 #endif // OPAL_H460_NAT
629 
630  Category m_category;
635 };
636 
637 
640 class H460_FeatureSet : public PObject, public map<H460_FeatureID, H460_Feature *>
641 {
642  PCLASSINFO(H460_FeatureSet, PObject);
643  public:
647  H323EndPoint & ep
648  );
650 
651 
654  virtual void LoadFeatureSet(
655  H323Connection * con = NULL
656  );
657 
660  bool AddFeature(H460_Feature * feat);
661 
664  void RemoveFeature(const H460_FeatureID & id);
665 
668  H460_Feature * GetFeature(const H460_FeatureID & id);
669  template <class FEAT> bool GetFeature(FEAT * & feature, const H460_FeatureID & id = FEAT::ID())
670  {
671  feature = dynamic_cast<FEAT *>(GetFeature(id));
672  return feature != NULL;
673  }
674 
677  bool HasFeature(const H460_FeatureID & feat);
678 
682  virtual void OnReceivePDU(
683  H460_MessageType pduType,
684  const H225_FeatureSet & pdu
685  );
686 
690  virtual bool OnSendPDU(
691  H460_MessageType pduType,
692  H225_FeatureSet & pdu
693  );
694 
698 
699  static bool Copy(H225_FeatureSet & fs, const H225_ArrayOf_GenericData & gd);
700  static bool Copy(H225_ArrayOf_GenericData & gd, const H225_FeatureSet & fs);
701 
702  protected:
703  void OnReceivePDU(H460_MessageType pduType, const H225_ArrayOf_FeatureDescriptor & descriptors);
704 
706 };
707 
708 
710 
712 
713 #define H460_FEATURE(name, friendlyName) \
714  PCREATE_PLUGIN(name, H460_Feature, H460_Feature##name, PPlugin_H460_Feature, \
715  virtual const char * GetFriendlyName() const { return friendlyName; } \
716  )
717 
718 
719 #if OPAL_H460_NAT
720  PPLUGIN_STATIC_LOAD(Std18, H460_Feature);
721  PPLUGIN_STATIC_LOAD(Std19, H460_Feature);
722  PPLUGIN_STATIC_LOAD(Std23, H460_Feature);
723  PPLUGIN_STATIC_LOAD(Std24, H460_Feature);
724 #endif
725 
726 
727 #endif // OPAL_H460
728 
729 #endif // OPAL_H460_H4601_H