1 // H4601.cxx: implementation of the H460 class.
3 * Virteos H.460 Implementation for the OpenH323 Project.
5 * Virteos is a Trade Mark of ISVO (Asia) Pte Ltd.
7 * Copyright (c) 2004 ISVO (Asia) Pte Ltd. All Rights Reserved.
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/
14 * Software distributed under the License is distributed on an "AS IS"
15 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16 * the License for the specific language governing rights and limitations
19 * The Original Code is derived from and used in conjunction with the
20 * OpenH323 Project (www.openh323.org/)
22 * The Initial Developer of the Original Code is ISVO (Asia) Pte Ltd.
25 * Contributor(s): ______________________________________.
28 * Revision 1.17 2006/10/10 13:56:41 csoutheren
29 * Fix problem with H.460 compilation
31 * Revision 1.16 2006/09/20 07:41:59 shorne
32 * some more updates and fixes
34 * Revision 1.15 2006/08/10 04:05:03 csoutheren
35 * Apply 1537305 - Fix compile problems on gcc 4.1
36 * Thanks to Stanislav Brabec
38 * Revision 1.14 2006/07/01 05:31:03 shorne
39 * added building featureset from generic data field
41 * Revision 1.13 2006/06/15 15:37:20 shorne
44 * Revision 1.12 2006/06/11 00:17:43 csoutheren
45 * Added pragma for old gcc compilers
47 * Revision 1.11 2006/06/09 06:30:12 csoutheren
48 * Remove compile warning and errors with gcc
50 * Revision 1.10 2006/06/08 13:26:16 shorne
51 * Resyn Opal and OpenH323 versions
53 * Revision 1.9 2006/06/08 11:50:06 shorne
54 * Fix for compiling under linux
56 * Revision 1.8 2006/05/30 17:20:46 shorne
57 * revert part of last change and alter function call
59 * Revision 1.7 2006/05/30 11:16:52 hfriederich
60 * Fix compiler errors and warning for gcc4
62 * Revision 1.6 2006/05/27 03:28:22 shorne
63 * Added UnAllocated Message Type Fix compile error on Linux.
71 #pragma implementation "h4601.h"
74 #include <ptlib/pluginmgr.h>
85 OpalOID::OpalOID(const char * str
)
90 H460_FeatureID::H460_FeatureID()
92 SetTag(H225_GenericIdentifier::e_standard
);
93 PASN_Integer
& val
= *this;
97 H460_FeatureID::H460_FeatureID(unsigned ID
)
99 SetTag(H225_GenericIdentifier::e_standard
);
100 PASN_Integer
& val
= *this;
104 H460_FeatureID::H460_FeatureID(OpalOID ID
)
106 SetTag(H225_GenericIdentifier::e_oid
);
107 PASN_ObjectId
& val
= *this;
111 H460_FeatureID::H460_FeatureID(PString ID
)
113 SetTag(H225_GenericIdentifier::e_nonStandard
);
114 H225_GloballyUniqueID
& val
= *this;
118 H460_FeatureID::H460_FeatureID(H225_GenericIdentifier ID
)
121 H225_GenericIdentifier
& val
= *this;
125 PObject
* H460_FeatureID::Clone() const
127 return new H460_FeatureID(*this);
130 PObject::Comparison
H460_FeatureID::Compare(const PObject
& obj
) const
132 PAssert(PIsDescendant(&obj
, H460_FeatureID
), PInvalidCast
);
134 const H460_FeatureID
& id
= (const H460_FeatureID
&)obj
;
136 if (id
.IDString() == IDString())
143 PINLINE H460_FeatureID
& H460_FeatureID::operator=(unsigned ID
)
145 SetTag(H225_GenericIdentifier::e_standard
);
146 PASN_Integer
& val
= *this;
151 PINLINE H460_FeatureID
& H460_FeatureID::operator=(OpalOID ID
)
153 SetTag(H225_GenericIdentifier::e_oid
);
154 PASN_ObjectId
& val
= *this;
155 val
.SetValue(ID
.AsString());
159 PINLINE H460_FeatureID
& H460_FeatureID::operator=(PString ID
)
161 SetTag(H225_GenericIdentifier::e_nonStandard
);
162 H225_GloballyUniqueID
& val
= *this;
167 PString
H460_FeatureID::IDString() const
169 if (GetFeatureType() == H225_GenericIdentifier::e_standard
) {
170 const PASN_Integer
& jint
= *this;
171 return "Std " + PString(jint
);
174 if (GetFeatureType() == H225_GenericIdentifier::e_oid
) {
175 const PASN_ObjectId
& obj
= *this;
176 return "OID " + obj
.AsString();
179 if (GetFeatureType() == H225_GenericIdentifier::e_nonStandard
) {
180 const H225_GloballyUniqueID
& gui
= *this;
181 return "NonStd " + gui
.AsString();
184 return PString("unknown");
187 //////////////////////////////////////////////////////////////////////
188 H460_FeatureContent::H460_FeatureContent()
193 H460_FeatureContent::H460_FeatureContent(PASN_OctetString
& param
)
195 SetTag(H225_Content::e_raw
);
196 PASN_OctetString
& val
= *this;
200 H460_FeatureContent::H460_FeatureContent(const PString
& param
)
202 SetTag(H225_Content::e_text
);
203 PASN_IA5String
& val
= *this;
207 H460_FeatureContent::H460_FeatureContent(PASN_BMPString
& param
)
209 SetTag(H225_Content::e_unicode
);
210 PASN_BMPString
& val
= *this;
214 H460_FeatureContent::H460_FeatureContent(BOOL param
)
216 SetTag(H225_Content::e_bool
);
217 PASN_Boolean
& val
= *this;
221 H460_FeatureContent::H460_FeatureContent(unsigned param
, unsigned len
)
226 SetTag(H225_Content::e_number8
);
227 PASN_Integer
& val
= *this;
228 val
.SetConstraints(PASN_Object::FixedConstraint
, 0, 255);
231 else if (len
== 16) {
232 SetTag(H225_Content::e_number16
);
233 PASN_Integer
& val
= *this;
234 val
.SetConstraints(PASN_Object::FixedConstraint
, 0, 65535);
237 else if (len
== 32) {
238 SetTag(H225_Content::e_number32
);
239 PASN_Integer
& val
= *this;
240 val
.SetConstraints(PASN_Object::FixedConstraint
, 0, 4294967295U);
244 SetTag(H225_Content::e_number8
);
245 PASN_Integer
& val
= *this;
246 val
.SetConstraints(PASN_Object::FixedConstraint
, 0, 255);
251 H460_FeatureContent::H460_FeatureContent(const H460_FeatureID
& id
)
253 SetTag(H225_Content::e_id
);
254 H225_GenericIdentifier
& val
= *this;
258 H460_FeatureContent::H460_FeatureContent(const H225_AliasAddress
& add
)
260 SetTag(H225_Content::e_alias
);
261 H225_AliasAddress
& val
= *this;
265 H460_FeatureContent::H460_FeatureContent(const PURL
& add
)
268 H225_AliasAddress
* alias
= new H225_AliasAddress();
270 alias
->SetTag(H225_AliasAddress::e_url_ID
);
271 PASN_IA5String
& url
= *alias
;
272 url
= add
.AsString();
274 SetTag(H225_Content::e_alias
);
275 H225_AliasAddress
& val
= *this;
279 H460_FeatureContent::H460_FeatureContent(const H323TransportAddress
& add
)
281 SetTag(H225_Content::e_transport
);
282 H225_TransportAddress
& val
= *this;
286 H460_FeatureContent::H460_FeatureContent(const H460_FeatureTable
& table
)
288 SetTag(H225_Content::e_compound
);
289 H225_ArrayOf_EnumeratedParameter
& val
= *this;
290 val
.SetConstraints(PASN_Object::FixedConstraint
, 1, 512);
294 H460_FeatureContent::H460_FeatureContent(H460_Feature
* add
)
296 SetTag(H225_Content::e_nested
);
297 H225_ArrayOf_GenericData
& val
= *this;
298 val
.SetConstraints(PASN_Object::FixedConstraint
, 1, 16);
300 val
.SetSize(val
.GetSize()+1);
303 H460_FeatureContent::H460_FeatureContent(const H225_Content
& param
)
305 OnReceivedPDU(param
);
308 /////////////////////////////////////////////////////////////////////
310 H460_FeatureParameter::H460_FeatureParameter()
312 m_id
= H460_FeatureID(0);
315 H460_FeatureParameter::H460_FeatureParameter(unsigned Identifier
)
317 m_id
= H460_FeatureID(Identifier
);
320 H460_FeatureParameter::H460_FeatureParameter(const PString
& Identifier
)
322 m_id
= H460_FeatureID(Identifier
);
325 H460_FeatureParameter::H460_FeatureParameter(const OpalOID
& Identifier
)
327 m_id
= H460_FeatureID(Identifier
);
330 H460_FeatureParameter::H460_FeatureParameter(const H225_EnumeratedParameter
& param
)
332 OnReceivedPDU(param
);
335 H460_FeatureParameter::H460_FeatureParameter(const H460_FeatureID
& ID
)
340 H460_FeatureContent
H460_FeatureParameter::operator=( const PASN_OctetString
& value
)
342 m_content
= H460_FeatureContent(*value
);
347 H460_FeatureContent
H460_FeatureParameter::operator=( const PString
& value
)
351 PURL
* url
= new PURL();
352 if (url
->Parse(value
,"http")) // Parameter is an Http Address
353 m_content
= H460_FeatureContent(*url
);
356 if (value
.Find(":") != P_MAX_INDEX
) {
357 PStringArray Cmd
= value
.Tokenise(":", FALSE
);
359 if (Cmd
.GetSize() == 2) { // Parameter is an Address
360 H323TransportAddress
* add
= new H323TransportAddress(Cmd
[0],(short)Cmd
[1].AsUnsigned());
361 m_content
= H460_FeatureContent(*add
);
369 H460_FeatureContent
H460_FeatureParameter::operator=( const PASN_BMPString
& value
)
371 m_content
= H460_FeatureContent(value
);
376 H460_FeatureContent
H460_FeatureParameter::operator=( const BOOL
& value
)
378 m_content
= H460_FeatureContent(value
);
383 H460_FeatureContent
H460_FeatureParameter::operator=( const unsigned & value
)
387 m_content
= H460_FeatureContent(value
,32);
389 m_content
= H460_FeatureContent(value
,8);
390 else if (value
< 256)
391 m_content
= H460_FeatureContent(value
,16);
393 m_content
= H460_FeatureContent(value
,32);
399 H460_FeatureContent
H460_FeatureParameter::operator=( const H460_FeatureID
& value
)
401 m_content
= H460_FeatureContent(value
);
406 H460_FeatureContent
H460_FeatureParameter::operator=( const H225_AliasAddress
& value
)
408 m_content
= H460_FeatureContent(value
);
413 H460_FeatureContent
H460_FeatureParameter::operator=( const H323TransportAddress
& value
)
415 m_content
= H460_FeatureContent(value
);
420 H460_FeatureContent
H460_FeatureParameter::operator=( const H460_FeatureTable
& value
)
422 m_content
= H460_FeatureContent(value
);
427 H460_FeatureContent
H460_FeatureParameter::operator=( H460_Feature
* value
)
429 m_content
= H460_FeatureContent(value
);
434 H460_FeatureParameter::operator PASN_OctetString
&()
436 PASN_OctetString
& content
= m_content
;
440 H460_FeatureParameter::operator PString
&()
442 PASN_IA5String
& content
= m_content
;
443 PString
& con
= *(new PString(content
));
447 H460_FeatureParameter::operator PASN_BMPString
&()
449 PASN_BMPString
& content
= m_content
;
453 H460_FeatureParameter::operator BOOL ()
455 PASN_Boolean
& content
= m_content
;
460 H460_FeatureParameter::operator unsigned()
462 PASN_Integer
& content
= m_content
;
466 H460_FeatureParameter::operator H460_FeatureID
&()
468 H225_GenericIdentifier
& content
= m_content
;
469 return (H460_FeatureID
&)content
;
472 H460_FeatureParameter::operator H225_AliasAddress
&()
474 H225_AliasAddress
& content
= m_content
;
478 H460_FeatureParameter::operator H323TransportAddress
&()
480 H225_TransportAddress
& content
= m_content
;
481 return (H323TransportAddress
&)content
;
485 H460_FeatureParameter::operator H225_ArrayOf_EnumeratedParameter
&()
487 H225_ArrayOf_EnumeratedParameter
& content
= m_content
;
491 H460_FeatureParameter::operator PURL
&()
493 H225_AliasAddress
& content
= m_content
;
495 if (content
.GetTag() == H225_AliasAddress::e_url_ID
) {
496 PASN_IA5String
& Surl
= content
;
497 PURL
& url
= *(new PURL(Surl
));
501 return *(new PURL());
504 /////////////////////////////////////////////////////////////////////
506 H460_FeatureTable::H460_FeatureTable()
510 H460_FeatureTable::H460_FeatureTable(const H225_ArrayOf_EnumeratedParameter
& Xparams
)
512 OnReceivedPDU(Xparams
);
515 H460_FeatureParameter
& H460_FeatureTable::AddParameter(H460_FeatureID
& id
, H460_FeatureContent
& con
)
517 PTRACE(6, "H460\tAdd ID: " << id
<< " content " << con
);
519 H460_FeatureParameter
* Nparam
= new H460_FeatureParameter(id
);
520 Nparam
->addContent(con
);
522 AddParameter(*Nparam
);
527 void H460_FeatureTable::AddParameter(H225_EnumeratedParameter
& Xparam
)
529 if ((GetSize() == 1) &&
530 (!((H225_EnumeratedParameter
*)array
.GetAt(0))->HasOptionalField(0)))
531 array
.SetAt(0, &Xparam
);
536 //void H460_FeatureTable::SetParameter(H460_FeatureParameter & Nparam, H225_EnumeratedParameter & Xparam) const
538 // Nparam.OnSendingPDU(Xparam);
541 H460_FeatureParameter
& H460_FeatureTable::GetParameter(PINDEX id
)
543 return (H460_FeatureParameter
&)*array
.GetAt(id
);
546 H460_FeatureParameter
& H460_FeatureTable::GetParameter(const H460_FeatureID
& id
)
549 PINDEX num
= GetParameterIndex(id
);
552 return GetParameter(num
);
554 return *(new H460_FeatureParameter());
558 PINDEX
H460_FeatureTable::GetParameterIndex(const H460_FeatureID
& id
)
562 for (i
= 0; i
< GetSize(); i
++) {
563 H460_FeatureParameter
& fparam
= (H460_FeatureParameter
&)array
[i
];
564 H460_FeatureID param
= fparam
.ID();
572 BOOL
H460_FeatureTable::HasParameter(const H460_FeatureID
& id
) {
574 PTRACE(6, "H460\tCheck has Parameter " << id
);
576 if (GetParameterIndex(id
) < GetSize())
583 void H460_FeatureTable::RemoveParameter(PINDEX id
)
588 void H460_FeatureTable::RemoveParameter(const H460_FeatureID
& id
)
590 PINDEX j
= GetParameterIndex(id
);
597 void H460_FeatureTable::ReplaceParameter(const H460_FeatureID
& id
, H460_FeatureContent
& con
)
600 PTRACE(6, "H460\tReplace ID: " << id
<< " content " << con
);
602 PINDEX j
= GetParameterIndex(id
);
607 // array.RemoveAt(j);
609 H460_FeatureParameter
* Nparam
= new H460_FeatureParameter(id
);
610 Nparam
->addContent(con
);
612 array
.SetAt(j
,Nparam
);
616 BOOL
H460_FeatureTable::ParameterIsUnique(const H460_FeatureID
& id
)
621 for (i
= 0; i
< GetSize(); i
++) {
622 H460_FeatureParameter
& param
= GetParameter(i
);
624 if (param
.ID() == id
) {
634 H460_FeatureParameter
& H460_FeatureTable::operator[](PINDEX id
)
636 return GetParameter(id
);
639 /////////////////////////////////////////////////////////////////////
641 H460_Feature::H460_Feature()
642 : CurrentTable((H460_FeatureTable
*)&m_parameters
)
644 // IncludeOptionalField(e_parameters);
645 // CurrentTable = (H460_FeatureTable*)&m_parameters;
648 FeatureCategory
= FeatureSupported
;
651 H460_Feature::H460_Feature(unsigned identifier
)
652 : CurrentTable((H460_FeatureTable
*)&m_parameters
)
654 SetFeatureID(H460_FeatureID(identifier
));
655 // IncludeOptionalField(e_parameters);
656 // CurrentTable = (H460_FeatureTable*)&m_parameters;
659 FeatureCategory
= FeatureSupported
;
662 H460_Feature::H460_Feature(PString identifier
)
663 : CurrentTable((H460_FeatureTable
*)&m_parameters
)
665 SetFeatureID(H460_FeatureID(identifier
));
666 // IncludeOptionalField(e_parameters);
667 // CurrentTable = (H460_FeatureTable*)&m_parameters;
670 FeatureCategory
= FeatureSupported
;
673 H460_Feature::H460_Feature(OpalOID identifier
)
674 : CurrentTable((H460_FeatureTable
*)&m_parameters
)
676 SetFeatureID(H460_FeatureID(identifier
));
677 // IncludeOptionalField(e_parameters);
678 // CurrentTable = (H460_FeatureTable *)&m_parameters;
681 FeatureCategory
= FeatureSupported
;
685 H460_Feature::H460_Feature(const H225_FeatureDescriptor
& descriptor
)
687 CurrentTable
= (H460_FeatureTable
*)&m_parameters
;
688 OnReceivedPDU(descriptor
);
693 PString
H460_Feature::GetFeatureIDAsString()
695 return ((H460_FeatureID
)m_id
).IDString();
698 H460_FeatureParameter
& H460_Feature::AddParameter(H460_FeatureID
* id
, H460_FeatureContent
& con
)
700 if (!HasOptionalField(e_parameters
)) {
701 IncludeOptionalField(e_parameters
);
702 CurrentTable
= (H460_FeatureTable
*)&m_parameters
;
704 return CurrentTable
->AddParameter(*id
, con
);
707 void H460_Feature::AddParameter(H460_FeatureParameter
* param
)
709 if (!HasOptionalField(e_parameters
)) {
710 IncludeOptionalField(e_parameters
);
711 CurrentTable
= (H460_FeatureTable
*)&m_parameters
;
714 CurrentTable
->AddParameter(*param
);
717 void H460_Feature::RemoveParameter(PINDEX id
)
719 CurrentTable
->RemoveParameter(id
);
721 if (CurrentTable
->ParameterCount() == 0) {
722 RemoveOptionalField(e_parameters
);
726 void H460_Feature::ReplaceParameter(H460_FeatureID id
, H460_FeatureContent
& con
)
728 CurrentTable
->ReplaceParameter(id
,con
);
731 H460_FeatureParameter
& H460_Feature::GetFeatureParameter(PINDEX id
)
733 return CurrentTable
->GetParameter(id
);
736 H460_FeatureParameter
& H460_Feature::GetFeatureParameter(const H460_FeatureID
& id
)
738 return CurrentTable
->GetParameter(id
);
741 BOOL
H460_Feature::HasFeatureParameter(const H460_FeatureID
& id
)
743 return CurrentTable
->HasParameter(id
);
746 BOOL
H460_Feature::Contains(const H460_FeatureID
& id
)
748 PTRACE(6, "H460\tCheck for Parameter " << id
);
750 if (HasOptionalField(e_parameters
)) {
751 H460_FeatureTable
& Table
= (H460_FeatureTable
&)m_parameters
;
752 if (Table
.HasParameter(id
))
759 H460_FeatureParameter
& H460_Feature::Value(const H460_FeatureID
& id
)
761 if (HasOptionalField(e_parameters
)) {
762 H460_FeatureTable
& Table
= (H460_FeatureTable
&)m_parameters
;
763 if (Table
.HasParameter(id
))
764 return Table
.GetParameter(id
);
767 return *(new H460_FeatureParameter());
770 H460_FeatureParameter
& H460_Feature::operator()(PINDEX id
)
772 return CurrentTable
->GetParameter(id
);
775 H460_FeatureParameter
& H460_Feature::operator()(const H460_FeatureID
& id
)
777 return GetFeatureParameter(id
);
780 H460_FeatureTable
& H460_Feature::GetCurrentTable()
782 return *CurrentTable
;
785 void H460_Feature::SetCurrentTable(H460_FeatureTable
& table
)
787 CurrentTable
= &table
;
790 void H460_Feature::SetCurrentTable(H460_FeatureParameter
& param
)
792 H225_ArrayOf_EnumeratedParameter
& table
= param
;
793 SetCurrentTable((H460_FeatureTable
&)table
);
796 void H460_Feature::SetDefaultTable()
798 CurrentTable
= (H460_FeatureTable
*)&m_parameters
;
801 void H460_Feature::AttachEndPoint(H323EndPoint
* _ep
)
806 void H460_Feature::AttachConnection(H323Connection
* _con
)
811 /////////////////////////////////////////////////////////////////////
813 static const char H460FeaturePluginBaseClass
[] = "H460_Feature";
815 template <> H460_Feature
* PDevicePluginFactory
<H460_Feature
>::Worker::Create(const PString
& type
) const
817 return H460_Feature::CreateFeature(type
);
820 PStringList
H460_Feature::GetFeatureNames(PPluginManager
* pluginMgr
)
822 if (pluginMgr
== NULL
)
823 pluginMgr
= &PPluginManager::GetPluginManager();
825 return pluginMgr
->GetPluginsProviding(H460FeaturePluginBaseClass
);
828 PStringList
H460_Feature::GetFeatureFriendlyNames(const PString
& feature
, PPluginManager
* pluginMgr
)
830 if (pluginMgr
== NULL
)
831 pluginMgr
= &PPluginManager::GetPluginManager();
833 return pluginMgr
->GetPluginsDeviceNames(feature
, H460FeaturePluginBaseClass
);
836 H460_Feature
* H460_Feature::CreateFeature(const PString
& featurename
, int pduType
, PPluginManager
* pluginMgr
)
838 if (pluginMgr
== NULL
)
839 pluginMgr
= &PPluginManager::GetPluginManager();
841 return (H460_Feature
*)pluginMgr
->CreatePluginsDeviceByName(featurename
, H460FeaturePluginBaseClass
,pduType
);
845 /////////////////////////////////////////////////////////////////////
847 H460_FeatureStd::H460_FeatureStd(unsigned Identifier
)
848 : H460_Feature(Identifier
)
852 H460_FeatureParameter
& H460_FeatureStd::Add(unsigned id
, H460_FeatureContent
& con
)
854 return AddParameter(new H460_FeatureID(id
),con
);
857 void H460_FeatureStd::Remove(unsigned id
)
859 RemoveParameter(H460_FeatureID(id
));
862 void H460_FeatureStd::Replace(unsigned id
, H460_FeatureContent
& con
)
864 ReplaceParameter(H460_FeatureID(id
),con
);
867 BOOL
H460_FeatureStd::HasParameter(unsigned id
)
869 return HasFeatureParameter(H460_FeatureID(id
));
872 H460_FeatureParameter
& H460_FeatureStd::GetParameter(unsigned id
)
874 return GetFeatureParameter(H460_FeatureID(id
));
878 /////////////////////////////////////////////////////////////////////
880 H460_FeatureNonStd::H460_FeatureNonStd(PString Identifier
)
881 : H460_Feature(Identifier
)
885 H460_FeatureParameter
& H460_FeatureNonStd::Add(PString id
, H460_FeatureContent
& con
)
887 return AddParameter(new H460_FeatureID(id
),con
);
890 void H460_FeatureNonStd::Remove(PString id
)
892 RemoveParameter(H460_FeatureID(id
));
895 void H460_FeatureNonStd::Replace(PString id
, H460_FeatureContent
& con
)
897 ReplaceParameter(H460_FeatureID(id
),con
);
900 BOOL
H460_FeatureNonStd::HasParameter(PString id
)
902 return HasFeatureParameter(H460_FeatureID(id
));
905 H460_FeatureParameter
& H460_FeatureNonStd::operator[](PString id
)
907 return GetFeatureParameter(H460_FeatureID(id
));
910 /////////////////////////////////////////////////////////////////////
912 H460_FeatureOID::H460_FeatureOID(OpalOID Identifier
)
913 : H460_Feature(Identifier
)
917 H460_FeatureParameter
& H460_FeatureOID::Add(const PString
& id
, H460_FeatureContent
& con
)
919 PString val
= GetBase() + "." + id
;
920 return AddParameter(new H460_FeatureID(OpalOID(val
)),con
);
923 void H460_FeatureOID::Remove(const PString
& id
)
925 PString val
= GetBase() + "." + id
;
926 RemoveParameter(H460_FeatureID(OpalOID(val
)));
929 void H460_FeatureOID::Replace(const PString
& id
, H460_FeatureContent
& con
)
931 PString val
= GetBase() + "." + id
;
932 ReplaceParameter(H460_FeatureID(OpalOID(val
)),con
);
936 BOOL
H460_FeatureOID::HasParameter(OpalOID id
)
938 return HasFeatureParameter(H460_FeatureID(id
));
942 H460_FeatureParameter
& H460_FeatureOID::operator[](OpalOID id
)
944 PString val
= GetBase() + "." + id
.AsString();
945 return GetFeatureParameter(H460_FeatureID(OpalOID(val
)));
948 BOOL
H460_FeatureOID::Contains(const PString
& id
)
950 PString val
= GetBase() + "." + id
;
951 return H460_Feature::Contains(OpalOID(val
));
954 H460_FeatureParameter
& H460_FeatureOID::Value(const PString
& id
)
956 PString val
= GetBase() + "." + id
;
957 return H460_Feature::Value(OpalOID(val
));
960 PString
H460_FeatureOID::GetBase()
962 OpalOID id
= (H460_FeatureID
)m_id
;
963 return id
.AsString();
966 /////////////////////////////////////////////////////////////////////
967 H460_FeatureSet::H460_FeatureSet()
973 H460_FeatureSet::H460_FeatureSet(H460_FeatureSet
* _base
)
975 Features
.DisallowDeleteObjects(); // Derived FeatureSets should not delete Objects.
976 AttachBaseFeatureSet(_base
);
977 AttachEndPoint(_base
->GetEndPoint());
980 H460_FeatureSet::H460_FeatureSet(const H225_FeatureSet
& fs
)
982 Features
.DisallowDeleteObjects(); // Built FeatureSet should not delete Objects.
985 CreateFeatureSet(fs
);
988 H460_FeatureSet::H460_FeatureSet(const H225_ArrayOf_GenericData
& generic
)
990 Features
.DisallowDeleteObjects(); // Built FeatureSet should not delete Objects.
994 for (PINDEX i
=0; i
< generic
.GetSize(); i
++) {
995 AddFeature((H460_Feature
*)&generic
[i
]);
999 BOOL
H460_FeatureSet::ProcessFirstPDU(const H225_FeatureSet
& fs
)
1002 PTRACE(6,"H460\tCreate Common FeatureSet");
1004 H460_FeatureSet remote
= H460_FeatureSet(fs
);
1006 /// Remove the features the remote does not support.
1007 for (PINDEX i
=0; i
< Features
.GetSize(); i
++) {
1008 H460_Feature
& feat
= Features
.GetDataAt(i
);
1009 H460_FeatureID id
= feat
.GetFeatureID();
1010 if (!remote
.HasFeature(id
))
1013 PTRACE(4,"H460\tUse Common Feature " << id
);
1020 BOOL
H460_FeatureSet::CreateFeatureSet(const H225_FeatureSet
& fs
)
1022 PTRACE(6,"H460\tCreate FeatureSet from FeatureSet PDU");
1024 if (fs
.HasOptionalField(H225_FeatureSet::e_neededFeatures
)) {
1025 const H225_ArrayOf_FeatureDescriptor
& fsn
= fs
.m_neededFeatures
;
1026 for (PINDEX i
=0; i
< fsn
.GetSize(); i
++) {
1027 AddFeature((H460_Feature
*)&fsn
[i
]);
1031 if (fs
.HasOptionalField(H225_FeatureSet::e_desiredFeatures
)) {
1032 const H225_ArrayOf_FeatureDescriptor
& fsd
= fs
.m_desiredFeatures
;
1033 for (PINDEX i
=0; i
< fsd
.GetSize(); i
++) {
1034 AddFeature((H460_Feature
*)&fsd
[i
]);
1038 if (fs
.HasOptionalField(H225_FeatureSet::e_supportedFeatures
)) {
1039 const H225_ArrayOf_FeatureDescriptor
& fss
= fs
.m_supportedFeatures
;
1040 for (PINDEX i
=0; i
< fss
.GetSize(); i
++) {
1041 AddFeature((H460_Feature
*)&fss
[i
]);
1048 BOOL
H460_FeatureSet::LoadFeatureSet(int inst
, H323Connection
* con
)
1051 PStringList features
= H460_Feature::GetFeatureNames();
1053 for (PINDEX i
= 0; i
< features
.GetSize(); i
++) {
1056 H460_Feature
* feat
= NULL
;
1057 if (baseSet
&& baseSet
->HasFeature(features
[i
])) {
1058 H460_Feature
* tempfeat
= baseSet
->GetFeature(features
[i
]);
1059 if ((tempfeat
->GetPurpose() >= inst
) && (tempfeat
->GetPurpose() < inst
*2))
1062 feat
= H460_Feature::CreateFeature(features
[i
],inst
);
1064 feat
->AttachEndPoint(ep
);
1069 feat
->AttachConnection(con
);
1072 PTRACE(4,"H460\tLoaded Feature " << features
[i
]);
1079 BOOL
H460_FeatureSet::LoadFeature(const PString
& featid
)
1082 H460_Feature
* newfeat
= H460_Feature::CreateFeature(featid
);
1084 if (newfeat
!= NULL
)
1085 return AddFeature(newfeat
);
1090 H460_FeatureSet
& H460_FeatureSet::DeriveNewFeatureSet()
1092 H460_FeatureSet
* feat
= new H460_FeatureSet(this) ;
1097 BOOL
H460_FeatureSet::AddFeature(H460_Feature
* Nfeat
)
1100 PTRACE(4, "H460\tLoaded " << Nfeat
->GetFeatureIDAsString());
1102 return Features
.SetAt(Nfeat
->GetFeatureID(),Nfeat
);
1106 void H460_FeatureSet::RemoveFeature(H460_FeatureID id
)
1109 info
<< "H460\t Removed ";
1110 switch (id
.GetFeatureType()) {
1111 case H460_FeatureID::e_standard
:
1112 info
<< "Std Feature " << (unsigned)id
<< "\n";
1114 case H460_FeatureID::e_oid
:
1115 info
<< "OID Feature " << (OpalOID
)id
<< "\n";
1117 case H460_FeatureID::e_nonStandard
:
1118 info
<< "NonStd Feature " << ((H225_GloballyUniqueID
&)(id
)).AsString() << "\n";
1123 Features
.RemoveAt(id
);
1128 PString
featureType(PINDEX id
)
1131 case 1: return "Needed";
1132 case 2: return "Desired";
1133 case 3: return "Supported";
1134 default: return "?";
1139 BOOL
H460_FeatureSet::CreateFeatureSetPDU(H225_FeatureSet
& fs
, unsigned MessageID
)
1141 PTRACE(6,"H460\tCreate FeatureSet " << PTracePDU(MessageID
) << " PDU");
1143 BOOL buildPDU
= FALSE
;
1145 for (PINDEX i
= 0; i
< Features
.GetSize(); i
++) { // Iterate thro the features
1146 H460_Feature
& feat
= Features
.GetDataAt(i
);
1147 PTRACE(6,"H460\tExamining " << feat
.GetFeatureIDAsString());
1150 H225_FeatureDescriptor featdesc
;
1151 if (CreateFeaturePDU(feat
,featdesc
,MessageID
)) {
1154 PTRACE(6,"H460\tLoading Feature " << feat
.GetFeatureIDAsString() << " as "
1155 << featureType(feat
.FeatureCategory
) << " feature to " << PTracePDU(MessageID
)
1156 << " PDU\n" << featdesc
);
1159 /// For some completely silly reason the ITU decided to send/receive H460 Messages in two places,
1160 /// for some messages it is included in the messsage body FeatureSet (to Advertise it) and others
1161 /// in the genericData field (as actual information). Even though a Feature is generic data. It is beyond
1162 /// me to determine Why it is so. Anyway if a message is to be carried in the genericData field it is given
1163 /// the default category of supported.
1166 switch (MessageID
) {
1167 case H460_MessageType::e_gatekeeperRequest
:
1168 case H460_MessageType::e_gatekeeperConfirm
:
1169 case H460_MessageType::e_gatekeeperReject
:
1170 case H460_MessageType::e_registrationRequest
:
1171 case H460_MessageType::e_registrationConfirm
:
1172 case H460_MessageType::e_registrationReject
:
1173 case H460_MessageType::e_setup
:
1174 case H460_MessageType::e_callProceeding
:
1175 cat
= feat
.FeatureCategory
;
1178 cat
= H460_Feature::FeatureSupported
;
1182 switch (cat
) { // Add it to the correct feature list
1183 case H460_Feature::FeatureNeeded
:
1185 if (featdesc
.GetDataLength() > 0) {
1186 if (!fs
.HasOptionalField(H225_FeatureSet::e_neededFeatures
))
1187 fs
.IncludeOptionalField(H225_FeatureSet::e_neededFeatures
);
1189 H225_ArrayOf_FeatureDescriptor
& fsn
= fs
.m_neededFeatures
;
1190 lastPos
= fsn
.GetSize();
1191 fsn
.SetSize(lastPos
+1);
1192 fsn
[lastPos
] = featdesc
;
1196 case H460_Feature::FeatureDesired
:
1198 if (featdesc
.GetDataLength() > 0) {
1199 if (!fs
.HasOptionalField(H225_FeatureSet::e_desiredFeatures
))
1200 fs
.IncludeOptionalField(H225_FeatureSet::e_desiredFeatures
);
1202 H225_ArrayOf_FeatureDescriptor
& fsd
= fs
.m_desiredFeatures
;
1203 lastPos
= fsd
.GetSize();
1204 fsd
.SetSize(lastPos
+1);
1205 fsd
[lastPos
] = featdesc
;
1209 case H460_Feature::FeatureSupported
:
1211 if (featdesc
.GetDataLength() > 0) {
1212 if (!fs
.HasOptionalField(H225_FeatureSet::e_supportedFeatures
))
1213 fs
.IncludeOptionalField(H225_FeatureSet::e_supportedFeatures
);
1215 H225_ArrayOf_FeatureDescriptor
& fss
= fs
.m_supportedFeatures
;
1216 lastPos
= fss
.GetSize();
1217 fss
.SetSize(lastPos
+1);
1218 fss
[lastPos
] = featdesc
;
1225 PTRACE(4,"H460\tFeatureSet for " << PTracePDU(MessageID
) << " PDU\n" << fs
);
1230 void H460_FeatureSet::ReadFeatureSetPDU(const H225_FeatureSet
& fs
, unsigned MessageID
)
1233 PTRACE(6,"H460\tRead FeatureSet " << PTracePDU(MessageID
) << " PDU");
1235 // Generate Common Set of Features.
1236 switch (MessageID
) {
1237 case H460_MessageType::e_gatekeeperRequest
:
1238 case H460_MessageType::e_gatekeeperConfirm
:
1239 case H460_MessageType::e_registrationRequest
:
1240 case H460_MessageType::e_registrationConfirm
:
1241 case H460_MessageType::e_setup
:
1242 case H460_MessageType::e_callProceeding
:
1243 ProcessFirstPDU(fs
);
1251 if (fs
.HasOptionalField(H225_FeatureSet::e_neededFeatures
)) {
1252 const H225_ArrayOf_FeatureDescriptor
& fsn
= fs
.m_neededFeatures
;
1253 for (PINDEX i
=0; i
< fsn
.GetSize(); i
++) {
1254 H225_FeatureDescriptor
& fd
= fsn
[i
];
1255 ID
= GetFeatureIDPDU(fd
);
1258 ReadFeaturePDU(Features
[ID
],fd
,MessageID
);
1262 if (fs
.HasOptionalField(H225_FeatureSet::e_desiredFeatures
)) {
1263 const H225_ArrayOf_FeatureDescriptor
& fsd
= fs
.m_desiredFeatures
;
1264 for (PINDEX i
=0; i
< fsd
.GetSize(); i
++) {
1265 H225_FeatureDescriptor
& fd
= fsd
[i
];
1266 ID
= GetFeatureIDPDU(fd
);
1269 ReadFeaturePDU(Features
[ID
],fd
,MessageID
);
1273 if (fs
.HasOptionalField(H225_FeatureSet::e_supportedFeatures
)) {
1274 const H225_ArrayOf_FeatureDescriptor
& fss
= fs
.m_supportedFeatures
;
1275 for (PINDEX i
=0; i
< fss
.GetSize(); i
++) {
1276 H225_FeatureDescriptor
& fd
= fss
[i
];
1277 ID
= GetFeatureIDPDU(fd
);
1280 ReadFeaturePDU(Features
[ID
],fd
,MessageID
);
1285 H460_FeatureID
H460_FeatureSet::GetFeatureIDPDU(H225_FeatureDescriptor
& pdu
)
1289 H225_GenericIdentifier
& id
= pdu
.m_id
;
1291 if ((id
.GetTag() == H225_GenericIdentifier::e_standard
)) {
1292 PASN_Integer
& sid
= id
;
1293 unsigned iid
= sid
.GetValue();
1294 fid
= H460_FeatureID(iid
);
1297 if ((id
.GetTag() == H225_GenericIdentifier::e_oid
)) {
1298 PASN_ObjectId
& oid
= id
;
1299 OpalOID
& aid
= (OpalOID
&)oid
;
1300 fid
= H460_FeatureID(aid
);
1304 if ((id
.GetTag() == H225_GenericIdentifier::e_nonStandard
)) {
1305 H225_GloballyUniqueID
& uns
= id
;
1306 PString uid
= uns
.AsString();
1307 fid
= H460_FeatureID(uid
);
1313 BOOL
H460_FeatureSet::CreateFeaturePDU(H460_Feature
& Feat
, H225_FeatureDescriptor
& pdu
,unsigned MessageID
)
1316 PTRACE(6,"H460\tEncoding " << PTracePDU(MessageID
) << " PDU for " << Feat
.GetFeatureIDAsString() );
1318 switch (MessageID
) {
1319 case H460_MessageType::e_gatekeeperRequest
:
1320 return Feat
.OnSendGatekeeperRequest(pdu
);
1322 case H460_MessageType::e_gatekeeperConfirm
:
1323 return Feat
.OnSendGatekeeperConfirm(pdu
);
1325 case H460_MessageType::e_gatekeeperReject
:
1326 return Feat
.OnSendGatekeeperReject(pdu
);
1328 case H460_MessageType::e_registrationRequest
:
1329 return Feat
.OnSendRegistrationRequest(pdu
);
1331 case H460_MessageType::e_registrationConfirm
:
1332 return Feat
.OnSendRegistrationConfirm(pdu
);
1334 case H460_MessageType::e_registrationReject
:
1335 return Feat
.OnSendRegistrationReject(pdu
);
1337 case H460_MessageType::e_admissionRequest
:
1338 return Feat
.OnSendAdmissionRequest(pdu
);
1340 case H460_MessageType::e_admissionConfirm
:
1341 return Feat
.OnSendAdmissionConfirm(pdu
);
1343 case H460_MessageType::e_admissionReject
:
1344 return Feat
.OnSendAdmissionReject(pdu
);
1346 case H460_MessageType::e_locationRequest
:
1347 return Feat
.OnSendLocationRequest(pdu
);
1349 case H460_MessageType::e_locationConfirm
:
1350 return Feat
.OnSendLocationConfirm(pdu
);
1352 case H460_MessageType::e_locationReject
:
1353 return Feat
.OnSendLocationReject(pdu
);
1355 case H460_MessageType::e_nonStandardMessage
:
1356 return Feat
.OnSendNonStandardMessage(pdu
);
1358 case H460_MessageType::e_serviceControlIndication
:
1359 return Feat
.OnSendServiceControlIndication(pdu
);
1361 case H460_MessageType::e_serviceControlResponse
:
1362 return Feat
.OnSendServiceControlResponse(pdu
);
1364 case H460_MessageType::e_Endpoint:
1365 return Feat.OnSendEndpoint(pdu);
1367 case H460_MessageType::e_setup
:
1368 return Feat
.OnSendSetup_UUIE(pdu
);
1370 case H460_MessageType::e_alerting
:
1371 return Feat
.OnSendAlerting_UUIE(pdu
);
1373 case H460_MessageType::e_callProceeding
:
1374 return Feat
.OnSendCallProceeding_UUIE(pdu
);
1376 case H460_MessageType::e_connect
:
1377 return Feat
.OnSendCallConnect_UUIE(pdu
);
1379 case H460_MessageType::e_facility
:
1380 return Feat
.OnSendFacility_UUIE(pdu
);
1382 case H460_MessageType::e_releaseComplete
:
1383 return Feat
.OnSendReleaseComplete_UUIE(pdu
);
1386 return Feat
.OnSendUnAllocatedPDU(pdu
);
1392 void H460_FeatureSet::ReadFeaturePDU(H460_Feature
& Feat
, const H225_FeatureDescriptor
& pdu
,unsigned MessageID
)
1395 PTRACE(6,"H460\tDecoding " << PTracePDU(MessageID
) << " PDU for " << Feat
.GetFeatureIDAsString() );
1397 switch (MessageID
) {
1398 case H460_MessageType::e_gatekeeperRequest
:
1399 Feat
.OnReceiveGatekeeperRequest(pdu
);
1402 case H460_MessageType::e_gatekeeperConfirm
:
1403 Feat
.OnReceiveGatekeeperConfirm(pdu
);
1405 case H460_MessageType::e_gatekeeperReject
:
1406 Feat
.OnReceiveGatekeeperReject(pdu
);
1408 case H460_MessageType::e_registrationRequest
:
1409 Feat
.OnReceiveRegistrationRequest(pdu
);
1411 case H460_MessageType::e_registrationConfirm
:
1412 Feat
.OnReceiveRegistrationConfirm(pdu
);
1414 case H460_MessageType::e_registrationReject
:
1415 Feat
.OnReceiveRegistrationReject(pdu
);
1417 case H460_MessageType::e_admissionRequest
:
1418 Feat
.OnReceiveAdmissionRequest(pdu
);
1420 case H460_MessageType::e_admissionConfirm
:
1421 Feat
.OnReceiveAdmissionConfirm(pdu
);
1423 case H460_MessageType::e_admissionReject
:
1424 Feat
.OnReceiveAdmissionReject(pdu
);
1426 case H460_MessageType::e_locationRequest
:
1427 Feat
.OnReceiveLocationRequest(pdu
);
1429 case H460_MessageType::e_locationConfirm
:
1430 Feat
.OnReceiveLocationConfirm(pdu
);
1432 case H460_MessageType::e_locationReject
:
1433 Feat
.OnReceiveLocationReject(pdu
);
1435 case H460_MessageType::e_nonStandardMessage
:
1436 Feat
.OnReceiveNonStandardMessage(pdu
);
1438 case H460_MessageType::e_serviceControlIndication
:
1439 Feat
.OnReceiveServiceControlIndication(pdu
);
1441 case H460_MessageType::e_serviceControlResponse
:
1442 Feat
.OnReceiveServiceControlResponse(pdu
);
1444 // case H460_MessageType::e_Endpoint:
1445 // return Feat.OnReceiveEndpoint(pdu);
1447 case H460_MessageType::e_setup
:
1448 Feat
.OnReceiveSetup_UUIE(pdu
);
1450 case H460_MessageType::e_alerting
:
1451 Feat
.OnReceiveAlerting_UUIE(pdu
);
1453 case H460_MessageType::e_callProceeding
:
1454 Feat
.OnReceiveCallProceeding_UUIE(pdu
);
1456 case H460_MessageType::e_connect
:
1457 Feat
.OnReceiveCallConnect_UUIE(pdu
);
1459 case H460_MessageType::e_facility
:
1460 Feat
.OnReceiveFacility_UUIE(pdu
);
1462 case H460_MessageType::e_releaseComplete
:
1463 Feat
.OnReceiveReleaseComplete_UUIE(pdu
);
1466 Feat
.OnReceivedUnAllocatedPDU(pdu
);
1470 PString
H460_FeatureSet::PTracePDU(PINDEX id
) const
1473 case H460_MessageType::e_gatekeeperRequest
: return "GK Request";
1474 case H460_MessageType::e_gatekeeperConfirm
: return "GK Confirm";
1475 case H460_MessageType::e_gatekeeperReject
: return "GK Reject";
1476 case H460_MessageType::e_registrationRequest
: return "Reg Request";
1477 case H460_MessageType::e_registrationConfirm
: return "Reg Confirm";
1478 case H460_MessageType::e_registrationReject
: return "Reg Reject";
1479 case H460_MessageType::e_admissionRequest
: return "Adm Reqest";
1480 case H460_MessageType::e_admissionConfirm
: return "Adm Confirm";
1481 case H460_MessageType::e_admissionReject
: return "Adm Reject";
1482 case H460_MessageType::e_locationRequest
: return "Loc Request";
1483 case H460_MessageType::e_locationConfirm
: return "Loc Confirm";
1484 case H460_MessageType::e_locationReject
: return "Loc Reject";
1485 case H460_MessageType::e_nonStandardMessage
: return "NonStd";
1486 case H460_MessageType::e_serviceControlIndication
:return "Ctrl Indication";
1487 case H460_MessageType::e_serviceControlResponse
:return "Ctrl Response";
1488 // case H460_MessageType::e_Endpoint :return "Endpoint";
1489 case H460_MessageType::e_setup
:return "Setup";
1490 case H460_MessageType::e_alerting
:return "Alerting";
1491 case H460_MessageType::e_callProceeding
:return "CallProceed";
1492 case H460_MessageType::e_connect
:return "Connect";
1493 case H460_MessageType::e_facility
:return "Facility";
1494 case H460_MessageType::e_releaseComplete
: return "ReleaseComplete";
1495 default: return "?";
1500 void H460_FeatureSet::ReceiveFeature(unsigned id
, const H225_FeatureSet
& Message
)
1502 ReadFeatureSetPDU(Message
,id
);
1505 BOOL
H460_FeatureSet::SendFeature(unsigned id
, H225_FeatureSet
& Message
)
1507 return CreateFeatureSetPDU(Message
,id
);
1510 void H460_FeatureSet::AttachEndPoint(H323EndPoint
* _ep
)
1512 PTRACE(4,"H460\tEndpoint Attached");
1516 void H460_FeatureSet::AttachBaseFeatureSet(H460_FeatureSet
* _baseSet
)
1521 BOOL
H460_FeatureSet::HasFeature(const H460_FeatureID
& id
)
1524 for (PINDEX i
=0; i
< Features
.GetSize(); i
++) {
1525 H460_Feature
& feat
= Features
.GetDataAt(i
);
1526 if (feat
.GetFeatureID() == id
) {
1533 H460_Feature
* H460_FeatureSet::GetFeature(const H460_FeatureID
& id
)
1535 return &Features
[id
];