OPAL  Version 3.12.9
h4601.h
Go to the documentation of this file.
1 // H4601.h:
2 /*
3  * Virteos H.460 Implementation for the h323plus Library.
4  *
5  * Virteos is a Trade Mark of ISVO (Asia) Pte Ltd.
6  *
7  * Copyright (c) 2004 ISVO (Asia) Pte Ltd. All Rights Reserved.
8  *
9  * The contents of this file are subject to the Mozilla Public License
10  * Version 1.0 (the "License"); you may not use this file except in
11  * compliance with the License. You may obtain a copy of the License at
12  * http://www.mozilla.org/MPL/
13  *
14  * Alternatively, the contents of this file may be used under the terms
15  * of the General Public License (the "GNU License"), in which case the
16  * provisions of GNU License are applicable instead of those
17  * above. If you wish to allow use of your version of this file only
18  * under the terms of the GNU License and not to allow others to use
19  * your version of this file under the MPL, indicate your decision by
20  * deleting the provisions above and replace them with the notice and
21  * other provisions required by the GNU License. If you do not delete
22  * the provisions above, a recipient may use your version of this file
23  * under either the MPL or the GNU License."
24  *
25  * Software distributed under the License is distributed on an "AS IS"
26  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
27  * the License for the specific language governing rights and limitations
28  * under the License.
29  *
30  * The Original Code is derived from and used in conjunction with the
31  * OpenH323 Project (www.openh323.org/)
32  *
33  * The Initial Developer of the Original Code is ISVO (Asia) Pte Ltd.
34  *
35  *
36  * Contributor(s): Many thanks to Simon Horne.
37  *
38  * $Revision: 28069 $
39  * $Author: rjongbloed $
40  * $Date: 2012-07-20 10:45:49 +1000 (Fri, 20 Jul 2012) $
41 */
42 
43 #ifndef OPAL_H460_H4601_H
44 #define OPAL_H460_H4601_H
45 
46 #ifdef P_USE_PRAGMA
47 #pragma interface
48 #endif
49 
50 #include <opal/buildopts.h>
51 
52 #if OPAL_H460
53 
54 #include <asn/h225.h>
55 #include <h323/transaddr.h>
56 #include <opal/guid.h>
57 #include <ptlib/pluginmgr.h>
58 #include <ptclib/url.h>
59 
60 
61 #ifdef _MSC_VER
62 #pragma warning(disable:4100)
63 #endif
64 
66 
67 template<class H225>
68 class H460 : public H225 {
69 public:
70 
76  virtual void OnReceivedPDU(
77  const H225 & /*id*/
78  ) {};
79 
84  virtual PBoolean OnSendingPDU(
85  H225 & /*id*/
86  ) const { return FALSE;};
87 
88 protected:
89 
90 };
91 
92 class OpalOID : public PASN_ObjectId
93 {
94  public:
95  OpalOID();
96  OpalOID(
97  const char * str
98  );
99 
100  OpalOID & operator+(const char *);
101 
102  unsigned GetLastIdentifier()
103  { return (*this)[GetSize()-1]; }
104 };
105 
106 
107 
109 
119 class H460_FeatureID : public H460<H225_GenericIdentifier>
120 {
121 
122  public:
123 
128  H460_FeatureID();
129 
132  H460_FeatureID(unsigned ID);
133 
137 
140  H460_FeatureID(PString ID);
141 
142  H460_FeatureID(H225_GenericIdentifier ID);
144 
149  operator unsigned () const
150  { return ((PASN_Integer *)choice)->GetValue(); };
151 
154  operator OpalOID & ()
155  { return (OpalOID &)*choice; };
156 
159  operator PString () const
160  { return ((H225_GloballyUniqueID *)choice)->AsString(); };
161 
162 
163  PINLINE H460_FeatureID & operator=(unsigned ID);
164 
165  PINLINE H460_FeatureID & operator=(OpalOID ID);
166 
167  PINLINE H460_FeatureID & operator=(PString ID);
168 
171  unsigned GetFeatureType() const { return GetTag(); };
172 
173  PString IDString() const;
175 
178  PObject * Clone() const;
179 
180  PObject::Comparison Compare(const PObject & obj) const;
182 
183 };
184 
185 
187 
192 class H460_Feature;
193 class H460_FeatureTable;
194 class H460_FeatureContent : public H460<H225_Content>
195 {
196 
197  public:
198 
204 
208  H460_FeatureContent(PASN_OctetString & param);
209 
212  H460_FeatureContent(const PString & param);
213 
216  H460_FeatureContent(PASN_BMPString & param);
217 
220  H460_FeatureContent(PBoolean param);
221 
224  H460_FeatureContent(unsigned param, unsigned len);
225 
229 
232  H460_FeatureContent(const H225_AliasAddress & add);
233 
236  H460_FeatureContent(const PURL & add);
237 
241 
244  H460_FeatureContent(const H460_FeatureTable & table);
245 
249 
253 
256  H460_FeatureContent(const H225_Content & param);
257 
259 
262  operator PASN_OctetString () const { return *((PASN_OctetString *)choice); };
263  operator PString () const
264  {
265  switch (GetTag()) {
266  case e_text:
267  return ((PASN_IA5String &)*choice).GetValue();
268  case e_transport:
269  return H323TransportAddress(*(H225_TransportAddress *)choice);
270  default:
271  break;
272  }
273 
274  return PString();
275  };
276 
277  operator PASN_BMPString () const { return *(PASN_BMPString *)choice; };
278  operator PBoolean () const { return *(PASN_Boolean *)choice; };
279 
280  operator unsigned () const
281  {
282  switch (GetTag()) {
283  case e_number8:
284  case e_number16:
285  case e_number32:
286  return *(PASN_Integer*)choice;
287  default:
288  return 0;
289  }
290  }
291 
292  operator H460_FeatureID () const { return *(H225_GenericIdentifier *)choice; };
293  operator H225_AliasAddress () const { return *(H225_AliasAddress *)choice; };
294  operator H323TransportAddress () const { return H323TransportAddress(*(H225_TransportAddress *)choice); };
295  operator H460_FeatureTable *() { return (H460_FeatureTable *)choice; };
296  operator H460_Feature *() { return (H460_Feature *)choice; };
297 
299 };
300 
302 
307 class H460_Feature;
308 class H460_FeatureParameter : public H460<H225_EnumeratedParameter>
309 {
310 
311  public:
312 
318 
321  H460_FeatureParameter(unsigned Identifier);
322 
325  H460_FeatureParameter(const PString & Identifier);
326 
329  H460_FeatureParameter(const OpalOID & Identifier);
330 
333  H460_FeatureParameter(const H225_EnumeratedParameter & param);
334 
339 
344  const H460_FeatureID ID() { return m_id; };
345 
348  void addContent(const H460_FeatureContent & con )
349  { IncludeOptionalField(e_content); m_content = con; };
350 
354  { if (hasContent())
355  delete &m_content;
356  m_content = con; };
357 
360  PBoolean hasContent()
361  { return (GetTag() == e_content); };
362 
364 
365 
368  operator PASN_OctetString &();
369  operator PString &();
370  operator PASN_BMPString &();
371  operator PBoolean ();
372  operator unsigned ();
373  operator H460_FeatureID &();
374  operator H225_AliasAddress &();
375  operator H323TransportAddress ();
376  operator H225_ArrayOf_EnumeratedParameter &();
377  operator PURL &();
378  operator OpalGloballyUniqueID ();
379 
380 
382  const PASN_OctetString & value
383  );
384 
386  const PString & value
387  );
388 
390  const PASN_BMPString & value
391  );
392 
394  const PBoolean & value
395  );
396 
398  const unsigned & value
399  );
400 
402  const H460_FeatureID & value
403  );
404 
406  const H225_AliasAddress & value
407  );
408 
410  const H323TransportAddress & value
411  );
412 
414  const H460_FeatureTable & value
415  );
416 
418  H460_Feature * value
419  );
420 
422  const OpalGloballyUniqueID & value
423  );
424 
425 
426 };
427 
429 
434 class H460_FeatureTable : public H460<H225_ArrayOf_EnumeratedParameter>
435 
436 {
437  public:
438 
444 
447  H460_FeatureTable(const H225_ArrayOf_EnumeratedParameter & Xparams);
449 
452 
458 
463 
467  void AddParameter(H225_EnumeratedParameter & Xparam);
468 
474  H460_FeatureParameter & GetParameter(PINDEX id);
475 
483 
488  PINDEX GetParameterIndex(const H460_FeatureID & id);
489 
494  PBoolean HasParameter(const H460_FeatureID & id);
495 
500  void RemoveParameter(PINDEX id);
501 
506  void RemoveParameter(const H460_FeatureID & id);
507 
512  void ReplaceParameter(const H460_FeatureID & id, const H460_FeatureContent & con);
513 
517  int ParameterCount() { return GetSize(); };
518 
526  PBoolean ParameterIsUnique(const H460_FeatureID & id);
527 
531  PINDEX id
532  ) const { return operator[](id); };
533 
537  PINDEX id
538  );
540 
541 };
542 
544 
548 class H323EndPoint;
549 class H323Connection;
550 class H460_Feature : public H460<H225_FeatureDescriptor>
551 {
552  public:
555 
558  H460_Feature();
559 
562  H460_Feature(unsigned Identifier);
563 
566  H460_Feature(PString Identifier);
567 
570  H460_Feature(OpalOID Indentifier);
571 
574  H460_Feature(const H225_FeatureDescriptor & descriptor);
575 
577 
580 
581  enum {
585  } FeatureCategory;
586 
587 
588  enum {
595  } FeatureInstance;
596 
598 
603  operator unsigned () const { return (H460_FeatureID)m_id; };
604 
607  // operator OpalOID () const { return (H460_FeatureID)m_id; };
608 
611  operator PString () const { return (H460_FeatureID)m_id; };
612 
615  H460_FeatureID GetFeatureID() { return m_id; };
616 
619  void SetFeatureID(const H460_FeatureID & id) { m_id = id; };
620 
623  PString GetFeatureIDAsString();
624 
627  unsigned GetFeatureType() { return ((H460_FeatureID)m_id).GetFeatureType(); };
629 
635 
639 
642  virtual void AddParameter(H460_FeatureParameter * param);
643 
646  virtual void RemoveParameter(PINDEX id);
647 
650  virtual void ReplaceParameter(const H460_FeatureID id, const H460_FeatureContent & con);
651 
655 
659 
662  PBoolean HasFeatureParameter(const H460_FeatureID & id);
663 
666  PBoolean Contains(const H460_FeatureID & id);
667 
671 
675  PINDEX id //* Index position in the collection of the object.
676  ) const { return operator()(id); };
677 
679  PINDEX id
680  );
681 
685  const H460_FeatureID & id //< FeatureID of the object.
686  ) const { return operator()(id); };
687 
689  const H460_FeatureID & id
690  );
691 
695  { return CurrentTable->ParameterCount(); };
696 
700 
703  void SetCurrentTable(H460_FeatureTable & table);
704 
708 
711  void SetDefaultTable();
712 
714 
719  static PStringList GetFeatureNames(PPluginManager * pluginMgr = NULL);
720 
723  static PStringList GetFeatureFriendlyNames(const PString & feature, PPluginManager * pluginMgr = NULL);
724 
727  static H460_Feature * CreateFeature(const PString & featurename,
728  int FeatureType = FeatureBase,
729  PPluginManager * pluginMgr = NULL
730  );
733  static PStringList GetFeatureName() { return PStringList("empty"); };
734 
737  static PStringList GetFeatureFriendlyName() { return PStringList("empty"); };
738 
742  static int GetPurpose() { return FeatureBase; };
743 
746  virtual void AttachEndPoint(H323EndPoint * _ep);
747 
750  virtual void AttachConnection(H323Connection * _con);
751 
753 
756  /* These are the main calls which can be overridden to
757  allow the various derived features access to the GEF
758  interface.
759  */
760  // PDU calls (Used in the H225_RAS Class)
761  virtual PBoolean OnSendGatekeeperRequest(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
762  virtual PBoolean OnSendGatekeeperConfirm(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
763  virtual PBoolean OnSendGatekeeperReject(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
764 
765  virtual void OnReceiveGatekeeperRequest(const H225_FeatureDescriptor & /*pdu*/) {};
766  virtual void OnReceiveGatekeeperConfirm(const H225_FeatureDescriptor & /*pdu*/) {};
767  virtual void OnReceiveGatekeeperReject(const H225_FeatureDescriptor & /*pdu*/) {};
768 
769  virtual PBoolean OnSendRegistrationRequest(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
770  virtual PBoolean OnSendRegistrationConfirm(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
771  virtual PBoolean OnSendRegistrationReject(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
772 
773  virtual void OnReceiveRegistrationRequest(const H225_FeatureDescriptor & /*pdu*/) {};
774  virtual void OnReceiveRegistrationConfirm(const H225_FeatureDescriptor & /*pdu*/) {};
775  virtual void OnReceiveRegistrationReject(const H225_FeatureDescriptor & /*pdu*/) {};
776 
777  virtual PBoolean OnSendAdmissionRequest(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
778  virtual PBoolean OnSendAdmissionConfirm(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
779  virtual PBoolean OnSendAdmissionReject(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
780 
781  virtual void OnReceiveAdmissionRequest(const H225_FeatureDescriptor & /*pdu*/) {};
782  virtual void OnReceiveAdmissionConfirm(const H225_FeatureDescriptor & /*pdu*/) {};
783  virtual void OnReceiveAdmissionReject(const H225_FeatureDescriptor & /*pdu*/) {};
784 
785  virtual PBoolean OnSendLocationRequest(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
786  virtual PBoolean OnSendLocationConfirm(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
787  virtual PBoolean OnSendLocationReject(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
788 
789  virtual void OnReceiveLocationRequest(const H225_FeatureDescriptor & /*pdu*/) {};
790  virtual void OnReceiveLocationConfirm(const H225_FeatureDescriptor & /*pdu*/) {};
791  virtual void OnReceiveLocationReject(const H225_FeatureDescriptor & /*pdu*/) {};
792 
793  virtual PBoolean OnSendServiceControlIndication(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
794  virtual PBoolean OnSendServiceControlResponse(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
795 
796  virtual void OnReceiveServiceControlIndication(const H225_FeatureDescriptor & /*pdu*/) {};
797  virtual void OnReceiveServiceControlResponse(const H225_FeatureDescriptor & /*pdu*/) {};
798 
799  virtual PBoolean OnSendNonStandardMessage(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
800  virtual void OnReceiveNonStandardMessage(const H225_FeatureDescriptor & /*pdu*/) {};
801 
802  virtual PBoolean OnSendUnregistrationRequest(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
803  virtual void OnReceiveUnregistrationRequest(const H225_FeatureDescriptor & /*pdu*/) {};
804 
805  virtual PBoolean OnSendEndpoint(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
806  virtual void OnReceiveEndpoint(const H225_FeatureDescriptor & /*pdu*/) {};
807 
808  virtual PBoolean OnSendInfoRequestMessage(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
809  virtual void OnReceiveInfoRequestMessage(const H225_FeatureDescriptor & /*pdu*/) {};
810 
811  virtual PBoolean OnSendInfoRequestResponseMessage(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
812  virtual void OnReceiveInfoRequestResponseMessage(const H225_FeatureDescriptor & /*pdu*/) {};
813 
814  virtual PBoolean OnSendDisengagementRequestMessage(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
815  virtual void OnReceiveDisengagementRequestMessage(const H225_FeatureDescriptor & /*pdu*/) {};
816 
817  virtual PBoolean OnSendDisengagementConfirmMessage(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
818  virtual void OnReceiveDisengagementConfirmMessage(const H225_FeatureDescriptor & /*pdu*/) {};
820 
823  // UUIE Calls (Used in the H323SignalPDU Class)
824  virtual PBoolean OnSendSetup_UUIE(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
825  virtual void OnReceiveSetup_UUIE(const H225_FeatureDescriptor & /*pdu*/) {};
826 
827  virtual PBoolean OnSendAlerting_UUIE(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
828  virtual void OnReceiveAlerting_UUIE(const H225_FeatureDescriptor & /*pdu*/) {};
829 
830  virtual PBoolean OnSendCallProceeding_UUIE(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
831  virtual void OnReceiveCallProceeding_UUIE(const H225_FeatureDescriptor & /*pdu*/) {};
832 
833  virtual PBoolean OnSendCallConnect_UUIE(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
834  virtual void OnReceiveCallConnect_UUIE(const H225_FeatureDescriptor & /*pdu*/) {};
835 
836  virtual PBoolean OnSendFacility_UUIE(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
837  virtual void OnReceiveFacility_UUIE(const H225_FeatureDescriptor & /*pdu*/) {};
838 
839  virtual PBoolean OnSendReleaseComplete_UUIE(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
840  virtual void OnReceiveReleaseComplete_UUIE(const H225_FeatureDescriptor & /*pdu*/) {};
841 
842  virtual PBoolean OnSendUnAllocatedPDU(H225_FeatureDescriptor & /*pdu*/) { return FALSE; };
843  virtual void OnReceivedUnAllocatedPDU(const H225_FeatureDescriptor & /*pdu*/) {};
844 
846 
849  // H501 Calls (To Be Implemented
850  // H501_MessageCommonInfo
851  // H501_AddressTemplate
852  // H501_ContactInformation
853  // H501_RouteInformation
855 
856  protected:
860 };
861 
863 {
864  PCLASSINFO(H460_FeatureStd, H460_Feature);
865  public:
866 
870 
873  H460_FeatureStd(unsigned Identifier);
875 
880  H460_FeatureParameter & Add(unsigned id, const H460_FeatureContent & con);
881 
884  void Remove(unsigned id);
885 
888  void Replace(unsigned id,const H460_FeatureContent & con);
889 
892  PBoolean HasParameter(unsigned id);
893 
896  H460_FeatureParameter & GetParameter(unsigned id);
898 
902  unsigned id
903  ) { return GetParameter(id); };
904 
905 };
906 
908 {
909  PCLASSINFO(H460_FeatureNonStd, H460_Feature);
910  public:
911 
916  H460_FeatureNonStd(PString Identifier);
918 
923  H460_FeatureParameter & Add(const PString id, const H460_FeatureContent & con);
924 
927  void Remove(const PString & id);
928 
931  void Replace( const PString & id, const H460_FeatureContent & con);
932 
935  PBoolean HasParameter(PString id);
936 
938 
942  PString id
943  ) const { return operator[](id); };
944 
948  PString id
949  );
950 
951 };
952 
954 {
955  PCLASSINFO(H460_FeatureOID, H460_Feature);
956  public:
957 
962  H460_FeatureOID(OpalOID Identifier);
964 
969  H460_FeatureParameter & Add(const PString & id, const H460_FeatureContent & con);
970 
973  void Remove(const PString & id);
974 
977  void Replace(const PString & id, const H460_FeatureContent & con);
978 
981  PBoolean HasParameter(OpalOID id);
982 
985  PBoolean Contains(const PString & id);
986 
989  H460_FeatureParameter & Value(const PString & id);
990 
992 
996  OpalOID id
997  ) const { return operator[](id); };
998 
1002  OpalOID id
1003  );
1004 
1005  protected:
1006  PString GetBase();
1007 
1008 };
1010 // Dictionary/List of Features
1011 
1012 PDICTIONARY(H460_Features, H460_FeatureID , H460_Feature);
1013 
1015 // FeatureSet Main Calling Class
1016 class H323EndPoint;
1017 class H460_FeatureSet : public PObject
1018 {
1019  PCLASSINFO(H460_FeatureSet, PObject);
1020  public:
1021 
1024  H460_FeatureSet();
1025 
1029 
1032  H460_FeatureSet(const H225_FeatureSet & fs);
1033 
1036  H460_FeatureSet(const H225_ArrayOf_GenericData & genericData);
1037 
1041 
1044  virtual PBoolean LoadFeatureSet(int inst = H460_Feature::FeatureBase,
1045  H323Connection * con = NULL);
1046 
1051  PBoolean ProcessFirstPDU(const H225_FeatureSet & fs);
1052 
1055  virtual PBoolean CreateFeatureSet(const H225_FeatureSet & fs);
1056 
1059  virtual PBoolean LoadFeature(const PString & featid);
1060 
1063  PBoolean AddFeature(H460_Feature * feat);
1064 
1067  void RemoveFeature(H460_FeatureID id);
1068 
1071  H460_Feature * GetFeature(const H460_FeatureID & id);
1072 
1075  PBoolean HasFeature(const H460_FeatureID & feat);
1076 
1080  void ReceiveFeature(unsigned id, const H225_FeatureSet & Message);
1081 
1085  PBoolean SendFeature(unsigned id, H225_FeatureSet & Message);
1086 
1089  virtual void AttachEndPoint(H323EndPoint * ep);
1090 
1093  virtual void AttachBaseFeatureSet(H460_FeatureSet * baseSet);
1094 
1098 
1099  protected:
1100 
1101  PBoolean CreateFeatureSetPDU(H225_FeatureSet & fs, unsigned MessageID);
1102 
1103  void ReadFeatureSetPDU(const H225_FeatureSet & fs, unsigned MessageID);
1104 
1105  H460_FeatureID GetFeatureIDPDU(H225_FeatureDescriptor & pdu);
1106 
1107  PBoolean CreateFeaturePDU(H460_Feature & Feat, H225_FeatureDescriptor & pdu, unsigned MessageID);
1108  void ReadFeaturePDU(H460_Feature & Feat, const H225_FeatureDescriptor & pdu, unsigned MessageID);
1109 
1110  PString PTracePDU(PINDEX id) const;
1111 
1112  H460_Features m_features;
1115 };
1116 
1118 
1119 template <class className> class H460PluginServiceDescriptor : public PDevicePluginServiceDescriptor
1120 {
1121  public:
1122  virtual PObject * CreateInstance(int /*userData*/) const { return new className; }
1123  virtual PStringArray GetDeviceNames(int /*userData*/) const { return className::GetFeatureFriendlyName(); }
1124  virtual bool ValidateDeviceName(const PString & deviceName, int userData) const
1125  {
1126  PStringList devices = className::GetFeatureName();
1127  if ((deviceName == devices[0]) &&
1128  (className::GetPurpose() >= userData) &&
1129  (className::GetPurpose() < userData*2)) {
1130 
1131  return TRUE;
1132  } else
1133  return FALSE;
1134  }
1135 };
1136 
1137 #define H460_FEATURE(name) \
1138 static H460PluginServiceDescriptor<H460_Feature##name> H460_Feature##name##_descriptor; \
1139 PCREATE_PLUGIN_STATIC(name, H460_Feature, &H460_Feature##name##_descriptor); \
1140 
1141 
1142 #ifdef _MSC_VER
1143 #pragma warning(disable:4100)
1144 #endif
1145 
1146 #endif // OPAL_H460
1147 
1148 #endif // OPAL_H460_H4601_H