00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #if !defined(_H460_H)
00060 #define _H460_H
00061
00062
00063 #ifdef P_USE_PRAGMA
00064 #pragma interface
00065 #endif
00066
00067 #include <asn/h225.h>
00068 #include <h323/transaddr.h>
00069 #include <ptlib/pluginmgr.h>
00070 #include <ptclib/url.h>
00071
00072
00073 #ifdef _MSC_VER
00074 #pragma warning(disable:4100)
00075 #endif
00076
00078
00079 template<class H225>
00080 class H460 : public H225 {
00081 public:
00082
00088 virtual void OnReceivedPDU(
00089 const H225 &
00090 ) {};
00091
00096 virtual PBoolean OnSendingPDU(
00097 H225 &
00098 ) const { return PFalse;};
00099
00100 protected:
00101
00102 };
00103
00104 class OpalOID : public PASN_ObjectId
00105 {
00106 public:
00107
00108 OpalOID();
00109
00110 OpalOID(
00111 const char * str
00112 );
00113 };
00114
00115
00116
00118
00128 class H460_FeatureID : public H460<H225_GenericIdentifier>
00129 {
00130
00131 public:
00132
00137 H460_FeatureID();
00138
00141 H460_FeatureID(unsigned ID);
00142
00145 H460_FeatureID(OpalOID ID);
00146
00149 H460_FeatureID(PString ID);
00150
00151 H460_FeatureID(H225_GenericIdentifier ID);
00153
00158 operator unsigned () const
00159 { return ((PASN_Integer *)choice)->GetValue(); };
00160
00163 operator OpalOID & ()
00164 { return (OpalOID &)*choice; };
00165
00168 operator PString () const
00169 { return ((H225_GloballyUniqueID *)choice)->AsString(); };
00170
00171
00172 PINLINE H460_FeatureID & operator=(unsigned ID);
00173
00174 PINLINE H460_FeatureID & operator=(OpalOID ID);
00175
00176 PINLINE H460_FeatureID & operator=(PString ID);
00177
00180 unsigned GetFeatureType() const { return GetTag(); };
00181
00182 PString IDString() const;
00184
00187 PObject * Clone() const;
00188
00189 PObject::Comparison Compare(const PObject & obj) const;
00191
00192 };
00193
00194
00196
00201 class H460_Feature;
00202 class H460_FeatureTable;
00203 class H460_FeatureContent : public H460<H225_Content>
00204 {
00205
00206 public:
00207
00212 H460_FeatureContent();
00213
00217 H460_FeatureContent(PASN_OctetString & param);
00218
00221 H460_FeatureContent(const PString & param);
00222
00225 H460_FeatureContent(PASN_BMPString & param);
00226
00229 H460_FeatureContent(PBoolean param);
00230
00233 H460_FeatureContent(unsigned param, unsigned len);
00234
00237 H460_FeatureContent(const H460_FeatureID & id);
00238
00241 H460_FeatureContent(const H225_AliasAddress & add);
00242
00245 H460_FeatureContent(const PURL & add);
00246
00249 H460_FeatureContent(const H323TransportAddress & add);
00250
00253 H460_FeatureContent(const H460_FeatureTable & table);
00254
00257 H460_FeatureContent(H460_Feature * data);
00258
00261 H460_FeatureContent(const H225_Content & param);
00262
00264
00267 operator PASN_OctetString () const { return *((PASN_OctetString *)choice); };
00268 operator PString () const
00269 {
00270 switch (GetTag()) {
00271 case e_text:
00272 return ((PASN_IA5String &)*choice).GetValue();
00273 case e_transport:
00274 return H323TransportAddress(*(H225_TransportAddress *)choice);
00275 default:
00276 break;
00277 }
00278
00279 return PString();
00280 };
00281
00282 operator PASN_BMPString () const { return *(PASN_BMPString *)choice; };
00283 operator PBoolean () const { return *(PASN_Boolean *)choice; };
00284
00285 operator unsigned () const
00286 {
00287 switch (GetTag()) {
00288 case e_number8:
00289 case e_number16:
00290 case e_number32:
00291 return *(PASN_Integer*)choice;
00292 default:
00293 return 0;
00294 }
00295 }
00296
00297 operator H460_FeatureID () const { return *(H225_GenericIdentifier *)choice; };
00298 operator H225_AliasAddress () const { return *(H225_AliasAddress *)choice; };
00299 operator H323TransportAddress () const { return H323TransportAddress(*(H225_TransportAddress *)choice); };
00300 operator H460_FeatureTable *() { return (H460_FeatureTable *)choice; };
00301 operator H460_Feature *() { return (H460_Feature *)choice; };
00302
00304 };
00305
00307
00312 class H460_Feature;
00313 class H460_FeatureParameter : public H460<H225_EnumeratedParameter>
00314 {
00315
00316 public:
00317
00322 H460_FeatureParameter();
00323
00326 H460_FeatureParameter(unsigned Identifier);
00327
00330 H460_FeatureParameter(const PString & Identifier);
00331
00334 H460_FeatureParameter(const OpalOID & Identifier);
00335
00338 H460_FeatureParameter(const H225_EnumeratedParameter & param);
00339
00342 H460_FeatureParameter(const H460_FeatureID & ID);
00344
00349 const H460_FeatureID ID() { return m_id; };
00350
00353 void addContent(const H460_FeatureContent & con )
00354 { IncludeOptionalField(e_content); m_content = con; };
00355
00358 void replaceContent(const H460_FeatureContent & con )
00359 { if (hasContent())
00360 delete &m_content;
00361 m_content = con; };
00362
00365 PBoolean hasContent()
00366 { return (GetTag() == e_content); };
00367
00369
00370
00373 operator PASN_OctetString &();
00374 operator PString &();
00375 operator PASN_BMPString &();
00376 operator PBoolean ();
00377 operator unsigned ();
00378 operator H460_FeatureID &();
00379 operator H225_AliasAddress &();
00380 operator H323TransportAddress &();
00381 operator H225_ArrayOf_EnumeratedParameter &();
00382 operator PURL &();
00383
00384
00385 H460_FeatureContent operator=(
00386 const PASN_OctetString & value
00387 );
00388
00389 H460_FeatureContent operator=(
00390 const PString & value
00391 );
00392
00393 H460_FeatureContent operator=(
00394 const PASN_BMPString & value
00395 );
00396
00397 H460_FeatureContent operator=(
00398 const PBoolean & value
00399 );
00400
00401 H460_FeatureContent operator=(
00402 const unsigned & value
00403 );
00404
00405 H460_FeatureContent operator=(
00406 const H460_FeatureID & value
00407 );
00408
00409 H460_FeatureContent operator=(
00410 const H225_AliasAddress & value
00411 );
00412
00413 H460_FeatureContent operator=(
00414 const H323TransportAddress & value
00415 );
00416
00417 H460_FeatureContent operator=(
00418 const H460_FeatureTable & value
00419 );
00420
00421 H460_FeatureContent operator=(
00422 H460_Feature * value
00423 );
00424
00425
00426 };
00427
00429
00434 class H460_FeatureTable : public H460<H225_ArrayOf_EnumeratedParameter>
00435
00436 {
00437 public:
00438
00443 H460_FeatureTable();
00444
00447 H460_FeatureTable(const H225_ArrayOf_EnumeratedParameter & Xparams);
00449
00452
00457 H460_FeatureParameter & AddParameter(H460_FeatureID & id, H460_FeatureContent & con);
00458
00462 void AddParameter(H225_EnumeratedParameter & Xparam);
00463
00469 H460_FeatureParameter & GetParameter(PINDEX id);
00470
00477 H460_FeatureParameter & GetParameter(const H460_FeatureID & id);
00478
00483 PINDEX GetParameterIndex(const H460_FeatureID & id);
00484
00489 PBoolean HasParameter(const H460_FeatureID & id);
00490
00495 void RemoveParameter(PINDEX id);
00496
00501 void RemoveParameter(const H460_FeatureID & id);
00502
00507 void ReplaceParameter(const H460_FeatureID & id, H460_FeatureContent & con);
00508
00512 int ParameterCount() { return GetSize(); };
00513
00521 PBoolean ParameterIsUnique(const H460_FeatureID & id);
00522
00525 inline H460_FeatureParameter & operator[](
00526 PINDEX id
00527 ) const { return operator[](id); };
00528
00531 H460_FeatureParameter & operator[](
00532 PINDEX id
00533 );
00535
00536 };
00537
00539
00543 class H323EndPoint;
00544 class H323Connection;
00545 class H460_Feature : public H460<H225_FeatureDescriptor>
00546 {
00547 public:
00550
00553 H460_Feature();
00554
00557 H460_Feature(unsigned Identifier);
00558
00561 H460_Feature(PString Identifier);
00562
00565 H460_Feature(OpalOID Indentifier);
00566
00569 H460_Feature(const H225_FeatureDescriptor & descriptor);
00570
00572
00575
00576 enum {
00577 FeatureNeeded = 1,
00578 FeatureDesired,
00579 FeatureSupported
00580 } FeatureCategory;
00581
00582
00583 enum {
00584 FeatureBase =4,
00585 FeatureBaseAll =5,
00586 FeatureBaseRas =6,
00587 FeatureBaseSignal=7,
00588 FeatureRas =8,
00589 FeatureSignal =16
00590 } FeatureInstance;
00591
00593
00598 operator unsigned () const { return (H460_FeatureID)m_id; };
00599
00602
00603
00606 operator PString () const { return (H460_FeatureID)m_id; };
00607
00610 H460_FeatureID GetFeatureID() { return m_id; };
00611
00614 void SetFeatureID(const H460_FeatureID & id) { m_id = id; };
00615
00618 PString GetFeatureIDAsString();
00619
00622 unsigned GetFeatureType() { return ((H460_FeatureID)m_id).GetFeatureType(); };
00624
00629 virtual H460_FeatureParameter & AddParameter(H460_FeatureID * id, H460_FeatureContent & con);
00630
00633 virtual void AddParameter(H460_FeatureParameter * param);
00634
00637 virtual void RemoveParameter(PINDEX id);
00638
00641 virtual void ReplaceParameter(H460_FeatureID id, H460_FeatureContent & con);
00642
00645 H460_FeatureParameter & GetFeatureParameter(PINDEX id);
00646
00649 H460_FeatureParameter & GetFeatureParameter(const H460_FeatureID & id);
00650
00653 PBoolean HasFeatureParameter(const H460_FeatureID & id);
00654
00657 PBoolean Contains(const H460_FeatureID & id);
00658
00661 H460_FeatureParameter & Value(const H460_FeatureID & id);
00662
00665 inline H460_FeatureParameter & operator()(
00666 PINDEX id
00667 ) const { return operator()(id); };
00668
00669 H460_FeatureParameter & operator()(
00670 PINDEX id
00671 );
00672
00675 inline H460_FeatureParameter & operator[](
00676 const H460_FeatureID & id
00677 ) const { return operator()(id); };
00678
00679 H460_FeatureParameter & operator()(
00680 const H460_FeatureID & id
00681 );
00682
00685 int GetParameterCount()
00686 { return CurrentTable->ParameterCount(); };
00687
00690 H460_FeatureTable & GetCurrentTable();
00691
00694 void SetCurrentTable(H460_FeatureTable & table);
00695
00698 void SetCurrentTable(H460_FeatureParameter & param);
00699
00702 void SetDefaultTable();
00703
00705
00710 static PStringList GetFeatureNames(PPluginManager * pluginMgr = NULL);
00711
00714 static PStringList GetFeatureFriendlyNames(const PString & feature, PPluginManager * pluginMgr = NULL);
00715
00718 static H460_Feature * CreateFeature(const PString & featurename,
00719 int FeatureType = FeatureBase,
00720 PPluginManager * pluginMgr = NULL
00721 );
00724 static PStringList GetFeatureName() { return PStringList("empty"); };
00725
00728 static PStringList GetFeatureFriendlyName() { return PStringList("empty"); };
00729
00733 static int GetPurpose() { return FeatureBase; };
00734
00737 virtual void AttachEndPoint(H323EndPoint * _ep);
00738
00741 virtual void AttachConnection(H323Connection * _con);
00742
00744
00747
00748
00749
00750
00751
00752 virtual PBoolean OnSendGatekeeperRequest(H225_FeatureDescriptor & ) { return PFalse; };
00753 virtual PBoolean OnSendGatekeeperConfirm(H225_FeatureDescriptor & ) { return PFalse; };
00754 virtual PBoolean OnSendGatekeeperReject(H225_FeatureDescriptor & ) { return PFalse; };
00755
00756 virtual void OnReceiveGatekeeperRequest(const H225_FeatureDescriptor & ) {};
00757 virtual void OnReceiveGatekeeperConfirm(const H225_FeatureDescriptor & ) {};
00758 virtual void OnReceiveGatekeeperReject(const H225_FeatureDescriptor & ) {};
00759
00760 virtual PBoolean OnSendRegistrationRequest(H225_FeatureDescriptor & ) { return PFalse; };
00761 virtual PBoolean OnSendRegistrationConfirm(H225_FeatureDescriptor & ) { return PFalse; };
00762 virtual PBoolean OnSendRegistrationReject(H225_FeatureDescriptor & ) { return PFalse; };
00763
00764 virtual void OnReceiveRegistrationRequest(const H225_FeatureDescriptor & ) {};
00765 virtual void OnReceiveRegistrationConfirm(const H225_FeatureDescriptor & ) {};
00766 virtual void OnReceiveRegistrationReject(const H225_FeatureDescriptor & ) {};
00767
00768 virtual PBoolean OnSendAdmissionRequest(H225_FeatureDescriptor & ) { return PFalse; };
00769 virtual PBoolean OnSendAdmissionConfirm(H225_FeatureDescriptor & ) { return PFalse; };
00770 virtual PBoolean OnSendAdmissionReject(H225_FeatureDescriptor & ) { return PFalse; };
00771
00772 virtual void OnReceiveAdmissionRequest(const H225_FeatureDescriptor & ) {};
00773 virtual void OnReceiveAdmissionConfirm(const H225_FeatureDescriptor & ) {};
00774 virtual void OnReceiveAdmissionReject(const H225_FeatureDescriptor & ) {};
00775
00776 virtual PBoolean OnSendLocationRequest(H225_FeatureDescriptor & ) { return PFalse; };
00777 virtual PBoolean OnSendLocationConfirm(H225_FeatureDescriptor & ) { return PFalse; };
00778 virtual PBoolean OnSendLocationReject(H225_FeatureDescriptor & ) { return PFalse; };
00779
00780 virtual void OnReceiveLocationRequest(const H225_FeatureDescriptor & ) {};
00781 virtual void OnReceiveLocationConfirm(const H225_FeatureDescriptor & ) {};
00782 virtual void OnReceiveLocationReject(const H225_FeatureDescriptor & ) {};
00783
00784 virtual PBoolean OnSendServiceControlIndication(H225_FeatureDescriptor & ) { return PFalse; };
00785 virtual PBoolean OnSendServiceControlResponse(H225_FeatureDescriptor & ) { return PFalse; };
00786
00787 virtual void OnReceiveServiceControlIndication(const H225_FeatureDescriptor & ) {};
00788 virtual void OnReceiveServiceControlResponse(const H225_FeatureDescriptor & ) {};
00789
00790
00791 virtual PBoolean OnSendNonStandardMessage(H225_FeatureDescriptor & ) { return PFalse; };
00792 virtual void OnReceiveNonStandardMessage(const H225_FeatureDescriptor & ) {};
00793
00794 virtual PBoolean OnSendEndpoint(H225_FeatureDescriptor & ) { return PFalse; };
00795 virtual void OnReceiveEndpoint(const H225_FeatureDescriptor & ) {};
00797
00800
00801 virtual PBoolean OnSendSetup_UUIE(H225_FeatureDescriptor & ) { return PFalse; };
00802 virtual void OnReceiveSetup_UUIE(const H225_FeatureDescriptor & ) {};
00803
00804 virtual PBoolean OnSendAlerting_UUIE(H225_FeatureDescriptor & ) { return PFalse; };
00805 virtual void OnReceiveAlerting_UUIE(const H225_FeatureDescriptor & ) {};
00806
00807 virtual PBoolean OnSendCallProceeding_UUIE(H225_FeatureDescriptor & ) { return PFalse; };
00808 virtual void OnReceiveCallProceeding_UUIE(const H225_FeatureDescriptor & ) {};
00809
00810 virtual PBoolean OnSendCallConnect_UUIE(H225_FeatureDescriptor & ) { return PFalse; };
00811 virtual void OnReceiveCallConnect_UUIE(const H225_FeatureDescriptor & ) {};
00812
00813 virtual PBoolean OnSendFacility_UUIE(H225_FeatureDescriptor & ) { return PFalse; };
00814 virtual void OnReceiveFacility_UUIE(const H225_FeatureDescriptor & ) {};
00815
00816 virtual PBoolean OnSendReleaseComplete_UUIE(H225_FeatureDescriptor & ) { return PFalse; };
00817 virtual void OnReceiveReleaseComplete_UUIE(const H225_FeatureDescriptor & ) {};
00818
00819 virtual PBoolean OnSendUnAllocatedPDU(H225_FeatureDescriptor & ) { return PFalse; };
00820 virtual void OnReceivedUnAllocatedPDU(const H225_FeatureDescriptor & ) {};
00821
00823
00826
00827
00828
00829
00830
00832
00833 protected:
00834 H460_FeatureTable * CurrentTable;
00835 H323EndPoint * ep;
00836 H323Connection * con;
00837 };
00838
00839 class H460_FeatureStd : public H460_Feature
00840 {
00841 PCLASSINFO(H460_FeatureStd, H460_Feature);
00842 public:
00843
00846 H460_FeatureStd() {};
00847
00850 H460_FeatureStd(unsigned Identifier);
00852
00857 H460_FeatureParameter & Add(unsigned id, H460_FeatureContent & con);
00858
00861 void Remove(unsigned id);
00862
00865 void Replace(unsigned id, H460_FeatureContent & con);
00866
00869 PBoolean HasParameter(unsigned id);
00870
00873 H460_FeatureParameter & GetParameter(unsigned id);
00875
00878 inline H460_FeatureParameter & operator[] (
00879 unsigned id
00880 ) { return GetParameter(id); };
00881
00882 };
00883
00884 class H460_FeatureNonStd : public H460_Feature
00885 {
00886 PCLASSINFO(H460_FeatureNonStd, H460_Feature);
00887 public:
00888
00893 H460_FeatureNonStd(PString Identifier);
00895
00900 H460_FeatureParameter & Add(PString id, H460_FeatureContent & con);
00901
00904 void Remove(PString id);
00905
00908 void Replace(PString id, H460_FeatureContent & con);
00909
00912 PBoolean HasParameter(PString id);
00913
00915
00918 inline H460_FeatureParameter & operator[](
00919 PString id
00920 ) const { return operator[](id); };
00921
00924 H460_FeatureParameter & operator[](
00925 PString id
00926 );
00927
00928 };
00929
00930 class H460_FeatureOID : public H460_Feature
00931 {
00932 PCLASSINFO(H460_FeatureOID, H460_Feature);
00933 public:
00934
00939 H460_FeatureOID(OpalOID Identifier);
00941
00946 H460_FeatureParameter & Add(const PString & id, H460_FeatureContent & con);
00947
00950 void Remove(const PString & id);
00951
00954 void Replace(const PString & id, H460_FeatureContent & con);
00955
00958 PBoolean HasParameter(OpalOID id);
00959
00962 PBoolean Contains(const PString & id);
00963
00966 H460_FeatureParameter & Value(const PString & id);
00967
00969
00972 inline H460_FeatureParameter & operator[](
00973 OpalOID id
00974 ) const { return operator[](id); };
00975
00978 H460_FeatureParameter & operator[](
00979 OpalOID id
00980 );
00981
00982 protected:
00983 PString GetBase();
00984
00985 };
00987
00988
00989 PDICTIONARY(H460_Features, H460_FeatureID , H460_Feature);
00990
00992
00993 class H323EndPoint;
00994 class H460_FeatureSet : public PObject
00995 {
00996 PCLASSINFO(H460_FeatureSet, PObject);
00997 public:
00998
01001 H460_FeatureSet();
01002
01005 H460_FeatureSet(H460_FeatureSet * _base);
01006
01009 H460_FeatureSet(const H225_FeatureSet & fs);
01010
01013 H460_FeatureSet(const H225_ArrayOf_GenericData & generic);
01014
01017 H460_FeatureSet & DeriveNewFeatureSet();
01018
01021 virtual PBoolean LoadFeatureSet(int inst = H460_Feature::FeatureBase,
01022 H323Connection * con = NULL);
01023
01028 PBoolean ProcessFirstPDU(const H225_FeatureSet & fs);
01029
01032 virtual PBoolean CreateFeatureSet(const H225_FeatureSet & fs);
01033
01036 virtual PBoolean LoadFeature(const PString & featid);
01037
01040 PBoolean AddFeature(H460_Feature * Nfeat);
01041
01044 void RemoveFeature(H460_FeatureID id);
01045
01048 H460_Feature * GetFeature(const H460_FeatureID & id);
01049
01052 PBoolean HasFeature(const H460_FeatureID & feat);
01053
01057 void ReceiveFeature(unsigned id, const H225_FeatureSet & Message);
01058
01062 PBoolean SendFeature(unsigned id, H225_FeatureSet & Message);
01063
01066 virtual void AttachEndPoint(H323EndPoint * _ep);
01067
01070 virtual void AttachBaseFeatureSet(H460_FeatureSet * _baseSet);
01071
01074 H323EndPoint * GetEndPoint() { return ep; };
01075
01076 protected:
01077
01078 PBoolean CreateFeatureSetPDU(H225_FeatureSet & fs, unsigned MessageID);
01079
01080 void ReadFeatureSetPDU(const H225_FeatureSet & fs, unsigned MessageID);
01081
01082 H460_FeatureID GetFeatureIDPDU(H225_FeatureDescriptor & pdu);
01083
01084 PBoolean CreateFeaturePDU(H460_Feature & Feat, H225_FeatureDescriptor & pdu, unsigned MessageID);
01085 void ReadFeaturePDU(H460_Feature & Feat, const H225_FeatureDescriptor & pdu, unsigned MessageID);
01086
01087 PString PTracePDU(PINDEX id) const;
01088
01089 H460_Features Features;
01090 H323EndPoint * ep;
01091 H460_FeatureSet * baseSet;
01092
01093 };
01094
01096
01097 template <class className> class H460PluginServiceDescriptor : public PDevicePluginServiceDescriptor
01098 {
01099 public:
01100 virtual PObject * CreateInstance(int ) const { return new className; }
01101 virtual PStringList GetDeviceNames(int ) const { return className::GetFeatureFriendlyName(); }
01102 virtual bool ValidateDeviceName(const PString & deviceName, int userData) const
01103 {
01104 PStringList devices = className::GetFeatureName();
01105 if ((deviceName == devices[0]) &&
01106 (className::GetPurpose() >= userData) &&
01107 (className::GetPurpose() < userData*2)) {
01108
01109 return PTrue;
01110 } else
01111 return PFalse;
01112 }
01113 };
01114
01115 #define H460_FEATURE(name) \
01116 static H460PluginServiceDescriptor<H460_Feature##name> H460_Feature##name##_descriptor; \
01117 PCREATE_PLUGIN(H460_Feature##name##, H460_Feature, &H460_Feature##name##_descriptor); \
01118
01119
01120 #ifdef _MSC_VER
01121 #pragma warning(disable:4100)
01122 #endif
01123
01124 #endif // !defined(_H460_H)
01125